diff --git a/cli/tests/cli_run.rs b/cli/tests/cli_run.rs index aa7020700f..6b0f34780b 100644 --- a/cli/tests/cli_run.rs +++ b/cli/tests/cli_run.rs @@ -18,6 +18,13 @@ mod cli_run { #[cfg(not(debug_assertions))] use roc_collections::all::MutMap; + #[cfg(target_os = "linux")] + const TEST_SURGICAL_LINKER: bool = true; + + // Surgical linker currently only supports linux. + #[cfg(not(target_os = "linux"))] + const TEST_SURGICAL_LINKER: bool = false; + #[cfg(not(target_os = "macos"))] const ALLOW_VALGRIND: bool = true; @@ -136,7 +143,6 @@ mod cli_run { ); } } - /// This macro does two things. /// /// First, it generates and runs a separate test for each of the given @@ -184,6 +190,24 @@ mod cli_run { example.expected_ending, example.use_valgrind, ); + + // Also check with the surgical linker. + + if TEST_SURGICAL_LINKER { + if matches!(example.executable_filename, "echo" | "hello-rust") { + eprintln!("WARNING: skipping testing example {} with surgical linking because rust is currently not supported!", example.filename); + return; + } + + check_output_with_stdin( + &file_name, + example.stdin, + example.executable_filename, + &["--roc-linker"], + example.expected_ending, + example.use_valgrind, + ); + } } )* @@ -228,7 +252,7 @@ mod cli_run { }, hello_rust:"hello-rust" => Example { filename: "Hello.roc", - executable_filename: "hello-world", + executable_filename: "hello-rust", stdin: &[], expected_ending:"Hello, World!\n", use_valgrind: true, diff --git a/examples/hello-rust/.gitignore b/examples/hello-rust/.gitignore index 6b820fd903..8485821d7c 100644 --- a/examples/hello-rust/.gitignore +++ b/examples/hello-rust/.gitignore @@ -1 +1 @@ -hello-world +hello-rust diff --git a/examples/hello-rust/Hello.roc b/examples/hello-rust/Hello.roc index d78f48ff19..cd7092308d 100644 --- a/examples/hello-rust/Hello.roc +++ b/examples/hello-rust/Hello.roc @@ -1,4 +1,4 @@ -app "hello-world" +app "hello-rust" packages { base: "platform" } imports [] provides [ main ] to base diff --git a/linker/README.md b/linker/README.md index 0d1e2d77ee..d65d68e14b 100644 --- a/linker/README.md +++ b/linker/README.md @@ -31,7 +31,6 @@ This linker is run in 2 phases: preprocessing and surigical linking. ## TODO (In a lightly prioritized order) -- Run CLI tests and/or benchmarks with the Roc Linker. - Test with an executable completely generated by Cargo (It will hopefully work out of the box like zig). - Add Macho support - Honestly should be almost exactly the same code. diff --git a/linker/src/lib.rs b/linker/src/lib.rs index 1a043fbce1..3fa53e1bbd 100644 --- a/linker/src/lib.rs +++ b/linker/src/lib.rs @@ -199,6 +199,7 @@ fn generate_dynamic_lib( // TODO properly generate this list. for name in &[ format!("roc__{}_1_exposed", sym), + format!("roc__{}_1_exposed_generic", sym), format!("roc__{}_1_Fx_caller", sym), format!("roc__{}_1_Fx_size", sym), format!("roc__{}_1_Fx_result_size", sym),