-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ignore -fPIC flag when not building relocatable code #9710
Conversation
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
PTAL |
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') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is enough to hit the bug, at least not when i tested myself. I had to build tests/hello_libcxx.cpp
which I guess includes enough libc++ to see breakage.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test fails withou the corresponding change to strip the -fPIC
. I just reconfirmed. There might be multiple bugs but the emcc.py change makes this test start passing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah ok, sounds good on the test then.
@@ -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') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You explained this to me but I realize I still don't get it, sorry. What happens in this case:
emcc a.c -fPIC -c
emcc a.o -s SIDE_MODULE
It seems like the first command will lose the -fPIC
, so it will try to link a non-PIC into a SIDE_MODULE. I think you said that errors? Would the only way to avoid the error be to pass SIDE_MODULE
at compile time too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes and yes.
For now, until we fix the underlying issue with static linking of PIC objects, then we can allow -fPIC
to control this again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sgtm, but (separately from this PR if you want) please update the docs to mention that with the new backend, MAIN/SIDE_MODULES must have their source files built with MAIN/SIDE_MODULE
. E.g. here in the list of big backend differences, https://emscripten.org/docs/compiling/WebAssembly.html#backends
Please add this to the docs (that with the new backend, one must add flags a compile time too). And also this is a breaking change for some users (as |
…#9710) This issue was supposed to have been fixed in lld but it seems that issues remain. See https://reviews.llvm.org/D65922. Fixes: emscripten-core#9690, emscripten-core#9013
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