@@ -6735,26 +6735,22 @@ def test_no_missing_symbols(self): # simple hello world should not show any miss
67356735mergeInto(LibraryManager.library, {
67366736 my_js__deps: ['main'],
67376737 my_js: (function() {
6738- return function() {
6739- console.log("hello " + _nonexistingvariable);
6740- };
6738+ return () => console.log("hello " + _nonexistingvariable);
67416739 }()),
67426740});
67436741''')
6744- create_file('test.cpp ', '''\
6742+ create_file('test.c ', '''\
67456743#include <stdio.h>
67466744#include <stdlib.h>
67476745
6748- extern "C" {
6749- extern void my_js();
6750- }
6746+ void my_js();
67516747
67526748int main() {
67536749 my_js();
67546750 return EXIT_SUCCESS;
67556751}
67566752''')
6757- self.run_process([EMXX , 'test.cpp ', '--js-library', 'library_foo.js'])
6753+ self.run_process([EMCC , 'test.c ', '--js-library', 'library_foo.js'])
67586754
67596755 # but we do error on a missing js var
67606756 create_file('library_foo_missing.js', '''
@@ -6767,16 +6763,16 @@ def test_no_missing_symbols(self): # simple hello world should not show any miss
67676763 }()),
67686764});
67696765''')
6770- err = self.expect_fail([EMXX , 'test.cpp ', '--js-library', 'library_foo_missing.js'])
6771- self.assertContained('undefined symbol: nonexistingvariable', err)
6766+ err = self.expect_fail([EMCC , 'test.c ', '--js-library', 'library_foo_missing.js'])
6767+ self.assertContained('wasm-ld: error: symbol exported via --export not found : nonexistingvariable', err)
67726768
67736769 # and also for missing C code, of course (without the --js-library, it's just a missing C method)
6774- err = self.expect_fail([EMXX , 'test.cpp '])
6770+ err = self.expect_fail([EMCC , 'test.c '])
67756771 self.assertContained('undefined symbol: my_js', err)
67766772
6777- def test_js_lib_to_system_lib (self):
6778- # memset is in compiled code, so a js library __deps can't access it. it
6779- # would need to be in deps_info.json or EXPORTED_FUNCTIONS
6773+ def test_js_lib_native_deps (self):
6774+ # Verify that memset (which lives in compiled code), can be specified as a JS library
6775+ # dependency.
67806776 create_file('lib.js', r'''
67816777mergeInto(LibraryManager.library, {
67826778 depper__deps: ['memset'],
@@ -6785,38 +6781,19 @@ def test_js_lib_to_system_lib(self):
67856781 },
67866782});
67876783''')
6788- create_file('test.cpp', r'''
6789- #include <string.h>
6784+ create_file('test.c', r'''
67906785#include <stdio.h>
67916786
6792- extern "C" {
6793- extern void depper(char*);
6794- }
6787+ void depper(char*);
67956788
67966789int main(int argc, char** argv) {
6797- char buffer[11];
6798- buffer[10] = '\0';
6799- // call by a pointer, to force linking of memset, no llvm intrinsic here
6800- volatile auto ptr = memset;
6801- (*ptr)(buffer, 'a', 10);
6790+ char buffer[11] = { 0 };
68026791 depper(buffer);
68036792 puts(buffer);
68046793}
68056794''')
68066795
6807- err = self.expect_fail([EMXX, 'test.cpp', '--js-library', 'lib.js'])
6808- self.assertContained('_memset may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library', err)
6809-
6810- # without the dep, and with EXPORTED_FUNCTIONS, it works ok
6811- create_file('lib.js', r'''
6812- mergeInto(LibraryManager.library, {
6813- depper: function(ptr) {
6814- _memset(ptr, 'd'.charCodeAt(0), 10);
6815- },
6816- });
6817- ''')
6818- self.run_process([EMXX, 'test.cpp', '--js-library', 'lib.js', '-sEXPORTED_FUNCTIONS=_main,_memset'])
6819- self.assertContained('dddddddddd', self.run_js('a.out.js'))
6796+ self.do_runf('test.c', 'dddddddddd\n', emcc_args=['--js-library', 'lib.js'])
68206797
68216798 def test_realpath(self):
68226799 create_file('src.c', r'''
0 commit comments