Bug 239567

Summary: multimedia/ffmpeg: build with FLITE=on fails
Product: Ports & Packages Reporter: VVD <vvd>
Component: Individual Port(s)Assignee: freebsd-multimedia mailing list <multimedia>
Status: Closed FIXED    
Severity: Affects Only Me CC: mi, sobomax
Priority: --- Keywords: regression
Version: LatestFlags: jbeich: maintainer-feedback+
Hardware: Any   
OS: Any   
See Also: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=239712

Description VVD 2019-08-01 02:30:15 UTC
12.0-p8 i386.

Part of build log:
====================================================================
cc -Llibavcodec -Llibavdevice -Llibavfilter -Llibavformat -Llibavresample -Llibavutil -Llibpostproc -Llibswscale -Llibswresample -fstack-protector-strong -L/usr/local/lib   -Wl,--as-needed -Wl,-z,noexecstack -Wl,--warn-common -Wl,-rpath-link=libpostproc:libswresample:libswscale:libavfilter:libavdevice:libavformat:libavcodec:libavutil:libavresample -Qunused-arguments   -o ffprobe_g fftools/cmdutils.o fftools/ffprobe.o  -lavdevice -lavfilter -lavformat -lavcodec -lavresample -lpostproc -lswresample -lswscale -lavutil  -lm -L/usr/local/lib -ldrm -L/usr/local/lib -lxcb -L/usr/local/lib -lxcb-shm -L/usr/local/lib -lxcb-shape -L/usr/local/lib -lxcb-xfixes -L/usr/local/lib -lcdio_paranoia -lcdio_cdda -lcdio -lm -lcam -L/usr/local/lib -ldc1394 -L/usr/local/lib -lcaca -lGL -L/usr/local/lib -lv4l2 -lXv -lX11 -lXext -pthread -lm -L/usr/local/lib -lbs2b -L/usr/local/lib -llilv-0 -ldl -lsratom-0 -lsord-0 -lserd-0 -L/usr/local/lib -lrubberband -lstdc++ -lflite_cmu_time_awb -lflite_cmu_us_awb -lflite_cmu_us_kal -lflite_cmu_us_kal16 -lflite_cmu_us_rms -lflite_cmu_us_slt -lflite_usenglish -lflite_cmulex -lflite -L/usr/local/lib -lfribidi -L/usr/local/lib -ltesseract -L/usr/local/lib -lopencv_aruco -lopencv_bgsegm -lopencv_bioinspired -lopencv_ccalib -lopencv_dnn_modern -lopencv_dnn_objdetect -lopencv_dpm -lopencv_face -lopencv_freetype -lopencv_fuzzy -lopencv_hdf -lopencv_hfs -lopencv_img_hash -lopencv_line_descriptor -lopencv_optflow -lopencv_reg -lopencv_rgbd -lopencv_saliency -lopencv_sfm -lopencv_stereo -lopencv_stitching -lopencv_structured_light -lopencv_phase_unwrapping -lopencv_superres -lopencv_surface_matching -lopencv_tracking -lopencv_datasets -lopencv_text -lopencv_dnn -lopencv_plot -lopencv_videostab -lopencv_photo -lopencv_xfeatures2d -lopencv_shape -lopencv_video -lopencv_ml -lopencv_ximgproc -lopencv_calib3d -lopencv_features2d -lopencv_highgui -lopencv_videoio -lopencv_flann -lopencv_xobjdetect -lopencv_imgcodecs -lopencv_objdetect -lopencv_xphoto -lopencv_imgproc -lopencv_core -L/usr/local/lib -lva -L/usr/local/lib -lass -L/usr/local/lib -lvidstab -L/usr/local/lib -lzmq -L/usr/local/lib -lzimg -L/usr/local/lib -lOpenCL -L/usr/local/lib -lfontconfig -lfreetype -L/usr/local/lib -lfreetype -lm -L/usr/local/lib -lxml2 -lbz2 -L/usr/local/lib -lgme -L/usr/local/lib -lmodplug -L/usr/local/lib -lopenmpt -lstdc++ -L/usr/local/lib -lbluray -lz -lssl -lcrypto -L/usr/local/lib -lrtmp -lz -L/usr/local/lib -lssh -L/usr/local/lib/samba4 -lsmbclient -L/usr/local/lib -lvpx -lm -L/usr/local/lib -lvpx -lm -L/usr/local/lib -lvpx -lm -L/usr/local/lib -lvpx -lm -L/usr/local/lib -lwebpmux -lwebp -pthread -lm -llzma -L/usr/local/lib -ldav1d -lcelt0 -lopencore-amrwb -L/usr/local/lib -lrsvg-2 -lm -lgio-2.0 -lgdk_pixbuf-2.0 -lgobject-2.0 -lglib-2.0 -lintl -lcairo -lpthread -L/usr/local/lib -lzvbi -lintl -R/usr/local/lib -lpthread -lm -lpng -lz -lsnappy -lstdc++ -lz -L/usr/local/lib -laom -lcodec2 -L/usr/local/lib -lfdk-aac -lgsm -lilbc -pthread -lmp3lame -lm -lopencore-amrnb -L/usr/local/lib -lopenjp2 -L/usr/local/lib -lopus -L/usr/local/lib -lspeex -ltheoraenc -ltheoradec -logg -ltwolame -lvo-amrwbenc -L/usr/local/lib -lvorbis -L/usr/local/lib -lvorbisenc -lwavpack -L/usr/local/lib -lwebp -L/usr/local/lib -lx264 -L/usr/local/lib -lx265 -lxvidcore -L/usr/local/lib -lopenh264 -L/usr/local/lib -lkvazaar -L/usr/local/lib -lva -lm -lm -lm -lsoxr -lm -pthread -L/usr/local/lib -lva-drm -lva -L/usr/local/lib -lva-x11 -lva -lvdpau -lX11 -lm -L/usr/local/lib -ldrm -L/usr/local/lib -lOpenCL -L/usr/local/lib -lva -lXv -lX11 -lXext  
/usr/local/lib/libflite_cmu_us_kal.so: undefined reference to `cmu_postlex'
/usr/local/lib/libflite_cmu_us_awb.so: undefined reference to `usenglish_init'
/usr/local/lib/libflite_cmu_us_awb.so: undefined reference to `cmu_lex_init'
cc: error: linker command failed with exit code 1 (use -v to see invocation)
gmake[2]: *** [Makefile:108: ffprobe_g] Error 1
gmake[2]: *** Waiting for unfinished jobs....
/usr/local/lib/libflite_cmu_us_kal.so: undefined reference to `cmu_postlex'
/usr/local/lib/libflite_cmu_us_awb.so: undefined reference to `usenglish_init'
/usr/local/lib/libflite_cmu_us_awb.so: undefined reference to `cmu_lex_init'
cc: error: linker command failed with exit code 1 (use -v to see invocation)
gmake[2]: *** [Makefile:108: ffmpeg_g] Error 1
gmake[2]: Leaving directory '/usr/obj/usr/ports/multimedia/ffmpeg/work/ffmpeg-4.1.4'
===> Compilation failed unexpectedly.
Try to set MAKE_JOBS_UNSAFE=yes and rebuild before reporting the failure to
the maintainer.
*** Error code 1

