Skip to content

CMake 3.18 generates invalid gcc flag -Xarch_x86_64 on Linux when CMAKE_OSX_ARCHITECTURES=x86_64

Nixpkgs pass a unified set of default CMake flags when compiling either for Linux or for Darwin, and this set includes -DCMAKE_OSX_ARCHITECTURES=x86_64. Since !4561 (merged) (released in 3.18.0) this causes CMake to add -Xarch_x86_64 to PCH options, breaking Linux builds that use target_precompile_headers: https://github.com/NixOS/nixpkgs/issues/94905

To reproduce, add set(CMAKE_OSX_ARCHITECTURES "x86_64") to Tests/RunCMake/PrecompileHeaders/PchInterface.cmake and run ctest -R PrecompileHeaders -V on Linux/gcc, it will fail with error: unrecognized command line option ‘-Xarch_x86_64’.

Edited by Orivej Desh
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information