[compiler-rt] e429f24 - [CMake] Enable -qfuncsect when building with IBM XL

Hubert Tong via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 15 07:45:56 PST 2020


Author: Hubert Tong
Date: 2020-01-15T10:45:50-05:00
New Revision: e429f24ed8b16149ad668edd3fb000a3a56c8e40

URL: https://github.com/llvm/llvm-project/commit/e429f24ed8b16149ad668edd3fb000a3a56c8e40
DIFF: https://github.com/llvm/llvm-project/commit/e429f24ed8b16149ad668edd3fb000a3a56c8e40.diff

LOG: [CMake] Enable -qfuncsect when building with IBM XL

Summary:
The IBM XL compiler uses `-qfuncsect` for `-ffunction-sections`.

The comment about sanitizers and `-f[no-]function-sections` is corrected
also, as it is pertinent to this patch.

The sanitizer-related use of `-fno-function-sections` is associated with
powerpc64le, a target for which there is an IBM XL compiler, so that use
is updated in this patch to apply `-qnofuncsect` in case a build using
the XL compiler is viable on that platform.

This patch has been verified with the XL compiler on AIX only.

Reviewers: daltenty, stevewan

Reviewed By: daltenty

Subscribers: mgorny, steven.zhang, #sanitizers, llvm-commits

Tags: #sanitizers, #llvm

Differential Revision: https://reviews.llvm.org/D72335

Added: 
    

Modified: 
    compiler-rt/CMakeLists.txt
    llvm/cmake/modules/HandleLLVMOptions.cmake

Removed: 
    


################################################################################
diff  --git a/compiler-rt/CMakeLists.txt b/compiler-rt/CMakeLists.txt
index 8d768a404f21..db64d031c9a3 100644
--- a/compiler-rt/CMakeLists.txt
+++ b/compiler-rt/CMakeLists.txt
@@ -286,7 +286,11 @@ append_list_if(COMPILER_RT_HAS_FNO_LTO_FLAG -fno-lto SANITIZER_COMMON_CFLAGS)
 # Linux test function-sections-are-bad.cpp fails with the following error:
 # 'undefined symbol: __sanitizer_unaligned_load32'.
 if(DEFINED TARGET_powerpc64le_CFLAGS)
-  append_list_if(COMPILER_RT_HAS_FNO_FUNCTION_SECTIONS_FLAG -fno-function-sections TARGET_powerpc64le_CFLAGS)
+  if(CMAKE_CXX_COMPILER_ID MATCHES "XL")
+    append("-qnofuncsect" TARGET_powerpc64le_CFLAGS)
+  else()
+    append_list_if(COMPILER_RT_HAS_FNO_FUNCTION_SECTIONS_FLAG -fno-function-sections TARGET_powerpc64le_CFLAGS)
+  endif()
 endif()
 
 # The following is a workaround for s390x.  This avoids creation of "partial

diff  --git a/llvm/cmake/modules/HandleLLVMOptions.cmake b/llvm/cmake/modules/HandleLLVMOptions.cmake
index ab219e52f9d9..d519a7e8e9f0 100644
--- a/llvm/cmake/modules/HandleLLVMOptions.cmake
+++ b/llvm/cmake/modules/HandleLLVMOptions.cmake
@@ -782,9 +782,11 @@ if(NOT CYGWIN AND NOT WIN32)
      NOT uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG")
     check_c_compiler_flag("-Werror -fno-function-sections" C_SUPPORTS_FNO_FUNCTION_SECTIONS)
     if (C_SUPPORTS_FNO_FUNCTION_SECTIONS)
-      # Don't add -ffunction-section if it can be disabled with -fno-function-sections.
+      # Don't add -ffunction-sections if it can't be disabled with -fno-function-sections.
       # Doing so will break sanitizers.
       add_flag_if_supported("-ffunction-sections" FFUNCTION_SECTIONS)
+    elseif (CMAKE_CXX_COMPILER_ID MATCHES "XL")
+      append("-qfuncsect" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
     endif()
     add_flag_if_supported("-fdata-sections" FDATA_SECTIONS)
   endif()


        


More information about the llvm-commits mailing list