Skip to content

Commit 2c8d9fd

Browse files
committedMar 8, 2024
Warn when setting used on the command line more than once
See emscripten-core#19938
1 parent 74a368a commit 2c8d9fd

File tree

6 files changed

+22
-9
lines changed

6 files changed

+22
-9
lines changed
 

‎ChangeLog.md

+3
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
25+
conflicting values. In this case the first setting is ignored. (#21464)
2326

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

‎emcc.py

+3
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

+1-1
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_browser.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -4866,7 +4866,7 @@ def test_pthread_hello_thread(self, opts, modularize):
48664866
'modularize': (['-sMODULARIZE', '-sEXPORT_NAME=MyModule'],),
48674867
'O3': (['-O3'],),
48684868
'O3_modularize': (['-O3', '-sMODULARIZE', '-sEXPORT_NAME=MyModule'],),
4869-
'O3_modularize_MINIMAL_RUNTIME_2': (['-O3', '-sMODULARIZE', '-sEXPORT_NAME=MyModule', '-sMINIMAL_RUNTIME=2'],),
4869+
'O3_modularize_MINIMAL_RUNTIME_2': (['-O3', '-sMODULARIZE', '-sEXPORT_NAME=MyModule', '-sMINIMAL_RUNTIME=2', '-Wno-unused-command-line-argument'],),
48704870
})
48714871
def test_minimal_runtime_hello_thread(self, opts):
48724872
self.btest_exit('pthread/hello_thread.c', args=['--closure=1', '-sMINIMAL_RUNTIME', '-pthread'] + opts)

‎test/test_core.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -9157,8 +9157,9 @@ def test_pthread_create_embind_stack_check(self):
91579157
# embind should work with stack overflow checks (see #12356)
91589158
self.set_setting('STACK_OVERFLOW_CHECK', 2)
91599159
self.set_setting('EXIT_RUNTIME')
9160+
self.set_setting('DEFAULT_TO_CXX')
91609161
self.emcc_args += ['-lembind']
9161-
self.do_run_in_out_file_test('core/pthread/create.c', emcc_args=['-sDEFAULT_TO_CXX'])
9162+
self.do_run_in_out_file_test('core/pthread/create.c')
91629163

91639164
@node_pthreads
91649165
def test_pthread_exceptions(self):

‎test/test_other.py

+12-6
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>
@@ -12017,21 +12021,23 @@ def test_default_to_cxx(self):
1201712021

1201812022
@parameterized({
1201912023
'': ([],),
12020-
'minimal': (['-sMINIMAL_RUNTIME', '-sSUPPORT_ERRNO'],),
12024+
'minimal': (['-sMINIMAL_RUNTIME'],),
1202112025
})
1202212026
def test_support_errno(self, args):
1202312027
self.emcc_args += args + ['-sEXPORTED_FUNCTIONS=_main,___errno_location', '-Wno-deprecated']
1202412028

12025-
self.do_other_test('test_support_errno.c')
12026-
size_default = os.path.getsize('test_support_errno.js')
12029+
self.do_other_test('test_support_errno.c', emcc_args=['-sSUPPORT_ERRNO'])
12030+
size_enabled = os.path.getsize('test_support_errno.js')
1202712031

1202812032
# Run the same test again but with SUPPORT_ERRNO disabled. This time we don't expect errno
1202912033
# to be set after the failing syscall.
12030-
self.emcc_args += ['-sSUPPORT_ERRNO=0']
12031-
self.do_other_test('test_support_errno.c', out_suffix='_disabled')
12034+
self.do_other_test('test_support_errno.c', emcc_args=['-sSUPPORT_ERRNO=0'], out_suffix='_disabled')
1203212035

1203312036
# Verify the JS output was smaller
12034-
self.assertLess(os.path.getsize('test_support_errno.js'), size_default)
12037+
size_disabled = os.path.getsize('test_support_errno.js')
12038+
print(size_enabled)
12039+
print(size_disabled)
12040+
self.assertLess(size_disabled, size_enabled)
1203512041

1203612042
def test_assembly(self):
1203712043
self.run_process([EMCC, '-c', test_file('other/test_asm.s'), '-o', 'foo.o'])

0 commit comments

Comments
 (0)
Failed to load comments.