2
0
mirror of https://github.com/xcat2/xcat-dep.git synced 2026-09-12 12:36:23 +00:00

fix(goconserver): strip the cross-compiled binaries at link time

For a native build rpm's brp-strip strips the Go binaries; for a cross build
(--target-arch riscv64 on x86_64) the host strip cannot handle the foreign
ELF and the rpm shipped unstripped 19 MB binaries. Pass -s -w to the Go
linker for cross builds only, so the riscv64 rpm is stripped like the
native ones; native builds are unchanged.
This commit is contained in:
Vinícius Ferrão
2026-08-20 18:49:03 -03:00
parent e52b31e1fd
commit 08d59ced0d
+2
View File
@@ -140,6 +140,8 @@ my $go_build_dir = "$work_dir/bin";
make_path($go_build_dir);
my $ldflags = "-X main.Version=$version";
# rpm's brp-strip on the host cannot strip a foreign-arch ELF, so let the Go linker do it.
$ldflags .= ' -s -w' if $cross;
run("cd " . sh_quote($src_dir) . " && " .
"go build -trimpath -buildvcs=false -ldflags " . sh_quote($ldflags) .