mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-27 13:59:08 +00:00
a functional windows surgical linker
This commit is contained in:
parent
466b5d78cb
commit
1c95fd3761
3 changed files with 417 additions and 32 deletions
|
@ -473,6 +473,20 @@ pub fn preprocess(
|
|||
println!("Targeting: {}", target);
|
||||
}
|
||||
|
||||
if let target_lexicon::BinaryFormat::Coff = target.binary_format {
|
||||
crate::pe::preprocess_windows(
|
||||
exec_filename,
|
||||
Path::new(metadata_filename),
|
||||
Path::new(out_filename),
|
||||
shared_lib,
|
||||
verbose,
|
||||
time,
|
||||
)
|
||||
.unwrap_or_else(|e| internal_error!("{}", e));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
let total_start = Instant::now();
|
||||
let exec_parsing_start = total_start;
|
||||
let exec_file = fs::File::open(exec_filename).unwrap_or_else(|e| internal_error!("{}", e));
|
||||
|
@ -1975,6 +1989,23 @@ pub fn surgery(
|
|||
time: bool,
|
||||
target: &Triple,
|
||||
) {
|
||||
let app_parsing_start = Instant::now();
|
||||
let app_file = fs::File::open(app_filename).unwrap_or_else(|e| internal_error!("{}", e));
|
||||
let app_mmap = unsafe { Mmap::map(&app_file).unwrap_or_else(|e| internal_error!("{}", e)) };
|
||||
let app_data = &*app_mmap;
|
||||
let app_obj = match object::File::parse(app_data) {
|
||||
Ok(obj) => obj,
|
||||
Err(err) => {
|
||||
internal_error!("Failed to parse application file: {}", err);
|
||||
}
|
||||
};
|
||||
|
||||
let app_parsing_duration = app_parsing_start.elapsed();
|
||||
|
||||
if let target_lexicon::BinaryFormat::Coff = target.binary_format {
|
||||
return crate::pe::surgery_pe(out_filename, metadata_filename, app_data, verbose);
|
||||
}
|
||||
|
||||
let total_start = Instant::now();
|
||||
let loading_metadata_start = total_start;
|
||||
let md: metadata::Metadata = {
|
||||
|
@ -1989,18 +2020,6 @@ pub fn surgery(
|
|||
};
|
||||
let loading_metadata_duration = loading_metadata_start.elapsed();
|
||||
|
||||
let app_parsing_start = Instant::now();
|
||||
let app_file = fs::File::open(app_filename).unwrap_or_else(|e| internal_error!("{}", e));
|
||||
let app_mmap = unsafe { Mmap::map(&app_file).unwrap_or_else(|e| internal_error!("{}", e)) };
|
||||
let app_data = &*app_mmap;
|
||||
let app_obj = match object::File::parse(app_data) {
|
||||
Ok(obj) => obj,
|
||||
Err(err) => {
|
||||
internal_error!("Failed to parse application file: {}", err);
|
||||
}
|
||||
};
|
||||
let app_parsing_duration = app_parsing_start.elapsed();
|
||||
|
||||
let load_and_mmap_start = Instant::now();
|
||||
let exec_file = fs::OpenOptions::new()
|
||||
.read(true)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue