From 02725320fd14bf1d236f75c7f6ad8b6217b71a9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Matos?= Date: Tue, 30 May 2023 16:39:37 +0100 Subject: [PATCH] Workaround parsing GNU system headers with GCC 11.0 version. (#1737) 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 cde493bd..7cda0375 100644 --- a/src/Parser/ParserOptions.cs +++ b/src/Parser/ParserOptions.cs @@ -240,9 +240,11 @@ namespace CppSharp.Parser 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")