[ readding the LO list. should get the solution, please keep it in Cc ]

Hi,

Am 01.11.25 um 13:15 schrieb Mohmed Ali:
When I ran:

$ readelf -d rust_uno-example.uno.so <http://rust_uno-example.uno.so> | grep 
NEEDED

NEEDED [ /home/abo-ali/libreoffice/rust_uno/target/release/librust_uno.so ]

and also:

$ ldd rust_uno-example.uno.so <http://rust_uno-example.uno.so> | grep rust_uno

/home/abo-ali/libreoffice/rust_uno/target/release/librust_uno.so (0x...)


It worked locally because that path existed in my build tree, but not in your 
packaged environment.

and probably in any reviewers' local build, too if they tested from the local 
build-tree instdir/ ..

This revealed a *hardcoded absolute path* embedded in the binary.

The issue happens because |$(SRCDIR)| expands to an absolute path at build 
time, which gets permanently embedded in the binary.
[...]
The makefile was linking |librust_uno.so| using an absolute path, so the linker 
recorded that full path in the binary’s *NEEDED* section.

Ah, I see. I wasn't explicitely aware that specifying a full path also 
hardcodes the path.
Makes sense, though.

  *

    *Dev build:* The path existed → worked fine

  *

    *Packaged build:* The path didn’t exist → failed at runtime

Yeah, that sound like it.

Your |LD_LIBRARY_PATH| workaround confirmed this behavior, but it’s not a 
sustainable solution.

Yup.

To fix this, I updated the makefile to use relative search paths and proper 
*RPATH* configuration:
```

$(eval $(call gb_Library_add_ldflags,rust_uno-example,\

     -Wl,-rpath,'$$ORIGIN' \

))

$(eval $(call gb_Library_add_libs,rust_uno-example,\

     -L$(SRCDIR)/rust_uno/target/release -lrust_uno \

))

```
Now, when I check the result:
$ readelf -d workdir/Extension/rust_uno-example/root/rust_uno-example.uno.so 
<http://rust_uno-example.uno.so> | grep NEEDED | grep rust
NEEDED [librust_uno.so]

It shows a *relative dependency* (|librust_uno.so|) instead of the previous 
absolute path.

If this works on your side as well, I’ll prepare a patch for the next update to 
include this fix.

So basically

diff --git a/rust_uno/Library_rust_uno-example.mk 
b/rust_uno/Library_rust_uno-example.mk
index 4f55a5b28296..fc4d9a3d1a7f 100644
--- a/rust_uno/Library_rust_uno-example.mk
+++ b/rust_uno/Library_rust_uno-example.mk
@@ -30,8 +30,11 @@ $(eval $(call gb_Library_use_libraries,rust_uno-example, \
 $(eval $(call gb_Library_use_sdk_api,rust_uno-example))
$(call gb_Library_get_target,rust_uno-example): $(call gb_CustomTarget_get_target,rust_uno/cargo)
+$(eval $(call gb_Library_add_ldflags,rust_uno-example,\
+    -Wl,-rpath,'$$ORIGIN' \
+))
 $(eval $(call gb_Library_add_libs,rust_uno-example,\
-    $(SRCDIR)/rust_uno/target/release/$(if $(filter 
WNT,$(OS_FOR_BUILD)),rust_uno.dll.lib,librust_uno.so) \
+    -L$(SRCDIR)/rust_uno/target/release -lrust_uno \
 ))
# vim: set noet sw=4 ts=4:

Will try now and report back.

Regards,

Rene

Reply via email to