New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
iOS build error: "C source files not allowed when not using cgo or SWIG: iostat_darwin.c" #1402
Comments
Maybe this PR #1362 can help. |
That actually worked but the work around I used was to remove all C files in the directory, otherwise CGO understands it needs to use CGO instead of nonCGO. Not sure if its possible to somehow tell Go not to use CGO on a particular package and having C files at the same time... |
I am seeing the same issue when trying to compile the package with What is the plan with fixing this issue? |
I haven't tested it myself, but if the problem is that cgo is used, would setting |
The problem is that if you keep CGO enabled ,go detects C / header files in this library directory and rise this issue. What I did as a work around is just to remove the library C files and header files and compile again. I know its not elegant but works in the mean time |
Removing the C files helps to compile the library for iOS with |
I've been using the same gomobile binary to use it on m1 chip without issues, but for sure wont work for non arm64 chips. In summary didn't test it for x64 Mac, you'll need to get a better workaroud for your use cae unfortunately... let us know if you find a better workaround.. :) |
Describe the bug
I'm getting a "C source files not allowed when not using cgo or SWIG: iostat_darwin.c" error when compiling when trying to compile go-btfs which has a dependency on go-sutil. I need to use CGO so CGO=0 is not doable for me, issue is happening for arm64 and x86_64 as well.
Exact output error:
package github.com/bittorrent/go-btfs/cmd/btfs
imports github.com/bittorrent/go-btfs/chain
imports github.com/bittorrent/go-btfs/core/commands/storage/path
imports github.com/shirou/gopsutil/v3/disk: C source files not allowed when not using cgo or SWIG: iostat_darwin.c
make: *** [ios-arm64] Error 1
To Reproduce
v3.22.12
Expected behavior
Compiling completed with no issues
Environment (please complete the following information):
Windows: [paste the result of
ver
]Linux: [paste contents of
/etc/os-release
and the result ofuname -a
]Mac OS:
ProductName: macOS
ProductVersion: 13.1
BuildVersion: 22C65
Darwin Simbads-MacBook-Air.local 22.2.0 Darwin Kernel Version 22.2.0: Fri Nov 11 02:04:44 PST 2022; root:xnu-8792.61.2~4/RELEASE_ARM64_T8103 arm64
FreeBSD: [paste the result of
freebsd-version -k -r -u
anduname -a
]OpenBSD: [paste the result of
uname -a
]Additional context
[Cross-compiling? Paste the command you are using to cross-compile and the result of the corresponding
go env
]GO111MODULE=""
GOARCH="arm64"
GOBIN=""
GOCACHE="/Users/simbadmarino/Library/Caches/go-build"
GOENV="/Users/simbadmarino/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="arm64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/simbadmarino/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/simbadmarino/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_arm64"
GOVCS=""
GOVERSION="go1.19.4"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/simbadmarino/Documents/btfs-sharedLib/go.mod"
GOWORK=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/89/7_dkrhfd345107kdvp3gk4p40000gn/T/go-build1188434045=/tmp/go-build -gno-record-gcc-switches -fno-common"
MakeFile:
clangwrap.txt
Any support is greatly appreciated. Thanks
The text was updated successfully, but these errors were encountered: