mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-01 07:41:12 +00:00
fixing windows cargo build errors
This commit is contained in:
parent
16e568be76
commit
784894bb8f
7 changed files with 72 additions and 29 deletions
14
Cargo.lock
generated
14
Cargo.lock
generated
|
@ -1162,7 +1162,7 @@ checksum = "1d428afc93ad288f6dffc1fa5f4a78201ad2eec33c5a522e51c181009eb09061"
|
|||
dependencies = [
|
||||
"byteorder",
|
||||
"dynasm",
|
||||
"memmap2 0.5.0",
|
||||
"memmap2 0.5.3",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -2018,9 +2018,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "memmap2"
|
||||
version = "0.5.0"
|
||||
version = "0.5.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4647a11b578fead29cdbb34d4adef8dd3dc35b876c9c6d5240d83f205abfe96e"
|
||||
checksum = "057a3db23999c867821a7a59feb06a578fcb03685e983dff90daf9e7d24ac08f"
|
||||
dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
@ -3195,8 +3195,10 @@ dependencies = [
|
|||
"roc_target",
|
||||
"roc_types",
|
||||
"roc_unify",
|
||||
"slab",
|
||||
"snafu",
|
||||
"ven_graph",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -3495,7 +3497,7 @@ dependencies = [
|
|||
"bumpalo",
|
||||
"clap 3.0.0-beta.5",
|
||||
"iced-x86",
|
||||
"memmap2 0.5.0",
|
||||
"memmap2 0.5.3",
|
||||
"object 0.26.2",
|
||||
"roc_build",
|
||||
"roc_collections",
|
||||
|
@ -3825,7 +3827,7 @@ checksum = "61b3909d758bb75c79f23d4736fac9433868679d3ad2ea7a61e3c25cfda9a088"
|
|||
[[package]]
|
||||
name = "rustyline"
|
||||
version = "9.1.1"
|
||||
source = "git+https://github.com/rtfeldman/rustyline?tag=v9.1.1#7053ae0fe0ee710d38ed5845dd979113382994dc"
|
||||
source = "git+https://github.com/rtfeldman/rustyline?rev=e74333c#e74333c0d618896b88175bf06645108f996fe6d0"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"cfg-if 1.0.0",
|
||||
|
@ -3848,7 +3850,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "rustyline-derive"
|
||||
version = "0.6.0"
|
||||
source = "git+https://github.com/rtfeldman/rustyline?tag=v9.1.1#7053ae0fe0ee710d38ed5845dd979113382994dc"
|
||||
source = "git+https://github.com/rtfeldman/rustyline?rev=e74333c#e74333c0d618896b88175bf06645108f996fe6d0"
|
||||
dependencies = [
|
||||
"quote",
|
||||
"syn",
|
||||
|
|
|
@ -21,10 +21,16 @@ roc_target = { path = "../compiler/roc_target" }
|
|||
roc_error_macros = { path = "../error_macros" }
|
||||
arrayvec = "0.7.2"
|
||||
bumpalo = { version = "3.8.0", features = ["collections"] }
|
||||
libc = "0.2.106"
|
||||
page_size = "0.4.2"
|
||||
snafu = { version = "0.6.10", features = ["backtraces"] }
|
||||
ven_graph = { path = "../vendor/pathfinding" }
|
||||
slab = "0.4.5"
|
||||
|
||||
[dev-dependencies]
|
||||
indoc = "1.0.3"
|
||||
|
||||
[target.'cfg(windows)'.dependencies]
|
||||
winapi = "0.3.9"
|
||||
|
||||
[target.'cfg(unix)'.dependencies]
|
||||
libc = "0.2.106"
|
||||
|
|
|
@ -10,12 +10,10 @@
|
|||
///
|
||||
/// Pages also use the node value 0 (all 0 bits) to mark nodes as unoccupied.
|
||||
/// This is important for performance.
|
||||
use libc::{MAP_ANONYMOUS, MAP_PRIVATE, PROT_READ, PROT_WRITE};
|
||||
use std::any::type_name;
|
||||
use std::ffi::c_void;
|
||||
use std::marker::PhantomData;
|
||||
use std::mem::{align_of, size_of, MaybeUninit};
|
||||
use std::ptr::null;
|
||||
|
||||
pub const NODE_BYTES: usize = 32;
|
||||
|
||||
|
@ -108,14 +106,30 @@ impl Pool {
|
|||
// addresses from the OS which will be lazily translated into
|
||||
// physical memory one 4096-byte page at a time, once we actually
|
||||
// try to read or write in that page's address range.
|
||||
#[cfg(unix)]{
|
||||
use libc::{MAP_ANONYMOUS, MAP_PRIVATE, PROT_READ, PROT_WRITE};
|
||||
|
||||
libc::mmap(
|
||||
null::<c_void>() as *mut c_void,
|
||||
std::ptr::null_mut(),
|
||||
bytes_to_mmap,
|
||||
PROT_READ | PROT_WRITE,
|
||||
MAP_PRIVATE | MAP_ANONYMOUS,
|
||||
0,
|
||||
0,
|
||||
)
|
||||
}
|
||||
#[cfg(windows)]{
|
||||
use winapi::um::memoryapi::{VirtualAlloc};
|
||||
use winapi::um::winnt::{MEM_COMMIT, MEM_RESERVE};
|
||||
use winapi::um::winnt::{PAGE_READWRITE};
|
||||
|
||||
VirtualAlloc(
|
||||
std::ptr::null_mut(),
|
||||
bytes_to_mmap,
|
||||
MEM_COMMIT | MEM_RESERVE,
|
||||
PAGE_READWRITE,
|
||||
)
|
||||
}
|
||||
} as *mut [MaybeUninit<u8>; NODE_BYTES];
|
||||
|
||||
// This is our actual capacity, in nodes.
|
||||
|
@ -230,10 +244,22 @@ impl<T> std::ops::IndexMut<NodeId<T>> for Pool {
|
|||
impl Drop for Pool {
|
||||
fn drop(&mut self) {
|
||||
unsafe {
|
||||
#[cfg(unix)]{
|
||||
libc::munmap(
|
||||
self.nodes as *mut c_void,
|
||||
NODE_BYTES * self.capacity as usize,
|
||||
);
|
||||
}
|
||||
#[cfg(windows)]{
|
||||
use winapi::um::memoryapi::{VirtualFree};
|
||||
use winapi::um::winnt::{MEM_RELEASE};
|
||||
|
||||
VirtualFree(
|
||||
self.nodes as *mut c_void,
|
||||
NODE_BYTES * self.capacity as usize,
|
||||
MEM_RELEASE
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,12 +50,17 @@ fn main() {
|
|||
);
|
||||
|
||||
// OBJECT FILES
|
||||
#[cfg(windows)]
|
||||
const BUILTINS_HOST_FILE: &str = "builtins-host.obj";
|
||||
|
||||
#[cfg(not(windows))]
|
||||
const BUILTINS_HOST_FILE: &str = "builtins-host.o";
|
||||
|
||||
generate_object_file(
|
||||
&bitcode_path,
|
||||
"BUILTINS_HOST_O",
|
||||
"object",
|
||||
"builtins-host.o",
|
||||
BUILTINS_HOST_FILE,
|
||||
);
|
||||
|
||||
generate_object_file(
|
||||
|
|
|
@ -24,7 +24,7 @@ roc_collections = { path = "../compiler/collections" }
|
|||
bumpalo = { version = "3.8.0", features = ["collections"] }
|
||||
clap = { version = "= 3.0.0-beta.5", default-features = false, features = ["std", "color", "suggestions"] }
|
||||
iced-x86 = { version = "1.15.0", default-features = false, features = ["std", "decoder", "op_code_info", "instr_info"] }
|
||||
memmap2 = "0.5.0"
|
||||
memmap2 = "0.5.3"
|
||||
object = { version = "0.26.2", features = ["read", "write"] }
|
||||
serde = { version = "1.0.130", features = ["derive"] }
|
||||
bincode = "1.3.3"
|
||||
|
|
|
@ -20,7 +20,6 @@ use std::io;
|
|||
use std::io::{BufReader, BufWriter};
|
||||
use std::mem;
|
||||
use std::os::raw::c_char;
|
||||
use std::os::unix::fs::PermissionsExt;
|
||||
use std::path::Path;
|
||||
use std::process::Command;
|
||||
use std::time::{Duration, SystemTime};
|
||||
|
@ -1627,9 +1626,14 @@ fn surgery_impl(
|
|||
let flushing_data_duration = flushing_data_start.elapsed().unwrap();
|
||||
|
||||
// Make sure the final executable has permision to execute.
|
||||
// TODO windows alternative?
|
||||
#[cfg(target_family = "unix")]
|
||||
{
|
||||
use std::os::unix::fs::PermissionsExt;
|
||||
let mut perms = fs::metadata(out_filename)?.permissions();
|
||||
perms.set_mode(perms.mode() | 0o111);
|
||||
fs::set_permissions(out_filename, perms)?;
|
||||
}
|
||||
|
||||
let total_duration = total_start.elapsed().unwrap();
|
||||
|
||||
|
|
|
@ -10,8 +10,8 @@ bumpalo = {version = "3.8.0", features = ["collections"]}
|
|||
const_format = "0.2.22"
|
||||
inkwell = {path = "../vendor/inkwell"}
|
||||
libloading = {version = "0.7.1"}
|
||||
rustyline = {git = "https://github.com/rtfeldman/rustyline", tag = "v9.1.1"}
|
||||
rustyline-derive = {git = "https://github.com/rtfeldman/rustyline", tag = "v9.1.1"}
|
||||
rustyline = {git = "https://github.com/rtfeldman/rustyline", rev = "e74333c"}
|
||||
rustyline-derive = {git = "https://github.com/rtfeldman/rustyline", rev = "e74333c"}
|
||||
target-lexicon = "0.12.2"
|
||||
|
||||
roc_build = {path = "../compiler/build"}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue