Bug 269241 - lang/spidermonkey102: builds fine with TRYBROKEN=1 on 12.4 (does not fail the readelf check)
Summary: lang/spidermonkey102: builds fine with TRYBROKEN=1 on 12.4 (does not fail the...
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Some People
Assignee: Neel Chauhan
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-01-30 09:56 UTC by John Hein
Modified: 2023-02-13 17:15 UTC (History)
1 user (show)

See Also:
nc: maintainer-feedback+


Attachments
[patch] allow builds on 12.x (1.70 KB, patch)
2023-02-13 12:00 UTC, John Hein
jcfyecrayz: maintainer-approval? (nc)
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description John Hein 2023-01-30 09:56:26 UTC
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 \
Comment 1 John Hein 2023-02-13 12:00:26 UTC
Created attachment 240130 [details]
[patch] allow builds on 12.x

I've been using this actively on 12.3 and 12.4 systems.  Builds fine and run testing is good.

Please look at this and respond - and commit if you agree.
Comment 2 Neel Chauhan freebsd_committer freebsd_triage 2023-02-13 17:12:54 UTC
LGTM. will commit shortly.
Comment 3 Neel Chauhan freebsd_committer freebsd_triage 2023-02-13 17:14:37 UTC
Committed!
Comment 4 commit-hook freebsd_committer freebsd_triage 2023-02-13 17:15:15 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=da17cd55f0add82bef10b8863d94ebe97b106d4a

commit da17cd55f0add82bef10b8863d94ebe97b106d4a
Author:     John Hein <jcfyecrayz@liamekaens.com>
AuthorDate: 2023-02-13 17:13:45 +0000
Commit:     Neel Chauhan <nc@FreeBSD.org>
CommitDate: 2023-02-13 17:13:45 +0000

    lang/spidermonkey102: Fix build on 12.x

    PR:     269241

 lang/spidermonkey102/Makefile                  |  2 --
 lang/spidermonkey102/files/patch-moz.configure | 14 +++++++++++++-
 2 files changed, 13 insertions(+), 3 deletions(-)