global_flags.compiler.gnu.march.cmake 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. set(_GNU_MARCH_C_CXX_FLAGS "")
  2. if (CMAKE_SYSTEM_PROCESSOR MATCHES "^(i686|x86_64|AMD64)$")
  3. if (CMAKE_SYSTEM_PROCESSOR STREQUAL "i686")
  4. string(APPEND _GNU_MARCH_C_CXX_FLAGS " -m32")
  5. elseif (CMAKE_SYSTEM_PROCESSOR MATCHES "^(x86_64|AMD64)$")
  6. string(APPEND _GNU_MARCH_C_CXX_FLAGS " -m64")
  7. endif()
  8. string(APPEND _GNU_MARCH_C_CXX_FLAGS "\
  9. -msse2 \
  10. -msse3 \
  11. -mssse3 \
  12. ")
  13. if ((CMAKE_SYSTEM_PROCESSOR MATCHES "^(x86_64|AMD64)$") OR (NOT ANDROID))
  14. string(APPEND _GNU_MARCH_C_CXX_FLAGS "\
  15. -msse4.1 \
  16. -msse4.2 \
  17. -mpopcnt \
  18. ")
  19. if (NOT ANDROID)
  20. # older clang versions did not support this feature on Android:
  21. # https://reviews.llvm.org/rGc32d307a49f5255602e7543e64e6c38a7f536abc
  22. string(APPEND _GNU_MARCH_C_CXX_FLAGS " -mcx16")
  23. endif()
  24. endif()
  25. if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
  26. string(APPEND _GNU_MARCH_C_CXX_FLAGS " -D_YNDX_LIBUNWIND_ENABLE_EXCEPTION_BACKTRACE")
  27. endif()
  28. elseif (CMAKE_SYSTEM_PROCESSOR MATCHES "^(arm64|aarch64)$")
  29. if (CMAKE_SYSTEM_NAME MATCHES "^(Darwin|Linux)$")
  30. # Clang 13+ generates outline atomics by default if '-rtlib=compiler_rt' is specified or system's
  31. # libgcc version is >= 9.3.1 : https://github.com/llvm/llvm-project/commit/c5e7e649d537067dec7111f3de1430d0fc8a4d11
  32. # Disable this behaviour because our build links with contrib/libs/cxxsupp/builtins that does not contain outline atomics yet
  33. string(APPEND _GNU_MARCH_C_CXX_FLAGS " -mno-outline-atomics")
  34. endif()
  35. elseif (ANDROID AND (CMAKE_ANDROID_ARCH_ABI STREQUAL "armeabi-v7a"))
  36. string(APPEND _GNU_MARCH_C_CXX_FLAGS " -mfloat-abi=softfp")
  37. endif()