diff --git a/test/test_browser.py b/test/test_browser.py index d7e1d7d3ef449..3709613779052 100644 --- a/test/test_browser.py +++ b/test/test_browser.py @@ -1936,6 +1936,7 @@ def test_gl_glteximage(self): @parameterized({ '': ([],), 'pthreads': (['-pthread', '-sPROXY_TO_PTHREAD', '-sOFFSCREEN_FRAMEBUFFER'],), + 'pthreads_main_module': (['-pthread', '-sPROXY_TO_PTHREAD', '-sOFFSCREEN_FRAMEBUFFER', '-sMAIN_MODULE', '-Wno-experimental'],), }) @requires_graphics_hardware def test_gl_textures(self, args): diff --git a/tools/link.py b/tools/link.py index 622dd7b93c097..9b0392d71fcb3 100644 --- a/tools/link.py +++ b/tools/link.py @@ -3090,7 +3090,14 @@ def run(options, linker_args): logger.debug('stopping after linking to object file') return 0 - linker_args += phase_calculate_system_libraries(options) + system_libs = phase_calculate_system_libraries(options) + # Only add system libraries that have not already been specified. + # This avoids issues where the user explictly includes, for example, `-lGL`. + # This is not normally a problem except in the case of -sMAIN_MODULE=1 where + # the duplicate library would result in duplicate symbols. + for s in system_libs: + if s not in linker_args: + linker_args.append(s) js_syms = {} if (not settings.SIDE_MODULE or settings.ASYNCIFY) and not shared.SKIP_SUBPROCS: