Skip to content

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

Merged
merged 1 commit into from
Jan 15, 2020
Merged

Strip -fPIC compiler flag during compilation #10209

merged 1 commit into from
Jan 15, 2020

Conversation

sbc100
Copy link
Collaborator

@sbc100 sbc100 commented Jan 14, 2020

This is a partial revert of #9750.

The binaryen change that was designed to allow this to work was
reverted: WebAssembly/binaryen#2513

@sbc100 sbc100 requested a review from kripken January 14, 2020 22:00
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')
Copy link
Member

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?

Copy link
Collaborator Author

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.

Copy link
Collaborator Author

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.

Copy link
Member

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?

Copy link
Member

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.

Copy link
Collaborator Author

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.

Copy link
Member

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.

Copy link
Collaborator Author

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.

Copy link
Member

@kripken kripken left a 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.

@sbc100 sbc100 merged commit 19a9e35 into master Jan 15, 2020
@delete-merged-branch delete-merged-branch bot deleted the strip_fpic branch January 15, 2020 01:37
@dcodeIO
Copy link
Contributor

dcodeIO commented Jan 19, 2020

Can confirm that the warning works :)

@rohitsaini1995
Copy link

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 ?

@sbc100
Copy link
Collaborator Author

sbc100 commented Jan 28, 2020

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.

sbc100 added a commit that referenced this pull request Jan 29, 2020
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.
sbc100 added a commit that referenced this pull request Jan 29, 2020
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants