Skip to content

Commit e6f13e9

Browse files
authored
Remove some references to build time environment from sysimg (#36582)
All of these are always re-populated at load time and does not need to be in sysimg. Similar to #36536.
1 parent 826dac3 commit e6f13e9

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

base/sysimg.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,4 +101,9 @@ let
101101
empty!(LOAD_PATH)
102102
empty!(DEPOT_PATH)
103103
end
104+
105+
@eval Sys begin
106+
BINDIR = ""
107+
STDLIB = ""
108+
end
104109
end

base/sysinfo.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,12 @@ function __init__()
114114
global SC_CLK_TCK = ccall(:jl_SC_CLK_TCK, Clong, ())
115115
global CPU_NAME = ccall(:jl_get_cpu_name, Ref{String}, ())
116116
global JIT = ccall(:jl_get_JIT, Ref{String}, ())
117+
__init_build()
118+
nothing
119+
end
120+
# Populate the paths needed by sysimg compilation, e.g. `generate_precompile.jl`,
121+
# without pulling in anything unnecessary like `CPU_NAME`
122+
function __init_build()
117123
global BINDIR = ccall(:jl_get_julia_bindir, Any, ())::String
118124
vers = "v$(VERSION.major).$(VERSION.minor)"
119125
global STDLIB = abspath(BINDIR, "..", "share", "julia", "stdlib", vers)

contrib/generate_precompile.jl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# This file is a part of Julia. License is MIT: https://julialang.org/license
22

33
if isempty(ARGS) || ARGS[1] !== "0"
4+
Sys.__init_build()
45
# Prevent this from being put into the Main namespace
56
@eval Module() begin
67
if !isdefined(Base, :uv_eventloop)
@@ -210,5 +211,15 @@ end
210211

211212
generate_precompile_statements()
212213

214+
# As a last step in system image generation,
215+
# remove some references to build time environment for a more reproducible build.
216+
@eval Base PROGRAM_FILE = ""
217+
@eval Sys begin
218+
BINDIR = ""
219+
STDLIB = ""
220+
end
221+
empty!(Base.ARGS)
222+
empty!(Core.ARGS)
223+
213224
end # @eval
214225
end

0 commit comments

Comments
 (0)