Bug 236546 - [PATCH] math/mprime: does not work on FreeBSD 12.
Summary: [PATCH] math/mprime: does not work on FreeBSD 12.
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: Steve Wills
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-03-15 07:09 UTC by Ivan Rozhuk
Modified: 2019-04-12 20:20 UTC (History)
4 users (show)

See Also:
rozhuk.im: maintainer-feedback+
rozhuk.im: merge-quarterly?


Attachments
patch (12.09 KB, patch)
2019-03-15 07:09 UTC, Ivan Rozhuk
no flags Details | Diff
patch (5.25 KB, patch)
2019-03-15 07:14 UTC, Ivan Rozhuk
rozhuk.im: maintainer-approval+
Details | Diff
Force mprime linking to use BFD ld (1.24 KB, patch)
2019-03-16 12:28 UTC, Dimitry Andric
no flags Details | Diff
readelf -aW output for lld-linked mprime executable (649.45 KB, text/plain)
2019-03-16 12:29 UTC, Dimitry Andric
no flags Details
readelf -aW output for bfd-linked mprime executable (653.29 KB, text/plain)
2019-03-16 12:30 UTC, Dimitry Andric
no flags Details
use LLD_UNSAFE instead of gcc to avoid run error on FreeBSD 12 (5.19 KB, patch)
2019-03-16 17:39 UTC, Ivan Rozhuk
rozhuk.im: maintainer-approval+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ivan Rozhuk 2019-03-15 07:09:26 UTC
Created attachment 202876 [details]
patch

I discover that mprime fail to start on FreeBSD 12.
There is something wrong with compiling/linking the used clang.
Then build with gcc - run ok.

Also multithreaded build enabled.
Comment 1 Ivan Rozhuk 2019-03-15 07:14:56 UTC
Created attachment 202877 [details]
patch
Comment 2 Dimitry Andric freebsd_committer freebsd_triage 2019-03-16 12:28:03 UTC
Created attachment 202908 [details]
Force mprime linking to use BFD ld

There's definitely something fishy going on:

$ gdb /usr/local/bin/mprime-real
GNU gdb (GDB) 8.2.1 [GDB v8.2.1 for FreeBSD]
...
(gdb) run
Starting program: /usr/local/bin/mprime-real
target.c:2238: internal-error: void target_mourn_inferior(ptid_t): Assertion `ptid == inferior_ptid' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Quit this debugging session? (y or n) y

This is a bug, please report it.  For instructions, see:
<http://www.gnu.org/software/gdb/bugs/>.

target.c:2238: internal-error: void target_mourn_inferior(ptid_t): Assertion `ptid == inferior_ptid' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Create a core file of GDB? (y or n) n

And even worse, the dynamic linker asserts on it:

$ ldd /usr/local/bin/mprime-real
/usr/local/bin/mprime-real:
/usr/local/bin/mprime-real: signal 6

It looks like ld.lld is mangling the executable somehow: when I force the mprime-real executable to be linked with ld.bfd, it does run correctly.  See the force-ld-bfd-1.diff patch.
Comment 3 Dimitry Andric freebsd_committer freebsd_triage 2019-03-16 12:29:42 UTC
Created attachment 202909 [details]
readelf -aW output for lld-linked mprime executable
Comment 4 Dimitry Andric freebsd_committer freebsd_triage 2019-03-16 12:30:05 UTC
Created attachment 202910 [details]
readelf -aW output for bfd-linked mprime executable
Comment 5 Ivan Rozhuk 2019-03-16 16:45:16 UTC
(In reply to Dimitry Andric from comment #2)
LLD_UNSAFE=	yes
should do same.
Comment 6 Dimitry Andric freebsd_committer freebsd_triage 2019-03-16 17:28:37 UTC
(In reply to rozhuk.im from comment #5)
> (In reply to Dimitry Andric from comment #2)
> LLD_UNSAFE=	yes
> should do same.

I thought of that, but it doesn't seem to work since the makefile is rather non-standard and doesn't follow any regular conventions.  But if it works for you, please use it.
Comment 7 Ivan Rozhuk 2019-03-16 17:39:24 UTC
Created attachment 202917 [details]
use LLD_UNSAFE instead of gcc to avoid run error on FreeBSD 12
Comment 8 Ivan Rozhuk 2019-03-16 17:44:26 UTC
(In reply to Dimitry Andric from comment #6)
It wotks for me because I already patch makefiles to proper handle LDFLAGS and other staff.
Comment 9 commit-hook freebsd_committer freebsd_triage 2019-04-12 20:18:14 UTC
A commit references this bug:

Author: swills
Date: Fri Apr 12 20:17:33 UTC 2019
New revision: 498741
URL: https://svnweb.freebsd.org/changeset/ports/498741

Log:
  math/mprime: avoid runtime issue

  PR:		236546
  Submitted by:	rozhuk.im@gmail.com (maintainer)

Changes:
  head/math/mprime/Makefile
  head/math/mprime/files/patch-gwnum_makebsd64
  head/math/mprime/files/patch-gwnum_makemsys
  head/math/mprime/files/patch-linux64_makebsd
  head/math/mprime/files/patch-linux_makebsd
Comment 10 Steve Wills freebsd_committer freebsd_triage 2019-04-12 20:20:14 UTC
Committed, thanks!