Skip to content

fix(build): exclude -lutil on Android - #1019

Open
Noah Kirschmann (noah1510) wants to merge 1 commit into
microsoft:mainfrom
noah1510:fix/android-exclude-libutil
Open

Noah Kirschmann (noah1510) wants to merge 1 commit into
microsoft:mainfrom
noah1510:fix/android-exclude-libutil

Conversation

@noah1510

Copy link
Copy Markdown

Goal

Allow node-pty to build and link natively on Android (e.g., Termux / Bionic-based environments) without failing on a missing libutil library.

Summary of Changes

  • Updated binding.gyp to include OS=="android" in the existing libraries! condition that excludes -lutil:
    ['OS=="mac" or OS=="solaris" or OS=="android"', {
      'libraries!': [
        '-lutil'
      ]
    }],

Why

On non-Windows platforms, binding.gyp links against -lutil by default and currently excludes it only on mac and solaris. On Android, Bionic provides openpty/forkpty directly in libc and does not ship a separate libutil, causing native builds to fail at link time when -lutil is passed.

No other changes are needed:

  • The OS=="linux" block in binding.gyp only applies when SYSROOT_PATH is set for Linux sysroot builds.
  • src/unix/pty.cc compiles cleanly under Android via the existing #if defined(__linux__) paths (<pty.h>, openpty/forkpty, pty_close_inherited_fds, and /proc-based pty_getproc).
  • Linux, macOS, Windows, and Solaris builds are completely unaffected.

Testing

  • Built build/Release/pty.node natively on Android (arm64, Termux, node@26.13.1) via node-gyp rebuild — compiled and linked cleanly without warnings or errors.
  • Verified runtime behavior with a smoke test calling pty.open() and pty.fork() (verifying PTY output and clean exit).

Android (Bionic) provides openpty/forkpty directly in libc and does not have a separate libutil library, so exclude -lutil when OS=="android".

Co-authored-by: Antigravity (Gemini 4 Neon) <noreply@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant