Index: CMakeLists.txt =================================================================== --- CMakeLists.txt +++ CMakeLists.txt @@ -40,8 +40,8 @@ # Configure the Version.inc file. configure_file( - ${CMAKE_CURRENT_SOURCE_DIR}/include/lld/Config/Version.inc.in - ${CMAKE_CURRENT_BINARY_DIR}/include/lld/Config/Version.inc) + ${CMAKE_CURRENT_SOURCE_DIR}/include/lld/Core/Version.inc.in + ${CMAKE_CURRENT_BINARY_DIR}/include/lld/Core/Version.inc) if (CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR) Index: include/lld/Config/Makefile =================================================================== --- include/lld/Config/Makefile +++ /dev/null @@ -1,32 +0,0 @@ -LLD_LEVEL := ../../.. - -BUILT_SOURCES = Version.inc - -TABLEGEN_INC_FILES_COMMON = 1 - -include $(LLD_LEVEL)/Makefile - -# Compute the lld version from the LLVM version, unless specified explicitly. -ifndef LLD_VERSION -LLD_VERSION := $(subst svn,,$(LLVMVersion)) -LLD_VERSION := $(subst rc,,$(LLD_VERSION)) -endif - -LLD_VERSION_COMPONENTS := $(subst ., ,$(LLD_VERSION)) -LLD_VERSION_MAJOR := $(word 1,$(LLD_VERSION_COMPONENTS)) -LLD_VERSION_MINOR := $(word 2,$(LLD_VERSION_COMPONENTS)) - -LLD_REVISION := $(strip \ - $(shell $(LLVM_SRC_ROOT)/utils/GetSourceVersion $(LLVM_SRC_ROOT)/tools/lld)) - -LLD_REPOSITORY := $(strip \ - $(shell $(LLVM_SRC_ROOT)/utils/GetRepositoryPath $(LLVM_SRC_ROOT)/tools/lld)) - -$(ObjDir)/Version.inc.tmp : Version.inc.in Makefile $(LLVM_OBJ_ROOT)/Makefile.config $(ObjDir)/.dir - $(Echo) "Updating LLD version info." - $(Verb)sed -e "s#@LLD_VERSION@#$(LLD_VERSION)#g" \ - -e "s#@LLD_VERSION_MAJOR@#$(LLD_VERSION_MAJOR)#g" \ - -e "s#@LLD_VERSION_MINOR@#$(LLD_VERSION_MINOR)#g" \ - -e "s#@LLD_REVISION@#$(LLD_REVISION)#g" \ - -e "s#@LLD_REPOSITORY@#$(LLD_REPOSITORY)#g" \ - $< > $@ Index: include/lld/Config/Version.h =================================================================== --- include/lld/Config/Version.h +++ /dev/null @@ -1,51 +0,0 @@ -//===- lld/Config/Version.h - LLD Version Number ----------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -/// -/// \file -/// \brief Defines version macros and version-related utility functions -/// for lld. -/// -//===----------------------------------------------------------------------===// - -#ifndef LLD_VERSION_H -#define LLD_VERSION_H - -#include "lld/Config/Version.inc" -#include "llvm/ADT/StringRef.h" -#include - -/// \brief Helper macro for LLD_VERSION_STRING. -#define LLD_MAKE_VERSION_STRING2(X) #X - -/// \brief Helper macro for LLD_VERSION_STRING. -#define LLD_MAKE_VERSION_STRING(X, Y) LLD_MAKE_VERSION_STRING2(X.Y) - -/// \brief A string that describes the lld version number, e.g., "1.0". -#define LLD_VERSION_STRING \ - LLD_MAKE_VERSION_STRING(LLD_VERSION_MAJOR, LLD_VERSION_MINOR) - -namespace lld { -/// \brief Retrieves the repository path (e.g., Subversion path) that -/// identifies the particular lld branch, tag, or trunk from which this -/// lld was built. -llvm::StringRef getLLDRepositoryPath(); - -/// \brief Retrieves the repository revision number (or identifer) from which -/// this lld was built. -llvm::StringRef getLLDRevision(); - -/// \brief Retrieves the full repository version that is an amalgamation of -/// the information in getLLDRepositoryPath() and getLLDRevision(). -std::string getLLDRepositoryVersion(); - -/// \brief Retrieves a string representing the complete lld version. -llvm::StringRef getLLDVersion(); -} - -#endif // LLD_VERSION_H Index: include/lld/Config/Version.inc.in =================================================================== --- include/lld/Config/Version.inc.in +++ /dev/null @@ -1,5 +0,0 @@ -#define LLD_VERSION @LLD_VERSION@ -#define LLD_VERSION_MAJOR @LLD_VERSION_MAJOR@ -#define LLD_VERSION_MINOR @LLD_VERSION_MINOR@ -#define LLD_REVISION_STRING "@LLD_REVISION@" -#define LLD_REPOSITORY_STRING "@LLD_REPOSITORY@" Index: include/lld/Core/Makefile =================================================================== --- /dev/null +++ include/lld/Core/Makefile @@ -0,0 +1,32 @@ +LLD_LEVEL := ../../.. + +BUILT_SOURCES = Version.inc + +TABLEGEN_INC_FILES_COMMON = 1 + +include $(LLD_LEVEL)/Makefile + +# Compute the lld version from the LLVM version, unless specified explicitly. +ifndef LLD_VERSION +LLD_VERSION := $(subst svn,,$(LLVMVersion)) +LLD_VERSION := $(subst rc,,$(LLD_VERSION)) +endif + +LLD_VERSION_COMPONENTS := $(subst ., ,$(LLD_VERSION)) +LLD_VERSION_MAJOR := $(word 1,$(LLD_VERSION_COMPONENTS)) +LLD_VERSION_MINOR := $(word 2,$(LLD_VERSION_COMPONENTS)) + +LLD_REVISION := $(strip \ + $(shell $(LLVM_SRC_ROOT)/utils/GetSourceVersion $(LLVM_SRC_ROOT)/tools/lld)) + +LLD_REPOSITORY := $(strip \ + $(shell $(LLVM_SRC_ROOT)/utils/GetRepositoryPath $(LLVM_SRC_ROOT)/tools/lld)) + +$(ObjDir)/Version.inc.tmp : Version.inc.in Makefile $(LLVM_OBJ_ROOT)/Makefile.config $(ObjDir)/.dir + $(Echo) "Updating LLD version info." + $(Verb)sed -e "s#@LLD_VERSION@#$(LLD_VERSION)#g" \ + -e "s#@LLD_VERSION_MAJOR@#$(LLD_VERSION_MAJOR)#g" \ + -e "s#@LLD_VERSION_MINOR@#$(LLD_VERSION_MINOR)#g" \ + -e "s#@LLD_REVISION@#$(LLD_REVISION)#g" \ + -e "s#@LLD_REPOSITORY@#$(LLD_REPOSITORY)#g" \ + $< > $@ Index: include/lld/Core/Version.h =================================================================== --- /dev/null +++ include/lld/Core/Version.h @@ -0,0 +1,51 @@ +//===- lld/Core/Version.h - LLD Version Number ------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +/// +/// \file +/// \brief Defines version macros and version-related utility functions +/// for lld. +/// +//===----------------------------------------------------------------------===// + +#ifndef LLD_CORE_VERSION_H +#define LLD_CORE_VERSION_H + +#include "lld/Core/Version.inc" +#include "llvm/ADT/StringRef.h" +#include + +/// \brief Helper macro for LLD_VERSION_STRING. +#define LLD_MAKE_VERSION_STRING2(X) #X + +/// \brief Helper macro for LLD_VERSION_STRING. +#define LLD_MAKE_VERSION_STRING(X, Y) LLD_MAKE_VERSION_STRING2(X.Y) + +/// \brief A string that describes the lld version number, e.g., "1.0". +#define LLD_VERSION_STRING \ + LLD_MAKE_VERSION_STRING(LLD_VERSION_MAJOR, LLD_VERSION_MINOR) + +namespace lld { +/// \brief Retrieves the repository path (e.g., Subversion path) that +/// identifies the particular lld branch, tag, or trunk from which this +/// lld was built. +llvm::StringRef getLLDRepositoryPath(); + +/// \brief Retrieves the repository revision number (or identifer) from which +/// this lld was built. +llvm::StringRef getLLDRevision(); + +/// \brief Retrieves the full repository version that is an amalgamation of +/// the information in getLLDRepositoryPath() and getLLDRevision(). +std::string getLLDRepositoryVersion(); + +/// \brief Retrieves a string representing the complete lld version. +llvm::StringRef getLLDVersion(); +} + +#endif // LLD_CORE_VERSION_H Index: include/lld/Core/Version.inc.in =================================================================== --- /dev/null +++ include/lld/Core/Version.inc.in @@ -0,0 +1,5 @@ +#define LLD_VERSION @LLD_VERSION@ +#define LLD_VERSION_MAJOR @LLD_VERSION_MAJOR@ +#define LLD_VERSION_MINOR @LLD_VERSION_MINOR@ +#define LLD_REVISION_STRING "@LLD_REVISION@" +#define LLD_REPOSITORY_STRING "@LLD_REPOSITORY@" Index: include/lld/Makefile =================================================================== --- include/lld/Makefile +++ include/lld/Makefile @@ -1,5 +1,5 @@ LLD_LEVEL := ../.. -DIRS := Config +DIRS := Core include $(LLD_LEVEL)/Makefile Index: lib/CMakeLists.txt =================================================================== --- lib/CMakeLists.txt +++ lib/CMakeLists.txt @@ -1,4 +1,3 @@ -add_subdirectory(Config) add_subdirectory(Core) add_subdirectory(Driver) add_subdirectory(ReaderWriter) Index: lib/Config/CMakeLists.txt =================================================================== --- lib/Config/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -add_llvm_library(lldConfig - Version.cpp - LINK_LIBS - LLVMSupport - ) Index: lib/Config/Makefile =================================================================== --- lib/Config/Makefile +++ /dev/null @@ -1,13 +0,0 @@ -##===- lib/Config/Makefile ---------------------------------*- Makefile -*-===## -# -# The LLVM Compiler Infrastructure -# -# This file is distributed under the University of Illinois Open Source -# License. See LICENSE.TXT for details. -# -##===----------------------------------------------------------------------===## - -LLD_LEVEL := ../.. -LIBRARYNAME := lldConfig - -include $(LLD_LEVEL)/Makefile Index: lib/Config/Version.cpp =================================================================== --- lib/Config/Version.cpp +++ /dev/null @@ -1,66 +0,0 @@ -//===- lib/Config/Version.cpp - LLD Version Number ---------------*- C++-=====// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file defines several version-related utility functions for LLD. -// -//===----------------------------------------------------------------------===// - -#include "lld/Config/Version.h" -#include "llvm/Support/raw_ostream.h" -#include -#include - -using namespace llvm; - -namespace lld { - -StringRef getLLDRepositoryPath() { -#ifdef LLD_REPOSITORY_STRING - return LLD_REPOSITORY_STRING; -#else - return ""; -#endif -} - -StringRef getLLDRevision() { -#ifdef LLD_REVISION_STRING - return LLD_REVISION_STRING; -#else - return ""; -#endif -} - -std::string getLLDRepositoryVersion() { - std::string buf; - llvm::raw_string_ostream OS(buf); - std::string Path = getLLDRepositoryPath(); - std::string Revision = getLLDRevision(); - if (!Path.empty() || !Revision.empty()) { - OS << '('; - if (!Path.empty()) - OS << Path; - if (!Revision.empty()) { - if (!Path.empty()) - OS << ' '; - OS << Revision; - } - OS << ')'; - } - return OS.str(); -} - -StringRef getLLDVersion() { -#ifdef LLD_VERSION_STRING - return LLD_VERSION_STRING; -#else - return ""; -#endif -} - -} // end namespace lld Index: lib/Core/CMakeLists.txt =================================================================== --- lib/Core/CMakeLists.txt +++ lib/Core/CMakeLists.txt @@ -6,6 +6,7 @@ Reader.cpp Resolver.cpp SymbolTable.cpp + Version.cpp Writer.cpp LINK_LIBS LLVMSupport Index: lib/Core/Version.cpp =================================================================== --- /dev/null +++ lib/Core/Version.cpp @@ -0,0 +1,66 @@ +//===- lib/Core/Version.cpp - LLD Version Number -----------------*- C++-=====// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file defines several version-related utility functions for LLD. +// +//===----------------------------------------------------------------------===// + +#include "lld/Core/Version.h" +#include "llvm/Support/raw_ostream.h" +#include +#include + +using namespace llvm; + +namespace lld { + +StringRef getLLDRepositoryPath() { +#ifdef LLD_REPOSITORY_STRING + return LLD_REPOSITORY_STRING; +#else + return ""; +#endif +} + +StringRef getLLDRevision() { +#ifdef LLD_REVISION_STRING + return LLD_REVISION_STRING; +#else + return ""; +#endif +} + +std::string getLLDRepositoryVersion() { + std::string buf; + llvm::raw_string_ostream OS(buf); + std::string Path = getLLDRepositoryPath(); + std::string Revision = getLLDRevision(); + if (!Path.empty() || !Revision.empty()) { + OS << '('; + if (!Path.empty()) + OS << Path; + if (!Revision.empty()) { + if (!Path.empty()) + OS << ' '; + OS << Revision; + } + OS << ')'; + } + return OS.str(); +} + +StringRef getLLDVersion() { +#ifdef LLD_VERSION_STRING + return LLD_VERSION_STRING; +#else + return ""; +#endif +} + +} // end namespace lld Index: lib/Driver/CMakeLists.txt =================================================================== --- lib/Driver/CMakeLists.txt +++ lib/Driver/CMakeLists.txt @@ -19,7 +19,6 @@ WinLinkDriver.cpp WinLinkModuleDef.cpp LINK_LIBS - lldConfig lldMachO lldPECOFF lldELF Index: lib/Driver/UniversalDriver.cpp =================================================================== --- lib/Driver/UniversalDriver.cpp +++ lib/Driver/UniversalDriver.cpp @@ -15,8 +15,8 @@ //===----------------------------------------------------------------------===// #include "lld/Driver/Driver.h" -#include "lld/Config/Version.h" #include "lld/Core/LLVM.h" +#include "lld/Core/Version.h" #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/StringExtras.h" #include "llvm/ADT/StringSwitch.h" Index: tools/lld/Makefile =================================================================== --- tools/lld/Makefile +++ tools/lld/Makefile @@ -19,7 +19,7 @@ include $(LEVEL)/Makefile.config LINK_COMPONENTS := $(TARGETS_TO_BUILD) -USEDLIBS = lldDriver.a lldConfig.a \ +USEDLIBS = lldDriver.a \ lldELF.a lldMachO.a lldPECOFF.a lldYAML.a \ lldReaderWriter.a lldCore.a lldNative.a \ lldHexagonELFTarget.a lldMipsELFTarget.a \ Index: unittests/DriverTests/Makefile =================================================================== --- unittests/DriverTests/Makefile +++ unittests/DriverTests/Makefile @@ -9,7 +9,7 @@ LLD_LEVEL = ../.. TESTNAME = DriverTests -USEDLIBS = lldDriver.a lldConfig.a \ +USEDLIBS = lldDriver.a \ lldELF.a lldMachO.a lldPECOFF.a \ lldCore.a lldNative.a lldReaderWriter.a \ lldHexagonELFTarget.a lldMipsELFTarget.a \