summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--llvm/cmake/modules/VersionFromVCS.cmake84
-rw-r--r--llvm/include/llvm/CMakeLists.txt1
-rw-r--r--llvm/include/llvm/Support/CMakeLists.txt54
-rw-r--r--llvm/lib/LTO/CMakeLists.txt51
-rw-r--r--llvm/lib/LTO/LTO.cpp3
-rw-r--r--llvm/lib/LTO/ThinLTOCodeGenerator.cpp7
6 files changed, 106 insertions, 94 deletions
diff --git a/llvm/cmake/modules/VersionFromVCS.cmake b/llvm/cmake/modules/VersionFromVCS.cmake
index e92540991a1..983b48fefa0 100644
--- a/llvm/cmake/modules/VersionFromVCS.cmake
+++ b/llvm/cmake/modules/VersionFromVCS.cmake
@@ -25,57 +25,65 @@ function(add_version_info_from_vcs VERS)
set(LLVM_REPOSITORY ${Project_WC_URL} PARENT_SCOPE)
endif()
endif()
- elseif( EXISTS ${SOURCE_DIR}/.git )
- set(result "${result}git")
- # Try to get a ref-id
+ else()
find_program(git_executable NAMES git git.exe git.cmd)
if( git_executable )
- if( EXISTS ${SOURCE_DIR}/.git/svn )
- # Get the repository URL
- execute_process(COMMAND
- ${git_executable} svn info
- WORKING_DIRECTORY ${SOURCE_DIR}
- TIMEOUT 5
- RESULT_VARIABLE git_result
- OUTPUT_VARIABLE git_output)
- if( git_result EQUAL 0 )
- string(REGEX MATCH "URL: ([^ \n]*)" svn_url ${git_output})
- if(svn_url)
- set(LLVM_REPOSITORY ${CMAKE_MATCH_1} PARENT_SCOPE)
+ # Run from a subdirectory to force git to print an absoute path.
+ execute_process(COMMAND ${git_executable} rev-parse --git-dir
+ WORKING_DIRECTORY ${SOURCE_DIR}/cmake
+ RESULT_VARIABLE git_result
+ OUTPUT_VARIABLE git_dir)
+ if(git_result EQUAL 0)
+ # Try to get a ref-id
+ string(STRIP "${git_dir}" git_dir)
+ set(result "${result}git")
+ if( EXISTS ${git_dir}/svn )
+ # Get the repository URL
+ execute_process(COMMAND
+ ${git_executable} svn info
+ WORKING_DIRECTORY ${SOURCE_DIR}
+ TIMEOUT 5
+ RESULT_VARIABLE git_result
+ OUTPUT_VARIABLE git_output)
+ if( git_result EQUAL 0 )
+ string(REGEX MATCH "URL: ([^ \n]*)" svn_url ${git_output})
+ if(svn_url)
+ set(LLVM_REPOSITORY ${CMAKE_MATCH_1} PARENT_SCOPE)
+ endif()
+ endif()
+
+ # Get the svn revision number for this git commit if one exists.
+ execute_process(COMMAND ${git_executable} svn find-rev HEAD
+ WORKING_DIRECTORY ${SOURCE_DIR}
+ TIMEOUT 5
+ RESULT_VARIABLE git_result
+ OUTPUT_VARIABLE git_head_svn_rev_number
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ if( git_result EQUAL 0 AND git_output)
+ set(SVN_REVISION ${git_head_svn_rev_number} PARENT_SCOPE)
+ set(git_svn_rev "-svn-${git_head_svn_rev_number}")
+ else()
+ set(git_svn_rev "")
endif()
endif()
- # Get the svn revision number for this git commit if one exists.
- execute_process(COMMAND ${git_executable} svn find-rev HEAD
+ # Get the git ref id
+ execute_process(COMMAND
+ ${git_executable} rev-parse --short HEAD
WORKING_DIRECTORY ${SOURCE_DIR}
TIMEOUT 5
RESULT_VARIABLE git_result
- OUTPUT_VARIABLE git_head_svn_rev_number
+ OUTPUT_VARIABLE git_ref_id
OUTPUT_STRIP_TRAILING_WHITESPACE)
- if( git_result EQUAL 0 AND git_output)
- set(SVN_REVISION ${git_head_svn_rev_number} PARENT_SCOPE)
- set(git_svn_rev "-svn-${git_head_svn_rev_number}")
+
+ if( git_result EQUAL 0 )
+ set(GIT_COMMIT ${git_ref_id} PARENT_SCOPE)
+ set(result "${result}${git_svn_rev}-${git_ref_id}")
else()
- set(git_svn_rev "")
+ set(result "${result}${git_svn_rev}")
endif()
endif()
-
- # Get the git ref id
- execute_process(COMMAND
- ${git_executable} rev-parse --short HEAD
- WORKING_DIRECTORY ${SOURCE_DIR}
- TIMEOUT 5
- RESULT_VARIABLE git_result
- OUTPUT_VARIABLE git_ref_id
- OUTPUT_STRIP_TRAILING_WHITESPACE)
-
- if( git_result EQUAL 0 )
- set(GIT_COMMIT ${git_ref_id} PARENT_SCOPE)
- set(result "${result}${git_svn_rev}-${git_ref_id}")
- else()
- set(result "${result}${git_svn_rev}")
- endif()
endif()
endif()
set(${VERS} ${result} PARENT_SCOPE)
diff --git a/llvm/include/llvm/CMakeLists.txt b/llvm/include/llvm/CMakeLists.txt
index ff805396eb0..1d5ca3ba92b 100644
--- a/llvm/include/llvm/CMakeLists.txt
+++ b/llvm/include/llvm/CMakeLists.txt
@@ -1,4 +1,5 @@
add_subdirectory(IR)
+add_subdirectory(Support)
# If we're doing an out-of-tree build, copy a module map for generated
# header files into the build area.
diff --git a/llvm/include/llvm/Support/CMakeLists.txt b/llvm/include/llvm/Support/CMakeLists.txt
new file mode 100644
index 00000000000..b4b99370574
--- /dev/null
+++ b/llvm/include/llvm/Support/CMakeLists.txt
@@ -0,0 +1,54 @@
+# Figure out if we can track VC revisions.
+function(find_first_existing_file out_var)
+ foreach(file ${ARGN})
+ if(EXISTS "${file}")
+ set(${out_var} "${file}" PARENT_SCOPE)
+ return()
+ endif()
+ endforeach()
+endfunction()
+
+macro(find_first_existing_vc_file out_var path)
+ find_program(git_executable NAMES git git.exe git.cmd)
+ # Run from a subdirectory to force git to print an absolute path.
+ execute_process(COMMAND ${git_executable} rev-parse --git-dir
+ WORKING_DIRECTORY ${path}/cmake
+ RESULT_VARIABLE git_result
+ OUTPUT_VARIABLE git_dir)
+ if(git_result EQUAL 0)
+ string(STRIP "${git_dir}" git_dir)
+ set(${out_var} "${git_dir}/logs/HEAD")
+ else()
+ find_first_existing_file(${out_var}
+ "${path}/.svn/wc.db" # SVN 1.7
+ "${path}/.svn/entries" # SVN 1.6
+ )
+ endif()
+endmacro()
+
+find_first_existing_vc_file(llvm_vc "${LLVM_MAIN_SRC_DIR}")
+
+# The VC revision include that we want to generate.
+set(version_inc "${CMAKE_CURRENT_BINARY_DIR}/VCSRevision.h")
+
+set(get_svn_script "${LLVM_CMAKE_PATH}/GenerateVersionFromCVS.cmake")
+
+if(DEFINED llvm_vc)
+ # Create custom target to generate the VC revision include.
+ add_custom_command(OUTPUT "${version_inc}"
+ DEPENDS "${llvm_vc}" "${get_svn_script}"
+ COMMAND
+ ${CMAKE_COMMAND} "-DSOURCE_DIR=${LLVM_MAIN_SRC_DIR}"
+ "-DNAME=LLVM_REVISION"
+ "-DHEADER_FILE=${version_inc}"
+ -P "${get_svn_script}")
+
+ # Mark the generated header as being generated.
+ set_source_files_properties("${version_inc}"
+ PROPERTIES GENERATED TRUE
+ HEADER_FILE_ONLY TRUE)
+else()
+ file(WRITE "${version_inc}" "")
+endif()
+
+add_custom_target(llvm_vcsrevision_h DEPENDS "${version_inc}")
diff --git a/llvm/lib/LTO/CMakeLists.txt b/llvm/lib/LTO/CMakeLists.txt
index c73143eb330..73b5662d4bc 100644
--- a/llvm/lib/LTO/CMakeLists.txt
+++ b/llvm/lib/LTO/CMakeLists.txt
@@ -1,52 +1,3 @@
-# Figure out if we can track VC revisions.
-function(find_first_existing_file out_var)
- foreach(file ${ARGN})
- if(EXISTS "${file}")
- set(${out_var} "${file}" PARENT_SCOPE)
- return()
- endif()
- endforeach()
-endfunction()
-
-macro(find_first_existing_vc_file out_var path)
- find_first_existing_file(${out_var}
- "${path}/.git/logs/HEAD" # Git
- "${path}/.svn/wc.db" # SVN 1.7
- "${path}/.svn/entries" # SVN 1.6
- )
-endmacro()
-
-find_first_existing_vc_file(llvm_vc "${LLVM_MAIN_SRC_DIR}")
-
-# The VC revision include that we want to generate.
-set(version_inc "${CMAKE_CURRENT_BINARY_DIR}/LLVMLTORevision.h")
-
-set(get_svn_script "${LLVM_CMAKE_PATH}/GenerateVersionFromCVS.cmake")
-
-if(DEFINED llvm_vc)
- # Create custom target to generate the VC revision include.
- add_custom_command(OUTPUT "${version_inc}"
- DEPENDS "${llvm_vc}" "${get_svn_script}"
- COMMAND
- ${CMAKE_COMMAND} "-DSOURCE_DIR=${LLVM_MAIN_SRC_DIR}"
- "-DNAME=LLVM_REVISION"
- "-DHEADER_FILE=${version_inc}"
- -P "${get_svn_script}")
-
- # Mark the generated header as being generated.
- set_source_files_properties("${version_inc}"
- PROPERTIES GENERATED TRUE
- HEADER_FILE_ONLY TRUE)
-
- # Tell Version.cpp that it needs to build with -DHAVE_SVN_VERSION_INC.
- set_source_files_properties(Version.cpp
- PROPERTIES COMPILE_DEFINITIONS "HAVE_SVN_VERSION_INC")
-else()
- # Not producing a VC revision include.
- set(version_inc)
-endif()
-
-
add_llvm_library(LLVMLTO
Caching.cpp
LTO.cpp
@@ -55,11 +6,11 @@ add_llvm_library(LLVMLTO
LTOCodeGenerator.cpp
UpdateCompilerUsed.cpp
ThinLTOCodeGenerator.cpp
- ${version_inc}
ADDITIONAL_HEADER_DIRS
${LLVM_MAIN_INCLUDE_DIR}/llvm/LTO
DEPENDS
intrinsics_gen
+ llvm_vcsrevision_h
)
diff --git a/llvm/lib/LTO/LTO.cpp b/llvm/lib/LTO/LTO.cpp
index 6ca7e34527c..e6fc8cc8853 100644
--- a/llvm/lib/LTO/LTO.cpp
+++ b/llvm/lib/LTO/LTO.cpp
@@ -35,6 +35,7 @@
#include "llvm/Support/TargetRegistry.h"
#include "llvm/Support/ThreadPool.h"
#include "llvm/Support/Threading.h"
+#include "llvm/Support/VCSRevision.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Target/TargetMachine.h"
#include "llvm/Target/TargetOptions.h"
@@ -74,7 +75,7 @@ static void computeCacheKey(
// Start with the compiler revision
Hasher.update(LLVM_VERSION_STRING);
-#ifdef HAVE_LLVM_REVISION
+#ifdef LLVM_REVISION
Hasher.update(LLVM_REVISION);
#endif
diff --git a/llvm/lib/LTO/ThinLTOCodeGenerator.cpp b/llvm/lib/LTO/ThinLTOCodeGenerator.cpp
index 970c75e4ace..0d845a26d0c 100644
--- a/llvm/lib/LTO/ThinLTOCodeGenerator.cpp
+++ b/llvm/lib/LTO/ThinLTOCodeGenerator.cpp
@@ -14,10 +14,6 @@
#include "llvm/LTO/legacy/ThinLTOCodeGenerator.h"
-#ifdef HAVE_LLVM_REVISION
-#include "LLVMLTORevision.h"
-#endif
-
#include "llvm/ADT/Statistic.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/Analysis/ModuleSummaryAnalysis.h"
@@ -47,6 +43,7 @@
#include "llvm/Support/ThreadPool.h"
#include "llvm/Support/Threading.h"
#include "llvm/Support/ToolOutputFile.h"
+#include "llvm/Support/VCSRevision.h"
#include "llvm/Target/TargetMachine.h"
#include "llvm/Transforms/IPO.h"
#include "llvm/Transforms/IPO/FunctionImport.h"
@@ -304,7 +301,7 @@ public:
// Start with the compiler revision
Hasher.update(LLVM_VERSION_STRING);
-#ifdef HAVE_LLVM_REVISION
+#ifdef LLVM_REVISION
Hasher.update(LLVM_REVISION);
#endif
OpenPOWER on IntegriCloud