[PATCH] D46577: [compiler-rt][cmake][mips] Correct the option handling for GCC 7

Simon Dardis via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue May 8 05:02:05 PDT 2018


sdardis created this revision.
sdardis added reviewers: eugenis, beanz.
Herald added subscribers: Sanitizers, delcypher, arichardson, mgorny, dberris.

GCC 7 rejects the usage of --target=mipsel-linux-gnu, which earlier versions
accepted but warned on. Instead, detect the compiler being used and supply
--target=mipsel-linux-gnu for Clang only.

Additionally, -mips32r2 requires -mabi=32 for versions of GCC which target
mips64 by default.

This resolves PR37002.

Thanks to James Cowgill for reporting the issue!


Repository:
  rCRT Compiler Runtime

https://reviews.llvm.org/D46577

Files:
  cmake/base-config-ix.cmake


Index: cmake/base-config-ix.cmake
===================================================================
--- cmake/base-config-ix.cmake
+++ cmake/base-config-ix.cmake
@@ -176,12 +176,30 @@
       # -mips32r2/-mips64r2. We don't use -mips1/-mips3 because we want to match
       # clang's default CPU's. In the 64-bit case, we must also specify the ABI
       # since the default ABI differs between gcc and clang.
+      #
+      # We also have to tolerate differences between different versions of GCC
+      # and Clang, notably that --target=mips(el)-linux-gnu is accepted by both
+      # but required for Clang and gives a warning for GCC prior to 7. GCC 7
+      # rejects the option, causing a configuration issue leading cmake to
+      # believe GCC for mips, can't compile for mips.
+      set(CLANG_TARGET_FLAG "")
+      set(CLANG_TARGET_FLAG64 "")
+      if(CMAKE_C_COMPILER_ID MATCHES Clang)
+        set(CLANG_MIPS_TARGET_FLAG "--target=mipsel-linux-gnu")
+        set(CLANG_MIPS_TARGET_FLAG64 "--target=mips64el-linux-gnu")
+      endif()
       # FIXME: Ideally, we would build the N32 library too.
-      test_target_arch(mipsel "" "-mips32r2" "--target=mipsel-linux-gnu")
-      test_target_arch(mips64el "" "-mips64r2" "--target=mips64el-linux-gnu" "-mabi=64")
+      test_target_arch(mipsel "" "-mips32r2" "${CLANG_MIPS_TARGET_FLAG}" "-mabi=32")
+      test_target_arch(mips64el "" "-mips64r2" "${CLANG_MIPS_TARGET_FLAG64}" "-mabi=64")
     elseif("${COMPILER_RT_DEFAULT_TARGET_ARCH}" MATCHES "mips")
-      test_target_arch(mips "" "-mips32r2" "--target=mips-linux-gnu")
-      test_target_arch(mips64 "" "-mips64r2" "--target=mips64-linux-gnu" "-mabi=64")
+      set(CLANG_TARGET_FLAG "")
+      set(CLANG_TARGET_FLAG64 "")
+      if(CMAKE_C_COMPILER_ID MATCHES Clang)
+        set(CLANG_MIPS_TARGET_FLAG "--target=mips-linux-gnu")
+        set(CLANG_MIPS_TARGET_FLAG64 "--target=mips64-linux-gnu")
+      endif()
+      test_target_arch(mips "" "-mips32r2" "${CLANG_MIPS_TARGET_FLAG}" "-mabi=32")
+      test_target_arch(mips64 "" "-mips64r2" "${CLANG_MIPS_TARGET_FLAG64}" "-mabi=64")
     elseif("${COMPILER_RT_DEFAULT_TARGET_ARCH}" MATCHES "arm")
       if(WIN32)
         test_target_arch(arm "" "" "")


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D46577.145667.patch
Type: text/x-patch
Size: 2227 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180508/33e5b6e4/attachment.bin>


More information about the llvm-commits mailing list