Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow the user to pass arbitrary C flags (on all platforms) #665

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
14 changes: 10 additions & 4 deletions src/PackageCompiler.jl
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ const WARNED_CPP_COMPILER = Ref{Bool}(false)

function run_compiler(cmd::Cmd; cplusplus::Bool=false)
cc = get(ENV, "JULIA_CC", nothing)
cc_flags = get(ENV, "JULIA_CC_FLAGS", nothing)
path = nothing
@static if Sys.iswindows()
path = joinpath(LazyArtifacts.artifact"mingw-w64", (Int==Int64 ? "mingw64" : "mingw32"), "bin", cplusplus ? "g++.exe" : "gcc.exe")
Expand Down Expand Up @@ -158,7 +159,12 @@ function run_compiler(cmd::Cmd; cplusplus::Bool=false)
if path !== nothing
compiler_cmd = addenv(compiler_cmd, "PATH" => string(ENV["PATH"], ";", dirname(path)))
end
full_cmd = `$compiler_cmd $cmd`
if cc_flags !== nothing
compiler_flags = Cmd(Base.shell_split(cc_flags))
else
compiler_flags = ``
end
full_cmd = `$compiler_cmd $compiler_flags $cmd`
@debug "running $full_cmd"
run(full_cmd)
end
Expand Down Expand Up @@ -366,7 +372,7 @@ project will be put into the sysimage.

An attempt to automatically find a compiler will be done but can also be given
explicitly by setting the environment variable `JULIA_CC` to a path to a
compiler (can also include extra arguments to the compiler, like `-g`).
compiler. Extra arguments to the compiler (like `-g`) can be specified with `JULIA_CC_FLAGS`.

### Keyword arguments:

Expand Down Expand Up @@ -633,7 +639,7 @@ argument, for example:

An attempt to automatically find a compiler will be done but can also be given
explicitly by setting the environment variable `JULIA_CC` to a path to a
compiler (can also include extra arguments to the compiler, like `-g`).
compiler. Extra arguments to the compiler (like `-g`) can be specified with `JULIA_CC_FLAGS`.

### Keyword arguments:

Expand Down Expand Up @@ -792,7 +798,7 @@ simply calls `jl_atexit_hook(retcode)`.)

An attempt to automatically find a compiler will be done but can also be given
explicitly by setting the environment variable `JULIA_CC` to a path to a
compiler (can also include extra arguments to the compiler, like `-g`).
compiler. Extra arguments to the compiler (like `-g`) can be specified with `JULIA_CC_FLAGS`.

### Keyword arguments:

Expand Down