diff mbox series

[for-7.1,v6,49/51] tests/tcg: Expose AR to test build environment if needed

Message ID 20220317050538.924111-50-richard.henderson@linaro.org
State New
Headers show
Series target/nios2: Shadow register set, EIC and VIC | expand

Commit Message

Richard Henderson March 17, 2022, 5:05 a.m. UTC
The runtime we build for Nios2 requires building a static archive,
so supply the ar tool for that case.

Cc: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 tests/tcg/Makefile.qemu |  7 +++++++
 tests/tcg/configure.sh  | 14 ++++++++++++++
 2 files changed, 21 insertions(+)
diff mbox series

Patch

diff --git a/tests/tcg/Makefile.qemu b/tests/tcg/Makefile.qemu
index 84c8543878..00b043c702 100644
--- a/tests/tcg/Makefile.qemu
+++ b/tests/tcg/Makefile.qemu
@@ -24,6 +24,7 @@  quiet-command = $(quiet-@)$(call quiet-command-run,$1,$2,$3)
 CROSS_CC_GUEST:=
 CROSS_AS_GUEST:=
 CROSS_LD_GUEST:=
+CROSS_AR_GUEST:=
 DOCKER_IMAGE:=
 
 -include tests/tcg/config-$(TARGET).mak
@@ -46,6 +47,7 @@  cross-build-guest-tests:
 	    $(MAKE) -f $(TCG_MAKE) TARGET="$(TARGET)" CC="$(CROSS_CC_GUEST)" \
 			$(if $(CROSS_AS_GUEST),AS="$(CROSS_AS_GUEST)") \
 			$(if $(CROSS_LD_GUEST),LD="$(CROSS_LD_GUEST)") \
+			$(if $(CROSS_AR_GUEST),AR="$(CROSS_AR_GUEST)") \
 			SRC_PATH="$(SRC_PATH)" BUILD_STATIC=$(CROSS_CC_GUEST_STATIC) \
 			EXTRA_CFLAGS="$(CROSS_CC_GUEST_CFLAGS)"), \
 	"BUILD","$(TARGET) guest-tests with $(CROSS_CC_GUEST)")
@@ -73,6 +75,10 @@  DOCKER_LD_CMD=$(if $(DOCKER_CROSS_LD_GUEST),"$(DOCKER_SCRIPT) cc \
 		-i qemu/$(DOCKER_IMAGE) \
 		-s $(SRC_PATH) -- ")
 
+DOCKER_AR_CMD=$(if $(DOCKER_CROSS_AR_GUEST),"$(DOCKER_SCRIPT) cc \
+		--cc $(DOCKER_CROSS_AR_GUEST) \
+		-i qemu/$(DOCKER_IMAGE) \
+		-s $(SRC_PATH) -- ")
 
 .PHONY: docker-build-guest-tests
 docker-build-guest-tests: docker-image-$(DOCKER_IMAGE)
@@ -81,6 +87,7 @@  docker-build-guest-tests: docker-image-$(DOCKER_IMAGE)
 	   $(MAKE) -f $(TCG_MAKE) TARGET="$(TARGET)" CC=$(DOCKER_COMPILE_CMD) \
 			$(if $(DOCKER_AS_CMD),AS=$(DOCKER_AS_CMD)) \
 			$(if $(DOCKER_LD_CMD),LD=$(DOCKER_LD_CMD)) \
+			$(if $(DOCKER_AR_CMD),AR=$(DOCKER_AR_CMD)) \
 			SRC_PATH="$(SRC_PATH)" BUILD_STATIC=y \
 			EXTRA_CFLAGS="$(CROSS_CC_GUEST_CFLAGS)"), \
 	"BUILD","$(TARGET) guest-tests with docker qemu/$(DOCKER_IMAGE)")
diff --git a/tests/tcg/configure.sh b/tests/tcg/configure.sh
index ed4b5ccb1f..0b829f4f05 100755
--- a/tests/tcg/configure.sh
+++ b/tests/tcg/configure.sh
@@ -80,6 +80,9 @@  fi
 : ${cross_as_tricore="tricore-as"}
 : ${cross_ld_tricore="tricore-ld"}
 
+# nios2 is special as it requires ar
+: ${cross_ar_nios2="nios2-linux-gnu-ar"}
+
 for target in $target_list; do
   arch=${target%%-*}
 
@@ -89,6 +92,7 @@  for target in $target_list; do
   container_cross_cc=
   container_cross_as=
   container_cross_ld=
+  container_cross_ar=
 
   # suppress clang
   supress_clang=
@@ -166,6 +170,7 @@  for target in $target_list; do
       container_hosts=x86_64
       container_image=debian-nios2-cross
       container_cross_cc=nios2-linux-gnu-gcc
+      container_cross_ar=nios2-linux-gnu-ar
       ;;
     ppc-*)
       container_hosts=x86_64
@@ -285,6 +290,11 @@  for target in $target_list; do
                   ;;
           esac
       fi
+
+      eval "target_ar=\"\${cross_ar_$arch}\""
+      if has $target_ar; then
+          echo "CROSS_AR_GUEST=$target_ar" >> $config_target_mak
+      fi
   fi
 
   if test $got_cross_cc = yes; then
@@ -344,6 +354,10 @@  for target in $target_list; do
                   echo "DOCKER_CROSS_LD_GUEST=$container_cross_ld" >> \
                       $config_target_mak
               fi
+              if test -n "$container_cross_ar"; then
+                  echo "DOCKER_CROSS_AR_GUEST=$container_cross_ar" >> \
+                      $config_target_mak
+              fi
           fi
       done
   fi