kornelski / cargo-deb

Make Debian packages directly from Rust/Cargo projects
https://lib.rs/cargo-deb
MIT License
408 stars 48 forks source link

strip failed when cross compiling #74

Closed Ludea closed 1 year ago

Ludea commented 1 year ago

Hi,

I trying to create a .deb with my app for aarch64 from x86_64 hosts.

I install g++-aarch64-linux-gnu libc6-dev-arm64-cross, run cargo build --release --target aarch64-unknown-linux-gnu all is fine

When running cargo deb -p myapp --target aarch64-unknown-linux-gnu, I get

strip: Unable to recognise the format of the input file `/home/runner/work/myapp/myapp/target/aarch64-unknown-linux-gnu/release/myapp'
cargo-deb: unable to strip binary '/home/runner/work/myapp/myapp/target/aarch64-unknown-linux-gnu/release/myapp': strip: exit status: 1.
hint: Target-specific strip commands are configured in [target.aarch64-unknown-linux-gnu] strip = { path = "strip" } in .cargo/config

I do something wrong ?

msalau commented 1 year ago

Hi @Ludea

I have the very same issue but on a different platform. I've fixed it by adding required information to the config.

In my case (for Raspberry Pi / ARMv7). Content of ~/.cargo/config

[target.armv7-unknown-linux-gnueabihf]
strip = "/usr/bin/arm-linux-gnueabihf-strip"
objcopy = "/usr/bin/arm-linux-gnueabihf-objcopy"
linker = "/usr/bin/arm-linux-gnueabihf-gcc"
kornelski commented 1 year ago

You can't use strip command when cross compiling, because it is platform specific, like your compiler and linker are. You need a special version for the target, configured like the error says.

Ludea commented 1 year ago

[target.armv7-unknown-linux-gnueabihf] strip = "/usr/bin/arm-linux-gnueabihf-strip" objcopy = "/usr/bin/arm-linux-gnueabihf-objcopy" linker = "/usr/bin/arm-linux-gnueabihf-gcc"

Can we use env var to setup strip ? I already do this when building app and creating deb

env:
        CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc
        CC_aarch64_unknown_linux_gnu: aarch64-linux-gnu-gcc
        CXX_aarch64_unknown_linux_gnu: aarch64-linux-gnu-g++
msalau commented 1 year ago

@Ludea It seems there is no such option.

Ludea commented 1 year ago

closing, I use cargo config to specify strip and objcopy path