Stop.
make[1]: stopped in /usr/ports/multimedia/ffmpeg
*** Error code 1

Stop.
make: stopped in /usr/ports/multimedia/ffmpeg

===>>> make build failed for multimedia/ffmpeg
====================================================================

audio/flite was rebuilded fine.
Comment 1 Jan Beich freebsd_committer 2019-08-01 07:49:09 UTC
Not a ffmpeg issue.

(In reply to VVD from comment #0)
> /usr/local/lib/libflite_cmu_us_kal.so: undefined reference to `cmu_postlex'
> /usr/local/lib/libflite_cmu_us_awb.so: undefined reference to `cmu_lex_init'

ffmpeg already links against -lflite_cmulex.

> /usr/local/lib/libflite_cmu_us_awb.so: undefined reference to `usenglish_init'

ffmpeg already links against -lflite_usenglish.
Comment 2 Jan Beich freebsd_committer 2019-08-01 08:10:13 UTC
Nevermind. -Wl,--as-needed in ffmpeg build is the culprit.
Comment 3 commit-hook freebsd_committer 2019-08-01 09:14:10 UTC
A commit references this bug:

Author: jbeich
Date: Thu Aug  1 09:13:34 UTC 2019
New revision: 507762
URL: https://svnweb.freebsd.org/changeset/ports/507762

Log:
  multimedia/ffmpeg: unbreak FLITE=on with Clang after r507592

  -Wl,--as-needed is partially broken in base GNU bfd:
  /usr/local/lib/libflite_cmu_us_awb.so: undefined reference to `usenglish_init'
  /usr/local/lib/libflite_cmu_us_awb.so: undefined reference to `cmu_lex_init'
  /usr/local/lib/libflite_cmu_us_kal.so: undefined reference to `cmu_postlex'

  PR:		239567
  Reported by:	VVD

Changes:
  head/multimedia/ffmpeg/Makefile
Comment 4 VVD 2019-08-01 11:26:58 UTC
Thanks!

Build fine on 12.0 i386 now.
But it build fine on 12.0 amd64 (with flite) before this patch too.
Comment 5 Jan Beich freebsd_committer 2019-08-01 19:12:06 UTC
(In reply to VVD from comment #4)
> But it build fine on 12.0 amd64 (with flite) before this patch too.

12.0 amd64 defaults to WITH_LLD_IS_LD, see src.conf(5) or /usr/src/share/mk/src.opts.mk. On non-Clang architectures lang/gcc* is used which defaults to ld.bfd from devel/binutils, not affected by -Wl,--as-needed bug.

-Wl,--as-needed is used by upstream to avoid overlinking: -lflite* are passed globally but only libavfilter actually needs those. -lflite* are underlinked libraries, so interdependencies are left to deal with by consumers. Unfortunately, without direct references by libavfilter base ld.bfd with -Wl,--as-needed assumes -lflite_cmulex and -lflite_usenglish are not used.
Comment 6 VVD 2019-08-06 10:55:10 UTC
Same with multimedia/mpv and net-im/qTox:
/usr/local/lib/libflite_cmu_us_kal.so.1: undefined reference to `cmu_postlex'
/usr/local/lib/libflite_cmu_us_awb.so.1: undefined reference to `usenglish_init'
/usr/local/lib/libflite_cmu_us_awb.so.1: undefined reference to `cmu_lex_init'

Workaround is - add this to Makefile:
.if exists(/usr/bin/ld.lld) && (${/usr/bin/ld:L:tA} != /usr/bin/ld.lld)
LDFLAGS+=       -fuse-ld=lld
.endif

Probably some other ports dependent on ffmpeg have this issue too.
Comment 7 Mikhail Teterin freebsd_committer 2019-08-11 20:20:21 UTC
Getting the same error with mpv and ffmpegthumbnailer.
Comment 8 VVD 2019-08-11 20:41:22 UTC
May be add this to Mk/bsd.*.mk:
> .if exists(/usr/bin/ld.lld) && (${/usr/bin/ld:L:tA} != /usr/bin/ld.lld)
> LDFLAGS+=       -fuse-ld=lld
> .endif
Comment 9 Mikhail Teterin freebsd_committer 2019-08-11 22:44:10 UTC
(In reply to VVD from comment #8)
> LDFLAGS+=       -fuse-ld=lld

Thanks, that's an interesting workaround...