mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 20:31:15 +01:00
The `Support/LLVMDriver.h` header was renamed to `Driver.h`, and the API of `llvm::ToolContext` changed such that a constructor call is needed instead of aggregate initialization. A couple new bazel deps were added (libxml2 and xz), and rules_cc required an updated version. The addition of libxml2 and xz required some additions to check_non_test_cc_deps.py. libxml2 also required allow-listing an additional URL in CI jobs. Dropped `0011_Temporarily_remove_reference_to_hermetic_toolchain.patch`, no longer needed. Added `0012_Drop_dependencies_on_linux_uapi_and_pyyaml.patch` to remove a couple dependencies from llvm that Carbon doesn't currently require. These were causing bazel queries in check_deps and forbid_llvm_googletest.py to fail.
47 lines
1.4 KiB
C++
47 lines
1.4 KiB
C++
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
|
|
// Exceptions. See /LICENSE for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
|
|
#include "toolchain/driver/llvm_runner.h"
|
|
|
|
#include <algorithm>
|
|
#include <memory>
|
|
#include <numeric>
|
|
#include <optional>
|
|
#include <string>
|
|
|
|
#include "common/string_helpers.h"
|
|
#include "common/vlog.h"
|
|
#include "lld/Common/Driver.h"
|
|
#include "llvm/ADT/ArrayRef.h"
|
|
#include "llvm/ADT/StringRef.h"
|
|
#include "llvm/Support/Allocator.h"
|
|
|
|
namespace Carbon {
|
|
|
|
auto LLVMRunner::Run(LLVMTool tool, llvm::ArrayRef<llvm::StringRef> args)
|
|
-> bool {
|
|
std::string path = installation_->llvm_tool_path(tool);
|
|
|
|
// Allocate one chunk of storage for the actual C-strings and a vector of
|
|
// pointers into the storage.
|
|
llvm::BumpPtrAllocator alloc;
|
|
llvm::SmallVector<const char*, 64> cstr_args =
|
|
BuildCStrArgs(path, args, alloc);
|
|
|
|
CARBON_VLOG("Running LLVM's {0} tool with args:\n", tool.name());
|
|
for (const char* cstr_arg : cstr_args) {
|
|
CARBON_VLOG(" '{0}'\n", cstr_arg);
|
|
}
|
|
|
|
int exit_code =
|
|
tool.main_fn()(cstr_args.size(), const_cast<char**>(cstr_args.data()),
|
|
llvm::ToolContext{path.c_str(), /*PrependArg=*/nullptr,
|
|
/*NeedsPrependArg=*/false});
|
|
|
|
// TODO: Should this be forwarding the full exit code?
|
|
return exit_code == 0;
|
|
}
|
|
|
|
} // namespace Carbon
|