Skip to content

Commit

Permalink
Ignore -fPIC flag when not building relocatable code
Browse files Browse the repository at this point in the history
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
  • Loading branch information
sbc100 committed Oct 25, 2019
1 parent 9e389cb commit a1a8b17
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
5 changes: 4 additions & 1 deletion emcc.py
Original file line number Diff line number Diff line change
Expand Up @@ -1883,6 +1883,9 @@ def is_link_flag(flag):
return any(flag.startswith(x) for x in ('-l', '-L', '-Wl,'))

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

# Bitcode args generation code
def get_clang_command(input_files):
Expand Down Expand Up @@ -3661,5 +3664,5 @@ def validate_arg_level(level_string, max_level, err_msg, clamp=False):
try:
sys.exit(run(sys.argv))
except KeyboardInterrupt:
logger.warning("KeyboardInterrupt")
logger.warning('KeyboardInterrupt')
sys.exit(1)
5 changes: 5 additions & 0 deletions tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -8359,6 +8359,11 @@ def test_undefined_main(self):
'''
self.build(src, self.get_dir(), 'test.c')

def test_fpic_static(self):
self.emcc_args.append('-fPIC')
self.emcc_args.remove('-Werror')
self.do_run_in_out_file_test('tests', 'core', 'test_hello_world')


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

0 comments on commit a1a8b17

Please sign in to comment.