The meaning of `LLVM_TARGET_ARCH` variable?

The docs say:

LLVM_TARGET_ARCH:STRING

LLVM target to use for native code generation. This is required for JIT generation. It defaults to “host”, meaning that it shall pick the architecture of the machine where LLVM is being built. If you are cross-compiling, set it to the target architecture name.

It’s not entirely clear to me what this means (more specifically what native here means) and what this should contain? I found some discussion here ⚙ D142404 [docs] Prefer setting LLVM_HOST_TRIPLE instead of LLVM_DEFAULT_TARGET_TRIPLE and LLVM_TARGET_ARCH but it didn’t clear my confusion.

For example, I am building LLVM on x86 host and targeting AArch64. The built toolchain will also run on x86.

The following make sense:

-DLLVM_TARGETS_TO_BUILD=AArch64
-DLLVM_DEFAULT_TARGET_TRIPLE=“aarch64-unknown-linux-gnu”

But should LLVM_TARGET_ARCH be AArch64 or x86 or should it just be omitted/set to host?

LLVM_TARGET_ARCH should normally be automatically computed using LLVM_HOST_TRIPLE, which is also automatically computed based based on the toolchain you’re using to build LLVM. You shouldn’t normally need to touch either of them.

If you’re building JIT, I believe it has to set to the target architecture the jitted code is running on