Skip to content

Commit 5f9dc3d

Browse files
committed
Strip -fPIC compiler flag during compilation
This is a partial revert of #9750. The binaryen change that was designed to allow this to work was reverted: WebAssembly/binaryen#2513
1 parent 0bebbec commit 5f9dc3d

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

emcc.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1937,6 +1937,9 @@ def is_link_flag(flag):
19371937
return any(flag.startswith(x) for x in ('-l', '-L', '-Wl,'))
19381938

19391939
compile_args = [a for a in newargs if a and not is_link_flag(a)]
1940+
if '-fPIC' in compile_args and not shared.Settings.RELOCATABLE:
1941+
shared.warning('ignoring -fPIC flag when not building with SIDE_MODULE or MAIN_MODULE')
1942+
compile_args.remove('-fPIC')
19401943

19411944
# Bitcode args generation code
19421945
def get_clang_command(input_files):

emscripten.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2452,7 +2452,9 @@ def create_asm_consts_wasm(forwarded_json, metadata):
24522452
', code, sigPtr, argbuf); }')
24532453

24542454
if shared.Settings.RELOCATABLE:
2455-
preamble += '\n code -= %s;\n' % shared.Settings.GLOBAL_BASE
2455+
# TODO(sbc): remove this conidtion after
2456+
# https://github.com/WebAssembly/binaryen/pull/2408 lands
2457+
preamble += '\n if (code >= %s) code -= %s;\n' % (shared.Settings.GLOBAL_BASE, shared.Settings.GLOBAL_BASE)
24562458

24572459
asm_const_funcs.append(r'''
24582460
function %s(code, sigPtr, argbuf) {%s

tests/test_core.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8554,6 +8554,7 @@ def test_undefined_main(self):
85548554

85558555
def test_fpic_static(self):
85568556
self.emcc_args.append('-fPIC')
8557+
self.emcc_args.remove('-Werror')
85578558
self.do_run_in_out_file_test('tests', 'core', 'test_hello_world')
85588559

85598560
@node_pthreads

0 commit comments

Comments
 (0)