qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] configure: do not require gcc runtime library for firmwares
@ 2024-02-16 18:12 Marek Marczykowski-Górecki
  2024-02-19 16:12 ` Michael Tokarev
  0 siblings, 1 reply; 2+ messages in thread
From: Marek Marczykowski-Górecki @ 2024-02-16 18:12 UTC (permalink / raw)
  To: qemu-devel
  Cc: Marek Marczykowski-Górecki, Paolo Bonzini, Alex Bennée,
	Thomas Huth

probe_target_compiler() when checking for multilib support checks if
-nostdlib works together with -lgcc. It isn't necessary for building
various components in pc-bios/optionrom, as evidenced by looking at
actually used link flags there.
Alpine Linux for x86_64 does not ship with 32bit libgcc, but its gcc is
otherwise perfectly capable of building firmwares in pc-bios/optionrom
dir. Make configure recognize this situation.

Keep requiring functional -lgcc in other places.

Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
---
 configure | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/configure b/configure
index ff058d6c48..7721999f49 100755
--- a/configure
+++ b/configure
@@ -1216,7 +1216,7 @@ have_target() {
   return 1
 }
 
-# probe_target_compiler TARGET
+# probe_target_compiler TARGET [nostdlib-extra-ldflags]
 #
 # Look for a compiler for the given target, either native or cross.
 # Set variables target_* if a compiler is found, and container_cross_*
@@ -1226,6 +1226,9 @@ have_target() {
 #
 # If TARGET is a user-mode emulation target, also set build_static to
 # "y" if static linking is possible.
+# When testing -nostdlib build, -lgcc will be added for more extensive multilib
+# support test, but the -lgcc can be overriden with the second argument to the
+# function.
 #
 probe_target_compiler() {
   # reset all output variables
@@ -1243,6 +1246,7 @@ probe_target_compiler() {
   container_cross_strip=
 
   target_arch=${1%%-*}
+  nostdlib_ldflags=${2--lgcc}
   case $target_arch in
     aarch64) container_hosts="x86_64 aarch64" ;;
     alpha) container_hosts=x86_64 ;;
@@ -1432,7 +1436,7 @@ probe_target_compiler() {
     case $1 in
       *-softmmu)
         if do_compiler "$target_cc" $target_cflags -o $TMPO -c $TMPC &&
-          do_compiler "$target_cc" $target_cflags -r -nostdlib -o "${TMPDIR1}/${TMPB}2.o" "$TMPO" -lgcc; then
+          do_compiler "$target_cc" $target_cflags -r -nostdlib -o "${TMPDIR1}/${TMPB}2.o" "$TMPO" $nostdlib_ldflags; then
           got_cross_cc=yes
           break
         fi
@@ -1544,7 +1548,7 @@ echo "# Automatically generated by configure - do not modify" > Makefile.prereqs
 if have_target i386-softmmu x86_64-softmmu && \
         test "$host_os" != "darwin" && test "$host_os" != "sunos" && \
         test "$host_os" != "haiku" && \
-        probe_target_compiler i386-softmmu; then
+        probe_target_compiler i386-softmmu ""; then
     subdirs="$subdirs pc-bios/optionrom"
     config_mak=pc-bios/optionrom/config.mak
     echo "# Automatically generated by configure - do not modify" > $config_mak
-- 
2.43.0



^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-02-19 16:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-16 18:12 [PATCH] configure: do not require gcc runtime library for firmwares Marek Marczykowski-Górecki
2024-02-19 16:12 ` Michael Tokarev

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).