Precompilation and finalizers

I wanted to register a finalizer for instances of some specific type. The final requirement is to achieve the following features simultaneously:

  1. invoking some callback once the object is gc-ed
  2. keeping the object precompile-able

Unfortunately, it seems that my finalizer got lost after precompilation:

module MyMod

mutable struct S
    function S()
        self = new()
        finalizer(self) do x
            println("call finalizer")
        end
        self
    end
end

const precompiled_s = S()
end

If I precompile the module S, and load the module again, the finalizer never gets called.

How could I restore my finalizers registered to the all objects of S?