Bug 216718

Summary: multimedia/ffmpeg: clang 4.0 crashes with -O3 -march=native
Product: Ports & Packages Reporter: Jan Beich <jbeich>
Component: Individual Port(s)Assignee: freebsd-multimedia (Nobody) <multimedia>
Status: Closed FIXED    
Severity: Affects Only Me CC: dim, w.schwarzenfeld
Priority: --- Keywords: needs-patch
Version: LatestFlags: bugzilla: maintainer-feedback? (multimedia)
Hardware: i386   
OS: Any   
See Also: https://llvm.org/bugs/show_bug.cgi?id=31847
Bug Depends on:    
Bug Blocks: 216008    
Description Flags
libavfilter/vf_waveform.c (preprocessed, compressed)
command line args (for clang 4.0) none

Description Jan Beich freebsd_committer 2017-02-02 07:49:20 UTC
ffmpeg already passes -O3 by default as part of OPTIMIZED_CFLAGS option, so only CPUTYPE?=native in make.conf was something new.

Assertion failed: (isLoopInvariant(Operands[i], L) && "SCEVAddRecExpr operand is not loop-invariant!"), function getAddRecExpr, file /usr/src/contrib/llvm/lib/Analysis/ScalarEvolution.cpp, line 2963.
cc: error: unable to execute command: Abort trap
cc: error: clang frontend command failed due to signal (use -v to see invocation)
FreeBSD clang version 4.0.0 (branches/release_40 293443) (based on LLVM 4.0.0)
Target: i386-unknown-freebsd12.0
Thread model: posix
InstalledDir: /usr/bin
Comment 1 Jan Beich freebsd_committer 2017-02-02 07:50:32 UTC
Created attachment 179517 [details]
libavfilter/vf_waveform.c (preprocessed, compressed)
Comment 2 Jan Beich freebsd_committer 2017-02-02 07:52:36 UTC
Created attachment 179518 [details]
command line args (for clang 4.0)

Alternatively, one can do the following:

  $ cd /usr/ports/multimedia/ffmpeg
  $ make configure
  $ cd $(make -V WRKSRC)
  $ cc -m32 -O3 -march=haswell -I. -c libavfilter/vf_waveform.c
Comment 3 Dimitry Andric freebsd_committer 2017-02-02 12:09:18 UTC
Reproduced with llvm trunk r293557.  I submitted an upstream bug report here:
Comment 4 Walter Schwarzenfeld freebsd_triage 2018-01-10 03:25:22 UTC
If I understand this right

it seems done, and could be closed.
Comment 5 Jan Beich freebsd_committer 2018-01-10 08:21:58 UTC
Agree, I can't reproduce the crash on either FreeBSD 11.1 or via devel/llvm40 using either the attached sample or building the port on i386 with CPUTYPE set.