Skip to content

[Bug]: libxml2 tests runtest fail to link: undefined reference to glob/globfree — fix by linking -landroid-glob #27092

@wuxianggujun

Description

@wuxianggujun

Problem description

Building libxml2 2.15.0 in the Termux builder (aarch64) fails at the tests stage when linking runtest:

ld.lld: error: undefined symbol: glob
ld.lld: error: undefined symbol: globfree
clang: error: linker command failed with exit code 1

On Android, glob(3)/globfree(3) are provided by libandroid-glob, not bionic. With Python bindings/tests enabled, the runtest executable needs to link against -landroid-glob.

Minimal fix that works in practice (recipe-only):

  • Add libandroid-glob to TERMUX_PKG_DEPENDS
  • Add LDFLAGS+=" -landroid-glob" inside termux_step_configure()

This is sufficient because the current build path propagates LDFLAGS to test linking.

Patch (unified diff):

--- a/packages/libxml2/build.sh
+++ b/packages/libxml2/build.sh
@@
-TERMUX_PKG_DEPENDS="libiconv, libicu, zlib"
+TERMUX_PKG_DEPENDS="libiconv, libicu, zlib, libandroid-glob"
@@
 termux_step_configure() {
+    # Ensure glob/globfree resolve on Android tests
+    LDFLAGS+=" -landroid-glob"
     mkdir -p "$TERMUX_PKG_BUILDDIR/python/doc/xml"
     export TERMUX_MESON_ENABLE_SOVERSION=1
     termux_step_configure_meson
 }

Notes:

  • The _XOPEN_SOURCE (600 vs 700) warnings are benign and unrelated.
  • If some environments don’t propagate global LDFLAGS to tests, a target-scoped link arg for runtest in src/meson.build would also work, but the above minimal change fixes the issue in the current builder.

What steps will reproduce the bug?

  1. (Optional) clean caches/markers:

    rm -rf ~/.termux-build/libxml2* ~/.termux-build/python-libxml2*
    rm -f /data/data/.built-packages/libxml2 /data/data/.built-packages/python-libxml2
  2. Build:

    ./build-package.sh -a aarch64 libxml2
  3. Observe link error for runtest:

    ld.lld: error: undefined symbol: glob
    ld.lld: error: undefined symbol: globfree
    

What is the expected behavior?

  • libxml2 builds successfully on Android, including tests (or tests link without undefined symbols).
  • No undefined references to glob/globfree during runtest link.

System information

If reproduced **on device**, paste the output of:


termux-info


If reproduced **only in the Termux package builder**, indicate that here, e.g.:


Not running on device; reproduced in package builder container.

Builder image: ghcr.io/termux/package-builder
Arch: aarch64
Package: libxml2 2.15.0
Python: 3.12 (TERMUX_PKG_SETUP_PYTHON=true; -Dpython=enabled)
Command: ./build-package.sh -a aarch64 libxml2

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug reportSomething is not working properlypackagingIssue related to building packages, not affecting end users directly

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions