summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShoaib Meenai <smeenai@fb.com>2019-03-26 22:16:53 +0000
committerShoaib Meenai <smeenai@fb.com>2019-03-26 22:16:53 +0000
commit19c45546fc70d705ce3b470fca4289f33d0cdc20 (patch)
tree4c5d650283033a2954e95e2a870b5fafb1c6b842
parent2cabea054e40ae2837da959d0ca89ae25cf1b1f1 (diff)
downloadbcm5719-llvm-19c45546fc70d705ce3b470fca4289f33d0cdc20.tar.gz
bcm5719-llvm-19c45546fc70d705ce3b470fca4289f33d0cdc20.zip
[cmake] Reset variable before using it
A bunch of macros use the same variable name, and since CMake macros don't get their own scope, the value persists across macro invocations, and we can end up exporting targets which shouldn't be exported. Clear the variable before each use to avoid this. Converting these macros to functions would also help, since it would avoid the variable leaking into its parent scope, and that's something I plan to follow up with. It won't fully address the problem, however, since functions still inherit variables from their parent scopes, so if someone in the parent scope just happened to use the same variable name we'd still have the same issue. llvm-svn: 357036
-rw-r--r--clang/cmake/modules/AddClang.cmake3
-rw-r--r--llvm/cmake/modules/AddLLVM.cmake3
-rw-r--r--llvm/cmake/modules/TableGen.cmake1
3 files changed, 6 insertions, 1 deletions
diff --git a/clang/cmake/modules/AddClang.cmake b/clang/cmake/modules/AddClang.cmake
index 76ff6b1f152..18bac7172b2 100644
--- a/clang/cmake/modules/AddClang.cmake
+++ b/clang/cmake/modules/AddClang.cmake
@@ -89,7 +89,7 @@ macro(add_clang_library name)
target_link_libraries(${name} INTERFACE ${LLVM_COMMON_LIBS})
if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY OR ${name} STREQUAL "libclang")
-
+ set(export_to_clangtargets)
if(${name} IN_LIST LLVM_DISTRIBUTION_COMPONENTS OR
"clang-libraries" IN_LIST LLVM_DISTRIBUTION_COMPONENTS OR
NOT LLVM_DISTRIBUTION_COMPONENTS)
@@ -137,6 +137,7 @@ macro(add_clang_tool name)
add_dependencies(${name} clang-resource-headers)
if (CLANG_BUILD_TOOLS)
+ set(export_to_clangtargets)
if(${name} IN_LIST LLVM_DISTRIBUTION_COMPONENTS OR
NOT LLVM_DISTRIBUTION_COMPONENTS)
set(export_to_clangtargets EXPORT ClangTargets)
diff --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake
index e72680c408a..41e263586b1 100644
--- a/llvm/cmake/modules/AddLLVM.cmake
+++ b/llvm/cmake/modules/AddLLVM.cmake
@@ -669,6 +669,7 @@ macro(add_llvm_library name)
set(install_type LIBRARY)
endif()
+ set(export_to_llvmexports)
if(${name} IN_LIST LLVM_DISTRIBUTION_COMPONENTS OR
(in_llvm_libs AND "llvm-libraries" IN_LIST LLVM_DISTRIBUTION_COMPONENTS) OR
NOT LLVM_DISTRIBUTION_COMPONENTS)
@@ -874,6 +875,7 @@ macro(add_llvm_tool name)
if ( ${name} IN_LIST LLVM_TOOLCHAIN_TOOLS OR NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
if( LLVM_BUILD_TOOLS )
+ set(export_to_llvmexports)
if(${name} IN_LIST LLVM_DISTRIBUTION_COMPONENTS OR
NOT LLVM_DISTRIBUTION_COMPONENTS)
set(export_to_llvmexports EXPORT LLVMExports)
@@ -921,6 +923,7 @@ macro(add_llvm_utility name)
set_target_properties(${name} PROPERTIES FOLDER "Utils")
if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
if (LLVM_INSTALL_UTILS AND LLVM_BUILD_UTILS)
+ set(export_to_llvmexports)
if (${name} IN_LIST LLVM_DISTRIBUTION_COMPONENTS OR
NOT LLVM_DISTRIBUTION_COMPONENTS)
set(export_to_llvmexports EXPORT LLVMExports)
diff --git a/llvm/cmake/modules/TableGen.cmake b/llvm/cmake/modules/TableGen.cmake
index 3c84ae78a34..1701a464f0e 100644
--- a/llvm/cmake/modules/TableGen.cmake
+++ b/llvm/cmake/modules/TableGen.cmake
@@ -164,6 +164,7 @@ macro(add_tablegen target project)
endif()
if (${project} STREQUAL LLVM AND NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
+ set(export_to_llvmexports)
if(${target} IN_LIST LLVM_DISTRIBUTION_COMPONENTS OR
NOT LLVM_DISTRIBUTION_COMPONENTS)
set(export_to_llvmexports EXPORT LLVMExports)
OpenPOWER on IntegriCloud