From d56088a96412b4ca5f26c61c3e9b8671b4557628 Mon Sep 17 00:00:00 2001 From: Tony Kelman Date: Sat, 22 Mar 2014 22:08:14 -0700 Subject: [PATCH] Minor MSVC changes 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 --- Make.inc | 4 ++-- base/Makefile | 14 ++++++++++---- src/ast.c | 6 ++++++ src/builtins.c | 5 +++++ src/flisp/Makefile | 3 +++ src/support/Makefile | 4 ++-- 6 files changed, 28 insertions(+), 8 deletions(-) diff --git a/Make.inc b/Make.inc index c9ee813078fb6..d034dd373e0f0 100644 --- a/Make.inc +++ b/Make.inc @@ -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 @@ -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 diff --git a/base/Makefile b/base/Makefile index 418a3440489d4..af9e830286449 100644 --- a/base/Makefile +++ b/base/Makefile @@ -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: @@ -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)\"" >> $@ diff --git a/src/ast.c b/src/ast.c index 520a9494ea19a..17a97c259dd7e 100644 --- a/src/ast.c +++ b/src/ast.c @@ -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" }; diff --git a/src/builtins.c b/src/builtins.c index a94aae2356f0d..a3cdf991f2361 100644 --- a/src/builtins.c +++ b/src/builtins.c @@ -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; diff --git a/src/flisp/Makefile b/src/flisp/Makefile index 07da15b07c40a..15e66bd021b1a 100644 --- a/src/flisp/Makefile +++ b/src/flisp/Makefile @@ -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) diff --git a/src/support/Makefile b/src/support/Makefile index dab33146cd0f5..0be80a5b90e65 100644 --- a/src/support/Makefile +++ b/src/support/Makefile @@ -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