Bug 220590 - math/fftw3: fails to build on armv6 (729 ports skipped)
Summary: math/fftw3: fails to build on armv6 (729 ports skipped)
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: Jason E. Hale
URL:
Keywords: needs-patch, regression
Depends on:
Blocks:
 
Reported: 2017-07-10 05:29 UTC by Jan Beich
Modified: 2018-10-10 21:45 UTC (History)
2 users (show)

See Also:
jhale: maintainer-feedback+
koobs: merge-quarterly+


Attachments
Disable unsafe-math-optimizations on armv6 (527 bytes, patch)
2017-07-12 10:54 UTC, Jason E. Hale
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jan Beich freebsd_committer 2017-07-10 05:29:37 UTC
3.3.5 built fine but 3.3.6 (both pl1 and pl2) don't. Both arm* and mips* have LDBL_PREC=53 but 3.3.6 builds fine on mips*, so the issue is Clang-related. It seems -O1 (or higher) combined with -ffast-math makes it emit references to sincos() rather than sin() + cos().

../libbench2/libbench2.a(verify-lib.o): In function `aphase_shift':
verify-lib.c:(.text+0x580): undefined reference to `sincos'
../libbench2/libbench2.a(verify-lib.o): In function `tf_shift':
verify-lib.c:(.text+0x1440): undefined reference to `sincos'
verify-lib.c:(.text+0x1794): undefined reference to `sincos'
cc: error: linker command failed with exit code 1 (use -v to see invocation)

https://lists.freebsd.org/pipermail/freebsd-pkg-fallout/Week-of-Mon-20170703/498191.html # fftw3
https://lists.freebsd.org/pipermail/freebsd-pkg-fallout/Week-of-Mon-20170703/498192.html # fftw3-float
https://lists.freebsd.org/pipermail/freebsd-pkg-fallout/Week-of-Mon-20170703/498863.html # fftw3-long
Comment 1 Jan Beich freebsd_committer 2017-07-10 05:37:29 UTC
Affected FreeBSD versions: 11.0 (clang 3.8), 11.1 (clang 4.0), 12.0 (clang500-import).
Workarounds: define USE_GCC=yes or drop -ffast-math.
Comment 2 Jan Beich freebsd_committer 2017-07-10 05:40:39 UTC
Err, -ffast-math is a group of flags. The issue is caused by -funsafe-math-optimizations.
Comment 3 Jan Beich freebsd_committer 2017-07-10 05:47:00 UTC
Here's a test case:

$ cat a.c
#include <stdio.h>
#include <math.h>

int main(int argc, char *argv[])
{
  printf("%Lf\n", cosl(5));
  printf("%Lf\n", sinl(5));
  return 0;
}

$ cc a.c -lm -O1 -funsafe-math-optimizations
/tmp/a-718f07.o: In function `main':
a.c:(.text+0x18): undefined reference to `sincos'
cc: error: linker command failed with exit code 1 (use -v to see invocation)
Comment 4 mikael.urankar 2017-07-10 14:39:53 UTC
(In reply to Jan Beich from comment #1)
Are you sure 12 is affected?
Comment 5 Jan Beich freebsd_committer 2017-07-10 14:48:03 UTC
(In reply to mikael.urankar from comment #4)
> Are you sure 12 is affected?

Ah, you're right! When writing comment 1 I've only checked whether sincos is emitted but not if libm contains it. comment 3 example builds fine on 12.0 with clang 4.0 and clang 5.0.
Comment 6 Jason E. Hale freebsd_committer 2017-07-12 10:54:29 UTC
Created attachment 184300 [details]
Disable unsafe-math-optimizations on armv6

This patch should disable "unsafe-math-optimizations" on armv6. I'm not sure at what point it started working on 12.x, so I just used a generic version check. I don't have the ability to test this, so any feedback would be appreciated.
Comment 7 mikael.urankar 2017-07-12 10:59:13 UTC
The 11 branch is missing this commit which solved the problem on 12: base r319047
Comment 8 Jason E. Hale freebsd_committer 2017-07-12 11:02:23 UTC
(In reply to mikael.urankar from comment #7)

Ok, I'll change it to check for less than 1200032, then. Thanks!
Comment 9 mikael.urankar 2017-07-13 13:36:09 UTC
or you can use (untested)
CFLAGS_armv6=	-fno-builtin-sincos -fno-builtin-sin -fno-builtin-cos \
		-fno-builtin-sincosf -fno-builtin-sinf -fno-builtin-cosf \
		-fno-builtin-sincosl -fno-builtin-sinl -fno-builtin-cosl
Comment 10 commit-hook freebsd_committer 2017-07-31 11:59:09 UTC
A commit references this bug:

Author: jhale
Date: Mon Jul 31 11:58:28 UTC 2017
New revision: 446955
URL: https://svnweb.freebsd.org/changeset/ports/446955

Log:
  Fix build on armv6. The -funsafe-math-optimizations flag in Clang (pulled in by
  -ffast-math) is emitting references to the sincos() function which is not
  implemented on versions of FreeBSD < 1200032. Workaround by adding
  -fno-unsafe-math-optimizations to armv6 CFLAGS.

  /bin/sh ../libtool  --tag=CC   --mode=link /nxb-bin/usr/bin/cc -D_THREAD_SAFE -pthread -O2 -pipe  -O3 -ffast-math -fstrict-aliasing -fomit-frame-pointer   -o bench bench-bench.o bench-hook.o bench-fftw-bench.o ../threads/libfftw3_threads.la ../libfftw3.la ../libbench2/libbench2.a  -lm
  libtool: link: /nxb-bin/usr/bin/cc -D_THREAD_SAFE -pthread -O2 -pipe -O3 -ffast-math -fstrict-aliasing -fomit-frame-pointer -o .libs/bench bench-bench.o bench-hook.o bench-fftw-bench.o  ../threads/.libs/libfftw3_threads.so ../.libs/libfftw3.so ../libbench2/libbench2.a -lm -pthread -Wl,-rpath -Wl,/usr/local/lib
  ./libbench2/libbench2.a(verify-lib.o): In function `aphase_shift':
  verify-lib.c:(.text+0x578): undefined reference to `sincos'
  ./libbench2/libbench2.a(verify-lib.o): In function `tf_shift':
  verify-lib.c:(.text+0x13a0): undefined reference to `sincos'
  verify-lib.c:(.text+0x16e4): undefined reference to `sincos'
  cc: error: linker command failed with exit code 1 (use -v to see invocation)
  gmake[3]: *** [Makefile:400: bench] Error 1
  gmake[3]: Leaving directory '/wrkdirs/usr/ports/math/fftw3/work/fftw-3.3.6-pl2/tests'
  gmake[2]: *** [Makefile:684: all-recursive] Error 1
  gmake[2]: Leaving directory '/wrkdirs/usr/ports/math/fftw3/work/fftw-3.3.6-pl2'
  gmake[1]: *** [Makefile:549: all] Error 2
  gmake[1]: Leaving directory '/wrkdirs/usr/ports/math/fftw3/work/fftw-3.3.6-pl2'
  *** Error code 1

  PR:		220590
  Submitted by:	jbeich

Changes:
  head/math/fftw3/Makefile
Comment 11 commit-hook freebsd_committer 2017-07-31 12:17:25 UTC
A commit references this bug:

Author: jhale
Date: Mon Jul 31 12:16:28 UTC 2017
New revision: 446956
URL: https://svnweb.freebsd.org/changeset/ports/446956

Log:
  MFH: r446955

  Fix build on armv6. The -funsafe-math-optimizations flag in Clang (pulled in by
  -ffast-math) is emitting references to the sincos() function which is not
  implemented on versions of FreeBSD < 1200032. Workaround by adding
  -fno-unsafe-math-optimizations to armv6 CFLAGS.

  /bin/sh ../libtool  --tag=CC   --mode=link /nxb-bin/usr/bin/cc -D_THREAD_SAFE -pthread -O2 -pipe  -O3 -ffast-math -fstrict-aliasing -fomit-frame-pointer   -o bench bench-bench.o bench-hook.o bench-fftw-bench.o ../threads/libfftw3_threads.la ../libfftw3.la ../libbench2/libbench2.a  -lm
  libtool: link: /nxb-bin/usr/bin/cc -D_THREAD_SAFE -pthread -O2 -pipe -O3 -ffast-math -fstrict-aliasing -fomit-frame-pointer -o .libs/bench bench-bench.o bench-hook.o bench-fftw-bench.o  ../threads/.libs/libfftw3_threads.so ../.libs/libfftw3.so ../libbench2/libbench2.a -lm -pthread -Wl,-rpath -Wl,/usr/local/lib
  ./libbench2/libbench2.a(verify-lib.o): In function `aphase_shift':
  verify-lib.c:(.text+0x578): undefined reference to `sincos'
  ./libbench2/libbench2.a(verify-lib.o): In function `tf_shift':
  verify-lib.c:(.text+0x13a0): undefined reference to `sincos'
  verify-lib.c:(.text+0x16e4): undefined reference to `sincos'
  cc: error: linker command failed with exit code 1 (use -v to see invocation)
  gmake[3]: *** [Makefile:400: bench] Error 1
  gmake[3]: Leaving directory '/wrkdirs/usr/ports/math/fftw3/work/fftw-3.3.6-pl2/tests'
  gmake[2]: *** [Makefile:684: all-recursive] Error 1
  gmake[2]: Leaving directory '/wrkdirs/usr/ports/math/fftw3/work/fftw-3.3.6-pl2'
  gmake[1]: *** [Makefile:549: all] Error 2
  gmake[1]: Leaving directory '/wrkdirs/usr/ports/math/fftw3/work/fftw-3.3.6-pl2'
  *** Error code 1

  PR:		220590
  Submitted by:	jbeich

  Approved by:	ports-secteam (blanket)

Changes:
_U  branches/2017Q3/
  branches/2017Q3/math/fftw3/Makefile
Comment 12 commit-hook freebsd_committer 2018-10-10 21:45:30 UTC
A commit references this bug:

Author: jbeich
Date: Wed Oct 10 21:44:42 UTC 2018
New revision: 481771
URL: https://svnweb.freebsd.org/changeset/ports/481771

Log:
  math/fftw3: drop FreeBSD 11.1 support per EOL

  PR:		220590 (for tracking)

Changes:
  head/math/fftw3/Makefile