Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions test/test_sanity.py
Original file line number Diff line number Diff line change
Expand Up @@ -780,6 +780,12 @@ def test_embuilder_external_ports_options(self):
self.run_process([EMBUILDER, 'build', f'{external_port_path}:dependency=sdl2', '--force'])
self.assertExists(os.path.join(config.CACHE, 'sysroot', 'lib', 'wasm32-emscripten', 'lib_external-sdl2.a'))

def test_embuilder_transitive_pic(self):
restore_and_set_up()
self.run_process([EMBUILDER, 'clear', 'sdl2*'])
self.run_process([EMBUILDER, '--pic', 'clear', 'sdl2*'])
self.run_process([EMCC, '-sMAIN_MODULE=2', '-sUSE_SDL=2', '-sUSE_SDL_GFX=2', test_file('hello_world.c')])

def test_binaryen_version(self):
restore_and_set_up()
with open(EM_CONFIG, 'a') as f:
Expand Down
6 changes: 5 additions & 1 deletion tools/system_libs.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,11 @@ def get_base_cflags(build_dir, force_object_files=False, preprocess=True):
if settings.LTO and not force_object_files:
flags += ['-flto=' + settings.LTO]
if settings.RELOCATABLE or settings.MAIN_MODULE:
flags += ['-fPIC']
# Explictly include `-sRELOCATABLE` when building system libraries.
# `-fPIC` alone is not enough to configure trigger the building and
# caching of `pic` libraries (see `get_lib_dir` in `cache.py`)
# FIXME(sbc): `-fPIC` should really be enough here.
flags += ['-fPIC', '-sRELOCATABLE']
if preprocess:
flags += ['-DEMSCRIPTEN_DYNAMIC_LINKING']
if settings.MEMORY64:
Expand Down