[OpenWrt-Devel] Setting LD_LIBRARY_PATH is not cool

Kirill Elagin kirelagin at gmail.com
Thu May 21 01:59:06 EDT 2015


Git commit 98b0429
<http://git.openwrt.org/?p=openwrt.git;a=commitdiff;h=98b042952a9ee8513ead66040ce4261e7a011aba;hp=122ba8031d2311429e94014ad98849c51b3b634f>
added the `$staging_dir/host/lib` directory to `$LD_LIBRARY_PATH`.
The problem with this approach is that some host tools used during the
build might need libraries from non-standard locations. They know where to
look for the libraries as they have proper `RUNPATH`.

Setting `$LD_LIBRARY_PATH` makes `ld.so` try to load libraries from the
wrong location first, and if it happens so that it finds the library there,
the program will fail.
And that’s exactly what’s happening in my case:

~~~~
[nix-shell:~/proj/openwrt/openwrt]$ make V=s
make: *** [world] Segmentation fault
~~~~

It turns, the failing line is `mkdir -p tmp` from the
`staging_dir/host/.prereq-build` in `include/toplevel.mk`. `mkdir` is
trying to load `libc.so` and loads an incompatible libc that is found in
`/lib`, instead of the one it needs, which resides in a non-standard
location.

And that brings me to the second issue. The mentioned commit adds
`$(STAGING_DIR_HOST)/lib` to `$LIBRARY_PATH`, but, as far as I can tell,
`$(STAGING_DIR_HOST)` is not available there, so it ends up adding `/lib`.

I might be missing something crucial, but this last point makes me suspect
that the original idea never actually worked, and the fact that no one
noticed this suggests that the two lines can be safely dropped. Binaries in
`$(STAGING_DIR_HOST)/bin` that need special libraries have proper `RUNPATH`
anyway.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.infradead.org/pipermail/openwrt-devel/attachments/20150521/46fa57e2/attachment.htm>
-------------- next part --------------
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


More information about the openwrt-devel mailing list