From b82144b6e4b535fe266b0d970def849f84ff9137 Mon Sep 17 00:00:00 2001 From: Simon Atanasyan Date: Sat, 27 Apr 2019 09:28:54 +0000 Subject: [PATCH] [cmake] Disable a GCC optimization when building LLVM for MIPS GCC when compiling LLVM for MIPS can introduce a jump to an uninitialized value when shrink wrapping is enabled. As shrink wrapping is enabled in GCC at all optimization levels, it must be disabled. This bug exists for all versions of GCC since 4.9.2. This partially resolves PR37701 / GCC PR target/86069. Patch by Simon Dardis. Differential Revision: https://reviews.llvm.org/D48069 llvm-svn: 359376 --- llvm/cmake/modules/HandleLLVMOptions.cmake | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/llvm/cmake/modules/HandleLLVMOptions.cmake b/llvm/cmake/modules/HandleLLVMOptions.cmake index 15497d4..88946aa 100644 --- a/llvm/cmake/modules/HandleLLVMOptions.cmake +++ b/llvm/cmake/modules/HandleLLVMOptions.cmake @@ -248,6 +248,11 @@ if( LLVM_ENABLE_PIC ) else() add_flag_or_print_warning("-fPIC" FPIC) endif() + # GCC for MIPS can miscompile LLVM due to PR37701. + if(CMAKE_COMPILER_IS_GNUCXX AND LLVM_NATIVE_ARCH STREQUAL "Mips" AND + NOT Uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG") + add_flag_or_print_warning("-fno-shrink-wrap" FNO_SHRINK_WRAP) + endif() endif() if(NOT WIN32 AND NOT CYGWIN AND NOT (${CMAKE_SYSTEM_NAME} MATCHES "AIX" AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU")) -- 2.7.4