Commit 7be093ea authored by Jan Kratochvil's avatar Jan Kratochvil Committed by John Koleszar
Browse files

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
parent 2931b05a
...@@ -255,9 +255,10 @@ TMP_H="${TMPDIRx}/vpx-conf-$$-${RANDOM}.h" ...@@ -255,9 +255,10 @@ TMP_H="${TMPDIRx}/vpx-conf-$$-${RANDOM}.h"
TMP_C="${TMPDIRx}/vpx-conf-$$-${RANDOM}.c" TMP_C="${TMPDIRx}/vpx-conf-$$-${RANDOM}.c"
TMP_O="${TMPDIRx}/vpx-conf-$$-${RANDOM}.o" TMP_O="${TMPDIRx}/vpx-conf-$$-${RANDOM}.o"
TMP_X="${TMPDIRx}/vpx-conf-$$-${RANDOM}.x" TMP_X="${TMPDIRx}/vpx-conf-$$-${RANDOM}.x"
TMP_ASM="${TMPDIRx}/vpx-conf-$$-${RANDOM}.asm"
clean_temp_files() { 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 @@ check_add_ldflags() { ...@@ -322,6 +323,21 @@ check_add_ldflags() {
add_ldflags "$@" 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() { write_common_config_banner() {
echo '# This file automatically generated by configure. Do not edit!' > config.mk echo '# This file automatically generated by configure. Do not edit!' > config.mk
echo "TOOLCHAIN := ${toolchain}" >> config.mk echo "TOOLCHAIN := ${toolchain}" >> config.mk
...@@ -440,13 +456,18 @@ process_common_cmdline() { ...@@ -440,13 +456,18 @@ process_common_cmdline() {
disable builtin_libc disable builtin_libc
alt_libc="${optval}" 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=*)
prefix="${optval}" prefix="${optval}"
;; ;;
--libdir=*) --libdir=*)
libdir="${optval}" libdir="${optval}"
;; ;;
--libc|--prefix|--libdir) --libc|--as|--prefix|--libdir)
die "Option ${opt} requires argument" die "Option ${opt} requires argument"
;; ;;
--help|-h) show_help --help|-h) show_help
...@@ -802,6 +823,7 @@ process_common_toolchain() { ...@@ -802,6 +823,7 @@ process_common_toolchain() {
;; ;;
esac esac
AS="${alt_as:-${AS:-auto}}"
case ${tgt_cc} in case ${tgt_cc} in
icc*) icc*)
CC=${CC:-icc} CC=${CC:-icc}
...@@ -830,7 +852,16 @@ process_common_toolchain() { ...@@ -830,7 +852,16 @@ process_common_toolchain() {
;; ;;
esac 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 AS_SFX=.asm
case ${tgt_os} in case ${tgt_os} in
win*) win*)
...@@ -839,7 +870,9 @@ process_common_toolchain() { ...@@ -839,7 +870,9 @@ process_common_toolchain() {
;; ;;
linux*|solaris*) linux*|solaris*)
add_asflags -f elf${bits} 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*) darwin*)
add_asflags -f macho${bits} add_asflags -f macho${bits}
...@@ -852,7 +885,7 @@ process_common_toolchain() { ...@@ -852,7 +885,7 @@ process_common_toolchain() {
# enabled icc && ! enabled pic && add_cflags -fno-pic -mdynamic-no-pic # enabled icc && ! enabled pic && add_cflags -fno-pic -mdynamic-no-pic
enabled icc && ! enabled pic && add_cflags -fno-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 esac
;; ;;
......
...@@ -23,6 +23,7 @@ Advanced options: ...@@ -23,6 +23,7 @@ Advanced options:
${toggle_libs} don't build libraries ${toggle_libs} don't build libraries
${toggle_examples} don't build examples ${toggle_examples} don't build examples
--libc=PATH path to alternate libc --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 ${toggle_fast_unaligned} don't use unaligned accesses, even when
supported by hardware [auto] supported by hardware [auto]
${toggle_codec_srcs} in/exclude codec library source code ${toggle_codec_srcs} in/exclude codec library source code
...@@ -266,6 +267,7 @@ CMDLINE_SELECT=" ...@@ -266,6 +267,7 @@ CMDLINE_SELECT="
libs libs
examples examples
libc libc
as
fast_unaligned fast_unaligned
codec_srcs codec_srcs
debug_libs debug_libs
......
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