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

Commit 4d493e1

Browse files
committed
fixes
1 parent 4c7ce2d commit 4d493e1

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
@@ -361,9 +369,12 @@ function create_sysimg_from_object_file(input_object::String, sysimage_path::Str
361369
o_file = `-Wl,--whole-archive $input_object -Wl,--no-whole-archive`
362370
end
363371
extra = Sys.iswindows() ? `-Wl,--export-all-symbols` : ``
364-
cmd = `$(get_compiler()) $(bitflag()) $(march()) -shared -L$(julia_libdir) -o $sysimage_path $o_file -ljulia $extra`
372+
compiler = get_compiler()
373+
cmd = `$compiler $(bitflag()) $(march()) -shared -L$(julia_libdir) -o $sysimage_path $o_file -ljulia $extra`
365374
@debug "running $cmd"
366-
run(cmd)
375+
windows_compiler_artifact_path(compiler) do
376+
run(cmd)
377+
end
367378
return nothing
368379
end
369380

@@ -559,9 +570,13 @@ function create_executable_from_sysimg(;sysimage_path::String,
559570
else
560571
rpath = `-Wl,-rpath,\$ORIGIN:\$ORIGIN/../lib`
561572
end
562-
cmd = `$(get_compiler()) -DJULIAC_PROGRAM_LIBNAME=$(repr(sysimage_path)) $(bitflag()) $(march()) -o $(executable_path) $(wrapper) $(sysimage_path) -O2 $rpath $flags`
573+
compiler = get_compiler()
574+
cmd = `$compiler -DJULIAC_PROGRAM_LIBNAME=$(repr(sysimage_path)) $(bitflag()) $(march()) -o $(executable_path) $(wrapper) $(sysimage_path) -O2 $rpath $flags`
563575
@debug "running $cmd"
564576
run(cmd)
577+
windows_compiler_artifact_path(compiler) do
578+
run(cmd)
579+
end
565580
return nothing
566581
end
567582

0 commit comments

Comments
 (0)