Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update usage for build_sysimg.jl #28970

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ endif
julia-deps: | $(DIRS) $(build_datarootdir)/julia/base $(build_datarootdir)/julia/test $(build_defaultpkgdir)
@$(MAKE) $(QUIET_MAKE) -C $(BUILDROOT)/deps

julia-base: julia-deps $(build_sysconfdir)/julia/startup.jl $(build_man1dir)/julia.1 $(build_datarootdir)/julia/julia-config.jl
julia-base: julia-deps $(build_sysconfdir)/julia/startup.jl $(build_man1dir)/julia.1 $(build_datarootdir)/julia/julia-config.jl $(build_datarootdir)/julia/build_sysimg.jl
@$(MAKE) $(QUIET_MAKE) -C $(BUILDROOT)/base

julia-libccalltest: julia-deps
Expand Down Expand Up @@ -137,6 +137,9 @@ $(build_sysconfdir)/julia/startup.jl: $(JULIAHOME)/etc/startup.jl | $(build_sysc
@echo Creating usr/etc/julia/startup.jl
@cp $< $@

$(build_datarootdir)/julia/build_sysimg.jl: $(JULIAHOME)/contrib/build_sysimg.jl | $(build_datarootdir)/julia
$(INSTALL_M) $< $(dir $@)

$(build_datarootdir)/julia/julia-config.jl : $(JULIAHOME)/contrib/julia-config.jl | $(build_datarootdir)/julia
$(INSTALL_M) $< $(dir $@)

Expand Down
26 changes: 14 additions & 12 deletions contrib/build_sysimg.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/usr/bin/env julia
# This file is a part of Julia. License is MIT: https://julialang.org/license

import Libdl

# Build a system image binary at sysimg_path.dlext. Allow insertion of a userimg via
# userimg_path. If sysimg_path.dlext is currently loaded into memory, don't continue
# unless force is set to true. Allow targeting of a CPU architecture via cpu_target.
Expand Down Expand Up @@ -33,7 +35,7 @@ function build_sysimg(sysimg_path=nothing, cpu_target="native", userimg_path=not
sysimg = Libdl.dlopen_e("sys")
if sysimg != C_NULL
if !force && Base.samefile(Libdl.dlpath(sysimg), "$(sysimg_path).$(Libdl.dlext)")
info("System image already loaded at $(Libdl.dlpath(sysimg)), set force=true to override.")
@info("System image already loaded at $(Libdl.dlpath(sysimg)), set force=true to override.")
return nothing
end
end
Expand Down Expand Up @@ -71,31 +73,31 @@ function build_sysimg(sysimg_path=nothing, cpu_target="native", userimg_path=not
try
# Start by building basecompiler.{ji,o}
basecompiler_path = joinpath(dirname(sysimg_path), "basecompiler")
info("Building basecompiler.o")
info("$julia -C $cpu_target --output-ji $basecompiler_path.ji --output-o $basecompiler_path.o compiler/compiler.jl")
@info("Building basecompiler.o")
@info("$julia -C $cpu_target --output-ji $basecompiler_path.ji --output-o $basecompiler_path.o compiler/compiler.jl")
run(`$julia -C $cpu_target --output-ji $basecompiler_path.ji --output-o $basecompiler_path.o compiler/compiler.jl`)

# Bootstrap off of that to create sys.{ji,o}
info("Building sys.o")
info("$julia -C $cpu_target --output-ji $sysimg_path.ji --output-o $sysimg_path.o -J $basecompiler_path.ji --startup-file=no sysimg.jl")
@info("Building sys.o")
@info("$julia -C $cpu_target --output-ji $sysimg_path.ji --output-o $sysimg_path.o -J $basecompiler_path.ji --startup-file=no sysimg.jl")
run(`$julia -C $cpu_target --output-ji $sysimg_path.ji --output-o $sysimg_path.o -J $basecompiler_path.ji --startup-file=no sysimg.jl`)

if cc !== nothing
link_sysimg(sysimg_path, cc, debug)
!isempty(warn_msg) && foreach(warn, warn_msg)
else
!isempty(warn_msg) && foreach(warn, warn_msg)
info("System image successfully built at $sysimg_path.ji.")
@info("System image successfully built at $sysimg_path.ji.")
end

if !Base.samefile("$(default_sysimg_path(debug)).ji", "$sysimg_path.ji")
if isfile("$sysimg_path.$(Libdl.dlext)")
info("To run Julia with this image loaded, run: `julia -J $sysimg_path.$(Libdl.dlext)`.")
@info("To run Julia with this image loaded, run: `julia -J $sysimg_path.$(Libdl.dlext)`.")
else
info("To run Julia with this image loaded, run: `julia -J $sysimg_path.ji`.")
@info("To run Julia with this image loaded, run: `julia -J $sysimg_path.ji`.")
end
else
info("Julia will automatically load this system image at next startup.")
@info("Julia will automatically load this system image at next startup.")
end
finally
# Cleanup userimg.jl
Expand Down Expand Up @@ -165,8 +167,8 @@ function link_sysimg(sysimg_path=nothing, cc=find_system_compiler(), debug=false
end

sysimg_file = "$sysimg_path.$(Libdl.dlext)"
info("Linking sys.$(Libdl.dlext)")
info("$cc $(join(FLAGS, ' ')) -o $sysimg_file $sysimg_path.o")
@info("Linking sys.$(Libdl.dlext)")
@info("$cc $(join(FLAGS, ' ')) -o $sysimg_file $sysimg_path.o")
# Windows has difficulties overwriting a file in use so we first link to a temp file
if Sys.iswindows() && isfile(sysimg_file)
if success(pipeline(`$cc $FLAGS -o $sysimg_path.tmp $sysimg_path.o`; stdout=stdout, stderr=stderr))
Expand All @@ -176,7 +178,7 @@ function link_sysimg(sysimg_path=nothing, cc=find_system_compiler(), debug=false
else
run(`$cc $FLAGS -o $sysimg_file $sysimg_path.o`)
end
info("System image successfully built at $sysimg_path.$(Libdl.dlext)")
@info("System image successfully built at $sysimg_path.$(Libdl.dlext)")
return
end

Expand Down