static link polly into tools
authorSebastian Pop <spop@codeaurora.org>
Fri, 14 Mar 2014 04:04:14 +0000 (04:04 +0000)
committerSebastian Pop <spop@codeaurora.org>
Fri, 14 Mar 2014 04:04:14 +0000 (04:04 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@203886 91177308-0d34-0410-b5e6-96231b3b80d8

CMakeLists.txt
include/llvm/Config/config.h.cmake
include/llvm/Config/llvm-config.h.cmake
tools/CMakeLists.txt
tools/bugpoint/CMakeLists.txt
tools/bugpoint/bugpoint.cpp
tools/opt/CMakeLists.txt
tools/opt/opt.cpp

index 49d1296950a5b3120b77985966ec5d9a788f3032..237701818ff9e944701b3ac46c1c904046adb442 100644 (file)
@@ -503,6 +503,8 @@ endif()
 add_subdirectory(projects)
 
 option(WITH_POLLY "Build LLVM with Polly" ON)
+option(LINK_POLLY_INTO_TOOLS "Static link Polly into tools" OFF)
+
 if(WITH_POLLY)
   if(NOT EXISTS ${LLVM_MAIN_SRC_DIR}/tools/polly/CMakeLists.txt)
     set(WITH_POLLY OFF)
index 4a15197895ba5025f0024d55ad621e0d21ee4c87..ea1e75a76a085dd3240bb27720f0da48d7b7210b 100644 (file)
 /* Linker version detected at compile time. */
 #undef HOST_LINK_VERSION
 
+/* Define if we link Polly to the tools */
+#cmakedefine LINK_POLLY_INTO_TOOLS
+
 /* Installation directory for binary executables */
 #cmakedefine LLVM_BINDIR "${LLVM_BINDIR}"
 
index 2b828a1ffb07a592e4fe28d0dddf4794c8a12c1e..65116cb469ccde1b68b891fd9fe6ffc8abdfde1d 100644 (file)
 /* Minor version of the LLVM API */
 #cmakedefine LLVM_VERSION_MINOR ${LLVM_VERSION_MINOR}
 
+/* Define if we link Polly to the tools */
+#cmakedefine LINK_POLLY_INTO_TOOLS
+
 #endif
index c3ebe18b8a507d37b75d700084c3485c64aaf915..13b7f5af85a7da7afc49a4fca3194a88ac30b420 100644 (file)
@@ -1,5 +1,13 @@
 add_llvm_tool_subdirectory(llvm-config)
 
+# Build polly before the tools: the tools link against polly when
+# LINK_POLLY_INTO_TOOLS is set.
+if(WITH_POLLY)
+  add_llvm_external_project(polly)
+else(WITH_POLLY)
+  list(APPEND LLVM_IMPLICIT_PROJECT_IGNORE "${LLVM_MAIN_SRC_DIR}/tools/polly")
+endif(WITH_POLLY)
+
 add_llvm_tool_subdirectory(opt)
 add_llvm_tool_subdirectory(llvm-as)
 add_llvm_tool_subdirectory(llvm-dis)
@@ -67,12 +75,6 @@ if( NOT LLVM_INCLUDE_TOOLS STREQUAL "bootstrap-only" )
   add_llvm_external_project(lld)
   add_llvm_external_project(lldb)
 
-  if(WITH_POLLY)
-    add_llvm_external_project(polly)
-  else(WITH_POLLY)
-    list(APPEND LLVM_IMPLICIT_PROJECT_IGNORE "${LLVM_MAIN_SRC_DIR}/tools/polly")
-  endif(WITH_POLLY)
-
   # Automatically add remaining sub-directories containing a 'CMakeLists.txt'
   # file as external projects.
   add_llvm_implicit_external_projects()
index b537a5d237d8ba88326c18f434ebcaaa60cc62d9..d71e097918c40d47785d3dd2d55446501107dd7b 100644 (file)
@@ -32,3 +32,12 @@ add_llvm_tool(bugpoint
   bugpoint.cpp
   )
 set_target_properties(bugpoint PROPERTIES ENABLE_EXPORTS 1)
+
+if(WITH_POLLY AND LINK_POLLY_INTO_TOOLS)
+  target_link_libraries(bugpoint Polly)
+  if(POLLY_LINK_LIBS)
+    foreach(lib ${POLLY_LINK_LIBS})
+      target_link_libraries(bugpoint ${lib})
+    endforeach(lib)
+  endif(POLLY_LINK_LIBS)
+endif(WITH_POLLY AND LINK_POLLY_INTO_TOOLS)
index b79434080ddb818aef6b75f3eb38cd4480b28b7e..5c03b41abbeecbf8b80102ee7845633335cbbfba 100644 (file)
@@ -109,6 +109,12 @@ namespace {
   };
 }
 
+#ifdef LINK_POLLY_INTO_TOOLS
+namespace polly {
+void initializePollyPasses(llvm::PassRegistry &Registry);
+}
+#endif
+
 int main(int argc, char **argv) {
 #ifndef DEBUG_BUGPOINT
   llvm::sys::PrintStackTraceOnErrorSignal();
@@ -130,6 +136,10 @@ int main(int argc, char **argv) {
   initializeInstrumentation(Registry);
   initializeTarget(Registry);
 
+#ifdef LINK_POLLY_INTO_TOOLS
+  polly::initializePollyPasses(Registry);
+#endif
+
   cl::ParseCommandLineOptions(argc, argv,
                               "LLVM automatic testcase reducer. See\nhttp://"
                               "llvm.org/cmds/bugpoint.html"
index 1f76ab55511b43a32364d018f385c59c69b00dcf..1d3f08db7d2984ef1653631451a1a92a026503da 100644 (file)
@@ -32,3 +32,12 @@ add_llvm_tool(opt
   opt.cpp
   )
 set_target_properties(opt PROPERTIES ENABLE_EXPORTS 1)
+
+if(WITH_POLLY AND LINK_POLLY_INTO_TOOLS)
+  target_link_libraries(opt Polly)
+  if(POLLY_LINK_LIBS)
+    foreach(lib ${POLLY_LINK_LIBS})
+      target_link_libraries(opt ${lib})
+    endforeach(lib)
+  endif(POLLY_LINK_LIBS)
+endif(WITH_POLLY AND LINK_POLLY_INTO_TOOLS)
index 4dd9544fc32b923a1461044069d41470c0563dd3..5a198816e676e832f6c15db847ac2d23957dc468 100644 (file)
@@ -304,6 +304,12 @@ static TargetMachine* GetTargetMachine(Triple TheTriple) {
                                         GetCodeGenOptLevel());
 }
 
+#ifdef LINK_POLLY_INTO_TOOLS
+namespace polly {
+void initializePollyPasses(llvm::PassRegistry &Registry);
+}
+#endif
+
 //===----------------------------------------------------------------------===//
 // main for opt
 //
@@ -338,6 +344,10 @@ int main(int argc, char **argv) {
   // supported. For now, just add CodeGenPrepare.
   initializeCodeGenPreparePass(Registry);
 
+#ifdef LINK_POLLY_INTO_TOOLS
+  polly::initializePollyPasses(Registry);
+#endif
+
   cl::ParseCommandLineOptions(argc, argv,
     "llvm .bc -> .bc modular optimizer and analysis printer\n");