ref: 7be093ea4d50c8d38438f88cb9fa817c1c9de8dd
parent: 2931b05ac5659e50f46afd358dcaba1b604ef3c0
author: Jan Kratochvil <jan.kratochvil@redhat.com>
date: Tue Oct 5 15:15:08 EDT 2010
nasm: add configure support yasm has to be preferred as currently nasm produces marginally less efficient code (longer opcodes). Filed for nasm as: https://sourceforge.net/tracker/?func=detail&atid=106208&aid=3037462&group_id=6208 OTOH package should be built always the same, no matter which additional packages are / are not present on the system. As the package should be built with nasm (as yasm may not be available) we should not use yasm even if it is possibly available. nasm >= approx. 2.09 is required for the nasm compilation as the former versions had a section alignment bug. Provide nasm compatibility. No binary change by this patch with yasm on {x86_64,i686}-fedora13-linux-gnu. Few longer opcodes with nasm on {x86_64,i686}-fedora13-linux-gnu have been checked as safe. Change-Id: Icb0fe39c64bbcc3bcd7972e392fd03f3273340df
--- a/build/make/configure.sh
+++ b/build/make/configure.sh
@@ -255,9 +255,10 @@
TMP_C="${TMPDIRx}/vpx-conf-$$-${RANDOM}.c"
TMP_O="${TMPDIRx}/vpx-conf-$$-${RANDOM}.o"
TMP_X="${TMPDIRx}/vpx-conf-$$-${RANDOM}.x"
+TMP_ASM="${TMPDIRx}/vpx-conf-$$-${RANDOM}.asm"
clean_temp_files() {
- rm -f ${TMP_C} ${TMP_H} ${TMP_O} ${TMP_X}
+ rm -f ${TMP_C} ${TMP_H} ${TMP_O} ${TMP_X} ${TMP_ASM}
}
#
@@ -322,6 +323,21 @@
add_ldflags "$@"
}
+check_asm_align() {
+ log check_asm_align "$@"
+ cat >${TMP_ASM} <<EOF
+section .rodata
+align 16
+EOF
+ log_file ${TMP_ASM}
+ check_cmd ${AS} ${ASFLAGS} -o ${TMP_O} ${TMP_ASM}
+ readelf -WS ${TMP_O} >${TMP_X}
+ log_file ${TMP_X}
+ if ! grep -q '\.rodata .* 16$' ${TMP_X}; then
+ die "${AS} ${ASFLAGS} does not support section alignment (nasm <=2.08?)"
+ fi
+}
+
write_common_config_banner() {
echo '# This file automatically generated by configure. Do not edit!' > config.mk
echo "TOOLCHAIN := ${toolchain}" >> config.mk
@@ -440,6 +456,11 @@
disable builtin_libc
alt_libc="${optval}"
;;
+ --as=*)
+ [ "${optval}" = yasm -o "${optval}" = nasm -o "${optval}" = auto ] \
+ || die "Must be yasm, nasm or auto: ${optval}"
+ alt_as="${optval}"
+ ;;
--prefix=*)
prefix="${optval}"
;;
@@ -446,7 +467,7 @@
--libdir=*)
libdir="${optval}"
;;
- --libc|--prefix|--libdir)
+ --libc|--as|--prefix|--libdir)
die "Option ${opt} requires argument"
;;
--help|-h) show_help
@@ -802,6 +823,7 @@
;;
esac
+ AS="${alt_as:-${AS:-auto}}"
case ${tgt_cc} in
icc*)
CC=${CC:-icc}
@@ -830,7 +852,16 @@
;;
esac
- AS=yasm
+ case "${AS}" in
+ auto|"")
+ which nasm >/dev/null 2>&1 && AS=nasm
+ which yasm >/dev/null 2>&1 && AS=yasm
+ [ "${AS}" = auto -o -z "${AS}" ] \
+ && die "Neither yasm nor nasm have been found"
+ ;;
+ esac
+ log_echo " using $AS"
+ [ "${AS##*/}" = nasm ] && add_asflags -Ox
AS_SFX=.asm
case ${tgt_os} in
win*)
@@ -839,7 +870,9 @@
;;
linux*|solaris*)
add_asflags -f elf${bits}
- enabled debug && add_asflags -g dwarf2
+ enabled debug && [ "${AS}" = yasm ] && add_asflags -g dwarf2
+ enabled debug && [ "${AS}" = nasm ] && add_asflags -g
+ [ "${AS##*/}" = nasm ] && check_asm_align
;;
darwin*)
add_asflags -f macho${bits}
@@ -852,7 +885,7 @@
# enabled icc && ! enabled pic && add_cflags -fno-pic -mdynamic-no-pic
enabled icc && ! enabled pic && add_cflags -fno-pic
;;
- *) log "Warning: Unknown os $tgt_os while setting up yasm flags"
+ *) log "Warning: Unknown os $tgt_os while setting up $AS flags"
;;
esac
;;
--- a/configure
+++ b/configure
@@ -23,6 +23,7 @@
${toggle_libs} don't build libraries
${toggle_examples} don't build examples
--libc=PATH path to alternate libc
+ --as={yasm|nasm|auto} use specified assembler [auto, yasm preferred]
${toggle_fast_unaligned} don't use unaligned accesses, even when
supported by hardware [auto]
${toggle_codec_srcs} in/exclude codec library source code
@@ -266,6 +267,7 @@
libs
examples
libc
+ as
fast_unaligned
codec_srcs
debug_libs