Commit 4f9297ac authored by Diego Biurrun's avatar Diego Biurrun Committed by James Almer

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.

(Cherry-picked from libav commit 57b753b4)
Signed-off-by: 's avatarJames Almer <jamrial@gmail.com>
parent 3cc73d3d
...@@ -6,7 +6,7 @@ os: ...@@ -6,7 +6,7 @@ os:
addons: addons:
apt: apt:
packages: packages:
- yasm - nasm
- diffutils - diffutils
compiler: compiler:
- clang - clang
...@@ -17,7 +17,7 @@ cache: ...@@ -17,7 +17,7 @@ cache:
before_install: before_install:
- if [ "$TRAVIS_OS_NAME" == "osx" ]; then brew update --all; fi - if [ "$TRAVIS_OS_NAME" == "osx" ]; then brew update --all; fi
install: install:
- if [ "$TRAVIS_OS_NAME" == "osx" ]; then brew install yasm; fi - if [ "$TRAVIS_OS_NAME" == "osx" ]; then brew install nasm; fi
script: script:
- mkdir -p ffmpeg-samples - mkdir -p ffmpeg-samples
- ./configure --samples=ffmpeg-samples --cc=$CC - ./configure --samples=ffmpeg-samples --cc=$CC
......
...@@ -22,6 +22,8 @@ version <next>: ...@@ -22,6 +22,8 @@ version <next>:
- headphone audio filter - headphone audio filter
- superequalizer audio filter - superequalizer audio filter
- roberts video filter - roberts video filter
- The x86 assembler default switched from yasm to nasm, pass
--x86asmexe=yasm to configure to restore the old behavior.
version 3.3: version 3.3:
- CrystalHD decoder moved to new decode API - CrystalHD decoder moved to new decode API
......
...@@ -3258,7 +3258,7 @@ pkg_config_default=pkg-config ...@@ -3258,7 +3258,7 @@ pkg_config_default=pkg-config
ranlib_default="ranlib" ranlib_default="ranlib"
strip_default="strip" strip_default="strip"
version_script='--version-script' version_script='--version-script'
x86asmexe_default="yasm" x86asmexe_default="nasm"
windres_default="windres" windres_default="windres"
nvcc_default="nvcc" nvcc_default="nvcc"
nvccflags_default="-gencode arch=compute_30,code=sm_30 -O2" nvccflags_default="-gencode arch=compute_30,code=sm_30 -O2"
...@@ -5506,7 +5506,7 @@ EOF ...@@ -5506,7 +5506,7 @@ EOF
} }
if ! disabled_any asm mmx x86asm; then if ! disabled_any asm mmx x86asm; then
for program in $x86asmexe yasm nasm; do for program in $x86asmexe nasm yasm; do
probe_x86asm $program probe_x86asm $program
test -n "$x86asm_type" && break test -n "$x86asm_type" && break
done done
...@@ -5518,7 +5518,7 @@ EOF ...@@ -5518,7 +5518,7 @@ EOF
esac esac
check_x86asm "movbe ecx, [5]" && enable x86asm || 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 "vextracti128 xmm0, ymm0, 0" || disable avx2_external
check_x86asm "vpmacsdd xmm0, xmm1, xmm2, xmm3" || disable xop_external check_x86asm "vpmacsdd xmm0, xmm1, xmm2, xmm3" || disable xop_external
check_x86asm "vfmaddps ymm0, ymm1, ymm2, ymm3" || disable fma4_external check_x86asm "vfmaddps ymm0, ymm1, ymm2, ymm3" || disable fma4_external
......
...@@ -161,8 +161,8 @@ do{ ...@@ -161,8 +161,8 @@ do{
For x86, mark registers that are clobbered in your asm. This means both 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 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 particularly important on Win64, where xmm6-15 are callee-save, and not
restoring their contents leads to undefined results. In external asm (e.g. restoring their contents leads to undefined results. In external asm,
yasm), you do this by using: you do this by using:
cglobal function_name, num_args, num_regs, num_xmm_regs cglobal function_name, num_args, num_regs, num_xmm_regs
In inline asm, you specify clobbered registers at the end of your asm: In inline asm, you specify clobbered registers at the end of your asm:
__asm__(".." ::: "%eax"). __asm__(".." ::: "%eax").
...@@ -199,12 +199,12 @@ actual lines causing issues. ...@@ -199,12 +199,12 @@ actual lines causing issues.
Inline asm vs. external asm Inline asm vs. external asm
--------------------------- ---------------------------
Both inline asm (__asm__("..") in a .c file, handled by a compiler such as gcc) 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 FFmpeg. Which one to use differs per specific case. are accepted in FFmpeg. Which one to use differs per specific case.
- if your code is intended to be inlined in a C function, inline asm is always - if your code is intended to be inlined in a C function, inline asm is always
better, because external asm cannot be inlined 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. - 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 MpegEncContext; note that this is not ideal and is discouraged if there
are alternatives), then inline asm is always better, because predicting are alternatives), then inline asm is always better, because predicting
......
...@@ -71,9 +71,9 @@ Mac OS X on PowerPC or ARM (iPhone) requires a preprocessor from ...@@ -71,9 +71,9 @@ Mac OS X on PowerPC or ARM (iPhone) requires a preprocessor from
assembly functions. Put the Perl script somewhere assembly functions. Put the Perl script somewhere
in your PATH, FFmpeg's configure will pick it up automatically. in your PATH, FFmpeg's configure will pick it up automatically.
Mac OS X on amd64 and x86 requires @command{yasm} to build most of the Mac OS X on amd64 and x86 requires @command{nasm} to build most of the
optimized assembly functions. @uref{http://www.finkproject.org/, Fink}, optimized assembly functions. @uref{http://www.finkproject.org/, Fink},
@uref{http://www.gentoo.org/proj/en/gentoo-alt/prefix/bootstrap-macos.xml, Gentoo Prefix}, @uref{https://wiki.gentoo.org/wiki/Project:Prefix, Gentoo Prefix},
@uref{https://mxcl.github.com/homebrew/, Homebrew} @uref{https://mxcl.github.com/homebrew/, Homebrew}
or @uref{http://www.macports.org, MacPorts} can easily provide it. or @uref{http://www.macports.org, MacPorts} can easily provide it.
...@@ -141,7 +141,7 @@ them under @command{MinGW-w64 Win64 Shell} and @command{MinGW-w64 Win32 Shell}. ...@@ -141,7 +141,7 @@ them under @command{MinGW-w64 Win64 Shell} and @command{MinGW-w64 Win32 Shell}.
pacman -S make pkgconf diffutils pacman -S make pkgconf diffutils
# mingw-w64 packages and toolchains # 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-SDL2
@end example @end example
To target 32 bits replace @code{x86_64} with @code{i686} in the command above. To target 32 bits replace @code{x86_64} with @code{i686} in the command above.
...@@ -159,7 +159,7 @@ You will need the following prerequisites: ...@@ -159,7 +159,7 @@ You will need the following prerequisites:
@item @uref{http://code.google.com/p/msinttypes/, msinttypes} @item @uref{http://code.google.com/p/msinttypes/, msinttypes}
(if using MSVC 2012 or earlier) (if using MSVC 2012 or earlier)
@item @uref{http://msys2.github.io/, MSYS2} @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.) (Also available via MSYS2's package manager.)
@end itemize @end itemize
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment