diff --git a/ci/package_release.sh b/ci/package_release.sh index 534ab74bde..6f307d8134 100755 --- a/ci/package_release.sh +++ b/ci/package_release.sh @@ -10,20 +10,18 @@ strip ./target/release-with-lto/roc_language_server # to be able to delete "target" later cp target/release-with-lto/roc ./roc cp target/release-with-lto/roc_language_server ./roc_language_server +cp target/release-with-lto/wasi-libc.a wasi-libc.a # delete unnecessary files and folders -git clean -fdx --exclude roc --exclude roc_language_server +git clean -fdx --exclude roc --exclude roc_language_server --exclude wasi-libc.a -mkdir $1 +mkdir -p $1 $1/examples $1/crates/compiler/builtins/bitcode +mv roc roc_language_server lib LICENSE LEGAL_DETAILS $1 -mv roc roc_language_server LICENSE LEGAL_DETAILS $1 - -mkdir $1/examples mv examples/helloWorld.roc examples/platform-switching examples/cli $1/examples -mkdir -p $1/crates/compiler/builtins/bitcode mv crates/roc_std $1/crates mv crates/compiler/builtins/bitcode/src $1/crates/compiler/builtins/bitcode -tar -czvf "$1.tar.gz" $1 \ No newline at end of file +tar -czvf "$1.tar.gz" $1 diff --git a/crates/compiler/build/src/link.rs b/crates/compiler/build/src/link.rs index 347f713f41..8eb9c411ae 100644 --- a/crates/compiler/build/src/link.rs +++ b/crates/compiler/build/src/link.rs @@ -119,10 +119,17 @@ fn find_zig_glue_path() -> PathBuf { } fn find_wasi_libc_path() -> PathBuf { + // This path is available when built and run from source // Environment variable defined in wasi-libc-sys/build.rs - let wasi_libc_pathbuf = PathBuf::from(WASI_LIBC_PATH); - if std::path::Path::exists(&wasi_libc_pathbuf) { - return wasi_libc_pathbuf; + let build_path = PathBuf::from(WASI_LIBC_PATH); + if std::path::Path::exists(&build_path) { + return build_path; + } + + // This path is available in the release tarball + match get_relative_path(Path::new("wasi-libc.a")) { + Some(path) if path.exists() => return path, + _ => (), } internal_error!("cannot find `wasi-libc.a`") diff --git a/crates/wasi-libc-sys/build.rs b/crates/wasi-libc-sys/build.rs index 838a5dc2d0..70eddef4f6 100644 --- a/crates/wasi-libc-sys/build.rs +++ b/crates/wasi-libc-sys/build.rs @@ -8,9 +8,17 @@ fn main() { println!("cargo:rerun-if-changed=build.rs"); println!("cargo:rerun-if-changed=src/dummy.c"); + // out_dir == "/target/[/]/build/wasi_libc_sys_/" let out_dir = env::var("OUT_DIR").unwrap(); let zig_cache_dir = PathBuf::from(&out_dir).join("zig-cache"); - let out_file = PathBuf::from(&out_dir).join("wasi-libc.a"); + + // out_file == "/target/[/]/lib/wasi-libc.a" + let mut out_file = PathBuf::from(&out_dir); + out_file.pop(); + out_file.pop(); + out_file.pop(); + out_file.push("lib"); + out_file.push("wasi-libc.a"); // Compile a dummy C program with Zig, with our own private cache directory zig() @@ -38,6 +46,7 @@ fn main() { .unwrap(); // Copy libc to where Cargo expects the output of this crate + fs::create_dir_all(out_file.parent().unwrap()).unwrap(); fs::copy(libc_path, &out_file).unwrap(); println!(