Skip to content

Commit 9c774da

Browse files
authored
Fix --cc-flag to allow multiple flags (#150)
1 parent ded6405 commit 9c774da

File tree

4 files changed

+12
-9
lines changed

4 files changed

+12
-9
lines changed

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ usage: juliac.jl [-v] [-q] [-d <dir>] [-n <name>] [-p <file>] [-c]
9393
[--compile {yes|no|all|min}] [-C <target>]
9494
[-O {0,1,2,3}] [-g <level>] [--inline {yes|no}]
9595
[--check-bounds {yes|no}] [--math-mode {ieee,fast}]
96-
[--cc <cc>] [--cc-flags <flags>] [--version] [-h]
96+
[--cc <cc>] [--cc-flag <flag>] [--version] [-h]
9797
juliaprog [cprog]
9898
9999
Static Julia Compiler
@@ -162,8 +162,9 @@ optional arguments:
162162
disallow or enable unsafe floating point
163163
optimizations
164164
--cc <cc> system C compiler
165-
--cc-flags <flags> pass custom flags to the system C compiler
166-
when building a shared library or executable
165+
--cc-flag <flag> pass custom flag to the system C compiler when
166+
building a shared library or executable, can
167+
be repeated for multiple flags
167168
--version show version information and exit
168169
-h, --help show this help message and exit
169170

juliac.jl

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,10 +144,12 @@ Base.@ccallable function julia_main(args::Vector{String})::Cint
144144
arg_type = String
145145
metavar = "<cc>"
146146
help = "system C compiler"
147-
"--cc-flags"
147+
"--cc-flag"
148148
arg_type = String
149-
metavar = "<flags>"
150-
help = "pass custom flags to the system C compiler when building a shared library or executable"
149+
action = :append_arg
150+
dest_name = "cc-flags"
151+
metavar = "<flag>"
152+
help = "pass custom flag to the system C compiler when building a shared library or executable, can be repeated for multiple flags"
151153
end
152154

153155
s.epilog = """

src/static_julia.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ compiles the Julia file at path `juliaprog` with keyword arguments:
6565
check_bounds {yes|no} emit bounds checks always or never
6666
math_mode {ieee,fast} disallow or enable unsafe floating point optimizations
6767
cc system C compiler
68-
cc_flags <flags> pass custom flags to the system C compiler when building a shared library or executable
68+
cc_flags <flags> pass custom flags to the system C compiler when building a shared library or executable (either `nothing` or a string array)
6969
"""
7070
function static_julia(
7171
juliaprog;

test/runtests.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,10 @@ end
9292
@test isfile(joinpath(builddir, "hello.$(PackageCompiler.Libdl.dlext)"))
9393
@test isfile(joinpath(builddir, "hello$executable_ext"))
9494
@test success(`$(joinpath(builddir, "hello$executable_ext"))`)
95-
@testset "--cc-flags" begin
95+
@testset "--cc-flag" begin
9696
# Try passing `--help` to $cc. This should work for any system compiler.
9797
# Then grep the output for "-g", which should be present on any system.
98-
@test occursin("-g", read(`$julia $juliac -se --cc-flags="--help" $jlfile $cfile --builddir $builddir`, String))
98+
@test occursin("-g", read(`$julia $juliac -se --cc-flag="--help" $jlfile $cfile --builddir $builddir`, String))
9999
# Just as a control, make sure that without passing '--help', we don't see "-g"
100100
@test !occursin("-g", read(`$julia $juliac -se $jlfile $cfile --builddir $builddir`, String))
101101
end

0 commit comments

Comments
 (0)