Merge pull request #268619 from tweag/lib-descriptions
[NixPkgs.git] / pkgs / development / compilers / emscripten / 0001-emulate-clang-sysroot-include-logic.patch
blob6a57e423bd72b9b144dd4267c985ca05f04c54b3
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
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 | 7 ++++++-
20 1 file changed, 6 insertions(+), 1 deletion(-)
22 diff --git a/emcc.py b/emcc.py
23 index ba8d1b556..7d89644c5 100755
24 --- a/emcc.py
25 +++ b/emcc.py
26 @@ -883,7 +883,12 @@ def parse_s_args(args):
29 def emsdk_cflags(user_args):
30 - cflags = ['--sysroot=' + cache.get_sysroot(absolute=True)]
31 + cflags = [
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')
36 + ]
38 def array_contains_any_of(hay, needles):
39 for n in needles:
40 --
41 2.40.0