Skip to content

Forward CXX env and arguments from cargo_build_script #1003

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

Open
ikalchev opened this issue Nov 2, 2021 · 0 comments · May be fixed by #1004
Open

Forward CXX env and arguments from cargo_build_script #1003

ikalchev opened this issue Nov 2, 2021 · 0 comments · May be fixed by #1004

Comments

@ikalchev
Copy link
Contributor

ikalchev commented Nov 2, 2021

Objects produced with cargo_build_script may be linked in cc_* targets. For this to succeed, the options for building with a cargo build script and with cc_* should be (mostly) the same.

When using a cargo_build_script that compiles a C++ object, the env and command line arguments from the cc_toolchain are not forwarded to cargo_build_script_runner/bin.rs.

(This is in continuation of my comments here #969 (comment))

PR coming soon.

Example

Suppose the cc_toolchain defines -D_GLIBCXX_USE_CXX11_ABI=0. Now suppose we use a cargo_build_script that compiles a cc_library that has in its sources:

void f(const std::string& str);

If we now try to link this library in a cc_binary which calls f, we will get a link-time error for undefined reference to f. Upon inspecting the symbols of the library produced by cargo_build_script we can find f. However, upon further inspection, the mangling of the parameter for the function is different - std::__cxx11:basic_string..., whereas the cc_binary looks for std::basic_string....

ikalchev pushed a commit to ikalchev/rules_rust that referenced this issue Nov 2, 2021
We need to forward the C++ command line arguments and env to ``bin.rs``
to make sure cargo_build libraries are compiled with the same options
as `cc_*` targets.

Fixes bazelbuild#1003
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants