1From 301b2d82cdbfaffe4dfba1d2cfed068a4115f730 Mon Sep 17 00:00:00 2001
2From: =?UTF-8?q?Mustafa=20=C3=87al=C4=B1=C5=9Fkan?= <muscaln@protonmail.com>
3Date: Sat, 30 Apr 2022 16:18:31 +0300
4Subject: [PATCH 2/3] Add clang header path
5
6
7diff --git a/builder/builtins.go b/builder/builtins.go
8index 121398fa..a589988b 100644
9--- a/builder/builtins.go
10+++ b/builder/builtins.go
11@@ -170,7 +170,7 @@ var aeabiBuiltins = []string{
12 var CompilerRT = Library{
13 name: "compiler-rt",
14 cflags: func(target, headerPath string) []string {
15- return []string{"-Werror", "-Wall", "-std=c11", "-nostdlibinc"}
16+ return []string{"-Werror", "-Wall", "-std=c11", "-isystem", "@clang_include@"}
17 },
18 sourceDir: func() string {
19 llvmDir := filepath.Join(goenv.Get("TINYGOROOT"), "llvm-project/compiler-rt/lib/builtins")
20diff --git a/builder/picolibc.go b/builder/picolibc.go
21index d0786ee3..9a5cf9b0 100644
22--- a/builder/picolibc.go
23+++ b/builder/picolibc.go
24@@ -30,7 +30,7 @@ var Picolibc = Library{
25 "-D_IEEE_LIBM",
26 "-D__OBSOLETE_MATH_FLOAT=1", // use old math code that doesn't expect a FPU
27 "-D__OBSOLETE_MATH_DOUBLE=0",
28- "-nostdlibinc",
29+ "-isystem", "@clang_include@",
30 "-isystem", newlibDir + "/libc/include",
31 "-I" + newlibDir + "/libc/tinystdio",
32 "-I" + newlibDir + "/libm/common",
33diff --git a/compileopts/config.go b/compileopts/config.go
34index a006b673..3a105b49 100644
35--- a/compileopts/config.go
36+++ b/compileopts/config.go
37@@ -279,6 +279,7 @@ func (c *Config) CFlags() []string {
38 path, _ := c.LibcPath("picolibc")
39 cflags = append(cflags,
40 "--sysroot="+path,
41+ "-isystem", "@clang_include@",
42 "-isystem", filepath.Join(path, "include"), // necessary for Xtensa
43 "-isystem", filepath.Join(picolibcDir, "include"),
44 "-isystem", filepath.Join(picolibcDir, "tinystdio"),
45@@ -288,7 +289,6 @@ func (c *Config) CFlags() []string {
46 path, _ := c.LibcPath("musl")
47 arch := MuslArchitecture(c.Triple())
48 cflags = append(cflags,
49- "-nostdlibinc",
50 "-isystem", filepath.Join(path, "include"),
51 "-isystem", filepath.Join(root, "lib", "musl", "arch", arch),
52 "-isystem", filepath.Join(root, "lib", "musl", "include"),
53--
542.37.2
55