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

[BROKEN] 32-bit x86 (i386) support #966

Draft
wants to merge 2 commits into
base: rust
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion arch/um/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ config UML
select TRACE_IRQFLAGS_SUPPORT
select TTY # Needed for line.c
select HAVE_ARCH_VMAP_STACK
select HAVE_RUST if X86_64
select HAVE_RUST

config MMU
bool
Expand Down
2 changes: 1 addition & 1 deletion arch/x86/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ config X86
select HAVE_STATIC_CALL_INLINE if HAVE_OBJTOOL
select HAVE_PREEMPT_DYNAMIC_CALL
select HAVE_RSEQ
select HAVE_RUST if X86_64
select HAVE_RUST
select HAVE_SYSCALL_TRACEPOINTS
select HAVE_UACCESS_VALIDATION if HAVE_OBJTOOL
select HAVE_UNSTABLE_SCHED_CLOCK
Expand Down
1 change: 1 addition & 0 deletions arch/x86/lib/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ ifeq ($(CONFIG_X86_32),y)
ifneq ($(CONFIG_X86_CMPXCHG64),y)
lib-y += cmpxchg8b_emu.o atomic64_386_32.o
endif
lib-y += moddiv_32.o
else
obj-y += iomap_copy_64.o
ifneq ($(CONFIG_GENERIC_CSUM),y)
Expand Down
13 changes: 13 additions & 0 deletions arch/x86/lib/moddiv_32.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#include <linux/math64.h>

unsigned long long __udivdi3(unsigned long long a, unsigned long long b)
{
return div64_u64(a, b);
}

unsigned long long __umoddi3(unsigned long long a, unsigned long long b)
{
unsigned long long rem;
div64_u64_rem(a, b, &rem);
return rem;
}
13 changes: 13 additions & 0 deletions scripts/generate_rust_target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,19 @@ fn main() {
ts.push("features", features);
ts.push("llvm-target", "x86_64-linux-gnu");
ts.push("target-pointer-width", "64");
} else if cfg.has("X86_32") {
ts.push("arch", "x86");
ts.push(
"data-layout",
"e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-f64:32:64-f80:32-n8:16:32-S128",
);
let mut features = "-3dnow,-3dnowa,-mmx,+soft-float".to_string();
if cfg.has("RETPOLINE") {
features += ",+retpoline-external-thunk";
}
ts.push("features", features);
ts.push("llvm-target", "i386-unknown-linux-gnu");
ts.push("target-pointer-width", "32");
} else {
panic!("Unsupported architecture");
}
Expand Down