Opened 7 years ago

Closed 15 months ago

#6527 closed defect (wontfix)

NASM 2.11.06 doesn't load config.asm

Reported by: Hans Carlson Owned by:
Priority: normal Component: build system
Version: git-master Keywords: nasm configuration
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

NASM version 2.11.06 doesn't seem to work correctly and configure should check to see if NASM is newer then 2.11.06 before allowing it to be used.

Background:
On July 12, 2017, I tried to build from git master on a system that had no problems building from master a few months earlier (March 29, 2017).

The problems stem from changes to "configure" (on June 21, 2017) that prefers nasm over yasm http://git.ffmpeg.org/gitweb/ffmpeg.git/commit/4f9297ac3b39098547863d28fbc8d2a906d5be49. My system has both, but nasm is old... and apparently too old.

After downloading the latest git master (at the time, July 12, 2017), "make" displayed the following errors:

$ git clone git://source.ffmpeg.org/ffmpeg.git ffmpeg-20170712
...
$ cd ffmpeg-20170712
$ configure
...
$ make
...
X86ASM	libavfilter/x86/af_afir.o
libavutil/x86/x86inc.asm:45: error: symbol `HAVE_ALIGNED_STACK' not defined before use
libavutil/x86/x86inc.asm:58: error: symbol `ARCH_X86_64' not defined before use
libavutil/x86/x86inc.asm:193: error: (DECLARE_REG_SIZE:11) symbol `ARCH_X86_64' not defined before use
libavutil/x86/x86inc.asm:194: error: (DECLARE_REG_SIZE:11) symbol `ARCH_X86_64' not defined before use
libavutil/x86/x86inc.asm:195: error: (DECLARE_REG_SIZE:11) symbol `ARCH_X86_64' not defined before use
libavutil/x86/x86inc.asm:196: error: (DECLARE_REG_SIZE:11) symbol `ARCH_X86_64' not defined before use
libavutil/x86/x86inc.asm:197: error: (DECLARE_REG_SIZE:11) symbol `ARCH_X86_64' not defined before use
libavutil/x86/x86inc.asm:198: error: (DECLARE_REG_SIZE:11) symbol `ARCH_X86_64' not defined before use
libavutil/x86/x86inc.asm:199: error: (DECLARE_REG_SIZE:11) symbol `ARCH_X86_64' not defined before use
libavutil/x86/x86inc.asm:225: error: symbol `ARCH_X86_64' not defined before use
libavutil/x86/x86inc.asm:938: error: (INIT_XMM:5) symbol `ARCH_X86_64' not defined before use
libavutil/x86/x86inc.asm:938: error: (INIT_CPUFLAGS:32) symbol `ARCH_X86_64' not defined before use
libavutil/x86/x86inc.asm:938: error: (CPUNOP:1) symbol `HAVE_CPUNOP' not defined before use
libavutil/x86/x86inc.asm:938: error: unknown 'cpu' type
libavfilter/x86/af_afir.asm:30: error: (INIT_XMM:5) symbol `ARCH_X86_64' not defined before use
libavfilter/x86/af_afir.asm:30: error: (INIT_CPUFLAGS:32) symbol `ARCH_X86_64' not defined before use
libavfilter/x86/af_afir.asm:30: error: (CPUNOP:1) symbol `HAVE_CPUNOP' not defined before use
libavfilter/x86/af_afir.asm:30: error: unknown 'cpu' type
libavfilter/x86/af_afir.asm:31: error: (INIT_XMM:5) symbol `ARCH_X86_64' not defined before use
libavfilter/x86/af_afir.asm:31: error: (INIT_CPUFLAGS:32) symbol `ARCH_X86_64' not defined before use
libavfilter/x86/af_afir.asm:31: error: (CPUNOP:1) symbol `HAVE_CPUNOP' not defined before use
libavfilter/x86/af_afir.asm:31: error: unknown 'cpu' type
make: *** [libavfilter/x86/af_afir.o] Error 1

I eventually, figured out what command was actually used by running "make -n" and grepping for 'X86ASM.*af_afir':

printf "X86ASM\t%s\n" libavfilter/x86/af_afir.o; nasm -f elf32 -g -F dwarf -I./ -I.// -Ilibavfilter/x86/ -Pconfig.asm -MD libavfilter/x86/af_afir.d  -o libavfilter/x86/af_afir.o libavfilter/x86/af_afir.asm

When the "nasm ..." line above is run by itself, it generates the same errors. It appears the -Pconfig.asm option is ignored with NASM version 2.11.06. The symbols it's looking for ARE defined in config.asm:

$ egrep 'HAVE_ALIGNED_STACK|ARCH_X86_64' config.asm
%define ARCH_X86_64 0
%define HAVE_ALIGNED_STACK 1

I also tried "nasm -DARCH_X86_64=0 ..." but that fails as well. The only thing that did work was to add the above "%define" directly to libavutil/x86/x86inc.asm.

If NASM version 2.11.08 is used, then the original nasm command works fine (without modifying x86inc.asm)

I think a change to configure to check the version of nasm before allowing it to be used would avoid this problem. Maybe, something like the following:

--- a/configure	2017-07-14 13:18:02.493845243 -0700
+++ b/configure	2017-07-14 13:26:02.205575931 -0700
@@ -5502,9 +5502,19 @@
     enabled ssse3  && check_inline_asm ssse3_inline  '"pabsw %xmm0, %xmm0"'
     enabled mmxext && check_inline_asm mmxext_inline '"pmaxub %mm0, %mm1"'

+    check_nasm(){
+      log "$1 -v"
+      nasmverstr=$($1 -v 2>&1 | tee -a $logfile)
+      nasmver=$(expr "$nasmverstr" : 'NASM version \([0-9.][0-9.]*\).*')
+      [ -z "$nasmver" ] && return 1
+      n_nasmver=$(echo "$nasmver" | sed 's/[^0-9]//g')
+      [ "$n_nasmver" -lt '21108' ] && die "NASM version [$nasmver] is too old.  Upgrade NASM or try configure --x86asmexe=yasm"
+      return 0
+    }
+
     probe_x86asm(){
         x86asmexe_probe=$1
-        if check_cmd $x86asmexe_probe -v; then
+        if check_nasm $x86asmexe_probe; then
             x86asmexe=$x86asmexe_probe
             x86asm_type=nasm
             x86asm_debug="-g -F dwarf"

On a slightly related note, while investigating this issue, I had to go through several changes before finding the one that caused the problems. The log message in this change (http://git.ffmpeg.org/gitweb/ffmpeg.git/commit/3cc73d3d6d2a98cd0da3deda90760729c82cdeeb) is incorrect. I says "nasm --version" has worked since 2.11, but nasm didn't support the "--version" option until 2.13. The change itself is fine, it's just the log message that's misleading.

Change History (1)

comment:1 by Elon Musk, 15 months ago

Resolution: wontfix
Status: newclosed
Note: See TracTickets for help on using tickets.