<div dir="ltr"><div><div><div><div><div><div>Git commit <a href="http://git.openwrt.org/?p=openwrt.git;a=commitdiff;h=98b042952a9ee8513ead66040ce4261e7a011aba;hp=122ba8031d2311429e94014ad98849c51b3b634f">98b0429</a> added the `$staging_dir/host/lib` directory to `$LD_LIBRARY_PATH`.<br></div>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`.<br><br></div>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.<br></div>And that’s exactly what’s happening in my case:<br><br>~~~~<br>[nix-shell:~/proj/openwrt/openwrt]$ make V=s<br>make: *** [world] Segmentation fault<br>~~~~<br><br></div>It
turns, the failing line is `mkdir -p tmp` from the
`staging_dir/host/.prereq-build` in `include/<a href="http://toplevel.mk">toplevel.mk</a>`. `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.<br><br></div>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`.<br><br></div>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.</div>