I’m working with Codeblocks IDE which is mingw64 based (but clang from the official site).
I can’t build libraries with b2 that are recognised (says “wrong format”).
You'll have to "tell" b2 to use the same linker (and output format as the one you're using with CB). The compiler just builds object-files, there's nothing to "recognise", so the error must be linked to the linker.
C:\Temp>lld lld is a generic driver. Invoke ld.lld (Unix), ld64.lld (macOS) or lld-link (Windows) instead.
You'll probably have to start with using clang++.exe, and not clang-cl.exe (although you could try clang-cl -fuse-ld=lld -flto=thin, but I guess that will still use lld-link, which will produce the same files as link.exe (the VC-one)).
You can also add the clang-cl -v (verbose) option, that might give you a better idea as to what is actually going on.
"If something cannot go on forever, it will stop" - Herbert Stein