Skip to content

Commit 9e924c5

Browse files
authored
[emcc.py] Handle all pass-through args correctly (#23428)
We were only handling `-mllvm` and not all the other ones.
1 parent 25e6e9c commit 9e924c5

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

emcc.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1132,6 +1132,12 @@ def parse_args(newargs): # noqa: C901, PLR0912, PLR0915
11321132
arg = newargs[i]
11331133
arg_value = None
11341134

1135+
if arg in CLANG_FLAGS_WITH_ARGS:
1136+
# Ignore the next argument rather than trying to parse it. This is needed
1137+
# because that next arg could, for example, start with `-o` and we don't want
1138+
# to confuse that with a normal `-o` flag.
1139+
skip = True
1140+
11351141
def check_flag(value):
11361142
# Check for and consume a flag
11371143
if arg == value:
@@ -1480,11 +1486,6 @@ def consume_arg_file():
14801486
exit_with_error(f'unsupported target: {options.target} (emcc only supports wasm64-unknown-emscripten and wasm32-unknown-emscripten)')
14811487
elif check_arg('--use-port'):
14821488
ports.handle_use_port_arg(settings, consume_arg())
1483-
elif arg == '-mllvm':
1484-
# Ignore the next argument rather than trying to parse it. This is needed
1485-
# because llvm args could, for example, start with `-o` and we don't want
1486-
# to confuse that with a normal `-o` flag.
1487-
skip = True
14881489

14891490
if should_exit:
14901491
sys.exit(0)

test/test_other.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12244,6 +12244,10 @@ def test_linker_flags_pass_through(self):
1224412244
err = self.expect_fail([EMCC, test_file('hello_world.c'), '-Xlinker', '--waka'])
1224512245
self.assertContained('wasm-ld: error: unknown argument: --waka', err)
1224612246

12247+
# Explicitly check that emcc doesn't try to process passthrough args
12248+
err = self.expect_fail([EMCC, test_file('hello_world.c'), '-Xlinker', '--post-link'])
12249+
self.assertContained('wasm-ld: error: unknown argument: --post-link', err)
12250+
1224712251
err = self.run_process([EMCC, test_file('hello_world.c'), '-z', 'foo'], stderr=PIPE).stderr
1224812252
self.assertContained('wasm-ld: warning: unknown -z value: foo', err)
1224912253

0 commit comments

Comments
 (0)