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

Fix build_sysimg on windows #18393

Merged
merged 2 commits into from
Sep 9, 2016
Merged
Changes from 1 commit
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
Next Next commit
Fix build_sysimg on windows
  • Loading branch information
musm committed Sep 7, 2016
commit 59c1cdaba7b5d0e3f01d9688b54fea4b340b0b77
18 changes: 12 additions & 6 deletions contrib/build_sysimg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ function build_sysimg(sysimg_path=nothing, cpu_target="native", userimg_path=not
userimg_path = abspath(userimg_path)
end

# Enter base/ and setup some useful paths
# Enter base and setup some useful paths
base_dir = dirname(Base.find_source_file("sysimg.jl"))
cd(base_dir) do
julia = joinpath(JULIA_HOME, debug ? "julia-debug" : "julia")
Expand Down Expand Up @@ -71,18 +71,18 @@ function build_sysimg(sysimg_path=nothing, cpu_target="native", userimg_path=not
try
# Start by building inference0.{ji,o}
inference0_path = joinpath(dirname(sysimg_path), "inference0")
info("Building inference0.o...")
info("Building inference0.o")
println("$julia -C $cpu_target --output-ji $inference0_path.ji --output-o $inference0_path.o coreimg.jl")
run(`$julia -C $cpu_target --output-ji $inference0_path.ji --output-o $inference0_path.o coreimg.jl`)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like this inference0 step is completely unused

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, i'll remove it. The only reference I have explaining inference0 is here https://github.com/JuliaLang/julia/blob/6b5a05eb1a029aef93f77b60bb1d745c7d6e1d8d/doc/devdocs/functions.rst
(scroll all the way down)
It doesn't show up in any other search.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vtjnash hasn't updated the devdocs since he removed the inference0 step


# Bootstrap off off that to create inference.{ji,o}
inference_path = joinpath(dirname(sysimg_path), "inference")
info("Building inference.o...")
info("Building inference.o")
println("$julia -C $cpu_target --output-ji $inference_path.ji --output-o $inference_path.o coreimg.jl")
run(`$julia -C $cpu_target --output-ji $inference_path.ji --output-o $inference_path.o coreimg.jl`)

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

Expand Down Expand Up @@ -161,9 +161,15 @@ function link_sysimg(sysimg_path=nothing, cc=find_system_compiler(), debug=false
push!(FLAGS, "-lssp")
end

sysimg_file = "$sysimg_path.$(Libdl.dlext)"
info("Linking sys.$(Libdl.dlext)")
run(`$cc $FLAGS -o $sysimg_path.$(Libdl.dlext) $sysimg_path.o`)

if is_windows() && isfile(sysimg_file)
mv(sysimg_file, "$sysimg_file.old"; remove_destination=true)
run(`$cc $FLAGS -o $sysimg_file $sysimg_path.o`)
run(`rm "$sysimg_path.$(Libdl.dlext).old"`)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a little surprised this doesn't error, even after the file has been moved it's still loaded by the running executable

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe. I have seen many times in windows that a stubborn file that refuses to be deleted just needs a rename, before you can delete it, strange but it work.

else
run(`$cc $FLAGS -o $sysimg_file $sysimg_path.o`)
end
info("System image successfully built at $sysimg_path.$(Libdl.dlext)")
end

Expand Down