Skip to content

use g++/clang++ for sysimage #602

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

Merged
merged 1 commit into from
Oct 13, 2021
Merged
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
20 changes: 11 additions & 9 deletions src/PackageCompiler.jl
Original file line number Diff line number Diff line change
Expand Up @@ -88,24 +88,26 @@ function march()
end
end

function run_compiler(cmd::Cmd)
function run_compiler(cmd::Cmd; cplusplus::Bool=false)
cc = get(ENV, "JULIA_CC", nothing)
path = nothing
@static if Sys.iswindows()
path = joinpath(LazyArtifacts.artifact"mingw-w64", (Int==Int64 ? "mingw64" : "mingw32"), "bin", "gcc.exe")
path = joinpath(LazyArtifacts.artifact"mingw-w64", (Int==Int64 ? "mingw64" : "mingw32"), "bin", cplusplus ? "g++.exe" : "gcc.exe")
compiler_cmd = `$path`
end
if cc !== nothing
compiler_cmd = Cmd(Base.shell_split(cc))
path = nothing
elseif !Sys.iswindows()
if Sys.which("gcc") !== nothing
compiler_cmd = `gcc`
elseif Sys.which("clang") !== nothing
compiler_cmd = `clang`
else
error("could not find a compiler, looked for `gcc` and `clang`")
found_compiler = false
compilers = cplusplus ? ("g++", "clang++") : ("gcc", "clang")
for compiler in compilers
if Sys.which(compiler) !== nothing
compiler_cmd = `$compiler`
found_compiler = true
end
end
found_compiler || error("could not find a compiler, looked for ", join(compilers, " and "))
end
if path !== nothing
compiler_cmd = addenv(compiler_cmd, "PATH" => string(ENV["PATH"], ";", dirname(path)))
Expand Down Expand Up @@ -627,7 +629,7 @@ function create_sysimg_from_object_file(input_object::String,
extra = get_extra_linker_flags(version, compat_level, soname)
m = something(march(), ``)
cmd = `$(bitflag()) $m -shared -L$(julia_libdir()) -L$(julia_private_libdir()) -o $sysimage_path $o_file_flags -ljulia-internal -ljulia $extra`
run_compiler(cmd)
run_compiler(cmd; cplusplus=true)
return nothing
end

Expand Down