Skip to content

Commit

Permalink
Updates for MSVC
Browse files Browse the repository at this point in the history
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
  • Loading branch information
tkelman committed Mar 31, 2014
1 parent 06b5846 commit 86818f1
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 6 deletions.
4 changes: 4 additions & 0 deletions Make.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions deps/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down
40 changes: 40 additions & 0 deletions deps/utf8proc_msvc.patch
Original file line number Diff line number Diff line change
@@ -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 <stdbool.h>
#include <inttypes.h>
5 changes: 2 additions & 3 deletions src/flisp/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 6 additions & 2 deletions src/flisp/Windows.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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 $**

Expand Down
2 changes: 1 addition & 1 deletion src/julia_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions src/support/Windows.mk
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ HEADERS = \
libsupport.h \
MurmurHash3.h \
ptrhash.h \
strtod.h \
timefuncs.h \
utf8.h \
utils.h \
Expand All @@ -23,6 +24,7 @@ HEADERS = \
OBJECTS = \
hashing.obj \
timefuncs.obj \
strtod.obj \
ptrhash.obj \
operators.obj \
utf8.obj \
Expand Down

0 comments on commit 86818f1

Please sign in to comment.