Skip to content

The error describing a failure due to CGO_ENABLED=0 is followed by additional compiler errors in 1.26 #2473

Description

@dagood

When you build a Go app using crypto without backend support due to not having cgo, it should result in an error like this:

$ CGO_ENABLED=0 msgo1.25.14-1 run .
# crypto
../../sdk/msgo1.25.14-1/src/crypto/systemcrypto_nocgo.go:10:2: `
        Using a crypto backend requires CGO_ENABLED=1.

        For more information, visit https://github.com/microsoft/go/tree/microsoft/main/eng/doc/fips
        ` (untyped string constant "\n\tUsing a crypto backend requires CGO_ENABLED=1.\n\t\n\tFor more i...) is not used

With 1.26, there are additional misleading errors after the explanatory error:

$ CGO_ENABLED=0 msgo1.26.7-1 run .
# crypto
../../sdk/msgo1.26.7-1/src/crypto/systemcrypto_nocgo_linux.go:10:2: `
        Using GOEXPERIMENT=systemcrypto on Linux requires CGO_ENABLED=1.

        Consider using our cgo-less experiment by setting GOEXPERIMENT=ms_nocgo_opensslcrypto.

        For more information, visit https://github.com/microsoft/go/blob/microsoft/main/eng/doc/MigrationGuide.md#cgo-is-not-enabled
        ` (untyped string constant "\n\tUsing GOEXPERIMENT=systemcrypto on Linux requires CGO_ENABLED=1....) is not used
# crypto/internal/backend/fips140
../../sdk/msgo1.26.7-1/src/crypto/internal/backend/fips140/fips140.go:39:12: undefined: systemFIPSMode
../../sdk/msgo1.26.7-1/src/crypto/internal/backend/fips140/fips140.go:60:6: undefined: backendEnabled

It seems that this has always been the case in the 1.26 branch:

$ CGO_ENABLED=0 msgo1.26.0-1 run .
# crypto
../../sdk/msgo1.26.0-1/src/crypto/systemcrypto_nocgo_linux.go:10:2: `
        Using GOEXPERIMENT=systemcrypto on Linux requires CGO_ENABLED=1.

        Consider using our cgo-less experiment by setting GOEXPERIMENT=ms_nocgo_opensslcrypto.

        For more information, visit https://github.com/microsoft/go/blob/microsoft/main/eng/doc/MigrationGuide.md#cgo-is-not-enabled
        ` (untyped string constant "\n\tUsing GOEXPERIMENT=systemcrypto on Linux requires CGO_ENABLED=1....) is not used
# crypto/internal/backend/fips140
../../sdk/msgo1.26.0-1/src/crypto/internal/backend/fips140/fips140.go:39:12: undefined: systemFIPSMode
../../sdk/msgo1.26.0-1/src/crypto/internal/backend/fips140/fips140.go:60:6: undefined: backendEnabled

This has caused at least one developer using the Microsoft build of Go to miss the explanation.

Metadata

Metadata

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