Skip to content

cmd/cgo: cgo is incompatible with constant references from C #75751

@based-us3r

Description

@based-us3r

Go version

go1.25.1 X:nodwarf5 linux/amd64/clang/musl

Output of go env in your module/workspace:

WORK=/tmp/go-build3193581676
AR='llvm-ar'
CC='clang-20'
CGO_CFLAGS='-march=native -mtune=native -O3 -pipe -fopenmp -pthread -fno-plt -fomit-frame-pointer -fPIC -D_FORTIFY_SOURCE=2 -fopenmp-extensions -flto=thin -ffat-lto-objects'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-march=native -mtune=native -O3 -pipe -fopenmp -pthread -fno-plt -fomit-frame-pointer -fPIC -D_FORTIFY_SOURCE=2 -fopenmp-extensions -flto=thin -ffat-lto-objects'
CGO_ENABLED='1'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-Wl,-O3,--sort-common,--as-needed,-z,noexecstack,-z,pack-relative-relocs,-z,relro,-z,now,--undefined-version -flto=thin -Wl,--gc-sections -fuse-ld=lld -march=native -mtune=native -O3 -pipe -fopenmp -pthread -fno-plt -fomit-frame-pointer -fPIC -D_FORTIFY_SOURCE=2 -fopenmp-extensions -ffat-lto-objects'
CXX='clang++-20'
GCCGO='gccgo'
GO111MODULE='on'
GOAMD64='v1'
GOARCH='amd64'
GOAUTH='netrc'
GOBIN=''
GOCACHE='/var/tmp/portage/app-containers/podman-5.5.2/temp/go-build'
GOCACHEPROG=''
GODEBUG=''
GOENV='/home/root/.config/go/env'
GOEXE=''
GOEXPERIMENT='nodwarf5'
GOFIPS140='off'
GOFLAGS='-buildmode=pie -buildvcs=false -modcacherw -v -x -p=1'
GOGCCFLAGS='-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build3193581676=/tmp/go-build -gno-record-gcc-switches'
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMOD='/var/tmp/portage/app-containers/podman-5.5.2/work/podman-5.5.2/go.mod'
GOMODCACHE='/var/tmp/portage/app-containers/podman-5.5.2/work/go-mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/home/root/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/lib/go'
GOSUMDB='sum.golang.org'
GOTELEMETRY='local'
GOTELEMETRYDIR='/home/root/.config/go/telemetry'
GOTMPDIR=''
GOTOOLCHAIN='local'
GOTOOLDIR='/usr/lib/go/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.25.1 X:nodwarf5'
GOWORK=''
PKG_CONFIG='x86_64-pc-linux-musl-pkg-config'

What did you do?

Hello! Today I tried to compile Podman on my machine but encountered an error with it just exiting with error code 1. I went to check the logs to see what went wrong and saw the error “make: *** [Makefile:376: bin/podman] Error 1.” I looked at the Makefile at that location and saw the following build command:

bin/podman: $(SOURCES) go.mod go.sum
ifeq (,$(findstring systemd,$(BUILDTAGS)))
        @echo "Podman is being compiled without the systemd build tag. \
                Install libsystemd on Ubuntu or systemd-devel on rpm based \
                distro for journald support."
endif
        $(GOCMD) build \
                $(BUILDFLAGS) \
                $(GO_LDFLAGS) '$(LDFLAGS_PODMAN)' \
                -tags "$(BUILDTAGS)" \
                -o $@ ./cmd/podman
        test -z "${SELINUXOPT}" || chcon -t container_runtime_exec_t $@

And here’s the relevant build log output:

Podman is being compiled without the systemd build tag.         Install libsystemd on Ubuntu or systemd-devel on rpm based      distro for journald support.
CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build \
        -v -work -x \
        -ldflags ' -X github.com/containers/podman/v5/libpod/define.buildInfo=1759585793 -X "github.com/containers/podman/v5/libpod/define.buildOrigin=Gentoo Portage" -X github.com/containers/podman/v5/libpod/config.additionalHelperBinariesDir= ' \
        -tags "    libsubid  seccomp" \
        -o bin/podman ./cmd/podman
WORK=/var/tmp/portage/app-containers/podman-5.5.2/temp/go-build3069367709

I tried to find the line where the error occurred but ended up with the following last lines:

