Bug 225488

Summary: clang-6.0.0 crashes building multimedia/libvpx
Product: Base System Reporter: Pawel Pekala <pawel>
Component: binAssignee: freebsd-toolchain (Nobody) <toolchain>
Status: Closed FIXED    
Severity: Affects Some People CC: cem, dim, emaste, jbeich
Priority: ---    
Version: CURRENT   
Hardware: amd64   
OS: Any   
Bug Depends on:    
Bug Blocks: 224669    
Attachments:
Description Flags
shell file
none
c file none

Description Pawel Pekala freebsd_committer freebsd_triage 2018-01-27 12:13:37 UTC
cc  -O2 -pipe -march=native  -fstack-protector -fno-strict-aliasing -m64 -DNDEBUG -O3 -fPIC -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0 -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -Wall -Wdeclaration-after-statement -Wdisabled-optimization -Wfloat-conversion -Wparentheses-equality -Wpointer-arith -Wtype-limits -Wcast-qual -Wvla -Wimplicit-function-declaration -Wuninitialized -Wunused -Wextra -Wundef -Wshorten-64-to-32 -I. -I"/usr/local/ports/multimedia/libvpx/work/libvpx-1.7.0" -msse2 -c -o vpx_dsp/x86/variance_sse2.c.o vpx_dsp/x86/variance_sse2.c
SplitVectorResult #0: t25: v8i64 = llvm.x86.avx512.psad.bw.512 TargetConstant:i64<5820>, t11, t5

fatal error: error in backend: Do not know how to split the result of this operator!

cc: error: clang frontend command failed with exit code 70 (use -v to see invocation)
FreeBSD clang version 6.0.0 (branches/release_60 323338) (based on LLVM 6.0.0)
Target: x86_64-unknown-freebsd12.0
Thread model: posix
InstalledDir: /usr/bin
cc: note: diagnostic msg: PLEASE submit a bug report to https://bugs.freebsd.org/submit/ and include the crash backtrace, preprocessed source, and associated run script.
cc: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
cc: note: diagnostic msg: /tmp/sad4d_avx512-2e4c36.c
cc: note: diagnostic msg: /tmp/sad4d_avx512-2e4c36.sh
cc: note: diagnostic msg: 

********************
gmake[2]: *** [Makefile:157: vpx_dsp/x86/sad4d_avx512.c.o] Error 70
gmake[2]: *** Waiting for unfinished jobs....
gmake[1]: *** [Makefile:17: .DEFAULT] Error 2
gmake[1]: Leaving directory '/usr/local/ports/multimedia/libvpx/work/libvpx-1.7.0'
===> Compilation failed unexpectedly.

FreeBSD blaviken.kreta.org 12.0-CURRENT FreeBSD 12.0-CURRENT #13 r328465: Sat Jan 27 12:47:49 CET 2018     root@blaviken.kreta.org:/usr/obj/hdd/src/amd64.amd64/sys/GENERIC  amd64
Comment 1 Pawel Pekala freebsd_committer freebsd_triage 2018-01-27 12:17:23 UTC
Created attachment 190105 [details]
shell file

sad4d_avx512-2e4c36.c is 2.4MB and cannot be attached. I can send it privately if someone is interested in this bug.
Comment 2 Jan Beich freebsd_committer freebsd_triage 2018-01-27 13:02:30 UTC
(In reply to Pawel Pekala from comment #0)
> vpx_dsp/x86/variance_sse2.c

A few lines below it says vpx_dsp/x86/sad4d_avx512.c. After playing a bit with attachment 190105 [details] the issue seems to be -march=native injecting -mno-sse4.1 which isn't reverted by -mavx* e.g.,

$ cd /usr/ports/multimedia/libvpx
$ make clean configure
$ cd `make -V WRKSRC`
$ gmake vpx_dsp_rtcd.h
$ cc -mno-sse4.1 -mavx512bw -I. -c -o vpx_dsp/x86/sad4d_avx512.c.o vpx_dsp/x86/sad4d_avx512.c

(In reply to Pawel Pekala from comment #1)
> sad4d_avx512-2e4c36.c is 2.4MB and cannot be attached.

Compressing with xz(1) should've worked as well e.g., bug 225086 has one 8.5MB large if uncompressed.
Comment 3 Pawel Pekala freebsd_committer freebsd_triage 2018-01-27 13:27:28 UTC
Created attachment 190111 [details]
c file
Comment 4 Pawel Pekala freebsd_committer freebsd_triage 2018-01-27 13:57:20 UTC
Removing -march=native from CFLAGS leads to correct build.
Comment 5 commit-hook freebsd_committer freebsd_triage 2018-01-28 16:11:24 UTC
A commit references this bug:

Author: dim
Date: Sun Jan 28 16:10:41 UTC 2018
New revision: 328513
URL: https://svnweb.freebsd.org/changeset/base/328513

Log:
  Pull in r322245 from upstream clang trunk (by Craig Topper):

    [X86] Make -mavx512f imply -mfma and -mf16c in the frontend like it
    does in the backend.

    Similarly, make -mno-fma and -mno-f16c imply -mno-avx512f.

    Withou this  "-mno-sse -mavx512f" ends up with avx512f being enabled
    in the frontend but disabled in the backend.

  Reported by:	pawel
  PR:		225488

Changes:
  head/contrib/llvm/tools/clang/lib/Basic/Targets/X86.cpp
Comment 6 Dimitry Andric freebsd_committer freebsd_triage 2018-01-28 16:13:05 UTC
Fixed in r328513.  I have also submitted a request upstream to merge it into the clang 6.0 branch.