2011-12-02 04:18:09 +08:00
|
|
|
//===-- llvm-config.cpp - LLVM project configuration utility --------------===//
|
|
|
|
//
|
2019-01-19 16:50:56 +08:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2011-12-02 04:18:09 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This tool encapsulates information about an LLVM project configuration for
|
|
|
|
// use by other project's build environments (to determine installed path,
|
|
|
|
// available features, required libraries, etc.).
|
|
|
|
//
|
|
|
|
// Note that although this tool *may* be used by some parts of LLVM's build
|
|
|
|
// itself (i.e., the Makefiles use it to compute required libraries when linking
|
|
|
|
// tools), this tool is primarily designed to support external projects.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2018-06-24 00:50:09 +08:00
|
|
|
#include "llvm/Config/llvm-config.h"
|
2011-12-02 04:18:09 +08:00
|
|
|
#include "llvm/ADT/STLExtras.h"
|
|
|
|
#include "llvm/ADT/StringMap.h"
|
|
|
|
#include "llvm/ADT/StringRef.h"
|
2014-03-29 09:08:53 +08:00
|
|
|
#include "llvm/ADT/Triple.h"
|
2011-12-02 04:18:09 +08:00
|
|
|
#include "llvm/ADT/Twine.h"
|
|
|
|
#include "llvm/Config/config.h"
|
|
|
|
#include "llvm/Support/FileSystem.h"
|
|
|
|
#include "llvm/Support/Path.h"
|
2018-06-24 00:50:09 +08:00
|
|
|
#include "llvm/Support/WithColor.h"
|
2011-12-02 04:18:09 +08:00
|
|
|
#include "llvm/Support/raw_ostream.h"
|
|
|
|
#include <cstdlib>
|
|
|
|
#include <set>
|
2016-01-12 15:23:58 +08:00
|
|
|
#include <unordered_set>
|
tools/llvm-config: improve shared library support
Summary:
This is a re-commit of r257003, which was reverted,
along with the fixes from http://reviews.llvm.org/D15986.
r252532 added support for reporting the monolithic library
when LLVM_BUILD_LLVM_DYLIB is used. This would only be done
if the individual components were not found, and the dynamic
library is found.
This diff extends this as follows:
- If LLVM_LINK_LLVM_DYLIB is set, then prefer the shared
library, even if all component libraries exist.
- Two flags, --link-shared and --link-static are introduced
to provide explicit guidance. If --link-shared is passed
and the shared library does not exist, an error results.
Additionally, changed the expected shared library names from
(e.g.) LLVM-3.8.0 to LLVM-3.8. The former exists only in an
installation (and then only in CMake builds I think?), and not
in the build tree; this breaks usage of llvm-config during
builds, e.g. by llvm-go.
Reviewers: DiamondLovesYou, beanz
Subscribers: llvm-commits
Differential Revision: http://reviews.llvm.org/D15986
llvm-svn: 258283
2016-01-20 12:03:09 +08:00
|
|
|
#include <vector>
|
2011-12-02 04:18:09 +08:00
|
|
|
|
|
|
|
using namespace llvm;
|
|
|
|
|
|
|
|
// Include the build time variables we can report to the user. This is generated
|
|
|
|
// at build time from the BuildVariables.inc.in file by the build system.
|
|
|
|
#include "BuildVariables.inc"
|
|
|
|
|
|
|
|
// Include the component table. This creates an array of struct
|
|
|
|
// AvailableComponent entries, which record the component name, library name,
|
|
|
|
// and required components for all of the available libraries.
|
|
|
|
//
|
|
|
|
// Not all components define a library, we also use "library groups" as a way to
|
|
|
|
// create entries for pseudo groups like x86 or all-targets.
|
|
|
|
#include "LibraryDependencies.inc"
|
|
|
|
|
tools/llvm-config: improve shared library support
Summary:
This is a re-commit of r257003, which was reverted,
along with the fixes from http://reviews.llvm.org/D15986.
r252532 added support for reporting the monolithic library
when LLVM_BUILD_LLVM_DYLIB is used. This would only be done
if the individual components were not found, and the dynamic
library is found.
This diff extends this as follows:
- If LLVM_LINK_LLVM_DYLIB is set, then prefer the shared
library, even if all component libraries exist.
- Two flags, --link-shared and --link-static are introduced
to provide explicit guidance. If --link-shared is passed
and the shared library does not exist, an error results.
Additionally, changed the expected shared library names from
(e.g.) LLVM-3.8.0 to LLVM-3.8. The former exists only in an
installation (and then only in CMake builds I think?), and not
in the build tree; this breaks usage of llvm-config during
builds, e.g. by llvm-go.
Reviewers: DiamondLovesYou, beanz
Subscribers: llvm-commits
Differential Revision: http://reviews.llvm.org/D15986
llvm-svn: 258283
2016-01-20 12:03:09 +08:00
|
|
|
// LinkMode determines what libraries and flags are returned by llvm-config.
|
|
|
|
enum LinkMode {
|
|
|
|
// LinkModeAuto will link with the default link mode for the installation,
|
|
|
|
// which is dependent on the value of LLVM_LINK_LLVM_DYLIB, and fall back
|
|
|
|
// to the alternative if the required libraries are not available.
|
|
|
|
LinkModeAuto = 0,
|
|
|
|
|
|
|
|
// LinkModeShared will link with the dynamic component libraries if they
|
|
|
|
// exist, and return an error otherwise.
|
|
|
|
LinkModeShared = 1,
|
|
|
|
|
|
|
|
// LinkModeStatic will link with the static component libraries if they
|
|
|
|
// exist, and return an error otherwise.
|
|
|
|
LinkModeStatic = 2,
|
|
|
|
};
|
|
|
|
|
2018-05-01 23:54:18 +08:00
|
|
|
/// Traverse a single component adding to the topological ordering in
|
2011-12-02 04:18:09 +08:00
|
|
|
/// \arg RequiredLibs.
|
|
|
|
///
|
|
|
|
/// \param Name - The component to traverse.
|
|
|
|
/// \param ComponentMap - A prebuilt map of component names to descriptors.
|
|
|
|
/// \param VisitedComponents [in] [out] - The set of already visited components.
|
Fix `llvm-config` to adapt to the install environment.
Summary:
This patch does a couple of things:
- Adds a new argument `--shared-mode` which accepts a list of components and prints whether or not the provided components need to be linked statically or shared.
- Fixes `--libnames` when CMake BUILD_SHARED_LIBS is used.
- Fixes `--libnames`, `--libs`, and `--libfiles` for dylib when static components aren't installed.
- Fixes `--libnames`, `--libs`, `--libfiles`, and `--components` to use LLVM_DYLIB_COMPONENTS as the component manifest for dylib linking.
- Uses the host platform's usual convention for filename extensions and such, instead of always defaulting to Unix-izms.
Because I don't own a Mac, I am not able to test the Mac platform dependent stuff locally. If someone would be willing to run a build for me on their machine (unless there's a better option), I'd appreciate it.
Reviewers: jfb, brad.king, whitequark, beanz
Subscribers: beanz, jauhien, llvm-commits
Differential Revision: http://reviews.llvm.org/D13198
llvm-svn: 252532
2015-11-10 07:15:38 +08:00
|
|
|
/// \param RequiredLibs [out] - The ordered list of required
|
|
|
|
/// libraries.
|
|
|
|
/// \param GetComponentNames - Get the component names instead of the
|
|
|
|
/// library name.
|
tools/llvm-config: improve shared library support
Summary:
This is a re-commit of r257003, which was reverted,
along with the fixes from http://reviews.llvm.org/D15986.
r252532 added support for reporting the monolithic library
when LLVM_BUILD_LLVM_DYLIB is used. This would only be done
if the individual components were not found, and the dynamic
library is found.
This diff extends this as follows:
- If LLVM_LINK_LLVM_DYLIB is set, then prefer the shared
library, even if all component libraries exist.
- Two flags, --link-shared and --link-static are introduced
to provide explicit guidance. If --link-shared is passed
and the shared library does not exist, an error results.
Additionally, changed the expected shared library names from
(e.g.) LLVM-3.8.0 to LLVM-3.8. The former exists only in an
installation (and then only in CMake builds I think?), and not
in the build tree; this breaks usage of llvm-config during
builds, e.g. by llvm-go.
Reviewers: DiamondLovesYou, beanz
Subscribers: llvm-commits
Differential Revision: http://reviews.llvm.org/D15986
llvm-svn: 258283
2016-01-20 12:03:09 +08:00
|
|
|
static void VisitComponent(const std::string &Name,
|
|
|
|
const StringMap<AvailableComponent *> &ComponentMap,
|
|
|
|
std::set<AvailableComponent *> &VisitedComponents,
|
2015-11-26 06:49:48 +08:00
|
|
|
std::vector<std::string> &RequiredLibs,
|
Fix `llvm-config` to adapt to the install environment.
Summary:
This patch does a couple of things:
- Adds a new argument `--shared-mode` which accepts a list of components and prints whether or not the provided components need to be linked statically or shared.
- Fixes `--libnames` when CMake BUILD_SHARED_LIBS is used.
- Fixes `--libnames`, `--libs`, and `--libfiles` for dylib when static components aren't installed.
- Fixes `--libnames`, `--libs`, `--libfiles`, and `--components` to use LLVM_DYLIB_COMPONENTS as the component manifest for dylib linking.
- Uses the host platform's usual convention for filename extensions and such, instead of always defaulting to Unix-izms.
Because I don't own a Mac, I am not able to test the Mac platform dependent stuff locally. If someone would be willing to run a build for me on their machine (unless there's a better option), I'd appreciate it.
Reviewers: jfb, brad.king, whitequark, beanz
Subscribers: beanz, jauhien, llvm-commits
Differential Revision: http://reviews.llvm.org/D13198
llvm-svn: 252532
2015-11-10 07:15:38 +08:00
|
|
|
bool IncludeNonInstalled, bool GetComponentNames,
|
tools/llvm-config: improve shared library support
Summary:
This is a re-commit of r257003, which was reverted,
along with the fixes from http://reviews.llvm.org/D15986.
r252532 added support for reporting the monolithic library
when LLVM_BUILD_LLVM_DYLIB is used. This would only be done
if the individual components were not found, and the dynamic
library is found.
This diff extends this as follows:
- If LLVM_LINK_LLVM_DYLIB is set, then prefer the shared
library, even if all component libraries exist.
- Two flags, --link-shared and --link-static are introduced
to provide explicit guidance. If --link-shared is passed
and the shared library does not exist, an error results.
Additionally, changed the expected shared library names from
(e.g.) LLVM-3.8.0 to LLVM-3.8. The former exists only in an
installation (and then only in CMake builds I think?), and not
in the build tree; this breaks usage of llvm-config during
builds, e.g. by llvm-go.
Reviewers: DiamondLovesYou, beanz
Subscribers: llvm-commits
Differential Revision: http://reviews.llvm.org/D15986
llvm-svn: 258283
2016-01-20 12:03:09 +08:00
|
|
|
const std::function<std::string(const StringRef &)>
|
|
|
|
*GetComponentLibraryPath,
|
2016-02-10 03:41:14 +08:00
|
|
|
std::vector<std::string> *Missing,
|
|
|
|
const std::string &DirSep) {
|
2011-12-02 04:18:09 +08:00
|
|
|
// Lookup the component.
|
|
|
|
AvailableComponent *AC = ComponentMap.lookup(Name);
|
2016-02-13 02:43:10 +08:00
|
|
|
if (!AC) {
|
|
|
|
errs() << "Can't find component: '" << Name << "' in the map. Available components are: ";
|
|
|
|
for (const auto &Component : ComponentMap) {
|
|
|
|
errs() << "'" << Component.first() << "' ";
|
|
|
|
}
|
|
|
|
errs() << "\n";
|
|
|
|
report_fatal_error("abort");
|
|
|
|
}
|
2011-12-02 04:18:09 +08:00
|
|
|
assert(AC && "Invalid component name!");
|
|
|
|
|
|
|
|
// Add to the visited table.
|
|
|
|
if (!VisitedComponents.insert(AC).second) {
|
|
|
|
// We are done if the component has already been visited.
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-05-16 02:44:17 +08:00
|
|
|
// Only include non-installed components if requested.
|
|
|
|
if (!AC->IsInstalled && !IncludeNonInstalled)
|
|
|
|
return;
|
|
|
|
|
2011-12-02 04:18:09 +08:00
|
|
|
// Otherwise, visit all the dependencies.
|
|
|
|
for (unsigned i = 0; AC->RequiredLibraries[i]; ++i) {
|
|
|
|
VisitComponent(AC->RequiredLibraries[i], ComponentMap, VisitedComponents,
|
Fix `llvm-config` to adapt to the install environment.
Summary:
This patch does a couple of things:
- Adds a new argument `--shared-mode` which accepts a list of components and prints whether or not the provided components need to be linked statically or shared.
- Fixes `--libnames` when CMake BUILD_SHARED_LIBS is used.
- Fixes `--libnames`, `--libs`, and `--libfiles` for dylib when static components aren't installed.
- Fixes `--libnames`, `--libs`, `--libfiles`, and `--components` to use LLVM_DYLIB_COMPONENTS as the component manifest for dylib linking.
- Uses the host platform's usual convention for filename extensions and such, instead of always defaulting to Unix-izms.
Because I don't own a Mac, I am not able to test the Mac platform dependent stuff locally. If someone would be willing to run a build for me on their machine (unless there's a better option), I'd appreciate it.
Reviewers: jfb, brad.king, whitequark, beanz
Subscribers: beanz, jauhien, llvm-commits
Differential Revision: http://reviews.llvm.org/D13198
llvm-svn: 252532
2015-11-10 07:15:38 +08:00
|
|
|
RequiredLibs, IncludeNonInstalled, GetComponentNames,
|
2016-02-10 03:41:14 +08:00
|
|
|
GetComponentLibraryPath, Missing, DirSep);
|
Fix `llvm-config` to adapt to the install environment.
Summary:
This patch does a couple of things:
- Adds a new argument `--shared-mode` which accepts a list of components and prints whether or not the provided components need to be linked statically or shared.
- Fixes `--libnames` when CMake BUILD_SHARED_LIBS is used.
- Fixes `--libnames`, `--libs`, and `--libfiles` for dylib when static components aren't installed.
- Fixes `--libnames`, `--libs`, `--libfiles`, and `--components` to use LLVM_DYLIB_COMPONENTS as the component manifest for dylib linking.
- Uses the host platform's usual convention for filename extensions and such, instead of always defaulting to Unix-izms.
Because I don't own a Mac, I am not able to test the Mac platform dependent stuff locally. If someone would be willing to run a build for me on their machine (unless there's a better option), I'd appreciate it.
Reviewers: jfb, brad.king, whitequark, beanz
Subscribers: beanz, jauhien, llvm-commits
Differential Revision: http://reviews.llvm.org/D13198
llvm-svn: 252532
2015-11-10 07:15:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (GetComponentNames) {
|
|
|
|
RequiredLibs.push_back(Name);
|
|
|
|
return;
|
2011-12-02 04:18:09 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Add to the required library list.
|
Fix `llvm-config` to adapt to the install environment.
Summary:
This patch does a couple of things:
- Adds a new argument `--shared-mode` which accepts a list of components and prints whether or not the provided components need to be linked statically or shared.
- Fixes `--libnames` when CMake BUILD_SHARED_LIBS is used.
- Fixes `--libnames`, `--libs`, and `--libfiles` for dylib when static components aren't installed.
- Fixes `--libnames`, `--libs`, `--libfiles`, and `--components` to use LLVM_DYLIB_COMPONENTS as the component manifest for dylib linking.
- Uses the host platform's usual convention for filename extensions and such, instead of always defaulting to Unix-izms.
Because I don't own a Mac, I am not able to test the Mac platform dependent stuff locally. If someone would be willing to run a build for me on their machine (unless there's a better option), I'd appreciate it.
Reviewers: jfb, brad.king, whitequark, beanz
Subscribers: beanz, jauhien, llvm-commits
Differential Revision: http://reviews.llvm.org/D13198
llvm-svn: 252532
2015-11-10 07:15:38 +08:00
|
|
|
if (AC->Library) {
|
tools/llvm-config: improve shared library support
Summary:
This is a re-commit of r257003, which was reverted,
along with the fixes from http://reviews.llvm.org/D15986.
r252532 added support for reporting the monolithic library
when LLVM_BUILD_LLVM_DYLIB is used. This would only be done
if the individual components were not found, and the dynamic
library is found.
This diff extends this as follows:
- If LLVM_LINK_LLVM_DYLIB is set, then prefer the shared
library, even if all component libraries exist.
- Two flags, --link-shared and --link-static are introduced
to provide explicit guidance. If --link-shared is passed
and the shared library does not exist, an error results.
Additionally, changed the expected shared library names from
(e.g.) LLVM-3.8.0 to LLVM-3.8. The former exists only in an
installation (and then only in CMake builds I think?), and not
in the build tree; this breaks usage of llvm-config during
builds, e.g. by llvm-go.
Reviewers: DiamondLovesYou, beanz
Subscribers: llvm-commits
Differential Revision: http://reviews.llvm.org/D15986
llvm-svn: 258283
2016-01-20 12:03:09 +08:00
|
|
|
if (Missing && GetComponentLibraryPath) {
|
|
|
|
std::string path = (*GetComponentLibraryPath)(AC->Library);
|
2016-02-10 03:41:14 +08:00
|
|
|
if (DirSep == "\\") {
|
|
|
|
std::replace(path.begin(), path.end(), '/', '\\');
|
|
|
|
}
|
tools/llvm-config: improve shared library support
Summary:
This is a re-commit of r257003, which was reverted,
along with the fixes from http://reviews.llvm.org/D15986.
r252532 added support for reporting the monolithic library
when LLVM_BUILD_LLVM_DYLIB is used. This would only be done
if the individual components were not found, and the dynamic
library is found.
This diff extends this as follows:
- If LLVM_LINK_LLVM_DYLIB is set, then prefer the shared
library, even if all component libraries exist.
- Two flags, --link-shared and --link-static are introduced
to provide explicit guidance. If --link-shared is passed
and the shared library does not exist, an error results.
Additionally, changed the expected shared library names from
(e.g.) LLVM-3.8.0 to LLVM-3.8. The former exists only in an
installation (and then only in CMake builds I think?), and not
in the build tree; this breaks usage of llvm-config during
builds, e.g. by llvm-go.
Reviewers: DiamondLovesYou, beanz
Subscribers: llvm-commits
Differential Revision: http://reviews.llvm.org/D15986
llvm-svn: 258283
2016-01-20 12:03:09 +08:00
|
|
|
if (!sys::fs::exists(path))
|
|
|
|
Missing->push_back(path);
|
Fix `llvm-config` to adapt to the install environment.
Summary:
This patch does a couple of things:
- Adds a new argument `--shared-mode` which accepts a list of components and prints whether or not the provided components need to be linked statically or shared.
- Fixes `--libnames` when CMake BUILD_SHARED_LIBS is used.
- Fixes `--libnames`, `--libs`, and `--libfiles` for dylib when static components aren't installed.
- Fixes `--libnames`, `--libs`, `--libfiles`, and `--components` to use LLVM_DYLIB_COMPONENTS as the component manifest for dylib linking.
- Uses the host platform's usual convention for filename extensions and such, instead of always defaulting to Unix-izms.
Because I don't own a Mac, I am not able to test the Mac platform dependent stuff locally. If someone would be willing to run a build for me on their machine (unless there's a better option), I'd appreciate it.
Reviewers: jfb, brad.king, whitequark, beanz
Subscribers: beanz, jauhien, llvm-commits
Differential Revision: http://reviews.llvm.org/D13198
llvm-svn: 252532
2015-11-10 07:15:38 +08:00
|
|
|
}
|
2011-12-02 04:18:09 +08:00
|
|
|
RequiredLibs.push_back(AC->Library);
|
Fix `llvm-config` to adapt to the install environment.
Summary:
This patch does a couple of things:
- Adds a new argument `--shared-mode` which accepts a list of components and prints whether or not the provided components need to be linked statically or shared.
- Fixes `--libnames` when CMake BUILD_SHARED_LIBS is used.
- Fixes `--libnames`, `--libs`, and `--libfiles` for dylib when static components aren't installed.
- Fixes `--libnames`, `--libs`, `--libfiles`, and `--components` to use LLVM_DYLIB_COMPONENTS as the component manifest for dylib linking.
- Uses the host platform's usual convention for filename extensions and such, instead of always defaulting to Unix-izms.
Because I don't own a Mac, I am not able to test the Mac platform dependent stuff locally. If someone would be willing to run a build for me on their machine (unless there's a better option), I'd appreciate it.
Reviewers: jfb, brad.king, whitequark, beanz
Subscribers: beanz, jauhien, llvm-commits
Differential Revision: http://reviews.llvm.org/D13198
llvm-svn: 252532
2015-11-10 07:15:38 +08:00
|
|
|
}
|
2011-12-02 04:18:09 +08:00
|
|
|
}
|
|
|
|
|
2018-05-01 23:54:18 +08:00
|
|
|
/// Compute the list of required libraries for a given list of
|
2011-12-02 04:18:09 +08:00
|
|
|
/// components, in an order suitable for passing to a linker (that is, libraries
|
|
|
|
/// appear prior to their dependencies).
|
|
|
|
///
|
|
|
|
/// \param Components - The names of the components to find libraries for.
|
2012-05-16 02:44:17 +08:00
|
|
|
/// \param IncludeNonInstalled - Whether non-installed components should be
|
|
|
|
/// reported.
|
Fix `llvm-config` to adapt to the install environment.
Summary:
This patch does a couple of things:
- Adds a new argument `--shared-mode` which accepts a list of components and prints whether or not the provided components need to be linked statically or shared.
- Fixes `--libnames` when CMake BUILD_SHARED_LIBS is used.
- Fixes `--libnames`, `--libs`, and `--libfiles` for dylib when static components aren't installed.
- Fixes `--libnames`, `--libs`, `--libfiles`, and `--components` to use LLVM_DYLIB_COMPONENTS as the component manifest for dylib linking.
- Uses the host platform's usual convention for filename extensions and such, instead of always defaulting to Unix-izms.
Because I don't own a Mac, I am not able to test the Mac platform dependent stuff locally. If someone would be willing to run a build for me on their machine (unless there's a better option), I'd appreciate it.
Reviewers: jfb, brad.king, whitequark, beanz
Subscribers: beanz, jauhien, llvm-commits
Differential Revision: http://reviews.llvm.org/D13198
llvm-svn: 252532
2015-11-10 07:15:38 +08:00
|
|
|
/// \param GetComponentNames - True if one would prefer the component names.
|
2016-02-10 03:41:14 +08:00
|
|
|
static std::vector<std::string> ComputeLibsForComponents(
|
|
|
|
const std::vector<StringRef> &Components, bool IncludeNonInstalled,
|
|
|
|
bool GetComponentNames, const std::function<std::string(const StringRef &)>
|
|
|
|
*GetComponentLibraryPath,
|
|
|
|
std::vector<std::string> *Missing, const std::string &DirSep) {
|
2015-11-26 06:49:48 +08:00
|
|
|
std::vector<std::string> RequiredLibs;
|
2015-11-10 07:51:45 +08:00
|
|
|
std::set<AvailableComponent *> VisitedComponents;
|
2011-12-02 04:18:09 +08:00
|
|
|
|
|
|
|
// Build a map of component names to information.
|
tools/llvm-config: improve shared library support
Summary:
This is a re-commit of r257003, which was reverted,
along with the fixes from http://reviews.llvm.org/D15986.
r252532 added support for reporting the monolithic library
when LLVM_BUILD_LLVM_DYLIB is used. This would only be done
if the individual components were not found, and the dynamic
library is found.
This diff extends this as follows:
- If LLVM_LINK_LLVM_DYLIB is set, then prefer the shared
library, even if all component libraries exist.
- Two flags, --link-shared and --link-static are introduced
to provide explicit guidance. If --link-shared is passed
and the shared library does not exist, an error results.
Additionally, changed the expected shared library names from
(e.g.) LLVM-3.8.0 to LLVM-3.8. The former exists only in an
installation (and then only in CMake builds I think?), and not
in the build tree; this breaks usage of llvm-config during
builds, e.g. by llvm-go.
Reviewers: DiamondLovesYou, beanz
Subscribers: llvm-commits
Differential Revision: http://reviews.llvm.org/D15986
llvm-svn: 258283
2016-01-20 12:03:09 +08:00
|
|
|
StringMap<AvailableComponent *> ComponentMap;
|
2011-12-02 04:18:09 +08:00
|
|
|
for (unsigned i = 0; i != array_lengthof(AvailableComponents); ++i) {
|
|
|
|
AvailableComponent *AC = &AvailableComponents[i];
|
|
|
|
ComponentMap[AC->Name] = AC;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Visit the components.
|
|
|
|
for (unsigned i = 0, e = Components.size(); i != e; ++i) {
|
|
|
|
// Users are allowed to provide mixed case component names.
|
|
|
|
std::string ComponentLower = Components[i].lower();
|
|
|
|
|
|
|
|
// Validate that the user supplied a valid component name.
|
|
|
|
if (!ComponentMap.count(ComponentLower)) {
|
|
|
|
llvm::errs() << "llvm-config: unknown component name: " << Components[i]
|
|
|
|
<< "\n";
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
VisitComponent(ComponentLower, ComponentMap, VisitedComponents,
|
Fix `llvm-config` to adapt to the install environment.
Summary:
This patch does a couple of things:
- Adds a new argument `--shared-mode` which accepts a list of components and prints whether or not the provided components need to be linked statically or shared.
- Fixes `--libnames` when CMake BUILD_SHARED_LIBS is used.
- Fixes `--libnames`, `--libs`, and `--libfiles` for dylib when static components aren't installed.
- Fixes `--libnames`, `--libs`, `--libfiles`, and `--components` to use LLVM_DYLIB_COMPONENTS as the component manifest for dylib linking.
- Uses the host platform's usual convention for filename extensions and such, instead of always defaulting to Unix-izms.
Because I don't own a Mac, I am not able to test the Mac platform dependent stuff locally. If someone would be willing to run a build for me on their machine (unless there's a better option), I'd appreciate it.
Reviewers: jfb, brad.king, whitequark, beanz
Subscribers: beanz, jauhien, llvm-commits
Differential Revision: http://reviews.llvm.org/D13198
llvm-svn: 252532
2015-11-10 07:15:38 +08:00
|
|
|
RequiredLibs, IncludeNonInstalled, GetComponentNames,
|
2016-02-10 03:41:14 +08:00
|
|
|
GetComponentLibraryPath, Missing, DirSep);
|
2011-12-02 04:18:09 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// The list is now ordered with leafs first, we want the libraries to printed
|
|
|
|
// in the reverse order of dependency.
|
|
|
|
std::reverse(RequiredLibs.begin(), RequiredLibs.end());
|
2015-11-10 07:51:45 +08:00
|
|
|
|
|
|
|
return RequiredLibs;
|
2011-12-02 04:18:09 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* *** */
|
|
|
|
|
2015-03-10 00:23:46 +08:00
|
|
|
static void usage() {
|
2011-12-02 04:18:09 +08:00
|
|
|
errs() << "\
|
|
|
|
usage: llvm-config <OPTION>... [<COMPONENT>...]\n\
|
|
|
|
\n\
|
|
|
|
Get various configuration information needed to compile programs which use\n\
|
|
|
|
LLVM. Typically called from 'configure' scripts. Examples:\n\
|
|
|
|
llvm-config --cxxflags\n\
|
|
|
|
llvm-config --ldflags\n\
|
|
|
|
llvm-config --libs engine bcreader scalaropts\n\
|
|
|
|
\n\
|
|
|
|
Options:\n\
|
|
|
|
--version Print LLVM version.\n\
|
|
|
|
--prefix Print the installation prefix.\n\
|
|
|
|
--src-root Print the source root LLVM was built from.\n\
|
|
|
|
--obj-root Print the object root used to build LLVM.\n\
|
|
|
|
--bindir Directory containing LLVM executables.\n\
|
|
|
|
--includedir Directory containing LLVM headers.\n\
|
|
|
|
--libdir Directory containing LLVM libraries.\n\
|
2017-01-06 16:23:33 +08:00
|
|
|
--cmakedir Directory containing LLVM cmake modules.\n\
|
2011-12-02 04:18:09 +08:00
|
|
|
--cppflags C preprocessor flags for files that include LLVM headers.\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\
|
2013-12-25 10:24:32 +08:00
|
|
|
--system-libs System Libraries needed to link against LLVM components.\n\
|
2011-12-02 04:18:09 +08:00
|
|
|
--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\
|
|
|
|
--components List of all possible components.\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\
|
2013-12-04 07:22:25 +08:00
|
|
|
--assertion-mode Print assertion mode of LLVM tree (ON or OFF).\n\
|
2016-03-08 19:49:24 +08:00
|
|
|
--build-system Print the build system used to build LLVM (always cmake).\n\
|
2015-11-05 04:57:43 +08:00
|
|
|
--has-rtti Print whether or not LLVM was built with rtti (YES or NO).\n\
|
2017-01-11 03:55:51 +08:00
|
|
|
--has-global-isel Print whether or not LLVM was built with global-isel support (ON or OFF).\n\
|
Fix `llvm-config` to adapt to the install environment.
Summary:
This patch does a couple of things:
- Adds a new argument `--shared-mode` which accepts a list of components and prints whether or not the provided components need to be linked statically or shared.
- Fixes `--libnames` when CMake BUILD_SHARED_LIBS is used.
- Fixes `--libnames`, `--libs`, and `--libfiles` for dylib when static components aren't installed.
- Fixes `--libnames`, `--libs`, `--libfiles`, and `--components` to use LLVM_DYLIB_COMPONENTS as the component manifest for dylib linking.
- Uses the host platform's usual convention for filename extensions and such, instead of always defaulting to Unix-izms.
Because I don't own a Mac, I am not able to test the Mac platform dependent stuff locally. If someone would be willing to run a build for me on their machine (unless there's a better option), I'd appreciate it.
Reviewers: jfb, brad.king, whitequark, beanz
Subscribers: beanz, jauhien, llvm-commits
Differential Revision: http://reviews.llvm.org/D13198
llvm-svn: 252532
2015-11-10 07:15:38 +08:00
|
|
|
--shared-mode Print how the provided components can be collectively linked (`shared` or `static`).\n\
|
tools/llvm-config: improve shared library support
Summary:
This is a re-commit of r257003, which was reverted,
along with the fixes from http://reviews.llvm.org/D15986.
r252532 added support for reporting the monolithic library
when LLVM_BUILD_LLVM_DYLIB is used. This would only be done
if the individual components were not found, and the dynamic
library is found.
This diff extends this as follows:
- If LLVM_LINK_LLVM_DYLIB is set, then prefer the shared
library, even if all component libraries exist.
- Two flags, --link-shared and --link-static are introduced
to provide explicit guidance. If --link-shared is passed
and the shared library does not exist, an error results.
Additionally, changed the expected shared library names from
(e.g.) LLVM-3.8.0 to LLVM-3.8. The former exists only in an
installation (and then only in CMake builds I think?), and not
in the build tree; this breaks usage of llvm-config during
builds, e.g. by llvm-go.
Reviewers: DiamondLovesYou, beanz
Subscribers: llvm-commits
Differential Revision: http://reviews.llvm.org/D15986
llvm-svn: 258283
2016-01-20 12:03:09 +08:00
|
|
|
--link-shared Link the components as shared libraries.\n\
|
|
|
|
--link-static Link the component libraries statically.\n\
|
2016-12-14 06:17:59 +08:00
|
|
|
--ignore-libllvm Ignore libLLVM and link component libraries instead.\n\
|
2011-12-02 04:18:09 +08:00
|
|
|
Typical components:\n\
|
|
|
|
all All LLVM libraries (default).\n\
|
|
|
|
engine Either a native JIT or a bitcode interpreter.\n";
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
2018-05-01 23:54:18 +08:00
|
|
|
/// Compute the path to the main executable.
|
2013-06-26 13:01:35 +08:00
|
|
|
std::string GetExecutablePath(const char *Argv0) {
|
2011-12-02 04:18:09 +08:00
|
|
|
// This just needs to be some symbol in the binary; C++ doesn't
|
|
|
|
// allow taking the address of ::main however.
|
tools/llvm-config: improve shared library support
Summary:
This is a re-commit of r257003, which was reverted,
along with the fixes from http://reviews.llvm.org/D15986.
r252532 added support for reporting the monolithic library
when LLVM_BUILD_LLVM_DYLIB is used. This would only be done
if the individual components were not found, and the dynamic
library is found.
This diff extends this as follows:
- If LLVM_LINK_LLVM_DYLIB is set, then prefer the shared
library, even if all component libraries exist.
- Two flags, --link-shared and --link-static are introduced
to provide explicit guidance. If --link-shared is passed
and the shared library does not exist, an error results.
Additionally, changed the expected shared library names from
(e.g.) LLVM-3.8.0 to LLVM-3.8. The former exists only in an
installation (and then only in CMake builds I think?), and not
in the build tree; this breaks usage of llvm-config during
builds, e.g. by llvm-go.
Reviewers: DiamondLovesYou, beanz
Subscribers: llvm-commits
Differential Revision: http://reviews.llvm.org/D15986
llvm-svn: 258283
2016-01-20 12:03:09 +08:00
|
|
|
void *P = (void *)(intptr_t)GetExecutablePath;
|
2013-06-26 13:01:35 +08:00
|
|
|
return llvm::sys::fs::getMainExecutable(Argv0, P);
|
2011-12-02 04:18:09 +08:00
|
|
|
}
|
|
|
|
|
2018-05-01 23:54:18 +08:00
|
|
|
/// Expand the semi-colon delimited LLVM_DYLIB_COMPONENTS into
|
Fix `llvm-config` to adapt to the install environment.
Summary:
This patch does a couple of things:
- Adds a new argument `--shared-mode` which accepts a list of components and prints whether or not the provided components need to be linked statically or shared.
- Fixes `--libnames` when CMake BUILD_SHARED_LIBS is used.
- Fixes `--libnames`, `--libs`, and `--libfiles` for dylib when static components aren't installed.
- Fixes `--libnames`, `--libs`, `--libfiles`, and `--components` to use LLVM_DYLIB_COMPONENTS as the component manifest for dylib linking.
- Uses the host platform's usual convention for filename extensions and such, instead of always defaulting to Unix-izms.
Because I don't own a Mac, I am not able to test the Mac platform dependent stuff locally. If someone would be willing to run a build for me on their machine (unless there's a better option), I'd appreciate it.
Reviewers: jfb, brad.king, whitequark, beanz
Subscribers: beanz, jauhien, llvm-commits
Differential Revision: http://reviews.llvm.org/D13198
llvm-svn: 252532
2015-11-10 07:15:38 +08:00
|
|
|
/// the full list of components.
|
2015-11-26 06:49:48 +08:00
|
|
|
std::vector<std::string> GetAllDyLibComponents(const bool IsInDevelopmentTree,
|
2016-02-10 03:41:14 +08:00
|
|
|
const bool GetComponentNames,
|
|
|
|
const std::string &DirSep) {
|
Fix `llvm-config` to adapt to the install environment.
Summary:
This patch does a couple of things:
- Adds a new argument `--shared-mode` which accepts a list of components and prints whether or not the provided components need to be linked statically or shared.
- Fixes `--libnames` when CMake BUILD_SHARED_LIBS is used.
- Fixes `--libnames`, `--libs`, and `--libfiles` for dylib when static components aren't installed.
- Fixes `--libnames`, `--libs`, `--libfiles`, and `--components` to use LLVM_DYLIB_COMPONENTS as the component manifest for dylib linking.
- Uses the host platform's usual convention for filename extensions and such, instead of always defaulting to Unix-izms.
Because I don't own a Mac, I am not able to test the Mac platform dependent stuff locally. If someone would be willing to run a build for me on their machine (unless there's a better option), I'd appreciate it.
Reviewers: jfb, brad.king, whitequark, beanz
Subscribers: beanz, jauhien, llvm-commits
Differential Revision: http://reviews.llvm.org/D13198
llvm-svn: 252532
2015-11-10 07:15:38 +08:00
|
|
|
std::vector<StringRef> DyLibComponents;
|
|
|
|
|
2015-11-10 07:51:45 +08:00
|
|
|
StringRef DyLibComponentsStr(LLVM_DYLIB_COMPONENTS);
|
|
|
|
size_t Offset = 0;
|
|
|
|
while (true) {
|
|
|
|
const size_t NextOffset = DyLibComponentsStr.find(';', Offset);
|
2017-01-13 03:47:38 +08:00
|
|
|
DyLibComponents.push_back(DyLibComponentsStr.substr(Offset, NextOffset-Offset));
|
2015-11-10 07:51:45 +08:00
|
|
|
if (NextOffset == std::string::npos) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
Offset = NextOffset + 1;
|
Fix `llvm-config` to adapt to the install environment.
Summary:
This patch does a couple of things:
- Adds a new argument `--shared-mode` which accepts a list of components and prints whether or not the provided components need to be linked statically or shared.
- Fixes `--libnames` when CMake BUILD_SHARED_LIBS is used.
- Fixes `--libnames`, `--libs`, and `--libfiles` for dylib when static components aren't installed.
- Fixes `--libnames`, `--libs`, `--libfiles`, and `--components` to use LLVM_DYLIB_COMPONENTS as the component manifest for dylib linking.
- Uses the host platform's usual convention for filename extensions and such, instead of always defaulting to Unix-izms.
Because I don't own a Mac, I am not able to test the Mac platform dependent stuff locally. If someone would be willing to run a build for me on their machine (unless there's a better option), I'd appreciate it.
Reviewers: jfb, brad.king, whitequark, beanz
Subscribers: beanz, jauhien, llvm-commits
Differential Revision: http://reviews.llvm.org/D13198
llvm-svn: 252532
2015-11-10 07:15:38 +08:00
|
|
|
}
|
|
|
|
|
2015-11-10 07:51:45 +08:00
|
|
|
assert(!DyLibComponents.empty());
|
Fix `llvm-config` to adapt to the install environment.
Summary:
This patch does a couple of things:
- Adds a new argument `--shared-mode` which accepts a list of components and prints whether or not the provided components need to be linked statically or shared.
- Fixes `--libnames` when CMake BUILD_SHARED_LIBS is used.
- Fixes `--libnames`, `--libs`, and `--libfiles` for dylib when static components aren't installed.
- Fixes `--libnames`, `--libs`, `--libfiles`, and `--components` to use LLVM_DYLIB_COMPONENTS as the component manifest for dylib linking.
- Uses the host platform's usual convention for filename extensions and such, instead of always defaulting to Unix-izms.
Because I don't own a Mac, I am not able to test the Mac platform dependent stuff locally. If someone would be willing to run a build for me on their machine (unless there's a better option), I'd appreciate it.
Reviewers: jfb, brad.king, whitequark, beanz
Subscribers: beanz, jauhien, llvm-commits
Differential Revision: http://reviews.llvm.org/D13198
llvm-svn: 252532
2015-11-10 07:15:38 +08:00
|
|
|
|
2015-11-10 07:51:45 +08:00
|
|
|
return ComputeLibsForComponents(DyLibComponents,
|
|
|
|
/*IncludeNonInstalled=*/IsInDevelopmentTree,
|
2016-02-10 03:41:14 +08:00
|
|
|
GetComponentNames, nullptr, nullptr, DirSep);
|
Fix `llvm-config` to adapt to the install environment.
Summary:
This patch does a couple of things:
- Adds a new argument `--shared-mode` which accepts a list of components and prints whether or not the provided components need to be linked statically or shared.
- Fixes `--libnames` when CMake BUILD_SHARED_LIBS is used.
- Fixes `--libnames`, `--libs`, and `--libfiles` for dylib when static components aren't installed.
- Fixes `--libnames`, `--libs`, `--libfiles`, and `--components` to use LLVM_DYLIB_COMPONENTS as the component manifest for dylib linking.
- Uses the host platform's usual convention for filename extensions and such, instead of always defaulting to Unix-izms.
Because I don't own a Mac, I am not able to test the Mac platform dependent stuff locally. If someone would be willing to run a build for me on their machine (unless there's a better option), I'd appreciate it.
Reviewers: jfb, brad.king, whitequark, beanz
Subscribers: beanz, jauhien, llvm-commits
Differential Revision: http://reviews.llvm.org/D13198
llvm-svn: 252532
2015-11-10 07:15:38 +08:00
|
|
|
}
|
|
|
|
|
2011-12-02 04:18:09 +08:00
|
|
|
int main(int argc, char **argv) {
|
|
|
|
std::vector<StringRef> Components;
|
|
|
|
bool PrintLibs = false, PrintLibNames = false, PrintLibFiles = false;
|
Fix `llvm-config` to adapt to the install environment.
Summary:
This patch does a couple of things:
- Adds a new argument `--shared-mode` which accepts a list of components and prints whether or not the provided components need to be linked statically or shared.
- Fixes `--libnames` when CMake BUILD_SHARED_LIBS is used.
- Fixes `--libnames`, `--libs`, and `--libfiles` for dylib when static components aren't installed.
- Fixes `--libnames`, `--libs`, `--libfiles`, and `--components` to use LLVM_DYLIB_COMPONENTS as the component manifest for dylib linking.
- Uses the host platform's usual convention for filename extensions and such, instead of always defaulting to Unix-izms.
Because I don't own a Mac, I am not able to test the Mac platform dependent stuff locally. If someone would be willing to run a build for me on their machine (unless there's a better option), I'd appreciate it.
Reviewers: jfb, brad.king, whitequark, beanz
Subscribers: beanz, jauhien, llvm-commits
Differential Revision: http://reviews.llvm.org/D13198
llvm-svn: 252532
2015-11-10 07:15:38 +08:00
|
|
|
bool PrintSystemLibs = false, PrintSharedMode = false;
|
2011-12-02 04:18:09 +08:00
|
|
|
bool HasAnyOption = false;
|
|
|
|
|
|
|
|
// llvm-config is designed to support being run both from a development tree
|
|
|
|
// and from an installed path. We try and auto-detect which case we are in so
|
|
|
|
// that we can report the correct information when run from a development
|
|
|
|
// tree.
|
2012-01-26 09:31:38 +08:00
|
|
|
bool IsInDevelopmentTree;
|
2016-03-08 19:49:24 +08:00
|
|
|
enum { CMakeStyle, CMakeBuildModeStyle } DevelopmentTreeLayout;
|
2019-03-25 23:18:55 +08:00
|
|
|
llvm::SmallString<256> CurrentPath(GetExecutablePath(argv[0]));
|
2011-12-02 04:18:09 +08:00
|
|
|
std::string CurrentExecPrefix;
|
|
|
|
std::string ActiveObjRoot;
|
|
|
|
|
2013-12-17 13:48:37 +08:00
|
|
|
// 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
|
|
|
|
|
2019-03-25 23:18:55 +08:00
|
|
|
// Create an absolute path, and pop up one directory (we expect to be inside a
|
|
|
|
// bin dir).
|
|
|
|
sys::fs::make_absolute(CurrentPath);
|
|
|
|
CurrentExecPrefix =
|
|
|
|
sys::path::parent_path(sys::path::parent_path(CurrentPath)).str();
|
2011-12-02 04:18:09 +08:00
|
|
|
|
|
|
|
// Check to see if we are inside a development tree by comparing to possible
|
2012-05-16 06:07:18 +08:00
|
|
|
// locations (prefix style or CMake style).
|
2016-03-08 19:49:24 +08:00
|
|
|
if (sys::fs::equivalent(CurrentExecPrefix, LLVM_OBJ_ROOT)) {
|
2012-01-26 09:31:38 +08:00
|
|
|
IsInDevelopmentTree = true;
|
|
|
|
DevelopmentTreeLayout = CMakeStyle;
|
|
|
|
ActiveObjRoot = LLVM_OBJ_ROOT;
|
2019-08-17 01:17:45 +08:00
|
|
|
} else if (sys::fs::equivalent(sys::path::parent_path(CurrentExecPrefix),
|
|
|
|
LLVM_OBJ_ROOT)) {
|
2011-12-02 04:18:09 +08:00
|
|
|
IsInDevelopmentTree = true;
|
2012-01-26 09:31:38 +08:00
|
|
|
DevelopmentTreeLayout = CMakeBuildModeStyle;
|
2011-12-02 04:18:09 +08:00
|
|
|
ActiveObjRoot = LLVM_OBJ_ROOT;
|
|
|
|
} else {
|
|
|
|
IsInDevelopmentTree = false;
|
2016-03-08 19:49:24 +08:00
|
|
|
DevelopmentTreeLayout = CMakeStyle; // Initialized to avoid warnings.
|
2011-12-02 04:18:09 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Compute various directory locations based on the derived location
|
|
|
|
// information.
|
2017-01-06 16:23:33 +08:00
|
|
|
std::string ActivePrefix, ActiveBinDir, ActiveIncludeDir, ActiveLibDir,
|
|
|
|
ActiveCMakeDir;
|
2011-12-02 04:18:09 +08:00
|
|
|
std::string ActiveIncludeOption;
|
|
|
|
if (IsInDevelopmentTree) {
|
|
|
|
ActiveIncludeDir = std::string(LLVM_SRC_ROOT) + "/include";
|
|
|
|
ActivePrefix = CurrentExecPrefix;
|
|
|
|
|
|
|
|
// CMake organizes the products differently than a normal prefix style
|
|
|
|
// layout.
|
2012-01-26 09:31:38 +08:00
|
|
|
switch (DevelopmentTreeLayout) {
|
|
|
|
case CMakeStyle:
|
|
|
|
ActiveBinDir = ActiveObjRoot + "/bin";
|
2014-12-29 19:16:25 +08:00
|
|
|
ActiveLibDir = ActiveObjRoot + "/lib" + LLVM_LIBDIR_SUFFIX;
|
2017-01-06 16:23:33 +08:00
|
|
|
ActiveCMakeDir = ActiveLibDir + "/cmake/llvm";
|
2012-01-26 09:31:38 +08:00
|
|
|
break;
|
|
|
|
case CMakeBuildModeStyle:
|
2019-08-17 01:17:45 +08:00
|
|
|
// FIXME: Should we consider the build-mode-specific path as the prefix?
|
2013-12-20 00:02:23 +08:00
|
|
|
ActivePrefix = ActiveObjRoot;
|
2019-08-17 01:17:45 +08:00
|
|
|
ActiveBinDir = ActiveObjRoot + "/" + build_mode + "/bin";
|
2014-12-29 19:16:25 +08:00
|
|
|
ActiveLibDir =
|
2019-08-17 01:17:45 +08:00
|
|
|
ActiveObjRoot + "/" + build_mode + "/lib" + LLVM_LIBDIR_SUFFIX;
|
|
|
|
// The CMake directory isn't separated by build mode.
|
|
|
|
ActiveCMakeDir =
|
|
|
|
ActivePrefix + "/lib" + LLVM_LIBDIR_SUFFIX + "/cmake/llvm";
|
2012-01-26 09:31:38 +08:00
|
|
|
break;
|
2011-12-02 04:18:09 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// We need to include files from both the source and object trees.
|
tools/llvm-config: improve shared library support
Summary:
This is a re-commit of r257003, which was reverted,
along with the fixes from http://reviews.llvm.org/D15986.
r252532 added support for reporting the monolithic library
when LLVM_BUILD_LLVM_DYLIB is used. This would only be done
if the individual components were not found, and the dynamic
library is found.
This diff extends this as follows:
- If LLVM_LINK_LLVM_DYLIB is set, then prefer the shared
library, even if all component libraries exist.
- Two flags, --link-shared and --link-static are introduced
to provide explicit guidance. If --link-shared is passed
and the shared library does not exist, an error results.
Additionally, changed the expected shared library names from
(e.g.) LLVM-3.8.0 to LLVM-3.8. The former exists only in an
installation (and then only in CMake builds I think?), and not
in the build tree; this breaks usage of llvm-config during
builds, e.g. by llvm-go.
Reviewers: DiamondLovesYou, beanz
Subscribers: llvm-commits
Differential Revision: http://reviews.llvm.org/D15986
llvm-svn: 258283
2016-01-20 12:03:09 +08:00
|
|
|
ActiveIncludeOption =
|
|
|
|
("-I" + ActiveIncludeDir + " " + "-I" + ActiveObjRoot + "/include");
|
2011-12-02 04:18:09 +08:00
|
|
|
} else {
|
|
|
|
ActivePrefix = CurrentExecPrefix;
|
|
|
|
ActiveIncludeDir = ActivePrefix + "/include";
|
2017-06-02 04:51:55 +08:00
|
|
|
SmallString<256> path(StringRef(LLVM_TOOLS_INSTALL_DIR));
|
2017-06-02 03:20:33 +08:00
|
|
|
sys::fs::make_absolute(ActivePrefix, path);
|
|
|
|
ActiveBinDir = path.str();
|
2014-12-29 19:16:25 +08:00
|
|
|
ActiveLibDir = ActivePrefix + "/lib" + LLVM_LIBDIR_SUFFIX;
|
2017-01-06 16:23:33 +08:00
|
|
|
ActiveCMakeDir = ActiveLibDir + "/cmake/llvm";
|
2011-12-02 04:18:09 +08:00
|
|
|
ActiveIncludeOption = "-I" + ActiveIncludeDir;
|
|
|
|
}
|
|
|
|
|
Fix `llvm-config` to adapt to the install environment.
Summary:
This patch does a couple of things:
- Adds a new argument `--shared-mode` which accepts a list of components and prints whether or not the provided components need to be linked statically or shared.
- Fixes `--libnames` when CMake BUILD_SHARED_LIBS is used.
- Fixes `--libnames`, `--libs`, and `--libfiles` for dylib when static components aren't installed.
- Fixes `--libnames`, `--libs`, `--libfiles`, and `--components` to use LLVM_DYLIB_COMPONENTS as the component manifest for dylib linking.
- Uses the host platform's usual convention for filename extensions and such, instead of always defaulting to Unix-izms.
Because I don't own a Mac, I am not able to test the Mac platform dependent stuff locally. If someone would be willing to run a build for me on their machine (unless there's a better option), I'd appreciate it.
Reviewers: jfb, brad.king, whitequark, beanz
Subscribers: beanz, jauhien, llvm-commits
Differential Revision: http://reviews.llvm.org/D13198
llvm-svn: 252532
2015-11-10 07:15:38 +08:00
|
|
|
/// We only use `shared library` mode in cases where the static library form
|
|
|
|
/// of the components provided are not available; note however that this is
|
|
|
|
/// skipped if we're run from within the build dir. However, once installed,
|
|
|
|
/// we still need to provide correct output when the static archives are
|
|
|
|
/// removed or, as in the case of CMake's `BUILD_SHARED_LIBS`, never present
|
|
|
|
/// in the first place. This can't be done at configure/build time.
|
|
|
|
|
|
|
|
StringRef SharedExt, SharedVersionedExt, SharedDir, SharedPrefix, StaticExt,
|
2016-02-10 03:41:14 +08:00
|
|
|
StaticPrefix, StaticDir = "lib", DirSep = "/";
|
2016-02-10 09:12:55 +08:00
|
|
|
const Triple HostTriple(Triple::normalize(LLVM_HOST_TRIPLE));
|
Fix `llvm-config` to adapt to the install environment.
Summary:
This patch does a couple of things:
- Adds a new argument `--shared-mode` which accepts a list of components and prints whether or not the provided components need to be linked statically or shared.
- Fixes `--libnames` when CMake BUILD_SHARED_LIBS is used.
- Fixes `--libnames`, `--libs`, and `--libfiles` for dylib when static components aren't installed.
- Fixes `--libnames`, `--libs`, `--libfiles`, and `--components` to use LLVM_DYLIB_COMPONENTS as the component manifest for dylib linking.
- Uses the host platform's usual convention for filename extensions and such, instead of always defaulting to Unix-izms.
Because I don't own a Mac, I am not able to test the Mac platform dependent stuff locally. If someone would be willing to run a build for me on their machine (unless there's a better option), I'd appreciate it.
Reviewers: jfb, brad.king, whitequark, beanz
Subscribers: beanz, jauhien, llvm-commits
Differential Revision: http://reviews.llvm.org/D13198
llvm-svn: 252532
2015-11-10 07:15:38 +08:00
|
|
|
if (HostTriple.isOSWindows()) {
|
|
|
|
SharedExt = "dll";
|
tools/llvm-config: improve shared library support
Summary:
This is a re-commit of r257003, which was reverted,
along with the fixes from http://reviews.llvm.org/D15986.
r252532 added support for reporting the monolithic library
when LLVM_BUILD_LLVM_DYLIB is used. This would only be done
if the individual components were not found, and the dynamic
library is found.
This diff extends this as follows:
- If LLVM_LINK_LLVM_DYLIB is set, then prefer the shared
library, even if all component libraries exist.
- Two flags, --link-shared and --link-static are introduced
to provide explicit guidance. If --link-shared is passed
and the shared library does not exist, an error results.
Additionally, changed the expected shared library names from
(e.g.) LLVM-3.8.0 to LLVM-3.8. The former exists only in an
installation (and then only in CMake builds I think?), and not
in the build tree; this breaks usage of llvm-config during
builds, e.g. by llvm-go.
Reviewers: DiamondLovesYou, beanz
Subscribers: llvm-commits
Differential Revision: http://reviews.llvm.org/D15986
llvm-svn: 258283
2016-01-20 12:03:09 +08:00
|
|
|
SharedVersionedExt = LLVM_DYLIB_VERSION ".dll";
|
2016-02-10 03:41:14 +08:00
|
|
|
if (HostTriple.isOSCygMing()) {
|
|
|
|
StaticExt = "a";
|
2016-02-10 11:09:13 +08:00
|
|
|
StaticPrefix = "lib";
|
2016-02-10 03:41:14 +08:00
|
|
|
} else {
|
|
|
|
StaticExt = "lib";
|
|
|
|
DirSep = "\\";
|
|
|
|
std::replace(ActiveObjRoot.begin(), ActiveObjRoot.end(), '/', '\\');
|
|
|
|
std::replace(ActivePrefix.begin(), ActivePrefix.end(), '/', '\\');
|
|
|
|
std::replace(ActiveBinDir.begin(), ActiveBinDir.end(), '/', '\\');
|
|
|
|
std::replace(ActiveLibDir.begin(), ActiveLibDir.end(), '/', '\\');
|
2017-01-06 16:23:33 +08:00
|
|
|
std::replace(ActiveCMakeDir.begin(), ActiveCMakeDir.end(), '/', '\\');
|
2016-02-10 03:41:14 +08:00
|
|
|
std::replace(ActiveIncludeOption.begin(), ActiveIncludeOption.end(), '/',
|
|
|
|
'\\');
|
|
|
|
}
|
Fix `llvm-config` to adapt to the install environment.
Summary:
This patch does a couple of things:
- Adds a new argument `--shared-mode` which accepts a list of components and prints whether or not the provided components need to be linked statically or shared.
- Fixes `--libnames` when CMake BUILD_SHARED_LIBS is used.
- Fixes `--libnames`, `--libs`, and `--libfiles` for dylib when static components aren't installed.
- Fixes `--libnames`, `--libs`, `--libfiles`, and `--components` to use LLVM_DYLIB_COMPONENTS as the component manifest for dylib linking.
- Uses the host platform's usual convention for filename extensions and such, instead of always defaulting to Unix-izms.
Because I don't own a Mac, I am not able to test the Mac platform dependent stuff locally. If someone would be willing to run a build for me on their machine (unless there's a better option), I'd appreciate it.
Reviewers: jfb, brad.king, whitequark, beanz
Subscribers: beanz, jauhien, llvm-commits
Differential Revision: http://reviews.llvm.org/D13198
llvm-svn: 252532
2015-11-10 07:15:38 +08:00
|
|
|
SharedDir = ActiveBinDir;
|
|
|
|
StaticDir = ActiveLibDir;
|
|
|
|
} else if (HostTriple.isOSDarwin()) {
|
|
|
|
SharedExt = "dylib";
|
tools/llvm-config: improve shared library support
Summary:
This is a re-commit of r257003, which was reverted,
along with the fixes from http://reviews.llvm.org/D15986.
r252532 added support for reporting the monolithic library
when LLVM_BUILD_LLVM_DYLIB is used. This would only be done
if the individual components were not found, and the dynamic
library is found.
This diff extends this as follows:
- If LLVM_LINK_LLVM_DYLIB is set, then prefer the shared
library, even if all component libraries exist.
- Two flags, --link-shared and --link-static are introduced
to provide explicit guidance. If --link-shared is passed
and the shared library does not exist, an error results.
Additionally, changed the expected shared library names from
(e.g.) LLVM-3.8.0 to LLVM-3.8. The former exists only in an
installation (and then only in CMake builds I think?), and not
in the build tree; this breaks usage of llvm-config during
builds, e.g. by llvm-go.
Reviewers: DiamondLovesYou, beanz
Subscribers: llvm-commits
Differential Revision: http://reviews.llvm.org/D15986
llvm-svn: 258283
2016-01-20 12:03:09 +08:00
|
|
|
SharedVersionedExt = LLVM_DYLIB_VERSION ".dylib";
|
Fix `llvm-config` to adapt to the install environment.
Summary:
This patch does a couple of things:
- Adds a new argument `--shared-mode` which accepts a list of components and prints whether or not the provided components need to be linked statically or shared.
- Fixes `--libnames` when CMake BUILD_SHARED_LIBS is used.
- Fixes `--libnames`, `--libs`, and `--libfiles` for dylib when static components aren't installed.
- Fixes `--libnames`, `--libs`, `--libfiles`, and `--components` to use LLVM_DYLIB_COMPONENTS as the component manifest for dylib linking.
- Uses the host platform's usual convention for filename extensions and such, instead of always defaulting to Unix-izms.
Because I don't own a Mac, I am not able to test the Mac platform dependent stuff locally. If someone would be willing to run a build for me on their machine (unless there's a better option), I'd appreciate it.
Reviewers: jfb, brad.king, whitequark, beanz
Subscribers: beanz, jauhien, llvm-commits
Differential Revision: http://reviews.llvm.org/D13198
llvm-svn: 252532
2015-11-10 07:15:38 +08:00
|
|
|
StaticExt = "a";
|
|
|
|
StaticDir = SharedDir = ActiveLibDir;
|
|
|
|
StaticPrefix = SharedPrefix = "lib";
|
|
|
|
} else {
|
|
|
|
// default to the unix values:
|
|
|
|
SharedExt = "so";
|
tools/llvm-config: improve shared library support
Summary:
This is a re-commit of r257003, which was reverted,
along with the fixes from http://reviews.llvm.org/D15986.
r252532 added support for reporting the monolithic library
when LLVM_BUILD_LLVM_DYLIB is used. This would only be done
if the individual components were not found, and the dynamic
library is found.
This diff extends this as follows:
- If LLVM_LINK_LLVM_DYLIB is set, then prefer the shared
library, even if all component libraries exist.
- Two flags, --link-shared and --link-static are introduced
to provide explicit guidance. If --link-shared is passed
and the shared library does not exist, an error results.
Additionally, changed the expected shared library names from
(e.g.) LLVM-3.8.0 to LLVM-3.8. The former exists only in an
installation (and then only in CMake builds I think?), and not
in the build tree; this breaks usage of llvm-config during
builds, e.g. by llvm-go.
Reviewers: DiamondLovesYou, beanz
Subscribers: llvm-commits
Differential Revision: http://reviews.llvm.org/D15986
llvm-svn: 258283
2016-01-20 12:03:09 +08:00
|
|
|
SharedVersionedExt = LLVM_DYLIB_VERSION ".so";
|
Fix `llvm-config` to adapt to the install environment.
Summary:
This patch does a couple of things:
- Adds a new argument `--shared-mode` which accepts a list of components and prints whether or not the provided components need to be linked statically or shared.
- Fixes `--libnames` when CMake BUILD_SHARED_LIBS is used.
- Fixes `--libnames`, `--libs`, and `--libfiles` for dylib when static components aren't installed.
- Fixes `--libnames`, `--libs`, `--libfiles`, and `--components` to use LLVM_DYLIB_COMPONENTS as the component manifest for dylib linking.
- Uses the host platform's usual convention for filename extensions and such, instead of always defaulting to Unix-izms.
Because I don't own a Mac, I am not able to test the Mac platform dependent stuff locally. If someone would be willing to run a build for me on their machine (unless there's a better option), I'd appreciate it.
Reviewers: jfb, brad.king, whitequark, beanz
Subscribers: beanz, jauhien, llvm-commits
Differential Revision: http://reviews.llvm.org/D13198
llvm-svn: 252532
2015-11-10 07:15:38 +08:00
|
|
|
StaticExt = "a";
|
|
|
|
StaticDir = SharedDir = ActiveLibDir;
|
|
|
|
StaticPrefix = SharedPrefix = "lib";
|
|
|
|
}
|
|
|
|
|
2017-01-11 03:55:51 +08:00
|
|
|
const bool BuiltDyLib = !!LLVM_ENABLE_DYLIB;
|
Fix `llvm-config` to adapt to the install environment.
Summary:
This patch does a couple of things:
- Adds a new argument `--shared-mode` which accepts a list of components and prints whether or not the provided components need to be linked statically or shared.
- Fixes `--libnames` when CMake BUILD_SHARED_LIBS is used.
- Fixes `--libnames`, `--libs`, and `--libfiles` for dylib when static components aren't installed.
- Fixes `--libnames`, `--libs`, `--libfiles`, and `--components` to use LLVM_DYLIB_COMPONENTS as the component manifest for dylib linking.
- Uses the host platform's usual convention for filename extensions and such, instead of always defaulting to Unix-izms.
Because I don't own a Mac, I am not able to test the Mac platform dependent stuff locally. If someone would be willing to run a build for me on their machine (unless there's a better option), I'd appreciate it.
Reviewers: jfb, brad.king, whitequark, beanz
Subscribers: beanz, jauhien, llvm-commits
Differential Revision: http://reviews.llvm.org/D13198
llvm-svn: 252532
2015-11-10 07:15:38 +08:00
|
|
|
|
|
|
|
/// CMake style shared libs, ie each component is in a shared library.
|
2017-01-11 03:55:51 +08:00
|
|
|
const bool BuiltSharedLibs = !!LLVM_ENABLE_SHARED;
|
Fix `llvm-config` to adapt to the install environment.
Summary:
This patch does a couple of things:
- Adds a new argument `--shared-mode` which accepts a list of components and prints whether or not the provided components need to be linked statically or shared.
- Fixes `--libnames` when CMake BUILD_SHARED_LIBS is used.
- Fixes `--libnames`, `--libs`, and `--libfiles` for dylib when static components aren't installed.
- Fixes `--libnames`, `--libs`, `--libfiles`, and `--components` to use LLVM_DYLIB_COMPONENTS as the component manifest for dylib linking.
- Uses the host platform's usual convention for filename extensions and such, instead of always defaulting to Unix-izms.
Because I don't own a Mac, I am not able to test the Mac platform dependent stuff locally. If someone would be willing to run a build for me on their machine (unless there's a better option), I'd appreciate it.
Reviewers: jfb, brad.king, whitequark, beanz
Subscribers: beanz, jauhien, llvm-commits
Differential Revision: http://reviews.llvm.org/D13198
llvm-svn: 252532
2015-11-10 07:15:38 +08:00
|
|
|
|
|
|
|
bool DyLibExists = false;
|
|
|
|
const std::string DyLibName =
|
tools/llvm-config: improve shared library support
Summary:
This is a re-commit of r257003, which was reverted,
along with the fixes from http://reviews.llvm.org/D15986.
r252532 added support for reporting the monolithic library
when LLVM_BUILD_LLVM_DYLIB is used. This would only be done
if the individual components were not found, and the dynamic
library is found.
This diff extends this as follows:
- If LLVM_LINK_LLVM_DYLIB is set, then prefer the shared
library, even if all component libraries exist.
- Two flags, --link-shared and --link-static are introduced
to provide explicit guidance. If --link-shared is passed
and the shared library does not exist, an error results.
Additionally, changed the expected shared library names from
(e.g.) LLVM-3.8.0 to LLVM-3.8. The former exists only in an
installation (and then only in CMake builds I think?), and not
in the build tree; this breaks usage of llvm-config during
builds, e.g. by llvm-go.
Reviewers: DiamondLovesYou, beanz
Subscribers: llvm-commits
Differential Revision: http://reviews.llvm.org/D15986
llvm-svn: 258283
2016-01-20 12:03:09 +08:00
|
|
|
(SharedPrefix + "LLVM-" + SharedVersionedExt).str();
|
|
|
|
|
|
|
|
// If LLVM_LINK_DYLIB is ON, the single shared library will be returned
|
|
|
|
// for "--libs", etc, if they exist. This behaviour can be overridden with
|
|
|
|
// --link-static or --link-shared.
|
2017-01-11 03:55:51 +08:00
|
|
|
bool LinkDyLib = !!LLVM_LINK_DYLIB;
|
Fix `llvm-config` to adapt to the install environment.
Summary:
This patch does a couple of things:
- Adds a new argument `--shared-mode` which accepts a list of components and prints whether or not the provided components need to be linked statically or shared.
- Fixes `--libnames` when CMake BUILD_SHARED_LIBS is used.
- Fixes `--libnames`, `--libs`, and `--libfiles` for dylib when static components aren't installed.
- Fixes `--libnames`, `--libs`, `--libfiles`, and `--components` to use LLVM_DYLIB_COMPONENTS as the component manifest for dylib linking.
- Uses the host platform's usual convention for filename extensions and such, instead of always defaulting to Unix-izms.
Because I don't own a Mac, I am not able to test the Mac platform dependent stuff locally. If someone would be willing to run a build for me on their machine (unless there's a better option), I'd appreciate it.
Reviewers: jfb, brad.king, whitequark, beanz
Subscribers: beanz, jauhien, llvm-commits
Differential Revision: http://reviews.llvm.org/D13198
llvm-svn: 252532
2015-11-10 07:15:38 +08:00
|
|
|
|
|
|
|
if (BuiltDyLib) {
|
2016-02-10 03:41:14 +08:00
|
|
|
std::string path((SharedDir + DirSep + DyLibName).str());
|
|
|
|
if (DirSep == "\\") {
|
|
|
|
std::replace(path.begin(), path.end(), '/', '\\');
|
|
|
|
}
|
|
|
|
DyLibExists = sys::fs::exists(path);
|
tools/llvm-config: improve shared library support
Summary:
This is a re-commit of r257003, which was reverted,
along with the fixes from http://reviews.llvm.org/D15986.
r252532 added support for reporting the monolithic library
when LLVM_BUILD_LLVM_DYLIB is used. This would only be done
if the individual components were not found, and the dynamic
library is found.
This diff extends this as follows:
- If LLVM_LINK_LLVM_DYLIB is set, then prefer the shared
library, even if all component libraries exist.
- Two flags, --link-shared and --link-static are introduced
to provide explicit guidance. If --link-shared is passed
and the shared library does not exist, an error results.
Additionally, changed the expected shared library names from
(e.g.) LLVM-3.8.0 to LLVM-3.8. The former exists only in an
installation (and then only in CMake builds I think?), and not
in the build tree; this breaks usage of llvm-config during
builds, e.g. by llvm-go.
Reviewers: DiamondLovesYou, beanz
Subscribers: llvm-commits
Differential Revision: http://reviews.llvm.org/D15986
llvm-svn: 258283
2016-01-20 12:03:09 +08:00
|
|
|
if (!DyLibExists) {
|
|
|
|
// The shared library does not exist: don't error unless the user
|
|
|
|
// explicitly passes --link-shared.
|
|
|
|
LinkDyLib = false;
|
|
|
|
}
|
Fix `llvm-config` to adapt to the install environment.
Summary:
This patch does a couple of things:
- Adds a new argument `--shared-mode` which accepts a list of components and prints whether or not the provided components need to be linked statically or shared.
- Fixes `--libnames` when CMake BUILD_SHARED_LIBS is used.
- Fixes `--libnames`, `--libs`, and `--libfiles` for dylib when static components aren't installed.
- Fixes `--libnames`, `--libs`, `--libfiles`, and `--components` to use LLVM_DYLIB_COMPONENTS as the component manifest for dylib linking.
- Uses the host platform's usual convention for filename extensions and such, instead of always defaulting to Unix-izms.
Because I don't own a Mac, I am not able to test the Mac platform dependent stuff locally. If someone would be willing to run a build for me on their machine (unless there's a better option), I'd appreciate it.
Reviewers: jfb, brad.king, whitequark, beanz
Subscribers: beanz, jauhien, llvm-commits
Differential Revision: http://reviews.llvm.org/D13198
llvm-svn: 252532
2015-11-10 07:15:38 +08:00
|
|
|
}
|
tools/llvm-config: improve shared library support
Summary:
This is a re-commit of r257003, which was reverted,
along with the fixes from http://reviews.llvm.org/D15986.
r252532 added support for reporting the monolithic library
when LLVM_BUILD_LLVM_DYLIB is used. This would only be done
if the individual components were not found, and the dynamic
library is found.
This diff extends this as follows:
- If LLVM_LINK_LLVM_DYLIB is set, then prefer the shared
library, even if all component libraries exist.
- Two flags, --link-shared and --link-static are introduced
to provide explicit guidance. If --link-shared is passed
and the shared library does not exist, an error results.
Additionally, changed the expected shared library names from
(e.g.) LLVM-3.8.0 to LLVM-3.8. The former exists only in an
installation (and then only in CMake builds I think?), and not
in the build tree; this breaks usage of llvm-config during
builds, e.g. by llvm-go.
Reviewers: DiamondLovesYou, beanz
Subscribers: llvm-commits
Differential Revision: http://reviews.llvm.org/D15986
llvm-svn: 258283
2016-01-20 12:03:09 +08:00
|
|
|
LinkMode LinkMode =
|
|
|
|
(LinkDyLib || BuiltSharedLibs) ? LinkModeShared : LinkModeAuto;
|
Fix `llvm-config` to adapt to the install environment.
Summary:
This patch does a couple of things:
- Adds a new argument `--shared-mode` which accepts a list of components and prints whether or not the provided components need to be linked statically or shared.
- Fixes `--libnames` when CMake BUILD_SHARED_LIBS is used.
- Fixes `--libnames`, `--libs`, and `--libfiles` for dylib when static components aren't installed.
- Fixes `--libnames`, `--libs`, `--libfiles`, and `--components` to use LLVM_DYLIB_COMPONENTS as the component manifest for dylib linking.
- Uses the host platform's usual convention for filename extensions and such, instead of always defaulting to Unix-izms.
Because I don't own a Mac, I am not able to test the Mac platform dependent stuff locally. If someone would be willing to run a build for me on their machine (unless there's a better option), I'd appreciate it.
Reviewers: jfb, brad.king, whitequark, beanz
Subscribers: beanz, jauhien, llvm-commits
Differential Revision: http://reviews.llvm.org/D13198
llvm-svn: 252532
2015-11-10 07:15:38 +08:00
|
|
|
|
|
|
|
/// Get the component's library name without the lib prefix and the
|
|
|
|
/// extension. Returns true if Lib is in a recognized format.
|
|
|
|
auto GetComponentLibraryNameSlice = [&](const StringRef &Lib,
|
|
|
|
StringRef &Out) {
|
|
|
|
if (Lib.startswith("lib")) {
|
|
|
|
unsigned FromEnd;
|
|
|
|
if (Lib.endswith(StaticExt)) {
|
|
|
|
FromEnd = StaticExt.size() + 1;
|
|
|
|
} else if (Lib.endswith(SharedExt)) {
|
|
|
|
FromEnd = SharedExt.size() + 1;
|
|
|
|
} else {
|
|
|
|
FromEnd = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (FromEnd != 0) {
|
|
|
|
Out = Lib.slice(3, Lib.size() - FromEnd);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
};
|
|
|
|
/// Maps Unixizms to the host platform.
|
|
|
|
auto GetComponentLibraryFileName = [&](const StringRef &Lib,
|
tools/llvm-config: improve shared library support
Summary:
This is a re-commit of r257003, which was reverted,
along with the fixes from http://reviews.llvm.org/D15986.
r252532 added support for reporting the monolithic library
when LLVM_BUILD_LLVM_DYLIB is used. This would only be done
if the individual components were not found, and the dynamic
library is found.
This diff extends this as follows:
- If LLVM_LINK_LLVM_DYLIB is set, then prefer the shared
library, even if all component libraries exist.
- Two flags, --link-shared and --link-static are introduced
to provide explicit guidance. If --link-shared is passed
and the shared library does not exist, an error results.
Additionally, changed the expected shared library names from
(e.g.) LLVM-3.8.0 to LLVM-3.8. The former exists only in an
installation (and then only in CMake builds I think?), and not
in the build tree; this breaks usage of llvm-config during
builds, e.g. by llvm-go.
Reviewers: DiamondLovesYou, beanz
Subscribers: llvm-commits
Differential Revision: http://reviews.llvm.org/D15986
llvm-svn: 258283
2016-01-20 12:03:09 +08:00
|
|
|
const bool Shared) {
|
2016-02-10 03:41:14 +08:00
|
|
|
std::string LibFileName;
|
|
|
|
if (Shared) {
|
2016-12-13 07:07:22 +08:00
|
|
|
if (Lib == DyLibName) {
|
|
|
|
// Treat the DyLibName specially. It is not a component library and
|
|
|
|
// already has the necessary prefix and suffix (e.g. `.so`) added so
|
|
|
|
// just return it unmodified.
|
|
|
|
assert(Lib.endswith(SharedExt) && "DyLib is missing suffix");
|
|
|
|
LibFileName = Lib;
|
|
|
|
} else {
|
|
|
|
LibFileName = (SharedPrefix + Lib + "." + SharedExt).str();
|
|
|
|
}
|
2016-02-10 03:41:14 +08:00
|
|
|
} else {
|
|
|
|
// default to static
|
|
|
|
LibFileName = (StaticPrefix + Lib + "." + StaticExt).str();
|
Fix `llvm-config` to adapt to the install environment.
Summary:
This patch does a couple of things:
- Adds a new argument `--shared-mode` which accepts a list of components and prints whether or not the provided components need to be linked statically or shared.
- Fixes `--libnames` when CMake BUILD_SHARED_LIBS is used.
- Fixes `--libnames`, `--libs`, and `--libfiles` for dylib when static components aren't installed.
- Fixes `--libnames`, `--libs`, `--libfiles`, and `--components` to use LLVM_DYLIB_COMPONENTS as the component manifest for dylib linking.
- Uses the host platform's usual convention for filename extensions and such, instead of always defaulting to Unix-izms.
Because I don't own a Mac, I am not able to test the Mac platform dependent stuff locally. If someone would be willing to run a build for me on their machine (unless there's a better option), I'd appreciate it.
Reviewers: jfb, brad.king, whitequark, beanz
Subscribers: beanz, jauhien, llvm-commits
Differential Revision: http://reviews.llvm.org/D13198
llvm-svn: 252532
2015-11-10 07:15:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return LibFileName;
|
|
|
|
};
|
|
|
|
/// Get the full path for a possibly shared component library.
|
tools/llvm-config: improve shared library support
Summary:
This is a re-commit of r257003, which was reverted,
along with the fixes from http://reviews.llvm.org/D15986.
r252532 added support for reporting the monolithic library
when LLVM_BUILD_LLVM_DYLIB is used. This would only be done
if the individual components were not found, and the dynamic
library is found.
This diff extends this as follows:
- If LLVM_LINK_LLVM_DYLIB is set, then prefer the shared
library, even if all component libraries exist.
- Two flags, --link-shared and --link-static are introduced
to provide explicit guidance. If --link-shared is passed
and the shared library does not exist, an error results.
Additionally, changed the expected shared library names from
(e.g.) LLVM-3.8.0 to LLVM-3.8. The former exists only in an
installation (and then only in CMake builds I think?), and not
in the build tree; this breaks usage of llvm-config during
builds, e.g. by llvm-go.
Reviewers: DiamondLovesYou, beanz
Subscribers: llvm-commits
Differential Revision: http://reviews.llvm.org/D15986
llvm-svn: 258283
2016-01-20 12:03:09 +08:00
|
|
|
auto GetComponentLibraryPath = [&](const StringRef &Name, const bool Shared) {
|
|
|
|
auto LibFileName = GetComponentLibraryFileName(Name, Shared);
|
|
|
|
if (Shared) {
|
2016-02-10 03:41:14 +08:00
|
|
|
return (SharedDir + DirSep + LibFileName).str();
|
Fix `llvm-config` to adapt to the install environment.
Summary:
This patch does a couple of things:
- Adds a new argument `--shared-mode` which accepts a list of components and prints whether or not the provided components need to be linked statically or shared.
- Fixes `--libnames` when CMake BUILD_SHARED_LIBS is used.
- Fixes `--libnames`, `--libs`, and `--libfiles` for dylib when static components aren't installed.
- Fixes `--libnames`, `--libs`, `--libfiles`, and `--components` to use LLVM_DYLIB_COMPONENTS as the component manifest for dylib linking.
- Uses the host platform's usual convention for filename extensions and such, instead of always defaulting to Unix-izms.
Because I don't own a Mac, I am not able to test the Mac platform dependent stuff locally. If someone would be willing to run a build for me on their machine (unless there's a better option), I'd appreciate it.
Reviewers: jfb, brad.king, whitequark, beanz
Subscribers: beanz, jauhien, llvm-commits
Differential Revision: http://reviews.llvm.org/D13198
llvm-svn: 252532
2015-11-10 07:15:38 +08:00
|
|
|
} else {
|
2016-02-10 03:41:14 +08:00
|
|
|
return (StaticDir + DirSep + LibFileName).str();
|
Fix `llvm-config` to adapt to the install environment.
Summary:
This patch does a couple of things:
- Adds a new argument `--shared-mode` which accepts a list of components and prints whether or not the provided components need to be linked statically or shared.
- Fixes `--libnames` when CMake BUILD_SHARED_LIBS is used.
- Fixes `--libnames`, `--libs`, and `--libfiles` for dylib when static components aren't installed.
- Fixes `--libnames`, `--libs`, `--libfiles`, and `--components` to use LLVM_DYLIB_COMPONENTS as the component manifest for dylib linking.
- Uses the host platform's usual convention for filename extensions and such, instead of always defaulting to Unix-izms.
Because I don't own a Mac, I am not able to test the Mac platform dependent stuff locally. If someone would be willing to run a build for me on their machine (unless there's a better option), I'd appreciate it.
Reviewers: jfb, brad.king, whitequark, beanz
Subscribers: beanz, jauhien, llvm-commits
Differential Revision: http://reviews.llvm.org/D13198
llvm-svn: 252532
2015-11-10 07:15:38 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2011-12-02 04:18:09 +08:00
|
|
|
raw_ostream &OS = outs();
|
|
|
|
for (int i = 1; i != argc; ++i) {
|
|
|
|
StringRef Arg = argv[i];
|
|
|
|
|
|
|
|
if (Arg.startswith("-")) {
|
|
|
|
HasAnyOption = true;
|
|
|
|
if (Arg == "--version") {
|
|
|
|
OS << PACKAGE_VERSION << '\n';
|
|
|
|
} else if (Arg == "--prefix") {
|
|
|
|
OS << ActivePrefix << '\n';
|
|
|
|
} else if (Arg == "--bindir") {
|
|
|
|
OS << ActiveBinDir << '\n';
|
|
|
|
} else if (Arg == "--includedir") {
|
|
|
|
OS << ActiveIncludeDir << '\n';
|
|
|
|
} else if (Arg == "--libdir") {
|
|
|
|
OS << ActiveLibDir << '\n';
|
2017-01-06 16:23:33 +08:00
|
|
|
} else if (Arg == "--cmakedir") {
|
|
|
|
OS << ActiveCMakeDir << '\n';
|
2011-12-02 04:18:09 +08:00
|
|
|
} else if (Arg == "--cppflags") {
|
|
|
|
OS << ActiveIncludeOption << ' ' << LLVM_CPPFLAGS << '\n';
|
|
|
|
} else if (Arg == "--cflags") {
|
|
|
|
OS << ActiveIncludeOption << ' ' << LLVM_CFLAGS << '\n';
|
|
|
|
} else if (Arg == "--cxxflags") {
|
|
|
|
OS << ActiveIncludeOption << ' ' << LLVM_CXXFLAGS << '\n';
|
|
|
|
} else if (Arg == "--ldflags") {
|
2016-02-10 03:41:14 +08:00
|
|
|
OS << ((HostTriple.isWindowsMSVCEnvironment()) ? "-LIBPATH:" : "-L")
|
|
|
|
<< ActiveLibDir << ' ' << LLVM_LDFLAGS << '\n';
|
2013-12-19 16:46:36 +08:00
|
|
|
} else if (Arg == "--system-libs") {
|
|
|
|
PrintSystemLibs = true;
|
2011-12-02 04:18:09 +08:00
|
|
|
} else if (Arg == "--libs") {
|
|
|
|
PrintLibs = true;
|
|
|
|
} else if (Arg == "--libnames") {
|
|
|
|
PrintLibNames = true;
|
|
|
|
} else if (Arg == "--libfiles") {
|
|
|
|
PrintLibFiles = true;
|
|
|
|
} else if (Arg == "--components") {
|
Fix `llvm-config` to adapt to the install environment.
Summary:
This patch does a couple of things:
- Adds a new argument `--shared-mode` which accepts a list of components and prints whether or not the provided components need to be linked statically or shared.
- Fixes `--libnames` when CMake BUILD_SHARED_LIBS is used.
- Fixes `--libnames`, `--libs`, and `--libfiles` for dylib when static components aren't installed.
- Fixes `--libnames`, `--libs`, `--libfiles`, and `--components` to use LLVM_DYLIB_COMPONENTS as the component manifest for dylib linking.
- Uses the host platform's usual convention for filename extensions and such, instead of always defaulting to Unix-izms.
Because I don't own a Mac, I am not able to test the Mac platform dependent stuff locally. If someone would be willing to run a build for me on their machine (unless there's a better option), I'd appreciate it.
Reviewers: jfb, brad.king, whitequark, beanz
Subscribers: beanz, jauhien, llvm-commits
Differential Revision: http://reviews.llvm.org/D13198
llvm-svn: 252532
2015-11-10 07:15:38 +08:00
|
|
|
/// If there are missing static archives and a dylib was
|
|
|
|
/// built, print LLVM_DYLIB_COMPONENTS instead of everything
|
|
|
|
/// in the manifest.
|
2015-11-26 06:49:48 +08:00
|
|
|
std::vector<std::string> Components;
|
2011-12-02 04:18:09 +08:00
|
|
|
for (unsigned j = 0; j != array_lengthof(AvailableComponents); ++j) {
|
2012-05-16 02:44:17 +08:00
|
|
|
// Only include non-installed components when in a development tree.
|
|
|
|
if (!AvailableComponents[j].IsInstalled && !IsInDevelopmentTree)
|
|
|
|
continue;
|
|
|
|
|
Fix `llvm-config` to adapt to the install environment.
Summary:
This patch does a couple of things:
- Adds a new argument `--shared-mode` which accepts a list of components and prints whether or not the provided components need to be linked statically or shared.
- Fixes `--libnames` when CMake BUILD_SHARED_LIBS is used.
- Fixes `--libnames`, `--libs`, and `--libfiles` for dylib when static components aren't installed.
- Fixes `--libnames`, `--libs`, `--libfiles`, and `--components` to use LLVM_DYLIB_COMPONENTS as the component manifest for dylib linking.
- Uses the host platform's usual convention for filename extensions and such, instead of always defaulting to Unix-izms.
Because I don't own a Mac, I am not able to test the Mac platform dependent stuff locally. If someone would be willing to run a build for me on their machine (unless there's a better option), I'd appreciate it.
Reviewers: jfb, brad.king, whitequark, beanz
Subscribers: beanz, jauhien, llvm-commits
Differential Revision: http://reviews.llvm.org/D13198
llvm-svn: 252532
2015-11-10 07:15:38 +08:00
|
|
|
Components.push_back(AvailableComponents[j].Name);
|
|
|
|
if (AvailableComponents[j].Library && !IsInDevelopmentTree) {
|
2016-02-10 03:41:14 +08:00
|
|
|
std::string path(
|
|
|
|
GetComponentLibraryPath(AvailableComponents[j].Library, false));
|
|
|
|
if (DirSep == "\\") {
|
|
|
|
std::replace(path.begin(), path.end(), '/', '\\');
|
|
|
|
}
|
|
|
|
if (DyLibExists && !sys::fs::exists(path)) {
|
|
|
|
Components =
|
|
|
|
GetAllDyLibComponents(IsInDevelopmentTree, true, DirSep);
|
llvm::sort(C.begin(), C.end(), ...) -> llvm::sort(C, ...)
Summary: The convenience wrapper in STLExtras is available since rL342102.
Reviewers: dblaikie, javed.absar, JDevlieghere, andreadb
Subscribers: MatzeB, sanjoy, arsenm, dschuff, mehdi_amini, sdardis, nemanjai, jvesely, nhaehnle, sbc100, jgravelle-google, eraman, aheejin, kbarton, JDevlieghere, javed.absar, gbedwell, jrtc27, mgrang, atanasyan, steven_wu, george.burgess.iv, dexonsmith, kristina, jsji, llvm-commits
Differential Revision: https://reviews.llvm.org/D52573
llvm-svn: 343163
2018-09-27 10:13:45 +08:00
|
|
|
llvm::sort(Components);
|
Fix `llvm-config` to adapt to the install environment.
Summary:
This patch does a couple of things:
- Adds a new argument `--shared-mode` which accepts a list of components and prints whether or not the provided components need to be linked statically or shared.
- Fixes `--libnames` when CMake BUILD_SHARED_LIBS is used.
- Fixes `--libnames`, `--libs`, and `--libfiles` for dylib when static components aren't installed.
- Fixes `--libnames`, `--libs`, `--libfiles`, and `--components` to use LLVM_DYLIB_COMPONENTS as the component manifest for dylib linking.
- Uses the host platform's usual convention for filename extensions and such, instead of always defaulting to Unix-izms.
Because I don't own a Mac, I am not able to test the Mac platform dependent stuff locally. If someone would be willing to run a build for me on their machine (unless there's a better option), I'd appreciate it.
Reviewers: jfb, brad.king, whitequark, beanz
Subscribers: beanz, jauhien, llvm-commits
Differential Revision: http://reviews.llvm.org/D13198
llvm-svn: 252532
2015-11-10 07:15:38 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (unsigned I = 0; I < Components.size(); ++I) {
|
|
|
|
if (I) {
|
|
|
|
OS << ' ';
|
|
|
|
}
|
|
|
|
|
|
|
|
OS << Components[I];
|
2011-12-02 04:18:09 +08:00
|
|
|
}
|
|
|
|
OS << '\n';
|
|
|
|
} else if (Arg == "--targets-built") {
|
2011-12-16 08:04:43 +08:00
|
|
|
OS << LLVM_TARGETS_BUILT << '\n';
|
2011-12-02 04:18:09 +08:00
|
|
|
} else if (Arg == "--host-target") {
|
2014-03-29 09:08:53 +08:00
|
|
|
OS << Triple::normalize(LLVM_DEFAULT_TARGET_TRIPLE) << '\n';
|
2011-12-02 04:18:09 +08:00
|
|
|
} else if (Arg == "--build-mode") {
|
2013-12-03 22:35:17 +08:00
|
|
|
OS << build_mode << '\n';
|
2013-12-04 07:22:25 +08:00
|
|
|
} else if (Arg == "--assertion-mode") {
|
|
|
|
#if defined(NDEBUG)
|
|
|
|
OS << "OFF\n";
|
|
|
|
#else
|
|
|
|
OS << "ON\n";
|
|
|
|
#endif
|
2015-09-10 00:39:30 +08:00
|
|
|
} else if (Arg == "--build-system") {
|
|
|
|
OS << LLVM_BUILD_SYSTEM << '\n';
|
2015-11-05 04:57:43 +08:00
|
|
|
} else if (Arg == "--has-rtti") {
|
2017-01-11 03:55:51 +08:00
|
|
|
OS << (LLVM_HAS_RTTI ? "YES" : "NO") << '\n';
|
2016-03-08 08:02:50 +08:00
|
|
|
} else if (Arg == "--has-global-isel") {
|
2017-01-11 03:55:51 +08:00
|
|
|
OS << (LLVM_HAS_GLOBAL_ISEL ? "ON" : "OFF") << '\n';
|
Fix `llvm-config` to adapt to the install environment.
Summary:
This patch does a couple of things:
- Adds a new argument `--shared-mode` which accepts a list of components and prints whether or not the provided components need to be linked statically or shared.
- Fixes `--libnames` when CMake BUILD_SHARED_LIBS is used.
- Fixes `--libnames`, `--libs`, and `--libfiles` for dylib when static components aren't installed.
- Fixes `--libnames`, `--libs`, `--libfiles`, and `--components` to use LLVM_DYLIB_COMPONENTS as the component manifest for dylib linking.
- Uses the host platform's usual convention for filename extensions and such, instead of always defaulting to Unix-izms.
Because I don't own a Mac, I am not able to test the Mac platform dependent stuff locally. If someone would be willing to run a build for me on their machine (unless there's a better option), I'd appreciate it.
Reviewers: jfb, brad.king, whitequark, beanz
Subscribers: beanz, jauhien, llvm-commits
Differential Revision: http://reviews.llvm.org/D13198
llvm-svn: 252532
2015-11-10 07:15:38 +08:00
|
|
|
} else if (Arg == "--shared-mode") {
|
|
|
|
PrintSharedMode = true;
|
2011-12-02 04:18:09 +08:00
|
|
|
} else if (Arg == "--obj-root") {
|
2013-12-20 00:02:28 +08:00
|
|
|
OS << ActivePrefix << '\n';
|
2011-12-02 04:18:09 +08:00
|
|
|
} else if (Arg == "--src-root") {
|
|
|
|
OS << LLVM_SRC_ROOT << '\n';
|
2016-12-14 07:01:53 +08:00
|
|
|
} else if (Arg == "--ignore-libllvm") {
|
|
|
|
LinkDyLib = false;
|
|
|
|
LinkMode = BuiltSharedLibs ? LinkModeShared : LinkModeAuto;
|
tools/llvm-config: improve shared library support
Summary:
This is a re-commit of r257003, which was reverted,
along with the fixes from http://reviews.llvm.org/D15986.
r252532 added support for reporting the monolithic library
when LLVM_BUILD_LLVM_DYLIB is used. This would only be done
if the individual components were not found, and the dynamic
library is found.
This diff extends this as follows:
- If LLVM_LINK_LLVM_DYLIB is set, then prefer the shared
library, even if all component libraries exist.
- Two flags, --link-shared and --link-static are introduced
to provide explicit guidance. If --link-shared is passed
and the shared library does not exist, an error results.
Additionally, changed the expected shared library names from
(e.g.) LLVM-3.8.0 to LLVM-3.8. The former exists only in an
installation (and then only in CMake builds I think?), and not
in the build tree; this breaks usage of llvm-config during
builds, e.g. by llvm-go.
Reviewers: DiamondLovesYou, beanz
Subscribers: llvm-commits
Differential Revision: http://reviews.llvm.org/D15986
llvm-svn: 258283
2016-01-20 12:03:09 +08:00
|
|
|
} else if (Arg == "--link-shared") {
|
|
|
|
LinkMode = LinkModeShared;
|
|
|
|
} else if (Arg == "--link-static") {
|
|
|
|
LinkMode = LinkModeStatic;
|
2011-12-02 04:18:09 +08:00
|
|
|
} else {
|
|
|
|
usage();
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
Components.push_back(Arg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!HasAnyOption)
|
|
|
|
usage();
|
|
|
|
|
tools/llvm-config: improve shared library support
Summary:
This is a re-commit of r257003, which was reverted,
along with the fixes from http://reviews.llvm.org/D15986.
r252532 added support for reporting the monolithic library
when LLVM_BUILD_LLVM_DYLIB is used. This would only be done
if the individual components were not found, and the dynamic
library is found.
This diff extends this as follows:
- If LLVM_LINK_LLVM_DYLIB is set, then prefer the shared
library, even if all component libraries exist.
- Two flags, --link-shared and --link-static are introduced
to provide explicit guidance. If --link-shared is passed
and the shared library does not exist, an error results.
Additionally, changed the expected shared library names from
(e.g.) LLVM-3.8.0 to LLVM-3.8. The former exists only in an
installation (and then only in CMake builds I think?), and not
in the build tree; this breaks usage of llvm-config during
builds, e.g. by llvm-go.
Reviewers: DiamondLovesYou, beanz
Subscribers: llvm-commits
Differential Revision: http://reviews.llvm.org/D15986
llvm-svn: 258283
2016-01-20 12:03:09 +08:00
|
|
|
if (LinkMode == LinkModeShared && !DyLibExists && !BuiltSharedLibs) {
|
2018-06-24 00:50:09 +08:00
|
|
|
WithColor::error(errs(), "llvm-config") << DyLibName << " is missing\n";
|
tools/llvm-config: improve shared library support
Summary:
This is a re-commit of r257003, which was reverted,
along with the fixes from http://reviews.llvm.org/D15986.
r252532 added support for reporting the monolithic library
when LLVM_BUILD_LLVM_DYLIB is used. This would only be done
if the individual components were not found, and the dynamic
library is found.
This diff extends this as follows:
- If LLVM_LINK_LLVM_DYLIB is set, then prefer the shared
library, even if all component libraries exist.
- Two flags, --link-shared and --link-static are introduced
to provide explicit guidance. If --link-shared is passed
and the shared library does not exist, an error results.
Additionally, changed the expected shared library names from
(e.g.) LLVM-3.8.0 to LLVM-3.8. The former exists only in an
installation (and then only in CMake builds I think?), and not
in the build tree; this breaks usage of llvm-config during
builds, e.g. by llvm-go.
Reviewers: DiamondLovesYou, beanz
Subscribers: llvm-commits
Differential Revision: http://reviews.llvm.org/D15986
llvm-svn: 258283
2016-01-20 12:03:09 +08:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
Fix `llvm-config` to adapt to the install environment.
Summary:
This patch does a couple of things:
- Adds a new argument `--shared-mode` which accepts a list of components and prints whether or not the provided components need to be linked statically or shared.
- Fixes `--libnames` when CMake BUILD_SHARED_LIBS is used.
- Fixes `--libnames`, `--libs`, and `--libfiles` for dylib when static components aren't installed.
- Fixes `--libnames`, `--libs`, `--libfiles`, and `--components` to use LLVM_DYLIB_COMPONENTS as the component manifest for dylib linking.
- Uses the host platform's usual convention for filename extensions and such, instead of always defaulting to Unix-izms.
Because I don't own a Mac, I am not able to test the Mac platform dependent stuff locally. If someone would be willing to run a build for me on their machine (unless there's a better option), I'd appreciate it.
Reviewers: jfb, brad.king, whitequark, beanz
Subscribers: beanz, jauhien, llvm-commits
Differential Revision: http://reviews.llvm.org/D13198
llvm-svn: 252532
2015-11-10 07:15:38 +08:00
|
|
|
if (PrintLibs || PrintLibNames || PrintLibFiles || PrintSystemLibs ||
|
|
|
|
PrintSharedMode) {
|
|
|
|
|
|
|
|
if (PrintSharedMode && BuiltSharedLibs) {
|
|
|
|
OS << "shared\n";
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-12-13 02:22:04 +08:00
|
|
|
// If no components were specified, default to "all".
|
|
|
|
if (Components.empty())
|
|
|
|
Components.push_back("all");
|
|
|
|
|
2011-12-02 04:18:09 +08:00
|
|
|
// Construct the list of all the required libraries.
|
tools/llvm-config: improve shared library support
Summary:
This is a re-commit of r257003, which was reverted,
along with the fixes from http://reviews.llvm.org/D15986.
r252532 added support for reporting the monolithic library
when LLVM_BUILD_LLVM_DYLIB is used. This would only be done
if the individual components were not found, and the dynamic
library is found.
This diff extends this as follows:
- If LLVM_LINK_LLVM_DYLIB is set, then prefer the shared
library, even if all component libraries exist.
- Two flags, --link-shared and --link-static are introduced
to provide explicit guidance. If --link-shared is passed
and the shared library does not exist, an error results.
Additionally, changed the expected shared library names from
(e.g.) LLVM-3.8.0 to LLVM-3.8. The former exists only in an
installation (and then only in CMake builds I think?), and not
in the build tree; this breaks usage of llvm-config during
builds, e.g. by llvm-go.
Reviewers: DiamondLovesYou, beanz
Subscribers: llvm-commits
Differential Revision: http://reviews.llvm.org/D15986
llvm-svn: 258283
2016-01-20 12:03:09 +08:00
|
|
|
std::function<std::string(const StringRef &)>
|
|
|
|
GetComponentLibraryPathFunction = [&](const StringRef &Name) {
|
|
|
|
return GetComponentLibraryPath(Name, LinkMode == LinkModeShared);
|
|
|
|
};
|
|
|
|
std::vector<std::string> MissingLibs;
|
|
|
|
std::vector<std::string> RequiredLibs = ComputeLibsForComponents(
|
|
|
|
Components,
|
|
|
|
/*IncludeNonInstalled=*/IsInDevelopmentTree, false,
|
2016-02-10 03:41:14 +08:00
|
|
|
&GetComponentLibraryPathFunction, &MissingLibs, DirSep);
|
tools/llvm-config: improve shared library support
Summary:
This is a re-commit of r257003, which was reverted,
along with the fixes from http://reviews.llvm.org/D15986.
r252532 added support for reporting the monolithic library
when LLVM_BUILD_LLVM_DYLIB is used. This would only be done
if the individual components were not found, and the dynamic
library is found.
This diff extends this as follows:
- If LLVM_LINK_LLVM_DYLIB is set, then prefer the shared
library, even if all component libraries exist.
- Two flags, --link-shared and --link-static are introduced
to provide explicit guidance. If --link-shared is passed
and the shared library does not exist, an error results.
Additionally, changed the expected shared library names from
(e.g.) LLVM-3.8.0 to LLVM-3.8. The former exists only in an
installation (and then only in CMake builds I think?), and not
in the build tree; this breaks usage of llvm-config during
builds, e.g. by llvm-go.
Reviewers: DiamondLovesYou, beanz
Subscribers: llvm-commits
Differential Revision: http://reviews.llvm.org/D15986
llvm-svn: 258283
2016-01-20 12:03:09 +08:00
|
|
|
if (!MissingLibs.empty()) {
|
|
|
|
switch (LinkMode) {
|
|
|
|
case LinkModeShared:
|
2016-12-14 07:08:52 +08:00
|
|
|
if (LinkDyLib && !BuiltSharedLibs)
|
tools/llvm-config: improve shared library support
Summary:
This is a re-commit of r257003, which was reverted,
along with the fixes from http://reviews.llvm.org/D15986.
r252532 added support for reporting the monolithic library
when LLVM_BUILD_LLVM_DYLIB is used. This would only be done
if the individual components were not found, and the dynamic
library is found.
This diff extends this as follows:
- If LLVM_LINK_LLVM_DYLIB is set, then prefer the shared
library, even if all component libraries exist.
- Two flags, --link-shared and --link-static are introduced
to provide explicit guidance. If --link-shared is passed
and the shared library does not exist, an error results.
Additionally, changed the expected shared library names from
(e.g.) LLVM-3.8.0 to LLVM-3.8. The former exists only in an
installation (and then only in CMake builds I think?), and not
in the build tree; this breaks usage of llvm-config during
builds, e.g. by llvm-go.
Reviewers: DiamondLovesYou, beanz
Subscribers: llvm-commits
Differential Revision: http://reviews.llvm.org/D15986
llvm-svn: 258283
2016-01-20 12:03:09 +08:00
|
|
|
break;
|
|
|
|
// Using component shared libraries.
|
|
|
|
for (auto &Lib : MissingLibs)
|
2018-06-24 00:50:09 +08:00
|
|
|
WithColor::error(errs(), "llvm-config") << "missing: " << Lib << "\n";
|
tools/llvm-config: improve shared library support
Summary:
This is a re-commit of r257003, which was reverted,
along with the fixes from http://reviews.llvm.org/D15986.
r252532 added support for reporting the monolithic library
when LLVM_BUILD_LLVM_DYLIB is used. This would only be done
if the individual components were not found, and the dynamic
library is found.
This diff extends this as follows:
- If LLVM_LINK_LLVM_DYLIB is set, then prefer the shared
library, even if all component libraries exist.
- Two flags, --link-shared and --link-static are introduced
to provide explicit guidance. If --link-shared is passed
and the shared library does not exist, an error results.
Additionally, changed the expected shared library names from
(e.g.) LLVM-3.8.0 to LLVM-3.8. The former exists only in an
installation (and then only in CMake builds I think?), and not
in the build tree; this breaks usage of llvm-config during
builds, e.g. by llvm-go.
Reviewers: DiamondLovesYou, beanz
Subscribers: llvm-commits
Differential Revision: http://reviews.llvm.org/D15986
llvm-svn: 258283
2016-01-20 12:03:09 +08:00
|
|
|
return 1;
|
|
|
|
case LinkModeAuto:
|
|
|
|
if (DyLibExists) {
|
|
|
|
LinkMode = LinkModeShared;
|
|
|
|
break;
|
|
|
|
}
|
2018-06-24 00:50:09 +08:00
|
|
|
WithColor::error(errs(), "llvm-config")
|
|
|
|
<< "component libraries and shared library\n\n";
|
2016-08-18 04:30:52 +08:00
|
|
|
LLVM_FALLTHROUGH;
|
tools/llvm-config: improve shared library support
Summary:
This is a re-commit of r257003, which was reverted,
along with the fixes from http://reviews.llvm.org/D15986.
r252532 added support for reporting the monolithic library
when LLVM_BUILD_LLVM_DYLIB is used. This would only be done
if the individual components were not found, and the dynamic
library is found.
This diff extends this as follows:
- If LLVM_LINK_LLVM_DYLIB is set, then prefer the shared
library, even if all component libraries exist.
- Two flags, --link-shared and --link-static are introduced
to provide explicit guidance. If --link-shared is passed
and the shared library does not exist, an error results.
Additionally, changed the expected shared library names from
(e.g.) LLVM-3.8.0 to LLVM-3.8. The former exists only in an
installation (and then only in CMake builds I think?), and not
in the build tree; this breaks usage of llvm-config during
builds, e.g. by llvm-go.
Reviewers: DiamondLovesYou, beanz
Subscribers: llvm-commits
Differential Revision: http://reviews.llvm.org/D15986
llvm-svn: 258283
2016-01-20 12:03:09 +08:00
|
|
|
case LinkModeStatic:
|
|
|
|
for (auto &Lib : MissingLibs)
|
2018-06-24 00:50:09 +08:00
|
|
|
WithColor::error(errs(), "llvm-config") << "missing: " << Lib << "\n";
|
tools/llvm-config: improve shared library support
Summary:
This is a re-commit of r257003, which was reverted,
along with the fixes from http://reviews.llvm.org/D15986.
r252532 added support for reporting the monolithic library
when LLVM_BUILD_LLVM_DYLIB is used. This would only be done
if the individual components were not found, and the dynamic
library is found.
This diff extends this as follows:
- If LLVM_LINK_LLVM_DYLIB is set, then prefer the shared
library, even if all component libraries exist.
- Two flags, --link-shared and --link-static are introduced
to provide explicit guidance. If --link-shared is passed
and the shared library does not exist, an error results.
Additionally, changed the expected shared library names from
(e.g.) LLVM-3.8.0 to LLVM-3.8. The former exists only in an
installation (and then only in CMake builds I think?), and not
in the build tree; this breaks usage of llvm-config during
builds, e.g. by llvm-go.
Reviewers: DiamondLovesYou, beanz
Subscribers: llvm-commits
Differential Revision: http://reviews.llvm.org/D15986
llvm-svn: 258283
2016-01-20 12:03:09 +08:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
} else if (LinkMode == LinkModeAuto) {
|
|
|
|
LinkMode = LinkModeStatic;
|
|
|
|
}
|
Fix `llvm-config` to adapt to the install environment.
Summary:
This patch does a couple of things:
- Adds a new argument `--shared-mode` which accepts a list of components and prints whether or not the provided components need to be linked statically or shared.
- Fixes `--libnames` when CMake BUILD_SHARED_LIBS is used.
- Fixes `--libnames`, `--libs`, and `--libfiles` for dylib when static components aren't installed.
- Fixes `--libnames`, `--libs`, `--libfiles`, and `--components` to use LLVM_DYLIB_COMPONENTS as the component manifest for dylib linking.
- Uses the host platform's usual convention for filename extensions and such, instead of always defaulting to Unix-izms.
Because I don't own a Mac, I am not able to test the Mac platform dependent stuff locally. If someone would be willing to run a build for me on their machine (unless there's a better option), I'd appreciate it.
Reviewers: jfb, brad.king, whitequark, beanz
Subscribers: beanz, jauhien, llvm-commits
Differential Revision: http://reviews.llvm.org/D13198
llvm-svn: 252532
2015-11-10 07:15:38 +08:00
|
|
|
|
|
|
|
if (PrintSharedMode) {
|
|
|
|
std::unordered_set<std::string> FullDyLibComponents;
|
2015-11-26 06:49:48 +08:00
|
|
|
std::vector<std::string> DyLibComponents =
|
2016-02-10 03:41:14 +08:00
|
|
|
GetAllDyLibComponents(IsInDevelopmentTree, false, DirSep);
|
Fix `llvm-config` to adapt to the install environment.
Summary:
This patch does a couple of things:
- Adds a new argument `--shared-mode` which accepts a list of components and prints whether or not the provided components need to be linked statically or shared.
- Fixes `--libnames` when CMake BUILD_SHARED_LIBS is used.
- Fixes `--libnames`, `--libs`, and `--libfiles` for dylib when static components aren't installed.
- Fixes `--libnames`, `--libs`, `--libfiles`, and `--components` to use LLVM_DYLIB_COMPONENTS as the component manifest for dylib linking.
- Uses the host platform's usual convention for filename extensions and such, instead of always defaulting to Unix-izms.
Because I don't own a Mac, I am not able to test the Mac platform dependent stuff locally. If someone would be willing to run a build for me on their machine (unless there's a better option), I'd appreciate it.
Reviewers: jfb, brad.king, whitequark, beanz
Subscribers: beanz, jauhien, llvm-commits
Differential Revision: http://reviews.llvm.org/D13198
llvm-svn: 252532
2015-11-10 07:15:38 +08:00
|
|
|
|
|
|
|
for (auto &Component : DyLibComponents) {
|
|
|
|
FullDyLibComponents.insert(Component);
|
|
|
|
}
|
|
|
|
DyLibComponents.clear();
|
|
|
|
|
|
|
|
for (auto &Lib : RequiredLibs) {
|
|
|
|
if (!FullDyLibComponents.count(Lib)) {
|
|
|
|
OS << "static\n";
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
FullDyLibComponents.clear();
|
|
|
|
|
tools/llvm-config: improve shared library support
Summary:
This is a re-commit of r257003, which was reverted,
along with the fixes from http://reviews.llvm.org/D15986.
r252532 added support for reporting the monolithic library
when LLVM_BUILD_LLVM_DYLIB is used. This would only be done
if the individual components were not found, and the dynamic
library is found.
This diff extends this as follows:
- If LLVM_LINK_LLVM_DYLIB is set, then prefer the shared
library, even if all component libraries exist.
- Two flags, --link-shared and --link-static are introduced
to provide explicit guidance. If --link-shared is passed
and the shared library does not exist, an error results.
Additionally, changed the expected shared library names from
(e.g.) LLVM-3.8.0 to LLVM-3.8. The former exists only in an
installation (and then only in CMake builds I think?), and not
in the build tree; this breaks usage of llvm-config during
builds, e.g. by llvm-go.
Reviewers: DiamondLovesYou, beanz
Subscribers: llvm-commits
Differential Revision: http://reviews.llvm.org/D15986
llvm-svn: 258283
2016-01-20 12:03:09 +08:00
|
|
|
if (LinkMode == LinkModeShared) {
|
Fix `llvm-config` to adapt to the install environment.
Summary:
This patch does a couple of things:
- Adds a new argument `--shared-mode` which accepts a list of components and prints whether or not the provided components need to be linked statically or shared.
- Fixes `--libnames` when CMake BUILD_SHARED_LIBS is used.
- Fixes `--libnames`, `--libs`, and `--libfiles` for dylib when static components aren't installed.
- Fixes `--libnames`, `--libs`, `--libfiles`, and `--components` to use LLVM_DYLIB_COMPONENTS as the component manifest for dylib linking.
- Uses the host platform's usual convention for filename extensions and such, instead of always defaulting to Unix-izms.
Because I don't own a Mac, I am not able to test the Mac platform dependent stuff locally. If someone would be willing to run a build for me on their machine (unless there's a better option), I'd appreciate it.
Reviewers: jfb, brad.king, whitequark, beanz
Subscribers: beanz, jauhien, llvm-commits
Differential Revision: http://reviews.llvm.org/D13198
llvm-svn: 252532
2015-11-10 07:15:38 +08:00
|
|
|
OS << "shared\n";
|
|
|
|
return 0;
|
|
|
|
} else {
|
|
|
|
OS << "static\n";
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
2011-12-02 04:18:09 +08:00
|
|
|
|
2014-03-03 23:06:14 +08:00
|
|
|
if (PrintLibs || PrintLibNames || PrintLibFiles) {
|
2011-12-02 04:18:09 +08:00
|
|
|
|
tools/llvm-config: improve shared library support
Summary:
This is a re-commit of r257003, which was reverted,
along with the fixes from http://reviews.llvm.org/D15986.
r252532 added support for reporting the monolithic library
when LLVM_BUILD_LLVM_DYLIB is used. This would only be done
if the individual components were not found, and the dynamic
library is found.
This diff extends this as follows:
- If LLVM_LINK_LLVM_DYLIB is set, then prefer the shared
library, even if all component libraries exist.
- Two flags, --link-shared and --link-static are introduced
to provide explicit guidance. If --link-shared is passed
and the shared library does not exist, an error results.
Additionally, changed the expected shared library names from
(e.g.) LLVM-3.8.0 to LLVM-3.8. The former exists only in an
installation (and then only in CMake builds I think?), and not
in the build tree; this breaks usage of llvm-config during
builds, e.g. by llvm-go.
Reviewers: DiamondLovesYou, beanz
Subscribers: llvm-commits
Differential Revision: http://reviews.llvm.org/D15986
llvm-svn: 258283
2016-01-20 12:03:09 +08:00
|
|
|
auto PrintForLib = [&](const StringRef &Lib) {
|
|
|
|
const bool Shared = LinkMode == LinkModeShared;
|
2014-03-03 23:06:14 +08:00
|
|
|
if (PrintLibNames) {
|
tools/llvm-config: improve shared library support
Summary:
This is a re-commit of r257003, which was reverted,
along with the fixes from http://reviews.llvm.org/D15986.
r252532 added support for reporting the monolithic library
when LLVM_BUILD_LLVM_DYLIB is used. This would only be done
if the individual components were not found, and the dynamic
library is found.
This diff extends this as follows:
- If LLVM_LINK_LLVM_DYLIB is set, then prefer the shared
library, even if all component libraries exist.
- Two flags, --link-shared and --link-static are introduced
to provide explicit guidance. If --link-shared is passed
and the shared library does not exist, an error results.
Additionally, changed the expected shared library names from
(e.g.) LLVM-3.8.0 to LLVM-3.8. The former exists only in an
installation (and then only in CMake builds I think?), and not
in the build tree; this breaks usage of llvm-config during
builds, e.g. by llvm-go.
Reviewers: DiamondLovesYou, beanz
Subscribers: llvm-commits
Differential Revision: http://reviews.llvm.org/D15986
llvm-svn: 258283
2016-01-20 12:03:09 +08:00
|
|
|
OS << GetComponentLibraryFileName(Lib, Shared);
|
2014-03-03 23:06:14 +08:00
|
|
|
} else if (PrintLibFiles) {
|
tools/llvm-config: improve shared library support
Summary:
This is a re-commit of r257003, which was reverted,
along with the fixes from http://reviews.llvm.org/D15986.
r252532 added support for reporting the monolithic library
when LLVM_BUILD_LLVM_DYLIB is used. This would only be done
if the individual components were not found, and the dynamic
library is found.
This diff extends this as follows:
- If LLVM_LINK_LLVM_DYLIB is set, then prefer the shared
library, even if all component libraries exist.
- Two flags, --link-shared and --link-static are introduced
to provide explicit guidance. If --link-shared is passed
and the shared library does not exist, an error results.
Additionally, changed the expected shared library names from
(e.g.) LLVM-3.8.0 to LLVM-3.8. The former exists only in an
installation (and then only in CMake builds I think?), and not
in the build tree; this breaks usage of llvm-config during
builds, e.g. by llvm-go.
Reviewers: DiamondLovesYou, beanz
Subscribers: llvm-commits
Differential Revision: http://reviews.llvm.org/D15986
llvm-svn: 258283
2016-01-20 12:03:09 +08:00
|
|
|
OS << GetComponentLibraryPath(Lib, Shared);
|
2014-03-03 23:06:14 +08:00
|
|
|
} else if (PrintLibs) {
|
2016-03-15 05:39:58 +08:00
|
|
|
// On Windows, output full path to library without parameters.
|
|
|
|
// Elsewhere, if this is a typical library name, include it using -l.
|
|
|
|
if (HostTriple.isWindowsMSVCEnvironment()) {
|
|
|
|
OS << GetComponentLibraryPath(Lib, Shared);
|
|
|
|
} else {
|
|
|
|
StringRef LibName;
|
Fix `llvm-config` to adapt to the install environment.
Summary:
This patch does a couple of things:
- Adds a new argument `--shared-mode` which accepts a list of components and prints whether or not the provided components need to be linked statically or shared.
- Fixes `--libnames` when CMake BUILD_SHARED_LIBS is used.
- Fixes `--libnames`, `--libs`, and `--libfiles` for dylib when static components aren't installed.
- Fixes `--libnames`, `--libs`, `--libfiles`, and `--components` to use LLVM_DYLIB_COMPONENTS as the component manifest for dylib linking.
- Uses the host platform's usual convention for filename extensions and such, instead of always defaulting to Unix-izms.
Because I don't own a Mac, I am not able to test the Mac platform dependent stuff locally. If someone would be willing to run a build for me on their machine (unless there's a better option), I'd appreciate it.
Reviewers: jfb, brad.king, whitequark, beanz
Subscribers: beanz, jauhien, llvm-commits
Differential Revision: http://reviews.llvm.org/D13198
llvm-svn: 252532
2015-11-10 07:15:38 +08:00
|
|
|
if (GetComponentLibraryNameSlice(Lib, LibName)) {
|
2016-03-15 05:39:58 +08:00
|
|
|
// Extract library name (remove prefix and suffix).
|
Fix `llvm-config` to adapt to the install environment.
Summary:
This patch does a couple of things:
- Adds a new argument `--shared-mode` which accepts a list of components and prints whether or not the provided components need to be linked statically or shared.
- Fixes `--libnames` when CMake BUILD_SHARED_LIBS is used.
- Fixes `--libnames`, `--libs`, and `--libfiles` for dylib when static components aren't installed.
- Fixes `--libnames`, `--libs`, `--libfiles`, and `--components` to use LLVM_DYLIB_COMPONENTS as the component manifest for dylib linking.
- Uses the host platform's usual convention for filename extensions and such, instead of always defaulting to Unix-izms.
Because I don't own a Mac, I am not able to test the Mac platform dependent stuff locally. If someone would be willing to run a build for me on their machine (unless there's a better option), I'd appreciate it.
Reviewers: jfb, brad.king, whitequark, beanz
Subscribers: beanz, jauhien, llvm-commits
Differential Revision: http://reviews.llvm.org/D13198
llvm-svn: 252532
2015-11-10 07:15:38 +08:00
|
|
|
OS << "-l" << LibName;
|
|
|
|
} else {
|
2016-03-15 05:39:58 +08:00
|
|
|
// Lib is already a library name without prefix and suffix.
|
|
|
|
OS << "-l" << Lib;
|
Fix `llvm-config` to adapt to the install environment.
Summary:
This patch does a couple of things:
- Adds a new argument `--shared-mode` which accepts a list of components and prints whether or not the provided components need to be linked statically or shared.
- Fixes `--libnames` when CMake BUILD_SHARED_LIBS is used.
- Fixes `--libnames`, `--libs`, and `--libfiles` for dylib when static components aren't installed.
- Fixes `--libnames`, `--libs`, `--libfiles`, and `--components` to use LLVM_DYLIB_COMPONENTS as the component manifest for dylib linking.
- Uses the host platform's usual convention for filename extensions and such, instead of always defaulting to Unix-izms.
Because I don't own a Mac, I am not able to test the Mac platform dependent stuff locally. If someone would be willing to run a build for me on their machine (unless there's a better option), I'd appreciate it.
Reviewers: jfb, brad.king, whitequark, beanz
Subscribers: beanz, jauhien, llvm-commits
Differential Revision: http://reviews.llvm.org/D13198
llvm-svn: 252532
2015-11-10 07:15:38 +08:00
|
|
|
}
|
2014-03-03 23:06:14 +08:00
|
|
|
}
|
Fix `llvm-config` to adapt to the install environment.
Summary:
This patch does a couple of things:
- Adds a new argument `--shared-mode` which accepts a list of components and prints whether or not the provided components need to be linked statically or shared.
- Fixes `--libnames` when CMake BUILD_SHARED_LIBS is used.
- Fixes `--libnames`, `--libs`, and `--libfiles` for dylib when static components aren't installed.
- Fixes `--libnames`, `--libs`, `--libfiles`, and `--components` to use LLVM_DYLIB_COMPONENTS as the component manifest for dylib linking.
- Uses the host platform's usual convention for filename extensions and such, instead of always defaulting to Unix-izms.
Because I don't own a Mac, I am not able to test the Mac platform dependent stuff locally. If someone would be willing to run a build for me on their machine (unless there's a better option), I'd appreciate it.
Reviewers: jfb, brad.king, whitequark, beanz
Subscribers: beanz, jauhien, llvm-commits
Differential Revision: http://reviews.llvm.org/D13198
llvm-svn: 252532
2015-11-10 07:15:38 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2016-12-14 07:08:52 +08:00
|
|
|
if (LinkMode == LinkModeShared && LinkDyLib) {
|
tools/llvm-config: improve shared library support
Summary:
This is a re-commit of r257003, which was reverted,
along with the fixes from http://reviews.llvm.org/D15986.
r252532 added support for reporting the monolithic library
when LLVM_BUILD_LLVM_DYLIB is used. This would only be done
if the individual components were not found, and the dynamic
library is found.
This diff extends this as follows:
- If LLVM_LINK_LLVM_DYLIB is set, then prefer the shared
library, even if all component libraries exist.
- Two flags, --link-shared and --link-static are introduced
to provide explicit guidance. If --link-shared is passed
and the shared library does not exist, an error results.
Additionally, changed the expected shared library names from
(e.g.) LLVM-3.8.0 to LLVM-3.8. The former exists only in an
installation (and then only in CMake builds I think?), and not
in the build tree; this breaks usage of llvm-config during
builds, e.g. by llvm-go.
Reviewers: DiamondLovesYou, beanz
Subscribers: llvm-commits
Differential Revision: http://reviews.llvm.org/D15986
llvm-svn: 258283
2016-01-20 12:03:09 +08:00
|
|
|
PrintForLib(DyLibName);
|
Fix `llvm-config` to adapt to the install environment.
Summary:
This patch does a couple of things:
- Adds a new argument `--shared-mode` which accepts a list of components and prints whether or not the provided components need to be linked statically or shared.
- Fixes `--libnames` when CMake BUILD_SHARED_LIBS is used.
- Fixes `--libnames`, `--libs`, and `--libfiles` for dylib when static components aren't installed.
- Fixes `--libnames`, `--libs`, `--libfiles`, and `--components` to use LLVM_DYLIB_COMPONENTS as the component manifest for dylib linking.
- Uses the host platform's usual convention for filename extensions and such, instead of always defaulting to Unix-izms.
Because I don't own a Mac, I am not able to test the Mac platform dependent stuff locally. If someone would be willing to run a build for me on their machine (unless there's a better option), I'd appreciate it.
Reviewers: jfb, brad.king, whitequark, beanz
Subscribers: beanz, jauhien, llvm-commits
Differential Revision: http://reviews.llvm.org/D13198
llvm-svn: 252532
2015-11-10 07:15:38 +08:00
|
|
|
} else {
|
|
|
|
for (unsigned i = 0, e = RequiredLibs.size(); i != e; ++i) {
|
2015-11-26 06:49:48 +08:00
|
|
|
auto Lib = RequiredLibs[i];
|
Fix `llvm-config` to adapt to the install environment.
Summary:
This patch does a couple of things:
- Adds a new argument `--shared-mode` which accepts a list of components and prints whether or not the provided components need to be linked statically or shared.
- Fixes `--libnames` when CMake BUILD_SHARED_LIBS is used.
- Fixes `--libnames`, `--libs`, and `--libfiles` for dylib when static components aren't installed.
- Fixes `--libnames`, `--libs`, `--libfiles`, and `--components` to use LLVM_DYLIB_COMPONENTS as the component manifest for dylib linking.
- Uses the host platform's usual convention for filename extensions and such, instead of always defaulting to Unix-izms.
Because I don't own a Mac, I am not able to test the Mac platform dependent stuff locally. If someone would be willing to run a build for me on their machine (unless there's a better option), I'd appreciate it.
Reviewers: jfb, brad.king, whitequark, beanz
Subscribers: beanz, jauhien, llvm-commits
Differential Revision: http://reviews.llvm.org/D13198
llvm-svn: 252532
2015-11-10 07:15:38 +08:00
|
|
|
if (i)
|
|
|
|
OS << ' ';
|
2014-03-03 23:06:14 +08:00
|
|
|
|
tools/llvm-config: improve shared library support
Summary:
This is a re-commit of r257003, which was reverted,
along with the fixes from http://reviews.llvm.org/D15986.
r252532 added support for reporting the monolithic library
when LLVM_BUILD_LLVM_DYLIB is used. This would only be done
if the individual components were not found, and the dynamic
library is found.
This diff extends this as follows:
- If LLVM_LINK_LLVM_DYLIB is set, then prefer the shared
library, even if all component libraries exist.
- Two flags, --link-shared and --link-static are introduced
to provide explicit guidance. If --link-shared is passed
and the shared library does not exist, an error results.
Additionally, changed the expected shared library names from
(e.g.) LLVM-3.8.0 to LLVM-3.8. The former exists only in an
installation (and then only in CMake builds I think?), and not
in the build tree; this breaks usage of llvm-config during
builds, e.g. by llvm-go.
Reviewers: DiamondLovesYou, beanz
Subscribers: llvm-commits
Differential Revision: http://reviews.llvm.org/D15986
llvm-svn: 258283
2016-01-20 12:03:09 +08:00
|
|
|
PrintForLib(Lib);
|
2014-03-03 23:06:14 +08:00
|
|
|
}
|
2011-12-02 04:18:09 +08:00
|
|
|
}
|
2014-03-03 23:06:14 +08:00
|
|
|
OS << '\n';
|
2011-12-02 04:18:09 +08:00
|
|
|
}
|
2013-12-19 16:46:36 +08:00
|
|
|
|
|
|
|
// Print SYSTEM_LIBS after --libs.
|
|
|
|
// FIXME: Each LLVM component may have its dependent system libs.
|
2017-01-07 05:33:54 +08:00
|
|
|
if (PrintSystemLibs) {
|
|
|
|
// Output system libraries only if linking against a static
|
|
|
|
// library (since the shared library links to all system libs
|
|
|
|
// already)
|
|
|
|
OS << (LinkMode == LinkModeStatic ? LLVM_SYSTEM_LIBS : "") << '\n';
|
|
|
|
}
|
2011-12-02 04:18:09 +08:00
|
|
|
} else if (!Components.empty()) {
|
2018-06-24 00:50:09 +08:00
|
|
|
WithColor::error(errs(), "llvm-config")
|
|
|
|
<< "components given, but unused\n\n";
|
2011-12-02 04:18:09 +08:00
|
|
|
usage();
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|