-
-
Notifications
You must be signed in to change notification settings - Fork 110
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
Cross validate Rust ABI with C ABI. #558
Conversation
Glib test buils but failed
It normal that generated ABI executable print "\nzu\nzu" ? |
Not expected at all. If you are running this on Windows, I am surprised it got I wonder how exactly do you run this on Windows, under msys2? |
Msys2x64 with gcc from it. |
|
There is really nice writeup why it doesn't work: https://stackoverflow.com/questions/10678124/mingw-gcc-unknown-conversion-type-character-h-snprintf#10680635. As a workaround one can use following before running tests On Windows the glib-sys test fails with following:
|
Really error for GPid GPollFD seems also have different sizes
vs
|
Confirming that set |
|
Still don't work without
GIO don't compiled until i leave only
Gtk too:
Pango also have many errors. |
Thanks for testing @EPashkin.
AFAIR I was compiling pango with additional define: -DPANGO_ENABLE_ENGINE, |
IMHO no help for Gio on windows. How you plan detect non-portable types? |
Latest results for Windows when using MSYS2 MinGW 64-bit with following flags
|
Pango still failed for me
|
It looks like a problem with exporting environment variable.
instead, it is:
Are you using cmd.exe instead of posix shell? |
I build under cmd.exe.
Glib failed with same error here too, while it works fine under cmd.exe |
@tmiasko Rechecked again, previous problem self fixed. @GuillaumeGomez, @sdroege You see any problem. |
src/codegen/sys/tests.rs
Outdated
|
||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, remove empty lines
I think I came up with a solution to the problem with uncheckable types:
in |
Also IMHO |
I tried to address the uncheckable types using somewhat different approach. Unfortunately, this is only a partial solution. The main problem is that C EDIT: Though, we could remove all non-portable headers from |
@tmiasko Yes, we already have |
Changes since last version:
|
|
||
fn generate_abi_c(env: &Env, path: &Path, w: &mut Write) -> io::Result<()> { | ||
info!("Generating file {:?}", path); | ||
general::start_comments(w, &env.config)?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add try!(writeln!(w, ""));
after this, and for abi.rs
too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
IMHO you can ignore secret-sys: it was added on initial stage and we decide don't publish it |
Maybe we need special |
src/codegen/sys/tests.rs
Outdated
None => return None, | ||
Some(name) => name, | ||
}; | ||
if is_name_made_up(&name) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
& unneeded
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
} | ||
|
||
if results.failed + results.failed_compile != 0 { | ||
panic!("FAILED\nABI test results: {} passed; {} failed (compilation errors: {})", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea
Maybe better don't include "includes" from .gir file to |
Regarding secret-sys, I wanted to test test generation :-) and selected Regarding headers, they don't change too often, so putting them into separate EDIT: It looks like there have been ABI breaking changes in atk as well.
|
|
src/codegen/sys/tests.rs
Outdated
writeln!(w, "")?; | ||
|
||
let ns = env.library.namespace(MAIN_NAMESPACE); | ||
for include in ns.c_includes.iter() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, change this to &ns.c_includes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missed due to all those warnings. Is there some option in clippy to show lints only for files that have some changes in version control?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I know currently this impossible
Fixed clippy warnings and rebased on top of #564. |
Default build rules in GNU Make are constructed based on those environment variables. The rule is eventually evaluated through a shell. To retain compatibility with this behaviour build tools generally use shell parsing rules as well. And so do we!
When combinined with proper configuration changes this makes it possible to skip testing types which are known not to be available.
Limit ABI tests to atk-sys, which is relatively small, to avoid excessive impact on CI runtime. ABI tests are disabled on Travis, because there have been ABI breaking changes since Ubuntu Trusty.
Headers generally need some manual tweaking. Some should be removed and others added, but generally don't change too often. Generate a separate file with headers, but don't overwrite it again unless it was removed.
@tmiasko Thanks |
Cross validate Rust ABI with C ABI.
This is still work in progress. Just in case you have any comments already,
or want to test it out.
Note: I am not using cc and pkg-config crates because they are ill-suited for
usage outside build.rs. For example, cc expects various env variables to be
preconfigured and errors out otherwise, nor does it supports building
executables. Pkg-config prints out cargo specific things on stdout as a side
effect of its usage, and it doesn't even provide access to complete cflags.