}
}
- sanitizers := *flagRace
-
- for _, flag := range ldflag {
- if strings.HasPrefix(flag, "-fsanitize=") {
- sanitizers = true
- }
- }
-
argv = append(argv, ldflag...)
- if sanitizers {
- // On a system where the toolchain creates position independent
- // executables by default, tsan/msan/asan/etc initialization can
- // fail. So we pass -no-pie here, but support for that flag is quite
- // new and we test for its support first.
+ // When building a program with the default -buildmode=exe the
+ // gc compiler generates code requires DT_TEXTREL in a
+ // position independent executable (PIE). On systems where the
+ // toolchain creates PIEs by default, and where DT_TEXTREL
+ // does not work, the resulting programs will not run. See
+ // issue #17847. To avoid this problem pass -no-pie to the
+ // toolchain if it is supported.
+ if Buildmode == BuildmodeExe {
src := filepath.Join(*flagTmpdir, "trivial.c")
if err := ioutil.WriteFile(src, []byte{}, 0666); err != nil {
Errorf(nil, "WriteFile trivial.c failed: %v", err)