aboutsummaryrefslogtreecommitdiff
path: root/tools/driver/NativeCompiler.cc
diff options
context:
space:
mode:
author_ov4 <ov4@ov4.org>2026-10-16 08:06:09 +0000
committer_ov4 <ov4@ov4.org>2026-10-16 08:06:09 +0000
commitd74e6f5278e67f42e9a020f81c9eb0272f624618 (patch)
tree935eaa12e239bc0b4409fdd948d16ab52feec9e3 /tools/driver/NativeCompiler.cc
parentc9f3a6a0b7d781fe73b48a5765fa8b6e7ca3c2f7 (diff)
feat(driver)!: select LLVM IR output with -S
Save native executables by default and LLVM IR with -S, using source-adjacent .out and .ll names. Keep -r independent of output selection and update the manuals and three-platform nightly smoke checks. BREAKING CHANGE: plain compilation and -o now save native executables. Use -S to save textual LLVM IR. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Diffstat (limited to 'tools/driver/NativeCompiler.cc')
-rw-r--r--tools/driver/NativeCompiler.cc10
1 files changed, 6 insertions, 4 deletions
diff --git a/tools/driver/NativeCompiler.cc b/tools/driver/NativeCompiler.cc
index f2ea3dc..8d798d7 100644
--- a/tools/driver/NativeCompiler.cc
+++ b/tools/driver/NativeCompiler.cc
@@ -60,7 +60,7 @@ class DriverDiagnostics : public clang::DiagnosticConsumer {
} // namespace
-bool compileNative(const cps::CodeGen &CG, llvm::StringRef OutputPath) {
+bool compileNative(const cps::CodeGen &CG, llvm::StringRef OutputPath, const char *Argv0) {
TemporaryDirectory Runtime;
if (auto EC = llvm::sys::fs::createUniqueDirectory("cpsc-native", Runtime.Path))
return fail("cannot create native compilation directory: " + EC.message());
@@ -157,10 +157,12 @@ bool compileNative(const cps::CodeGen &CG, llvm::StringRef OutputPath) {
DriverDiagnostics Printer;
clang::DiagnosticsEngine Diagnostics(new clang::DiagnosticIDs, Options, &Printer, false);
clang::driver::Driver Driver("cpsc", Triple.str(), Diagnostics);
- // The standard linker flavor constructs a job without checking for an
- // installed linker. Its platform arguments are passed to embedded LLD.
+ // Clang validates the linker executable even for an unlaunched job. Use
+ // cpsc's own path; only the job's arguments are passed to embedded LLD.
std::vector<std::string> Args = {"cpsc", "--driver-mode=g++", "-nostdlib", "-nostdlib++",
- "-fuse-ld=ld", "-o", std::string(StagedPath), std::string(ObjectPath)};
+ "-fuse-ld=lld", "-o", std::string(StagedPath), std::string(ObjectPath)};
+ Args.push_back("--ld-path=" + llvm::sys::fs::getMainExecutable(
+ Argv0, reinterpret_cast<void *>(&compileNative)));
for (const auto &Arg : *Metadata.getArray("arguments")) {
Args.push_back("-Xlinker");
Args.push_back(relocate(*Arg.getAsString()));