LLVM for ARM cortex -M4

See the documentation How To Cross-Compile Clang/LLVM using Clang/LLVM — LLVM 18.0.0git documentation, Download the requirements, and proceed with the steps.

See Cross-compilation using Clang — Clang 18.0.0git documentation to know cross compilation issues.

So if you look at clang driver testing you can find the commands that you need to run.

Short answer --target & --mcpu flag is used, also substitute the command according to your system setup.

Correct me if you find something wrong, As I didn’t it try myself.