Skip to content

Commit be27fe3

Browse files
committed
Warn when setting used on the command line more than once
See emscripten-core#19938
1 parent 53f661c commit be27fe3

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

emcc.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -684,6 +684,9 @@ def phase_parse_arguments(state):
684684
for s in settings_changes:
685685
key, value = s.split('=', 1)
686686
key, value = normalize_boolean_setting(key, value)
687+
old_value = user_settings.get(key)
688+
if old_value and old_value != value:
689+
diagnostics.warning('unused-command-line-argument', f'-s{key} specified multiple times. Ignoring previous value (`{old_value}`)')
687690
user_settings[key] = value
688691

689692
# STRICT is used when applying settings so it needs to be applied first before

test/test_other.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7811,6 +7811,10 @@ def test_dash_s_bad_json_types(self):
78117811
err = self.expect_fail([EMCC, test_file('hello_world.c'), '-sEXPORTED_FUNCTIONS=[{"a":1}]'])
78127812
self.assertContained("list members in settings must be strings (not $<class 'dict'>)", err)
78137813

7814+
def test_dash_s_repeated(self):
7815+
err = self.expect_fail([EMCC, '-Werror', test_file('hello_world.c'), '-sEXPORTED_FUNCTIONS=foo', '-sEXPORTED_FUNCTIONS=bar'])
7816+
self.assertContained('emcc: error: -sEXPORTED_FUNCTIONS specified multiple times. Ignoring previous value (`foo`) [-Wunused-command-line-argument]', err)
7817+
78147818
def test_zeroinit(self):
78157819
create_file('src.c', r'''
78167820
#include <stdio.h>

0 commit comments

Comments
 (0)