Skip to content

Commit f76cf19

Browse files
committed
Warn when setting used on the command line more than once
See #19938
1 parent 2a9af50 commit f76cf19

File tree

5 files changed

+13
-2
lines changed

5 files changed

+13
-2
lines changed

ChangeLog.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ See docs/process.md for more on how version tagging works.
2020

2121
3.1.56 (in development)
2222
-----------------------
23+
- emscripten will now generate an `unused-command-line-argument` warning if
24+
a `-s` setting is specified more than once on the command line with two
25+
different value. In this case the first setting is ignored. (#21464)
2326

2427
3.1.55 - 03/01/24
2528
-----------------

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/common.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -868,7 +868,7 @@ def setUp(self):
868868
# For historical reasons emcc compiles and links as C++ by default.
869869
# However we want to run our tests in a more strict manner. We can
870870
# remove this if the issue above is ever fixed.
871-
self.set_setting('NO_DEFAULT_TO_CXX')
871+
self.set_setting('DEFAULT_TO_CXX', 0)
872872
self.ldflags = []
873873
# Increate stack trace limit to maximise usefulness of test failure reports
874874
self.node_args = ['--stack-trace-limit=50']

test/test_core.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9153,8 +9153,9 @@ def test_pthread_create_embind_stack_check(self):
91539153
# embind should work with stack overflow checks (see #12356)
91549154
self.set_setting('STACK_OVERFLOW_CHECK', 2)
91559155
self.set_setting('EXIT_RUNTIME')
9156+
self.set_setting('DEFAULT_TO_CXX')
91569157
self.emcc_args += ['-lembind']
9157-
self.do_run_in_out_file_test('core/pthread/create.c', emcc_args=['-sDEFAULT_TO_CXX'])
9158+
self.do_run_in_out_file_test('core/pthread/create.c')
91589159

91599160
@node_pthreads
91609161
def test_pthread_exceptions(self):

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)