Skip to content

Forward CXX env and arguments from cargo_build_script #1003

@ikalchev

Description

@ikalchev

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....

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions