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

cross-compiling to aarch64-unknown-linux-gnu uses wrong linker #1378

Closed
andrewdavidmackenzie opened this issue Aug 28, 2024 · 15 comments
Closed

Comments

@andrewdavidmackenzie
Copy link

Hi, request for help.

In my release the build-local-artifacts step fails for two arm arch builds I have, when building ring, thus:

   Compiling ring v0.17.8
   Compiling parking v2.2.0
The following warnings were emitted during compilation:

warning: ring@0.17.8: Compiler family detection failed due to error: ToolNotFound: Failed to find tool. Is `arm-linux-gnueabihf-gcc` installed?
warning: ring@0.17.8: Compiler family detection failed due to error: ToolNotFound: Failed to find tool. Is `arm-linux-gnueabihf-gcc` installed?

Full job here: https://github.com/andrewdavidmackenzie/pigg/actions/runs/10597707922/job/29368504382

Here is my Cargo.toml
Here is my release.yml

How do I fix that?

@andrewdavidmackenzie
Copy link
Author

Maybe comments in this thread are part of my solution?
#74

"Add gcc-aarch64-linux-gnu to cargo-dist's dependencies.apt table. This installs a cross-compilation toolchain which can be invoked as aarch64-linux-gnu-gcc."

@andrewdavidmackenzie
Copy link
Author

I tried that, and things progressed but still this failure I need to look at more:

https://github.com/andrewdavidmackenzie/pigg/actions/runs/10599058041/job/29373158574

@mistydemeo
Copy link
Contributor

mistydemeo commented Aug 28, 2024

It looks like your armv7-unknown-linux-gnueabihf job is running into a bug/limitation in cargo-dist.

When we determine how to install dependencies, we look at the target triple. Since armv7-unknown-linux-gnueabihf isn't a target triple we recognize, we end up skipping package installation on that platform. We'll look at fixing this, and may have other fixes for your usecase in the future. In the meantime, our customizing build setup feature, which lets you run extra steps before your build begins, may be of use in making sure you can get the toolchain you need to target that platform.

Your aarch64-unknown-linux-gnu build looks like it's using the toolchain you installed, and is failing for reasons I'm not able to help with.

@andrewdavidmackenzie
Copy link
Author

Thanks for your detailed reply.
I'll look forward to new releases that increase the target coverage.

Is there a list of target triples you recognize, I could try and change my armv7 target to match one that works?
I see both mention here in the source

I'll also look at the customizing docs.

The aarch64 build was failing the same originally when I opened this issue, but that changed when I added:

[workspace.metadata.dist.dependencies.apt]
gcc-aarch64-linux-gnu = { version = '*', targets = ["aarch64-unknown-linux-gnu", "aarch64-unknown-linux-musl"] }

to my Cargo.toml, and now it's a "normal" build issue I'll have to investigate.

Thanks again.

@andrewdavidmackenzie
Copy link
Author

andrewdavidmackenzie commented Aug 29, 2024

I tried to customize, but suspect it's not being used.

In the armv7 job here the "Install Dependencies" step is empty.

The aarch64 job here is doing the gcc install, but I suspect it's picking that up from my meta-data in Cargo.toml

Did I get the addition of the setup right?

  • Cargo.toml addition here
  • added gcc-install.yml file here

@andrewdavidmackenzie
Copy link
Author

Tried a bunch of things today... no luck.

It's trying to link using "cc" and failing. job log

I'm stuck, and will have to remove these arm targets from my cargo-dist list of targets I fear...

@andrewdavidmackenzie
Copy link
Author

When searching for the error reported in my build log:

I see posts such as this that say my error is due to

"This is invoking the wrong linker (system linker), and most likely also invoking the wrong compiler ...."

@andrewdavidmackenzie andrewdavidmackenzie changed the title Compiler family detection failed due to error: ToolNotFound: Failed to find tool - for arm builds cross-compiling to aarch64-unknown-linux-gnu uses wrong linker Sep 2, 2024
@andrewdavidmackenzie
Copy link
Author

andrewdavidmackenzie commented Sep 2, 2024

I found this bug which mentioned the same error:

rust-lang/rust#82519

The error message here is:

 = note: /usr/bin/ld: /home/runner/work/pigg/pigg/target/aarch64-unknown-linux-gnu/dist/deps/piggui-cb0337339124d967.4g3dfa9548xp8fq1f7dediq7i.rcgu.o: Relocations in generic ELF (EM: 183)

certainly is from using "ld" and not an aarch64 linker - so seems to be the same issue.

I am going to try and force the linker for these targets by adding a .cargo/cargo.toml config file with this content:

[target.armv7-unknown-linux-gnueabihf]
linker = "arm-linux-gnueabihf-gcc"

[target.aarch64-unknown-linux-gnu]
linker = "aarch64-linux-gnu-gcc"

I already have this in Cargo.toml:
targets = ["aarch64-apple-darwin", "aarch64-unknown-linux-gnu", "armv7-unknown-linux-gnueabihf", "x86_64-apple-darwin", "x86_64-unknown-linux-gnu", "x86_64-pc-windows-msvc"]

and

[workspace.metadata.dist.dependencies.apt]
gcc-aarch64-linux-gnu = { version = '*', targets = ["aarch64-unknown-linux-gnu"] }
gcc-arm-linux-gnueabihf = { version = '*', targets = ["armv7-unknown-linux-gnueabihf"] }

And I have looked up those debian packages, and confirmed that is the name of the compiler/linker binary file in the package.

NOTE: I have modified the title of this issue to reflect this one of my two cargo-dist release build errors related to arm, I have filed an issue with ring for the other.

@andrewdavidmackenzie
Copy link
Author

No change. I'm out of ideas now.

@andrewdavidmackenzie
Copy link
Author

@mistydemeo is there anything else I can do to help troubleshoot this issue, that could help lead to solving it?

@Gankra
Copy link
Member

Gankra commented Sep 5, 2024

Apologies, Misty is on vacation this week.

Starting next week I'll be picking up

again (this time based on maturin, which some of our users are very-manually using). I think that's the only really practical way for us to support these cross-compiles.

@andrewdavidmackenzie
Copy link
Author

Was wondering if work started on #74 and if we can help in any way?

@Gankra
Copy link
Member

Gankra commented Sep 16, 2024

I'll be starting on the end of the week, but I'm not sure if there's an easy way to split up the tasks. The plan is to wrap/adapt https://github.com/PyO3/maturin

I expect the biggest bit of work will be fetching and orchestrating the docker images.

@andrewdavidmackenzie
Copy link
Author

I know that you are working on a totally new approach for cross compiling, but meanwhile I was looking at my failures again:

aarch64 build:

https://github.com/andrewdavidmackenzie/pigg/actions/runs/10901160279/job/30250372834

I can see that in the "Install dependencies" step it is using "apg-get" to install the aarch64 toolchain, presumably based on my meta.d.ist.dependencies.apt key in my Cargo.toml:

[workspace.metadata.dist.dependencies.apt]
gcc-aarch64-linux-gnu = { version = '*', targets = ["aarch64-unknown-linux-gnu"] }
gcc-arm-linux-gnueabihf = { version = '*', targets = ["armv7-unknown-linux-gnueabihf"] }
# Try this variation to see if it works
arm-linux-gnueabihf-gcc = { version = '*', targets = ["armv7-unknown-linux-gnueabihf"] }

But in the armv7 build:

https://github.com/andrewdavidmackenzie/pigg/actions/runs/10901160279/job/30250373154

I don't see it attempting to install either of my two attempts at an armv7 toolchain.

And that could be one reason that build fails with:

cargo:warning=Compiler family detection failed due to error: ToolNotFound: Failed to find tool. Is `arm-linux-gnueabihf-gcc` installed?

Do you know why it is not attempting to install the specified dependency for the "armv7-unknown-linux-gnueabihf" target?

@andrewdavidmackenzie
Copy link
Author

I have been able to get the aarch64 build via cargo-dist to work.
For the armv7 build there is a problem with non-installation of the linker dependency.
I have opened a new issue for that here #1417

So, I think we should close this one in favor of #1417

If that issue could be fixed, our cross compiling needs would be met with the current implementation.

FYI @Gankra

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