In order to build flang on a Windows on Arm machine, you will first need to setup your machine for LLVM development as described here: How to setup Windows on Arm for llvm development
You will have to add flang, clang and mlir to the list of enabled projects.
...
However, if you want to build a flang that can generate actual binaries, you need to use custom development branches such as this one. The latter is based on the community’s fir-dev branch, which is currently in the process of being upstreamed, plus a few hacks and workarounds some minor changes to get things working on Windows on Arm. You can use the steps described above to build even this version of flang, and the resulting executable should be able to compile a simple ‘hello world’ with a bit of help from clang. See the example script for more details(to link it with the builtins, pass -Xlinker /path/to/clang_rt.builtins-aarch64.lib
to flang, just as you did earlier to compile flang itself).
We are naturally working hard towards getting upstream flang to work on Windows on Arm in the cleanest way possible. Current progress is tracked in Jira.