toybox icon indicating copy to clipboard operation
toybox copied to clipboard

"no acceptable grep could be found" when building GNU Make (and others)

Open absolutelynothinghere opened this issue 2 years ago • 9 comments

When building GNU Make, the configure scripts displays the following error:

checking for grep that handles long lines and -e... configure: error: no acceptable grep could be found in /usr/local/sbin:/usr/local/bin:/usr/bin:/usr/sbin:/sbin:/bin:/usr/xpg4/bin

Many other configure scripts show the exact same error, I'm guessing this is a standard autotools test that toybox grep is failing.

absolutelynothinghere avatar Oct 26 '23 11:10 absolutelynothinghere

Acknowledged, I'll try to take a look this weekend. (Please poke me on monday if I forget.)

landley avatar Oct 26 '23 12:10 landley

autoconf has gotten extra-annoying because when I insert toybox grep into the start of the $PATH, the test finds /bin/grep later in the $PATH anyway and uses that without comment. How this is supposed to be sane behavior I don't know, but it means I need to rewrite logwrap to be able to use a second path variable instead of just traversing $PATH like ccache and friends.

Working on it, need to adjust test environment to lie to autoconf harder...

landley avatar Oct 27 '23 09:10 landley

So if I understand correctly, the issue is that autoconf can't find toybox grep, not that toybox grep doesn't pass the tests?

absolutelynothinghere avatar Oct 27 '23 12:10 absolutelynothinghere

No, it's that in my local test setup when toybox grep doesn't pass whatever test it ran, it silently falls back to calling /bin/grep anyway. Just saying I need to rework my test setup to stop autoconf from trying to be "clever"...

landley avatar Oct 28 '23 07:10 landley

Note that if you just put "GNU" into the output of grep --version, autoconf skips the check and Make has no trouble building afaict

davidar avatar Apr 19 '24 04:04 davidar

Sed also has this problem because autotools. ("If you are into pain, get the autotools book.. Read it awhile, throw it in a box and start sacrificing to Cthulu.")

Custom --version output will fix it (e.g. "This is not GNU grep 9.0") but that also means that grep will also have to manually help.

These lines somewhere in the main function, TOYFLAG_NOHELP in the option flags, and (help)(version) in the option string:

  // Lie to autoconf when it asks stupid questions, so configure regexes
  // that look for "GNU sed version %f" greater than some old buggy number
  // don't fail us for not matching their narrow expectations.
  if (FLAG(version)) {
    xprintf("This is not GNU grep version 9.0\n");
    return;
  }

  // Handling our own --version means we handle our own --help too.
  if (FLAG(help)) return show_help(stdout, 0);

oliverkwebb avatar Apr 19 '24 04:04 oliverkwebb

Note that if you just put "GNU" into the output of grep --version, autoconf skips the check and Make has no trouble building afaict

Yeah, I did the same thing for sed ages ago. The problem is if autoconf is traversing the REST of the $PATH to find broken commands and use those instead when the first one wasn't happy, then I may need to redesign my logpath wrapper so the remaining commands aren't in $PATH but are in some other variable entirely. (That's my pending $TODO item here.)

landley avatar Apr 20 '24 16:04 landley

Try commit d0e44b3a8cbd

landley avatar Jul 19 '24 04:07 landley

Try commit d0e44b3

I was able to successfully compile GNU Make with this, so I guess the issue is solved. Thank you!

When can we expect the upcoming release with this fix?

absolutelynothinghere avatar Aug 02 '24 17:08 absolutelynothinghere