From 51411eb7ffba1437c1019f992990914f60232c39 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Thu, 2 Mar 2017 14:54:28 +0100 Subject: [PATCH 1/3] build: Special-case handling of SDL CFLAGS SDL adds some "special" CFLAGS that interfere with building normal binaries. Capture those CFLAGS separately and avoid adding them to the general CFLAGS. --- configure | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/configure b/configure index a8e3926b70..9f339e6af6 100755 --- a/configure +++ b/configure @@ -4782,7 +4782,13 @@ if enabled nvenc; then require_cpp_condition nvEncodeAPI.h "NVENCAPI_MAJOR_VERSION >= 6" fi -check_pkg_config sdl "sdl >= 1.2.1 sdl < 1.3.0" SDL_events.h SDL_PollEvent +# SDL is "special" and adds some CFLAGS that should not pollute anything else. +if enabled avplay; then + CFLAGS_SAVE=$CFLAGS + check_pkg_config sdl "sdl >= 1.2.1 sdl < 1.3.0" SDL_events.h SDL_PollEvent && + sdl_cflags=$pkg_cflags + CFLAGS=$CFLAGS_SAVE +fi ! disabled pod2man && check_cmd pod2man --help && enable pod2man || disable pod2man ! disabled texi2html && check_cmd texi2html -version && enable texi2html || disable texi2html From f54037da8af2f2aeb5e5633b48434211e6a97fe5 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Tue, 28 Feb 2017 19:32:37 +0100 Subject: [PATCH 2/3] build: Make x86 assembler commandline-selectable --- configure | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/configure b/configure index 9f339e6af6..77b74dd408 100755 --- a/configure +++ b/configure @@ -268,6 +268,7 @@ Toolchain options: --objcc=OCC use ObjC compiler OCC [$cc_default] --dep-cc=DEPCC use dependency generator DEPCC [$cc_default] --ld=LD use linker LD + --x86asmexe=X86ASM use x86 assembler X86ASM --pkg-config=PKGCONFIG use pkg-config tool PKGCONFIG [$pkg_config_default] --pkg-config-flags=FLAGS pass additional flags to pkgconf [] --host-cc=HOSTCC use host C compiler HOSTCC @@ -1863,6 +1864,7 @@ CMDLINE_SET=" target_path target_samples toolchain + x86asmexe " CMDLINE_APPEND=" @@ -2561,13 +2563,13 @@ shlibdir_default="$libdir_default" ar_default="ar" cc_default="gcc" host_cc_default="gcc" +x86asmexe_default="yasm" ln_s="ln -s -f" nm_default="nm -g" pkg_config_default=pkg-config ranlib="ranlib" strip="strip" version_script='--version-script' -x86asmexe="yasm" # machine arch_default=$(uname -m) @@ -2997,6 +2999,7 @@ fi ar_default="${cross_prefix}${ar_default}" cc_default="${cross_prefix}${cc_default}" objcc_default="${cross_prefix}${objcc_default}" +x86asmexe_default="${cross_prefix}${x86asmexe_default}" nm_default="${cross_prefix}${nm_default}" pkg_config_default="${cross_prefix}${pkg_config_default}" ranlib="${cross_prefix}${ranlib}" @@ -3004,7 +3007,7 @@ strip="${cross_prefix}${strip}" sysinclude_default="${sysroot}/usr/include" -set_default arch cc pkg_config sysinclude target_exec target_os +set_default arch cc pkg_config sysinclude target_exec target_os x86asmexe enabled cross_compile || host_cc_default=$cc set_default host_cc @@ -4474,16 +4477,26 @@ EOF enabled ssse3 && check_inline_asm ssse3_inline '"pabsw %xmm0, %xmm0"' enabled mmxext && check_inline_asm mmxext_inline '"pmaxub %mm0, %mm1"' - if ! disabled_any asm mmx x86asm; then - if check_cmd $x86asmexe --version; then - x86asm_debug="-g dwarf2" - X86ASMDEP='$(DEPX86ASM) $(X86ASMFLAGS) -M $(X86ASM_O) $< > $(@:.o=.d)' - elif check_cmd nasm -v; then - x86asmexe=nasm + probe_x86asm(){ + x86asmexe_probe=$1 + if check_cmd $x86asmexe_probe -v; then + x86asmexe=$x86asmexe_probe + x86asm_type=nasm x86asm_debug="-g -F dwarf" X86ASM_DEPFLAGS='-MD $(@:.o=.d)' + elif check_cmd $x86asmexe_probe --version; then + x86asmexe=$x86asmexe_probe + x86asm_type=yasm + x86asm_debug="-g dwarf2" + X86ASMDEP='$(DEPX86ASM) $(X86ASMFLAGS) -M $(X86ASM_O) $< > $(@:.o=.d)' fi + } + if ! disabled_any asm mmx x86asm; then + for program in $x86asmexe yasm nasm; do + probe_x86asm $program + test -n "$x86asm_type" && break + done X86ASMFLAGS="-f $objformat" enabled pic && append X86ASMFLAGS "-DPIC" test -n "$extern_prefix" && append X86ASMFLAGS "-DPREFIX" @@ -5223,6 +5236,7 @@ echo "big-endian ${bigendian-no}" echo "runtime cpu detection ${runtime_cpudetect-no}" if enabled x86; then echo "standalone assembly ${x86asm-no}" + echo "x86 assembler ${x86asmexe}" echo "MMX enabled ${mmx-no}" echo "MMXEXT enabled ${mmxext-no}" echo "3DNow! enabled ${amd3dnow-no}" From 57b753b445e23363c997a8ec1c556e0b0f6e9da3 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Thu, 13 Oct 2016 20:33:15 +0200 Subject: [PATCH 3/3] build: Prefer NASM assembler over YASM NASM is more actively maintained and permits generating dependency information as a sideeffect of assembling, thus cutting build times in half. --- .travis.yml | 4 ++-- Changelog | 2 ++ configure | 6 +++--- doc/optimization.txt | 8 ++++---- doc/platform.texi | 12 ++++++------ 5 files changed, 17 insertions(+), 15 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8e9629a8dd..6f9647a701 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,7 +6,7 @@ os: addons: apt: packages: - - yasm + - nasm - diffutils compiler: - clang @@ -17,7 +17,7 @@ cache: before_install: - if [ "$TRAVIS_OS_NAME" == "osx" ]; then brew update --all; fi install: - - if [ "$TRAVIS_OS_NAME" == "osx" ]; then brew install yasm; fi + - if [ "$TRAVIS_OS_NAME" == "osx" ]; then brew install nasm; fi script: - mkdir -p libav-samples - ./configure --samples=libav-samples --cc=$CC diff --git a/Changelog b/Changelog index 8e8bbcbf52..cdf073b799 100644 --- a/Changelog +++ b/Changelog @@ -9,6 +9,8 @@ version : - config.log and other configuration files moved into avbuild/ directory - VAAPI-accelerated MPEG-2 and VP8 encoding - Apple Pixlet decoder +- The x86 assembler default switched from yasm to nasm, pass + --x86asmexe=yasm to configure to restore the old behavior. version 12: diff --git a/configure b/configure index 77b74dd408..587b2186cf 100755 --- a/configure +++ b/configure @@ -2563,7 +2563,7 @@ shlibdir_default="$libdir_default" ar_default="ar" cc_default="gcc" host_cc_default="gcc" -x86asmexe_default="yasm" +x86asmexe_default="nasm" ln_s="ln -s -f" nm_default="nm -g" pkg_config_default=pkg-config @@ -4493,7 +4493,7 @@ EOF } if ! disabled_any asm mmx x86asm; then - for program in $x86asmexe yasm nasm; do + for program in $x86asmexe nasm yasm; do probe_x86asm $program test -n "$x86asm_type" && break done @@ -4505,7 +4505,7 @@ EOF esac check_x86asm "movbe ecx, [5]" && enable x86asm || - die "yasm/nasm not found or too old. Use --disable-x86asm for a crippled build." + die "nasm/yasm not found or too old. Use --disable-x86asm for a crippled build." check_x86asm "vextracti128 xmm0, ymm0, 0" || disable avx2_external check_x86asm "vpmacsdd xmm0, xmm1, xmm2, xmm3" || disable xop_external check_x86asm "vfmadd132ps ymm0, ymm1, ymm2" || disable fma3_external diff --git a/doc/optimization.txt b/doc/optimization.txt index be12d85545..3277b9b721 100644 --- a/doc/optimization.txt +++ b/doc/optimization.txt @@ -161,8 +161,8 @@ do{ For x86, mark registers that are clobbered in your asm. This means both general x86 registers (e.g. eax) as well as XMM registers. This last one is particularly important on Win64, where xmm6-15 are callee-save, and not -restoring their contents leads to undefined results. In external asm (e.g. -yasm), you do this by using: +restoring their contents leads to undefined results. In external asm, +you do this by using: cglobal function_name, num_args, num_regs, num_xmm_regs In inline asm, you specify clobbered registers at the end of your asm: __asm__(".." ::: "%eax"). @@ -194,12 +194,12 @@ The latter requires a good optimizing compiler which gcc is not. Inline asm vs. external asm --------------------------- Both inline asm (__asm__("..") in a .c file, handled by a compiler such as gcc) -and external asm (.s or .asm files, handled by an assembler such as yasm/nasm) +and external asm (.s or .asm files, handled by an assembler such as nasm/yasm) are accepted in Libav. Which one to use differs per specific case. - if your code is intended to be inlined in a C function, inline asm is always better, because external asm cannot be inlined -- if your code calls external functions, yasm is always better +- if your code calls external functions, external asm is always better - if your code takes huge and complex structs as function arguments (e.g. MpegEncContext; note that this is not ideal and is discouraged if there are alternatives), then inline asm is always better, because predicting diff --git a/doc/platform.texi b/doc/platform.texi index 74b014e138..dc20d67bb7 100644 --- a/doc/platform.texi +++ b/doc/platform.texi @@ -69,9 +69,9 @@ OS X on PowerPC or ARM (iPhone) requires a preprocessor from assembly functions. Put the Perl script somewhere in your PATH, Libav's configure will pick it up automatically. -OS X on AMD64 and x86 requires @command{yasm} to build most of the +OS X on AMD64 and x86 requires @command{nasm} to build most of the optimized assembly functions @url{http://mxcl.github.com/homebrew/, Homebrew}, -@url{http://www.gentoo.org/proj/en/gentoo-alt/prefix/bootstrap-macos.xml, Gentoo Prefix} +@url{https://wiki.gentoo.org/wiki/Project:Prefix, Gentoo Prefix} or @url{http://www.macports.org, MacPorts} can easily provide it. @@ -134,7 +134,7 @@ them under @command{MinGW-w64 Win64 Shell} and @command{MinGW-w64 Win32 Shell}. pacman -S make pkgconf diffutils # mingw-w64 packages and toolchains -pacman -S mingw-w64-x86_64-yasm mingw-w64-x86_64-gcc mingw-w64-x86_64-SDL +pacman -S mingw-w64-x86_64-nasm mingw-w64-x86_64-gcc mingw-w64-x86_64-SDL @end example To target 32 bits replace @code{x86_64} with @code{i686} in the command above. @@ -152,14 +152,14 @@ You will need the following prerequisites: @item @uref{http://code.google.com/p/msinttypes/, msinttypes} (if using MSVC 2012 or earlier) @item @uref{http://msys2.github.io/, MSYS2} -@item @uref{http://yasm.tortall.net/, YASM} +@item @uref{http://www.nasm.us/, NASM} (Also available via MSYS2's package manager.) @end itemize To set up a proper environment in MSYS2, you need to run @code{msys_shell.bat} from the Visual Studio or Intel Compiler command prompt. -Place @code{yasm.exe} somewhere in your @code{PATH}. If using MSVC 2012 or +Place @code{nasm.exe} somewhere in your @code{PATH}. If using MSVC 2012 or earlier, place @code{c99wrap.exe} and @code{c99conv.exe} somewhere in your @code{PATH} as well. @@ -307,7 +307,7 @@ These library packages are only available from @uref{http://sourceware.org/cygwinports/, Cygwin Ports}: @example -yasm, libSDL-devel, libfaac-devel, libgsm-devel, libmp3lame-devel, +nasm, libSDL-devel, libfaac-devel, libgsm-devel, libmp3lame-devel, libschroedinger1.0-devel, speex-devel, libtheora-devel, libxvidcore-devel @end example