From 6409945b1c9bb626cca5a5303a7cac16429c5a47 Mon Sep 17 00:00:00 2001 From: Oneric Date: Fri, 27 Aug 2021 17:19:21 +0200 Subject: Use a wrapper script for NASM libtool assumes NASM accepts the same flags as the C-compiler, which is not actually the case. Previously we used -prefer-no-pic to avoid any additional flags being appended by libtool, which worked well for all tested platforms, but as it turns out it doesn't for NetBSD and OpenBSD. Using this wrapper-script also enables us to automatically define the PIC macro as needed, which became relevant when we started supporting 32-bit x86 PIC-assembly in 026d65e707637b0f90902bca48654871e33575f3. --- Makefile.am | 2 +- libass/Makefile.am | 2 +- ltnasm.sh | 28 ++++++++++++++++++++++++++++ 3 files changed, 30 insertions(+), 2 deletions(-) create mode 100755 ltnasm.sh diff --git a/Makefile.am b/Makefile.am index be8386e..8697553 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,5 +1,5 @@ ACLOCAL_AMFLAGS = -I m4 -EXTRA_DIST = libass.pc.in Changelog +EXTRA_DIST = libass.pc.in Changelog ltnasm.sh pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = libass.pc diff --git a/libass/Makefile.am b/libass/Makefile.am index d84012c..894c91c 100644 --- a/libass/Makefile.am +++ b/libass/Makefile.am @@ -12,7 +12,7 @@ nasm_verbose_ = $(nasm_verbose_$(AM_DEFAULT_VERBOSITY)) nasm_verbose_0 = @echo " NASM " $@; .asm.lo: - $(nasm_verbose)$(LIBTOOL) $(AM_V_lt) --tag=CC --mode=compile $(AS) $(ASFLAGS) -I$(srcdir)/ -o $@ $< -prefer-non-pic + $(nasm_verbose)$(LIBTOOL) $(AM_V_lt) --tag=CC --mode=compile $(top_srcdir)/ltnasm.sh $(AS) $(ASFLAGS) -I$(srcdir)/ -o $@ $< SRC_INTEL = x86/rasterizer.asm x86/blend_bitmaps.asm x86/be_blur.asm x86/blur.asm x86/cpuid.asm \ x86/cpuid.h diff --git a/ltnasm.sh b/ltnasm.sh new file mode 100755 index 0000000..92c3c42 --- /dev/null +++ b/ltnasm.sh @@ -0,0 +1,28 @@ +#!/bin/sh + +# Translate libtool supplied C-compiler options for NASM. +# libtool treats NASM like the C compiler, and may supply -f… options +# which are interpreted as the output file format by NASM, causing errors. +# Notably libtool will set -DPIC -fPIC and -fno-common; +# we want to use -DPIC by translating it to -DPIC=1, but remove everything else +# +# Theoretically the way the filtering is done here in a plain POSIX shell script, +# does mess up if there were spaces in any argument. However this will never happen +# since neither our filenames nor options do not contain spaces and source paths +# are not allowed to contain spaces by configure. + +cmd="" +while [ "$#" -gt 0 ] ; do + case "$1" in + # NASM accepts both -f format and -fformat, + # we always use the former, and libtool supplied + # C-compiler options will always use the latter. + -f) cmd="$cmd $1" ;; + -f*) : ;; + -DPIC) cmd="$cmd -DPIC=1" ;; + *) cmd="$cmd $1" ;; + esac + shift +done + +exec $cmd -- cgit v1.2.3