at master 1.5 kB view raw
1From 86fc9ce2b381748813b372f7e86909be6f955cbd Mon Sep 17 00:00:00 2001 2From: Yureka <yuka@yuka.dev> 3Date: Sat, 7 Aug 2021 09:16:46 +0200 4Subject: [PATCH] emulate clang 'sysroot + /include' logic 5 6Authored-By: Alexander Khovansky <alex@khovansky.me> 7Co-Authored-By: Yureka <yuka@yuka.dev> 8 9Clang provided by nix patches out logic that appends 'sysroot + /include' 10to the include path as well as automatic inclusion of libcxx includes (/include/c++/v1). 11The patch below adds that logic back by introducing cflags emulating this behavior to emcc 12invocations directly. 13 14Important note: with non-nix clang, sysroot/include dir ends up being the last 15in the include search order, right after the resource root. 16Hence usage of -idirafter. Clang also documents an -isystem-after flag 17but it doesn't appear to work 18--- 19 emcc.py | 3 +++ 20 1 file changed, 3 insertions(+) 21 22diff --git a/emcc.py b/emcc.py 23index 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')) 33 34 if settings.EMSCRIPTEN_TRACING: 35 cflags.append('-D__EMSCRIPTEN_TRACING__=1') 36-- 372.42.0 38