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

"linking with rust-lld failed" when compiling BIOS #20

Open
HazeSystem opened this issue Jan 14, 2023 · 1 comment
Open

"linking with rust-lld failed" when compiling BIOS #20

HazeSystem opened this issue Jan 14, 2023 · 1 comment

Comments

@HazeSystem
Copy link
Contributor

I got the following error trying to build bios. I have successfully built some other examples (ferris, fs, hello_world and monkey).

error: linking with `rust-lld` failed: exit code: 1
  |
  = note: "rust-lld" "-flavor" "gnu" "C:\\Users\\renhe\\AppData\\Local\\Temp\\rustci0ZOiV\\symbols.o" "C:\\Users\\renhe\\Documents\\GitHub\\psx-sdk-rs\\examples\\target\\mipsel-sony-psx\\release\\deps\\bios-dd9b20a8139ede00.bios.59bee40b-cgu.0.rcgu.o" "C:\\Users\\renhe\\Documents\\GitHub\\psx-sdk-rs\\examples\\target\\mipsel-sony-psx\\release\\deps\\bios-dd9b20a8139ede00.5dfc63nowul9hpyw.rcgu.o" "--as-needed" "-L" "C:\\Users\\renhe\\Documents\\GitHub\\psx-sdk-rs\\examples\\target\\mipsel-sony-psx\\release\\deps" "-L" "C:\\Users\\renhe\\Documents\\GitHub\\psx-sdk-rs\\examples\\target\\release\\deps" "-L" "C:\\Users\\renhe\\Documents\\GitHub\\psx-sdk-rs\\examples\\target\\mipsel-sony-psx\\release\\build\\psx-4fa2646774207910\\out" "-L" "C:\\Users\\renhe\\.rustup\\toolchains\\nightly-x86_64-pc-windows-msvc\\lib\\rustlib\\mipsel-sony-psx\\lib" "-Bstatic" "C:\\Users\\renhe\\Documents\\GitHub\\psx-sdk-rs\\examples\\target\\mipsel-sony-psx\\release\\deps\\libbytemuck-e3e6e7a5223e4a8f.rlib" "C:\\Users\\renhe\\Documents\\GitHub\\psx-sdk-rs\\examples\\target\\mipsel-sony-psx\\release\\deps\\libpsx-cc211b81ab3b3833.rlib" "C:\\Users\\renhe\\Documents\\GitHub\\psx-sdk-rs\\examples\\target\\mipsel-sony-psx\\release\\deps\\liblinked_list_allocator-5b0b3e84bbae530b.rlib" "C:\\Users\\renhe\\Documents\\GitHub\\psx-sdk-rs\\examples\\target\\mipsel-sony-psx\\release\\deps\\liballoc-16042111529a6aac.rlib" "C:\\Users\\renhe\\Documents\\GitHub\\psx-sdk-rs\\examples\\target\\mipsel-sony-psx\\release\\deps\\librustc_std_workspace_core-9b88d97047bd756f.rlib" "C:\\Users\\renhe\\Documents\\GitHub\\psx-sdk-rs\\examples\\target\\mipsel-sony-psx\\release\\deps\\libcore-67000f1dbeeb79dc.rlib" "C:\\Users\\renhe\\Documents\\GitHub\\psx-sdk-rs\\examples\\target\\mipsel-sony-psx\\release\\deps\\libcompiler_builtins-3b687ead3f7c55ff.rlib" "-Bdynamic" "--eh-frame-hdr" "-znoexecstack" "-L" "C:\\Users\\renhe\\.rustup\\toolchains\\nightly-x86_64-pc-windows-msvc\\lib\\rustlib\\mipsel-sony-psx\\lib" "-o" "C:\\Users\\renhe\\Documents\\GitHub\\psx-sdk-rs\\examples\\target\\mipsel-sony-psx\\release\\deps\\bios-dd9b20a8139ede00.exe" "--gc-sections" "-O1" "-Tpsexe.ld" "--oformat=binary"
  = note: rust-lld: error: undefined symbol: main
          >>> referenced by psx.6664e7ff-cgu.0
          >>>               psx-cc211b81ab3b3833.psx.6664e7ff-cgu.0.rcgu.o:(__start) in archive C:\Users\renhe\Documents\GitHub\psx-sdk-rs\examples\target\mipsel-sony-psx\release\deps\libpsx-cc211b81ab3b3833.rlib


error: could not compile `bios` due to previous error
@ayrtonm
Copy link
Owner

ayrtonm commented Jan 16, 2023

Are you building the bios with cargo psx build --link bios.ld like in its README?

undefined symbol: main leads me to think that it's using the default psexe.ld instead of bios.ld since the former pulls in the __start function in psx/src/runtime.rs which calls an unmangled main function.

Also lld isn't supported for building the bios yet since it doesn't set the load address from the ld script correctly. cargo should use mipsel-linux-gnu-ld because it's set in examples/bios/.cargo/config.toml but if that's not getting picked you can set the CARGO_TARGET_MIPSEL_SONY_PSX_LINKER environment variable to mipsel-linux-gnu-ld or mipsel-unknown-elf-ld and cargo build psx --link bios.ld should just work.

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

2 participants