compiler: avoid all debug info with -no-debug
Этот коммит содержится в:
родитель
003211b4ff
коммит
d63ce0646c
1 изменённых файлов: 22 добавлений и 16 удалений
|
@ -110,7 +110,9 @@ func NewCompiler(pkgName string, config Config) (*Compiler, error) {
|
||||||
c.mod.SetTarget(config.Triple)
|
c.mod.SetTarget(config.Triple)
|
||||||
c.mod.SetDataLayout(c.targetData.String())
|
c.mod.SetDataLayout(c.targetData.String())
|
||||||
c.builder = c.ctx.NewBuilder()
|
c.builder = c.ctx.NewBuilder()
|
||||||
|
if c.Debug {
|
||||||
c.dibuilder = llvm.NewDIBuilder(c.mod)
|
c.dibuilder = llvm.NewDIBuilder(c.mod)
|
||||||
|
}
|
||||||
|
|
||||||
c.uintptrType = c.ctx.IntType(c.targetData.PointerSize() * 8)
|
c.uintptrType = c.ctx.IntType(c.targetData.PointerSize() * 8)
|
||||||
if c.targetData.PointerSize() <= 4 {
|
if c.targetData.PointerSize() <= 4 {
|
||||||
|
@ -214,6 +216,7 @@ func (c *Compiler) Compile(mainPath string) error {
|
||||||
c.ir.SimpleDCE()
|
c.ir.SimpleDCE()
|
||||||
|
|
||||||
// Initialize debug information.
|
// Initialize debug information.
|
||||||
|
if c.Debug {
|
||||||
c.cu = c.dibuilder.CreateCompileUnit(llvm.DICompileUnit{
|
c.cu = c.dibuilder.CreateCompileUnit(llvm.DICompileUnit{
|
||||||
Language: llvm.DW_LANG_Go,
|
Language: llvm.DW_LANG_Go,
|
||||||
File: mainPath,
|
File: mainPath,
|
||||||
|
@ -221,6 +224,7 @@ func (c *Compiler) Compile(mainPath string) error {
|
||||||
Producer: "TinyGo",
|
Producer: "TinyGo",
|
||||||
Optimized: true,
|
Optimized: true,
|
||||||
})
|
})
|
||||||
|
}
|
||||||
|
|
||||||
var frames []*Frame
|
var frames []*Frame
|
||||||
|
|
||||||
|
@ -373,6 +377,7 @@ func (c *Compiler) Compile(mainPath string) error {
|
||||||
c.mod.NamedFunction("runtime.scheduler").SetLinkage(llvm.ExternalLinkage)
|
c.mod.NamedFunction("runtime.scheduler").SetLinkage(llvm.ExternalLinkage)
|
||||||
|
|
||||||
// see: https://reviews.llvm.org/D18355
|
// see: https://reviews.llvm.org/D18355
|
||||||
|
if c.Debug {
|
||||||
c.mod.AddNamedMetadataOperand("llvm.module.flags",
|
c.mod.AddNamedMetadataOperand("llvm.module.flags",
|
||||||
c.ctx.MDNode([]llvm.Metadata{
|
c.ctx.MDNode([]llvm.Metadata{
|
||||||
llvm.ConstInt(c.ctx.Int32Type(), 1, false).ConstantAsMetadata(), // Error on mismatch
|
llvm.ConstInt(c.ctx.Int32Type(), 1, false).ConstantAsMetadata(), // Error on mismatch
|
||||||
|
@ -381,6 +386,7 @@ func (c *Compiler) Compile(mainPath string) error {
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
c.dibuilder.Finalize()
|
c.dibuilder.Finalize()
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Создание таблицы
Сослаться в новой задаче