diff mbox

[v1,1/5] configure: introduce --extra-libs

Message ID 1453976119-24372-2-git-send-email-alex.bennee@linaro.org
State New
Headers show

Commit Message

Alex Bennée Jan. 28, 2016, 10:15 a.m. UTC
If for example you want to use the thread sanitizer you want to ensure all
binaries are linked with the library:

  ./configure ${TARGETS} --cc=gcc-5 --cxx=g++-5 \
    --extra-cflags="-fsanitize=thread" --extra-libs="-ltsan"

This is more explicit than just specifying --extra-ldflags which does
not get applied at the end of the linker string.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>


---
v1
  - rebase
  - also ensure it is applied to test builds
---
 configure | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

-- 
2.7.0

Comments

Alex Bennée Jan. 28, 2016, 11:38 a.m. UTC | #1
Paolo Bonzini <pbonzini@redhat.com> writes:

> On 28/01/2016 11:15, Alex Bennée wrote:

>> If for example you want to use the thread sanitizer you want to ensure all

>> binaries are linked with the library:

>>

>>   ./configure ${TARGETS} --cc=gcc-5 --cxx=g++-5 \

>>     --extra-cflags="-fsanitize=thread" --extra-libs="-ltsan"

>>

>> This is more explicit than just specifying --extra-ldflags which does

>> not get applied at the end of the linker string.

>>

>> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>

>

> Did you find out why you need -ltsan?


Not yet, just on my system it's needed (which is an LTS + GCC PPA).

>

> Paolo

>

>> ---

>> v1

>>   - rebase

>>   - also ensure it is applied to test builds

>> ---

>>  configure | 13 ++++++++++++-

>>  1 file changed, 12 insertions(+), 1 deletion(-)

>>

>> diff --git a/configure b/configure

>> index 44ac9ab..bd29ba7 100755

>> --- a/configure

>> +++ b/configure

>> @@ -113,7 +113,7 @@ compile_object() {

>>  compile_prog() {

>>    local_cflags="$1"

>>    local_ldflags="$2"

>> -  do_cc $QEMU_CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $local_ldflags

>> +  do_cc $QEMU_CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $local_ldflags $EXTRA_LIBS

>>  }

>>

>>  do_libtool() {

>> @@ -366,6 +366,8 @@ for opt do

>>    --extra-ldflags=*) LDFLAGS="$LDFLAGS $optarg"

>>                       EXTRA_LDFLAGS="$optarg"

>>    ;;

>> +  --extra-libs=*)    EXTRA_LIBS="$optarg"

>> +  ;;

>>    --enable-debug-info) debug_info="yes"

>>    ;;

>>    --disable-debug-info) debug_info="no"

>> @@ -786,6 +788,8 @@ for opt do

>>    ;;

>>    --extra-ldflags=*)

>>    ;;

>> +  --extra-libs=*)

>> +  ;;

>>    --enable-debug-info)

>>    ;;

>>    --disable-debug-info)

>> @@ -1282,6 +1286,7 @@ Advanced options (experts only):

>>    --objcc=OBJCC            use Objective-C compiler OBJCC [$objcc]

>>    --extra-cflags=CFLAGS    append extra C compiler flags QEMU_CFLAGS

>>    --extra-ldflags=LDFLAGS  append extra linker flags LDFLAGS

>> +  --extra-libs=LIBS        append extra libraries when linking

>>    --make=MAKE              use specified make [$make]

>>    --install=INSTALL        use specified install [$install]

>>    --python=PYTHON          use specified python [$python]

>> @@ -4715,6 +4720,11 @@ fi

>>  QEMU_CFLAGS="$pixman_cflags $fdt_cflags $QEMU_CFLAGS"

>>  libs_softmmu="$pixman_libs $libs_softmmu"

>>

>> +# extra-libs

>> +LIBS="$LIBS $EXTRA_LIBS"

>> +libs_softmmu="$libs_softmmu $EXTRA_LIBS"

>> +libs_qga="$libs_qga $EXTRA_LIBS"

>> +

>>  echo "Install prefix    $prefix"

>>  echo "BIOS directory    `eval echo $qemu_datadir`"

>>  echo "binary directory  `eval echo $bindir`"

>> @@ -4885,6 +4895,7 @@ fi

>>  echo "qemu_helperdir=$libexecdir" >> $config_host_mak

>>  echo "extra_cflags=$EXTRA_CFLAGS" >> $config_host_mak

>>  echo "extra_ldflags=$EXTRA_LDFLAGS" >> $config_host_mak

>> +echo "extra_libs=$EXTRA_LIBS" >> $config_host_mak

>>  echo "qemu_localedir=$qemu_localedir" >> $config_host_mak

>>  echo "libs_softmmu=$libs_softmmu" >> $config_host_mak

>>

>>



--
Alex Bennée
diff mbox

Patch

diff --git a/configure b/configure
index 44ac9ab..bd29ba7 100755
--- a/configure
+++ b/configure
@@ -113,7 +113,7 @@  compile_object() {
 compile_prog() {
   local_cflags="$1"
   local_ldflags="$2"
-  do_cc $QEMU_CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $local_ldflags
+  do_cc $QEMU_CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $local_ldflags $EXTRA_LIBS
 }
 
 do_libtool() {
@@ -366,6 +366,8 @@  for opt do
   --extra-ldflags=*) LDFLAGS="$LDFLAGS $optarg"
                      EXTRA_LDFLAGS="$optarg"
   ;;
+  --extra-libs=*)    EXTRA_LIBS="$optarg"
+  ;;
   --enable-debug-info) debug_info="yes"
   ;;
   --disable-debug-info) debug_info="no"
@@ -786,6 +788,8 @@  for opt do
   ;;
   --extra-ldflags=*)
   ;;
+  --extra-libs=*)
+  ;;
   --enable-debug-info)
   ;;
   --disable-debug-info)
@@ -1282,6 +1286,7 @@  Advanced options (experts only):
   --objcc=OBJCC            use Objective-C compiler OBJCC [$objcc]
   --extra-cflags=CFLAGS    append extra C compiler flags QEMU_CFLAGS
   --extra-ldflags=LDFLAGS  append extra linker flags LDFLAGS
+  --extra-libs=LIBS        append extra libraries when linking
   --make=MAKE              use specified make [$make]
   --install=INSTALL        use specified install [$install]
   --python=PYTHON          use specified python [$python]
@@ -4715,6 +4720,11 @@  fi
 QEMU_CFLAGS="$pixman_cflags $fdt_cflags $QEMU_CFLAGS"
 libs_softmmu="$pixman_libs $libs_softmmu"
 
+# extra-libs
+LIBS="$LIBS $EXTRA_LIBS"
+libs_softmmu="$libs_softmmu $EXTRA_LIBS"
+libs_qga="$libs_qga $EXTRA_LIBS"
+
 echo "Install prefix    $prefix"
 echo "BIOS directory    `eval echo $qemu_datadir`"
 echo "binary directory  `eval echo $bindir`"
@@ -4885,6 +4895,7 @@  fi
 echo "qemu_helperdir=$libexecdir" >> $config_host_mak
 echo "extra_cflags=$EXTRA_CFLAGS" >> $config_host_mak
 echo "extra_ldflags=$EXTRA_LDFLAGS" >> $config_host_mak
+echo "extra_libs=$EXTRA_LIBS" >> $config_host_mak
 echo "qemu_localedir=$qemu_localedir" >> $config_host_mak
 echo "libs_softmmu=$libs_softmmu" >> $config_host_mak