Android: libDispatch link error `ld.gold: error: cannot find -lutil` due entry `link "util"` in bionic.modulemap.gyb

Hello,

Am I only one who getting link errors in libDispatch after recent updates .)

The issue in missed libutil referenced in glibc.modulemap file generated from bionic.modulemap.gyb.

// File: stdlib/public/Platform/bionic.modulemap.gyb

module SwiftGlibc [system] {
  // FIXME: util contains rarely used functions and not usually needed.
  // Unfortunately link directive doesn't work in the submodule yet.
  link "util"

  link "dl"

...

I don't see libutil in Android NDK:

find . -type f -iname *.a -or -iname *.so | grep arch-arm/ | grep dl
./platforms/android-23/arch-arm/usr/lib/libdl.a
./platforms/android-23/arch-arm/usr/lib/libdl.so
...
./platforms/android-28/arch-arm/usr/lib/libdl.a
./platforms/android-28/arch-arm/usr/lib/libdl.so


find . -type f -iname *.a -or -iname *.so | grep arch-arm/ | grep util

NO RESULTS

Is that libutil is something really exists in Android NDK or it is artefact from Linux. Should we remove link "util" from file bionic.modulemap.gyb?

Thank you!


UPDATE 1: Additional info:

Native libraries must use only public API, and must not link against
non-NDK platform libraries. Starting with API 24 this rule is enforced
and applications are no longer able to load non-NDK platform libraries.
The rule is enforced by the dynamic linker, so non-public libraries are
not accessible regardless of the way code tries to loa
 them: System.loadLibrary, DT_NEEDED entries, and
direct calls to dlopen(3) will all work exactly the same.

Taken from: https://android.googlesource.com/platform/bionic/+/master/android-changes-for-ndk-developers.md


References:

  1. Related PR: https://github.com/apple/swift/pull/25082/files
  2. File bionic.modulemap.gyb: https://github.com/apple/swift/blob/master/stdlib/public/Platform/bionic.modulemap.gyb
  3. https://android.googlesource.com/platform/bionic/+/master/android-changes-for-ndk-developers.md

It may have been an improper link previously as I don't think that anyone else was trying to build the android SDK on Windows. util is used for one of the submodules, so I would like to investigate this before actually removing it. I don't know if anything in the android side of things is currently using the APIs from util, but if nothing is, then it should be safe to remove the link as well as the submodule.