LLVM: thread-local storage is not supported for the current target

Working on the CppSharp port and during the parsing of one of the include files I get this error:

Generating bindings for Common (CSharp)
  Error parsing 'AnonTypes.h, AnotherUnit.h, CSharp.h, CSharpTemplates.h'
/boot/system/develop/headers/c++/mutex(823,10): error : thread-local storage is not supported for the current target [/boot/home/workspace/dotnet/CppSharp/tests/dotnet/CSharp/CSharp.Gen.csproj]

Now a bit of context, CppSharp generates the bindings for C# out of the definition available in the provided headers. It uses a custom build of LLVM (specifically from this commit.
To summarize, it uses LLVM to parse the C++ headers, build an AST and generate the C# binding out of it.
This is a vanilla LLVM (well, more properly a subset of it) without any Haiku related patches applied.

It seems that it does not support TLS and when it parses one of the headers above it fails to parse mutex here:

 /// @cond undocumented
  // If TLS is available use thread-local state for the type-erased callable
  // that is being run by std::call_once in the current thread.
  extern __thread void* __once_callable;
  extern __thread void (*__once_call)();

_GLIBCXX_HAVE_TLS is defined in c++/x86_64-unknown-haiku/bits/c++config.h and I can’t undefine it of course.

I had a look at the LLVM patchset for v17 on haikuports including the preview for v18 here.

As a side note, I don’t see the TLS patch in the v18 patchset. Is this intentional? @davidkaroly @korli

Coming back to CppSharp, I also applied this specific patch and recompiled LLVM (well, let CppSharp do it) but nothing changes, I get the very same error.

I hope I gave enough info to help me. Am I missing something on the LLVM side?
Is there a way to override the definition of _GLIBCXX_HAVE_TLS?

Some patches were upstreamed:

EDIT: you should probably apply the whole patchset.

will do.

While you’re there, what is the rationale of this patch:

From dce7ec6e649f45e09ec214da3a455e31cd36e736 Mon Sep 17 00:00:00 2001
From: Jerome Duval <jerome.duval@gmail.com>
Date: Sat, 3 Apr 2021 23:23:24 +0200
Subject: lld: MachO needs libunwind somehow, disable

diff --git a/lld/CMakeLists.txt b/lld/CMakeLists.txt
index 595c286..efb08a8 100644
--- a/lld/CMakeLists.txt
+++ b/lld/CMakeLists.txt
@@ -199,7 +199,9 @@ endif()

We have libunwind, don’t we?

Might not apply anymore indeed.