diff --git a/builder/library.go b/builder/library.go index 6517355b..b8de1894 100644 --- a/builder/library.go +++ b/builder/library.go @@ -142,7 +142,7 @@ func (l *Library) load(config *compileopts.Config, tmpdir string) (job *compileJ // Note: -fdebug-prefix-map is necessary to make the output archive // reproducible. Otherwise the temporary directory is stored in the archive // itself, which varies each run. - args := append(l.cflags(target, headerPath), "-c", "-Oz", "-gdwarf-4", "-ffunction-sections", "-fdata-sections", "-Wno-macro-redefined", "--target="+target, "-fdebug-prefix-map="+dir+"="+remapDir) + args := append(l.cflags(target, headerPath), "-c", "-Oz", "-gdwarf-4", "-ffunction-sections", "-fdata-sections", "-Wno-macro-redefined", "--target="+target, "-fdebug-prefix-map="+dir+"="+remapDir, "-isystem", "@clang_include@") cpu := config.CPU() if cpu != "" { // X86 has deprecated the -mcpu flag, so we need to use -march instead. diff --git a/compileopts/config.go b/compileopts/config.go index 39fc4f2a..8711b5a8 100644 --- a/compileopts/config.go +++ b/compileopts/config.go @@ -264,6 +264,7 @@ func (c *Config) CFlags() []string { for _, flag := range c.Target.CFlags { cflags = append(cflags, strings.ReplaceAll(flag, "{root}", goenv.Get("TINYGOROOT"))) } + cflags = append([]string{"-isystem", "@clang_include@"}, cflags...) switch c.Target.Libc { case "darwin-libSystem": root := goenv.Get("TINYGOROOT")