Merge branch 'trunk' into improve-dependency-solving

This commit is contained in:
Richard Feldman 2020-10-12 10:23:53 -04:00 committed by GitHub
commit a3d81108c3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 37 additions and 11 deletions

View file

@ -122,6 +122,18 @@ fn link_linux(
host_input_path: &Path, host_input_path: &Path,
dest_filename: &Path, dest_filename: &Path,
) -> io::Result<Child> { ) -> 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! // NOTE: order of arguments to `ld` matters here!
// The `-l` flags should go after the `.o` arguments // The `-l` flags should go after the `.o` arguments
Command::new("ld") Command::new("ld")
@ -130,9 +142,9 @@ fn link_linux(
.args(&[ .args(&[
"-arch", "-arch",
arch_str(target), arch_str(target),
"/usr/lib/x86_64-linux-gnu/crti.o", libcrt_path.join("crti.o").to_str().unwrap(),
"/usr/lib/x86_64-linux-gnu/crtn.o", libcrt_path.join("crtn.o").to_str().unwrap(),
"/usr/lib/x86_64-linux-gnu/Scrt1.o", libcrt_path.join("Scrt1.o").to_str().unwrap(),
"-dynamic-linker", "-dynamic-linker",
"/lib64/ld-linux-x86-64.so.2", "/lib64/ld-linux-x86-64.so.2",
// Inputs // Inputs
@ -149,7 +161,7 @@ fn link_linux(
"-lc_nonshared", "-lc_nonshared",
"-lc++", "-lc++",
"-lunwind", "-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 // Output
"-o", "-o",
binary_path.to_str().unwrap(), // app binary_path.to_str().unwrap(), // app

View file

@ -350,8 +350,14 @@ pub fn load(
let arena = Bump::new(); let arena = Bump::new();
// Reserve one CPU for the main thread, and let all the others be eligible // Reserve one CPU for the main thread, and let all the others be eligible
// to spawn workers. // to spawn workers. We use .max(2) to enforce that we always
let num_workers = num_cpus::get() - 1; // 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); let mut worker_arenas = bumpalo::collections::Vec::with_capacity_in(num_workers, &arena);

View file

@ -823,8 +823,15 @@ fn load<'a>(
where where
{ {
// Reserve one CPU for the main thread, and let all the others be eligible // Reserve one CPU for the main thread, and let all the others be eligible
// to spawn workers. // to spawn workers. We use .max(2) to enforce that we always
let num_workers = num_cpus::get() - 1; // 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( let worker_arenas = arena.alloc(bumpalo::collections::Vec::with_capacity_in(
num_workers, num_workers,
arena, arena,

1
examples/.gitignore vendored
View file

@ -1,2 +1,3 @@
app app
host.o host.o
c_host.o

View file

@ -6,7 +6,7 @@ extern "C" {
fn quicksort(list: RocList<i64>) -> RocList<i64>; fn quicksort(list: RocList<i64>) -> RocList<i64>;
} }
const NUM_NUMS: usize = 1_000_000; const NUM_NUMS: usize = 10_000;
#[no_mangle] #[no_mangle]
pub fn rust_main() -> isize { pub fn rust_main() -> isize {
@ -14,7 +14,7 @@ pub fn rust_main() -> isize {
let mut nums = Vec::with_capacity(NUM_NUMS); let mut nums = Vec::with_capacity(NUM_NUMS);
for index in 0..nums.capacity() { for index in 0..nums.capacity() {
let num = index as i64 % 12345; let num = index as i64 % 123;
nums.push(num); nums.push(num);
} }

View file

@ -71,7 +71,7 @@ impl<T> RocList<T> {
let value = *self.get_storage_ptr(); let value = *self.get_storage_ptr();
// NOTE doesn't work with elements of 16 or more bytes // 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), Equal => Some(Storage::ReadOnly),
Less => Some(Storage::Refcounted(value)), Less => Some(Storage::Refcounted(value)),
Greater => Some(Storage::Capacity(value)), Greater => Some(Storage::Capacity(value)),