aboutsummaryrefslogtreecommitdiffhomepage
path: root/compiler
diff options
context:
space:
mode:
authorAyke van Laethem <[email protected]>2023-02-26 23:37:19 +0100
committerRon Evans <[email protected]>2023-02-27 23:11:22 +0100
commitea183e9197b7c83c18ea2c53e6ddd6fc5eebf296 (patch)
tree0cd19ea64b0d263ab80c299bdebeb58a52545a49 /compiler
parent74160c0e324a9926566ab76962fd0924c617bc38 (diff)
downloadtinygo-ea183e9197b7c83c18ea2c53e6ddd6fc5eebf296.tar.gz
tinygo-ea183e9197b7c83c18ea2c53e6ddd6fc5eebf296.zip
compiler: add llvm.ident metadata
This metadata is emitted by Clang and I found it is important for source level debugging on MacOS. This patch does not get source level debugging to work yet (for that, it seems like packages need to be built separately), but it is a step in the right direction.
Diffstat (limited to 'compiler')
-rw-r--r--compiler/compiler.go9
1 files changed, 9 insertions, 0 deletions
diff --git a/compiler/compiler.go b/compiler/compiler.go
index 458be2cb5..8b540d351 100644
--- a/compiler/compiler.go
+++ b/compiler/compiler.go
@@ -47,6 +47,7 @@ type Config struct {
CodeModel string
RelocationModel string
SizeLevel int
+ TinyGoVersion string // for llvm.ident
// Various compiler options that determine how code is generated.
Scheduler string
@@ -321,6 +322,14 @@ func CompilePackage(moduleName string, pkg *loader.Package, ssaPkg *ssa.Package,
llvm.ConstInt(c.ctx.Int32Type(), 4, false).ConstantAsMetadata(),
}),
)
+ if c.TinyGoVersion != "" {
+ // It is necessary to set llvm.ident, otherwise debugging on MacOS
+ // won't work.
+ c.mod.AddNamedMetadataOperand("llvm.ident",
+ c.ctx.MDNode(([]llvm.Metadata{
+ c.ctx.MDString("TinyGo version " + c.TinyGoVersion),
+ })))
+ }
c.dibuilder.Finalize()
c.dibuilder.Destroy()
}