aboutsummaryrefslogtreecommitdiffstats
path: root/tools/llvm-config
diff options
context:
space:
mode:
authorStephen Hines <srhines@google.com>2014-04-23 16:57:46 -0700
committerStephen Hines <srhines@google.com>2014-04-24 15:53:16 -0700
commit36b56886974eae4f9c5ebc96befd3e7bfe5de338 (patch)
treee6cfb69fbbd937f450eeb83bfb83b9da3b01275a /tools/llvm-config
parent69a8640022b04415ae9fac62f8ab090601d8f889 (diff)
downloadexternal_llvm-36b56886974eae4f9c5ebc96befd3e7bfe5de338.zip
external_llvm-36b56886974eae4f9c5ebc96befd3e7bfe5de338.tar.gz
external_llvm-36b56886974eae4f9c5ebc96befd3e7bfe5de338.tar.bz2
Update to LLVM 3.5a.
Change-Id: Ifadecab779f128e62e430c2b4f6ddd84953ed617
Diffstat (limited to 'tools/llvm-config')
-rw-r--r--tools/llvm-config/BuildVariables.inc.in4
-rw-r--r--tools/llvm-config/CMakeLists.txt5
-rw-r--r--tools/llvm-config/Makefile10
-rw-r--r--tools/llvm-config/llvm-config.cpp85
4 files changed, 71 insertions, 33 deletions
diff --git a/tools/llvm-config/BuildVariables.inc.in b/tools/llvm-config/BuildVariables.inc.in
index fe87afb..2ec019b 100644
--- a/tools/llvm-config/BuildVariables.inc.in
+++ b/tools/llvm-config/BuildVariables.inc.in
@@ -11,8 +11,8 @@
// llvm-config wants to report to the user, but which can only be determined at
// build time.
//
-// The non .in variant of this file has been autogenerated by the LLVM build. Do
-// not edit!
+// The variant of this file not ending with .in has been autogenerated by the
+// LLVM build. Do not edit!
//
//===----------------------------------------------------------------------===//
diff --git a/tools/llvm-config/CMakeLists.txt b/tools/llvm-config/CMakeLists.txt
index c651833..6f29a82 100644
--- a/tools/llvm-config/CMakeLists.txt
+++ b/tools/llvm-config/CMakeLists.txt
@@ -4,7 +4,7 @@ set(BUILDVARIABLES_SRCPATH ${CMAKE_CURRENT_SOURCE_DIR}/BuildVariables.inc.in)
set(BUILDVARIABLES_OBJPATH ${CMAKE_CURRENT_BINARY_DIR}/BuildVariables.inc)
# Compute the substitution values for various items.
-get_system_libs(LLVM_SYSTEM_LIBS_LIST)
+get_property(LLVM_SYSTEM_LIBS_LIST TARGET LLVMSupport PROPERTY LLVM_SYSTEM_LIBS)
foreach(l ${LLVM_SYSTEM_LIBS_LIST})
set(SYSTEM_LIBS ${SYSTEM_LIBS} "-l${l}")
endforeach()
@@ -22,6 +22,9 @@ set(LLVM_SYSTEM_LIBS ${SYSTEM_LIBS})
string(REPLACE ";" " " LLVM_TARGETS_BUILT "${LLVM_TARGETS_TO_BUILD}")
configure_file(${BUILDVARIABLES_SRCPATH} ${BUILDVARIABLES_OBJPATH} @ONLY)
+# Set build-time environment(s).
+add_definitions(-DCMAKE_CFG_INTDIR="${CMAKE_CFG_INTDIR}")
+
# Add the llvm-config tool.
add_llvm_tool(llvm-config
llvm-config.cpp
diff --git a/tools/llvm-config/Makefile b/tools/llvm-config/Makefile
index b20b6bf..b78551e 100644
--- a/tools/llvm-config/Makefile
+++ b/tools/llvm-config/Makefile
@@ -30,6 +30,14 @@ SUB_CPPFLAGS := ${CPP.BaseFlags}
SUB_CFLAGS := ${CPP.BaseFlags} ${C.Flags}
SUB_CXXFLAGS := ${CPP.BaseFlags} ${CXX.Flags}
+# Override LIBS with TARGET's LIBS for cross compilation.
+# FIXME: Host's llvm-config is not generated. It's for target's.
+ifneq ($(TARGET_LIBS), )
+ LLVM_SYSTEM_LIBS := $(TARGET_LIBS)
+else
+ LLVM_SYSTEM_LIBS := $(LIBS)
+endif
+
# This is blank for now. We need to be careful about adding stuff here:
# LDFLAGS tend not to be portable, and we don't currently require the
# user to use libtool when linking against LLVM.
@@ -51,7 +59,7 @@ $(ObjDir)/BuildVariables.inc: $(BUILDVARIABLES_SRCPATH) Makefile $(ObjDir)/.dir
>> temp.sed
$(Verb) $(ECHO) 's/@LLVM_BUILDMODE@/$(subst /,\/,$(BuildMode))/' \
>> temp.sed
- $(Verb) $(ECHO) 's/@LLVM_SYSTEM_LIBS@/$(subst /,\/,$(LIBS))/' \
+ $(Verb) $(ECHO) 's/@LLVM_SYSTEM_LIBS@/$(subst /,\/,$(LLVM_SYSTEM_LIBS))/' \
>> temp.sed
$(Verb) $(ECHO) 's/@LLVM_TARGETS_BUILT@/$(subst /,\/,$(TARGETS_TO_BUILD))/' \
>> temp.sed
diff --git a/tools/llvm-config/llvm-config.cpp b/tools/llvm-config/llvm-config.cpp
index 3924e2e..ed1c8c3 100644
--- a/tools/llvm-config/llvm-config.cpp
+++ b/tools/llvm-config/llvm-config.cpp
@@ -20,6 +20,7 @@
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/StringMap.h"
#include "llvm/ADT/StringRef.h"
+#include "llvm/ADT/Triple.h"
#include "llvm/ADT/Twine.h"
#include "llvm/Config/config.h"
#include "llvm/Config/llvm-config.h"
@@ -147,6 +148,7 @@ Options:\n\
--cflags C compiler flags for files that include LLVM headers.\n\
--cxxflags C++ compiler flags for files that include LLVM headers.\n\
--ldflags Print Linker flags.\n\
+ --system-libs System Libraries needed to link against LLVM components.\n\
--libs Libraries needed to link against LLVM components.\n\
--libnames Bare library names for in-tree builds.\n\
--libfiles Fully qualified library filenames for makefile depends.\n\
@@ -154,6 +156,7 @@ Options:\n\
--targets-built List of all targets currently built.\n\
--host-target Target triple used to configure LLVM.\n\
--build-mode Print build mode of LLVM tree (e.g. Debug or Release).\n\
+ --assertion-mode Print assertion mode of LLVM tree (ON or OFF).\n\
Typical components:\n\
all All LLVM libraries (default).\n\
engine Either a native JIT or a bitcode interpreter.\n";
@@ -171,6 +174,7 @@ std::string GetExecutablePath(const char *Argv0) {
int main(int argc, char **argv) {
std::vector<StringRef> Components;
bool PrintLibs = false, PrintLibNames = false, PrintLibFiles = false;
+ bool PrintSystemLibs = false;
bool HasAnyOption = false;
// llvm-config is designed to support being run both from a development tree
@@ -183,6 +187,13 @@ int main(int argc, char **argv) {
std::string CurrentExecPrefix;
std::string ActiveObjRoot;
+ // If CMAKE_CFG_INTDIR is given, honor it as build mode.
+ char const *build_mode = LLVM_BUILDMODE;
+#if defined(CMAKE_CFG_INTDIR)
+ if (!(CMAKE_CFG_INTDIR[0] == '.' && CMAKE_CFG_INTDIR[1] == '\0'))
+ build_mode = CMAKE_CFG_INTDIR;
+#endif
+
// Create an absolute path, and pop up one directory (we expect to be inside a
// bin dir).
sys::fs::make_absolute(CurrentPath);
@@ -192,7 +203,7 @@ int main(int argc, char **argv) {
// Check to see if we are inside a development tree by comparing to possible
// locations (prefix style or CMake style).
if (sys::fs::equivalent(CurrentExecPrefix,
- Twine(LLVM_OBJ_ROOT) + "/" + LLVM_BUILDMODE)) {
+ Twine(LLVM_OBJ_ROOT) + "/" + build_mode)) {
IsInDevelopmentTree = true;
DevelopmentTreeLayout = MakefileStyle;
@@ -230,16 +241,18 @@ int main(int argc, char **argv) {
// layout.
switch (DevelopmentTreeLayout) {
case MakefileStyle:
- ActiveBinDir = ActiveObjRoot + "/" + LLVM_BUILDMODE + "/bin";
- ActiveLibDir = ActiveObjRoot + "/" + LLVM_BUILDMODE + "/lib";
+ ActivePrefix = ActiveObjRoot;
+ ActiveBinDir = ActiveObjRoot + "/" + build_mode + "/bin";
+ ActiveLibDir = ActiveObjRoot + "/" + build_mode + "/lib";
break;
case CMakeStyle:
ActiveBinDir = ActiveObjRoot + "/bin";
ActiveLibDir = ActiveObjRoot + "/lib";
break;
case CMakeBuildModeStyle:
- ActiveBinDir = ActiveObjRoot + "/bin/" + LLVM_BUILDMODE;
- ActiveLibDir = ActiveObjRoot + "/lib/" + LLVM_BUILDMODE;
+ ActivePrefix = ActiveObjRoot;
+ ActiveBinDir = ActiveObjRoot + "/bin/" + build_mode;
+ ActiveLibDir = ActiveObjRoot + "/lib/" + build_mode;
break;
}
@@ -277,8 +290,9 @@ int main(int argc, char **argv) {
} else if (Arg == "--cxxflags") {
OS << ActiveIncludeOption << ' ' << LLVM_CXXFLAGS << '\n';
} else if (Arg == "--ldflags") {
- OS << "-L" << ActiveLibDir << ' ' << LLVM_LDFLAGS
- << ' ' << LLVM_SYSTEM_LIBS << '\n';
+ OS << "-L" << ActiveLibDir << ' ' << LLVM_LDFLAGS << '\n';
+ } else if (Arg == "--system-libs") {
+ PrintSystemLibs = true;
} else if (Arg == "--libs") {
PrintLibs = true;
} else if (Arg == "--libnames") {
@@ -298,11 +312,17 @@ int main(int argc, char **argv) {
} else if (Arg == "--targets-built") {
OS << LLVM_TARGETS_BUILT << '\n';
} else if (Arg == "--host-target") {
- OS << LLVM_DEFAULT_TARGET_TRIPLE << '\n';
+ OS << Triple::normalize(LLVM_DEFAULT_TARGET_TRIPLE) << '\n';
} else if (Arg == "--build-mode") {
- OS << LLVM_BUILDMODE << '\n';
+ OS << build_mode << '\n';
+ } else if (Arg == "--assertion-mode") {
+#if defined(NDEBUG)
+ OS << "OFF\n";
+#else
+ OS << "ON\n";
+#endif
} else if (Arg == "--obj-root") {
- OS << LLVM_OBJ_ROOT << '\n';
+ OS << ActivePrefix << '\n';
} else if (Arg == "--src-root") {
OS << LLVM_SRC_ROOT << '\n';
} else {
@@ -316,7 +336,7 @@ int main(int argc, char **argv) {
if (!HasAnyOption)
usage();
- if (PrintLibs || PrintLibNames || PrintLibFiles) {
+ if (PrintLibs || PrintLibNames || PrintLibFiles || PrintSystemLibs) {
// If no components were specified, default to "all".
if (Components.empty())
Components.push_back("all");
@@ -326,27 +346,34 @@ int main(int argc, char **argv) {
ComputeLibsForComponents(Components, RequiredLibs,
/*IncludeNonInstalled=*/IsInDevelopmentTree);
- for (unsigned i = 0, e = RequiredLibs.size(); i != e; ++i) {
- StringRef Lib = RequiredLibs[i];
- if (i)
- OS << ' ';
-
- if (PrintLibNames) {
- OS << Lib;
- } else if (PrintLibFiles) {
- OS << ActiveLibDir << '/' << Lib;
- } else if (PrintLibs) {
- // If this is a typical library name, include it using -l.
- if (Lib.startswith("lib") && Lib.endswith(".a")) {
- OS << "-l" << Lib.slice(3, Lib.size()-2);
- continue;
- }
+ if (PrintLibs || PrintLibNames || PrintLibFiles) {
+ for (unsigned i = 0, e = RequiredLibs.size(); i != e; ++i) {
+ StringRef Lib = RequiredLibs[i];
+ if (i)
+ OS << ' ';
- // Otherwise, print the full path.
- OS << ActiveLibDir << '/' << Lib;
+ if (PrintLibNames) {
+ OS << Lib;
+ } else if (PrintLibFiles) {
+ OS << ActiveLibDir << '/' << Lib;
+ } else if (PrintLibs) {
+ // If this is a typical library name, include it using -l.
+ if (Lib.startswith("lib") && Lib.endswith(".a")) {
+ OS << "-l" << Lib.slice(3, Lib.size()-2);
+ continue;
+ }
+
+ // Otherwise, print the full path.
+ OS << ActiveLibDir << '/' << Lib;
+ }
}
+ OS << '\n';
}
- OS << '\n';
+
+ // Print SYSTEM_LIBS after --libs.
+ // FIXME: Each LLVM component may have its dependent system libs.
+ if (PrintSystemLibs)
+ OS << LLVM_SYSTEM_LIBS << '\n';
} else if (!Components.empty()) {
errs() << "llvm-config: error: components given, but unused\n\n";
usage();