ieda: init at 0-unstable-2024-10-11 (#338769)
[NixPkgs.git] / pkgs / development / compilers / emscripten / 0001-emulate-clang-sysroot-include-logic.patch
blob4171906d5e3688d59360aa681e49751e05e89f6f
1 From 86fc9ce2b381748813b372f7e86909be6f955cbd 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
12 invocations directly.
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
18 ---
19 emcc.py | 3 +++
20 1 file changed, 3 insertions(+)
22 diff --git a/emcc.py b/emcc.py
23 index 279f6d4d9..26e20e2cc 100644
24 --- a/emcc.py
25 +++ b/emcc.py
26 @@ -400,6 +400,9 @@ def get_cflags(user_args, is_cxx):
27 # We add these to the user's flags (newargs), but not when building .s or .S assembly files
28 cflags = get_clang_flags(user_args)
29 cflags.append('--sysroot=' + cache.get_sysroot(absolute=True))
30 + cflags.append('-resource-dir=@resourceDir@')
31 + cflags.append('-idirafter' + cache.get_sysroot(absolute=True) + os.path.join('/include'))
32 + cflags.append('-iwithsysroot' + os.path.join('/include','c++','v1'))
34 if settings.EMSCRIPTEN_TRACING:
35 cflags.append('-D__EMSCRIPTEN_TRACING__=1')
36 --
37 2.42.0