From 9bb5a5f90a62d895ba1f716a335fa9f5274d9fce Mon Sep 17 00:00:00 2001 From: Cody Tapscott <84105208+topolarity@users.noreply.github.com> Date: Thu, 30 Oct 2025 17:42:04 -0400 Subject: [PATCH 1/3] Don't look up MinGW artifact if "JULIA_CC" is set see https://github.com/JuliaLang/JuliaC.jl/pull/67 --- src/PackageCompiler.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PackageCompiler.jl b/src/PackageCompiler.jl index 6fa7a565..3f430e3f 100644 --- a/src/PackageCompiler.jl +++ b/src/PackageCompiler.jl @@ -211,7 +211,7 @@ 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() + @static if Sys.iswindows() && cc === nothing path = joinpath(LazyArtifacts.artifact"mingw-w64", "extracted_files", (Int==Int64 ? "mingw64" : "mingw32"), "bin", cplusplus ? "g++.exe" : "gcc.exe") compiler_cmd = `$path` end From 489d1e7189e83d73db4e1f9d44989e0cc7babb20 Mon Sep 17 00:00:00 2001 From: Cody Tapscott <84105208+topolarity@users.noreply.github.com> Date: Thu, 30 Oct 2025 17:45:03 -0400 Subject: [PATCH 2/3] Fix-up --- src/PackageCompiler.jl | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/PackageCompiler.jl b/src/PackageCompiler.jl index 3f430e3f..e65cf9c0 100644 --- a/src/PackageCompiler.jl +++ b/src/PackageCompiler.jl @@ -211,10 +211,6 @@ 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() && cc === nothing - 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 @@ -246,6 +242,9 @@ function get_compiler_cmd(; cplusplus::Bool=false) end found_compiler || error("could not find a compiler, looked for ", join(((cplusplus ? compilers_cpp : ())..., compilers_c...), ", ", " and ")) + else + path = joinpath(LazyArtifacts.artifact"mingw-w64", "extracted_files", (Int==Int64 ? "mingw64" : "mingw32"), "bin", cplusplus ? "g++.exe" : "gcc.exe") + compiler_cmd = `$path` end if path !== nothing compiler_cmd = addenv(compiler_cmd, "PATH" => string(ENV["PATH"], ";", dirname(path))) From 844987b31fea08867e55b8f7cb1809dd98aaf59d Mon Sep 17 00:00:00 2001 From: Cody Tapscott <84105208+topolarity@users.noreply.github.com> Date: Thu, 30 Oct 2025 17:49:29 -0400 Subject: [PATCH 3/3] Fix-up --- src/PackageCompiler.jl | 52 ++++++++++++++++++++++-------------------- 1 file changed, 27 insertions(+), 25 deletions(-) diff --git a/src/PackageCompiler.jl b/src/PackageCompiler.jl index e65cf9c0..79e39cae 100644 --- a/src/PackageCompiler.jl +++ b/src/PackageCompiler.jl @@ -214,37 +214,39 @@ function get_compiler_cmd(; cplusplus::Bool=false) 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 ")) - else - path = joinpath(LazyArtifacts.artifact"mingw-w64", "extracted_files", (Int==Int64 ? "mingw64" : "mingw32"), "bin", cplusplus ? "g++.exe" : "gcc.exe") - compiler_cmd = `$path` end if path !== nothing compiler_cmd = addenv(compiler_cmd, "PATH" => string(ENV["PATH"], ";", dirname(path)))