Philipp Schrader | 1b6f448 | 2020-11-08 10:21:01 -0800 | [diff] [blame] | 1 | diff --git a/emcc.py b/emcc.py |
| 2 | index bdf788ef2..7eba3e011 100755 |
| 3 | --- a/emcc.py |
| 4 | +++ b/emcc.py |
James Kuszmaul | 27da814 | 2019-07-21 16:13:55 -0700 | [diff] [blame] | 5 | @@ -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 Schrader | 1b6f448 | 2020-11-08 10:21:01 -0800 | [diff] [blame] | 12 | |
| 13 | |
James Kuszmaul | 27da814 | 2019-07-21 16:13:55 -0700 | [diff] [blame] | 14 | 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 Schrader | 1b6f448 | 2020-11-08 10:21:01 -0800 | [diff] [blame] | 18 | |
James Kuszmaul | 27da814 | 2019-07-21 16:13:55 -0700 | [diff] [blame] | 19 | - 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 Schrader | 1b6f448 | 2020-11-08 10:21:01 -0800 | [diff] [blame] | 24 | |
James Kuszmaul | 27da814 | 2019-07-21 16:13:55 -0700 | [diff] [blame] | 25 | 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 Schrader | 1b6f448 | 2020-11-08 10:21:01 -0800 | [diff] [blame] | 32 | |
James Kuszmaul | 27da814 | 2019-07-21 16:13:55 -0700 | [diff] [blame] | 33 | if should_exit: |
| 34 | sys.exit(0) |
Philipp Schrader | 1b6f448 | 2020-11-08 10:21:01 -0800 | [diff] [blame] | 35 | diff --git a/tools/gen_struct_info.py b/tools/gen_struct_info.py |
| 36 | index 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: |
| 54 | diff --git a/tools/system_libs.py b/tools/system_libs.py |
| 55 | index 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 Kuszmaul | 9a05bfd | 2019-08-03 17:03:38 -0700 | [diff] [blame] | 60 | return shared.Building.parse_symbols(content).defs |
Philipp Schrader | 1b6f448 | 2020-11-08 10:21:01 -0800 | [diff] [blame] | 61 | |
James Kuszmaul | 9a05bfd | 2019-08-03 17:03:38 -0700 | [diff] [blame] | 62 | - 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 Schrader | 1b6f448 | 2020-11-08 10:21:01 -0800 | [diff] [blame] | 74 | |
James Kuszmaul | 9a05bfd | 2019-08-03 17:03:38 -0700 | [diff] [blame] | 75 | # 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 Schrader | 1b6f448 | 2020-11-08 10:21:01 -0800 | [diff] [blame] | 77 | @@ -425,7 +435,7 @@ def calculate(temp_files, in_temp, stdout_, stderr_, forced=[]): |
| 78 | # al |
James Kuszmaul | 9a05bfd | 2019-08-03 17:03:38 -0700 | [diff] [blame] | 79 | 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 Schrader | 1b6f448 | 2020-11-08 10:21:01 -0800 | [diff] [blame] | 84 | |
| 85 | def create_html5(libname): |
| 86 | @@ -444,7 +454,7 @@ def calculate(temp_files, in_temp, stdout_, stderr_, forced=[]): |
| 87 | commands = [] |
James Kuszmaul | 9a05bfd | 2019-08-03 17:03:38 -0700 | [diff] [blame] | 88 | 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 Schrader | 1b6f448 | 2020-11-08 10:21:01 -0800 | [diff] [blame] | 94 | 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 Kuszmaul | 9a05bfd | 2019-08-03 17:03:38 -0700 | [diff] [blame] | 97 | 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 Schrader | 1b6f448 | 2020-11-08 10:21:01 -0800 | [diff] [blame] | 103 | if shared.Settings.EMSCRIPTEN_TRACING: |