From 094af6ea07ce9cf0fc85a036deaff2ca9e5cd9c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Gronowski?= Date: Wed, 10 Apr 2024 16:09:20 +0200 Subject: [PATCH] darwin/build: Disallow CGO_ENABLED=1 when cross-compiling MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cross compiling CGO to Darwin requires an Apple SDK. Signed-off-by: Paweł Gronowski --- scripts/build/.variables | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/scripts/build/.variables b/scripts/build/.variables index de7945d0a7..7cfec2409f 100755 --- a/scripts/build/.variables +++ b/scripts/build/.variables @@ -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)