Skip to content

Commit 322a2f6

Browse files
committed
Ignore -fPIC flag when not building relocatable code
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 940603e commit 322a2f6

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

emcc.py

Lines changed: 3 additions & 0 deletions
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):

tests/test_core.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8276,6 +8276,11 @@ def test_undefined_main(self):
82768276
'''
82778277
self.build(src, self.get_dir(), 'test.c')
82788278

8279+
def test_fpic_static(self):
8280+
self.emcc_args.append('-fPIC')
8281+
self.emcc_args.remove('-Werror')
8282+
self.do_run_in_out_file_test('tests', 'core', 'test_hello_world')
8283+
82798284

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

0 commit comments

Comments
 (0)