mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-20 12:29:03 +00:00
main: parse extldflags early so we can report the error message
This avoids some weird behavior when the -extldflags flag cannot be parsed by TinyGo.
This commit is contained in:
@@ -406,15 +406,7 @@ func (c *Config) LDFlags() []string {
|
|||||||
if c.Target.LinkerScript != "" {
|
if c.Target.LinkerScript != "" {
|
||||||
ldflags = append(ldflags, "-T", c.Target.LinkerScript)
|
ldflags = append(ldflags, "-T", c.Target.LinkerScript)
|
||||||
}
|
}
|
||||||
|
ldflags = append(ldflags, c.Options.ExtLDFlags...)
|
||||||
if c.Options.ExtLDFlags != "" {
|
|
||||||
ext, err := shlex.Split(c.Options.ExtLDFlags)
|
|
||||||
if err != nil {
|
|
||||||
// if shlex can't split it, pass it as-is and let the external linker complain
|
|
||||||
ext = []string{c.Options.ExtLDFlags}
|
|
||||||
}
|
|
||||||
ldflags = append(ldflags, ext...)
|
|
||||||
}
|
|
||||||
|
|
||||||
return ldflags
|
return ldflags
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ type Options struct {
|
|||||||
Timeout time.Duration
|
Timeout time.Duration
|
||||||
WITPackage string // pass through to wasm-tools component embed invocation
|
WITPackage string // pass through to wasm-tools component embed invocation
|
||||||
WITWorld string // pass through to wasm-tools component embed -w option
|
WITWorld string // pass through to wasm-tools component embed -w option
|
||||||
ExtLDFlags string
|
ExtLDFlags []string
|
||||||
}
|
}
|
||||||
|
|
||||||
// Verify performs a validation on the given options, raising an error if options are not valid.
|
// Verify performs a validation on the given options, raising an error if options are not valid.
|
||||||
|
|||||||
@@ -1641,12 +1641,19 @@ func main() {
|
|||||||
Timeout: *timeout,
|
Timeout: *timeout,
|
||||||
WITPackage: witPackage,
|
WITPackage: witPackage,
|
||||||
WITWorld: witWorld,
|
WITWorld: witWorld,
|
||||||
ExtLDFlags: extLDFlags,
|
|
||||||
}
|
}
|
||||||
if *printCommands {
|
if *printCommands {
|
||||||
options.PrintCommands = printCommand
|
options.PrintCommands = printCommand
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if extLDFlags != "" {
|
||||||
|
options.ExtLDFlags, err = shlex.Split(extLDFlags)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Fprintln(os.Stderr, "could not parse -extldflags:", err)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
err = options.Verify()
|
err = options.Verify()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintln(os.Stderr, err.Error())
|
fmt.Fprintln(os.Stderr, err.Error())
|
||||||
|
|||||||
Reference in New Issue
Block a user