Skip to content

Commit b257a16

Browse files
committed
Updated rustc version
1 parent 69e6e5a commit b257a16

File tree

5 files changed

+65
-1736
lines changed

5 files changed

+65
-1736
lines changed
Lines changed: 53 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::io::Write;
2-
static DOTNET_ASSEMBLY: &[u8] = include_bytes!("{exec_file}");
3-
static RUNTIME_COFIG: &[u8] = b"{{
2+
static DOTNET_ASSEMBLY:&[u8] = include_bytes!("{exec_file}");
3+
static RUNTIME_COFIG:&[u8] = b"{{
44
\"runtimeOptions\": {{
55
\"tfm\": \"net8.0\",
66
\"framework\": {{
@@ -13,84 +13,55 @@ static RUNTIME_COFIG: &[u8] = b"{{
1313
}}
1414
}}
1515
}}";
16-
macro_rules! include_bytes_if {}
16+
macro_rules! include_bytes_if{{
17+
(true,$path:literal)=>{{
18+
include_bytes!($path)
19+
}};
20+
(false,$path:literal)=>{{b""}};
21+
}}
22+
23+
static BUNDLED_SHARED_LIB:&[u8] = include_bytes_if!({has_native_companion},"{native_companion_file}");
24+
static BUNDLED_PDB:&[u8] = include_bytes_if!({has_pdb},"{pdb_file}");
25+
fn main(){{
26+
let curr_path = std::env::current_exe().unwrap();
27+
let dll_path = curr_path.with_extension("dll");
28+
let config = curr_path.with_extension("runtimeconfig.json");
29+
let pdb_file = curr_path.with_file_name("{pdb_file}");
30+
let mut requires_refresh = false;
31+
if dll_path.exists() {{
32+
let ondisk_len = std::fs::File::open(dll_path.clone()).expect("Could not create a file to unpack the .NET assembly").metadata().unwrap().len();
33+
// If the length on disk is != expected, write the new file TODO: this can very rarely not detect if an update is needed. Check assembly GUID too, to ensure recompilation works.
34+
if ondisk_len != DOTNET_ASSEMBLY.len() as u64{{
35+
requires_refresh = true;
36+
}}
37+
}}
38+
if !dll_path.exists() || requires_refresh {{
39+
let mut file = std::fs::File::create(dll_path.clone()).expect("Could not create a file to unpack the .NET assembly");
40+
file.write_all(DOTNET_ASSEMBLY).expect("Could not unpack the .NET assembly");
41+
}}
42+
if !config.exists() ||requires_refresh {{
43+
let mut file = std::fs::File::create(config).expect("Could not create a file to save .NET runtime settings.");
44+
file.write_all(RUNTIME_COFIG).expect("Could not save .NET runtime settings");
45+
}}
46+
if {has_native_companion} {{
47+
if !std::path::Path::new("{native_companion_file}").exists() || requires_refresh{{
48+
let mut file = std::fs::File::create("{native_companion_file}").expect("Could not create a file to provide the native companion.");
49+
file.write_all(BUNDLED_SHARED_LIB).expect("Could create a file to provide the native companion");
50+
}}
51+
52+
}}
53+
if {has_pdb}{{
54+
if !pdb_file.exists() || requires_refresh{{
55+
println!("creating the pdb file");
56+
let mut file = std::fs::File::create(pdb_file).expect("Could not create a file to provide the pdb debug info.");
57+
file.write_all(BUNDLED_PDB).expect("Could create a file to provide the pdb debug info.");
58+
}}
59+
else{{
60+
println!("Not creating the pdb file");
61+
}}
62+
}}
63+
let args:Vec<String> = std::env::args().collect();
64+
let args = &args[1..];
65+
std::process::Command::new("{jumpstart_cmd}").arg(dll_path).args(args).status().expect("Could not start the .NET runtime.");
66+
}}
1767

18-
static BUNDLED_SHARED_LIB: &[u8] =
19-
include_bytes_if!({ has_native_companion }, "{native_companion_file}");
20-
static BUNDLED_PDB: &[u8] = include_bytes_if!({ has_pdb }, "{pdb_file}");
21-
fn main() {
22-
{
23-
let curr_path = std::env::current_exe().unwrap();
24-
let dll_path = curr_path.with_extension("dll");
25-
let config = curr_path.with_extension("runtimeconfig.json");
26-
let pdb_file = curr_path.with_file_name("{pdb_file}");
27-
let mut requires_refresh = false;
28-
if dll_path.exists() {
29-
{
30-
let ondisk_len = std::fs::File::open(dll_path.clone())
31-
.expect("Could not create a file to unpack the .NET assembly")
32-
.metadata()
33-
.unwrap()
34-
.len();
35-
// If the length on disk is != expected, write the new file TODO: this can very rarely not detect if an update is needed. Check assembly GUID too, to ensure recompilation works.
36-
if ondisk_len != DOTNET_ASSEMBLY.len() as u64 {
37-
{
38-
requires_refresh = true;
39-
}
40-
}
41-
}
42-
}
43-
if !dll_path.exists() || requires_refresh {
44-
{
45-
let mut file = std::fs::File::create(dll_path.clone())
46-
.expect("Could not create a file to unpack the .NET assembly");
47-
file.write_all(DOTNET_ASSEMBLY)
48-
.expect("Could not unpack the .NET assembly");
49-
}
50-
}
51-
if !config.exists() || requires_refresh {
52-
{
53-
let mut file = std::fs::File::create(config)
54-
.expect("Could not create a file to save .NET runtime settings.");
55-
file.write_all(RUNTIME_COFIG)
56-
.expect("Could not save .NET runtime settings");
57-
}
58-
}
59-
if { has_native_companion } {
60-
{
61-
if !std::path::Path::new("{native_companion_file}").exists() || requires_refresh {
62-
{
63-
let mut file = std::fs::File::create("{native_companion_file}")
64-
.expect("Could not create a file to provide the native companion.");
65-
file.write_all(BUNDLED_SHARED_LIB)
66-
.expect("Could create a file to provide the native companion");
67-
}
68-
}
69-
}
70-
}
71-
if { has_pdb } {
72-
{
73-
if !pdb_file.exists() || requires_refresh {
74-
{
75-
println!("creating the pdb file");
76-
let mut file = std::fs::File::create(pdb_file)
77-
.expect("Could not create a file to provide the pdb debug info.");
78-
file.write_all(BUNDLED_PDB)
79-
.expect("Could create a file to provide the pdb debug info.");
80-
}
81-
} else {
82-
{
83-
println!("Not creating the pdb file");
84-
}
85-
}
86-
}
87-
}
88-
let args: Vec<String> = std::env::args().collect();
89-
let args = &args[1..];
90-
std::process::Command::new("{jumpstart_cmd}")
91-
.arg(dll_path)
92-
.args(args)
93-
.status()
94-
.expect("Could not start the .NET runtime.");
95-
}
96-
}

cilly/src/v2/builtins/mod.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ fn insert_rust_alloc_zeroed(asm: &mut Assembly, patcher: &mut MissingMethodPatch
112112
let size = asm.alloc_node(CILNode::LdArg(0));
113113
let align = asm.alloc_node(CILNode::LdArg(1));
114114
let void_ptr = asm.nptr(Type::Void);
115+
let void_idx = asm.alloc_type(Type::Void);
115116
let sig = asm.sig([Type::Int(Int::USize), Type::Int(Int::USize)], void_ptr);
116117
let aligned_alloc = asm.alloc_string("AlignedAlloc");
117118
let native_mem = ClassRef::native_mem(asm);
@@ -126,6 +127,10 @@ fn insert_rust_alloc_zeroed(asm: &mut Assembly, patcher: &mut MissingMethodPatch
126127
call_method,
127128
Box::new([size, align]),
128129
))));
130+
let alloc = asm.alloc_node(CILNode::PtrCast(
131+
alloc,
132+
Box::new(super::cilnode::PtrCastRes::Ptr(void_idx)),
133+
));
129134
let alloc = asm.alloc_root(CILRoot::StLoc(0, alloc));
130135
let cap = asm.alloc_node(Const::USize(ALLOC_CAP));
131136
let check = asm.alloc_root(CILRoot::Branch(Box::new((
@@ -150,7 +155,7 @@ fn insert_rust_alloc_zeroed(asm: &mut Assembly, patcher: &mut MissingMethodPatch
150155
BasicBlock::new(vec![check, alloc, zero, ret], 0, None),
151156
BasicBlock::new(vec![throw], 1, None),
152157
],
153-
locals: vec![(None, asm.alloc_type(Type::Int(Int::USize)))],
158+
locals: vec![(None, asm.alloc_type(void_ptr))],
154159
}
155160
};
156161
patcher.insert(name, Box::new(generator));

0 commit comments

Comments
 (0)