Skip to content

Commit 0ab473f

Browse files
authored
fix bug with libdl.so and unused libraries (#1482)
My earlier PR had a bug that led to an error when `--use-built-in-libdl` was specified and there were unused libraries provided by the user _and_ `--stub-missing-functions` was _not_ used. This adds a test to exercise that case and moves the `self.use_built_in_libdl = false;` statement so that it is always run prior to a recursive call to `Linker::encode`. Signed-off-by: Joel Dice <[email protected]>
1 parent bcabe03 commit 0ab473f

File tree

10 files changed

+814
-1
lines changed

10 files changed

+814
-1
lines changed

crates/wit-component/src/linking.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1257,6 +1257,7 @@ impl Linker {
12571257
/// Encode the component and return the bytes
12581258
pub fn encode(mut self) -> Result<Vec<u8>> {
12591259
if self.use_built_in_libdl {
1260+
self.use_built_in_libdl = false;
12601261
self = self.library("libdl.so", include_bytes!("../libdl.so"), false)?;
12611262
}
12621263

@@ -1343,7 +1344,6 @@ impl Linker {
13431344
.all(|(_, export)| export.flags.contains(SymbolFlags::BINDING_WEAK)))
13441345
{
13451346
self.stub_missing_functions = false;
1346-
self.use_built_in_libdl = false;
13471347
self.libraries.push((
13481348
"wit-component:stubs".into(),
13491349
make_stubs_module(&missing),

0 commit comments

Comments
 (0)