Skip to content

Build fails for darwin-amd64 with CGO_ENABLED=1 #1606

@nmiyake

Description

@nmiyake

I have a Docker image configured with C and C++ compilers specified for darwin, but compilation fails for darwin-amd64 with CGO_ENABLED=1 with the following error:

# github.com/google/certificate-transparency-go/x509
x509/root_cgo_darwin.go:44:57: error: use of undeclared identifier 'kSecTrustSettingsDomainUser'
        OSStatus err = SecTrustSettingsCopyTrustSettings(cert, kSecTrustSettingsDomainUser, &trustSettings);
                                                               ^
x509/root_cgo_darwin.go:51:49: error: use of undeclared identifier 'kSecTrustSettingsDomainAdmin'
                err = SecTrustSettingsCopyTrustSettings(cert, kSecTrustSettingsDomainAdmin, &trustSettings);
                                                              ^
x509/root_cgo_darwin.go:58:10: error: use of undeclared identifier 'kSecTrustSettingsResultUnspecified'; did you mean 'kSecTrustResultUnspecified'?
                return kSecTrustSettingsResultUnspecified;
                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                       kSecTrustResultUnspecified
/usr/osxcross/bin/../SDK/MacOSX14.4.sdk/System/Library/Frameworks/Security.framework/Headers/SecTrust.h:94:5: note: 'kSecTrustResultUnspecified' declared here
    kSecTrustResultUnspecified  CF_ENUM_AVAILABLE(10_3, 2_0) = 4,
    ^
x509/root_cgo_darwin.go:65:10: error: use of undeclared identifier 'kSecTrustSettingsResultTrustRoot'
                return kSecTrustSettingsResultTrustRoot;
                       ^
x509/root_cgo_darwin.go:101:13: error: use of undeclared identifier 'kSecTrustSettingsResultTrustRoot'; did you mean '_kSecTrustSettingsResult'?
                        result = kSecTrustSettingsResultTrustRoot;
                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                                 _kSecTrustSettingsResult
