Skip to content

crypto/x509: exporting staticlib with ios_sdk failed with CGO_ENABLED=1 #39503

Description

@nodece

What version of Go are you using (go version)?

$ go version
go version go1.14.1 darwin/amd64

$ sw_vers
ProductName:	Mac OS X
ProductVersion:	10.15.5
BuildVersion:	19F101

What did you do?

clangwrap.sh

#!/bin/sh
# This uses the latest available iOS SDK, which is recommended.
# To select a specific SDK, run 'xcodebuild -showsdks'
# to see the available SDKs and replace iphoneos with one of them.
SDK_PATH=`xcrun --sdk $SDK --show-sdk-path`
# cmd/cgo doesn't support llvm-gcc-4.2, so we have to use clang.
CLANG=`xcrun --sdk $SDK --find clang`
exec $CLANG -arch $CLANGARCH -isysroot $SDK_PATH "$@"

build.sh

# iPhoneSimulator
export CGO_ENABLED=1
export GOARCH="amd64"
export CLANGARCH="x86_64"
export SDK=iphonesimulator13.5
export CC=$PWD/clangwrap.sh
export CXX=$PWD/clangwrap.sh
go build -buildmode=c-archive -o libtest_amd64.a main.go

build

bash ./build.sh

Log

# crypto/x509
/usr/local/Cellar/go/1.14.1/libexec/src/crypto/x509/root_cgo_darwin.go:43:57: error: use of undeclared identifier 'kSecTrustSettingsDomainUser'
        OSStatus err = SecTrustSettingsCopyTrustSettings(cert, kSecTrustSettingsDomainUser, &trustSettings);
                                                               ^
/usr/local/Cellar/go/1.14.1/libexec/src/crypto/x509/root_cgo_darwin.go:50:49: error: use of undeclared identifier 'kSecTrustSettingsDomainAdmin'
                err = SecTrustSettingsCopyTrustSettings(cert, kSecTrustSettingsDomainAdmin, &trustSettings);
                                                              ^
/usr/local/Cellar/go/1.14.1/libexec/src/crypto/x509/root_cgo_darwin.go:57:10: error: use of undeclared identifier 'kSecTrustSettingsResultUnspecified'; did you mean 'kSecTrustResultUnspecified'?
                return kSecTrustSettingsResultUnspecified;
                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                       kSecTrustResultUnspecified
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.5.sdk/System/Library/Frameworks/Security.framework/Headers/SecTrust.h:89:5: note: 'kSecTrustResultUnspecified' declared here
    kSecTrustResultUnspecified  CF_ENUM_AVAILABLE(10_3, 2_0) = 4,
    ^
/usr/local/Cellar/go/1.14.1/libexec/src/crypto/x509/root_cgo_darwin.go:64:10: error: use of undeclared identifier 'kSecTrustSettingsResultTrustRoot'
                return kSecTrustSettingsResultTrustRoot;
                       ^
/usr/local/Cellar/go/1.14.1/libexec/src/crypto/x509/root_cgo_darwin.go:100:13: error: use of undeclared identifier 'kSecTrustSettingsResultTrustRoot'; did you mean '_kSecTrustSettingsResult'?
                        result = kSecTrustSettingsResultTrustRoot;
                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                                 _kSecTrustSettingsResult
