t.Fatal(err)
}
- tests := []struct {
+ type testCase struct {
flag string
wantDWARF bool
- }{
+ }
+ tests := []testCase{
{"-w", false}, // -w flag disables DWARF
{"-s", false}, // -s implies -w
{"-s -w=0", true}, // -w=0 negates the implied -w
}
+ if testenv.HasCGO() {
+ tests = append(tests,
+ testCase{"-w -linkmode=external", false},
+ testCase{"-s -linkmode=external", false},
+ // Some external linkers don't have a way to preserve DWARF
+ // without emitting the symbol table. Skip this case for now.
+ // I suppose we can post- process, e.g. with objcopy.
+ //testCase{"-s -w=0 -linkmode=external", true},
+ )
+ }
+
for _, test := range tests {
name := strings.ReplaceAll(test.flag, " ", "_")
t.Run(name, func(t *testing.T) {
} else {
argv = append(argv, "-s")
}
+ } else if *FlagW {
+ argv = append(argv, "-Wl,-S") // suppress debugging symbols
}
// On darwin, whether to combine DWARF into executable.