Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/codegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3505,6 +3505,10 @@ static jl_cgval_t emit_globalref(jl_codectx_t &ctx, jl_module_t *mod, jl_sym_t *
undef_var_error_ifnot(ctx, ConstantInt::get(getInt1Ty(ctx.builder.getContext()), 0), name, (jl_value_t*)mod);
return jl_cgval_t();
}
if (jl_generating_output()) {
// root is required to allow bindings to be pruned, especially by `--trim`
jl_temporary_root(ctx, constval);
}
return mark_julia_const(ctx, constval);
}
if (rkp.kind != PARTITION_KIND_GLOBAL) {
Expand Down
13 changes: 13 additions & 0 deletions test/trimming/trimmability.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ area(c::Circle) = pi*c.radius^2

sum_areas(v::Vector{Shape}) = sum(area, v)

mutable struct Foo; x::Int; end
const storage = Foo[]
function add_one(x::Cint)::Cint
push!(storage, Foo(x))
return x + 1
end

function @main(args::Vector{String})::Cint
println(Core.stdout, str())
println(Core.stdout, PROGRAM_FILE)
Expand All @@ -38,6 +45,12 @@ function @main(args::Vector{String})::Cint
d = mapreduce(x -> x^2, +, sorted_arr)
# e = reduce(xor, rand(Int, 10))

for i = 1:10
# https://github.com/JuliaLang/julia/issues/60846
add_one(Cint(i))
GC.gc()
end

try
sock = connect("localhost", 4900)
if isopen(sock)
Expand Down
Loading