Skip to content
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

Rationale for not propagating -shared #24

Open
jsharpe opened this issue Jan 15, 2021 · 5 comments
Open

Rationale for not propagating -shared #24

jsharpe opened this issue Jan 15, 2021 · 5 comments

Comments

@jsharpe
Copy link
Contributor

jsharpe commented Jan 15, 2021

[flag for flag in link_flags if not flag.startswith("-l") and flag != "-shared"],

Was wondering why '-shared is removed from the list of flags that is propagated to vpip? I've found that for at least one package with a binary component that -shared needs to be propagated for proper compilation.

@benjaminp
Copy link
Contributor

We explicitly set it in our linker wrapper:

$CC -shared "${opts[@]}"

@jsharpe
Copy link
Contributor Author

jsharpe commented Jan 16, 2021

Ah ok, I think this is a specific issue to the mpi4py package then as it doesn't use the LD wrapper passed by vpip but instead the mpicc compiler wrapper alongside the ld flags passed and so the missing -shared from flags is an issue for that package.

@benjaminp
Copy link
Contributor

The principle here is that we always build shared modules for Python extensions. So, it makes sense that we ignore whatever Bazel's C++ rules think the linking configuration is.

I'm confused why this would break mpi4py, though, since presumably it doesn't rely on -shared being passed in when built outside of Bazel.

@jsharpe
Copy link
Contributor Author

jsharpe commented Jan 21, 2021

I haven't checked exactly this but I suspect because the LD flags are being overridden in the environment then its not automatically adding -shared as it assumes you've already fully specified the link options for a shared library?

Surely though it doesn't hurt if -shared is passed twice to the linker, so why does it need to be filtered out? I've patched my version to do this and it seems to work for the limited set of libraries that I'm building.

@benjaminp
Copy link
Contributor

It seems like the problem with -shared in default ldflags is when packages expect to build executables as part of their setup.py. For example, https://pypi.org/project/vmprof runs ./configure from its setup.py.

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

No branches or pull requests

2 participants