Repository: node
Issue: Cannot build arm64 arch on macOS / M1 host
Labels: build,macos,arm

### Version

16.10.0

### Platform

Darwin dev 20.6.0 Darwin Kernel Version 20.6.0: Mon Aug 30 06:12:20 PDT 2021; root:xnu-7195.141.6~3/RELEASE_ARM64_T8101 arm64

### Subsystem

_No response_

### What steps will reproduce the bug?

```
./configure --dest-cpu=arm64
make
```

### How often does it reproduce? Is there a required condition?

Always; deterministic

### What is the expected behavior?

Main binary and dependent libraries are working and output `arm64` on `lipo -info` call

### What do you see instead?

```
  g++ -o /Users/aron/iPlugDev/iPlug2/Dependencies/node/out/Release/obj.host/v8_base_without_compiler/deps/v8/src/heap/base/asm/x64/push_registers_asm.o ../deps/v8/src/heap/base/asm/x64/push_registers_asm.cc '-D_GLIBCXX_USE_CXX11_ABI=1' '-DV8_GYP_BUILD' '-DV8_TYPED_ARRAY_MAX_SIZE_IN_HEAP=64' '-D_DARWIN_USE_64_BIT_INODE=1' '-DOPENSSL_NO_PINSHARED' '-DOPENSSL_THREADS' '-DV8_TARGET_ARCH_ARM64' '-DV8_HAVE_TARGET_OS' '-DV8_TARGET_OS_MACOSX' '-DV8_EMBEDDER_STRING="-node.14"' '-DENABLE_DISASSEMBLER' '-DV8_PROMISE_INTERNAL_FIELD_COUNT=1' '-DENABLE_MINOR_MC' '-DOBJECT_PRINT' '-DV8_INTL_SUPPORT' '-DV8_ENABLE_LAZY_SOURCE_POSITIONS' '-DV8_USE_SIPHASH' '-DDISABLE_UNTRUSTED_CODE_MITIGATIONS' '-DV8_WIN64_UNWINDING_INFO' '-DV8_ENABLE_REGEXP_INTERPRETER_THREADED_DISPATCH' '-DV8_SNAPSHOT_COMPRESSION' '-DV8_ENABLE_SYSTEM_INSTRUMENTATION' '-DV8_ENABLE_WEBASSEMBLY' '-DV8_ALLOCATION_FOLDING' '-DV8_ALLOCATION_SITE_TRACKING' '-DICU_UTIL_DATA_IMPL=ICU_UTIL_DATA_STATIC' '-DV8_ADVANCED_BIGINT_ALGORITHMS' '-DUCONFIG_NO_SERVICE=1' '-DU_ENABLE_DYLOAD=0' '-DU_STATIC_IMPLEMENTATION=1' '-DU_HAVE_STD_STRING=1' '-DUCONFIG_NO_BREAK_ITERATION=0' -I../deps/v8 -I../deps/v8/include -I/Users/aron/iPlugDev/iPlug2/Dependencies/node/out/Release/obj/gen/inspector-generated-output-root -I../deps/v8/third_party/inspector_protocol -I/Users/aron/iPlugDev/iPlug2/Dependencies/node/out/Release/obj/gen -I/Users/aron/iPlugDev/iPlug2/Dependencies/node/out/Release/obj/gen/generate-bytecode-output-root -I../deps/icu-small/source/common -I../deps/icu-small/source/i18n -I../deps/icu-small/source/tools/toolutil -I../deps/v8/third_party/zlib -I../deps/v8/third_party/zlib/google  -O3 -gdwarf-2 -fstrict-aliasing -mmacosx-version-min=10.13 -Wall -Wendif-labels -W -Wno-unused-parameter -std=gnu++14 -stdlib=libc++ -fno-rtti -fno-exceptions -fno-strict-aliasing -MMD -MF /Users/aron/iPlugDev/iPlug2/Dependencies/node/out/Release/.deps//Users/aron/iPlugDev/iPlug2/Dependencies/node/out/Release/obj.host/v8_base_without_compiler/deps/v8/src/heap/base/asm/x64/push_registers_asm.o.d.raw   -c
<inline asm>:4:8: error: unknown token in expression
  push %rbp
       ^
<inline asm>:4:8: error: invalid operand
  push %rbp
       ^
<inline asm>:5:7: error: unknown token in expression
  mov %rsp, %rbp
      ^
<inline asm>:5:7: error: invalid operand
  mov %rsp, %rbp
      ^
<inline asm>:6:3: error: unrecognized instruction mnemonic, did you mean: ushl, ushr?
  push $0xCDCDCD
  ^
<inline asm>:7:8: error: unknown token in expression
  push %rbx
       ^
<inline asm>:7:8: error: invalid operand
  push %rbx
       ^
<inline asm>:8:8: error: unknown token in expression
  push %r12
       ^
<inline asm>:8:8: error: invalid operand
  push %r12
       ^
<inline asm>:9:8: error: unknown token in expression
  push %r13
       ^
<inline asm>:9:8: error: invalid operand
  push %r13
       ^
<inline asm>:10:8: error: unknown token in expression
  push %r14
       ^
<inline asm>:10:8: error: invalid operand
  push %r14
       ^
<inline asm>:11:8: error: unknown token in expression
  push %r15
       ^
<inline asm>:11:8: error: invalid operand
  push %r15
       ^
<inline asm>:12:7: error: unknown token in expression
  mov %rdx, %r8
      ^
<inline asm>:12:7: error: invalid operand
  mov %rdx, %r8
      ^
<inline asm>:13:7: error: unknown token in expression
  mov %rsp, %rdx
      ^
<inline asm>:13:7: error: invalid operand
  mov %rsp, %rdx
      ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
```

### Additional information

v8 seems to be trying to build `src/heap/base/asm/x64` instead of using inline assembly implementation  `src/heap/base/asm/arm64` which is available.

How to switch the target arch when compiling Node.js?

I'm embedding Node.js in a C++ application which needs to be as lightweight as possible. Therefore I'm trying to get a *non-universal* build containing only *arm64* binary, also for the dependent libs (`libuv`, `v8` etc).

Am I overlooking something? I thought using `--dest-cpu` was quite the go-to flag...

I'd also be happy about any comments helping me with this (hacks for the build scripts etc.)