Build flatc for the host instead of the target platform (#9077)
### Summary * Fixes https://github.com/pytorch/executorch/issues/7260 * We use flatc as part of the build step to generate some files from FlatBuffer definitions. This implies the tool runs on the host. However, we currently build flatc as part of the main build — which propagates the target CXX flags to flatc. Thus, flatc gets built targeting the target platform. To ensure flatc is built for the host, we can use include flatc as an [ExternalProject](https://cmake.org/cmake/help/latest/module/ExternalProject.html). This does not propagate the CXX flags * Some targets implicitly depended on flatc, we now make that requirement explicit * We currently spread the `FLATC_EXECUTABLE` defaulting across the project. Let's just centralize this at the root ### Test plan ```bash $ ./install_executorch.sh # Previously flatc was built against the Android target, now they target the host $ ./build/build_android_library.sh $ file /Users/jathu/executorch/cmake-out-android-arm64-v8a/third-party/flatbuffers/flatc /Users/jathu/executorch/cmake-out-android-arm64-v8a/third-party/flatbuffers/flatc: Mach-O 64-bit executable arm64 # Apple builds work as usual, but they use flatc from pip $ ./build/build_apple_frameworks.sh ``` cc @larryliu0820 @lucylq @swolchok @dbort
J
jathu committed
570e06c6088bb54e838c936afeeac21957e20175
Parent: 08f0f7a
Committed by GitHub <noreply@github.com>
on 3/13/2025, 8:29:42 PM