containers / podman

Podman: A tool for managing OCI containers and pods.
https://podman.io
Apache License 2.0
23.87k stars 2.42k forks source link

cross compile podman binding fails when GOOS=darwin GOARCH=amd64 #15733

Closed amokkara closed 2 years ago

amokkara commented 2 years ago

Is this a BUG REPORT or FEATURE REQUEST? (leave only one on its own line)

/kind bug

Description

Steps to reproduce the issue:

  1. use podman/bindings v3 or v4 in a go program github.com/containers/podman/v3 v3.2.3 and github.com/containers/podman/v4 v4.2.1 in my case

  2. cross compile with GOOS=darwin GOARCH=amd64
    ex: GOOS=darwin GOARCH=amd64 go build -o podman-poc-darwin

Describe the results you received: github.com/containers/image/v5/signature /root/go/pkg/mod/github.com/containers/image/v5@v5.17.0/signature/mechanism_gpgme.go:17:16: undefined: gpgme.Context /root/go/pkg/mod/github.com/containers/image/v5@v5.17.0/signature/mechanism_gpgme.go:67:44: undefined: gpgme.Context /root/go/pkg/mod/github.com/containers/image/v5@v5.17.0/signature/mechanism_gpgme.go:68:14: undefined: gpgme.New /root/go/pkg/mod/github.com/containers/image/v5@v5.17.0/signature/mechanism_gpgme.go:72:27: undefined: gpgme.ProtocolOpenPGP /root/go/pkg/mod/github.com/containers/image/v5@v5.17.0/signature/mechanism_gpgme.go:76:28: undefined: gpgme.ProtocolOpenPGP /root/go/pkg/mod/github.com/containers/image/v5@v5.17.0/signature/mechanism_gpgme.go:98:20: undefined: gpgme.NewDataBytes /root/go/pkg/mod/github.com/containers/image/v5@v5.17.0/signature/mechanism_gpgme.go:127:20: undefined: gpgme.NewDataBytes /root/go/pkg/mod/github.com/containers/image/v5@v5.17.0/signature/mechanism_gpgme.go:132:18: undefined: gpgme.NewDataWriter /root/go/pkg/mod/github.com/containers/image/v5@v5.17.0/signature/mechanism_gpgme.go:136:25: undefined: gpgme.Key /root/go/pkg/mod/github.com/containers/image/v5@v5.17.0/signature/mechanism_gpgme.go:136:61: undefined: gpgme.SigModeNormal /root/go/pkg/mod/github.com/containers/image/v5@v5.17.0/signature/mechanism_gpgme.go:136:61: too many errors

Describe the results you expected: Expected to compile without any errors

Additional information you deem important (e.g. issue happens only occasionally):

Output of podman version:

Version:      3.4.2
API Version:  3.4.2
Go Version:   go1.15.2
Built:        Thu Jan  1 05:30:00 1970
OS/Arch:      linux/amd64

Output of podman info:

host:
  arch: amd64
  buildahVersion: 1.23.1
  cgroupControllers:
  - cpuset
  - cpu
  - cpuacct
  - blkio
  - memory
  - devices
  - freezer
  - net_cls
  - perf_event
  - net_prio
  - hugetlb
  - pids
  - rdma
  cgroupManager: systemd
  cgroupVersion: v1
  conmon:
    package: 'conmon: /usr/libexec/podman/conmon'
    path: /usr/libexec/podman/conmon
    version: 'conmon version 2.1.2, commit: '
  cpus: 4
  distribution:
    codename: focal
    distribution: ubuntu
    version: "20.04"
  eventLogger: journald
  hostname: scspo2673281001
  idMappings:
    gidmap: null
    uidmap: null
  kernel: 5.4.0-37-generic
  linkmode: dynamic
  logDriver: journald
  memFree: 523198464
  memTotal: 8348454912
  ociRuntime:
    name: crun
    package: 'crun: /usr/bin/crun'
    path: /usr/bin/crun
    version: |-
      crun version UNKNOWN
      commit: ea1fe3938eefa14eb707f1d22adff4db670645d6
      spec: 1.0.0
      +SYSTEMD +SELINUX +APPARMOR +CAP +SECCOMP +EBPF +CRIU +YAJL
  os: linux
  remoteSocket:
    path: /run/podman/podman.sock
  security:
    apparmorEnabled: true
    capabilities: CAP_CHOWN,CAP_DAC_OVERRIDE,CAP_FOWNER,CAP_FSETID,CAP_KILL,CAP_NET_BIND_SERVICE,CAP_SETFCAP,CAP_SETGID,CAP_SETPCAP,CAP_SETUID,CAP_SYS_CHROOT
    rootless: false
    seccompEnabled: true
    seccompProfilePath: /usr/share/containers/seccomp.json
    selinuxEnabled: false
  serviceIsRemote: false
  slirp4netns:
    executable: /usr/bin/slirp4netns
    package: 'slirp4netns: /usr/bin/slirp4netns'
    version: |-
      slirp4netns version 1.1.8
      commit: unknown
      libslirp: 4.3.1-git
      SLIRP_CONFIG_VERSION_MAX: 3
      libseccomp: 2.4.3
  swapFree: 0
  swapTotal: 0
  uptime: 31h 38m 49.42s (Approximately 1.29 days)
plugins:
  log:
  - k8s-file
  - none
  - journald
  network:
  - bridge
  - macvlan
  volume:
  - local
registries:
  hub.docker.netapp.com:
    Blocked: false
    Insecure: true
    Location: hub.docker.netapp.com
    MirrorByDigestOnly: false
    Mirrors: []
    Prefix: hub.docker.netapp.com
  search:
  - hub.docker.netapp.com
store:
  configFile: /etc/containers/storage.conf
  containerStore:
    number: 0
    paused: 0
    running: 0
    stopped: 0
  graphDriverName: overlay
  graphOptions:
    overlay.mountopt: nodev,metacopy=on
  graphRoot: /var/lib/containers/storage
  graphStatus:
    Backing Filesystem: extfs
    Native Overlay Diff: "false"
    Supports d_type: "true"
    Using metacopy: "true"
  imageStore:
    number: 1
  runRoot: /run/containers/storage
  volumePath: /var/lib/containers/storage/volumes
version:
  APIVersion: 3.4.2
  Built: 0
  BuiltTime: Thu Jan  1 05:30:00 1970
  GitCommit: ""
  GoVersion: go1.15.2
  OsArch: linux/amd64
  Version: 3.4.2

Package info (e.g. output of rpm -q podman or apt list podman):

Listing... Done
podman/unknown,now 100:3.4.2-5 amd64 [installed]
podman/unknown 100:3.4.2-5 arm64
podman/unknown 100:3.4.2-5 armhf
podman/unknown 100:3.4.2-5 s390x

Have you tested with the latest version of Podman and have you checked the Podman Troubleshooting Guide? (https://github.com/containers/podman/blob/main/troubleshooting.md)

Yes

Additional environment details (AWS, VirtualBox, physical, etc.): Ubuntu 20.04, go 1.17.1

project setup:

image

go.mod file :


go 1.17

require github.com/containers/podman/v4 v4.2.1

require (
    github.com/BurntSushi/toml v1.2.0 // indirect
    github.com/Microsoft/go-winio v0.5.2 // indirect
    github.com/Microsoft/hcsshim v0.9.3 // indirect
    github.com/VividCortex/ewma v1.2.0 // indirect
    github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d // indirect
    github.com/beorn7/perks v1.0.1 // indirect
    github.com/blang/semver v3.5.1+incompatible // indirect
    github.com/blang/semver/v4 v4.0.0 // indirect
    github.com/cespare/xxhash/v2 v2.1.2 // indirect
    github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e // indirect
    github.com/cilium/ebpf v0.7.0 // indirect
    github.com/containerd/cgroups v1.0.3 // indirect
    github.com/containerd/containerd v1.6.6 // indirect
    github.com/containerd/stargz-snapshotter/estargz v0.12.0 // indirect
    github.com/containers/buildah v1.27.0 // indirect
    github.com/containers/common v0.49.1 // indirect
    github.com/containers/image/v5 v5.22.0 // indirect
    github.com/containers/libtrust v0.0.0-20200511145503-9c3a6c22cd9a // indirect
    github.com/containers/ocicrypt v1.1.5 // indirect
    github.com/containers/psgo v1.7.3 // indirect
    github.com/containers/storage v1.42.0 // indirect
    github.com/coreos/go-systemd/v22 v22.3.2 // indirect
    github.com/cyphar/filepath-securejoin v0.2.3 // indirect
    github.com/disiqueira/gotree/v3 v3.0.2 // indirect
    github.com/docker/distribution v2.8.1+incompatible // indirect
    github.com/docker/docker v20.10.17+incompatible // indirect
    github.com/docker/docker-credential-helpers v0.6.4 // indirect
    github.com/docker/go-connections v0.4.1-0.20210727194412-58542c764a11 // indirect
    github.com/docker/go-metrics v0.0.1 // indirect
    github.com/docker/go-units v0.4.0 // indirect
    github.com/fsnotify/fsnotify v1.5.4 // indirect
    github.com/ghodss/yaml v1.0.0 // indirect
    github.com/godbus/dbus/v5 v5.1.0 // indirect
    github.com/gogo/protobuf v1.3.2 // indirect
    github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
    github.com/golang/protobuf v1.5.2 // indirect
    github.com/google/go-containerregistry v0.10.0 // indirect
    github.com/google/go-intervals v0.0.2 // indirect
    github.com/google/uuid v1.3.0 // indirect
    github.com/gorilla/mux v1.8.0 // indirect
    github.com/hashicorp/errwrap v1.1.0 // indirect
    github.com/hashicorp/go-multierror v1.1.1 // indirect
    github.com/imdario/mergo v0.3.13 // indirect
    github.com/jinzhu/copier v0.3.5 // indirect
    github.com/json-iterator/go v1.1.12 // indirect
    github.com/klauspost/compress v1.15.9 // indirect
    github.com/klauspost/pgzip v1.2.5 // indirect
    github.com/letsencrypt/boulder v0.0.0-20220331220046-b23ab962616e // indirect
    github.com/manifoldco/promptui v0.9.0 // indirect
    github.com/mattn/go-runewidth v0.0.13 // indirect
    github.com/mattn/go-shellwords v1.0.12 // indirect
    github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect
    github.com/miekg/pkcs11 v1.1.1 // indirect
    github.com/mistifyio/go-zfs v2.1.2-0.20190413222219-f784269be439+incompatible // indirect
    github.com/moby/sys/mountinfo v0.6.2 // indirect
    github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
    github.com/modern-go/reflect2 v1.0.2 // indirect
    github.com/nxadm/tail v1.4.8 // indirect
    github.com/opencontainers/go-digest v1.0.0 // indirect
    github.com/opencontainers/image-spec v1.0.3-0.20220114050600-8b9d41f48198 // indirect
    github.com/opencontainers/runc v1.1.3 // indirect
    github.com/opencontainers/runtime-spec v1.0.3-0.20211214071223-8958f93039ab // indirect
    github.com/opencontainers/runtime-tools v0.9.1-0.20220714195903-17b3287fafb7 // indirect
    github.com/opencontainers/selinux v1.10.1 // indirect
    github.com/ostreedev/ostree-go v0.0.0-20210805093236-719684c64e4f // indirect
    github.com/pkg/errors v0.9.1 // indirect
    github.com/proglottis/gpgme v0.1.3 // indirect
    github.com/prometheus/client_golang v1.12.1 // indirect
    github.com/prometheus/client_model v0.2.0 // indirect
    github.com/prometheus/common v0.32.1 // indirect
    github.com/prometheus/procfs v0.7.3 // indirect
    github.com/rivo/uniseg v0.2.0 // indirect
    github.com/sigstore/sigstore v1.3.1-0.20220629021053-b95fc0d626c1 // indirect
    github.com/sirupsen/logrus v1.9.0 // indirect
    github.com/spf13/pflag v1.0.5 // indirect
    github.com/stefanberger/go-pkcs11uri v0.0.0-20201008174630-78d3cae3a980 // indirect
    github.com/sylabs/sif/v2 v2.7.1 // indirect
    github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635 // indirect
    github.com/tchap/go-patricia v2.3.0+incompatible // indirect
    github.com/theupdateframework/go-tuf v0.3.1 // indirect
    github.com/titanous/rocacheck v0.0.0-20171023193734-afe73141d399 // indirect
    github.com/ulikunitz/xz v0.5.10 // indirect
    github.com/vbatts/tar-split v0.11.2 // indirect
    github.com/vbauerster/mpb/v7 v7.4.2 // indirect
    github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect
    github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
    github.com/xeipuuv/gojsonschema v1.2.0 // indirect
    go.etcd.io/bbolt v1.3.6 // indirect
    go.mozilla.org/pkcs7 v0.0.0-20200128120323-432b2356ecb1 // indirect
    go.opencensus.io v0.23.0 // indirect
    golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4 // indirect
    golang.org/x/net v0.0.0-20220624214902-1bab6f366d9e // indirect
    golang.org/x/sync v0.0.0-20220601150217-0de741cfad7f // indirect
    golang.org/x/sys v0.0.0-20220823224334-20c2bfdbfe24 // indirect
    golang.org/x/term v0.0.0-20220526004731-065cf7ba2467 // indirect
    golang.org/x/text v0.3.7 // indirect
    google.golang.org/genproto v0.0.0-20220624142145-8cd45d7dbd1f // indirect
    google.golang.org/grpc v1.47.0 // indirect
    google.golang.org/protobuf v1.28.1 // indirect
    gopkg.in/square/go-jose.v2 v2.6.0 // indirect
    gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
    gopkg.in/yaml.v2 v2.4.0 // indirect
    gopkg.in/yaml.v3 v3.0.1 // indirect
)
Luap99 commented 2 years ago

You need to use special build tags to disable the c dependencies: https://github.com/containers/podman/blob/b9cbc0c09a68be7bb55048a494753c77c08bfbd3/Makefile#L45

amokkara commented 2 years ago

You need to use special build tags to disable the c dependencies:

https://github.com/containers/podman/blob/b9cbc0c09a68be7bb55048a494753c77c08bfbd3/Makefile#L45

Sorry, didn't quite get it. Could you give an example or detail the steps?

I'm using podman/bindings in my go project and compilation fails when I try to build go binary for Mac.

I'm just using this module in my project github.com/containers/podman/v3

Luap99 commented 2 years ago

go build -tags "remote exclude_graphdriver_btrfs btrfs_noversion exclude_graphdriver_devicemapper containers_image_openpgp" ...

rhatdan commented 2 years ago

This feels more like a discussion then an issue.