/usr/local/Cellar/go/1.14.1/libexec/src/crypto/x509/root_cgo_darwin.go:70:14: note: '_kSecTrustSettingsResult' declared here
        CFStringRef _kSecTrustSettingsResult = CFStringCreateWithCString(
                    ^
/usr/local/Cellar/go/1.14.1/libexec/src/crypto/x509/root_cgo_darwin.go:108:17: error: use of undeclared identifier 'kSecTrustSettingsResultTrustRoot'; did you mean '_kSecTrustSettingsResult'?
                if (result == kSecTrustSettingsResultTrustRoot) {
                              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                              _kSecTrustSettingsResult
/usr/local/Cellar/go/1.14.1/libexec/src/crypto/x509/root_cgo_darwin.go:70:14: note: '_kSecTrustSettingsResult' declared here
        CFStringRef _kSecTrustSettingsResult = CFStringCreateWithCString(
                    ^
/usr/local/Cellar/go/1.14.1/libexec/src/crypto/x509/root_cgo_darwin.go:110:24: error: use of undeclared identifier 'kSecTrustSettingsResultTrustAsRoot'; did you mean '_kSecTrustSettingsResult'?
                } else if (result == kSecTrustSettingsResultTrustAsRoot) {
                                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                                     _kSecTrustSettingsResult
/usr/local/Cellar/go/1.14.1/libexec/src/crypto/x509/root_cgo_darwin.go:70:14: note: '_kSecTrustSettingsResult' declared here
        CFStringRef _kSecTrustSettingsResult = CFStringCreateWithCString(
                    ^
/usr/local/Cellar/go/1.14.1/libexec/src/crypto/x509/root_cgo_darwin.go:112:24: error: use of undeclared identifier 'kSecTrustSettingsResultDeny'; did you mean '_kSecTrustSettingsResult'?
                } else if (result == kSecTrustSettingsResultDeny) {
                                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~
                                     _kSecTrustSettingsResult
/usr/local/Cellar/go/1.14.1/libexec/src/crypto/x509/root_cgo_darwin.go:70:14: note: '_kSecTrustSettingsResult' declared here
        CFStringRef _kSecTrustSettingsResult = CFStringCreateWithCString(
                    ^
/usr/local/Cellar/go/1.14.1/libexec/src/crypto/x509/root_cgo_darwin.go:125:12: error: use of undeclared identifier 'kSecTrustSettingsResultUnspecified'; did you mean 'kSecTrustResultUnspecified'?
                result = kSecTrustSettingsResultUnspecified;
                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                         kSecTrustResultUnspecified
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.5.sdk/System/Library/Frameworks/Security.framework/Headers/SecTrust.h:89:5: note: 'kSecTrustResultUnspecified' declared here
    kSecTrustResultUnspecified  CF_ENUM_AVAILABLE(10_3, 2_0) = 4,
    ^
/usr/local/Cellar/go/1.14.1/libexec/src/crypto/x509/root_cgo_darwin.go:166:73: error: use of undeclared identifier 'kSecTrustSettingsResultInvalid'; did you mean 'kSecTrustResultInvalid'?
                fprintf(stderr, "crypto/x509: kSecTrustSettingsResultInvalid = %d\n", kSecTrustSettingsResultInvalid);
                                                                                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                                                                                      kSecTrustResultInvalid
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.5.sdk/System/Library/Frameworks/Security.framework/Headers/SecTrust.h:85:5: note: 'kSecTrustResultInvalid' declared here
    kSecTrustResultInvalid  CF_ENUM_AVAILABLE(10_3, 2_0) = 0,
    ^
/usr/local/Cellar/go/1.14.1/libexec/src/crypto/x509/root_cgo_darwin.go:167:75: error: use of undeclared identifier 'kSecTrustSettingsResultTrustRoot'
                fprintf(stderr, "crypto/x509: kSecTrustSettingsResultTrustRoot = %d\n", kSecTrustSettingsResultTrustRoot);
                                                                                        ^
/usr/local/Cellar/go/1.14.1/libexec/src/crypto/x509/root_cgo_darwin.go:168:77: error: use of undeclared identifier 'kSecTrustSettingsResultTrustAsRoot'
                fprintf(stderr, "crypto/x509: kSecTrustSettingsResultTrustAsRoot = %d\n", kSecTrustSettingsResultTrustAsRoot);
                                                                                          ^
/usr/local/Cellar/go/1.14.1/libexec/src/crypto/x509/root_cgo_darwin.go:169:70: error: use of undeclared identifier 'kSecTrustSettingsResultDeny'
                fprintf(stderr, "crypto/x509: kSecTrustSettingsResultDeny = %d\n", kSecTrustSettingsResultDeny);
                                                                                   ^
/usr/local/Cellar/go/1.14.1/libexec/src/crypto/x509/root_cgo_darwin.go:170:77: error: use of undeclared identifier 'kSecTrustSettingsResultUnspecified'; did you mean 'kSecTrustResultUnspecified'?
                fprintf(stderr, "crypto/x509: kSecTrustSettingsResultUnspecified = %d\n", kSecTrustSettingsResultUnspecified);
                                                                                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                                                                                          kSecTrustResultUnspecified
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.5.sdk/System/Library/Frameworks/Security.framework/Headers/SecTrust.h:89:5: note: 'kSecTrustResultUnspecified' declared here
    kSecTrustResultUnspecified  CF_ENUM_AVAILABLE(10_3, 2_0) = 4,
    ^
/usr/local/Cellar/go/1.14.1/libexec/src/crypto/x509/root_cgo_darwin.go:176:2: error: use of undeclared identifier 'SecTrustSettingsDomain'
        SecTrustSettingsDomain domains[] = { kSecTrustSettingsDomainSystem,
        ^
/usr/local/Cellar/go/1.14.1/libexec/src/crypto/x509/root_cgo_darwin.go:179:26: error: use of undeclared identifier 'domains'
        int numDomains = sizeof(domains)/sizeof(SecTrustSettingsDomain);
                                ^
/usr/local/Cellar/go/1.14.1/libexec/src/crypto/x509/root_cgo_darwin.go:179:42: error: use of undeclared identifier 'SecTrustSettingsDomain'
        int numDomains = sizeof(domains)/sizeof(SecTrustSettingsDomain);
                                                ^
/usr/local/Cellar/go/1.14.1/libexec/src/crypto/x509/root_cgo_darwin.go:189:51: error: use of undeclared identifier 'domains'
                OSStatus err = SecTrustSettingsCopyCertificates(domains[i], &certs);
                                                                ^
/usr/local/Cellar/go/1.14.1/libexec/src/crypto/x509/root_cgo_darwin.go:202:8: error: use of undeclared identifier 'domains'
                        if (domains[i] == kSecTrustSettingsDomainSystem) {
                            ^
/usr/local/Cellar/go/1.14.1/libexec/src/crypto/x509/root_cgo_darwin.go:202:22: error: use of undeclared identifier 'kSecTrustSettingsDomainSystem'
                        if (domains[i] == kSecTrustSettingsDomainSystem) {
                                          ^
/usr/local/Cellar/go/1.14.1/libexec/src/crypto/x509/root_cgo_darwin.go:207:14: error: use of undeclared identifier 'kSecTrustSettingsResultTrustRoot'
                                result = kSecTrustSettingsResultTrustRoot;
                                         ^
/usr/local/Cellar/go/1.14.1/libexec/src/crypto/x509/root_cgo_darwin.go:235:18: error: use of undeclared identifier 'kSecTrustSettingsResultTrustRoot'
                        if (result == kSecTrustSettingsResultTrustRoot) {
                                      ^
/usr/local/Cellar/go/1.14.1/libexec/src/crypto/x509/root_cgo_darwin.go:243:25: error: use of undeclared identifier 'kSecTrustSettingsResultTrustAsRoot'
                        } else if (result == kSecTrustSettingsResultTrustAsRoot) {
                                             ^
/usr/local/Cellar/go/1.14.1/libexec/src/crypto/x509/root_cgo_darwin.go:251:25: error: use of undeclared identifier 'kSecTrustSettingsResultDeny'
                        } else if (result == kSecTrustSettingsResultDeny) {
                                             ^
/usr/local/Cellar/go/1.14.1/libexec/src/crypto/x509/root_cgo_darwin.go:253:25: error: use of undeclared identifier 'kSecTrustSettingsResultUnspecified'; did you mean 'kSecTrustResultUnspecified'?
                        } else if (result == kSecTrustSettingsResultUnspecified) {
                                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                                             kSecTrustResultUnspecified
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.5.sdk/System/Library/Frameworks/Security.framework/Headers/SecTrust.h:89:5: note: 'kSecTrustResultUnspecified' declared here
    kSecTrustResultUnspecified  CF_ENUM_AVAILABLE(10_3, 2_0) = 4,
    ^
/usr/local/Cellar/go/1.14.1/libexec/src/crypto/x509/root_cgo_darwin.go:264:30: error: use of undeclared identifier 'kSecFormatX509Cert'
                        err = SecItemExport(cert, kSecFormatX509Cert, kSecItemPemArmour, NULL, &data);
                                                  ^
/usr/local/Cellar/go/1.14.1/libexec/src/crypto/x509/root_cgo_darwin.go:264:50: error: use of undeclared identifier 'kSecItemPemArmour'
                        err = SecItemExport(cert, kSecFormatX509Cert, kSecItemPemArmour, NULL, &data);
                                                                      ^
27 errors generated.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.mobileAndroid, iOS, and x/mobile

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions