rust_dos
rust_dos copied to clipboard
Failing to compile - differs from LLVM target's default layout
❯ cargo build --release
Compiling core v0.0.0 (/home/arthur/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core)
warning: target json file contains unused fields: is-builtin
Compiling rustc-std-workspace-core v1.99.0 (/home/arthur/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/rustc-std-workspace-core)
error: data-layout for target `i586-rust_dos-1566376339033223016`, `e-m:e-p:32:32-f64:32:64-f80:32-n8:16:32-S128`, differs from LLVM target's `i586-unknown-none-code16` default layout, `e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-i128:128-f64:32:64-f80:32-n8:16:32-S128`
Compiling compiler_builtins v0.1.157
warning: `rustc-std-workspace-core` (lib) generated 1 warning (1 duplicate)
error: could not compile `rustc-std-workspace-core` (lib) due to 1 previous error; 1 warning emitted
warning: build failed, waiting for other jobs to finish...
warning: `core` (lib) generated 1 warning
error: could not compile `core` (lib) due to 1 previous error; 1 warning emitted
warning: `compiler_builtins` (lib) generated 1 warning (1 duplicate)
error: could not compile `compiler_builtins` (lib) due to 1 previous error; 1 warning emitted
❯ cargo objcopy --release -- -O binary --binary-architecture=i386:x86 rust_dos.com
Compiling core v0.0.0 (/home/arthur/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core)
Compiling rustc-std-workspace-core v1.99.0 (/home/arthur/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/rustc-std-workspace-core)
Compiling compiler_builtins v0.1.157
error: could not compile `rustc-std-workspace-core` (lib) due to 1 previous error; 1 warning emitted
warning: build failed, waiting for other jobs to finish...
error: could not compile `core` (lib) due to 1 previous error; 1 warning emitted
error: could not compile `compiler_builtins` (lib) due to 1 previous error; 1 warning emitted
error: Failed to parse crate metadata
I for sure don't know if it is the correct way of doing it, but I replaced the "data-layout" line in i586-rust_dos.json with:
"data-layout": "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-i128:128-f64:32:64-f80:32-n8:16:32-S128",
According to what was shown when I got the error message. It builds and executes in dosbox now. I've noticed that it get stuck when I use kbc_read(); Don't know if that's related. Don't know if anything more is broken because of this. Anyway I find it cool that it is possible to configure Rust to generate a working DOS COM file.
building for me with data-layout change only