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

bindgen identifies unused template parameters in std::unique_ptr<std::string> with latest Mac OS SDK #2942

Open
adetaylor opened this issue Sep 27, 2024 · 0 comments

Comments

@adetaylor
Copy link
Contributor

Using bindgen HEAD revision 7cc2658.

input.hpp contains:

/**
* <div rustbindgen="true" replaces="std::unique_ptr">
*/
template<typename T> class UniquePtr {
    T* ptr;
};
/**
* <div rustbindgen="true" replaces="std::string">
*/
class CxxString {
    char* ptr;
};

#include <memory>
#include <string>
std::unique_ptr<std::string> give_str_up();

Command-line:

cargo run --   "--blocklist-item" "std::unique_ptr" "--blocklist-item" "std::string" "--allowlist-function" "give_str_up" "--enable-cxx-namespaces" input.hpp "--" "-x" "c++" "-std=c++14" "-DBINDGEN"

On a Linux machine, this generates (abridged):

extern "C" {
    #[link_name = "\u{1}_Z11give_str_upB5cxx11v"]
    pub fn give_str_up() -> root::std::unique_ptr<root::std::string>;
}

On my current MacOS X machine, it gives me:

extern "C" {
    #[link_name = "\u{1}__Z11give_str_upv"]
    pub fn give_str_up() -> root::std::__1::unique_ptr;
}

Note the lack of template parameter on unique_ptr, which is the problem I'm facing.

This seems to be a difference in the latest version of the libc++ string header, causing bindgen to believe that the template parameters are unused. This used to be OK on prior OS X versions but I can't give specifics. The SDK causing trouble is the MacOS X 15 SDK.

This is (probably) the root cause of google/autocxx#1396.

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

No branches or pull requests

1 participant