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

protoc with Non-standard Compiler Toolchain #8304

Closed
llchan opened this issue Sep 20, 2019 · 7 comments
Closed

protoc with Non-standard Compiler Toolchain #8304

llchan opened this issue Sep 20, 2019 · 7 comments
Labels
question Questions that are neither investigations, bugs, nor enhancements stale stalebot believes this issue/PR has not been touched recently

Comments

@llchan
Copy link

llchan commented Sep 20, 2019

In the docs, it says it's possible to use a non-standard compiler by specifying CC/LD_LIBRARY_PATH. However, this seems to break host tools:

bazel-out/host/bin/external/com_google_protobuf/protoc: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by bazel-out/host/bin/external/com_google_protobuf/protoc)
bazel-out/host/bin/external/com_google_protobuf/protoc: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.20' not found (required by bazel-out/host/bin/external/com_google_protobuf/protoc)
bazel-out/host/bin/external/com_google_protobuf/protoc: /lib64/libstdc++.so.6: version `CXXABI_1.3.8' not found (required by bazel-out/host/bin/external/com_google_protobuf/protoc)

Running bazel with -s, it seems that protoc is compiled with the non-standard compiler but executed in a exec env - environment without the matching LD_LIBRARY_PATH. I don't have a preference which toolchain it uses, but build/execution should match.

This is basically the same issue as #4736, but if I'm reading this right the resolution there was to modify the bazel source code to pass in a custom environment, which isn't really a reasonable solution. My previous hack involved several patches to cc_configure.bzl and cc_wrapper.py, but now that those are gone it's less clear to me how to get this to work.

I believe this should be reproducible in any system with gcc<7, with a gcc>=7 available in a non-system path.

@lizan lizan added the question Questions that are neither investigations, bugs, nor enhancements label Sep 20, 2019
@lizan
Copy link
Member

lizan commented Sep 20, 2019

@llchan can you provide more context of your environment?

Try passing --action_env=LD_LIBRARY_PATH, that will propagate LD_LIBRARY_PATH when bazel executes the specified compiler.

@llchan
Copy link
Author

llchan commented Sep 20, 2019

I'm running on RHEL 7.5 with system gcc 4.8.5. Envoy requires a newer gcc, so I have a gcc 8.3.0 built in a separate path.

When building, I set CC/LD_LIBRARY_PATH in the shell that's calling bazel, and that seems to be respected. I've tried it with/without --action_env, but either way the protoc call is invoked with an empty environment. I also tried various things like LDFLAGS=-static-libgcc -static-libstdc++, but this does not seem to be passed into the protoc link step.

@llchan
Copy link
Author

llchan commented Sep 20, 2019

Actually this could be related to bazelbuild/bazel#4008. If that is the case, what's the best workaround? I no longer have the cc_wrapper to hijack LDFLAGS the way I used to.

@lizan
Copy link
Member

lizan commented Sep 20, 2019

@llchan try pass those LDFLAGS via --host_linkopt, i.e. --host_linkopt=-static-libgcc --host_linkopt=-static-libstdc++.

@llchan
Copy link
Author

llchan commented Sep 20, 2019

That worked, thanks for the tip!

We should probably still fix the mismatch between host tool compiler and host tool execution env. Seems like CC is respected but LD_LIBRARY_PATH is not. If it's any easier, I think it's acceptable for now to make host tools compile with the system compiler and not make that overridable.

@stale
Copy link

stale bot commented Oct 20, 2019

This issue has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in the next 7 days unless it is tagged "help wanted" or other activity occurs. Thank you for your contributions.

@stale stale bot added the stale stalebot believes this issue/PR has not been touched recently label Oct 20, 2019
@stale
Copy link

stale bot commented Oct 28, 2019

This issue has been automatically closed because it has not had activity in the last 37 days. If this issue is still valid, please ping a maintainer and ask them to label it as "help wanted". Thank you for your contributions.

@stale stale bot closed this as completed Oct 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Questions that are neither investigations, bugs, nor enhancements stale stalebot believes this issue/PR has not been touched recently
Projects
None yet
Development

No branches or pull requests

2 participants