Skip to content

Unable to compile bin bootloader due to error from rust-lld #499

Closed
@9thIvy

Description

@9thIvy

I originally came to this error after trying to build blog_os as I was following it. It's worked flawlessly so far, but I got into dependency hell on my last linux install and ended up nuking it. After installing nobara 41 over 40, I've been getting an error from rust-lld when building.

I have truncated most of the cargo build and install output. Here are my steps to reproduce:

$ git clone https://github.com/phil-opp/blog_os.git && cd blog_os
$ git checkout -b post-12 origin/post-12 
$ cargo build
Compiling compiler_builtins v0.1.151
   Compiling core v0.0.0 (/home/mythril/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core)
   Compiling rustc-std-workspace-core v1.99.0 (/home/mythril/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/rustc-std-workspace-core)
   Compiling alloc v0.0.0 (/home/mythril/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc)
   Compiling blog_os v0.1.0 (/tmp/blog_os)
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 10.22s
$ cargo install bootimage
$ cargo install bootimage
    Updating crates.io index
  Installing bootimage v0.10.3
    Updating crates.io index
     Locking 22 packages to latest compatible versions
   Compiling bootimage v0.10.3
    Finished `release` profile [optimized] target(s) in 5.22s
  Installing /home/mythril/.cargo/bin/bootimage
  Installing /home/mythril/.cargo/bin/cargo-bootimage
   Installed package `bootimage v0.10.3` (executables `bootimage`, `cargo-bootimage`)
$ cargo bootimage
WARNING: `CARGO_MANIFEST_DIR` env variable not set
Building kernel
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.04s
Building bootloader
   Compiling compiler_builtins v0.1.151
   Compiling core v0.0.0 (/home/mythril/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core)
   Compiling serde v1.0.116
   Compiling bitflags v1.2.1
   Compiling x86_64 v0.14.7
   Compiling llvm-tools v0.1.1
   Compiling toml v0.5.6
   Compiling bootloader v0.9.30 (/home/mythril/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/bootloader-0.9.30)
   Compiling rustc-std-workspace-core v1.99.0 (/home/mythril/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/rustc-std-workspace-core)
   Compiling zero v0.1.2
   Compiling volatile v0.4.4
   Compiling bit_field v0.10.1
   Compiling usize_conversions v0.2.0
   Compiling rlibc v1.0.0
   Compiling fixedvec v0.2.4
   Compiling xmas-elf v0.6.2
error: linking with `rust-lld` failed: exit status: 1
  |
  = note:  "rust-lld" "-flavor" "gnu" "--script=linker.ld" "--gc-sections" "/tmp/rustcAlpUTp/symbols.o" "<4 object files omitted>" "--as-needed" "-Bstatic" "/tmp/blog_os/target/bootimage/bootloader/x86_64-bootloader/release/deps/{libxmas_elf-5d65d2bf96cae931.rlib,libzero-7687372b2590b98d.rlib,libx86_64-51db3ea7fbab3b39.rlib,libvolatile-a65ebc85f9994f32.rlib,libbitflags-d0b0465c0016cac0.rlib,libbit_field-d84f3e3f48fe7d8b.rlib,libusize_conversions-83f8cb4f56f96380.rlib,libfixedvec-c637a26df226bd98.rlib,libbootloader-64a2dbd095894c20.rlib,librlibc-9db6015d2d748be6.rlib,librustc_std_workspace_core-0f32d5b194ffc9d8.rlib,libcore-df0460c8357f8b8d.rlib,libcompiler_builtins-0049d8cc3182492c.rlib}.rlib" "-L" "/tmp/rustcAlpUTp/raw-dylibs" "-Bdynamic" "--eh-frame-hdr" "-z" "noexecstack" "-L" "/tmp/blog_os/target/bootimage/bootloader/x86_64-bootloader/release/build/bootloader-f2b2226040fafd3d/out" "-o" "/tmp/blog_os/target/bootimage/bootloader/x86_64-bootloader/release/deps/bootloader-fab7ca5ce4af8903" "--gc-sections" "-O1"
  = note: some arguments are omitted. use `--verbose` to show all linker arguments
  = note: rust-lld: error: undefined symbol: __rustc::rust_begin_unwind
          >>> referenced by panicking.rs:75 (src/panicking.rs:75)
          >>>               core-df0460c8357f8b8d.core.c6d2aabfa5929589-cgu.12.rcgu.o:(core::panicking::panic_fmt::h4b21e9bee20e07ce) in archive /tmp/blog_os/target/bootimage/bootloader/x86_64-bootloader/release/deps/libcore-df0460c8357f8b8d.rlib
          

error: could not compile `bootloader` (bin "bootloader") due to 1 previous error
Error: Bootloader build failed.
Stderr: 

Stderr is actually empty, I did not remove it.

Here are the versions of everything:

bootimage 0.10.3
cargo 1.87.0-nightly (6cf826701 2025-03-14)
rustup 1.28.1 (f9edccde0 2025-03-05)
  info: This is the version for the rustup toolchain manager, not the rustc compiler.
  info: The currently active `rustc` version is `rustc 1.87.0-nightly (75530e9f7 2025-03-18)`
info: component 'llvm-tools' for target 'x86_64-unknown-linux-gnu' is up to date

What I have tried:

  • Building any post that uses bootimage
  • cargo clean
  • updating cargo
  • crying
  • posting on phil-opp/blog_os but was directed to post here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions