Bug 229885

Summary: benchmarks/stress-ng isn't broken on i386, something else is.
Product: Ports & Packages Reporter: dewayne
Component: Individual Port(s)Assignee: Luca Pizzamiglio <pizzamig>
Status: Closed FIXED    
Severity: Affects Some People Flags: pizzamig: maintainer-feedback+
Priority: ---    
Version: Latest   
Hardware: i386   
OS: Any   

Description dewayne 2018-07-19 08:15:20 UTC
I last built stress-ng-0.09.27.txz on i386 on 30th May on a FreeBSD 11.1Stable which was built around late April.  

After upgrading to latest 11.2Stable with clang 6.0.1 and rebuilding stress-ng 0.09.33 I obtain lots of messages like
stress-atomic.c:(.text+0x467): undefined reference to `__atomic_fetch_sub_8'
which is why the maintainer marked this port as broken in the Makefile.

So I went hunting, as I'm experiencing quite a few other ports problems.  I switched into a revert/build cycle and attempted to rebuild back to 0.09.23.  All experienced the same failure.  So... the problem isn't with stress-ng.

I've found that its quickest to simply force the build with gcc7, which in this case easily rebuilt stress-ng 0.09.23 AND stress-ng-0.09.33.

I suspect clang 6.0.X so I need to revert clang from 6.0.1 back to 5.0.0; but without reverting the buildworld as it would be preferable to establish that other libraries (or the kernel) weren't the issue. But how?

stress-ng 0.09.33 built and ran cleanly on amd64 under clang 6.0.1

Aside and incidentally, other ports that I had to modify build attributes for  were: textproc/htdig sysutils/npadmin net/isc-dhcp44-* on both i386 & amd64.  security/openssh-portable has only had a flavored enhancement but building has proven intractable in our environ, we enable one option BSM...
Comment 1 Luca Pizzamiglio freebsd_committer freebsd_triage 2018-07-23 10:24:56 UTC
Hi. I had the same issue with librdkafka. The issue is in clang 6.
Until clang 6 was only in current, I just marked them BROKEN there.
Then FreeBSD 11.2 came out (with clang 6) and I extended BROKEN to FreeBSD 11.2.

The problem is the configure/test: clang 6 perform some inline magic, and the configure tests believe that, on i386, atomic_add_fetch 8 byte long does exist, but when it compiles the real code, it fails, because it doesn't exist at all.

I'm in the process to update to stress-ng 0.09.34 and my solution is to add the attribute noinline to the function that tests atomics. Disabling inline there, the test code failed to compile, as expected.

I don't know exactly what triggered this issue, I wrote to the mailing list, but no solutions came out (https://readlist.com/lists/freebsd.org/freebsd-current/24/124939.html), but Dimitry sent a bug report in clang (https://bugs.llvm.org/show_bug.cgi?id=34347)
Comment 2 commit-hook freebsd_committer freebsd_triage 2018-07-23 15:53:31 UTC
A commit references this bug:

Author: pizzamig
Date: Mon Jul 23 15:52:54 UTC 2018
New revision: 475186
URL: https://svnweb.freebsd.org/changeset/ports/475186

Log:
  benchmarks/stress-ng: Update to 0.09.35

  While I'm upgrading, I fix the atomic 64 bit detection on clang6
  The current solution is to for the noinline attribute to the
  atomic detection code

  PR:		229885

Changes:
  head/benchmarks/stress-ng/Makefile
  head/benchmarks/stress-ng/distinfo
Comment 3 Luca Pizzamiglio freebsd_committer freebsd_triage 2018-07-23 15:55:38 UTC
I linked the commit that fix the build.
You can see in the makefile where I add the noinline attribute.

Thanks for motivating me to find a proper solution