Skip to content

Commit 53603f6

Browse files
Kenovtjnash
andauthored
Fix wine bootstrap (#40425)
* Fix wine bootstrap Fixes #39124 Closes #39022 * fix cross-build, and other build issues * this should probably be part of spawn, if it is needed * Revert "this should probably be part of spawn, if it is needed" This reverts commit eb88a9c. Seems to be needed * fixup! fix cross-build, and other build issues Co-authored-by: Jameson Nash <[email protected]>
1 parent 011d6f0 commit 53603f6

File tree

8 files changed

+35
-33
lines changed

8 files changed

+35
-33
lines changed

Make.inc

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -587,6 +587,12 @@ endif #USEMSVC
587587
RANLIB := $(CROSS_COMPILE)ranlib
588588
OBJCOPY := $(CROSS_COMPILE)objcopy
589589

590+
ifneq ($(USEMSVC), 1)
591+
CPP_STDOUT := $(CPP) -P
592+
else
593+
CPP_STDOUT := $(CPP) -E
594+
endif
595+
590596
# file extensions
591597
ifeq ($(OS), WINNT)
592598
SHLIB_EXT := dll
@@ -1024,22 +1030,18 @@ JCPPFLAGS+=-DSYSTEM_LLVM
10241030
endif # SYSTEM_LLVM
10251031

10261032
# Windows builds need a little help finding the LLVM libraries for llvm-config
1027-
LLVM_CONFIG_PATH_FIX :=
1033+
# use delayed expansion (= not :=) because spawn isn't defined until later
1034+
# WINEPATH is only needed for a wine-based cross compile
1035+
LLVM_CONFIG_PATH_FIX =
10281036
ifeq ($(OS),WINNT)
1029-
LLVM_CONFIG_PATH_FIX := PATH="$(build_bindir):$(PATH)"
1037+
LLVM_CONFIG_PATH_FIX = PATH="$(build_bindir):$(PATH)" WINEPATH="$(call cygpath_w,$(build_bindir));$(WINEPATH)"
10301038
endif
10311039

10321040
ifeq ($(BUILD_OS),$(OS))
1033-
LLVM_CONFIG_HOST := $(LLVM_CONFIG)
1041+
LLVM_CONFIG_HOST = $(LLVM_CONFIG_PATH_FIX) $(LLVM_CONFIG)
10341042
else
10351043
LLVM_CONFIG_HOST := $(basename $(LLVM_CONFIG))-host$(BUILD_EXE)
1036-
ifeq (exists, $(shell [ -f '$(LLVM_CONFIG_HOST)' ] && echo exists ))
1037-
ifeq ($(shell $(LLVM_CONFIG_PATH_FIX) $(LLVM_CONFIG_HOST) --version),3.3)
1038-
# llvm-config-host <= 3.3 is broken, use llvm-config instead (in an emulator)
1039-
# use delayed expansion (= not :=) because spawn isn't defined until later
1040-
LLVM_CONFIG_HOST = $(LLVM_CONFIG_PATH_FIX) $(call spawn,$(LLVM_CONFIG))
1041-
endif
1042-
else
1044+
ifneq (exists, $(shell [ -f '$(LLVM_CONFIG_HOST)' ] && echo exists ))
10431045
# llvm-config-host does not exist (cmake build)
10441046
LLVM_CONFIG_HOST = $(LLVM_CONFIG_PATH_FIX) $(call spawn,$(LLVM_CONFIG))
10451047
endif
@@ -1570,6 +1572,7 @@ PRINT_FLISP = echo '$(subst ','\'',$(1))'; $(1)
15701572
PRINT_JULIA = echo '$(subst ','\'',$(1))'; $(1)
15711573
15721574
endif
1575+
15731576
# Makefile debugging trick:
15741577
# call print-VARIABLE to see the runtime value of any variable
15751578
# (hardened against any special characters appearing in the output)

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,8 @@ $(build_depsbindir)/stringreplace: $(JULIAHOME)/contrib/stringreplace.c | $(buil
154154
@$(call PRINT_CC, $(HOSTCC) -o $(build_depsbindir)/stringreplace $(JULIAHOME)/contrib/stringreplace.c)
155155

156156
julia-base-cache: julia-sysimg-$(JULIA_BUILD_MODE) | $(DIRS) $(build_datarootdir)/julia
157-
@JULIA_BINDIR=$(call cygpath_w,$(build_bindir)) $(call spawn, $(JULIA_EXECUTABLE) --startup-file=no $(call cygpath_w,$(JULIAHOME)/etc/write_base_cache.jl) \
157+
@JULIA_BINDIR=$(call cygpath_w,$(build_bindir)) WINEPATH="$(call cygpath_w,$(build_bindir));$$WINEPATH" \
158+
$(call spawn, $(JULIA_EXECUTABLE) --startup-file=no $(call cygpath_w,$(JULIAHOME)/etc/write_base_cache.jl) \
158159
$(call cygpath_w,$(build_datarootdir)/julia/base.cache))
159160

160161
# public libraries, that are installed in $(prefix)/lib

base/Makefile

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,6 @@ include $(JULIAHOME)/Make.inc
66

77
TAGGED_RELEASE_BANNER := ""
88

9-
ifneq ($(USEMSVC), 1)
10-
CPP_STDOUT := $(CPP) -P
11-
else
12-
CPP_STDOUT := $(CPP) -E
13-
endif
14-
159
all: $(addprefix $(BUILDDIR)/,pcre_h.jl errno_h.jl build_h.jl.phony features_h.jl file_constants.jl uv_constants.jl version_git.jl.phony)
1610

1711
PCRE_CONST := 0x[0-9a-fA-F]+|[0-9]+|\([\-0-9]+\)

base/env.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ if Sys.iswindows()
3232
function _unsetenv(svar::AbstractString)
3333
var = cwstring(svar)
3434
ret = ccall(:SetEnvironmentVariableW,stdcall,Int32,(Ptr{UInt16},Ptr{UInt16}),var,C_NULL)
35-
windowserror(:setenv, ret == 0)
35+
windowserror(:setenv, ret == 0 && Libc.GetLastError() != ERROR_ENVVAR_NOT_FOUND)
3636
end
3737
else # !windows
3838
_getenv(var::AbstractString) = ccall(:getenv, Cstring, (Cstring,), var)

cli/Makefile

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -100,17 +100,10 @@ libjulia-debug: $(build_shlibdir)/libjulia-debug.$(SHLIB_EXT)
100100

101101
ifeq ($(OS),WINNT)
102102
# On Windows we need to strip out exported functions from the generated import library.
103-
# On i686, there's an extra underscore at the beginning
104-
ifeq ($(ARCH),i686)
105-
ABI_UNDERSCORE := _\#\#
106-
else
107-
ABI_UNDERSCORE :=
108-
endif
109-
EXPORTED_FUNCS := $(shell echo -e "#include \"jl_exported_funcs.inc\"\n#define XX(x) $(ABI_UNDERSCORE)x\nJL_EXPORTED_FUNCS(XX)" | $(CPP) -I$(JULIAHOME)/src - | tail -n 1)
110-
STRIP_EXPORTED_FUNCS := $(patsubst %,--strip-symbol=%,$(EXPORTED_FUNCS))
103+
STRIP_EXPORTED_FUNCS := $(shell $(CPP_STDOUT) -I$(JULIAHOME)/src $(SRCDIR)/list_strip_symbols.h)
111104
endif
112105

113-
$(build_shlibdir)/libjulia.$(JL_MAJOR_MINOR_SHLIB_EXT): $(LIB_OBJS) | $(build_shlibdir) $(build_libdir)
106+
$(build_shlibdir)/libjulia.$(JL_MAJOR_MINOR_SHLIB_EXT): $(LIB_OBJS) $(SRCDIR)/list_strip_symbols.h | $(build_shlibdir) $(build_libdir)
114107
@$(call PRINT_LINK, $(CC) $(call IMPLIB_FLAGS,$@.tmp) $(LOADER_CFLAGS) -DLIBRARY_EXPORTS -shared $(SHIPFLAGS) $(LIB_OBJS) -o $@ \
115108
$(JLIBLDFLAGS) $(LOADER_LDFLAGS) $(RPATH_LIB) $(call SONAME_FLAGS,libjulia.$(JL_MAJOR_SHLIB_EXT)))
116109
@$(INSTALL_NAME_CMD)libjulia.$(SHLIB_EXT) $@
@@ -120,7 +113,7 @@ ifeq ($(OS), WINNT)
120113
@$(call PRINT_ANALYZE, $(OBJCOPY) $(build_libdir)/$(notdir $@).tmp.a $(STRIP_EXPORTED_FUNCS) $(build_libdir)/$(notdir $@).a && rm $(build_libdir)/$(notdir $@).tmp.a)
121114
endif
122115

123-
$(build_shlibdir)/libjulia-debug.$(JL_MAJOR_MINOR_SHLIB_EXT): $(LIB_DOBJS) | $(build_shlibdir) $(build_libdir)
116+
$(build_shlibdir)/libjulia-debug.$(JL_MAJOR_MINOR_SHLIB_EXT): $(LIB_DOBJS) $(SRCDIR)/list_strip_symbols.h | $(build_shlibdir) $(build_libdir)
124117
@$(call PRINT_LINK, $(CC) $(call IMPLIB_FLAGS,$@.tmp) $(LOADER_CFLAGS) -DLIBRARY_EXPORTS -shared $(DEBUGFLAGS) $(LIB_DOBJS) -o $@ \
125118
$(JLIBLDFLAGS) $(LOADER_LDFLAGS) $(RPATH_LIB) $(call SONAME_FLAGS,libjulia-debug.$(JL_MAJOR_SHLIB_EXT)))
126119
@$(INSTALL_NAME_CMD)libjulia-debug.$(SHLIB_EXT) $@.tmp

cli/list_strip_symbols.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// This file is a part of Julia. License is MIT: https://julialang.org/license
2+
3+
#include "jl_exported_funcs.inc"
4+
#include "trampolines/common.h"
5+
#define XX(x) --strip-symbol=CNAME(x)
6+
JL_EXPORTED_FUNCS(XX)
7+
#undef XX

src/Makefile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,11 +140,13 @@ DEBUGFLAGS += "-DJL_LIBJULIA_SONAME=\"libjulia-debug.$(JL_MAJOR_SHLIB_EXT)\"" "-
140140

141141
ifeq ($(USE_CROSS_FLISP), 1)
142142
FLISPDIR := $(BUILDDIR)/flisp/host
143+
FLISP_EXECUTABLE_debug := $(FLISPDIR)/flisp-debug$(BUILD_EXE)
144+
FLISP_EXECUTABLE_release := $(FLISPDIR)/flisp$(BUILD_EXE)
143145
else
144146
FLISPDIR := $(BUILDDIR)/flisp
147+
FLISP_EXECUTABLE_debug := $(FLISPDIR)/flisp-debug$(EXE)
148+
FLISP_EXECUTABLE_release := $(FLISPDIR)/flisp$(EXE)
145149
endif
146-
FLISP_EXECUTABLE_debug := $(FLISPDIR)/flisp-debug$(BUILD_EXE)
147-
FLISP_EXECUTABLE_release := $(FLISPDIR)/flisp$(BUILD_EXE)
148150
ifeq ($(OS),WINNT)
149151
FLISP_EXECUTABLE := $(FLISP_EXECUTABLE_release)
150152
else

sysimage.mk

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ $(build_private_libdir)/corecompiler.ji: $(COMPILER_SRCS)
6565

6666
$(build_private_libdir)/sys.ji: $(build_private_libdir)/corecompiler.ji $(JULIAHOME)/VERSION $(BASE_SRCS) $(STDLIB_SRCS)
6767
@$(call PRINT_JULIA, cd $(JULIAHOME)/base && \
68-
if ! JULIA_BINDIR=$(call cygpath_w,$(build_bindir)) $(call spawn, $(JULIA_EXECUTABLE)) -g1 -O0 -C "$(JULIA_CPU_TARGET)" --output-ji $(call cygpath_w,$@).tmp $(JULIA_SYSIMG_BUILD_FLAGS) \
68+
if ! JULIA_BINDIR=$(call cygpath_w,$(build_bindir)) WINEPATH="$(call cygpath_w,$(build_bindir));$$WINEPATH" \
69+
$(call spawn, $(JULIA_EXECUTABLE)) -g1 -O0 -C "$(JULIA_CPU_TARGET)" --output-ji $(call cygpath_w,$@).tmp $(JULIA_SYSIMG_BUILD_FLAGS) \
6970
--startup-file=no --warn-overwrite=yes --sysimage $(call cygpath_w,$<) sysimg.jl $(RELBUILDROOT); then \
7071
echo '*** This error might be fixed by running `make clean`. If the error persists$(COMMA) try `make cleanall`. ***'; \
7172
false; \
@@ -75,8 +76,9 @@ $(build_private_libdir)/sys.ji: $(build_private_libdir)/corecompiler.ji $(JULIAH
7576
define sysimg_builder
7677
$$(build_private_libdir)/sys$1-o.a $$(build_private_libdir)/sys$1-bc.a : $$(build_private_libdir)/sys$1-%.a : $$(build_private_libdir)/sys.ji
7778
@$$(call PRINT_JULIA, cd $$(JULIAHOME)/base && \
78-
if ! JULIA_BINDIR=$$(call cygpath_w,$(build_bindir)) $$(call spawn, $3) $2 -C "$$(JULIA_CPU_TARGET)" --output-$$* $$(call cygpath_w,$$@).tmp $$(JULIA_SYSIMG_BUILD_FLAGS) \
79-
--startup-file=no --warn-overwrite=yes --sysimage $$(call cygpath_w,$$<) $$(call cygpath_w,$$(JULIAHOME)/contrib/generate_precompile.jl) $(JULIA_PRECOMPILE); then \
79+
if ! JULIA_BINDIR=$$(call cygpath_w,$(build_bindir)) WINEPATH="$$(call cygpath_w,$$(build_bindir));$$$$WINEPATH" \
80+
$$(call spawn, $3) $2 -C "$$(JULIA_CPU_TARGET)" --output-$$* $$(call cygpath_w,$$@).tmp $$(JULIA_SYSIMG_BUILD_FLAGS) \
81+
--startup-file=no --warn-overwrite=yes --sysimage $$(call cygpath_w,$$<) $$(call cygpath_w,$$(JULIAHOME)/contrib/generate_precompile.jl) $(JULIA_PRECOMPILE); then \
8082
echo '*** This error is usually fixed by running `make clean`. If the error persists$$(COMMA) try `make cleanall`. ***'; \
8183
false; \
8284
fi )

0 commit comments

Comments
 (0)