Skip to content

Commit 680803c

Browse files
authored
get trimming test working again (JuliaLang#56689)
1 parent 7e2e0ae commit 680803c

File tree

3 files changed

+10
-12
lines changed

3 files changed

+10
-12
lines changed

contrib/juliac.jl

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
cmd = Base.julia_cmd()
55
cmd = `$cmd --startup-file=no --history-file=no`
66
output_type = nothing # exe, sharedlib, sysimage
7-
trim = nothing
87
outname = nothing
98
file = nothing
109
add_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)
2322
end
2423

24+
# arguments to forward to julia compilation process
25+
julia_args = []
26+
2527
let 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
""")
8078
end
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)
8481
verbose && println("Running: $cmd")
8582
if !success(pipeline(cmd; stdout, stderr))
8683
println(stderr, "\nFailed to compile $file")

src/staticdata.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2578,6 +2578,7 @@ static void strip_specializations_(jl_method_instance_t *mi)
25782578
if (inferred && inferred != jl_nothing) {
25792579
if (jl_options.strip_ir) {
25802580
record_field_change((jl_value_t**)&codeinst->inferred, jl_nothing);
2581+
record_field_change((jl_value_t**)&codeinst->edges, (jl_value_t*)jl_emptysvec);
25812582
}
25822583
else if (jl_options.strip_metadata) {
25832584
jl_value_t *stripped = strip_codeinfo_meta(mi->def.method, inferred, codeinst);

test/trimming/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ LDFLAGS_ADD = -lm $(shell $(JULIA_CONFIG) --ldflags --ldlibs) -ljulia-internal
3333
release: hello$(EXE)
3434

3535
hello.o: $(SRCDIR)/hello.jl $(BUILDSCRIPT)
36-
$(JULIA) -t 1 -J $(BIN)/../lib/julia/sys.so --startup-file=no --history-file=no --output-o $@ --output-incremental=no --strip-ir --strip-metadata --trim $(BUILDSCRIPT) $(SRCDIR)/hello.jl --output-exe true
36+
$(JULIA) -t 1 -J $(BIN)/../lib/julia/sys.so --startup-file=no --history-file=no --output-o $@ --output-incremental=no --strip-ir --strip-metadata --experimental --trim $(BUILDSCRIPT) $(SRCDIR)/hello.jl --output-exe true
3737

3838
init.o: $(SRCDIR)/init.c
3939
$(CC) -c -o $@ $< $(CPPFLAGS_ADD) $(CPPFLAGS) $(CFLAGS_ADD) $(CFLAGS)

0 commit comments

Comments
 (0)