-
Notifications
You must be signed in to change notification settings - Fork 707
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
Incorrect __cxx11
part in symbol names in generated rust code
#789
Comments
The next steps to making this issue actionable are to look at what's inside I suspect it is using an inline namespace or something. |
This seems like we're mishandling inline namespaces somewhere somewhere... Does the error go away if you turn on the And yeah, a reduced test-case based on the above would be neat! I can try to construct one, but I'll be mostly away until the next week, so if you beat me to it, that'd be rad :) |
Setting the # predicate.sh
#!/usr/bin/env bash
# Exit the script with a nonzero exit code if:
# * any individual command finishes with a nonzero exit code, or
# * we access any undefined variable.
set -eu
# Print out Rust backtraces on panic. Useful for minimizing a particular panic.
export RUST_BACKTRACE=1
# If the `libclang.so` you're using for `bindgen` isn't the system
# `libclang.so`, let the linker find it.
export LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu/
# Make sure that the reduced test case is valid C/C++ by compiling it. If it
# isn't valid C/C++, this command will exit with a nonzero exit code and cause
# the whole script to do the same.
clang --std=c++11 -c ./pre_processed.hpp
# Run `bindgen` and `grep` for the thing your hunting down! Make sure to include
# `2>&1` to get at stderr if you're hunting down a panic.
bindgen \
--whitelist-type=Test \
./pre_processed.hpp \
-- -x c++ --std=c++11 \
2>&1 \
| grep "__cxx11"
I am not sure if I namespace __cxx11 {
template <typename> class A {
enum {};
};
} which looks indeed namespace related as Emilio suggested. Any ideas on how to proceed? |
Hmm... I don't think grepping for that will work, you presumably need a more complex test, or doing Complete shot in the dark, since I haven't been able to reproduce it yet, does: diff --git a/src/ir/item.rs b/src/ir/item.rs
index 3564c6e8..786cc708 100644
--- a/src/ir/item.rs
+++ b/src/ir/item.rs
@@ -649,6 +649,12 @@ impl Item {
_ => return item.id(),
}
}
+ ItemKind::Module(ref module) => {
+ if !module.is_inline() || ctx.options().conservative_inline_namespaces {
+ return item.id();
+ }
+ item = ctx.resolve_item(item.parent_id());
+ }
_ => return item.id(),
}
} Fix the problem? |
Ok, here it is: namespace std {
inline namespace __cxx11 {
template<typename CharT>
class basic_string {
struct Alloc_hider {
void* storage;
} hider;
unsigned long length;
struct {
CharT inline_storage[4];
};
};
}
}; |
Ok, so the test-case above works with any of the |
(I'm really bad at being mostly away, whoops) |
ir: Properly skip inline namespaces when building names. Fixes #789
If I try to wrap a c++ header with bindgen, the compilation of my project fails due to incorrect naming in the generated rust file. The header is taken from issue #598, where a generated binding seems to suffer of the same issue.
Input C/C++ Header
Bindgen Invocation
Actual Results
The generated rust file has undefined symbols:
here are the generated bindings:
Expected Results
The naming should obviously be valid. On IRC the idea was voiced that this might be related to "ABI tagging" but I do lack further insight into this issue.
RUST_LOG=bindgen
OutputThe log did not provide further details:
The text was updated successfully, but these errors were encountered: