diff --git a/tests/test_other.py b/tests/test_other.py index 17426844a825c..db369e2ba7b0e 100644 --- a/tests/test_other.py +++ b/tests/test_other.py @@ -10117,3 +10117,34 @@ def test_em_asm_side_module(self): def test_em_js_side_module(self): err = self.expect_fail([EMCC, '-sSIDE_MODULE', test_file('core/test_em_js.cpp')]) self.assertContained('EM_JS is not supported in side modules', err) + + # On Windows maximum command line length is 32767 characters. Create such a long build line by linking together + # several .o files to test that emcc internally uses response files properly when calling llvmn-nm and wasm-ld. + @is_slow_test + def test_windows_long_link_response_file(self): + decls = '' + calls = '' + files = [] + + def create_o(name, i): + nonlocal decls, calls, files + f = name + '.c' + create_file(f, 'int %s() { return %d; }' % (name, i)) + files += [f] + decls += 'int %s();' % name + calls += 'value += %s();' % name + + count = 1000 + for i in range(count): + name = 'a' + str(i) + for j in range(5): + name += name + create_o(name, i) + + main = '#include\n%s int main() { int value = 0; %s printf("%%d\\n", value); }' % (decls, calls) + open('main.c', 'w').write(main) + + assert(sum(len(f) for f in files) > 32767) + + self.run_process(building.get_command_with_possible_response_file([EMCC, 'main.c'] + files)) + self.assertContained(str(count * (count - 1) // 2), self.run_js('a.out.js'))