Configure cargo-strip to have custom strip files
Opened this issue · 16 comments
First of all: Thanks a lot!
The current solution implemented in #1 does not work for my configuration with MIPS. The issue is most likely that I used a custom binary to stripe down the binaries for mips
. The custom strip binary is build via a SDK(OpenWrt SDK) and has a custom path in my filesystem:
~openwrt/staging_dir/toolchain-mips_24kc_gcc-7.4.0_musl/bin/mips-openwrt-linux-strip ./target/mips-unknown-linux-musl/release/NetStats
Obviously, cargo stripe
isn't aware of the custom, path. Hence, cargo strip
requires some form of awareness about it.
Here is a suggestion: It is possible to configure within the ~/.cargo/config
the binaries for the linker and archiver. That looks like this:
[target.mips-unknown-linux-musl]
ar = "~/openwrt/staging_dir/toolchain-mips_24kc_gcc-7.4.0_musl/bin/mips-openwrt-linux-ar"
linker = "~/openwrt/staging_dir/toolchain-mips_24kc_gcc-7.4.0_musl/bin/mips-openwrt-linux-gcc"
Maybe we can use the same file to configure the path to the strip binary? Something like this:
[target.mips-unknown-linux-musl]
ar = "~/openwrt/staging_dir/toolchain-mips_24kc_gcc-7.4.0_musl/bin/mips-openwrt-linux-ar"
linker = "~/openwrt/staging_dir/toolchain-mips_24kc_gcc-7.4.0_musl/bin/mips-openwrt-linux-gcc"
strip = "~/openwrt/staging_dir/toolchain-mips_24kc_gcc-7.4.0_musl/bin/mips-openwrt-linux-strip"
When I remember the documentation about cargo correctly, this should be than a variable at your disposable. All what we need to do is checking for the variable and test that's a valid binary.
In case you want just to a one-time execution with a custom path, it might be handy to provide the path to the specify strip binary. Just like this:
cargo strip --target=mips-unknown-linux-musl --path ~/openwrt/staging_dir/toolchain-mips_24kc_gcc-7.4.0_musl/bin/mips-openwrt-linux-strip
This is a lot what I'm ask for, but anyway, thanks for the tool and for the work your doing!
best regards,
akendo
It might be option build.rustflags
, trying to check something running on my own.
I think rustflags are the wrong configuration entry. Important is the [target]
entry.
In my current understanding of the documentation it seems unlikely that my purposed way is working. The documentation does not imply that my idea is working. My logic here would be that target strip should be made available via: CARGO_TARGET_<triple>_STRIP
. I'm going to test for that.
Okay it does not work:
error: expected a table, but found a string for `target.mips-unknown-linux-musl.strip` in /home/akendo/.cargo/config
I guess instead we would have to provide a patch to the upstream cargo guys to include these option OR provide with a configuration file of our own. Not sure what's the best option here.
Thanks for your support. Could you share the strip
binary from the OpenWRT SDK as well as the binary that you want to strip, or an Hello World
compiled with the same toolchain?
Sure how do you like to get the file?
Please give me a hint once you're done downloading it. I like to remove it afterwards.
Thanks. I retrieved the binary. Could you also share mips-openwrt-linux-strip
?
Sure. Wasn't thinking of that: Here. I hope that this is working out-side the sdk trunk tree.
Thanks. I will investigate the binaries.
Can you upload tjhe strip
binary again? I got the following error.
curl http://blog.akendo.eu/mips-openwrt-linux-strip
<html>
<head><title>301 Moved Permanently</title></head>
<body bgcolor="white">
<center><h1>301 Moved Permanently</h1></center>
<hr><center>nginx</center>
</body>
</html>
Sure, one moment
You have to switch from http
to https
.
Thanks!