44cmd = Base. julia_cmd ()
55cmd = ` $cmd --startup-file=no --history-file=no`
66output_type = nothing # exe, sharedlib, sysimage
7- trim = nothing
87outname = nothing
98file = nothing
109add_ccallables = false
@@ -15,13 +14,16 @@ if help !== nothing
1514 println (
1615 """
1716 Usage: julia juliac.jl [--output-exe | --output-lib | --output-sysimage] <name> [options] <file.jl>
18- --trim=<no,safe,unsafe,unsafe-warn> Only output code statically determined to be reachable
17+ --experimental -- trim=<no,safe,unsafe,unsafe-warn> Only output code statically determined to be reachable
1918 --compile-ccallable Include all methods marked `@ccallable` in output
2019 --verbose Request verbose output
2120 """ )
2221 exit (0 )
2322end
2423
24+ # arguments to forward to julia compilation process
25+ julia_args = []
26+
2527let i = 1
2628 while i <= length (ARGS )
2729 arg = ARGS [i]
@@ -31,17 +33,13 @@ let i = 1
3133 i == length (ARGS ) && error (" Output specifier requires an argument" )
3234 global outname = ARGS [i+ 1 ]
3335 i += 1
34- elseif startswith (arg, " --trim" )
35- arg = split (arg, ' =' )
36- if length (arg) == 1
37- global trim = " safe"
38- else
39- global trim = arg[2 ]
40- end
4136 elseif arg == " --compile-ccallable"
4237 global add_ccallables = true
4338 elseif arg == " --verbose"
4439 global verbose = true
40+ elseif startswith (arg, " --trim" ) || arg == " --experimental"
41+ # forwarded args
42+ push! (julia_args, arg)
4543 else
4644 if arg[1 ] == ' -' || ! isnothing (file)
4745 println (" Unexpected argument `$arg `" )
@@ -79,8 +77,7 @@ open(initsrc_path, "w") do io
7977 """ )
8078end
8179
82- static_call_graph_arg () = isnothing (trim) ? ` ` : ` --trim=$(trim) `
83- cmd = addenv (` $cmd --project=$(Base. active_project ()) --output-o $img_path --output-incremental=no --strip-ir --strip-metadata $(static_call_graph_arg ()) $(joinpath (@__DIR__ ," juliac-buildscript.jl" )) $absfile $output_type $add_ccallables ` , " OPENBLAS_NUM_THREADS" => 1 , " JULIA_NUM_THREADS" => 1 )
80+ cmd = addenv (` $cmd --project=$(Base. active_project ()) --output-o $img_path --output-incremental=no --strip-ir --strip-metadata $julia_args $(joinpath (@__DIR__ ," juliac-buildscript.jl" )) $absfile $output_type $add_ccallables ` , " OPENBLAS_NUM_THREADS" => 1 , " JULIA_NUM_THREADS" => 1 )
8481verbose && println (" Running: $cmd " )
8582if ! success (pipeline (cmd; stdout , stderr ))
8683 println (stderr , " \n Failed to compile $file " )
0 commit comments