darwin/build: Disallow CGO_ENABLED=1 when cross-compiling

Cross compiling CGO to Darwin requires an Apple SDK.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
This commit is contained in:
Paweł Gronowski 2024-04-10 16:09:20 +02:00
parent 870ad7f4b9
commit 094af6ea07
No known key found for this signature in database
GPG Key ID: B85EFCFE26DEF92A
1 changed files with 10 additions and 0 deletions

View File

@ -44,6 +44,16 @@ if [ "${GOOS}" = "windows" ]; then
fi
export TARGET
# No CGO when cross building to darwin
if [ "$(go env GOOS)" = "darwin" ] && [ "$(uname)" != "Darwin" ]; then
if [ -z "$CGO_ENABLED" ]; then
CGO_ENABLED=0
elif [ "$CGO_ENABLED" = "1" ]; then
echo "CGO_ENABLED=1 not supported when cross-compiling for Darwin"
exit 1
fi
fi
if [ -z "$CGO_ENABLED" ]; then
case "$(go env GOOS)" in
linux)