-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Strip -fPIC compiler flag during compilation #10209
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
Conversation
This is a partial revert of #9750. The binaryen change that was designed to allow this to work was reverted: WebAssembly/binaryen#2513
@@ -1937,6 +1937,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.
This change means that people need to compile with SIDE/MAIN_MODULE
and not just link? Is that new or am I forgetting how upstream worked here?
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, I think that is true. But they will see this warning so it should be clear.
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 think this is pretty good intermediate fix until the binaryen fix is ready.
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.
Sounds good.
How do our current tests pass, then? It seems like all dylink/dlfcn tests should warn if they include more than 1 file, since I don't see this flag added to their compile commands?
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.
Agreed it's good to have a temp fix. I'm just trying to fully understand it.
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.
But none of our dylink currently pass -fPIC
. So this means they must all be passing SIDE/MAIN_MODULE
during both compile and link.
As far as I know we never advertised the fact that -fPIC
could be used at compile time instead of SIDE/MAIN_MODULE
.
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.
Interesting, good point.
We should probably add more realistic tests then, if users are using -fPIC
for dynamic linking but our tests aren't.
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.
IIUC users are not using fPIC
for dyamic linking, they are using it simply because their build system always adds it in, but they are doing static linking.
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.
For this PR, it might be nice to add a test of this specific warning, but if we expect to not need this for long, maybe not worth it.
Can confirm that the warning works :) |
As binaryen fix WebAssembly/binaryen#2622 is ready, are you gonna revert this change again. Because with latest emscripten , I am trying to build with SIDE_MODULE/MAIN_MODULE I am getting lots of warning "ignoring -fPIC flag when not building with SIDE_MODULE or MAIN_MODULE" and also error something like "recompile with -fPIC" even when I passed -fPIC flag. Or am I missing something ? |
Yes the plan is to remove this code/warning. For now, you should be able to add SIDE_MODULE/MAIN_MODULE to all your compilation steps to avoid the linker error. |
Now that we have landed (for the third time) the binaryen fix for WebAssembly/binaryen#2180 we can once again allow `-fPIC` at compile time as an alternative to MAIN_MODULE or SIDE_MODULE. This reverts commit 19a9e35.
Now that we have landed (for the third time) the binaryen fix for WebAssembly/binaryen#2180 we can once again allow `-fPIC` at compile time as an alternative to MAIN_MODULE or SIDE_MODULE. This reverts commit 19a9e35.
This is a partial revert of #9750.
The binaryen change that was designed to allow this to work was
reverted: WebAssembly/binaryen#2513