@@ -10237,13 +10237,13 @@ def test_dash_s_list_parsing(self):
1023710237 # Simple one-per-line response file format
1023810238 ("EXPORTED_FUNCTIONS=@response.txt", ''),
1023910239 # stray slash
10240- ("EXPORTED_FUNCTIONS=['_a', '_b', \\'_c', '_d']", '''invalid export name : "\\ \\'_c'"'''),
10240+ ("EXPORTED_FUNCTIONS=['_a', '_b', \\'_c', '_d']", r '''emcc: error: undefined exported symbol : "\\'_c'"'''),
1024110241 # stray slash
10242- ("EXPORTED_FUNCTIONS=['_a', '_b',\\ '_c', '_d']", '''invalid export name : "\\ \\ '_c'"'''),
10242+ ("EXPORTED_FUNCTIONS=['_a', '_b',\\ '_c', '_d']", r '''emcc: error: undefined exported symbol : "\\ '_c'"'''),
1024310243 # stray slash
10244- ('EXPORTED_FUNCTIONS=["_a", "_b", \\"_c", "_d"]', 'invalid export name : "\\ \\"_c""'),
10244+ ('EXPORTED_FUNCTIONS=["_a", "_b", \\"_c", "_d"]', r'emcc: error: undefined exported symbol : "\\"_c""'),
1024510245 # stray slash
10246- ('EXPORTED_FUNCTIONS=["_a", "_b",\\ "_c", "_d"]', 'invalid export name : "\\\\ "_c"'),
10246+ ('EXPORTED_FUNCTIONS=["_a", "_b",\\ "_c", "_d"]', r'emcc: error: undefined exported symbol : "\\ "_c" "'),
1024710247 # missing comma
1024810248 ('EXPORTED_FUNCTIONS=["_a", "_b" "_c", "_d"]', 'wasm-ld: error: symbol exported via --export not found: b" "_c'),
1024910249 ]:
@@ -14852,21 +14852,45 @@ def test_cxx20_modules_std_headers(self):
1485214852 self.do_runf('main.cpp', 'Hello Module!', cflags=['-std=c++20', '-fmodules'])
1485314853
1485414854 def test_invalid_export_name(self):
14855- create_file('test.c', '__attribute__((export_name("my.func"))) void myfunc() {}')
14856- expected = 'emcc: error: invalid export name: "_my.func"'
14857- self.assert_fail([EMCC, 'test.c'], expected)
14855+ create_file('main.c', r'''
14856+ #include <emscripten.h>
14857+ #include <stdio.h>
14858+
14859+ __attribute__((export_name("my.func"))) int myfunc() { return 42; }
14860+
14861+ int main() {
14862+ int rtn = EM_ASM_INT(return Module['_my.func']());
14863+ printf("got: %d\n", rtn);
14864+
14865+ int rtn2 = EM_ASM_INT(return wasmExports['my.func']());
14866+ printf("got2: %d\n", rtn2);
14867+ return 0;
14868+ }
14869+ ''')
14870+ expected = 'emcc: error: export name is not a valid JS symbol: "_my.func". Use `Module` or `wasmExports` to access this symbol'
14871+ self.assert_fail([EMCC, '-Werror', 'main.c'], expected)
14872+
14873+ # With warning suppressed the above program should work.
14874+ self.do_runf('main.c', 'got: 42\ngot2: 42\n', cflags=['-Wno-js-compiler'])
1485814875
1485914876 # When we are generating only wasm and not JS we don't need exports to
1486014877 # be valid JS symbols.
14861- self.run_process([EMCC, 'test.c', '--no-entry', '-o', 'out.wasm'])
14862-
14863- # GCC (and clang) and JavaScript also allow $ in symbol names
14864- create_file('valid.c', '''
14865- #include <emscripten.h>
14866- EMSCRIPTEN_KEEPALIVE
14867- void my$func() {}
14868- ''')
14869- self.run_process([EMCC, 'valid.c'])
14878+ self.run_process([EMCC, '-Werror', 'main.c', '--no-entry', '-o', 'out.wasm'])
14879+
14880+ def test_export_with_dollarsign(self):
14881+ # GCC (and clang) and JavaScript both allow $ in symbol names
14882+ create_file('main.c', r'''
14883+ #include <emscripten.h>
14884+ #include <stdio.h>
14885+
14886+ EMSCRIPTEN_KEEPALIVE int my$func() { return 42; }
14887+
14888+ int main() {
14889+ int rtn = EM_ASM_INT(return _my$func());
14890+ printf("got: %d\n", rtn);
14891+ return 0;
14892+ }''')
14893+ self.do_runf('main.c', 'got: 42\n')
1487014894
1487114895 @also_with_modularize
1487214896 def test_instantiate_wasm(self):
0 commit comments