ruby / ruby/etc

Android/Termux: etc fails to compile because `getpwent` declarations are unavailable

Open
#99 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C
Stars
33
Forks
16
Avg merge
1h 37m
Merged PRs (30d)
3

Description

My environment
  • OS: Android/Termux
  • arch: aarch64
  • ruby: 4.0.6
  • ruby gems version: 4.0.16
  • gem version: etc 1.4.6
  • compiler used: clang 21.1.8
  • android api: 36
Description

Installing the etc gem is fails while compiling the native extension:

  gem install etc

The configuration step reports that getpwent() is available in the output:

  checking for getpwent()... yes

However, compilation fails because Android's headers looks like not expose declarations for getpwent() and setpwent():

  etc.c:294:5: error: call to undeclared function 'setpwent'
  etc.c:295:18: error: call to undeclared function 'getpwent'
  error: incompatible integer to pointer conversion

Same problem occurs with older versions of the gem, including 1.4.1 through 1.4.5.

The expected behavior

The extension should either (I think):

  1. Compile successfully when these functions are available for the target android api; or
  2. Correctly detect that they are unavailable and disable only the affected functionality.

Current detection appears to report getpwent() as available even though the generated extension cannot compile against the android headers.

Reproduction process

I try to install ruby using Android Termux

  gem install etc --no-document

Relevant output:

  checking for getpwent()... yes
  ...

  error: call to undeclared function 'setpwent'
  error: call to undeclared function 'getpwent'

The declarations in Termux's pwd.h are guarded by Android API availability macros, for example:

  struct passwd *getpwent(void) __INTRODUCED_IN(26);
  void setpwent(void) __INTRODUCED_IN(26);

The etc extension includes pwd.h when HAVE_GETPWENT is defined, but the declarations are not visible for the API configuration used while compiling Ruby.

This causes a mismatch between the feature detection performed by extconf.rb and the code generated by the extension.

Thanks

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with extconf.rb's getpwent detection and etc.c's setpwent/getpwent calls. Reproduce the failure with gem install etc --no-document on Android/Termux, then verify that feature detection matches the declarations available for the configured Android API. Done means the gem compiles successfully or disables only the affected functionality.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, c, ruby
Domain
operating-systems
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.