pregenerate: Compile public headers entirely as C. After I43281918d498a0c78292d12c01a6df5233938228, we essentially already are doing that - however let's also tell the compiler to slightly simplify things a bit more. The only catch is that in C mode, functions become `static inline` in C when they'd be `inline` (and thus get weak linker symbols) in C++. Simplifies compilation a bit more (on my system down from 6.40s to 6.30s user time), but the primary win is consistency. Note that in case this ever misses a symbol, audit-symbols.go being run on CQ will flag it. As a corollary, that this change passes CQ without `prefix-symbols.h` changing is evidence for its correctness. Change-Id: If23753cb482268466ee52ce3d39665b66a6a6964 Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/94127 Commit-Queue: David Benjamin <davidben@google.com> Auto-Submit: Rudolf Polzer <rpolzer@google.com> Presubmit-BoringSSL-Verified: boringssl-scoped@luci-project-accounts.iam.gserviceaccount.com <boringssl-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: David Benjamin <davidben@google.com>
diff --git a/util/pregenerate/idextractor.go b/util/pregenerate/idextractor.go index a564b27..8c6b2db 100644 --- a/util/pregenerate/idextractor.go +++ b/util/pregenerate/idextractor.go
@@ -82,27 +82,25 @@ if isCL { // If using clang-cl.exe, args need to be in CL form. args = []string{ - "/TP", - "/std:c++17", - "/Zs", - "-Xclang", "-ast-dump=json", - "/I", "include", // Suppress the C++ helper APIs, to avoid including STL headers. There are // no C symbols in there, and this reduces the volume of JSON from around // 288 MB to 44 MB. - "/DBORINGSSL_NO_CXX=1", + "/TC", + "/std:c99", + "/Zs", + "-Xclang", "-ast-dump=json", + "/I", "include", "-", } } else { // Standard Clang args. args = []string{ - "-x", "c++", - "-std=c++17", + // See above. + "-x", "c", + "-std=c99", "-fsyntax-only", "-Xclang", "-ast-dump=json", "-Iinclude", - // See above. - "-DBORINGSSL_NO_CXX=1", "-", } } @@ -150,12 +148,13 @@ } var isInline bool switch id.Linkage { - case "", "static", "static inline": + case "", "static": // Definitely not linked. return nil - case `extern "C" inline`, `extern "C++" inline`: - // Sorry, can't redefine_extname inline functions: + case `extern "C" inline`, `extern "C++" inline`, "static inline": + // Sorry, can't redefine_extname inline functions in GCC: // error: #pragma redefine_extname is applicable to external C declarations only; not applied to function + // Also, including `static inline` as it becomes `inline` when compiling as C++. isInline = true case `extern "C"`: // Link those. @@ -189,7 +188,7 @@ } } - err = idextractor.New(report, idextractor.Options{Language: "C++"}).Parse(stdout) + err = idextractor.New(report, idextractor.Options{Language: "C"}).Parse(stdout) if err != nil { c.Process.Kill() return cSymbolData{}, err