From 740188055d120a18f87f4d50febed0f35849db13 Mon Sep 17 00:00:00 2001 From: Adeel Mujahid Date: Sun, 20 Oct 2019 21:21:02 +0300 Subject: [PATCH] Avoid unintended cached var in CMake's find_program (dotnet/coreclr#27322) Commit migrated from https://github.com/dotnet/coreclr/commit/2c22d9946b0f04c603a13cf7cc6196317e97442f --- src/coreclr/configuretools.cmake | 15 ++++++++------- src/coreclr/src/pal/tools/find-gcc.sh | 2 +- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/coreclr/configuretools.cmake b/src/coreclr/configuretools.cmake index 372309f..3c96e1a 100644 --- a/src/coreclr/configuretools.cmake +++ b/src/coreclr/configuretools.cmake @@ -10,15 +10,16 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") else() set(LLVM_PREFIX "llvm-") endif() + function(locate_llvm_exec exec var) - find_program(EXEC_LOCATION + find_program(EXEC_LOCATION_${exec} NAMES "${LLVM_PREFIX}${exec}${CLR_CMAKE_COMPILER_FILE_NAME_VERSION}" "${LLVM_PREFIX}${exec}") - if (EXEC_LOCATION STREQUAL "EXEC_LOCATION-NOTFOUND") + if (EXEC_LOCATION_${exec} STREQUAL "EXEC_LOCATION_${exec}-NOTFOUND") message(FATAL_ERROR "Unable to find llvm tool for: ${exec}.") endif() - set(${var} ${EXEC_LOCATION} PARENT_SCOPE) + set(${var} ${EXEC_LOCATION_${exec}} PARENT_SCOPE) endfunction() locate_llvm_exec(ar CMAKE_AR) locate_llvm_exec(link CMAKE_LINKER) @@ -34,20 +35,20 @@ elseif(CMAKE_CXX_COMPILER_ID MATCHES "GNU") endif() function(locate_gcc_exec exec var) - string(TOUPPER exec EXEC_UPPERCASE) + string(TOUPPER ${exec} EXEC_UPPERCASE) if(NOT "$ENV{CLR_${EXEC_UPPERCASE}}" STREQUAL "") set(${var} "$ENV{CLR_${EXEC_UPPERCASE}}" PARENT_SCOPE) return() endif() - find_program(EXEC_LOCATION + find_program(EXEC_LOCATION_${exec} NAMES "${GCC_PREFIX}${exec}${CLR_CMAKE_COMPILER_FILE_NAME_VERSION}" "${GCC_PREFIX}${exec}") - if (EXEC_LOCATION STREQUAL "EXEC_LOCATION-NOTFOUND") + if (EXEC_LOCATION_${exec} STREQUAL "EXEC_LOCATION_${exec}-NOTFOUND") message(FATAL_ERROR "Unable to find gcc tool for: ${exec}.") endif() - set(${var} ${EXEC_LOCATION} PARENT_SCOPE) + set(${var} ${EXEC_LOCATION_${exec}} PARENT_SCOPE) endfunction() locate_gcc_exec(ar CMAKE_AR) locate_gcc_exec(link CMAKE_LINKER) diff --git a/src/coreclr/src/pal/tools/find-gcc.sh b/src/coreclr/src/pal/tools/find-gcc.sh index 0fbdfbd..f7acc76 100755 --- a/src/coreclr/src/pal/tools/find-gcc.sh +++ b/src/coreclr/src/pal/tools/find-gcc.sh @@ -6,7 +6,7 @@ if [ $# -lt 2 ] then echo "Usage..." - echo "gen-buildsys-gcc.sh " + echo "find-gcc.sh " echo "Specify the Gcc version to use, split into major and minor version" exit 1 fi -- 2.7.4