Skip to content

Commit dce0653

Browse files
committed
Allow the user to define arbitrary C variables on all platforms.
Since PC.jl now exposes `c_driver_program` which allows the users to specify their own C wrapper program, it would be nice to be able to pass in more variables which might be best defined at build time. Currently this functionality is effectively limited to Linux as specifying $JULIA_CC will prevent PC.jl from inferring gcc.exe from the relative mingw installation.
1 parent 94fdba2 commit dce0653

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/PackageCompiler.jl

+5-4
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ const WARNED_CPP_COMPILER = Ref{Bool}(false)
118118

119119
function run_compiler(cmd::Cmd; cplusplus::Bool=false)
120120
cc = get(ENV, "JULIA_CC", nothing)
121+
cc_flags = get(ENV, "JULIA_CC_FLAGS", "")
121122
path = nothing
122123
@static if Sys.iswindows()
123124
path = joinpath(LazyArtifacts.artifact"mingw-w64", (Int==Int64 ? "mingw64" : "mingw32"), "bin", cplusplus ? "g++.exe" : "gcc.exe")
@@ -158,7 +159,7 @@ function run_compiler(cmd::Cmd; cplusplus::Bool=false)
158159
if path !== nothing
159160
compiler_cmd = addenv(compiler_cmd, "PATH" => string(ENV["PATH"], ";", dirname(path)))
160161
end
161-
full_cmd = `$compiler_cmd $cmd`
162+
full_cmd = `$compiler_cmd $cc_flags $cmd`
162163
@debug "running $full_cmd"
163164
run(full_cmd)
164165
end
@@ -366,7 +367,7 @@ project will be put into the sysimage.
366367
367368
An attempt to automatically find a compiler will be done but can also be given
368369
explicitly by setting the environment variable `JULIA_CC` to a path to a
369-
compiler (can also include extra arguments to the compiler, like `-g`).
370+
compiler. Extra arguments to the compiler (like `-g`) can be specified with `JULIA_CC_FLAGS`.
370371
371372
### Keyword arguments:
372373
@@ -633,7 +634,7 @@ argument, for example:
633634
634635
An attempt to automatically find a compiler will be done but can also be given
635636
explicitly by setting the environment variable `JULIA_CC` to a path to a
636-
compiler (can also include extra arguments to the compiler, like `-g`).
637+
compiler. Extra arguments to the compiler (like `-g`) can be specified with `JULIA_CC_FLAGS`.
637638
638639
### Keyword arguments:
639640
@@ -792,7 +793,7 @@ simply calls `jl_atexit_hook(retcode)`.)
792793
793794
An attempt to automatically find a compiler will be done but can also be given
794795
explicitly by setting the environment variable `JULIA_CC` to a path to a
795-
compiler (can also include extra arguments to the compiler, like `-g`).
796+
compiler. Extra arguments to the compiler (like `-g`) can be specified with `JULIA_CC_FLAGS`.
796797
797798
### Keyword arguments:
798799

0 commit comments

Comments
 (0)