[llvm] r260566 - [CMake] Produce an empty library for GlobalISel when not building it.
Quentin Colombet via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 11 11:18:28 PST 2016
Author: qcolombet
Date: Thu Feb 11 13:18:27 2016
New Revision: 260566
URL: http://llvm.org/viewvc/llvm-project?rev=260566&view=rev
Log:
[CMake] Produce an empty library for GlobalISel when not building it.
The rational for this change is that LLVMBuild cannot express conditional
dependencies. Therefore, when we start optionally using GlobalISel library for
say AArch64, without that change, all the tools that use the AArch64 library
would need to explicitly link with GlobalISel when we ask for it.
This does not scale.
Instead, we will set the dependencies between the target and GlobalISel and if
we did not ask to build GlobalISel, the library will just be empty.
Thanks to Chris Bieneman and Mehdi Animi for the idea.
Added:
llvm/trunk/lib/CodeGen/GlobalISel/EmptyFile.cpp
Modified:
llvm/trunk/lib/CodeGen/CMakeLists.txt
llvm/trunk/lib/CodeGen/GlobalISel/CMakeLists.txt
llvm/trunk/tools/llc/CMakeLists.txt
Modified: llvm/trunk/lib/CodeGen/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/CMakeLists.txt?rev=260566&r1=260565&r2=260566&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/CMakeLists.txt (original)
+++ llvm/trunk/lib/CodeGen/CMakeLists.txt Thu Feb 11 13:18:27 2016
@@ -143,6 +143,4 @@ add_dependencies(LLVMCodeGen intrinsics_
add_subdirectory(SelectionDAG)
add_subdirectory(AsmPrinter)
add_subdirectory(MIRParser)
-if(LLVM_BUILD_GLOBAL_ISEL)
- add_subdirectory(GlobalISel)
-endif()
+add_subdirectory(GlobalISel)
Modified: llvm/trunk/lib/CodeGen/GlobalISel/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/GlobalISel/CMakeLists.txt?rev=260566&r1=260565&r2=260566&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/GlobalISel/CMakeLists.txt (original)
+++ llvm/trunk/lib/CodeGen/GlobalISel/CMakeLists.txt Thu Feb 11 13:18:27 2016
@@ -1,6 +1,24 @@
+# List of all GlobalISel files.
+set(GLOBAL_ISEL_FILES
+ IRTranslator.cpp
+ MachineIRBuilder.cpp
+ )
+
+# Add GlobalISel files to the dependencies if the user wants to build it.
+if(LLVM_BUILD_GLOBAL_ISEL)
+ set(GLOBAL_ISEL_BUILD_FILES ${GLOBAL_ISEL_FILES})
+else()
+ set(GLOBAL_ISEL_BUILD_FILES"")
+ set(LLVM_OPTIONAL_SOURCES LLVMGlobalISel ${GLOBAL_ISEL_FILES})
+endif()
+
+
+# In LLVMBuild.txt files, it is not possible to mark a dependency to a
+# library as optional. So instead, generate an empty library if we did
+# not ask for it.
add_llvm_library(LLVMGlobalISel
- IRTranslator.cpp
- MachineIRBuilder.cpp
+ ${GLOBAL_ISEL_BUILD_FILES}
+ EmptyFile.cpp
)
add_dependencies(LLVMGlobalISel intrinsics_gen)
Added: llvm/trunk/lib/CodeGen/GlobalISel/EmptyFile.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/GlobalISel/EmptyFile.cpp?rev=260566&view=auto
==============================================================================
--- llvm/trunk/lib/CodeGen/GlobalISel/EmptyFile.cpp (added)
+++ llvm/trunk/lib/CodeGen/GlobalISel/EmptyFile.cpp Thu Feb 11 13:18:27 2016
@@ -0,0 +1,19 @@
+//===-- llvm/CodeGen/GlobalISel/EmptyFile.cpp ------ EmptyFile ---*- C++ -*-==//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+/// \file
+/// The purpose of this file is to please cmake by not creating an
+/// empty library when we do not build GlobalISel.
+/// \todo This file should be removed when GlobalISel is not optional anymore.
+//===----------------------------------------------------------------------===//
+
+// Anonymous namespace so that we do not step on anyone's toes.
+namespace {
+__attribute__ ((unused)) void foo(void) {
+}
+}
Modified: llvm/trunk/tools/llc/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llc/CMakeLists.txt?rev=260566&r1=260565&r2=260566&view=diff
==============================================================================
--- llvm/trunk/tools/llc/CMakeLists.txt (original)
+++ llvm/trunk/tools/llc/CMakeLists.txt Thu Feb 11 13:18:27 2016
@@ -1,10 +1,3 @@
-# Add GlobalISel to the dependencies if the user wants to build it.
-if(LLVM_BUILD_GLOBAL_ISEL)
- set(GLOBAL_ISEL GlobalISel)
-else()
- set(GLOBAL_ISEL "")
-endif()
-
set(LLVM_LINK_COMPONENTS
${LLVM_TARGETS_TO_BUILD}
Analysis
@@ -12,7 +5,6 @@ set(LLVM_LINK_COMPONENTS
CodeGen
Core
IRReader
- ${GLOBAL_ISEL}
MC
MIRParser
ScalarOpts
More information about the llvm-commits
mailing list