1 From 4bbbb640934aa653bcfec0335798b77a8935b815 Mon Sep 17 00:00:00 2001
2 From: Yureka <yuka@yuka.dev>
3 Date: Sat, 7 Aug 2021 09:16:46 +0200
4 Subject: [PATCH] emulate clang 'sysroot + /include' logic
6 Authored-By: Alexander Khovansky <alex@khovansky.me>
7 Co-Authored-By: Yureka <yuka@yuka.dev>
9 Clang provided by nix patches out logic that appends 'sysroot + /include'
10 to the include path as well as automatic inclusion of libcxx includes (/include/c++/v1).
11 The patch below adds that logic back by introducing cflags emulating this behavior to emcc
14 Important note: with non-nix clang, sysroot/include dir ends up being the last
15 in the include search order, right after the resource root.
16 Hence usage of -idirafter. Clang also documents an -isystem-after flag
17 but it doesn't appear to work
20 1 file changed, 6 insertions(+), 1 deletion(-)
22 diff --git a/emcc.py b/emcc.py
23 index ba8d1b556..7d89644c5 100755
26 @@ -883,7 +883,12 @@ def parse_s_args(args):
29 def emsdk_cflags(user_args):
30 - cflags = ['--sysroot=' + cache.get_sysroot(absolute=True)]
32 + '--sysroot=' + cache.get_sysroot(absolute=True),
33 + '-resource-dir=@resourceDir@',
34 + '-idirafter' + cache.get_sysroot(absolute=True) + os.path.join('/include'),
35 + '-iwithsysroot' + os.path.join('/include','c++','v1')
38 def array_contains_any_of(hay, needles):