diff --git a/core/src/main/java/org/teavm/backend/c/CTarget.java b/core/src/main/java/org/teavm/backend/c/CTarget.java index 9e883af3d..77aed11c8 100644 --- a/core/src/main/java/org/teavm/backend/c/CTarget.java +++ b/core/src/main/java/org/teavm/backend/c/CTarget.java @@ -122,6 +122,7 @@ import org.teavm.runtime.CallSiteLocation; import org.teavm.runtime.EventQueue; import org.teavm.runtime.ExceptionHandling; import org.teavm.runtime.Fiber; +import org.teavm.runtime.GC; import org.teavm.runtime.RuntimeArray; import org.teavm.runtime.RuntimeClass; import org.teavm.runtime.RuntimeObject; @@ -739,7 +740,17 @@ public class CTarget implements TeaVMTarget, TeaVMCHost { private void generateStaticInitializerCalls(GenerationContext context, CodeWriter writer, IncludeManager includes, ListableClassReaderSource classes) { MethodDescriptor clinitDescriptor = new MethodDescriptor("", ValueType.VOID); + if (classes.getClassNames().contains(GC.class.getName())) { + includes.includeClass(GC.class.getName()); + String clinitName = context.getNames().forMethod(new MethodReference(GC.class.getName(), + clinitDescriptor)); + writer.println(clinitName + "();"); + } + for (String className : classes.getClassNames()) { + if (className.equals(GC.class.getName())) { + continue; + } ClassReader cls = classes.get(className); if (!context.getCharacteristics().isStaticInit(cls.getName()) && !context.getCharacteristics().isStructure(cls.getName())) {