We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 89c1b4a commit 5cb5fc3Copy full SHA for 5cb5fc3
2 files changed
src/tools/run-make-support/src/lib.rs
@@ -31,8 +31,8 @@ pub use cc::{cc, extra_c_flags, extra_cxx_flags, Cc};
31
pub use clang::{clang, Clang};
32
pub use diff::{diff, Diff};
33
pub use llvm::{
34
- llvm_filecheck, llvm_objdump, llvm_profdata, llvm_readobj, LlvmFilecheck, LlvmObjdump,
35
- LlvmProfdata, LlvmReadobj,
+ llvm_ar, llvm_filecheck, llvm_objdump, llvm_profdata, llvm_readobj, LlvmAr, LlvmFilecheck,
+ LlvmObjdump, LlvmProfdata, LlvmReadobj,
36
};
37
pub use run::{cmd, run, run_fail, run_with_args};
38
pub use rustc::{aux_build, bare_rustc, rustc, Rustc};
@@ -333,7 +333,7 @@ pub fn build_native_static_lib(lib_name: &str) -> PathBuf {
333
obj_file.set_extension("");
334
obj_file.set_extension("obj");
335
}
336
- ar(&[obj_file], &lib_path);
+ llvm_ar().obj_to_ar().output_input(&lib_path, &obj_file).run();
337
path(lib_path)
338
339
src/tools/run-make-support/src/llvm.rs
@@ -29,6 +29,12 @@ pub fn llvm_objdump() -> LlvmObjdump {
29
LlvmObjdump::new()
30
+/// Construct a new `llvm-ar` invocation. This assumes that `llvm-ar` is available
+/// at `$LLVM_BIN_DIR/llvm-ar`.
+pub fn llvm_ar() -> LlvmAr {
+ LlvmAr::new()
+}
+
/// A `llvm-readobj` invocation builder.
39
#[derive(Debug)]
40
#[must_use]
@@ -57,10 +63,18 @@ pub struct LlvmObjdump {
57
63
cmd: Command,
58
64
59
65
66
+/// A `llvm-ar` invocation builder.
67
+#[derive(Debug)]
68
+#[must_use]
69
+pub struct LlvmAr {
70
+ cmd: Command,
71
72
60
73
crate::impl_common_helpers!(LlvmReadobj);
61
74
crate::impl_common_helpers!(LlvmProfdata);
62
75
crate::impl_common_helpers!(LlvmFilecheck);
76
crate::impl_common_helpers!(LlvmObjdump);
77
+crate::impl_common_helpers!(LlvmAr);
78
79
/// Generate the path to the bin directory of LLVM.
80
@@ -204,3 +218,26 @@ impl LlvmObjdump {
204
218
self
205
219
206
220
221
222
+impl LlvmAr {
223
+ /// Construct a new `llvm-ar` invocation. This assumes that `llvm-ar` is available
224
+ /// at `$LLVM_BIN_DIR/llvm-ar`.
225
+ pub fn new() -> Self {
226
+ let llvm_ar = llvm_bin_dir().join("llvm-ar");
227
+ let cmd = Command::new(llvm_ar);
228
+ Self { cmd }
229
+ }
230
231
+ pub fn obj_to_ar(&mut self) -> &mut Self {
232
+ self.cmd.arg("rcus");
233
+ self
234
235
236
+ /// Provide an output, then an input file. Bundled in one function, as llvm-ar has
237
+ /// no "--output"-style flag.
238
+ pub fn output_input(&mut self, out: impl AsRef<Path>, input: impl AsRef<Path>) -> &mut Self {
239
+ self.cmd.arg(out.as_ref());
240
+ self.cmd.arg(input.as_ref());
241
242
243
0 commit comments