Skip to content
Open
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
53 changes: 27 additions & 26 deletions src/PackageCompiler.jl
Original file line number Diff line number Diff line change
Expand Up @@ -211,41 +211,42 @@ const WARNED_CPP_COMPILER = Ref{Bool}(false)
function get_compiler_cmd(; cplusplus::Bool=false)
cc = get(ENV, "JULIA_CC", nothing)
path = nothing
@static if Sys.iswindows()
path = joinpath(LazyArtifacts.artifact"mingw-w64", "extracted_files", (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()
compilers_cpp = ("g++", "clang++")
compilers_c = ("gcc", "clang")
found_compiler = false
if cplusplus
for compiler in compilers_cpp
if Sys.which(compiler) !== nothing
compiler_cmd = `$compiler`
found_compiler = true
break
else
@static if Sys.iswindows()
path = joinpath(LazyArtifacts.artifact"mingw-w64", "extracted_files", (Int==Int64 ? "mingw64" : "mingw32"), "bin", cplusplus ? "g++.exe" : "gcc.exe")
compiler_cmd = `$path`
else
compilers_cpp = ("g++", "clang++")
compilers_c = ("gcc", "clang")
found_compiler = false
if cplusplus
for compiler in compilers_cpp
if Sys.which(compiler) !== nothing
compiler_cmd = `$compiler`
found_compiler = true
break
end
end
end
end
if !found_compiler
for compiler in compilers_c
if Sys.which(compiler) !== nothing
compiler_cmd = `$compiler`
found_compiler = true
if cplusplus && !WARNED_CPP_COMPILER[]
@warn "could not find a c++ compiler (g++ or clang++), falling back to $compiler, this might cause link errors"
WARNED_CPP_COMPILER[] = true
if !found_compiler
for compiler in compilers_c
if Sys.which(compiler) !== nothing
compiler_cmd = `$compiler`
found_compiler = true
if cplusplus && !WARNED_CPP_COMPILER[]
@warn "could not find a c++ compiler (g++ or clang++), falling back to $compiler, this might cause link errors"
WARNED_CPP_COMPILER[] = true
end
break
end
break
end
end
found_compiler || error("could not find a compiler, looked for ",
join(((cplusplus ? compilers_cpp : ())..., compilers_c...), ", ", " and "))
end
found_compiler || error("could not find a compiler, looked for ",
join(((cplusplus ? compilers_cpp : ())..., compilers_c...), ", ", " and "))
end
if path !== nothing
compiler_cmd = addenv(compiler_cmd, "PATH" => string(ENV["PATH"], ";", dirname(path)))
Expand Down
Loading