From 4581c2ca5fbe3c730bece029e95d4f03d5228ab6 Mon Sep 17 00:00:00 2001 From: Joao Matos Date: Tue, 30 May 2023 16:31:09 +0100 Subject: [PATCH] Workaround parsing GNU system headers with GCC 11.0 version. Closes https://github.com/mono/CppSharp/issues/1703. Upstream bugs: https://github.com/llvm/llvm-project/issues/51607 https://github.com/llvm/llvm-project/issues/53152 --- src/Parser/ParserOptions.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Parser/ParserOptions.cs b/src/Parser/ParserOptions.cs index cde493bd0..7cda0375e 100644 --- a/src/Parser/ParserOptions.cs +++ b/src/Parser/ParserOptions.cs @@ -240,9 +240,11 @@ public void SetupLinux(string headersPath = "") GetUnixCompilerInfo(headersPath, out var compiler, out var longVersion, out var shortVersion); AddSystemIncludeDirs(BuiltinsDir); - AddArguments($"-fgnuc-version={longVersion}"); var majorVersion = shortVersion.Split('.')[0]; + // Workaround https://github.com/llvm/llvm-project/issues/53152, remove once bug is fixed. + AddArguments(int.Parse(majorVersion) >= 11 ? $"-fgnuc-version=10.1" : $"-fgnuc-version={longVersion}"); + string[] versions = { longVersion, shortVersion, majorVersion }; string[] triples = { "x86_64-linux-gnu", "x86_64-pc-linux-gnu" }; if (compiler == "gcc")