-
Notifications
You must be signed in to change notification settings - Fork 747
When only generating functions, type parameter is lost #848
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
Comments
This is really hard to reproduce. I've preprocessed all of Trying reproducing with the full servo bindings next. |
Blech I can't even reproduce with the full preprocessed servo bindings. |
OK, I eventually figured out a real way to reproduce it... |
And this is reproducible on Windows as well. I have no idea why it didn't cause any issue on other platforms when with Gecko... |
You need two files, in different directory. Let's say // input.hpp
#include "another.h" // subdir/another.h
template<typename T>
class nsTArray;
/**
* <div rustbindgen replaces="nsTArray"></div>
*/
template<typename T>
class nsTArray_Simple {
T* m;
};
extern "C" {
nsTArray<int>* func();
} Then invoke bindgen with:
|
If you move all the code from |
What seem to be necessary for triggering this bug are:
What doesn't seem to be related:
|
Thanks a lot for the investigation an the test-case Xidorn, trying to repro now. |
So, I can repro, but the generated code is: /* automatically generated by rust-bindgen */
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct nsTArray {
pub mBuffer: *mut ::std::os::raw::c_void,
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct nsTArray_Simple<T> {
pub m: *mut T,
pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<T>>,
}
extern "C" {
pub fn func() -> *mut nsTArray;
} Which means that we're not managing to see the replacement. Does that match what you see @upsuper? |
I think I know why this is... |
So, we don't even find the replacement annotation, which is surprising, at a glance. I'm trying to bisect when this broke. |
I can confirm that v0.26.1 works, so far. |
Well, this is fun:
|
I can confirm that reverting that patch fixes the issue for me... Now, I'm going to see if this is a regression in |
So, I can confirm that passing empty flags to the new clang_sys also fixes this, so I bet what is happening is that clang-sys is returning all the paths, not only the system ones, and we're adding them as I bet clang does different stuff when parsing system headers which makes us not recognise annotations. |
So clang-4.0 gives me, as expected: $ clang -E -x c++ - -v -Iinclude
clang version 4.0.0 (tags/RELEASE_400/final)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-redhat-linux/7
Found candidate GCC installation: /usr/lib/gcc/x86_64-redhat-linux/7
Selected GCC installation: /usr/bin/../lib/gcc/x86_64-redhat-linux/7
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Selected multilib: .;@m64
"/usr/bin/clang-4.0" -cc1 -triple x86_64-unknown-linux-gnu -E -disable-free -disable-llvm-verifier -discard-value-names -main-file-name - -mrelocation-model static -mthread-model posix -mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 -v -dwarf-column-info -debugger-tuning=gdb -resource-dir /usr/bin/../lib64/clang/4.0.0 -I include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/7/../../../../include/c++/7 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/7/../../../../include/c++/7/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/7/../../../../include/c++/7/backward -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib64/clang/4.0.0/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -fdeprecated-macro -fdebug-compilation-dir /home/emilio/projects/moz/rust-bindgen -ferror-limit 19 -fmessage-length 190 -fobjc-runtime=gcc -fcxx-exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics -o - -x c++ -
clang -cc1 version 4.0.0 based upon LLVM 4.0.0 default target x86_64-unknown-linux-gnu
ignoring nonexistent directory "/include"
#include "..." search starts here:
#include <...> search starts here:
include
/usr/bin/../lib/gcc/x86_64-redhat-linux/7/../../../../include/c++/7
/usr/bin/../lib/gcc/x86_64-redhat-linux/7/../../../../include/c++/7/x86_64-redhat-linux
/usr/bin/../lib/gcc/x86_64-redhat-linux/7/../../../../include/c++/7/backward
/usr/local/include
/usr/bin/../lib64/clang/4.0.0/include
/usr/include
End of search list. Which means that we're incorrectly promoting |
I've investigated more, and the key is that clang doesn't try to parse documentation comments in system includes. |
Got a fix for this... Maybe we want to rethink all the path fixup, but it is needed so far to cross-compile so... |
lib: Filter out include paths when looking for clang paths. Fixes #848
lib: Filter out include paths when looking for clang paths. Fixes #848
We still have more issues like #835...
Input C/C++ Header
Bindgen Invocation
Actual Results
https://treeherder.mozilla.org/logviewer.html#?job_id=117196247&repo=try&lineNumber=6725
Expected Results
nsTArray
should have a type argument.The text was updated successfully, but these errors were encountered: