use crate::builder::Builder;
use crate::config::{Config, TargetSelection};
+use crate::OnceCell;
/// A helper macro to `unwrap` a result except also print out details like:
///
ptr::null_mut(),
);
- let mut data = [0u8; MAXIMUM_REPARSE_DATA_BUFFER_SIZE as usize];
- let db = data.as_mut_ptr() as *mut REPARSE_MOUNTPOINT_DATA_BUFFER;
- let buf = &mut (*db).ReparseTarget as *mut u16;
+ #[repr(C, align(8))]
+ struct Align8<T>(T);
+ let mut data = Align8([0u8; MAXIMUM_REPARSE_DATA_BUFFER_SIZE as usize]);
+ let db = data.0.as_mut_ptr() as *mut REPARSE_MOUNTPOINT_DATA_BUFFER;
+ let buf = core::ptr::addr_of_mut!((*db).ReparseTarget) as *mut u16;
let mut i = 0;
// FIXME: this conversion is very hacky
let v = br"\??\";
let res = DeviceIoControl(
h as *mut _,
FSCTL_SET_REPARSE_POINT,
- data.as_ptr() as *mut _,
+ db.cast(),
(*db).ReparseDataLength + 8,
ptr::null_mut(),
0,
let clang_rt_dir = clang_rt_builtins.parent().expect("The clang lib folder should exist");
clang_rt_dir.to_path_buf()
}
+
+pub fn lld_flag_no_threads(is_windows: bool) -> &'static str {
+ static LLD_NO_THREADS: OnceCell<(&'static str, &'static str)> = OnceCell::new();
+ let (windows, other) = LLD_NO_THREADS.get_or_init(|| {
+ let out = output(Command::new("lld").arg("-flavor").arg("ld").arg("--version"));
+ let newer = match (out.find(char::is_numeric), out.find('.')) {
+ (Some(b), Some(e)) => out.as_str()[b..e].parse::<i32>().ok().unwrap_or(14) > 10,
+ _ => true,
+ };
+ if newer { ("/threads:1", "--threads=1") } else { ("/no-threads", "--no-threads") }
+ });
+ if is_windows { windows } else { other }
+}