James Kuszmaul | 27da814 | 2019-07-21 16:13:55 -0700 | [diff] [blame] | 1 | --- emcc.py |
| 2 | +++ emcc.py |
| 3 | @@ -206,6 +206,9 @@ class EmccOptions(object): |
| 4 | # Defaults to using the native EOL on each platform (\r\n on Windows, \n on |
| 5 | # Linux & MacOS) |
| 6 | self.output_eol = os.linesep |
| 7 | + # Whether we will expand the full path of any input files to remove any |
| 8 | + # symlinks. |
| 9 | + self.expand_symlinks = True |
| 10 | |
| 11 | |
| 12 | def use_source_map(options): |
| 13 | @@ -859,7 +862,9 @@ There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR P |
| 14 | '-current_version', '-I', '-L', '-include-pch'): |
| 15 | continue # ignore this gcc-style argument |
| 16 | |
| 17 | - if os.path.islink(arg) and get_file_suffix(os.path.realpath(arg)) in SOURCE_ENDINGS + BITCODE_ENDINGS + DYNAMICLIB_ENDINGS + ASSEMBLY_ENDINGS + HEADER_ENDINGS: |
| 18 | + if (options.expand_symlinks |
| 19 | + and os.path.islink(arg) |
| 20 | + and get_file_suffix(os.path.realpath(arg)) in SOURCE_ENDINGS + BITCODE_ENDINGS + DYNAMICLIB_ENDINGS + ASSEMBLY_ENDINGS + HEADER_ENDINGS): |
| 21 | arg = os.path.realpath(arg) |
| 22 | |
| 23 | if not arg.startswith('-'): |
| 24 | @@ -2516,6 +2521,8 @@ def parse_args(newargs): |
| 25 | settings_changes.append('SIMD=1') |
| 26 | elif newargs[i] == '-mno-simd128': |
| 27 | settings_changes.append('SIMD=0') |
| 28 | + elif newargs[i] == '-no-canonical-prefixes': |
| 29 | + options.expand_symlinks = False |
| 30 | |
| 31 | if should_exit: |
| 32 | sys.exit(0) |
James Kuszmaul | 9a05bfd | 2019-08-03 17:03:38 -0700 | [diff] [blame^] | 33 | --- tools/system_libs.py |
| 34 | +++ tools/system_libs.py |
| 35 | @@ -89,10 +89,20 @@ def calculate(temp_files, in_temp, stdout_, stderr_, forced=[]): |
| 36 | if os.name != 'nt' and '\r\n' in content: |
| 37 | raise Exception('Windows newlines \\r\\n detected in symbols file "' + path + '"! This could happen for example when copying Emscripten checkout from Windows to Linux or macOS. Please use Unix line endings on checkouts of Emscripten on Linux and macOS!') |
James Kuszmaul | 27da814 | 2019-07-21 16:13:55 -0700 | [diff] [blame] | 38 | |
James Kuszmaul | 9a05bfd | 2019-08-03 17:03:38 -0700 | [diff] [blame^] | 39 | return shared.Building.parse_symbols(content).defs |
| 40 | |
| 41 | - default_opts = ['-Werror'] |
| 42 | + default_opts = ['-Werror', |
| 43 | + '-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', 'compat'), |
| 51 | + '-isystem', |
| 52 | + shared.path_from_root('system', 'include', 'libc')] |
| 53 | |
| 54 | # XXX We also need to add libc symbols that use malloc, for example strdup. It's very rare to use just them and not |
| 55 | # a normal malloc symbol (like free, after calling strdup), so we haven't hit this yet, but it is possible. |
| 56 | libc_symbols = read_symbols(shared.path_from_root('system', 'lib', 'libc.symbols')) |
| 57 | @@ -426,5 +436,5 @@ def calculate(temp_files, in_temp, stdout_, stderr_, forced=[]): |
| 58 | def create_al(libname): # libname is ignored, this is just one .o file |
| 59 | o = in_temp('al.o') |
| 60 | - check_call([shared.PYTHON, shared.EMCC, shared.path_from_root('system', 'lib', 'al.c'), '-o', o, '-Os'] + get_cflags()) |
| 61 | + check_call([shared.PYTHON, shared.EMCC, shared.path_from_root('system', 'lib', 'al.c'), '-o', o, '-Os'] + get_cflags() + default_opts) |
| 62 | return o |
| 63 | |
| 64 | @@ -447,5 +455,5 @@ def create_compiler_rt(libname): |
| 65 | for src in files: |
| 66 | o = in_temp(os.path.basename(src) + '.o') |
| 67 | - commands.append([shared.PYTHON, shared.EMCC, shared.path_from_root('system', 'lib', src), '-O2', '-o', o] + get_cflags()) |
| 68 | + commands.append([shared.PYTHON, shared.EMCC, shared.path_from_root('system', 'lib', src), '-O2', '-o', o] + get_cflags() + default_opts) |
| 69 | o_s.append(o) |
| 70 | run_commands(commands) |
| 71 | @@ -500,5 +506,5 @@ def calculate(temp_files, in_temp, stdout_, stderr_, forced=[]): |
| 72 | def create_malloc(out_name): |
| 73 | o = in_temp(out_name) |
| 74 | - cflags = ['-O2', '-fno-builtin'] |
| 75 | + cflags = default_opts + ['-O2', '-fno-builtin'] |
| 76 | if shared.Settings.USE_PTHREADS: |
| 77 | cflags += ['-s', 'USE_PTHREADS=1'] |
| 78 | --- tools/gen_struct_info.py |
| 79 | +++ tools/gen_struct_info.py |
| 80 | @@ -401,4 +401,12 @@ def inspect_code(headers, cpp_opts, structs, defines): |
| 81 | # Compile the program. |
| 82 | show('Compiling generated code...') |
| 83 | + cpp_opts += ['-isystem', |
| 84 | + shared.path_from_root('system', 'include'), |
| 85 | + '-isystem', |
| 86 | + shared.path_from_root('system', 'include', 'libcxx'), |
| 87 | + '-isystem', |
| 88 | + shared.path_from_root('system', 'lib', 'libc', 'musl', 'arch', 'emscripten'), |
| 89 | + '-isystem', |
| 90 | + shared.path_from_root('system', 'include', 'libc')] |
| 91 | # -Oz optimizes enough to avoid warnings on code size/num locals |
| 92 | 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', '-Wno-format'] |