Skip to content

Commit 69006f2

Browse files
committed
llvm-ar usage for build_native_static_lib
1 parent 10b9533 commit 69006f2

File tree

1 file changed

+6
-26
lines changed
  • src/tools/run-make-support/src

1 file changed

+6
-26
lines changed

src/tools/run-make-support/src/lib.rs

Lines changed: 6 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -281,26 +281,6 @@ pub fn not_contains<P: AsRef<Path>>(path: P, expected: &str) -> bool {
281281
!path.as_ref().file_name().is_some_and(|name| name.to_str().unwrap().contains(expected))
282282
}
283283

284-
/// Builds a static lib (`.lib` on Windows MSVC and `.a` for the rest) with the given name.
285-
#[track_caller]
286-
pub fn build_native_static_lib(lib_name: &str) -> PathBuf {
287-
let obj_file = if is_msvc() { format!("{lib_name}") } else { format!("{lib_name}.o") };
288-
let src = format!("{lib_name}.c");
289-
let lib_path = static_lib_name(lib_name);
290-
if is_msvc() {
291-
cc().arg("-c").out_exe(&obj_file).input(src).run();
292-
} else {
293-
cc().arg("-v").arg("-c").out_exe(&obj_file).input(src).run();
294-
};
295-
let obj_file = if is_msvc() {
296-
PathBuf::from(format!("{lib_name}.obj"))
297-
} else {
298-
PathBuf::from(format!("{lib_name}.o"))
299-
};
300-
llvm_ar().obj_to_ar().output_input(&lib_path, &obj_file).run();
301-
path(lib_path)
302-
}
303-
304284
/// Returns true if the filename at `path` is not in `expected`.
305285
pub fn filename_not_in_denylist<P: AsRef<Path>, V: AsRef<[String]>>(path: P, expected: V) -> bool {
306286
let expected = expected.as_ref();
@@ -339,12 +319,12 @@ pub fn build_native_static_lib(lib_name: &str) -> PathBuf {
339319
} else {
340320
cc().arg("-v").arg("-c").out_exe(&obj_file).input(src).run();
341321
};
342-
let mut obj_file = PathBuf::from(format!("{lib_name}.o"));
343-
if is_msvc() {
344-
obj_file.set_extension("");
345-
obj_file.set_extension("obj");
346-
}
347-
ar(&[obj_file], &lib_path);
322+
let obj_file = if is_msvc() {
323+
PathBuf::from(format!("{lib_name}.obj"))
324+
} else {
325+
PathBuf::from(format!("{lib_name}.o"))
326+
};
327+
llvm_ar().obj_to_ar().output_input(&lib_path, &obj_file).run();
348328
path(lib_path)
349329
}
350330

0 commit comments

Comments
 (0)