Skip to content

Commit fe35baf

Browse files
authored
Ignore -fPIC flag when not building relocatable code (#9710)
This issue was supposed to have been fixed in lld but it seems that issues remain. See https://reviews.llvm.org/D65922. Fixes: #9690, #9013
1 parent fd3f11f commit fe35baf

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

emcc.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -1883,6 +1883,9 @@ def is_link_flag(flag):
18831883
return any(flag.startswith(x) for x in ('-l', '-L', '-Wl,'))
18841884

18851885
compile_args = [a for a in newargs if a and not is_link_flag(a)]
1886+
if '-fPIC' in compile_args and not shared.Settings.RELOCATABLE:
1887+
shared.warning('ignoring -fPIC flag when not building with SIDE_MODULE or MAIN_MODULE')
1888+
compile_args.remove('-fPIC')
18861889

18871890
# Bitcode args generation code
18881891
def get_clang_command(input_files):
@@ -3661,5 +3664,5 @@ def validate_arg_level(level_string, max_level, err_msg, clamp=False):
36613664
try:
36623665
sys.exit(run(sys.argv))
36633666
except KeyboardInterrupt:
3664-
logger.warning("KeyboardInterrupt")
3667+
logger.warning('KeyboardInterrupt')
36653668
sys.exit(1)

tests/test_core.py

+5
Original file line numberDiff line numberDiff line change
@@ -8359,6 +8359,11 @@ def test_undefined_main(self):
83598359
'''
83608360
self.build(src, self.get_dir(), 'test.c')
83618361

8362+
def test_fpic_static(self):
8363+
self.emcc_args.append('-fPIC')
8364+
self.emcc_args.remove('-Werror')
8365+
self.do_run_in_out_file_test('tests', 'core', 'test_hello_world')
8366+
83628367

83638368
# Generate tests for everything
83648369
def make_run(name, emcc_args, settings=None, env=None):

0 commit comments

Comments
 (0)