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: linking with rust-lld failed #1160

Closed
ajadavis opened this issue Oct 13, 2022 · 3 comments
Closed

error: linking with rust-lld failed #1160

ajadavis opened this issue Oct 13, 2022 · 3 comments

Comments

@ajadavis
Copy link

following along edition 2, and currently finishing "minimal-rust-kernel"

getting this error when running "cargo bootimage":

"error: linking with rust-lld failed: exit status: 1:

when i run "rustc --version" i get output:
"rustc 1.66.0-nightly (db0597f56 2022-10-11)"

so i think the nightly build setting is ok.

contents of ./.cargo/config.toml:

[unstable]
build-std-features = ["compiler-builtins-mem"]
build-std = ["core", "compiler_builtins"]

[build]
target = "x86_64-blog_os.json"

contents of "x86_64-blog_os.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've got "bootloader = "0.9.8"" as a dependency in Cargo.toml (running v 10 gave issues before, but following along the blog's version now seems ok.

im on macOS Monterey v12.5
chip is an M1 max

doing some more research into rust-lld, but couldn't find anything in first pass. next step is to learn more about rust-lld from ground up. thx in advance if anyone knows the issue!

@feoxide
Copy link

feoxide commented Oct 14, 2022

I'm seeing the same issue. Here's the full error output:

