@@ -833,6 +833,11 @@ def setUp(self):
833
833
self .js_engines = config .JS_ENGINES .copy ()
834
834
self .settings_mods = {}
835
835
self .emcc_args = ['-Wclosure' , '-Werror' , '-Wno-limited-postlink-optimizations' ]
836
+ # TODO(https://github.com/emscripten-core/emscripten/issues/11121)
837
+ # For historical reasons emcc compiles and links as C++ by default.
838
+ # However we want to run our tests in a more strict manner. We can
839
+ # remove this if the issue above is ever fixed.
840
+ self .set_setting ('NO_DEFAULT_TO_CXX' )
836
841
self .ldflags = []
837
842
# Increate stack trace limit to maximise usefulness of test failure reports
838
843
self .node_args = ['--stack-trace-limit=50' ]
@@ -954,9 +959,13 @@ def has_changed_setting(self, key):
954
959
def clear_setting (self , key ):
955
960
self .settings_mods .pop (key , None )
956
961
957
- def serialize_settings (self ):
962
+ def serialize_settings (self , ldflags = True ):
958
963
ret = []
964
+ # Incomplete list of link-only settings
965
+ link_only_settings = ['NO_DEFAULT_TO_CXX' ]
959
966
for key , value in self .settings_mods .items ():
967
+ if not ldflags and key in link_only_settings :
968
+ continue
960
969
if value == 1 :
961
970
ret .append (f'-s{ key } ' )
962
971
elif type (value ) is list :
@@ -994,7 +1003,7 @@ def get_emcc_args(self, main_file=False, ldflags=True):
994
1003
def is_ldflag (f ):
995
1004
return any (f .startswith (s ) for s in ['-sENVIRONMENT=' , '--pre-js=' , '--post-js=' ])
996
1005
997
- args = self .serialize_settings () + self .emcc_args
1006
+ args = self .serialize_settings (ldflags ) + self .emcc_args
998
1007
if ldflags :
999
1008
args += self .ldflags
1000
1009
else :
@@ -1034,12 +1043,6 @@ def build(self, filename, libraries=None, includes=None, force_c=False, js_outfi
1034
1043
filename = test_file (filename )
1035
1044
suffix = '.js' if js_outfile else '.wasm'
1036
1045
compiler = [compiler_for (filename , force_c )]
1037
- if compiler [0 ] == EMCC :
1038
- # TODO(https://github.com/emscripten-core/emscripten/issues/11121)
1039
- # For historical reasons emcc compiles and links as C++ by default.
1040
- # However we want to run our tests in a more strict manner. We can
1041
- # remove this if the issue above is ever fixed.
1042
- compiler .append ('-sNO_DEFAULT_TO_CXX' )
1043
1046
1044
1047
if force_c :
1045
1048
assert shared .suffix (filename ) != '.c' , 'force_c is not needed for source files ending in .c'
@@ -2106,7 +2109,7 @@ def reftest(self, expected, manually_trigger=False):
2106
2109
setupRefTest();
2107
2110
''' % (reporting , basename , int (manually_trigger )))
2108
2111
2109
- def compile_btest (self , args , reporting = Reporting .FULL ):
2112
+ def compile_btest (self , args , reporting = Reporting .FULL , compiler = EMCC ):
2110
2113
# Inject support code for reporting results. This adds an include a header so testcases can
2111
2114
# use REPORT_RESULT, and also adds a cpp file to be compiled alongside the testcase, which
2112
2115
# contains the implementation of REPORT_RESULT (we can't just include that implementation in
@@ -2123,7 +2126,7 @@ def compile_btest(self, args, reporting=Reporting.FULL):
2123
2126
test_file ('report_result.c' )]
2124
2127
if EMTEST_BROWSER == 'node' :
2125
2128
args .append ('-DEMTEST_NODE' )
2126
- self .run_process ([EMCC ] + self .get_emcc_args () + args )
2129
+ self .run_process ([compiler ] + self .get_emcc_args () + args )
2127
2130
2128
2131
def btest_exit (self , filename , assert_returncode = 0 , * args , ** kwargs ):
2129
2132
"""Special case of btest that reports its result solely via exiting
@@ -2169,7 +2172,7 @@ def btest(self, filename, expected=None, reference=None,
2169
2172
args += [filename , '-o' , outfile ]
2170
2173
# print('all args:', args)
2171
2174
utils .delete_file (outfile )
2172
- self .compile_btest (args , reporting = reporting )
2175
+ self .compile_btest (args , reporting = reporting , compiler = compiler_for ( filename ) )
2173
2176
self .assertExists (outfile )
2174
2177
if post_build :
2175
2178
post_build ()
0 commit comments