Skip to content
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
32 changes: 26 additions & 6 deletions src/PackageCompiler.jl
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ function march()
end
end

const warned_cpp_compiler = Ref{Bool}(false)

function run_compiler(cmd::Cmd; cplusplus::Bool=false)
cc = get(ENV, "JULIA_CC", nothing)
path = nothing
Expand All @@ -99,15 +101,33 @@ function run_compiler(cmd::Cmd; cplusplus::Bool=false)
compiler_cmd = Cmd(Base.shell_split(cc))
path = nothing
elseif !Sys.iswindows()
compilers_cpp = ("g++", "clang++")
compilers_c = ("gcc", "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
if cplusplus
for compiler in compilers_cpp
if Sys.which(compiler) !== nothing
compiler_cmd = `$compiler`
found_compiler = true
break
end
end
end
found_compiler || error("could not find a compiler, looked for ", join(compilers, " and "))
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
end
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