package/icu: fix build failure due to a library clash

ICU build scripting adds some host libraries to LD_LIBRARY_PATH by
using constructs of the following form:

  LD_LIBRARY_PATH="custom-path:${LD_LIBRARY_PATH}"

If the original LD_LIBRARY_PATH is empty, this causes the last search
directory be an empty string, i.e. the working directory.

ICU build runs some basic host commands (e.g. "rm") in $(TARGET_DIR)/lib
under such an LD_LIBRARY_PATH, causing target libraries (e.g. libc) to
possibly get loaded instead of host system libraries if they are
compatible enough (e.g. arch matches).

Since the target libraries may not actually be ABI compatible with host
system binaries (e.g. target has an old libc), this can cause crashes
or other errors.

Observed errors include:
  (1) rm: libc.so.6: version `GLIBC_2.33' not found (required by rm)
  (2) sh: line 1: 1362670 Segmentation fault      (core dumped) rm -f libicudata.so.65

Workaround the issue by setting a dummy LD_LIBRARY_PATH when it would
otherwise be empty.

https://unicode-org.atlassian.net/browse/ICU-21417

Signed-off-by: Anssi Hannula <anssi.hannula@bitwise.fi>
Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
This commit is contained in:
Anssi Hannula 2021-12-16 18:45:22 +02:00 committed by Arnout Vandecappelle (Essensium/Mind)
parent e84bb6d295
commit ac1c781149

View file

@ -50,6 +50,17 @@ HOST_ICU_CONF_OPTS = \
ICU_SUBDIR = source
HOST_ICU_SUBDIR = source
# ICU build scripting adds paths to LD_LIBRARY_PATH using
# LD_LIBRARY_PATH="custom-path:${LD_LIBRARY_PATH}"
# which, if LD_LIBRARY_PATH was empty, causes the last search directory
# to be the working directory, causing the build to try to load target
# libraries, possibly crashing the build due to ABI mismatches.
# Workaround by ensuring LD_LIBRARY_PATH is never empty.
# https://unicode-org.atlassian.net/browse/ICU-21417
ifeq ($(LD_LIBRARY_PATH),)
ICU_MAKE_ENV += LD_LIBRARY_PATH=/dev/null
endif
ICU_CUSTOM_DATA_PATH = $(call qstrip,$(BR2_PACKAGE_ICU_CUSTOM_DATA_PATH))
ifneq ($(ICU_CUSTOM_DATA_PATH),)