Skip to content

Commit 0592b54

Browse files
authored
use the correct path to include Compiler.jl in release builds (JuliaLang#56601)
JuliaLang#56409 broke PackageCompiler (or other use cases where you want to compile a new core compiler from a release build) since it hardcoded the relative path `../usr/` from Base to the `shared` directory but this is not true in releases where it is at `..`.
1 parent bdd4e05 commit 0592b54

File tree

3 files changed

+17
-11
lines changed

3 files changed

+17
-11
lines changed

Compiler/src/Compiler.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,14 +87,14 @@ eval(m, x) = Core.eval(m, x)
8787
function include(x::String)
8888
if !isdefined(Base, :end_base_include)
8989
# During bootstrap, all includes are relative to `base/`
90-
x = Base.strcat(Base.strcat(Base.BUILDROOT, "../usr/share/julia/Compiler/src/"), x)
90+
x = Base.strcat(Base.strcat(Base.DATAROOT, "julia/Compiler/src/"), x)
9191
end
9292
Base.include(Compiler, x)
9393
end
9494

9595
function include(mod::Module, x::String)
9696
if !isdefined(Base, :end_base_include)
97-
x = Base.strcat(Base.strcat(Base.BUILDROOT, "../usr/share/julia/Compiler/src/"), x)
97+
x = Base.strcat(Base.strcat(Base.DATAROOT, "julia/Compiler/src/"), x)
9898
end
9999
Base.include(mod, x)
100100
end

base/Base_compiler.jl

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -266,29 +266,34 @@ function strcat(x::String, y::String)
266266
return out
267267
end
268268

269-
global BUILDROOT::String = ""
269+
BUILDROOT::String = ""
270+
DATAROOT::String = ""
270271

271272
baremodule BuildSettings end
272273

273274
function process_sysimg_args!()
274-
let i = 1
275-
global BUILDROOT
275+
let i = 2 # skip file name
276276
while i <= length(Core.ARGS)
277+
Core.println(Core.ARGS[i])
277278
if Core.ARGS[i] == "--buildsettings"
278279
include(BuildSettings, ARGS[i+1])
279-
i += 1
280+
elseif Core.ARGS[i] == "--buildroot"
281+
global BUILDROOT = Core.ARGS[i+1]
282+
elseif Core.ARGS[i] == "--dataroot"
283+
global DATAROOT = Core.ARGS[i+1]
280284
else
281-
BUILDROOT = Core.ARGS[i]
285+
error(strcat("invalid sysimage argument: ", Core.ARGS[i]))
282286
end
283-
i += 1
287+
i += 2
284288
end
285289
end
286290
end
287291
process_sysimg_args!()
288292

289293
function isready end
290294

291-
include(strcat(BUILDROOT, "../usr/share/julia/Compiler/src/Compiler.jl"))
295+
include(strcat(DATAROOT, "julia/Compiler/src/Compiler.jl"))
296+
292297

293298
const _return_type = Compiler.return_type
294299

sysimage.mk

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,18 +61,19 @@ BASE_SRCS := $(sort $(shell find $(JULIAHOME)/base -name \*.jl -and -not -name s
6161
$(shell find $(BUILDROOT)/base -name \*.jl -and -not -name sysimg.jl))
6262
STDLIB_SRCS := $(JULIAHOME)/base/sysimg.jl $(SYSIMG_STDLIBS_SRCS)
6363
RELBUILDROOT := $(call rel_path,$(JULIAHOME)/base,$(BUILDROOT)/base)/ # <-- make sure this always has a trailing slash
64+
RELDATADIR := $(call rel_path,$(JULIAHOME)/base,$(build_datarootdir))/ # <-- make sure this always has a trailing slash
6465

6566
$(build_private_libdir)/basecompiler.ji: $(COMPILER_SRCS)
6667
@$(call PRINT_JULIA, cd $(JULIAHOME)/base && \
6768
$(call spawn,$(JULIA_EXECUTABLE)) -C "$(JULIA_CPU_TARGET)" $(HEAPLIM) --output-ji $(call cygpath_w,$@).tmp \
68-
--startup-file=no --warn-overwrite=yes -g$(BOOTSTRAP_DEBUG_LEVEL) -O1 Base_compiler.jl $(RELBUILDROOT))
69+
--startup-file=no --warn-overwrite=yes -g$(BOOTSTRAP_DEBUG_LEVEL) -O1 Base_compiler.jl --buildroot $(RELBUILDROOT) --dataroot $(RELDATADIR))
6970
@mv $@.tmp $@
7071

7172
$(build_private_libdir)/sys.ji: $(build_private_libdir)/basecompiler.ji $(JULIAHOME)/VERSION $(BASE_SRCS) $(STDLIB_SRCS)
7273
@$(call PRINT_JULIA, cd $(JULIAHOME)/base && \
7374
if ! JULIA_BINDIR=$(call cygpath_w,$(build_bindir)) WINEPATH="$(call cygpath_w,$(build_bindir));$$WINEPATH" \
7475
$(call spawn, $(JULIA_EXECUTABLE)) -g1 -O1 -C "$(JULIA_CPU_TARGET)" $(HEAPLIM) --output-ji $(call cygpath_w,$@).tmp $(JULIA_SYSIMG_BUILD_FLAGS) \
75-
--startup-file=no --warn-overwrite=yes --sysimage $(call cygpath_w,$<) sysimg.jl $(RELBUILDROOT); then \
76+
--startup-file=no --warn-overwrite=yes --sysimage $(call cygpath_w,$<) sysimg.jl --buildroot $(RELBUILDROOT) --dataroot $(RELDATADIR); then \
7677
echo '*** This error might be fixed by running `make clean`. If the error persists$(COMMA) try `make cleanall`. ***'; \
7778
false; \
7879
fi )

0 commit comments

Comments
 (0)