mirror of
https://github.com/pezkuwichain/revive.git
synced 2026-06-14 05:21:03 +00:00
+15
-13
@@ -1,25 +1,27 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
fn llvm_config(arg: &str) -> String {
|
||||
let output = std::process::Command::new("llvm-config")
|
||||
.args([arg])
|
||||
.output()
|
||||
.unwrap_or_else(|_| panic!("`llvm-config {arg}` failed"));
|
||||
|
||||
use std::{io::Read, process::Command};
|
||||
String::from_utf8(output.stdout)
|
||||
.unwrap_or_else(|_| panic!("output of `llvm-config {arg}` should be utf8"))
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let mut flags = String::new();
|
||||
Command::new("llvm-config")
|
||||
.args(["--cxxflags"])
|
||||
.output()
|
||||
.expect("llvm-config should be able to provide CXX flags")
|
||||
.stdout
|
||||
.as_slice()
|
||||
.read_to_string(&mut flags)
|
||||
.expect("llvm-config output should be utf8");
|
||||
|
||||
let mut builder = cc::Build::new();
|
||||
flags
|
||||
llvm_config("--cxxflags")
|
||||
.split_whitespace()
|
||||
.fold(&mut builder, |builder, flag| builder.flag(flag))
|
||||
.cpp(true)
|
||||
.file("src/linker.cpp")
|
||||
.compile("liblinker.a");
|
||||
|
||||
println!("cargo:rustc-link-search=native={}", llvm_config("--libdir"));
|
||||
|
||||
for lib in ["lldELF", "lldCommon", "lldMachO"] {
|
||||
println!("cargo:rustc-link-lib=static={lib}");
|
||||
}
|
||||
|
||||
println!("cargo:rerun-if-changed=build.rs");
|
||||
}
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
#include "lld/Common/Driver.h"
|
||||
#include "lld/Common/CommonLinkerContext.h"
|
||||
#include "llvm/Support/CrashRecoveryContext.h"
|
||||
@@ -19,4 +17,4 @@ extern "C" bool LLDELFLink(const char *argv[], size_t length)
|
||||
llvm::CrashRecoveryContext crc;
|
||||
return canRunAgain && crc.RunSafely([&]()
|
||||
{ lld::CommonLinkerContext::destroy(); });
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user