Skip to content

Commit

Permalink
Minor MSVC changes
Browse files Browse the repository at this point in the history
compile basename and dirname for msvc

disable line endings error

define HUGE_VALF if needed

add shell32.lib and winmm.lib to OSLIBS

modify preprocessing for MSVC

add include path to openlibm for fenv.h
  • Loading branch information
tkelman committed Mar 31, 2014
1 parent 86818f1 commit d56088a
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 8 deletions.
4 changes: 2 additions & 2 deletions Make.inc
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ AR := $(CROSS_COMPILE)ar
AS := $(CROSS_COMPILE)as
LD := $(CROSS_COMPILE)ld
else
CPP = $(CC) -P -EP
CPP = $(CC) -EP
AR := lib
ifeq ($(ARCH),x86_64)
AS := ml64
Expand Down Expand Up @@ -499,7 +499,7 @@ ifneq ($(USEMSVC), 1)
OSLIBS += -Wl,--export-all-symbols -Wl,--version-script=$(JULIAHOME)/src/julia.expmap \
$(NO_WHOLE_ARCHIVE) -lpsapi -lkernel32 -lws2_32 -liphlpapi -lwinmm -ldbghelp -lssp
else
OSLIBS += kernel32.lib ws2_32.lib psapi.lib advapi32.lib iphlpapi.lib
OSLIBS += kernel32.lib ws2_32.lib psapi.lib advapi32.lib iphlpapi.lib shell32.lib winmm.lib
endif
JCPPFLAGS += -D_WIN32_WINNT=0x0600
JLDFLAGS = -Wl,--stack,8388608
Expand Down
14 changes: 10 additions & 4 deletions base/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ PCRE_CONST = 0x[0-9a-fA-F]+|[-+]?\s*[0-9]+

TAGGED_RELEASE_BANNER = ""

ifneq ($(USEMSVC), 1)
CPP_STDOUT = $(CPP) -P
else
CPP_STDOUT = $(CPP) -E
endif

all: pcre_h.jl errno_h.jl build_h.jl.phony fenv_constants.jl file_constants.jl uv_constants.jl version_git.jl.phony

pcre_h.jl:
Expand All @@ -14,17 +20,17 @@ errno_h.jl:
@$(call PRINT_PERL, echo '#include "errno.h"' | $(CPP) -dM - | perl -nle 'print "const $$1 = int32($$2)" if /^#define\s+(E\w+)\s+(\d+)\s*$$/' | sort > $@)

fenv_constants.jl: ../src/fenv_constants.h
@$(PRINT_PERL) $(CPP) -P -DJULIA ../src/fenv_constants.h | tail -n 8 | perl -ple 's/\sFE_UN\w+/ 0x10/g; s/\sFE_O\w+/ 0x08/g; s/\sFE_DI\w+/ 0x04/g; s/\sFE_INV\w+/ 0x01/g; s/\sFE_TON\w+/ 0x00/g; s/\sFE_UP\w+/ 0x800/g; s/\sFE_DO\w+/ 0x400/g; s/\sFE_TOW\w+/ 0xc00/g' > $@
@$(PRINT_PERL) $(CPP_STDOUT) -DJULIA -I../deps/openlibm/include ../src/fenv_constants.h | tail -n 8 | perl -ple 's/\sFE_UN\w+/ 0x10/g; s/\sFE_O\w+/ 0x08/g; s/\sFE_DI\w+/ 0x04/g; s/\sFE_INV\w+/ 0x01/g; s/\sFE_TON\w+/ 0x00/g; s/\sFE_UP\w+/ 0x800/g; s/\sFE_DO\w+/ 0x400/g; s/\sFE_TOW\w+/ 0xc00/g' > $@

