Skip to content

Commit 0dcd3ef

Browse files
committed
Tweaks for cross compiling from Cygwin to MinGW
* Cygwin versions of MinGW compilers put standard libraries in /bin, not /lib * Blas and Lapack should be in build_shlibdir * Don't use wine for Cygwin to MinGW cross compile * New cygpath_w helper function to convert Cygwin paths to Windows-style so MinGW-compiled executables can understand them * Use cygpath_w for system image file locations
1 parent 8854bad commit 0dcd3ef

File tree

2 files changed

+26
-7
lines changed

2 files changed

+26
-7
lines changed

Make.inc

+22-3
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,9 @@ BUILD_LLDB = 0
106106
#XC_HOST = i686-w64-mingw32
107107
#XC_HOST = x86_64-w64-mingw32
108108

109+
# Figure out OS and architecture
110+
BUILD_OS := $(shell uname)
111+
109112
ifeq ($(XC_HOST),)
110113
CROSS_COMPILE=
111114
HOSTCC = $(CC)
@@ -115,8 +118,13 @@ override OPENBLAS_DYNAMIC_ARCH = 1
115118
override CROSS_COMPILE=$(XC_HOST)-
116119
ifneq (,$(findstring mingw,$(XC_HOST)))
117120
override OS := WINNT
121+
ifneq (,$(findstring CYGWIN,$(BUILD_OS)))
122+
export STD_LIB_PATH := $(shell $(CROSS_COMPILE)gcc -print-search-dirs | grep programs | sed -e "s/^programs: =//" -e "s!/lib/!/bin/!g")
123+
export STD_LIB_PATH := $(STD_LIB_PATH):$(shell $(CROSS_COMPILE)gcc -print-search-dirs | grep libraries | sed -e "s/^libraries: =//" -e "s!/lib/!/bin/!g")
124+
else
118125
export STD_LIB_PATH := $(shell $(CROSS_COMPILE)gcc -print-search-dirs | grep programs | sed "s/^programs: =//" | xargs -d":" winepath -w | tr '\n' ';')
119126
export STD_LIB_PATH := $(STD_LIB_PATH);$(shell $(CROSS_COMPILE)gcc -print-search-dirs | grep libraries | sed "s/^libraries: =//" | xargs -d":" winepath -w | tr '\n' ';')
127+
endif
120128
else
121129
$(error "unknown XC_HOST variable set")
122130
endif
@@ -125,7 +133,6 @@ endif
125133
JLDOWNLOAD = $(JULIAHOME)/deps/jldownload
126134

127135
# Figure out OS and architecture
128-
BUILD_OS := $(shell uname)
129136
OS := $(BUILD_OS)
130137

131138
ifneq (,$(findstring MINGW,$(OS)))
@@ -367,7 +374,7 @@ LIBBLAS ?= -lblas
367374
LIBBLASNAME ?= libblas
368375
endif
369376
else
370-
LIBBLAS = -L$(build_libdir) -lopenblas
377+
LIBBLAS = -L$(build_shlibdir) -lopenblas
371378
LIBBLASNAME = libopenblas
372379
endif
373380

@@ -381,7 +388,7 @@ ifeq ($(USE_SYSTEM_LAPACK), 1)
381388
LIBLAPACK = -llapack
382389
LIBLAPACKNAME = liblapack
383390
else
384-
LIBLAPACK = -L$(build_libdir) -llapack $(LIBBLAS)
391+
LIBLAPACK = -L$(build_shlibdir) -llapack $(LIBBLAS)
385392
LIBLAPACKNAME = liblapack
386393
endif
387394
endif
@@ -572,6 +579,8 @@ endef
572579

573580
ifeq ($(BUILD_OS), WINNT)
574581
spawn = $(1)
582+
else ifneq (,$(findstring CYGWIN,$(BUILD_OS)))
583+
spawn = $(1)
575584
else
576585
ifeq ($(OS), WINNT)
577586
spawn = wine $(1)
@@ -580,9 +589,19 @@ spawn = $(1)
580589
endif
581590
endif
582591

592+
ifneq (,$(findstring CYGWIN,$(BUILD_OS)))
593+
cygpath_w = `cygpath -w $(1)`
594+
else
595+
cygpath_w = $(1)
596+
endif
597+
583598
exec = $(shell $(call spawn,$(1)))
584599

600+
ifneq (,$(findstring CYGWIN,$(BUILD_OS)))
601+
wine_pathsearch = $(firstword $(wildcard $(addsuffix /$(1),$(subst :, ,$(2)))))
602+
else
585603
wine_pathsearch = $(firstword $(wildcard $(addsuffix /$(1),$(shell printf %s\n '$(2)' | xargs -d";" winepath -u | tr '\n' ' '))))
604+
endif
586605
pathsearch = $(firstword $(wildcard $(addsuffix /$(1),$(subst :, ,$(2)))))
587606

588607
JULIA_EXECUTABLE_debug = $(build_bindir)/julia-debug-$(DEFAULT_REPL)$(EXE)

Makefile

+4-4
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ endif
6868
$(build_private_libdir)/sys%ji: $(build_private_libdir)/sys%bc
6969

7070
$(build_private_libdir)/sys%o: $(build_private_libdir)/sys%bc
71-
$(call spawn,$(LLVM_LLC)) -filetype=obj -relocation-model=pic -mattr=-bmi2,-avx2 -o $@ $<
71+
$(call spawn,$(LLVM_LLC)) -filetype=obj -relocation-model=pic -mattr=-bmi2,-avx2 -o $(call cygpath_w,$@) $(call cygpath_w,$<)
7272

7373
.PRECIOUS: $(build_private_libdir)/sys%o
7474

@@ -79,12 +79,12 @@ $(build_private_libdir)/sys%$(SHLIB_EXT): $(build_private_libdir)/sys%o
7979

8080
$(build_private_libdir)/sys0.bc:
8181
@$(QUIET_JULIA) cd base && \
82-
$(call spawn,$(JULIA_EXECUTABLE)) --build $(build_private_libdir)/sys0 sysimg.jl
82+
$(call spawn,$(JULIA_EXECUTABLE)) --build $(call cygpath_w,$(build_private_libdir)/sys0) sysimg.jl
8383

8484
$(build_private_libdir)/sys.bc: VERSION base/*.jl base/pkg/*.jl base/linalg/*.jl base/sparse/*.jl $(build_datarootdir)/julia/helpdb.jl $(build_datarootdir)/man/man1/julia.1 $(build_private_libdir)/sys0.$(SHLIB_EXT)
8585
@$(QUIET_JULIA) cd base && \
86-
$(call spawn,$(JULIA_EXECUTABLE)) --build $(build_private_libdir)/sys \
87-
-J$(build_private_libdir)/$$([ -e $(build_private_libdir)/sys.ji ] && echo sys.ji || echo sys0.ji) -f sysimg.jl \
86+
$(call spawn,$(JULIA_EXECUTABLE)) --build $(call cygpath_w,$(build_private_libdir)/sys) \
87+
-J$(call cygpath_w,$(build_private_libdir))/$$([ -e $(build_private_libdir)/sys.ji ] && echo sys.ji || echo sys0.ji) -f sysimg.jl \
8888
|| (echo "*** This error is usually fixed by running 'make clean'. If the error persists, try 'make cleanall'. ***" && false)
8989

9090
run-julia-debug run-julia-release: run-julia-%:

0 commit comments

Comments
 (0)