mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-24 22:02:23 +01:00
Add utilities for managing a toolchain install, and install and use LLD. (#3993)
The install directory contains the BUILD logic for creating an installable tree of data files and executables for the toolchain, and a library to facilitate toolchain code accessing the paths to their data within this installation. Then adds an installation of LLD in a synthetic LLVM installation, and teaches the Clang runner to configure this and use it for linking instead of the system linker. Currently, the install paths only really manage access to the LLVM binaries installed and used by the Clang runner for linking, but eventually other data files like the prelude and runtime libraries will be fleshed out as well. There are TODOs for moving more things over here such as the prelude. One interesting aspect of this is where to put helpers like parts of LLVM in our install. This PR suggests nesting those files under `lib/carbon`. While using a `lib` subdirectory isn't a perfect fit for the FHS (Filesystem Hierarchy Standard), having a single location where private data is collected is significantly superior to spreading them across the system. This also matches similar patterns used by Clang itself and several other language toolchains and standard libraries. The install directory also provides a natural place for us to build out packaging rules to create installable packages in various formats, but that remains future work. --------- Co-authored-by: Jon Ross-Perkins <jperkins@google.com>
This commit is contained in:
co-authored by
Jon Ross-Perkins
parent
d0c8483175
commit
d3a5b0eee7
@@ -16,6 +16,7 @@
|
||||
#include "absl/flags/parse.h"
|
||||
#include "common/check.h"
|
||||
#include "common/error.h"
|
||||
#include "common/exe_path.h"
|
||||
#include "common/init_llvm.h"
|
||||
#include "llvm/ADT/StringExtras.h"
|
||||
#include "llvm/ADT/Twine.h"
|
||||
@@ -826,6 +827,8 @@ static auto Main(int argc, char** argv) -> int {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
std::string exe_path = FindExecutablePath(argv[0]);
|
||||
|
||||
// Tests might try to read from stdin. Ensure those reads fail by closing
|
||||
// stdin and reopening it as /dev/null. Note that STDIN_FILENO doesn't exist
|
||||
// on Windows, but POSIX requires it to be 0.
|
||||
@@ -854,8 +857,9 @@ static auto Main(int argc, char** argv) -> int {
|
||||
std::mutex errs_mutex;
|
||||
|
||||
for (const auto& test_name : tests) {
|
||||
pool.async([&test_factory, &errs_mutex, test_name] {
|
||||
std::unique_ptr<FileTestBase> test(test_factory.factory_fn(test_name));
|
||||
pool.async([&test_factory, &errs_mutex, &exe_path, test_name] {
|
||||
std::unique_ptr<FileTestBase> test(
|
||||
test_factory.factory_fn(exe_path, test_name));
|
||||
auto result = test->Autoupdate();
|
||||
|
||||
// Guard access to llvm::errs, which is not thread-safe.
|
||||
@@ -872,7 +876,8 @@ static auto Main(int argc, char** argv) -> int {
|
||||
return EXIT_SUCCESS;
|
||||
} else if (absl::GetFlag(FLAGS_dump_output)) {
|
||||
for (const auto& test_name : tests) {
|
||||
std::unique_ptr<FileTestBase> test(test_factory.factory_fn(test_name));
|
||||
std::unique_ptr<FileTestBase> test(
|
||||
test_factory.factory_fn(exe_path, test_name));
|
||||
auto result = test->DumpOutput();
|
||||
if (!result.ok()) {
|
||||
llvm::errs() << "\n" << result.error().message() << "\n";
|
||||
@@ -882,11 +887,12 @@ static auto Main(int argc, char** argv) -> int {
|
||||
return EXIT_SUCCESS;
|
||||
} else {
|
||||
for (llvm::StringRef test_name : tests) {
|
||||
testing::RegisterTest(test_factory.name, test_name.data(), nullptr,
|
||||
test_name.data(), __FILE__, __LINE__,
|
||||
[&test_factory, test_name = test_name]() {
|
||||
return test_factory.factory_fn(test_name);
|
||||
});
|
||||
testing::RegisterTest(
|
||||
test_factory.name, test_name.data(), nullptr, test_name.data(),
|
||||
__FILE__, __LINE__,
|
||||
[&test_factory, &exe_path, test_name = test_name]() {
|
||||
return test_factory.factory_fn(exe_path, test_name);
|
||||
});
|
||||
}
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user