file_constants.jl: ../src/file_constants.h
@$(call PRINT_PERL, $(CPP) -P -DJULIA ../src/file_constants.h | perl -nle 'print "$$1 0o$$2" if /^(\s*const\s+[A-z_]+\s+=)\s+(0[0-9]*)\s*$$/; print "$$1" if /^\s*(const\s+[A-z_]+\s+=\s+([1-9]|0x)[0-9A-z]*)\s*$$/' > $@)
@$(call PRINT_PERL, $(CPP_STDOUT) -DJULIA ../src/file_constants.h | perl -nle 'print "$$1 0o$$2" if /^(\s*const\s+[A-z_]+\s+=)\s+(0[0-9]*)\s*$$/; print "$$1" if /^\s*(const\s+[A-z_]+\s+=\s+([1-9]|0x)[0-9A-z]*)\s*$$/' > $@)

uv_constants.jl: ../src/uv_constants.h $(build_includedir)/uv-errno.h
@$(call PRINT_PERL, $(CPP) -P "-I$(LIBUV_INC)" -DJULIA ../src/uv_constants.h | tail -n 16 > $@)
@$(call PRINT_PERL, $(CPP_STDOUT) "-I$(LIBUV_INC)" -DJULIA ../src/uv_constants.h | tail -n 16 > $@)

build_h.jl.phony:
@echo "# This file is automatically generated in base/Makefile" > $@
@$(CC) -E -P build.h -I../src/support | grep . >> $@
@$(CPP_STDOUT) build.h -I../src/support | grep . >> $@
@echo "const ARCH = :$(ARCH)" >> $@
ifeq ($(OS),$(BUILD_OS))
@echo "const MACHINE = \"$(BUILD_MACHINE)\"" >> $@
Expand Down
6 changes: 6 additions & 0 deletions src/ast.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@
#include "julia_internal.h"
#include "flisp.h"

// MSVC complains about "julia_flisp.boot.inc : error C4335: Mac file format
// detected: please convert the source file to either DOS or UNIX format"
#ifdef _MSC_VER
#pragma warning(disable:4335)
#endif

static uint8_t flisp_system_image[] = {
#include "julia_flisp.boot.inc"
};
Expand Down
5 changes: 5 additions & 0 deletions src/builtins.c
Original file line number Diff line number Diff line change
Expand Up @@ -671,6 +671,11 @@ DLLEXPORT int jl_strtod(char *str, double *out)
return 0;
}

// MSVC pre-2013 did not define HUGE_VALF
#ifndef HUGE_VALF
#define HUGE_VALF (1e25f * 1e25f)
#endif

DLLEXPORT int jl_substrtof(char *str, int offset, int len, float *out)
{
char *p;
Expand Down
3 changes: 3 additions & 0 deletions src/flisp/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ LIBTARGET = lib$(NAME)

SRCS = flisp.c builtins.c string.c equalhash.c table.c iostream.c \
julia_extensions.c
ifeq ($(USEMSVC), 1)
SRCS += basename.c dirname.c
endif

OBJS = $(SRCS:%.c=%.o)
DOBJS = $(SRCS:%.c=%.do)
Expand Down
4 changes: 2 additions & 2 deletions src/support/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ ifneq ($(USEMSVC), 1)
@$(call PRINT_CC, $(CC) $(CPPFLAGS) $(DEBUGFLAGS) -c $< -o $@)
else
%.o: %.S
@$(call PRINT_CC, $(CPP) $(CPPFLAGS) $(SHIPFLAGS) $<)
@$(call PRINT_CC, $(CPP) -P $(CPPFLAGS) $(SHIPFLAGS) $<)
@$(call PRINT_CC, $(AS) $(CPPFLAGS) $(SHIPFLAGS) -Fo$@ -c $*.i)
%.do: %.S
@$(call PRINT_CC, $(CPP) $(CPPFLAGS) $(DEBUGFLAGS) $<)
@$(call PRINT_CC, $(CPP) -P $(CPPFLAGS) $(DEBUGFLAGS) $<)
@$(call PRINT_CC, $(AS) $(CPPFLAGS) $(DEBUGFLAGS) -Fo$@ -c $*.i)
endif

Expand Down

0 comments on commit d56088a

Please sign in to comment.