Bug 283317 - textproc/sexp: fix build on non-x86
Summary: textproc/sexp: fix build on non-x86
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: Robert Clausecker
URL:
Keywords:
Depends on: 283861
Blocks:
  Show dependency treegraph
 
Reported: 2024-12-13 20:56 UTC by Benjamin Jacobs
Modified: 2025-01-05 14:26 UTC (History)
1 user (show)

See Also:


Attachments
0001-textproc-sexp-fix-build-on-non-x86.patch (2.44 KB, patch)
2024-12-13 20:56 UTC, Benjamin Jacobs
freebsd: maintainer-approval+
Details | Diff
sexp-0.17.0 build log on armv7 FreeBSD 14 (281.34 KB, text/plain)
2024-12-15 17:04 UTC, Robert Clausecker
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Benjamin Jacobs 2024-12-13 20:56:58 UTC
Created attachment 255843 [details]
0001-textproc-sexp-fix-build-on-non-x86.patch

Hi,

The attached patch allows textproc/sexp to build and run on aarch64.

With this patch, textproc/sexp will start to work on armv7 as well only once lang/ocaml is switched over to using the hard-float abi (which I intent to submit next, but since that will require rev-bumping many ports, I'm hoping to bundle that change as part of a larger ocaml update).

Thanks!
Comment 1 Robert Clausecker freebsd_committer freebsd_triage 2024-12-14 01:37:57 UTC
The ocaml change sounds interesting.  I had tried to get it working on armv7 for a while, but do not understand enough about it to make it so.
Comment 2 Robert Clausecker freebsd_committer freebsd_triage 2024-12-14 13:36:48 UTC
Shall I merge this one into the quarterly branch?
Comment 3 Benjamin Jacobs 2024-12-14 14:31:55 UTC
(In reply to Robert Clausecker from comment #2)

Not needed as textproc/sexp only exists in main, as far as I can tell.

For the armv7 stuff, I'll try to get it ready before Q1 is branched.
Comment 4 Robert Clausecker freebsd_committer freebsd_triage 2024-12-15 17:04:09 UTC
Created attachment 255881 [details]
sexp-0.17.0 build log on armv7 FreeBSD 14

Build fails on armv7, see attached log file.
Build succeeds on arm64 though; do you wish to proceed with the patch?
Comment 5 Benjamin Jacobs 2024-12-15 18:38:36 UTC
(In reply to Robert Clausecker from comment #4)

Hi, yes please you can proceeed with the patch. As noted above, that armv7 failure is unfortunately still expected. I'm hoping to fix that failure by producing a fix for lang/ocaml.

In short, that failure is caused by the non-functionning floating-point support of the "native-mode" compiler of OCaml on armv7 on freebsd. This can be demonstrated by the following command, which will output a non-sensical value instead of the well-known answer:
  echo "print_float 42.0" > pf.ml ; ocamlopt pf.ml && ./a.out

The longer and probably less accurate explanation is that sexp uses a ppx transformer to serialize-deserialize json, said transformer relies on a library which must know what is the range of integers that can safely be represented in a float (or maybe the oppositite?), and since the floating point support is broken, this determination of the safe-range triggers an assertion. 

I'm working on a patch for lang/ocaml to fix the armv7-a/VFPv3 support instead of using the soft-float abi (which, I assume, is non-working on freebsd), but although it seems to work okayish (at least to buil sexp), there is still a correctness issue exhibed by the ocaml test suite. I need more time to investigate.

If that plan doesn't work (fixing lang/ocaml), then maybe it would be possible to use the bytecode mode of ocaml to work around this issue on armv7. In any case, it would be nice to already unlock textproc/sexp for aarch64 (and possibly ppc64?).
Comment 6 Robert Clausecker freebsd_committer freebsd_triage 2024-12-15 21:39:51 UTC
(In reply to Benjamin Jacobs from comment #5)

Thanks.  I will proceed with the patch as is.  I was unsure if the armv7 breakage you mentioned and this one were related, so I wanted to ask to make sure it was expected.
Comment 7 commit-hook freebsd_committer freebsd_triage 2024-12-17 00:59:36 UTC
A commit in branch main references this bug:

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

commit 16187b44a7cd7a0db611a5fccc0d4a42293e95f5
Author:     Benjamin Jacobs <freebsd@dev.thsi.be>
AuthorDate: 2024-12-12 19:45:51 +0000
Commit:     Robert Clausecker <fuz@FreeBSD.org>
CommitDate: 2024-12-17 00:57:21 +0000

    textproc/sexp: fix build on non-x86

    PR:             283317

 ...ndor_base-0.16.3_src_discover_discover.ml (new) | 12 ++++++++
 ...ntrinsics-0.16.1_src_discover_discover.ml (new) | 32 ++++++++++++++++++++++
 2 files changed, 44 insertions(+)
Comment 8 Robert Clausecker freebsd_committer freebsd_triage 2024-12-17 01:03:38 UTC
Thank you for your contribution.
Comment 9 Benjamin Jacobs 2024-12-17 08:49:01 UTC
Thanks!