@@ -6782,26 +6782,22 @@ def test_no_missing_symbols(self): # simple hello world should not show any miss
67826782mergeInto(LibraryManager.library, {
67836783 my_js__deps: ['main'],
67846784 my_js: (function() {
6785- return function() {
6786- console.log("hello " + _nonexistingvariable);
6787- };
6785+ return () => console.log("hello " + _nonexistingvariable);
67886786 }()),
67896787});
67906788''')
6791- create_file('test.cpp ', '''\
6789+ create_file('test.c ', '''\
67926790#include <stdio.h>
67936791#include <stdlib.h>
67946792
6795- extern "C" {
6796- extern void my_js();
6797- }
6793+ void my_js();
67986794
67996795int main() {
68006796 my_js();
68016797 return EXIT_SUCCESS;
68026798}
68036799''')
6804- self.run_process([EMXX , 'test.cpp ', '--js-library', 'library_foo.js'])
6800+ self.run_process([EMCC , 'test.c ', '--js-library', 'library_foo.js'])
68056801
68066802 # but we do error on a missing js var
68076803 create_file('library_foo_missing.js', '''
@@ -6814,16 +6810,16 @@ def test_no_missing_symbols(self): # simple hello world should not show any miss
68146810 }()),
68156811});
68166812''')
6817- err = self.expect_fail([EMXX , 'test.cpp ', '--js-library', 'library_foo_missing.js'])
6818- self.assertContained('undefined symbol: nonexistingvariable', err)
6813+ err = self.expect_fail([EMCC , 'test.c ', '--js-library', 'library_foo_missing.js'])
6814+ self.assertContained('wasm-ld: error: symbol exported via --export not found : nonexistingvariable', err)
68196815
68206816 # and also for missing C code, of course (without the --js-library, it's just a missing C method)
6821- err = self.expect_fail([EMXX , 'test.cpp '])
6817+ err = self.expect_fail([EMCC , 'test.c '])
68226818 self.assertContained('undefined symbol: my_js', err)
68236819
6824- def test_js_lib_to_system_lib (self):
6825- # memset is in compiled code, so a js library __deps can't access it. it
6826- # would need to be in deps_info.json or EXPORTED_FUNCTIONS
6820+ def test_js_lib_native_deps (self):
6821+ # Verify that memset (which lives in compiled code), can be specified as a JS library
6822+ # dependency.
68276823 create_file('lib.js', r'''
68286824mergeInto(LibraryManager.library, {
68296825 depper__deps: ['memset'],
@@ -6832,38 +6828,19 @@ def test_js_lib_to_system_lib(self):
68326828 },
68336829});
68346830''')
6835- create_file('test.cpp', r'''
6836- #include <string.h>
6831+ create_file('test.c', r'''
68376832#include <stdio.h>
68386833
6839- extern "C" {
6840- extern void depper(char*);
6841- }
6834+ void depper(char*);
68426835
68436836int main(int argc, char** argv) {
6844- char buffer[11];
6845- buffer[10] = '\0';
6846- // call by a pointer, to force linking of memset, no llvm intrinsic here
6847- volatile auto ptr = memset;
6848- (*ptr)(buffer, 'a', 10);
6837+ char buffer[11] = { 0 };
68496838 depper(buffer);
68506839 puts(buffer);
68516840}
68526841''')
68536842
6854- err = self.expect_fail([EMXX, 'test.cpp', '--js-library', 'lib.js'])
6855- self.assertContained('_memset may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library', err)
6856-
6857- # without the dep, and with EXPORTED_FUNCTIONS, it works ok
6858- create_file('lib.js', r'''
6859- mergeInto(LibraryManager.library, {
6860- depper: function(ptr) {
6861- _memset(ptr, 'd'.charCodeAt(0), 10);
6862- },
6863- });
6864- ''')
6865- self.run_process([EMXX, 'test.cpp', '--js-library', 'lib.js', '-sEXPORTED_FUNCTIONS=_main,_memset'])
6866- self.assertContained('dddddddddd', self.run_js('a.out.js'))
6843+ self.do_runf('test.c', 'dddddddddd\n', emcc_args=['--js-library', 'lib.js'])
68676844
68686845 def test_realpath(self):
68696846 create_file('src.c', r'''
0 commit comments