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

Rust on ppc64le: unknown relocation R_PPC64_DTPREL16_LO_DS #1192

Closed
rjzak opened this issue Feb 10, 2024 · 10 comments
Closed

Rust on ppc64le: unknown relocation R_PPC64_DTPREL16_LO_DS #1192

rjzak opened this issue Feb 10, 2024 · 10 comments

Comments

@rjzak
Copy link
Sponsor

rjzak commented Feb 10, 2024

Trying to use Mold with Rust on ppc64le results in this error: unknown relocation: R_PPC64_DTPREL16_LO_DS.

❯ cat .cargo/config 
[target.powerpc64le-unknown-linux-gnu]
linker = "/usr/bin/clang-15"
rustflags = ["-C", "link-arg=--ld-path=/usr/local/bin/mold"]

❯ mold --version
mold 2.4.0 (3d9b4d5c05250fa7c507b0c74038915929f990f1; compatible with GNU ld)

❯ rustc --version
rustc 1.76.0 (07dca489a 2024-02-04)

❯ uname -a
Linux behemoth 6.1.0-17-powerpc64le #1 SMP Debian 6.1.69-1 (2023-12-30) ppc64le GNU/Linux

❯ lsb_release -a
No LSB modules are available.
Distributor ID:	Debian
Description:	Debian GNU/Linux 12 (bookworm)
Release:	12
Codename:	bookworm

I also tried with mold -run cargo build, which gave the same error. The Mold binary installed is the precompiled ppc64le binary from the releases page.

My apologies if this isn't the appropriate place to post this.

@rui314
Copy link
Owner

rui314 commented Feb 10, 2024

Thank you for your report. We can just support that relocation. Let me try doing that next week.

@rjzak
Copy link
Sponsor Author

rjzak commented Feb 10, 2024

Awesome! I'm happy to test.

@rui314 rui314 closed this as completed in 9f07fd0 Feb 20, 2024
@rui314
Copy link
Owner

rui314 commented Feb 20, 2024

Does the above fix work for you?

@rjzak
Copy link
Sponsor Author

rjzak commented Feb 23, 2024

It does not, and I suspect it's because 9f07fd0 added support for R_PPC64_DTPREL16_LO_DS in elf/arch-ppc64v1.cc instead of elf/arch-ppc64v2.cc. My system at least uses ELF v2.

❯ file build/mold
build/mold: ELF 64-bit LSB pie executable, 64-bit PowerPC or cisco 7500, OpenPOWER ELF V2 ABI, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld64.so.2, BuildID[sha1]=0cb684a1c6d458b0e653d1542809eff16273d136, for GNU/Linux 3.10.0, not stripped

I tried applying the same thing to elf/arch-ppc64v2.cc and it was a failure:
signal: 11, SIGSEGV: invalid memory reference when compiling my Rust project with the new Mold binary. I also don't know anything about linkers or the details of PPC64 ELF versions!

@rui314
Copy link
Owner

rui314 commented Feb 23, 2024

Is your program open-source? If so, let me know the name of it. I want to try it myself.

@rjzak
Copy link
Sponsor Author

rjzak commented Feb 23, 2024

rui314 added a commit that referenced this issue Feb 23, 2024
@rui314
Copy link
Owner

rui314 commented Feb 23, 2024

With the above change, cargo test should pass on ppc64le.

@rjzak
Copy link
Sponsor Author

rjzak commented Feb 23, 2024

Agreed, it works! Thank you.

@rjzak
Copy link
Sponsor Author

rjzak commented Feb 26, 2024

I've been noticing decent speed improvements on my ppc64le workstation, so I became a sponsor :)

@rui314
Copy link
Owner

rui314 commented Feb 27, 2024

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

2 participants