packagefile strings=/var/tmp/portage/app-containers/podman-5.5.2/temp/go-build3069367709/b067/_pkg_.a
packagefile syscall=/var/tmp/portage/app-containers/podman-5.5.2/temp/go-build3069367709/b041/_pkg_.a
EOF
/usr/lib/go/pkg/tool/linux_amd64/compile -o $WORK/b1096/_pkg_.a -trimpath "$WORK/b1096=>" -p [github.com/coreos/go-systemd/v22/activation](https://github.com/coreos/go-systemd/v22/activation) -lang=go1.12 -complete -installsuffix shared -buildid i7G2aJ-g04FFPqU2v5o>
go tool buildid -w $WORK/b1096/_pkg_.a # internal
cp $WORK/b1096/_pkg_.a /var/tmp/portage/app-containers/podman-5.5.2/temp/go-build/35/353ad937b8673659f8bf811d5ec89ff1b1a398a31e946ac86e21c7af4681266b-d # internal
[github.com/containers/podman/v5/pkg/terminal](https://github.com/containers/podman/v5/pkg/terminal)
mkdir -p $WORK/b1099/
echo '# import config' > $WORK/b1099/importcfg # internal
/usr/lib/go/pkg/tool/linux_amd64/compile -o $WORK/b1099/_pkg_.a -trimpath "$WORK/b1099=>" -p [github.com/containers/podman/v5/pkg/terminal](https://github.com/containers/podman/v5/pkg/terminal) -lang=go1.23 -complete -installsuffix shared -buildid MB2_APaQNMVtJEPDsO>
go tool buildid -w $WORK/b1099/_pkg_.a # internal
cp $WORK/b1099/_pkg_.a /var/tmp/portage/app-containers/podman-5.5.2/temp/go-build/dd/dd5b946f39696cbda35bb788c7a48a0dc40e35703df7f0811f856b7eefc531f2-d # internal
log/syslog
mkdir -p $WORK/b1101/
cat >/var/tmp/portage/app-containers/podman-5.5.2/temp/go-build3069367709/b1101/importcfg << 'EOF' # internal
# import config
packagefile errors=/var/tmp/portage/app-containers/podman-5.5.2/temp/go-build3069367709/b003/_pkg_.a
packagefile fmt=/var/tmp/portage/app-containers/podman-5.5.2/temp/go-build3069367709/b056/_pkg_.a
packagefile log=/var/tmp/portage/app-containers/podman-5.5.2/temp/go-build3069367709/b197/_pkg_.a
packagefile net=/var/tmp/portage/app-containers/podman-5.5.2/temp/go-build3069367709/b079/_pkg_.a
packagefile os=/var/tmp/portage/app-containers/podman-5.5.2/temp/go-build3069367709/b059/_pkg_.a
packagefile strings=/var/tmp/portage/app-containers/podman-5.5.2/temp/go-build3069367709/b067/_pkg_.a
packagefile sync=/var/tmp/portage/app-containers/podman-5.5.2/temp/go-build3069367709/b033/_pkg_.a
packagefile time=/var/tmp/portage/app-containers/podman-5.5.2/temp/go-build3069367709/b037/_pkg_.a
EOF
/usr/lib/go/pkg/tool/linux_amd64/compile -o $WORK/b1101/_pkg_.a -trimpath "$WORK/b1101=>" -p log/syslog -lang=go1.25 -std -complete -installsuffix shared -buildid VSFtIHOXZs99cn4AOggk/VSFtIHOXZs99cn4AOggk -gove>
go tool buildid -w $WORK/b1101/_pkg_.a # internal
cp $WORK/b1101/_pkg_.a /var/tmp/portage/app-containers/podman-5.5.2/temp/go-build/d7/d7a39fcd416e4aa3f0dea1c7953b424f546af6043f35c1412062b12f05cd45b1-d # internal
[github.com/sirupsen/logrus/hooks/syslog](https://github.com/sirupsen/logrus/hooks/syslog)
mkdir -p $WORK/b1100/
cat >/var/tmp/portage/app-containers/podman-5.5.2/temp/go-build3069367709/b1100/importcfg << 'EOF' # internal
# import config
packagefile fmt=/var/tmp/portage/app-containers/podman-5.5.2/temp/go-build3069367709/b056/_pkg_.a
packagefile [github.com/sirupsen/logrus=/var/tmp/portage/app-containers/podman-5.5.2/temp/go-build3069367709/b196/_pkg_.a](https://github.com/sirupsen/logrus=/var/tmp/portage/app-containers/podman-5.5.2/temp/go-build3069367709/b196/_pkg_.a)
packagefile log/syslog=/var/tmp/portage/app-containers/podman-5.5.2/temp/go-build3069367709/b1101/_pkg_.a
packagefile os=/var/tmp/portage/app-containers/podman-5.5.2/temp/go-build3069367709/b059/_pkg_.a
EOF
/usr/lib/go/pkg/tool/linux_amd64/compile -o $WORK/b1100/_pkg_.a -trimpath "$WORK/b1100=>" -p [github.com/sirupsen/logrus/hooks/syslog](https://github.com/sirupsen/logrus/hooks/syslog) -lang=go1.13 -complete -installsuffix shared -buildid oRG7fLsoYxzYpTzhXEJs/oR>
go tool buildid -w $WORK/b1100/_pkg_.a # internal
cp $WORK/b1100/_pkg_.a /var/tmp/portage/app-containers/podman-5.5.2/temp/go-build/4e/4efcc7586505932d0322d274bb3d783f5ddbc2606e734ccd34d47a68a1bb596f-d # internal
make: *** [Makefile:376: bin/podman] Error 1

After that, I limited the number of build threads to 1 and created a wrapper script around Go.

strace -f -o "$(date +%Y-%m-%d_%H-%M-%S)-$(printf "%04d" $((RANDOM % 10000)))-strace_output.txt" /usr/bin/go "$@"

After that, I obtained several strace files, with 7 having an exit code of 0 and 1 with an exit code of 1.

build.log

strace_output.tar.gz

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugReportIssues describing a possible bug in the Go implementation.NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.compiler/runtimeIssues related to the Go compiler and/or runtime.

    Type

    No type

    Projects

    Status

    Done

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions