cgo: Add LDFlags support

This commit is contained in:
Lucas Teske
2020-05-20 13:05:25 -03:00
committed by Ayke
parent b9fd6cee6f
commit 726d735ad3
8 changed files with 46 additions and 18 deletions
+5 -1
View File
@@ -32,7 +32,7 @@ func Build(pkgName, outpath string, config *compileopts.Config, action func(stri
if err != nil {
return err
}
mod, extraFiles, errs := compiler.Compile(pkgName, machine, config)
mod, extraFiles, extraLDFlags, errs := compiler.Compile(pkgName, machine, config)
if errs != nil {
return newMultiError(errs)
}
@@ -187,6 +187,10 @@ func Build(pkgName, outpath string, config *compileopts.Config, action func(stri
ldflags = append(ldflags, outpath)
}
if len(extraLDFlags) > 0 {
ldflags = append(ldflags, extraLDFlags...)
}
// Link the object files together.
err = link(config.Target.Linker, ldflags...)
if err != nil {