[Bug 269241] lang/spidermonkey102: builds fine with TRYBROKEN=1 on 12.4 (does not fail the readelf check)

From: <bugzilla-noreply_at_freebsd.org>
Date: Mon, 30 Jan 2023 09:56:26 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=269241

            Bug ID: 269241
           Summary: lang/spidermonkey102: builds fine with TRYBROKEN=1 on
                    12.4 (does not fail the readelf check)
           Product: Ports & Packages
           Version: Latest
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Some People
          Priority: ---
         Component: Individual Port(s)
          Assignee: nc@FreeBSD.org
          Reporter: jcfyecrayz@liamekaens.com
          Assignee: nc@FreeBSD.org
             Flags: maintainer-feedback?(nc@FreeBSD.org)

Building lang/spidermonkey102 works fine on FreeBSD 12.4 with TRYBROKEN=1 (or
with poudriere, testport or bulk -T).

It was marked broken with scant details (a brief comment about not finding
readelf), so it's not clear what may have "fixed" it (nor how to reproduce the
reported problem), and no reference to a problem report with any further
information.

Digging further, it turns out that moz.configure has the following check:

def validate_readelf(path):
 .
 .
    retcode, stdout, stderr = get_cmd_output(path, "--help")
    return retcode == 0 and any(l.startswith("  -d ") for l in
stdout.splitlines())

It attempts to check the output of 'readelf --help' to see if -d is supported. 
But /usr/bin/readelf (from the BSD licensed elftoolchain project) sends the
output of --help to stderr rather than stdout.  This is why the check failed
for /usr/bin/readelf.

As of FreeBSD 12.4, however, there is also /usr/bin/llvm-readelf.  The
configure script checks for that flavor of readelf as well, and llvm-readelf
DOES send --help output to stdout.  In fact, the configure check tries
llvm-readelf first before trying to fall back to readelf.

So, on 12.4, the configure check for readelf does not fail as it did for 12.3. 
Here is the snippet showing how 'make configure' fails in 12.3:

 .
 .
checking for readelf... not found
DEBUG: readelf: Looking for llvm-readelf
DEBUG: readelf: Looking for x86_64-portbld-freebsd12.3-readelf
DEBUG: readelf: Looking for x86_64-freebsd12.3-readelf
DEBUG: readelf: Looking for readelf
DEBUG: Executing: `/usr/bin/readelf --help`
DEBUG: readelf: /usr/bin/readelf found but didn't work

 .
 .


Now on 12.4, the configure check is happy:

 .
 .
checking for readelf... /usr/bin/llvm-readelf
checking for objcopy... /usr/bin/llvm-objcopy
 .
 .

[Incidentally, the GNU readelf also sends --help output to stdout as well. So
this problem never occurred on most or all Linux distributions.]

One COULD fix the configure check to also look at stderr like so:

--- work/firefox-102.4.0/moz.configure.orig     2022-10-10 09:55:56.000000000
-0600
+++ work/firefox-102.4.0/moz.configure  2023-01-29 21:22:35.614382000 -0700
@@ -812,7 +812,8 @@ def validate_readelf(path):
     # option in the `--help` output, which fortunately, s compatible between
     # llvm-readelf and readelf.
     retcode, stdout, stderr = get_cmd_output(path, "--help")
-    return retcode == 0 and any(l.startswith("  -d ") for l in
stdout.splitlines())
+    return retcode == 0 and (any(l.startswith("  -d ") for l in
stdout.splitlines()) \
+        or any(l.startswith("  -d ") for l in stderr.splitlines()))


 @depends("--enable-compile-environment", target, host)

But now that 12.4 has llvm-readelf, that patch is not needed unless we want to
support 12.3, which goes EOL in March, 2023.  If so, adding the above patch
does the job.

Given that 12.3 is shortly going to be EOL and the project package builders are
using 12.4, I think we should just remove the BROKEN_FreeBSD_12 from
lang/spidermonkey102/Makefile:


diff --git a/lang/spidermonkey102/Makefile b/lang/spidermonkey102/Makefile
index 219c5543fe83..3f32420c85c6 100644
--- a/lang/spidermonkey102/Makefile
+++ b/lang/spidermonkey102/Makefile
@@ -13,8 +13,6 @@ WWW=          https://spidermonkey.dev/
 LICENSE=       MPL20
 LICENSE_FILE=  ${WRKSRC}/LICENSE

-BROKEN_FreeBSD_12=     ERROR: Cannot find readelf
-
 BUILD_DEPENDS=
${LOCALBASE}/bin/python${PYTHON3_DEFAULT}:lang/python${PYTHON3_DEFAULT:S/.//g}
\
                ${RUST_DEFAULT}>=1.35:lang/${RUST_DEFAULT} \
                autoconf2.13:devel/autoconf2.13 \

-- 
You are receiving this mail because:
You are the assignee for the bug.