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:
@@ -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) .
|
||||
|
||||
Reference in New Issue
Block a user