Golang中debian/rules显式传递标签无效的问题如何解决

Golang中debian/rules显式传递标签无效的问题如何解决 你好,

我正在尝试为 ppc64el 架构构建 delve 包,但由于某些原因,它在测试用例执行后失败了。错误似乎是因为同一目录下存在两个文件(support_sentinel_linux.go 和 dump_linux.go)。

来自规则文件: dh_auto_build – -tags exp.linuxppc64le,exp.linuxriscv64

以下是错误日志中的一小段:

make[1]: Leaving directory '/build/reproducible-path/delve-1.24.0'
   dh_installdocs -O--buildsystem=golang
   dh_installchangelogs -O--buildsystem=golang
   dh_installman -O--buildsystem=golang
   dh_installsystemduser -O--buildsystem=golang
   dh_perl -O--buildsystem=golang
   dh_link -O--buildsystem=golang
   dh_strip_nondeterminism -O--buildsystem=golang
   dh_compress -O--buildsystem=golang
   dh_fixperms -O--buildsystem=golang
   dh_missing -O--buildsystem=golang
   dh_strip -a -O--buildsystem=golang
   dh_makeshlibs -a -O--buildsystem=golang
   dh_shlibdeps -a -O--buildsystem=golang
   dh_installdeb -O--buildsystem=golang
   dh_golang -O--buildsystem=golang
obj-powerpc64le-linux-gnu/src/github.com/go-delve/delve/service/debugger/debugger.go:31:2: found packages native (dump_linux.go) and your_linux_architecture_is_not_supported_by_delve (support_sentinel_linux.go) in /build/reproducible-path/delve-1.24.0/obj-powerpc64le-linux-gnu/src/github.com/go-delve/delve/pkg/proc/native
dh_golang: error: go list -f '{{ range .Deps }}{{.}}
{{ end }}' returned exit code 1
make: *** [debian/rules:10: binary] Error 25
dpkg-buildpackage: error: debian/rules binary subprocess returned exit status 2

有人能帮我解决这个问题吗?


更多关于Golang中debian/rules显式传递标签无效的问题如何解决的实战教程也可以访问 https://www.itying.com/category-94-b0.html

1 回复

更多关于Golang中debian/rules显式传递标签无效的问题如何解决的实战系列教程也可以访问 https://www.itying.com/category-94-b0.html


这个问题是由于 Go 编译器在同一个目录中发现了两个包声明导致的。在 /pkg/proc/native 目录下,support_sentinel_linux.go 文件包含 your_linux_architecture_is_not_supported_by_delve 包名,而 dump_linux.go 文件包含 native 包名。

错误信息显示构建系统尝试使用 exp.linuxppc64le 标签,但 support_sentinel_linux.go 文件可能没有正确的构建标签约束。以下是解决方案:

检查 support_sentinel_linux.go 文件的构建标签。该文件应该包含类似这样的构建约束:

//go:build !linux || !ppc64le
// +build !linux,!ppc64le

package your_linux_architecture_is_not_supported_by_delve

import "errors"

func init() {
    errors.New("your linux architecture is not supported by delve")
}

同时检查 dump_linux.go 文件的构建标签:

//go:build linux && ppc64le
// +build linux,ppc64le

package native

// ppc64le specific implementation

如果文件标签不正确,需要修正构建标签。对于 ppc64le 架构,support_sentinel_linux.go 应该被排除在构建之外。

另外,可以尝试在 debian/rules 文件中明确指定构建约束:

%:
    dh $@ --buildsystem=golang --with=golang

override_dh_auto_build:
    GOOS=linux GOARCH=ppc64le dh_auto_build -- -tags=exp.linuxppc64le

override_dh_auto_test:
    GOOS=linux GOARCH=ppc64le dh_auto_test -- -tags=exp.linuxppc64le

或者使用环境变量方式:

export GOOS=linux
export GOARCH=ppc64le
export CGO_ENABLED=1

%:
    dh $@ --buildsystem=golang --with=golang

override_dh_auto_build:
    dh_auto_build -- -tags=exp.linuxppc64le

如果问题仍然存在,可以尝试手动验证构建标签是否生效:

cd /build/reproducible-path/delve-1.24.0
GOOS=linux GOARCH=ppc64le go list -tags=exp.linuxppc64le ./pkg/proc/native

这应该只列出 native 包,而不包含 your_linux_architecture_is_not_supported_by_delve 包。

回到顶部