blob: f6c6b5108240f4b345125b41fdcefb5e6334f965 [file] [log] [blame]
Philipp Schrader1b6f4482020-11-08 10:21:01 -08001diff --git a/emcc.py b/emcc.py
2index bdf788ef2..7eba3e011 100755
3--- a/emcc.py
4+++ b/emcc.py
James Kuszmaul27da8142019-07-21 16:13:55 -07005@@ -206,6 +206,9 @@ class EmccOptions(object):
6 # Defaults to using the native EOL on each platform (\r\n on Windows, \n on
7 # Linux & MacOS)
8 self.output_eol = os.linesep
9+ # Whether we will expand the full path of any input files to remove any
10+ # symlinks.
11+ self.expand_symlinks = True
Philipp Schrader1b6f4482020-11-08 10:21:01 -080012
13
James Kuszmaul27da8142019-07-21 16:13:55 -070014 def use_source_map(options):
15@@ -859,7 +862,9 @@ There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR P
16 '-current_version', '-I', '-L', '-include-pch'):
17 continue # ignore this gcc-style argument
Philipp Schrader1b6f4482020-11-08 10:21:01 -080018
James Kuszmaul27da8142019-07-21 16:13:55 -070019- if os.path.islink(arg) and get_file_suffix(os.path.realpath(arg)) in SOURCE_ENDINGS + BITCODE_ENDINGS + DYNAMICLIB_ENDINGS + ASSEMBLY_ENDINGS + HEADER_ENDINGS:
20+ if (options.expand_symlinks
21+ and os.path.islink(arg)
22+ and get_file_suffix(os.path.realpath(arg)) in SOURCE_ENDINGS + BITCODE_ENDINGS + DYNAMICLIB_ENDINGS + ASSEMBLY_ENDINGS + HEADER_ENDINGS):
23 arg = os.path.realpath(arg)
Philipp Schrader1b6f4482020-11-08 10:21:01 -080024
James Kuszmaul27da8142019-07-21 16:13:55 -070025 if not arg.startswith('-'):
26@@ -2516,6 +2521,8 @@ def parse_args(newargs):
27 settings_changes.append('SIMD=1')
28 elif newargs[i] == '-mno-simd128':
29 settings_changes.append('SIMD=0')
30+ elif newargs[i] == '-no-canonical-prefixes':
31+ options.expand_symlinks = False
Philipp Schrader1b6f4482020-11-08 10:21:01 -080032
James Kuszmaul27da8142019-07-21 16:13:55 -070033 if should_exit:
34 sys.exit(0)
Philipp Schrader1b6f4482020-11-08 10:21:01 -080035diff --git a/tools/gen_struct_info.py b/tools/gen_struct_info.py
36index f6368ecff..7af844a2b 100755
37--- a/tools/gen_struct_info.py
38+++ b/tools/gen_struct_info.py
39@@ -387,6 +387,14 @@ def inspect_code(headers, cpp_opts, structs, defines):
40 info = []
41 # Compile the program.
42 show('Compiling generated code...')
43+ cpp_opts += ['-isystem',
44+ shared.path_from_root('system', 'include'),
45+ '-isystem',
46+ shared.path_from_root('system', 'include', 'libcxx'),
47+ '-isystem',
48+ shared.path_from_root('system', 'lib', 'libc', 'musl', 'arch', 'emscripten'),
49+ '-isystem',
50+ shared.path_from_root('system', 'include', 'libc')]
51 # -Oz optimizes enough to avoid warnings on code size/num locals
52 cmd = [shared.PYTHON, shared.EMCC] + cpp_opts + ['-o', js_file[1], src_file[1], '-s', 'BOOTSTRAPPING_STRUCT_INFO=1', '-s', 'WARN_ON_UNDEFINED_SYMBOLS=0', '-O0', '--js-opts', '0', '--memory-init-file', '0', '-s', 'SINGLE_FILE=1', '-s', 'WASM=0', '-Wno-format']
53 if shared.Settings.WASM_OBJECT_FILES:
54diff --git a/tools/system_libs.py b/tools/system_libs.py
55index 61a17d2cf..4de22e706 100755
56--- a/tools/system_libs.py
57+++ b/tools/system_libs.py
58@@ -91,7 +91,17 @@ def calculate(temp_files, in_temp, stdout_, stderr_, forced=[]):
59
James Kuszmaul9a05bfd2019-08-03 17:03:38 -070060 return shared.Building.parse_symbols(content).defs
Philipp Schrader1b6f4482020-11-08 10:21:01 -080061
James Kuszmaul9a05bfd2019-08-03 17:03:38 -070062- default_opts = ['-Werror']
63+ default_opts = ['-Werror',
64+ '-isystem',
65+ shared.path_from_root('system', 'include'),
66+ '-isystem',
67+ shared.path_from_root('system', 'include', 'libcxx'),
68+ '-isystem',
69+ shared.path_from_root('system', 'lib', 'libc', 'musl', 'arch', 'emscripten'),
70+ '-isystem',
71+ shared.path_from_root('system', 'include', 'compat'),
72+ '-isystem',
73+ shared.path_from_root('system', 'include', 'libc')]
Philipp Schrader1b6f4482020-11-08 10:21:01 -080074
James Kuszmaul9a05bfd2019-08-03 17:03:38 -070075 # XXX We also need to add libc symbols that use malloc, for example strdup. It's very rare to use just them and not
76 # a normal malloc symbol (like free, after calling strdup), so we haven't hit this yet, but it is possible.
Philipp Schrader1b6f4482020-11-08 10:21:01 -080077@@ -425,7 +435,7 @@ def calculate(temp_files, in_temp, stdout_, stderr_, forced=[]):
78 # al
James Kuszmaul9a05bfd2019-08-03 17:03:38 -070079 def create_al(libname): # libname is ignored, this is just one .o file
80 o = in_temp('al.o')
81- check_call([shared.PYTHON, shared.EMCC, shared.path_from_root('system', 'lib', 'al.c'), '-o', o, '-Os'] + get_cflags())
82+ check_call([shared.PYTHON, shared.EMCC, shared.path_from_root('system', 'lib', 'al.c'), '-o', o, '-Os'] + get_cflags() + default_opts)
83 return o
Philipp Schrader1b6f4482020-11-08 10:21:01 -080084
85 def create_html5(libname):
86@@ -444,7 +454,7 @@ def calculate(temp_files, in_temp, stdout_, stderr_, forced=[]):
87 commands = []
James Kuszmaul9a05bfd2019-08-03 17:03:38 -070088 for src in files:
89 o = in_temp(os.path.basename(src) + '.o')
90- commands.append([shared.PYTHON, shared.EMCC, shared.path_from_root('system', 'lib', src), '-O2', '-o', o] + get_cflags())
91+ commands.append([shared.PYTHON, shared.EMCC, shared.path_from_root('system', 'lib', src), '-O2', '-o', o] + get_cflags() + default_opts)
92 o_s.append(o)
93 run_commands(commands)
Philipp Schrader1b6f4482020-11-08 10:21:01 -080094 shared.Building.emar('cr', in_temp(libname), o_s)
95@@ -497,7 +507,7 @@ def calculate(temp_files, in_temp, stdout_, stderr_, forced=[]):
96
James Kuszmaul9a05bfd2019-08-03 17:03:38 -070097 def create_malloc(out_name):
98 o = in_temp(out_name)
99- cflags = ['-O2', '-fno-builtin']
100+ cflags = default_opts + ['-O2', '-fno-builtin']
101 if shared.Settings.USE_PTHREADS:
102 cflags += ['-s', 'USE_PTHREADS=1']
Philipp Schrader1b6f4482020-11-08 10:21:01 -0800103 if shared.Settings.EMSCRIPTEN_TRACING: