-
Notifications
You must be signed in to change notification settings - Fork 120
Fixed invalid module format & recent nightly support #67
Conversation
You may need to update https://github.com/alex/linux-kernel-module-rust/blob/master/tests/Makefile or https://github.com/alex/linux-kernel-module-rust/blob/master/tests/run_tests.py as well? Thanks for cleaning this up! |
I gave this a try on 1.35.0-nightly, 2019-03-09 and I am still getting some R_X86_64_GOTPCREL. On ubuntu 18.04, 4.15.0-34-generic |
I'm investigating the issue that @safarir pointed out, but am currently running into other problems:
|
Ugh, frustrating. What's the bindgen error, is it something that plausibly upstream should fix? |
With kernel @alex The issue is that bindgen does not support "asm gotos", I get errors about that. I'll check if the bindgen repo has an issue for that, and open one myself if not. I can't really estimate how much effort it would take to implement this. EDIT: Added a snippet of the bindgen errors I'm getting:
|
It seems like asmgotos shouldn't be needed just for generating bindings.
…On Tue, Mar 12, 2019 at 8:15 PM ahomescu ***@***.***> wrote:
With kernel 4.19.28-1-lts (on Arch Linux, haven't tried Ubuntu) and Rust
toolchain nightly-2019-02-03, I can confirm that the module builds and
loads for me.
@alex <https://github.com/alex> The issue is that bindgen does not
support "asm gotos", I get errors about that. I'll check if the bindgen
repo has an issue for that, and open one myself if not. I can't really
estimate how much effort it would take to implement this.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#67 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAADBLVylOyn9VZ-j3dCwHK28wT6AhN3ks5vWEMTgaJpZM4aez35>
.
--
All that is necessary for evil to succeed is for good people to do nothing.
|
Looks like this isn't even a bindgen issue, it's a clang issue: https://bugs.llvm.org/show_bug.cgi?id=9295, fixed in https://reviews.llvm.org/D56571 and landing in LLVM 9??? Edit: basically, clang exits during parsing because it can't parse |
Update on the |
Another issue I just ran into: updating bindgen from 0.47.3 to 0.48.1 broke the build with this error:
due to the output of bindgen switching from #[repr(C)]
pub struct xregs_state {
pub _bindgen_opaque_blob: [u8; 576usize],
} to #[repr(C, packed(64))]
#[repr(align(64))]
pub struct xregs_state {
pub i387: fxregs_state,
pub header: xstate_header,
pub extended_state_area: __IncompleteArrayField<u8>,
} The build works with bindgen 0.47.3, so I'm wondering if the top-level |
I'm ok pinning -- but let's file a bug with bindgen first, I don't want us to be stuck on old versions forever :-) |
Current status: my build works with the following versions:
|
I opened rust-lang/rust-bindgen#1538 and rust-lang/rust#59154. |
FWIW, you don't need to pin. You can just mark the xreg_state as |
Good point. |
Hi @TheDan64 , the target json switch for PLT is |
@jason-ni Sorry, that is correct in the modified json file, but not in my initial comment. Will edit. |
@alex I wonder if these tests are failing because travis seems to be on kernel 4.4? Building the module worked in 4.19 for me |
@TheDan64 Can you try adapting the makefile changes you did in |
this is the issue where we need to exclude some struct, right? |
Yeah. How do I go about marking |
In |
The next error I see when testing locally is:
#[repr(C, packed)]
#[derive(Debug, Default)]
pub struct desc_struct {
pub limit0: u16,
pub base0: u16,
pub _bitfield_1: __BindgenBitfieldUnit<[u8; 4usize], u8>,
} Should this be made opaque too? I'm guessing |
|
Oh yeah; good point. Does bindgen have a way to mark structs as Copy? |
Not only does it have a way, I think it does that by default! We have I don't have an off the cuff solution for that -- we don't need that struct AFAIK, so maybe we can make it (or the type containing it?) opaque. Or maybe we can explicitly add |
The commit that introduces it is utterly useless unfortunately: 01a7774 Bad Alex... no cookie. |
You can explicitly mark it |
I've rebased as you requested - however there were a ton of merge conflicts so hopefully I got it right.. |
Thanks! Looks like there's something going wrong in the build process -- some issue with how the makefile changes interact #68 ? |
I fixed the diff so that it uses Edit: Oh, the else clause maybe. hmm |
Co-Authored-By: TheDan64 <ThaDan64@gmail.com>
IT WORKS ON XENIAL! I think we should just disable trusty, and review this!!!! |
Thanks so much for your persistence on this! I'm excited to be able to merge this once @geofft has a look. |
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.
LGTM! If it looks good to @geofft, we'll land! Thanks again!
I'd like to know what precisely makes this build, mostly with the goal of making sure we don't accidentally regress it in the future again. I have two test branches ("test-without-ld" and "geofft-test-2"), the first one one based on this PR minus some things and the second one based on @alex's recent work on master plus some things, and I'm still unsure why the first one passes Travis and the second one doesn't. (There are very few changes between them; notably they both have the PLT change. Note GitHub's compare view is a by-commit comparison, you probably want to fetch the branches locally and diff them if you want to see the difference.) I'm hoping I can figure this out tonight or early tomorrow. Also I want to resolve the discussion in #75 before we merge this. Definitely happy to drop Trusty so we can get back to building productive things on new kernels and figure out the relocation problem with older kernels later. :-) Thanks for your work on this! |
OK, after some cherry-picking, it looks like those are the same question - the Besides that I think there's enough try/revert/try-again on this branch that I'd like to get rid of that, because everything's already confusing enough today and I'm worried it'll just be more confusing in the future - if everyone's okay with me doing so, I'd like to rebase this down to the semantic changes (and make sure we keep credit for everyone!). I can prep that by tomorrow morning. In particular I'd like to split out the Makefile changes and review those in a separate PR, since those don't seem to be necessary to get things to work. |
Actually I forgot we're in rebase mode and not merge mode so it doesn't matter where they're merged from... #79 is merged and master is passing CI, thank you 🎉 I'll open PRs for the remaining commits on this branch and close this. |
OK, I think everything's been split out:
Besides that the only thing in my local diff is a stray newline, so I'm closing this. But please open a new PR if I missed something! Thanks again for getting this project green :-D |
Hi there, we've been looking into writing a kernel module in rust, and your repo has been super helpful, thanks!
It seems like you guys had some issues with
R_X86_64_GOTPCREL
being introduced in rust nightly late last year causing thoseInvalid module format
error messages@ahomescu was able to narrow it down to this commit: rust-lang/rust@6009da0
And so the fix seems to be adding
"needs-plt": true
to the target json file. We've also updated the code to work on more recent nightlies.This works locally but for some reason travis' test
sysctl-tests
still fails withInvalid module format
for some reason. Is this test using a separate target info perhaps that needs to be update too? Or maybe is something being cached?