-
-
Notifications
You must be signed in to change notification settings - Fork 195
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 define arbitrary C variables passed to c_driver_program. #652
Conversation
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. For my use case, I would like to bake in a build version at build time. And rather than storing it in julia or needing to compile it into a file, it is far easeier to just have something like: #ifdef VERSION printf("%s\n", VERSION); #else This change will allow for that by passing a `c_defines` dict and letting the user pass in arguments for the compiler to define as a macro.
Codecov Report
@@ Coverage Diff @@
## master #652 +/- ##
==========================================
+ Coverage 95.25% 95.29% +0.04%
==========================================
Files 2 2
Lines 464 468 +4
==========================================
+ Hits 442 446 +4
Misses 22 22
Continue to review full report at Codecov.
|
Can't you already do this by setting an appropriate |
How would that work? setting it like it does seem like the way the variable is handled in Further, if I'm on windows I really want to leave the logic alone for using gcc from the local mingw. Otherwise I'm hard-coding a magic directory string for where it will be or adding the dependency to my own project. |
Okay, what I don't want is to add a zillion of keyword arguments for all kind of compiler features. There should in my opinion be one at most one argument for advanced users where they can customize the compiler options. Also, the docs do say:
|
very fair. and I must have just missed that in the docs, however I still feel like that makes those options inaccessible on windows. As a long term solution, why not organize the compiler flags and such into some sort of organized object/struct, where all options like binary location, environment, flags, cpu target, etc are stored. The current functions as is could just keep complexity away from the user and simply construct it in place and then delegate off to a version which accepts the struct, but an advanced user could manage their own versions of it if they wanted and then call directly into the versions which use the struct? Alternatively just formalize a new environment variable which is directly intended to pass arguments instead of being dual purpose? |
how would you feel if instead this looked something like: diff --git a/src/PackageCompiler.jl b/src/PackageCompiler.jl
index 4068520..4d0dbb1 100644
--- a/src/PackageCompiler.jl
+++ b/src/PackageCompiler.jl
@@ -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", "")
path = nothing
@static if Sys.iswindows()
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)
if path !== nothing
compiler_cmd = addenv(compiler_cmd, "PATH" => string(ENV["PATH"], ";", dirname(path)))
end
- full_cmd = `$compiler_cmd $cmd`
+ full_cmd = `$compiler_cmd $cc_flags $cmd`
@debug "running $full_cmd"
run(full_cmd)
end |
Closed in favor of #665 |
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.For my use case, I would like to bake in a build version at build time. And rather than storing it in julia or needing to compile it into a file, it is far easeier to just have something like:
Where
VERSION
would need to be passed to the compiler like:-DVERSION="1.3.0"
.This change will allow for that by passing a
c_defines
dict and letting the user pass in arguments for the compiler to define as a macro.