mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-30 15:21:12 +00:00
Merge branch 'trunk' into improve-dependency-solving
This commit is contained in:
commit
a3d81108c3
6 changed files with 37 additions and 11 deletions
|
@ -122,6 +122,18 @@ fn link_linux(
|
|||
host_input_path: &Path,
|
||||
dest_filename: &Path,
|
||||
) -> io::Result<Child> {
|
||||
let libcrt_path = if Path::new("/usr/lib/x86_64-linux-gnu").exists() {
|
||||
Path::new("/usr/lib/x86_64-linux-gnu")
|
||||
} else {
|
||||
Path::new("/usr/lib")
|
||||
};
|
||||
let libgcc_path = if Path::new("/lib/x86_64-linux-gnu/libgcc_s.so.1").exists() {
|
||||
Path::new("/lib/x86_64-linux-gnu/libgcc_s.so.1")
|
||||
} else if Path::new("/usr/lib/x86_64-linux-gnu/libgcc_s.so.1").exists() {
|
||||
Path::new("/usr/lib/x86_64-linux-gnu/libgcc_s.so.1")
|
||||
} else {
|
||||
Path::new("/usr/lib/libgcc_s.so.1")
|
||||
};
|
||||
// NOTE: order of arguments to `ld` matters here!
|
||||
// The `-l` flags should go after the `.o` arguments
|
||||
Command::new("ld")
|
||||
|
@ -130,9 +142,9 @@ fn link_linux(
|
|||
.args(&[
|
||||
"-arch",
|
||||
arch_str(target),
|
||||
"/usr/lib/x86_64-linux-gnu/crti.o",
|
||||
"/usr/lib/x86_64-linux-gnu/crtn.o",
|
||||
"/usr/lib/x86_64-linux-gnu/Scrt1.o",
|
||||
libcrt_path.join("crti.o").to_str().unwrap(),
|
||||
libcrt_path.join("crtn.o").to_str().unwrap(),
|
||||
libcrt_path.join("Scrt1.o").to_str().unwrap(),
|
||||
"-dynamic-linker",
|
||||
"/lib64/ld-linux-x86-64.so.2",
|
||||
// Inputs
|
||||
|
@ -149,7 +161,7 @@ fn link_linux(
|
|||
"-lc_nonshared",
|
||||
"-lc++",
|
||||
"-lunwind",
|
||||
// "-lgcc", // TODO will eventually need compiler_rt from gcc or something - see https://github.com/rtfeldman/roc/pull/554#discussion_r496370840
|
||||
libgcc_path.to_str().unwrap(),
|
||||
// Output
|
||||
"-o",
|
||||
binary_path.to_str().unwrap(), // app
|
||||
|
|
|
@ -350,8 +350,14 @@ pub fn load(
|
|||
let arena = Bump::new();
|
||||
|
||||
// Reserve one CPU for the main thread, and let all the others be eligible
|
||||
// to spawn workers.
|
||||
let num_workers = num_cpus::get() - 1;
|
||||
// to spawn workers. We use .max(2) to enforce that we always
|
||||
// end up with at least 1 worker - since (.max(2) - 1) will
|
||||
// always return a number that's at least 1. Using
|
||||
// .max(2) on the initial number of CPUs instead of
|
||||
// doing .max(1) on the entire expression guards against
|
||||
// num_cpus returning 0, while also avoiding wrapping
|
||||
// unsigned subtraction overflow.
|
||||
let num_workers = num_cpus::get().max(2) - 1;
|
||||
|
||||
let mut worker_arenas = bumpalo::collections::Vec::with_capacity_in(num_workers, &arena);
|
||||
|
||||
|
|
|
@ -823,8 +823,15 @@ fn load<'a>(
|
|||
where
|
||||
{
|
||||
// Reserve one CPU for the main thread, and let all the others be eligible
|
||||
// to spawn workers.
|
||||
let num_workers = num_cpus::get() - 1;
|
||||
// to spawn workers. We use .max(2) to enforce that we always
|
||||
// end up with at least 1 worker - since (.max(2) - 1) will
|
||||
// always return a number that's at least 1. Using
|
||||
// .max(2) on the initial number of CPUs instead of
|
||||
// doing .max(1) on the entire expression guards against
|
||||
// num_cpus returning 0, while also avoiding wrapping
|
||||
// unsigned subtraction overflow.
|
||||
let num_workers = num_cpus::get().max(2) - 1;
|
||||
|
||||
let worker_arenas = arena.alloc(bumpalo::collections::Vec::with_capacity_in(
|
||||
num_workers,
|
||||
arena,
|
||||
|
|
1
examples/.gitignore
vendored
1
examples/.gitignore
vendored
|
@ -1,2 +1,3 @@
|
|||
app
|
||||
host.o
|
||||
c_host.o
|
||||
|
|
|
@ -6,7 +6,7 @@ extern "C" {
|
|||
fn quicksort(list: RocList<i64>) -> RocList<i64>;
|
||||
}
|
||||
|
||||
const NUM_NUMS: usize = 1_000_000;
|
||||
const NUM_NUMS: usize = 10_000;
|
||||
|
||||
#[no_mangle]
|
||||
pub fn rust_main() -> isize {
|
||||
|
@ -14,7 +14,7 @@ pub fn rust_main() -> isize {
|
|||
let mut nums = Vec::with_capacity(NUM_NUMS);
|
||||
|
||||
for index in 0..nums.capacity() {
|
||||
let num = index as i64 % 12345;
|
||||
let num = index as i64 % 123;
|
||||
|
||||
nums.push(num);
|
||||
}
|
||||
|
|
|
@ -71,7 +71,7 @@ impl<T> RocList<T> {
|
|||
let value = *self.get_storage_ptr();
|
||||
|
||||
// NOTE doesn't work with elements of 16 or more bytes
|
||||
match usize::cmp(&0, &value) {
|
||||
match isize::cmp(&(value as isize), &0) {
|
||||
Equal => Some(Storage::ReadOnly),
|
||||
Less => Some(Storage::Refcounted(value)),
|
||||
Greater => Some(Storage::Capacity(value)),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue