main: move ldflags to compileopts

This commit is contained in:
Ayke van Laethem
2019-11-03 11:55:51 +01:00
committed by Ron Evans
parent ac330f4a70
commit 18cce571a2
2 changed files with 22 additions and 13 deletions
+1 -13
View File
@@ -187,25 +187,13 @@ func Compile(pkgName, outpath string, spec *compileopts.TargetSpec, options *com
}
}
// Merge and adjust LDFlags.
ldflags := append([]string{}, options.LDFlags...)
for _, flag := range spec.LDFlags {
ldflags = append(ldflags, strings.Replace(flag, "{root}", root, -1))
}
// Prepare link command.
executable := filepath.Join(dir, "main")
tmppath := executable // final file
ldflags = append(ldflags, "-o", executable, objfile, "-L", root)
ldflags := append(compilerConfig.LDFlags(), "-o", executable, objfile)
if spec.RTLib == "compiler-rt" {
ldflags = append(ldflags, librt)
}
if spec.GOARCH == "wasm" {
// Round heap size to next multiple of 65536 (the WebAssembly page
// size).
heapSize := (options.HeapSize + (65536 - 1)) &^ (65536 - 1)
ldflags = append(ldflags, "--initial-memory="+strconv.FormatInt(heapSize, 10))
}
// Compile extra files.
for i, path := range spec.ExtraFiles {