`
= note: rust-lld: error: undefined symbol: _rest_of_bootloader_start_addr
>>> referenced by bootloader.715ae32a-cgu.1
>>> ~/flint/target/bootimage/bootloader/x86_64-bootloader/release/deps/bootloader-d2c531ea42821f4b.bootloader.715ae32a-cgu.1.rcgu.o:(.boot-first-stage+0x60)
>>> referenced by bootloader.715ae32a-cgu.1
>>> ~/flint/target/bootimage/bootloader/x86_64-bootloader/release/deps/bootloader-d2c531ea42821f4b.bootloader.715ae32a-cgu.1.rcgu.o:(.boot-first-stage+0x7B)

      rust-lld: error: undefined symbol: _rest_of_bootloader_end_addr
      >>> referenced by bootloader.715ae32a-cgu.1
      >>>               ~/flint/target/bootimage/bootloader/x86_64-bootloader/release/deps/bootloader-d2c531ea42821f4b.bootloader.715ae32a-cgu.1.rcgu.o:(.boot-first-stage+0x81)
      
      rust-lld: error: undefined symbol: _kernel_buffer
      >>> referenced by bootloader.715ae32a-cgu.1
      >>>               ~/flint/target/bootimage/bootloader/x86_64-bootloader/release/deps/bootloader-d2c531ea42821f4b.bootloader.715ae32a-cgu.1.rcgu.o:(.boot+0x59)
      
      rust-lld: error: undefined symbol: _memory_map
      >>> referenced by bootloader.715ae32a-cgu.1
      >>>               ~/flint/target/bootimage/bootloader/x86_64-bootloader/release/deps/bootloader-d2c531ea42821f4b.bootloader.715ae32a-cgu.1.rcgu.o:(.boot+0xCA)
      >>> referenced by main.rs:108 (src/main.rs:108)
      >>>               ~/flint/target/bootimage/bootloader/x86_64-bootloader/release/deps/bootloader-d2c531ea42821f4b.bootloader.715ae32a-cgu.1.rcgu.o:(stage_4)
      
      rust-lld: error: undefined symbol: __page_table_start
      >>> referenced by bootloader.715ae32a-cgu.1
      >>>               ~/flint/target/bootimage/bootloader/x86_64-bootloader/release/deps/bootloader-d2c531ea42821f4b.bootloader.715ae32a-cgu.1.rcgu.o:(.boot+0x1A1)
      >>> referenced by bootloader.715ae32a-cgu.1
      >>>               ~/flint/target/bootimage/bootloader/x86_64-bootloader/release/deps/bootloader-d2c531ea42821f4b.bootloader.715ae32a-cgu.1.rcgu.o:(.boot+0x20C)
      >>> referenced by bootloader.715ae32a-cgu.1
      >>>               ~/flint/target/bootimage/bootloader/x86_64-bootloader/release/deps/bootloader-d2c531ea42821f4b.bootloader.715ae32a-cgu.1.rcgu.o:(.boot+0x219)
      >>> referenced 2 more times
      
      rust-lld: error: undefined symbol: __page_table_end
      >>> referenced by bootloader.715ae32a-cgu.1
      >>>               ~/flint/target/bootimage/bootloader/x86_64-bootloader/release/deps/bootloader-d2c531ea42821f4b.bootloader.715ae32a-cgu.1.rcgu.o:(.boot+0x1A6)
      >>> referenced by main.rs:111 (src/main.rs:111)
      >>>               ~/flint/target/bootimage/bootloader/x86_64-bootloader/release/deps/bootloader-d2c531ea42821f4b.bootloader.715ae32a-cgu.1.rcgu.o:(stage_4)
      >>> referenced by main.rs:105 (src/main.rs:105)
      >>>               ~/flint/target/bootimage/bootloader/x86_64-bootloader/release/deps/bootloader-d2c531ea42821f4b.bootloader.715ae32a-cgu.1.rcgu.o:(stage_4)
      
      rust-lld: error: undefined symbol: _p3
      >>> referenced by bootloader.715ae32a-cgu.1
      >>>               ~/flint/target/bootimage/bootloader/x86_64-bootloader/release/deps/bootloader-d2c531ea42821f4b.bootloader.715ae32a-cgu.1.rcgu.o:(.boot+0x1B4)
      >>> referenced by bootloader.715ae32a-cgu.1
      >>>               ~/flint/target/bootimage/bootloader/x86_64-bootloader/release/deps/bootloader-d2c531ea42821f4b.bootloader.715ae32a-cgu.1.rcgu.o:(.boot+0x1C9)
      
      rust-lld: error: undefined symbol: _p4
      >>> referenced by bootloader.715ae32a-cgu.1
      >>>               ~/flint/target/bootimage/bootloader/x86_64-bootloader/release/deps/bootloader-d2c531ea42821f4b.bootloader.715ae32a-cgu.1.rcgu.o:(.boot+0x1BC)
      >>> referenced by bootloader.715ae32a-cgu.1
      >>>               ~/flint/target/bootimage/bootloader/x86_64-bootloader/release/deps/bootloader-d2c531ea42821f4b.bootloader.715ae32a-cgu.1.rcgu.o:(.boot+0x24C)
      >>> referenced by main.rs:114 (src/main.rs:114)
      >>>               ~/flint/target/bootimage/bootloader/x86_64-bootloader/release/deps/bootloader-d2c531ea42821f4b.bootloader.715ae32a-cgu.1.rcgu.o:(stage_4)
      >>> referenced 1 more times
      
      rust-lld: error: undefined symbol: _p2
      >>> referenced by bootloader.715ae32a-cgu.1
      >>>               ~/flint/target/bootimage/bootloader/x86_64-bootloader/release/deps/bootloader-d2c531ea42821f4b.bootloader.715ae32a-cgu.1.rcgu.o:(.boot+0x1C1)
      >>> referenced by bootloader.715ae32a-cgu.1
      >>>               ~/flint/target/bootimage/bootloader/x86_64-bootloader/release/deps/bootloader-d2c531ea42821f4b.bootloader.715ae32a-cgu.1.rcgu.o:(.boot+0x1D6)
      >>> referenced by bootloader.715ae32a-cgu.1
      >>>               ~/flint/target/bootimage/bootloader/x86_64-bootloader/release/deps/bootloader-d2c531ea42821f4b.bootloader.715ae32a-cgu.1.rcgu.o:(.boot+0x1FB)
      
      rust-lld: error: undefined symbol: _p1
      >>> referenced by bootloader.715ae32a-cgu.1
      >>>               ~/flint/target/bootimage/bootloader/x86_64-bootloader/release/deps/bootloader-d2c531ea42821f4b.bootloader.715ae32a-cgu.1.rcgu.o:(.boot+0x1CE)
      >>> referenced by bootloader.715ae32a-cgu.1
      >>>               ~/flint/target/bootimage/bootloader/x86_64-bootloader/release/deps/bootloader-d2c531ea42821f4b.bootloader.715ae32a-cgu.1.rcgu.o:(.boot+0x231)
      >>> referenced by bootloader.715ae32a-cgu.1
      >>>               ~/flint/target/bootimage/bootloader/x86_64-bootloader/release/deps/bootloader-d2c531ea42821f4b.bootloader.715ae32a-cgu.1.rcgu.o:(.boot+0x371)
      
      rust-lld: error: undefined symbol: __bootloader_end
      >>> referenced by bootloader.715ae32a-cgu.1
      >>>               ~/flint/target/bootimage/bootloader/x86_64-bootloader/release/deps/bootloader-d2c531ea42821f4b.bootloader.715ae32a-cgu.1.rcgu.o:(.boot+0x221)
      >>> referenced by main.rs:113 (src/main.rs:113)
      >>>               ~/flint/target/bootimage/bootloader/x86_64-bootloader/release/deps/bootloader-d2c531ea42821f4b.bootloader.715ae32a-cgu.1.rcgu.o:(stage_4)
      >>> referenced by main.rs:105 (src/main.rs:105)
      >>>               ~/flint/target/bootimage/bootloader/x86_64-bootloader/release/deps/bootloader-d2c531ea42821f4b.bootloader.715ae32a-cgu.1.rcgu.o:(stage_4)
      
      rust-lld: error: undefined symbol: __bootloader_start
      >>> referenced by main.rs:112 (src/main.rs:112)
      >>>               ~/flint/target/bootimage/bootloader/x86_64-bootloader/release/deps/bootloader-d2c531ea42821f4b.bootloader.715ae32a-cgu.1.rcgu.o:(stage_4)
      >>> referenced by main.rs:105 (src/main.rs:105)
      >>>               ~/flint/target/bootimage/bootloader/x86_64-bootloader/release/deps/bootloader-d2c531ea42821f4b.bootloader.715ae32a-cgu.1.rcgu.o:(stage_4)

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

@tsatke
Copy link

tsatke commented Oct 14, 2022

rust-osdev/bootloader#271
rust-lang/rust#102836

Should already be fixed, the boot loader build is green again too, try again after upgrading to the latest nightly

@ajadavis
Copy link
Author

Incredible. Working for me after upgrading to latest nightly- many thanks!

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

No branches or pull requests

3 participants