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

libc++ support for Clang + Linux #4524

Closed
htuch opened this issue Jan 26, 2018 · 10 comments
Closed

libc++ support for Clang + Linux #4524

htuch opened this issue Jan 26, 2018 · 10 comments
Labels
P2 We'll consider working on this in future. (Assignee optional) type: feature request

Comments

@htuch
Copy link

htuch commented Jan 26, 2018

In the Envoy project, we would like to use a combination of our Bazel build and oss-fuzz (https://github.com/google/oss-fuzz), tracked at envoyproxy/envoy#508.

oss-fuzz requires that we are able to build with a Clang toolchain in a Linux Docker container, and link against libc++ rather than libstdc++, see google/oss-fuzz#1114.

I don't see direct support for this in cc_configure.bzl toolchain autoconfigure today, there's direct references to libstdc++ in

def _build_link_content():
for example. Ideally we would have some flag or detection of -stdlib=libc++ as a --linkopt that would correctly configure for linking against libc++.

We'd find it helpful to hear from Bazel team on the ideal way of structuring this and hopefully suggestions for how we can work around this in the interim to avoid blocking our full oss-fuzz integration. I'm guessing we could do a manually crafted CROSSTOOL file (possibly generated on-the-fly prior to Bazel invocation), or continue with Envoy's fork of cc_configure.bzl and build in the support there. The situation is complicated by the fact that oss-fuzz may invoke our build with arbitrary CFLAGS/CXXFLAGS/CC that we need to map into the Bazel world. Thanks!

@jmillikin-stripe @mattklein123 @kcc

@meteorcloudy meteorcloudy added type: feature request P2 We'll consider working on this in future. (Assignee optional) category: rules > C++ labels Jan 29, 2018
@meteorcloudy
Copy link
Member

Using a custom CROSSTOOL sounds like the right way to me, but //cc @mhlopko for more insight.

@htuch
Copy link
Author

htuch commented Feb 1, 2018

@jmillikin-stripe if we have #4031 in the next release, it seems this won't allow us to drop the cc_configure.bzl fork still, since we need to be able to override this for OSS-Fuzz as described above. Thoughts?

@jmillikin-stripe
Copy link
Contributor

If we can use the C++ toolchain support to define a custom envoy_cc_binary rule, then we can use it to do all the flag editing we want without having to worry about the crosstool. It should also be easier to keep up-to-date as the Bazel API changes, since we'll be poking at far fewer internal surfaces.

@hlopko
Copy link
Member

hlopko commented Feb 27, 2018

@htuch @jmillikin-stripe pls verify that 19c6428 is good enough, and let me know if not and I'll reopen. Thanks!

@jmillikin-stripe
Copy link
Contributor

@mhlopko The functionality looks good to me. Can you document somewhere what BAZEL_LINKOPTS is, its expected format, and how it's different from the --linkopt flag?

@hlopko
Copy link
Member

hlopko commented Feb 27, 2018

Let me come back to that next Monday, I'm planning a present for the world later this week.

@hlopko
Copy link
Member

hlopko commented Mar 5, 2018

Still working on (fully documented :) present.

@mihaimaruseac
Copy link

Hi. Any update on the document? I'm thinking we'll need this for OSSFuzz-tensorflow integration

@htuch
Copy link
Author

htuch commented Nov 5, 2018

@mihaimaruseac you can see what we did for Envoy + Bazel + oss-fuzz at https://github.com/google/oss-fuzz/blob/master/projects/envoy/build.sh.

@mihaimaruseac
Copy link

I'm following that, but I thought it might be easier/more readable with BAZEL_LINKOPT (which is not present there).

I got it to work just now, so it should be ok, thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P2 We'll consider working on this in future. (Assignee optional) type: feature request
Projects
None yet
Development

No branches or pull requests

5 participants