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

error: This crate currently does not support 32-bit protected mode when compiling kernel with x86_64-unknown-none target #90

Closed
aegis-dev opened this issue Jan 6, 2020 · 10 comments · Fixed by #91

Comments

@aegis-dev
Copy link

After updating bootloader to 0.8.3 I started getting error: This crate currently does not support 32-bit protected mode error but I am pretty sure that I cross-compile x86_64 arch binary.
This issue is not reproducible with bootloader version 0.7.1 or lower. Here is the content of my target x86_64-unknown-none.json:
{
"llvm-target": "x86_64-unknown-none",
"data-layout": "e-m:e-i64:64-f80:128-n8:16:32:64-S128",
"arch": "x86_64",
"target-endian": "little",
"target-pointer-width": "64",
"target-c-int-width": "32",
"os": "none",
"executables": true,
"linker-flavor": "ld.lld",
"linker": "rust-lld",
"panic-strategy": "abort",
"disable-redzone": true,
"features": "-mmx,-sse,+soft-float"
}

I am compiling with this command:
cargo bootimage --target x86_64-unknown-none.json

Best regards!

@phil-opp
Copy link
Member

phil-opp commented Jan 7, 2020

I tried to reproduce the error, but a test project compiles successfully with bootloader 0.8.3 and your target file.

The error you're seeing is emitted here:

bootloader/build.rs

Lines 3 to 7 in 90f5b89

#[cfg(target_arch = "x86")]
compile_error!(
"This crate currently does not support 32-bit protected mode. \
See https://github.com/rust-osdev/bootloader/issues/70 for more information."
);

Are you sure that you have the arch key in your target JSON set to "x86_64` and not "x86"?

@bjorn3
Copy link
Contributor

bjorn3 commented Jan 7, 2020

I think @0x00AE6150 is using a 32bit system. A build script always gets build for the native architecture, not the target architecture.

@phil-opp
Copy link
Member

phil-opp commented Jan 7, 2020

Good catch! Moving these checks to the lib.rs/main.rs should solve the problem, right?

@bjorn3
Copy link
Contributor

bjorn3 commented Jan 7, 2020

Yes

@aegis-dev
Copy link
Author

I am not sure why but my windows machine has 32 bit rust toolchain installed on 64 bit system... However, during rust installation i get prompted that x86_64 tools are installed. I will try to look more into it later.

@phil-opp
Copy link
Member

phil-opp commented Jan 8, 2020

@0x00AE6150 It could also be that you have e.g. an ARM CPU instead of a x86_64 CPU. Either way, the mistake is on our side, as it should be possible to build the bootloader on all platforms independent of the CPU architecture. The fix is actually relatively simple: We just have to move the checks linked above to a different file, so that they check the target system instead of the host system. I implemented this fix in #91 and will publish a new bootloader version as soon as it's merged.

@phil-opp
Copy link
Member

@0x00AE6150 I just released the fix in #91 as version 0.8.4. Could you try whether it fixes your issue?

@aegis-dev
Copy link
Author

@phil-opp I am so sorry for the delay. I will verify the fix today.

@aegis-dev
Copy link
Author

@phil-opp works like a charm. Thank you very much <3

@phil-opp
Copy link
Member

@0x00AE6150 Great! Thanks a lot for verifying!

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

Successfully merging a pull request may close this issue.

3 participants