https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93082
Bug ID: 93082 Summary: macOS Authorization.h needs fixinclude Product: gcc Version: 9.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: mcccs at gmx dot com Target Milestone: --- This bug has existed for at least two years. In Authorization.h: ``` static const size_t kAuthorizationExternalFormLength = 32; typedef struct { char bytes[kAuthorizationExternalFormLength]; } AuthorizationExternalForm; ``` GCC prints this error: /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/Security.framework/Headers/Authorization.h:193:7: error: variably modified 'bytes' at file scope (from gcc/c/c-decl.c Line 5792) Clang (-Wall -Wextra): *Compiles without warning* Clang (-Wall -Wextra -pedantic): warning: variable length array folded to constant array as an extension [-Wgnu-folding-constant] ---- Impact: Golang's official compiler allows linking between C and Go. When I try to build a Go package that imports "crypto/x509" (usually indirectly), part of Go standard library on macOS, and `export CC=gcc-9` is set, Go returns the following error: # crypto/x509 In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/Security.framework/Headers/AuthSession.h:32, from /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/Security.framework/Headers/Security.h:42, from /usr/local/Cellar/go/1.13.5/libexec/src/crypto/x509/root_cgo_darwin.go:17: /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/Security.framework/Headers/Authorization.h:193:7: error: variably modified 'bytes' at file scope 193 | char bytes[kAuthorizationExternalFormLength]; | ^~~~~ Other than a fixinclude, there are other ways: - Every time after an upgrade, open Authorization.h with sudo vim and replace kAuthorizationExternalFormLength with 32 - Remove `export CC=gcc-9` - Disable C-Go interlink (on by default) A fixincludes entry would be quite clean: fix = { hackname = darwin_authorization; mach = "*-*-darwin*"; files = Frameworks/Security.framework/Headers/Authorization.h; select = "char bytes[kAuthorizationExternalFormLength];\n"; c_fix = format; c_fix_arg = "char bytes[32];\n"; test_text = "char bytes[kAuthorizationExternalFormLength];\n"; }; However, I can't test it due to PR90835.