From a6a14cb13158795c5d5aa44a90823e0f1e96332b Mon Sep 17 00:00:00 2001 From: Paul Schoenfelder Date: Mon, 27 Feb 2023 01:56:50 -0500 Subject: [PATCH] fix: ensure libunwind is linked on linux --- Cargo.lock | 1 + compiler/linker/src/lib.rs | 21 ++++++++++++++------- firefly/Cargo.toml | 1 + tools/firefly-make/src/build.rs | 2 +- 4 files changed, 17 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8e6e14ecd..09f8854e5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -480,6 +480,7 @@ dependencies = [ "firefly_util", "human-panic", "log", + "unwind", ] [[package]] diff --git a/compiler/linker/src/lib.rs b/compiler/linker/src/lib.rs index 788cb810b..9ba37b657 100644 --- a/compiler/linker/src/lib.rs +++ b/compiler/linker/src/lib.rs @@ -146,17 +146,24 @@ impl ProjectInfo { .map(|t| t.dir.clone()) .unwrap_or_else(|| options.host_tlib_path.dir.clone()); let prefix = &options.target.options.staticlib_prefix; - info.used_deps - .push(match options.target.options.panic_strategy { - PanicStrategy::Abort => Dependency { + match options.target.options.panic_strategy { + PanicStrategy::Abort => { + info.used_deps.push(Dependency { name: Symbol::intern("panic_abort"), source: Some(fireflylib_dir.join(&format!("{}panic_abort.rlib", prefix))), - }, - PanicStrategy::Unwind => Dependency { + }); + } + PanicStrategy::Unwind => { + info.used_deps.push(Dependency { name: Symbol::intern("panic_unwind"), source: Some(fireflylib_dir.join(&format!("{}panic_unwind.rlib", prefix))), - }, - }); + }); + info.used_deps.push(Dependency { + name: Symbol::intern("unwind"), + source: Some(fireflylib_dir.join(&format!("{}unwind.rlib", prefix))), + }); + } + } if options.target.options.is_like_wasm { info.used_deps.push(Dependency { name: Symbol::intern("firefly_emulator"), diff --git a/firefly/Cargo.toml b/firefly/Cargo.toml index 0ae322f23..16d0f10c1 100644 --- a/firefly/Cargo.toml +++ b/firefly/Cargo.toml @@ -29,3 +29,4 @@ log.workspace = true [build-dependencies] firefly_crt = { path = "../runtimes/crt" } firefly_emulator = { path = "../runtimes/emulator" } +unwind = { path = "../compiler/unwind" } diff --git a/tools/firefly-make/src/build.rs b/tools/firefly-make/src/build.rs index 371c9fc50..b3b680ff0 100644 --- a/tools/firefly-make/src/build.rs +++ b/tools/firefly-make/src/build.rs @@ -476,7 +476,7 @@ pub fn run(config: &Config) -> anyhow::Result<()> { println!("Installing runtime libraries.."); - let firefly_libs = &["firefly_emulator"]; + let firefly_libs = &["firefly_emulator", "unwind"]; for lib in firefly_libs.iter().copied() { if let Some(files) = deps.get(lib) { for file in files.iter() {