Fix unsupported linker flag on Mac (#4473)
Summary: Run into the following linker error on Mac: ``` [ 83%] Linking CXX executable llama_main ld: warning: -s is obsolete ld: unknown options: --gc-sections clang: error: linker command failed with exit code 1 (use -v to see invocation) make[2]: *** [llama_main] Error 1 make[1]: *** [CMakeFiles/llama_main.dir/all] Error 2 make: *** [all] Error 2 ``` Env: `clang --version` ``` Apple clang version 15.0.0 (clang-1500.3.9.4) Target: arm64-apple-darwin23.6.0 Thread model: posix InstalledDir: /Library/Developer/CommandLineTools/usr/bin ``` Fix: It turns out that Apple Clang linker doesn't support the `--gc-sections` options, where it instructs the linker to remove unused sections from the final executable or shared library. Use an equivalent flags `-dead_strip` instead on Mac. Pull Request resolved: https://github.com/pytorch/executorch/pull/4473 Reviewed By: cccclai Differential Revision: D60474232 Pulled By: guangy10 fbshipit-source-id: d1f2745913a49588bdac4e8f5f792dfae4d7c9cd
G
Guang Yang committed
227b49de9eb65c19a98eaf44d2884ab27a5e9e8a
Parent: 2852bda
Committed by Facebook GitHub Bot <facebook-github-bot@users.noreply.github.com>
on 7/31/2024, 12:09:04 AM