|
31 | 31 | import tarfile |
32 | 32 | from dataclasses import dataclass |
33 | 33 | from enum import Enum, auto, unique |
34 | | -from subprocess import PIPE |
35 | 34 |
|
36 | 35 |
|
37 | 36 | from tools import shared, system_libs, utils, cmdline |
38 | 37 | from tools import diagnostics, building, compile |
39 | 38 | from tools.shared import unsuffixed_basename, get_file_suffix |
40 | | -from tools.shared import run_process, exit_with_error, DEBUG |
| 39 | +from tools.shared import exit_with_error, DEBUG |
41 | 40 | from tools.shared import in_temp |
42 | 41 | from tools.shared import DYLIB_EXTENSIONS |
43 | 42 | from tools.cmdline import CLANG_FLAGS_WITH_ARGS |
@@ -242,27 +241,6 @@ def run(args): |
242 | 241 | print(utils.EMSCRIPTEN_VERSION) |
243 | 242 | return 0 |
244 | 243 |
|
245 | | - if '--cflags' in args: |
246 | | - # fake running the command, to see the full args we pass to clang |
247 | | - args = [x for x in args if x != '--cflags'] |
248 | | - with shared.get_temp_files().get_file(suffix='.o') as temp_target: |
249 | | - input_file = 'hello_world.c' |
250 | | - compiler = shared.EMCC |
251 | | - if shared.run_via_emxx: |
252 | | - compiler = shared.EMXX |
253 | | - cmd = [compiler, utils.path_from_root('test', input_file), '-v', '-c', '-o', temp_target] + args |
254 | | - proc = run_process(cmd, stderr=PIPE, check=False) |
255 | | - if proc.returncode != 0: |
256 | | - print(proc.stderr) |
257 | | - exit_with_error('error getting cflags') |
258 | | - lines = [x for x in proc.stderr.splitlines() if clang in x and input_file in x] |
259 | | - if not lines: |
260 | | - exit_with_error(f'unable to parse output of `{cmd}`:\n{proc.stderr}') |
261 | | - parts = shlex.split(lines[0].replace('\\', '\\\\')) |
262 | | - parts = [x for x in parts if x not in ['-c', '-o', '-v', '-emit-llvm'] and input_file not in x and temp_target not in x] |
263 | | - print(shlex.join(parts[1:])) |
264 | | - return 0 |
265 | | - |
266 | 244 | if '-dumpmachine' in args or '-print-target-triple' in args or '--print-target-triple' in args: |
267 | 245 | print(shared.get_llvm_target()) |
268 | 246 | return 0 |
@@ -314,6 +292,13 @@ def run(args): |
314 | 292 |
|
315 | 293 | phase_setup(options, state) |
316 | 294 |
|
| 295 | + if '--cflags' in args: |
| 296 | + # Just print the flags we pass to clang and exit. We need to do this after |
| 297 | + # phase_setup because the setup sets things like SUPPORT_LONGJMP. |
| 298 | + cflags = compile.get_cflags(x for x in args if x != '--cflags') |
| 299 | + print(shlex.join(cflags)) |
| 300 | + return 0 |
| 301 | + |
317 | 302 | if options.reproduce: |
318 | 303 | create_reproduce_file(options.reproduce, args) |
319 | 304 |
|
|
0 commit comments