x509/root_cgo_darwin.go:71:14: note: '_kSecTrustSettingsResult' declared here
        CFStringRef _kSecTrustSettingsResult = CFStringCreateWithCString(
                    ^
x509/root_cgo_darwin.go:109:17: error: use of undeclared identifier 'kSecTrustSettingsResultTrustRoot'; did you mean '_kSecTrustSettingsResult'?
                if (result == kSecTrustSettingsResultTrustRoot) {
                              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                              _kSecTrustSettingsResult
x509/root_cgo_darwin.go:71:14: note: '_kSecTrustSettingsResult' declared here
        CFStringRef _kSecTrustSettingsResult = CFStringCreateWithCString(
                    ^
x509/root_cgo_darwin.go:111:24: error: use of undeclared identifier 'kSecTrustSettingsResultTrustAsRoot'; did you mean '_kSecTrustSettingsResult'?
                } else if (result == kSecTrustSettingsResultTrustAsRoot) {
                                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                                     _kSecTrustSettingsResult
x509/root_cgo_darwin.go:71:14: note: '_kSecTrustSettingsResult' declared here
        CFStringRef _kSecTrustSettingsResult = CFStringCreateWithCString(
                    ^
x509/root_cgo_darwin.go:113:24: error: use of undeclared identifier 'kSecTrustSettingsResultDeny'; did you mean '_kSecTrustSettingsResult'?
                } else if (result == kSecTrustSettingsResultDeny) {
                                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~
                                     _kSecTrustSettingsResult
x509/root_cgo_darwin.go:71:14: note: '_kSecTrustSettingsResult' declared here
        CFStringRef _kSecTrustSettingsResult = CFStringCreateWithCString(
                    ^
x509/root_cgo_darwin.go:126:12: error: use of undeclared identifier 'kSecTrustSettingsResultUnspecified'; did you mean 'kSecTrustResultUnspecified'?
                result = kSecTrustSettingsResultUnspecified;
                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                         kSecTrustResultUnspecified
/usr/osxcross/bin/../SDK/MacOSX14.4.sdk/System/Library/Frameworks/Security.framework/Headers/SecTrust.h:94:5: note: 'kSecTrustResultUnspecified' declared here
    kSecTrustResultUnspecified  CF_ENUM_AVAILABLE(10_3, 2_0) = 4,
    ^
x509/root_cgo_darwin.go:167:73: error: use of undeclared identifier 'kSecTrustSettingsResultInvalid'; did you mean 'kSecTrustResultInvalid'?
                fprintf(stderr, "crypto/x509: kSecTrustSettingsResultInvalid = %d\n", kSecTrustSettingsResultInvalid);
                                                                                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                                                                                      kSecTrustResultInvalid
/usr/osxcross/bin/../SDK/MacOSX14.4.sdk/System/Library/Frameworks/Security.framework/Headers/SecTrust.h:90:5: note: 'kSecTrustResultInvalid' declared here
    kSecTrustResultInvalid  CF_ENUM_AVAILABLE(10_3, 2_0) = 0,
    ^
x509/root_cgo_darwin.go:168:75: error: use of undeclared identifier 'kSecTrustSettingsResultTrustRoot'
                fprintf(stderr, "crypto/x509: kSecTrustSettingsResultTrustRoot = %d\n", kSecTrustSettingsResultTrustRoot);
                                                                                        ^
x509/root_cgo_darwin.go:169:77: error: use of undeclared identifier 'kSecTrustSettingsResultTrustAsRoot'
                fprintf(stderr, "crypto/x509: kSecTrustSettingsResultTrustAsRoot = %d\n", kSecTrustSettingsResultTrustAsRoot);
                                                                                          ^
x509/root_cgo_darwin.go:170:70: error: use of undeclared identifier 'kSecTrustSettingsResultDeny'
                fprintf(stderr, "crypto/x509: kSecTrustSettingsResultDeny = %d\n", kSecTrustSettingsResultDeny);
                                                                                   ^
x509/root_cgo_darwin.go:171:77: error: use of undeclared identifier 'kSecTrustSettingsResultUnspecified'; did you mean 'kSecTrustResultUnspecified'?
                fprintf(stderr, "crypto/x509: kSecTrustSettingsResultUnspecified = %d\n", kSecTrustSettingsResultUnspecified);
                                                                                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                                                                                          kSecTrustResultUnspecified
/usr/osxcross/bin/../SDK/MacOSX14.4.sdk/System/Library/Frameworks/Security.framework/Headers/SecTrust.h:94:5: note: 'kSecTrustResultUnspecified' declared here
    kSecTrustResultUnspecified  CF_ENUM_AVAILABLE(10_3, 2_0) = 4,
    ^
x509/root_cgo_darwin.go:177:2: error: use of undeclared identifier 'SecTrustSettingsDomain'
        SecTrustSettingsDomain domains[] = { kSecTrustSettingsDomainSystem,
        ^
x509/root_cgo_darwin.go:180:26: error: use of undeclared identifier 'domains'
        int numDomains = sizeof(domains)/sizeof(SecTrustSettingsDomain);
                                ^
x509/root_cgo_darwin.go:180:42: error: use of undeclared identifier 'SecTrustSettingsDomain'
        int numDomains = sizeof(domains)/sizeof(SecTrustSettingsDomain);
                                                ^
x509/root_cgo_darwin.go:190:51: error: use of undeclared identifier 'domains'
                OSStatus err = SecTrustSettingsCopyCertificates(domains[i], &certs);
                                                                ^
x509/root_cgo_darwin.go:191:14: error: use of undeclared identifier 'noErr'
                if (err != noErr) {
                           ^
x509/root_cgo_darwin.go:203:8: error: use of undeclared identifier 'domains'
                        if (domains[i] == kSecTrustSettingsDomainSystem) {
                            ^
x509/root_cgo_darwin.go:203:22: error: use of undeclared identifier 'kSecTrustSettingsDomainSystem'
                        if (domains[i] == kSecTrustSettingsDomainSystem) {
                                          ^
x509/root_cgo_darwin.go:208:14: error: use of undeclared identifier 'kSecTrustSettingsResultTrustRoot'
                                result = kSecTrustSettingsResultTrustRoot;
                                         ^
x509/root_cgo_darwin.go:236:18: error: use of undeclared identifier 'kSecTrustSettingsResultTrustRoot'
                        if (result == kSecTrustSettingsResultTrustRoot) {
                                      ^
x509/root_cgo_darwin.go:244:25: error: use of undeclared identifier 'kSecTrustSettingsResultTrustAsRoot'
                        } else if (result == kSecTrustSettingsResultTrustAsRoot) {
                                             ^
x509/root_cgo_darwin.go:252:25: error: use of undeclared identifier 'kSecTrustSettingsResultDeny'
                        } else if (result == kSecTrustSettingsResultDeny) {
                                             ^
x509/root_cgo_darwin.go:254:25: error: use of undeclared identifier 'kSecTrustSettingsResultUnspecified'; did you mean 'kSecTrustResultUnspecified'?
                        } else if (result == kSecTrustSettingsResultUnspecified) {
                                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                                             kSecTrustResultUnspecified
/usr/osxcross/bin/../SDK/MacOSX14.4.sdk/System/Library/Frameworks/Security.framework/Headers/SecTrust.h:94:5: note: 'kSecTrustResultUnspecified' declared here
    kSecTrustResultUnspecified  CF_ENUM_AVAILABLE(10_3, 2_0) = 4,
    ^
x509/root_cgo_darwin.go:265:30: error: use of undeclared identifier 'kSecFormatX509Cert'
                        err = SecItemExport(cert, kSecFormatX509Cert, kSecItemPemArmour, NULL, &data);
                                                  ^
x509/root_cgo_darwin.go:265:50: error: use of undeclared identifier 'kSecItemPemArmour'
                        err = SecItemExport(cert, kSecFormatX509Cert, kSecItemPemArmour, NULL, &data);
                                                                      ^
x509/root_cgo_darwin.go:266:15: error: use of undeclared identifier 'noErr'
                        if (err != noErr) {
                                   ^
29 errors generated.

The x509 package README indicates that it is a fork of https://github.com/golang/go/tree/master/src/crypto/x509, and it looks like the upstream has made significant changes in their darwin code.

Tested with version 14.4 of the darwin SDK.

All other combinations of amd64/arm64 and CGO_ENABLED=0/1 work:

OS Arch CGO_ENABLED Command Result
linux amd64 0 ~/certificate-transparency-go$ go build ./...
linux amd64 1 ~/certificate-transparency-go$ CGO_ENABLED=1 go build ./...
darwin arm64 0 ~/certificate-transparency-go$ GOOS=darwin GOARCH=arm64 go build ./...
darwin arm64 1 ~/certificate-transparency-go$ CGO_ENABLED=1 GOOS=darwin GOARCH=arm64 go build ./...
darwin amd64 0 ~/certificate-transparency-go$ GOOS=darwin GOARCH=amd64 go build ./...
darwin amd64 1 ~/certificate-transparency-go$ CGO_ENABLED=1 GOOS=darwin GOARCH=amd64 go build ./...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions