C source files not allowed when not using cgo or SWIG


(Yanping Li) #1

Hello,

I am trying to compile “runc” on “mac” by following runc instructions. Every time I tried, I got error “C source files not allowed when not using cgo or SWIG: cloned_binary.c nsexec.c”.

Google result shows two cases for such error:

  1. Go1.5 and Go1.4.2 installed to same place.
  2. Cross compiling.

Neither is close to my case. Appreciate if anyone can give any suggestions. Stuck on this issue for long time. Below is the go version, environment, and errors.

lexli-mbp$ go version
go version go1.13.3 darwin/amd64
lexli-mbp$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/lexli/Library/Caches/go-build"
GOENV="/Users/lexli/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/lexli/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/v7/5f5dfb8173z185b2jdbkwh080000gn/T/go-build755493385=/tmp/go-build -gno-record-gcc-switches -fno-common"
lexli-mbp$ pwd
/Users/lexli/go/src/github.com/opencontainers/runc

lexli-mbp$ make
go build -buildmode=pie -ldflags "-X main.gitCommit="c4d8e1688c816a8cef632a3b44a38611511b7140" -X main.version=1.0.0-rc9+dev " -tags "seccomp" -o runc .
init.go:10:2: C source files not allowed when not using cgo or SWIG: cloned_binary.c nsexec.c
make: *** [runc] Error 1

(Eric Lindblad) #2

From the Building section of the repository’s README.md file:

runc currently supports the Linux platform…

Might you have access to a Linux box?

having already installed libseccomp.so.2.4.1

running go get github.com/opencontainers/runc created an ELF LSB executable

whereas running make created an ELF LSB pie executable


(Yanping Li) #3

Eric, thank you so much for pointing this out. I tried to build it on Linux today and build succeeded.


(Eric Lindblad) #4

I don’t know your background.

Personally, having compiled a lot of source code, i.e., running autotools generated configure scripts, the words architecture, platform and target catch my eye.

Yanping Li, you’re welcome to mark this topic solved if you’re so inclined to do so.


(Yanping Li) #5

I am new to Golang world and this is my first post in this forum (didn’t know how to mark topic as solved).
I use “go get” to download and install package and their dependencies.


(Eric Lindblad) #7

how to mark topic as solved

This information unfortunately doesn’t seem to be accessible on the Go forum.

Would someone care to add an explanation and possibly a reference URL for this?