Skip to content
This repository was archived by the owner on Jun 9, 2023. It is now read-only.

Commit 6d30a50

Browse files
committed
fixes
1 parent 7b592d8 commit 6d30a50

File tree

1 file changed

+26
-11
lines changed

1 file changed

+26
-11
lines changed

src/PackageCompilerX.jl

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,28 @@ yesno(b::Bool) = b ? "yes" : "no"
2020
bitflag() = Int == Int32 ? `-m32` : `-m64`
2121
march() = (Int == Int32 ? `-march=pentium4` : ``)
2222

23-
function get_compiler()
23+
function windows_compiler_artifact_path(f, compiler)
2424
if Sys.iswindows()
25-
gcc_win_artifact_path = joinpath(Pkg.Artifacts.artifact"x86_64-w64-mingw32", "mingw64", "bin", "gcc.exe")
26-
return `$gcc_win_artifact_path`
25+
withenv("PATH" => string(ENV["PATH"], ";", dirname(compiler))) do
26+
f()
27+
end
28+
else
29+
f()
2730
end
31+
end
32+
33+
function get_compiler()
2834
cc = get(ENV, "JULIA_CC", nothing)
2935
if cc !== nothing
30-
return `$cc`
36+
return cc
3137
end
32-
if Sys.which("gcc") !== nothing
33-
return `gcc`
38+
if Sys.iswindows()
39+
return joinpath(Pkg.Artifacts.artifact"x86_64-w64-mingw32", "mingw64", "bin", "gcc.exe")
3440
end
35-
if Sys.which("clang") !== nothing
36-
return `clang`
41+
if Sys.which("gcc") !== nothing
42+
return gcc
43+
elseif Sys.which("clang") !== nothing
44+
return clang
3745
end
3846
error("could not find a compiler, looked for `gcc` and `clang`")
3947
end
@@ -362,9 +370,12 @@ function create_sysimg_from_object_file(input_object::String, sysimage_path::Str
362370
o_file = `-Wl,--whole-archive $input_object -Wl,--no-whole-archive`
363371
end
364372
extra = Sys.iswindows() ? `-Wl,--export-all-symbols` : ``
365-
cmd = `$(get_compiler()) $(bitflag()) $(march()) -shared -L$(julia_libdir) -o $sysimage_path $o_file -ljulia $extra`
373+
compiler = get_compiler()
374+
cmd = `$compiler $(bitflag()) $(march()) -shared -L$(julia_libdir) -o $sysimage_path $o_file -ljulia $extra`
366375
@debug "running $cmd"
367-
run(cmd)
376+
windows_compiler_artifact_path(compiler) do
377+
run(cmd)
378+
end
368379
return nothing
369380
end
370381

@@ -560,9 +571,13 @@ function create_executable_from_sysimg(;sysimage_path::String,
560571
else
561572
rpath = `-Wl,-rpath,\$ORIGIN:\$ORIGIN/../lib`
562573
end
563-
cmd = `$(get_compiler()) -DJULIAC_PROGRAM_LIBNAME=$(repr(sysimage_path)) $(bitflag()) $(march()) -o $(executable_path) $(wrapper) $(sysimage_path) -O2 $rpath $flags`
574+
compiler = get_compiler()
575+
cmd = `$compiler -DJULIAC_PROGRAM_LIBNAME=$(repr(sysimage_path)) $(bitflag()) $(march()) -o $(executable_path) $(wrapper) $(sysimage_path) -O2 $rpath $flags`
564576
@debug "running $cmd"
565577
run(cmd)
578+
windows_compiler_artifact_path(compiler) do
579+
run(cmd)
580+
end
566581
return nothing
567582
end
568583

0 commit comments

Comments
 (0)