diff mbox series

[v3,01/15] tests/tcg: Add docker_as and docker_ld cmds

Message ID 20210305170045.869437-2-kbastian@mail.uni-paderborn.de (mailing list archive)
State New, archived
Headers show
Series tests/tcg: Add TriCore tests | expand

Commit Message

Bastian Koppelmann March 5, 2021, 5 p.m. UTC
At least for the TriCore target no easily available c compiler exists.
Thus we need to rely on "as" and "ld". This allows us to run them
through the docker image as well as with locally installed tools.

Signed-off-by: Bastian Koppelmann <kbastian@mail.uni-paderborn.de>
---
v2 -> v3:
    - emit CROSS_LD_GUEST/CROSS_AS_GUEST

 tests/tcg/Makefile.qemu | 15 +++++++++++++++
 tests/tcg/configure.sh  | 20 ++++++++++++++++++++
 2 files changed, 35 insertions(+)

Comments

Alex Bennée April 14, 2021, 1:40 p.m. UTC | #1
Bastian Koppelmann <kbastian@mail.uni-paderborn.de> writes:

> At least for the TriCore target no easily available c compiler exists.
> Thus we need to rely on "as" and "ld". This allows us to run them
> through the docker image as well as with locally installed tools.
>
> Signed-off-by: Bastian Koppelmann <kbastian@mail.uni-paderborn.de>
> ---
> v2 -> v3:
>     - emit CROSS_LD_GUEST/CROSS_AS_GUEST
>
>  tests/tcg/Makefile.qemu | 15 +++++++++++++++
>  tests/tcg/configure.sh  | 20 ++++++++++++++++++++
>  2 files changed, 35 insertions(+)
>
> diff --git a/tests/tcg/Makefile.qemu b/tests/tcg/Makefile.qemu
> index a56564660c..fefb50903d 100644
> --- a/tests/tcg/Makefile.qemu
> +++ b/tests/tcg/Makefile.qemu
> @@ -22,6 +22,8 @@ quiet-@ = $(if $(V),,@)
>  quiet-command = $(quiet-@)$(call quiet-command-run,$1,$2,$3)
>  
>  CROSS_CC_GUEST:=
> +CROSS_AS_GUEST:=
> +CROSS_LD_GUEST:=
>  DOCKER_IMAGE:=
>  
>  -include tests/tcg/config-$(TARGET).mak
> @@ -42,6 +44,7 @@ cross-build-guest-tests:
>  	$(call quiet-command, \
>  	   (mkdir -p tests/tcg/$(TARGET) && cd tests/tcg/$(TARGET) && \
>  	    $(MAKE) -f $(TCG_MAKE) TARGET="$(TARGET)" CC="$(CROSS_CC_GUEST)" \
> +			AS="$(CROSS_AS_GUEST) LD="$(CROSS_LD_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)")
> @@ -59,11 +62,23 @@ DOCKER_COMPILE_CMD="$(DOCKER_SCRIPT) cc \
>  		-i qemu/$(DOCKER_IMAGE) \
>  		-s $(SRC_PATH) -- "
>  
> +DOCKER_AS_CMD="$(DOCKER_SCRIPT) cc \
> +		--cc $(DOCKER_CROSS_AS_GUEST) \
> +		-i qemu/$(DOCKER_IMAGE) \
> +		-s $(SRC_PATH) -- "
> +
> +DOCKER_LD_CMD="$(DOCKER_SCRIPT) cc \
> +		--cc $(DOCKER_CROSS_LD_GUEST) \
> +		-i qemu/$(DOCKER_IMAGE) \
> +		-s $(SRC_PATH) -- "
> +
> +
>  .PHONY: docker-build-guest-tests
>  docker-build-guest-tests: docker-image-$(DOCKER_IMAGE)
>  	$(call quiet-command, \
>  	  (mkdir -p tests/tcg/$(TARGET) && cd tests/tcg/$(TARGET) && \
>  	   $(MAKE) -f $(TCG_MAKE) TARGET="$(TARGET)" CC=$(DOCKER_COMPILE_CMD) \
> +			AS=$(DOCKER_AS_CMD) LD=$(DOCKER_LD_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 36b8a73a54..4da8c3fa12 100755
> --- a/tests/tcg/configure.sh
> +++ b/tests/tcg/configure.sh
> @@ -72,6 +72,12 @@ fi
>  : ${cross_cc_x86_64="x86_64-pc-linux-gnu-gcc"}
>  : ${cross_cc_cflags_x86_64="-m64"}
>  
> +# cross as defaults, can be overridden with --cross-as-ARCH
> +: ${cross_as_tricore="tricore-as"}
> +
> +# cross ld defaults, can be overridden with --cross-ld-ARCH
> +: ${cross_as_tricore="tricore-ld"}
> +

These explicit defaults should be in a separate patch.

>  for target in $target_list; do
>    arch=${target%%-*}
>    case $arch in
> @@ -228,6 +234,18 @@ for target in $target_list; do
>      fi
>      echo "CROSS_CC_GUEST=$target_compiler" >> $config_target_mak
>  
> +    eval "target_as=\${cross_as_$i}"
> +    if has $target_as; then
> +      echo "CROSS_AS_GUEST=$target_as" >> $config_target_mak
> +      continue
> +    fi

Should there be any attempt to verify the assembler will do something.
If you passed --cross-as-tricore=/bin/false to force the use of the
docker container it wouldn't work because we assume if it's there it
works.

> +
> +    eval "target_ld=\${cross_ld_$i}"
> +    if has $target_ld; then
> +      echo "CROSS_LD_GUEST=$target_ld" >> $config_target_mak
> +      continue
> +    fi
> +
>      # Test for compiler features for optional tests. We only do this
>      # for cross compilers because ensuring the docker containers based
>      # compilers is a requirememt for adding a new test that needs a
> @@ -261,5 +279,7 @@ for target in $target_list; do
>    if test $got_cross_cc = no && test "$container" != no && test -n "$container_image"; then
>      echo "DOCKER_IMAGE=$container_image" >> $config_target_mak
>      echo "DOCKER_CROSS_CC_GUEST=$container_cross_cc" >> $config_target_mak
> +    echo "DOCKER_CROSS_AS_GUEST=$container_cross_as" >> $config_target_mak
> +    echo "DOCKER_CROSS_LD_GUEST=$container_cross_ld" >>
> $config_target_mak

Could we gate these on being defined please?

>    fi
>  done
Alex Bennée April 14, 2021, 2:58 p.m. UTC | #2
Bastian Koppelmann <kbastian@mail.uni-paderborn.de> writes:

> At least for the TriCore target no easily available c compiler exists.
> Thus we need to rely on "as" and "ld". This allows us to run them
> through the docker image as well as with locally installed tools.
>
> Signed-off-by: Bastian Koppelmann <kbastian@mail.uni-paderborn.de>
> ---
> v2 -> v3:
>     - emit CROSS_LD_GUEST/CROSS_AS_GUEST
>
>  tests/tcg/Makefile.qemu | 15 +++++++++++++++
>  tests/tcg/configure.sh  | 20 ++++++++++++++++++++
>  2 files changed, 35 insertions(+)
>
> diff --git a/tests/tcg/Makefile.qemu b/tests/tcg/Makefile.qemu
> index a56564660c..fefb50903d 100644
> --- a/tests/tcg/Makefile.qemu
> +++ b/tests/tcg/Makefile.qemu
> @@ -22,6 +22,8 @@ quiet-@ = $(if $(V),,@)
>  quiet-command = $(quiet-@)$(call quiet-command-run,$1,$2,$3)
>  
>  CROSS_CC_GUEST:=
> +CROSS_AS_GUEST:=
> +CROSS_LD_GUEST:=
>  DOCKER_IMAGE:=
>  
>  -include tests/tcg/config-$(TARGET).mak
> @@ -42,6 +44,7 @@ cross-build-guest-tests:
>  	$(call quiet-command, \
>  	   (mkdir -p tests/tcg/$(TARGET) && cd tests/tcg/$(TARGET) && \
>  	    $(MAKE) -f $(TCG_MAKE) TARGET="$(TARGET)" CC="$(CROSS_CC_GUEST)" \
> +			AS="$(CROSS_AS_GUEST) LD="$(CROSS_LD_GUEST)" \

Also missing quote on AS="

>  			SRC_PATH="$(SRC_PATH)" BUILD_STATIC=$(CROSS_CC_GUEST_STATIC) \
>  			EXTRA_CFLAGS="$(CROSS_CC_GUEST_CFLAGS)"), \
>  	"BUILD","$(TARGET) guest-tests with $(CROSS_CC_GUEST)")
> @@ -59,11 +62,23 @@ DOCKER_COMPILE_CMD="$(DOCKER_SCRIPT) cc \
>  		-i qemu/$(DOCKER_IMAGE) \
>  		-s $(SRC_PATH) -- "
>  
> +DOCKER_AS_CMD="$(DOCKER_SCRIPT) cc \
> +		--cc $(DOCKER_CROSS_AS_GUEST) \
> +		-i qemu/$(DOCKER_IMAGE) \
> +		-s $(SRC_PATH) -- "
> +
> +DOCKER_LD_CMD="$(DOCKER_SCRIPT) cc \
> +		--cc $(DOCKER_CROSS_LD_GUEST) \
> +		-i qemu/$(DOCKER_IMAGE) \
> +		-s $(SRC_PATH) -- "
> +
> +
>  .PHONY: docker-build-guest-tests
>  docker-build-guest-tests: docker-image-$(DOCKER_IMAGE)
>  	$(call quiet-command, \
>  	  (mkdir -p tests/tcg/$(TARGET) && cd tests/tcg/$(TARGET) && \
>  	   $(MAKE) -f $(TCG_MAKE) TARGET="$(TARGET)" CC=$(DOCKER_COMPILE_CMD) \
> +			AS=$(DOCKER_AS_CMD) LD=$(DOCKER_LD_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 36b8a73a54..4da8c3fa12 100755
> --- a/tests/tcg/configure.sh
> +++ b/tests/tcg/configure.sh
> @@ -72,6 +72,12 @@ fi
>  : ${cross_cc_x86_64="x86_64-pc-linux-gnu-gcc"}
>  : ${cross_cc_cflags_x86_64="-m64"}
>  
> +# cross as defaults, can be overridden with --cross-as-ARCH
> +: ${cross_as_tricore="tricore-as"}
> +
> +# cross ld defaults, can be overridden with --cross-ld-ARCH
> +: ${cross_as_tricore="tricore-ld"}
> +
>  for target in $target_list; do
>    arch=${target%%-*}
>    case $arch in
> @@ -228,6 +234,18 @@ for target in $target_list; do
>      fi
>      echo "CROSS_CC_GUEST=$target_compiler" >> $config_target_mak
>  
> +    eval "target_as=\${cross_as_$i}"
> +    if has $target_as; then
> +      echo "CROSS_AS_GUEST=$target_as" >> $config_target_mak
> +      continue
> +    fi
> +
> +    eval "target_ld=\${cross_ld_$i}"
> +    if has $target_ld; then
> +      echo "CROSS_LD_GUEST=$target_ld" >> $config_target_mak
> +      continue
> +    fi
> +
>      # Test for compiler features for optional tests. We only do this
>      # for cross compilers because ensuring the docker containers based
>      # compilers is a requirememt for adding a new test that needs a
> @@ -261,5 +279,7 @@ for target in $target_list; do
>    if test $got_cross_cc = no && test "$container" != no && test -n "$container_image"; then
>      echo "DOCKER_IMAGE=$container_image" >> $config_target_mak
>      echo "DOCKER_CROSS_CC_GUEST=$container_cross_cc" >> $config_target_mak
> +    echo "DOCKER_CROSS_AS_GUEST=$container_cross_as" >> $config_target_mak
> +    echo "DOCKER_CROSS_LD_GUEST=$container_cross_ld" >> $config_target_mak
>    fi
>  done
diff mbox series

Patch

diff --git a/tests/tcg/Makefile.qemu b/tests/tcg/Makefile.qemu
index a56564660c..fefb50903d 100644
--- a/tests/tcg/Makefile.qemu
+++ b/tests/tcg/Makefile.qemu
@@ -22,6 +22,8 @@  quiet-@ = $(if $(V),,@)
 quiet-command = $(quiet-@)$(call quiet-command-run,$1,$2,$3)
 
 CROSS_CC_GUEST:=
+CROSS_AS_GUEST:=
+CROSS_LD_GUEST:=
 DOCKER_IMAGE:=
 
 -include tests/tcg/config-$(TARGET).mak
@@ -42,6 +44,7 @@  cross-build-guest-tests:
 	$(call quiet-command, \
 	   (mkdir -p tests/tcg/$(TARGET) && cd tests/tcg/$(TARGET) && \
 	    $(MAKE) -f $(TCG_MAKE) TARGET="$(TARGET)" CC="$(CROSS_CC_GUEST)" \
+			AS="$(CROSS_AS_GUEST) LD="$(CROSS_LD_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)")
@@ -59,11 +62,23 @@  DOCKER_COMPILE_CMD="$(DOCKER_SCRIPT) cc \
 		-i qemu/$(DOCKER_IMAGE) \
 		-s $(SRC_PATH) -- "
 
+DOCKER_AS_CMD="$(DOCKER_SCRIPT) cc \
+		--cc $(DOCKER_CROSS_AS_GUEST) \
+		-i qemu/$(DOCKER_IMAGE) \
+		-s $(SRC_PATH) -- "
+
+DOCKER_LD_CMD="$(DOCKER_SCRIPT) cc \
+		--cc $(DOCKER_CROSS_LD_GUEST) \
+		-i qemu/$(DOCKER_IMAGE) \
+		-s $(SRC_PATH) -- "
+
+
 .PHONY: docker-build-guest-tests
 docker-build-guest-tests: docker-image-$(DOCKER_IMAGE)
 	$(call quiet-command, \
 	  (mkdir -p tests/tcg/$(TARGET) && cd tests/tcg/$(TARGET) && \
 	   $(MAKE) -f $(TCG_MAKE) TARGET="$(TARGET)" CC=$(DOCKER_COMPILE_CMD) \
+			AS=$(DOCKER_AS_CMD) LD=$(DOCKER_LD_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 36b8a73a54..4da8c3fa12 100755
--- a/tests/tcg/configure.sh
+++ b/tests/tcg/configure.sh
@@ -72,6 +72,12 @@  fi
 : ${cross_cc_x86_64="x86_64-pc-linux-gnu-gcc"}
 : ${cross_cc_cflags_x86_64="-m64"}
 
+# cross as defaults, can be overridden with --cross-as-ARCH
+: ${cross_as_tricore="tricore-as"}
+
+# cross ld defaults, can be overridden with --cross-ld-ARCH
+: ${cross_as_tricore="tricore-ld"}
+
 for target in $target_list; do
   arch=${target%%-*}
   case $arch in
@@ -228,6 +234,18 @@  for target in $target_list; do
     fi
     echo "CROSS_CC_GUEST=$target_compiler" >> $config_target_mak
 
+    eval "target_as=\${cross_as_$i}"
+    if has $target_as; then
+      echo "CROSS_AS_GUEST=$target_as" >> $config_target_mak
+      continue
+    fi
+
+    eval "target_ld=\${cross_ld_$i}"
+    if has $target_ld; then
+      echo "CROSS_LD_GUEST=$target_ld" >> $config_target_mak
+      continue
+    fi
+
     # Test for compiler features for optional tests. We only do this
     # for cross compilers because ensuring the docker containers based
     # compilers is a requirememt for adding a new test that needs a
@@ -261,5 +279,7 @@  for target in $target_list; do
   if test $got_cross_cc = no && test "$container" != no && test -n "$container_image"; then
     echo "DOCKER_IMAGE=$container_image" >> $config_target_mak
     echo "DOCKER_CROSS_CC_GUEST=$container_cross_cc" >> $config_target_mak
+    echo "DOCKER_CROSS_AS_GUEST=$container_cross_as" >> $config_target_mak
+    echo "DOCKER_CROSS_LD_GUEST=$container_cross_ld" >> $config_target_mak
   fi
 done