4 ms·
For plain C/C++ you can just pass `-arch x86_64 -arch arm64` to clang. CMake takes care of this for you if you specify `CMAKE_OSX_ARCHITECTURES=x86_64;arm64` an
by geraldcombs 1y ago
For plain C/C++ you can just pass `-arch x86_64 -arch arm64` to clang. CMake takes care of this for you if you specify `CMAKE_OSX_ARCHITECTURES=x86_64;arm64` and IIRC Meson has similar functionality.
- kccqzy 1y agoTIL. I didn't know clang supports this natively.
- delta_p_delta_x 1y agoClang is natively a cross-compiler. Pass in --sysroot and a corresponding valid sysroot tree for any micro architecture/platform (arm-eabi, macOS, Windows MSVC, PowerPC, Alpine Linux with musl, you name it) and Clang will happily retarget the binary to the correct target platform.
- mrpippy 1y agoApple has supported that ‘-arch’ option in their GCC/Clang since at least the PPC->Intel transition, maybe even earlier (PPC64? NeXT/OPENSTEP?)
- zdw 1y agoI assume this is faster than doing two separate builds, because it can skip certain steps of the complier pipeline, and only the items that are arch specific (codegen, probably others) are done twice?
- astrange 1y agoThey can't really share anything since the preprocessor stage can be different.
- bee_rider 1y agoHow much work does clang have to do for this sort of thing (as opposed to llvm). Hypothetically could we start distributing programs in llvm ir, and compile that locally to ARM, x86, risc-v, or whatever else? I mean, no, that’s silly, right? But it would be kind of neat…
- dundarious 1y agollvm-ir is not architecture independent, even excluding issues like the C pre-processor.