From 86818f140f7d0842472387dd345353f61ca88471 Mon Sep 17 00:00:00 2001 From: tkelman Date: Fri, 21 Mar 2014 19:02:28 -0700 Subject: [PATCH] Updates for MSVC patch utf8proc so it can compile in either C or C++ mode dont define USE_COMPUTED_GOTO for MSVC (might be an odd double-definition problem from some header) add utf8proc info to src/flisp/Windows.mk (needs some improvement on handling of utf8proc version number and assumption of cl vs icl) add strtod to Windows.mk add DLLEXPORT before jl_init_frontend(void) modify OSLIBS and CONFIGURE_COMMON for msvc --- Make.inc | 4 ++++ deps/Makefile | 3 +++ deps/utf8proc_msvc.patch | 40 ++++++++++++++++++++++++++++++++++++++++ src/flisp/Makefile | 5 ++--- src/flisp/Windows.mk | 8 ++++++-- src/julia_internal.h | 2 +- src/support/Windows.mk | 2 ++ 7 files changed, 58 insertions(+), 6 deletions(-) create mode 100644 deps/utf8proc_msvc.patch diff --git a/Make.inc b/Make.inc index 3e5f6c66a34fd..c9ee813078fb6 100644 --- a/Make.inc +++ b/Make.inc @@ -495,8 +495,12 @@ JLDFLAGS = endif ifeq ($(OS), WINNT) +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 +endif JCPPFLAGS += -D_WIN32_WINNT=0x0600 JLDFLAGS = -Wl,--stack,8388608 ifeq ($(ARCH),i686) diff --git a/deps/Makefile b/deps/Makefile index fef93b77ef4a7..6651cd1cdaa75 100644 --- a/deps/Makefile +++ b/deps/Makefile @@ -8,8 +8,10 @@ ifneq ($(XC_HOST),) CONFIGURE_COMMON += --host=$(XC_HOST) endif ifeq ($(OS),WINNT) +ifneq ($(USEMSVC), 1) CONFIGURE_COMMON += LDFLAGS=-Wl,--stack,8388608 endif +endif CONFIGURE_COMMON += F77="$(FC)" CC="$(CC)" CXX="$(CXX)" # If the top-level Makefile is called with environment variables, @@ -1154,6 +1156,7 @@ utf8proc-v$(UTF8PROC_VER).tar.gz: utf8proc-v$(UTF8PROC_VER)/Makefile: utf8proc-v$(UTF8PROC_VER).tar.gz $(TAR) -xzf $< patch $@ < utf8proc_Makefile.patch + cd utf8proc-v$(UTF8PROC_VER) && patch < ../utf8proc_msvc.patch touch -c $@ $(UTF8PROC_OBJ_SOURCE): utf8proc-v$(UTF8PROC_VER)/Makefile diff --git a/deps/utf8proc_msvc.patch b/deps/utf8proc_msvc.patch new file mode 100644 index 0000000000000..1fc887177b44a --- /dev/null +++ b/deps/utf8proc_msvc.patch @@ -0,0 +1,40 @@ +diff --git a/utf8proc.c b/utf8proc.c +index ef2d433..e6c51f7 100644 +--- a/utf8proc.c ++++ b/utf8proc.c +@@ -536,7 +536,7 @@ ssize_t utf8proc_map( + *dstptr = NULL; + result = utf8proc_decompose(str, strlen, NULL, 0, options); + if (result < 0) return result; +- buffer = malloc(result * sizeof(int32_t) + 1); ++ buffer = (int32_t *) malloc(result * sizeof(int32_t) + 1); + if (!buffer) return UTF8PROC_ERROR_NOMEM; + result = utf8proc_decompose(str, strlen, buffer, result, options); + if (result < 0) { +@@ -550,7 +550,7 @@ ssize_t utf8proc_map( + } + { + int32_t *newptr; +- newptr = realloc(buffer, (size_t)result+1); ++ newptr = (int32_t *) realloc(buffer, (size_t)result+1); + if (newptr) buffer = newptr; + } + *dstptr = (uint8_t *)buffer; +diff --git a/utf8proc.h b/utf8proc.h +index 24a891b..304e227 100644 +--- a/utf8proc.h ++++ b/utf8proc.h +@@ -65,8 +65,13 @@ typedef int int32_t; + #else + #define ssize_t int + #endif ++#ifdef __cplusplus ++typedef unsigned char _bool; ++enum {_false, _true}; ++#else + typedef unsigned char bool; + enum {false, true}; ++#endif + #else + #include + #include diff --git a/src/flisp/Makefile b/src/flisp/Makefile index 829f909826021..07da15b07c40a 100644 --- a/src/flisp/Makefile +++ b/src/flisp/Makefile @@ -16,12 +16,11 @@ DOBJS = $(SRCS:%.c=%.do) LLTDIR = ../support LLT = $(LLTDIR)/libsupport.a $(LIBUV) $(LIBUTF8PROC) -FLAGS = -I$(LLTDIR) $(CFLAGS) \ - -DUSE_COMPUTED_GOTO $(HFILEDIRS:%=-I%) \ +FLAGS = -I$(LLTDIR) $(CFLAGS) $(HFILEDIRS:%=-I%) \ -I$(LIBUV_INC) -I$(JULIAHOME)/usr/include $(LIBDIRS:%=-L%) \ -DLIBRARY_EXPORTS ifneq ($(USEMSVC), 1) -FLAGS += -Wall -Wno-strict-aliasing -fvisibility=hidden +FLAGS += -Wall -Wno-strict-aliasing -DUSE_COMPUTED_GOTO -fvisibility=hidden endif LIBFILES = $(LLT) LIBS = $(LIBFILES) diff --git a/src/flisp/Windows.mk b/src/flisp/Windows.mk index 273b78e09dcb2..0abecca80c46f 100644 --- a/src/flisp/Windows.mk +++ b/src/flisp/Windows.mk @@ -31,16 +31,17 @@ OBJECTS = \ basename.obj LIBUV = $(MAKEDIR)\..\..\deps\libuv\libuv.lib +LIBUTF8PROC = $(MAKEDIR)\..\..\deps\utf8proc-v1.1.6\libutf8proc.lib LIBSUPPORT = $(MAKEDIR)\..\support\libsupport.lib -INCLUDE = $(INCLUDE);$(MAKEDIR)\..\..\deps\libuv\include;$(MAKEDIR)\..\support +INCLUDE = $(INCLUDE);$(MAKEDIR)\..\..\deps\libuv\include;$(MAKEDIR)\..\..\deps\utf8proc-v1.1.6;$(MAKEDIR)\..\support CFLAGS = $(CFLAGS) /Qstd=c99 -D_CRT_SECURE_NO_WARNINGS -DLIBRARY_EXPORTS LFLAGS = $(LFLAGS) kernel32.lib ws2_32.lib psapi.lib advapi32.lib iphlpapi.lib default: $(NAME).exe -$(NAME).exe: lib$(NAME).lib flmain.obj $(LIBSUPPORT) $(LIBUV) +$(NAME).exe: lib$(NAME).lib flmain.obj $(LIBSUPPORT) $(LIBUV) $(LIBUTF8PROC) $(LINK) $(LFLAGS) /OUT:$(NAME).exe /PDB:$(NAME).pdb /MAP $** $(LIBSUPPORT): @@ -49,6 +50,9 @@ $(LIBSUPPORT): $(LIBUV): PUSHD $(MAKEDIR)\..\..\deps\libuv && $(MAKE) /NOLOGO /F Windows.mk && POPD +$(LIBUTF8PROC): + PUSHD $(MAKEDIR)\..\..\deps\utf8proc-v1.1.6 && cl -nologo /c utf8proc.c && $(AR) /OUT:libutf8proc.lib utf8proc.obj && POPD + lib$(NAME).lib: $(OBJECTS) $(AR) /OUT:lib$(NAME).lib $** diff --git a/src/julia_internal.h b/src/julia_internal.h index feb379ff86469..c5d45b1c51adc 100644 --- a/src/julia_internal.h +++ b/src/julia_internal.h @@ -79,7 +79,7 @@ jl_array_t *jl_new_array_for_deserialization(jl_value_t *atype, uint32_t ndims, void jl_init_types(void); void jl_init_box_caches(void); -void jl_init_frontend(void); +DLLEXPORT void jl_init_frontend(void); void jl_init_primitives(void); void jl_init_codegen(void); void jl_init_intrinsic_functions(void); diff --git a/src/support/Windows.mk b/src/support/Windows.mk index a24b5697c459b..9c34e8fff0cdb 100644 --- a/src/support/Windows.mk +++ b/src/support/Windows.mk @@ -15,6 +15,7 @@ HEADERS = \ libsupport.h \ MurmurHash3.h \ ptrhash.h \ + strtod.h \ timefuncs.h \ utf8.h \ utils.h \ @@ -23,6 +24,7 @@ HEADERS = \ OBJECTS = \ hashing.obj \ timefuncs.obj \ + strtod.obj \ ptrhash.obj \ operators.obj \ utf8.obj \