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

add -fPIC for cxx_cc so that it can link in clang properly #1400

Closed
wants to merge 1 commit into from

Conversation

sthornington
Copy link

Fixes linking in clang toolchains, e.g. #1399

Copy link
Owner

@dtolnay dtolnay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks odd to me. -fPIC is something that needs to be seen by every C++ compiler invocation in a whole build. It isn't something that individual cc_library targets should be deciding to pass or not pass. Do you have more context about why this is the right fix?

@sthornington
Copy link
Author

This looks odd to me. -fPIC is something that needs to be seen by every C++ compiler invocation in a whole build. It isn't something that individual cc_library targets should be deciding to pass or not pass. Do you have more context about why this is the right fix?

Ultimately, I was just following clang's suggestion during trying to get it all working with clang in #1399

/usr/bin/ld.gold: error: bazel-out/k8-dbg/bin/external/crate_index__cxx-1.0.130/libcxx_cc.a(cxx.o): requires dynamic R_X86_64_32 reloc against '__gxx_personality_v0' which may overflow at runtime; recompile with -fPIC

@sthornington
Copy link
Author

I have great stake in how this is done, but this is the only thing that fixed it for me when building with a clang cc toolchain - have you been able to build it all in Linux with clang some other way?

@sthornington
Copy link
Author

Sorry I meant "I have no great stake in how it all gets done", I just need to be able to link rust and C++ and cxx bindings in both gcc and clang in bazel.

@sthornington
Copy link
Author

Ok I just added it to my bazelrc and that does the same trick. I guess I don't need this merged after all, but it's here if you want it.

@sthornington
Copy link
Author

That said, I have other issues... when compiling with -fsanitize stuff, it complains that that particular archive is missing __UBSAN symbols etc.

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.

2 participants