I've eventually made this work. My last issue was due to the target libLLVM_android being only available for host architectures (linux/darwin x86).
I made another target just for Android, and it did work, but since llvm version was too old (3.8 in particular), including those c++11 headers in art/compiler
have caused a lot of other issues. Making it another library and using that one from art/compiler would still wouldn't solve it.
Tinkering some art headers was messy, so I decided that the only solution was to use a more up-to-date llvm sources.
For this I've tried many many things, including:
1. cross compiling llvm, which worked but linking libLLVM.so against libart-compiler.so wouldn't, because Android NDK, has modified the std namespace. So I had unresolved symbols.
2. tried to compile NDK from sources to "work around" the namespace issue but I eventually gave up
3. tried to compile using the exact same flags that AOSP users for libart (except the c++11 one which LLVM requires), but stuck on issues as well.
I ended up doing what I've tried to avoid: integrated llvm9 sources into the soong build system as another external project, in a similar fashion with the outdated external/llvm.
To avoid collisions I named it external/llvmx (also for any blueprint targets as well), since the outdated llvm has dependencies with other parts of the AOSP.
I've created new blueprint targets (and referenced them in existing ones) for new code that were required for: libLLVM.so, llc, opt, and llvm-link.
The only difference from the external/llvm build process is that I didn't followed the same route for files generated by llvm's tblgen.
The tblgen dependencies have increased, and each of them required special handling (targets in .bp backed by some go lang scripts).
So I removed all the tblgen related targets from .bp files, and I'm including them as prebuilt headers from my cross-compiled version.
I can now link libLLVM.so against libart-compiler.so and actually use it. llvm9 headers do not cause any issues now.
Cheers,
Paschalis