Closed Mrs4s closed 7 months ago
Can you send us a minimal example so we can reproduce the build failure for ios? (Probably just import crypto/x509)
Can you add that code as a test case to crossbuild.txtar, to verify that iOS programs can be built on other systems?
Read CONTRIBUTING.md, to understand how our testing works.
If you get stuck anywhere, don't hesitate to ask for help.
Usually this would require a test to verify that the resulting binary can run on iOS, however this is a single line change so I think that's a little overkill.
test code:
// main.go
package main
import "C"
import (
"runtime"
)
func main() {}
//export getString
func getString() *C.char {
return C.CString("hello world from go! runtime: " + runtime.Version())
}
build script:
#!/bin/sh
export GOOS=ios
export GOARCH=arm64
export CGO_ENABLED=1
export SDK=iphonesimulator
#export SDK=iphoneos
export CGO_CFLAGS="-fembed-bitcode"
export MIN_VERSION=15
SDK_PATH=$(xcrun --sdk "$SDK" --show-sdk-path)
export SDK_PATH
if [ "$GOARCH" = "amd64" ]; then
CARCH="x86_64"
elif [ "$GOARCH" = "arm64" ]; then
CARCH="arm64"
fi
if [ "$SDK" = "iphoneos" ]; then
export TARGET="$CARCH-apple-ios$MIN_VERSION"
elif [ "$SDK" = "iphonesimulator" ]; then
export TARGET="$CARCH-apple-ios$MIN_VERSION-simulator"
fi
export CGO_LDFLAGS="-target ${TARGET} -syslibroot \"${SDK_PATH}\""
CC="$(pwd)/clangwrap.sh"
export CC
garble build -buildmode=c-archive -o TestGoiOS.a
clangwrap.sh:
#!/bin/sh
CLANG=$(xcrun --sdk "$SDK" --find clang)
exec "$CLANG" -target "$TARGET" -isysroot "$SDK_PATH" "$@"
error message:
# runtime
panic: package "crypto/x509/internal/macos" still missing after go list call
goroutine 1 [running]:
main.listPackage(0x14000178900, {0x14000c29dd2, 0x1a})
/tmp/global/pkg/mod/mvdan.cc/garble@v0.11.0/shared.go:380 +0x5ac
main.(*transformer).transformLinkname(0x14000130840, {0x14000c29dbe?, 0x3?}, {0x14000c29dd2, 0x22})
/tmp/global/pkg/mod/mvdan.cc/garble@v0.11.0/main.go:1154 +0x2d0
main.(*transformer).transformDirectives(0x16b712b4a?, {0x14000a41c00, 0x46, 0x16b712b14?})
/tmp/global/pkg/mod/mvdan.cc/garble@v0.11.0/main.go:1094 +0x124
main.(*transformer).transformCompile(0x14000130840, {0x1400013a030?, 0x1400002a094?, 0x7?})
/tmp/global/pkg/mod/mvdan.cc/garble@v0.11.0/main.go:1041 +0x944
main.mainErr({0x1400013a010, 0xa7, 0x104cda100?})
/tmp/global/pkg/mod/mvdan.cc/garble@v0.11.0/main.go:457 +0x740
main.main1()
/tmp/global/pkg/mod/mvdan.cc/garble@v0.11.0/main.go:254 +0x21c
main.main()
/tmp/global/pkg/mod/mvdan.cc/garble@v0.11.0/main.go:146 +0x1c
exit status 1
NOTE: Building for target iOS can only be done on macOS with xcode tools installed
We will properly test iOS support once #810 is done, merging this for now. Thanks @Mrs4s.
I came across a build error when trying to compile for iOS. To rectify this, I've introduced a check for GOOS=iOS. This addition resolved the issues in my use case.
I simply tested it and it was fine, but I don’t know if there are other effects.