tl;dr
I want to compile jdk in M1 MacBook.
Do not try to compile OpenJDK. Codebase is large and complicated. And no need, as others provide binaries & installers.
For a Mac using Apple Silicon rather than Intel x86-64, I suggest obtaining a distribution of Java 17 for macOS / AArch64, released 2021-09, from any of several vendors.
Or, use a build of earlier versions of Java ported to Apple Silicon by various vendors. For example, Azul Systems announced 2020-11 plans to ship builds of OpenJDK 8 and 11 for Apple Silicon, ARM-based Macs. I see downloads available now from that company for Java 11.0.13+8 on both Intel Macs and Apple Silicon Macs.
Details
Few of us ever compile the very large and complicated codebase of OpenJDK. Instead, we look to any of several vendors providing builds and installers.
Java 17 was released 2021-09. OpenJDK officially supports macOS on Apple Silicon: JEP 391: macOS/AArch64 Port. You have your choice of builds/installers from any of several vendors such as SAP, Red Hat/IBM, BellSoft, Azul Systems, Oracle, Adoptium/AdoptOpenJDK, Microsoft, Amazon, Pivotal, and more. These builds/installers will be based largely or entirely on the OpenJDK codebase.
FYI, Java 17 is the latest long-term support (LTS) version, to be supported for many years.
I myself am have been using first the early-access Java 17, and now the official Java 17 release, on my M1 MacBook Pro with IntelliJ 2021.x and Maven on Big Sur. Working well, no problems. Java 18 Early Access is now available for both Intel Macs and Apple Silicon Macs.
As commented, your specific error is likely due to you compiling for 32-bit ARM rather than 64-bit ARM used by Apple for their M1 chip.
If you insist on attempting to compile OpenJDK, I suggest examining the open-sourced tooling at Adoptium/AdoptOpenJDK. The tooling for building early-access builds at the OpenJDK site may also be open-sourced but I don’t know for certain.