这个警告是由于 macOS 10.15 以上版本不再支持 -pagezero_size 这个参数引起的。在编译时,可以加上 -Wno-deprecated-declarations 参数来忽略这个警告。或者可以使用 -mmacosx-version-min=10.14 参数来指定最低支持的 macOS 版本。例如:

go build -ldflags="-w -s" -tags=prod -o myapp -a -v -x -gcflags=all=-trimpath=${PWD} -asmflags=all=-trimpath=${PWD} -mmacosx-version-min=10.14

或者:

CGO_CFLAGS_ALLOW="-Wno-deprecated-declarations" go build
mac下使用cgo编译报错non-standard -pagezero_size is deprecated when targeting macOS 130 or later怎么解决

原文地址: https://www.cveoy.top/t/topic/eH88 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录