From 13db2c13e5f980a5b2103387abd075ecb7a1befb Mon Sep 17 00:00:00 2001 From: Ayke van Laethem Date: Wed, 17 Mar 2021 02:29:04 +0100 Subject: [PATCH] compiler: do not use llvm.GlobalContext() This is a leftover from a long time ago, when everything was still in the global context. The fact that this uses the global context is most certainly a bug. I have seen occasional crashes in the build-packages-indepedently branch (and PRs based on it) which I suspect are caused by this bug. I think this is a long-dormant bug that only surfaced when doing the compilation steps in parallel. --- compiler/compiler.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/compiler/compiler.go b/compiler/compiler.go index a7887f36..faa5038a 100644 --- a/compiler/compiler.go +++ b/compiler/compiler.go @@ -316,14 +316,14 @@ func CompileProgram(lprogram *loader.Program, machine llvm.TargetMachine, config c.mod.AddNamedMetadataOperand("llvm.module.flags", c.ctx.MDNode([]llvm.Metadata{ llvm.ConstInt(c.ctx.Int32Type(), 1, false).ConstantAsMetadata(), // Error on mismatch - llvm.GlobalContext().MDString("Debug Info Version"), + c.ctx.MDString("Debug Info Version"), llvm.ConstInt(c.ctx.Int32Type(), 3, false).ConstantAsMetadata(), // DWARF version }), ) c.mod.AddNamedMetadataOperand("llvm.module.flags", c.ctx.MDNode([]llvm.Metadata{ llvm.ConstInt(c.ctx.Int32Type(), 1, false).ConstantAsMetadata(), - llvm.GlobalContext().MDString("Dwarf Version"), + c.ctx.MDString("Dwarf Version"), llvm.ConstInt(c.ctx.Int32Type(), 4, false).ConstantAsMetadata(), }), )