All of lore.kernel.org
 help / color / mirror / Atom feed
* [kvm-unit-tests PATCH 0/4] Test compiling with Clang in the Travis-CI
@ 2021-06-22 13:55 Thomas Huth
  2021-06-22 13:55 ` [kvm-unit-tests PATCH 1/4] configure: Add the possibility to specify additional cflags Thomas Huth
                   ` (4 more replies)
  0 siblings, 5 replies; 9+ messages in thread
From: Thomas Huth @ 2021-06-22 13:55 UTC (permalink / raw)
  To: kvm, Paolo Bonzini
  Cc: Laurent Vivier, Janosch Frank, Cornelia Huck, Claudio Imbrenda,
	David Hildenbrand

Travis-CI recently changed their policy so that builds on the non-x86
build machines are possible without consuming any credits again.
While we're already testing the non-x86 builds in the gitlab-CI with
the GCC cross-compilers, we could still benefit from the non-x86
builders in the Travis-CI by compiling the code with Clang there, too
(since there are AFAIK no Clang cross-compilers available in the usual
distros on x86).

Thomas Huth (4):
  configure: Add the possibility to specify additional cflags
  powerpc: Probe whether the compiler understands -mabi=no-altivec
  lib/s390x: Fix the epsw inline assembly
  Test compilation with Clang on aarch64, ppc64le and s390x in Travis-CI

 .travis.yml              | 44 ++++++++++++++++++++++++++++++++++++++++
 Makefile                 |  3 ---
 configure                | 10 +++++++--
 lib/s390x/asm/arch_def.h |  2 +-
 powerpc/Makefile.common  |  4 +++-
 5 files changed, 56 insertions(+), 7 deletions(-)
 create mode 100644 .travis.yml

-- 
2.27.0


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

* [kvm-unit-tests PATCH 1/4] configure: Add the possibility to specify additional cflags
  2021-06-22 13:55 [kvm-unit-tests PATCH 0/4] Test compiling with Clang in the Travis-CI Thomas Huth
@ 2021-06-22 13:55 ` Thomas Huth
  2021-06-22 13:55 ` [kvm-unit-tests PATCH 2/4] powerpc: Probe whether the compiler understands -mabi=no-altivec Thomas Huth
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 9+ messages in thread
From: Thomas Huth @ 2021-06-22 13:55 UTC (permalink / raw)
  To: kvm, Paolo Bonzini
  Cc: Laurent Vivier, Janosch Frank, Cornelia Huck, Claudio Imbrenda,
	David Hildenbrand

For certain compilers or experiments, it might be necessary to
specify additional CFLAGS for the build. Let's add an option to
the configure script to specify such additional compiler flags.

Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 Makefile  |  3 ---
 configure | 10 ++++++++--
 2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/Makefile b/Makefile
index 1afa90e..f7b9f28 100644
--- a/Makefile
+++ b/Makefile
@@ -22,9 +22,6 @@ DESTDIR := $(PREFIX)/share/kvm-unit-tests/
 cc-option = $(shell if $(CC) -Werror $(1) -S -o /dev/null -xc /dev/null \
               > /dev/null 2>&1; then echo "$(1)"; else echo "$(2)"; fi ;)
 
-#make sure env CFLAGS variable is not used
-CFLAGS =
-
 libcflat := lib/libcflat.a
 cflatobjs := \
 	lib/argv.o \
diff --git a/configure b/configure
index d21601f..c48ab3d 100755
--- a/configure
+++ b/configure
@@ -8,6 +8,7 @@ fi
 srcdir=$(cd "$(dirname "$0")"; pwd)
 prefix=/usr/local
 cc=gcc
+cflags=
 ld=ld
 objcopy=objcopy
 objdump=objdump
@@ -38,8 +39,9 @@ usage() {
 	    --target=TARGET        target platform that the tests will be running on (qemu or
 	                           kvmtool, default is qemu) (arm/arm64 only)
 	    --cross-prefix=PREFIX  cross compiler prefix
-	    --cc=CC		   c compiler to use ($cc)
-	    --ld=LD		   ld linker to use ($ld)
+	    --cc=CC                c compiler to use ($cc)
+	    --cflags=FLAGS         extra options to be passed to the c compiler
+	    --ld=LD                ld linker to use ($ld)
 	    --prefix=PREFIX        where to install things ($prefix)
 	    --endian=ENDIAN        endianness to compile for (little or big, ppc64 only)
 	    --[enable|disable]-pretty-print-stacks
@@ -100,6 +102,9 @@ while [[ "$1" = -* ]]; do
 	--cc)
 	    cc="$arg"
 	    ;;
+	--cflags)
+	    cflags="$arg"
+	    ;;
 	--ld)
 	    ld="$arg"
 	    ;;
@@ -316,6 +321,7 @@ ARCH=$arch
 ARCH_NAME=$arch_name
 PROCESSOR=$processor
 CC=$cross_prefix$cc
+CFLAGS=$cflags
 LD=$cross_prefix$ld
 OBJCOPY=$cross_prefix$objcopy
 OBJDUMP=$cross_prefix$objdump
-- 
2.27.0


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

* [kvm-unit-tests PATCH 2/4] powerpc: Probe whether the compiler understands -mabi=no-altivec
  2021-06-22 13:55 [kvm-unit-tests PATCH 0/4] Test compiling with Clang in the Travis-CI Thomas Huth
  2021-06-22 13:55 ` [kvm-unit-tests PATCH 1/4] configure: Add the possibility to specify additional cflags Thomas Huth
@ 2021-06-22 13:55 ` Thomas Huth
  2021-06-22 13:55 ` [kvm-unit-tests PATCH 3/4] lib/s390x: Fix the epsw inline assembly Thomas Huth
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 9+ messages in thread
From: Thomas Huth @ 2021-06-22 13:55 UTC (permalink / raw)
  To: kvm, Paolo Bonzini
  Cc: Laurent Vivier, Janosch Frank, Cornelia Huck, Claudio Imbrenda,
	David Hildenbrand

Clang does not support "-mabi=no-altivec", so let's check whether
this option is supported before using it.

Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 powerpc/Makefile.common | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/powerpc/Makefile.common b/powerpc/Makefile.common
index 4c3121a..12c280c 100644
--- a/powerpc/Makefile.common
+++ b/powerpc/Makefile.common
@@ -17,9 +17,11 @@ all: directories $(TEST_DIR)/boot_rom.bin $(tests-all)
 
 ##################################################################
 
+mabi_no_altivec := $(call cc-option,-mabi=no-altivec,"")
+
 CFLAGS += -std=gnu99
 CFLAGS += -ffreestanding
-CFLAGS += -O2 -msoft-float -mabi=no-altivec -mno-altivec
+CFLAGS += -O2 -msoft-float -mno-altivec $(mabi_no_altivec)
 CFLAGS += -I $(SRCDIR)/lib -I $(SRCDIR)/lib/libfdt -I lib
 CFLAGS += -Wa,-mregnames
 
-- 
2.27.0


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

* [kvm-unit-tests PATCH 3/4] lib/s390x: Fix the epsw inline assembly
  2021-06-22 13:55 [kvm-unit-tests PATCH 0/4] Test compiling with Clang in the Travis-CI Thomas Huth
  2021-06-22 13:55 ` [kvm-unit-tests PATCH 1/4] configure: Add the possibility to specify additional cflags Thomas Huth
  2021-06-22 13:55 ` [kvm-unit-tests PATCH 2/4] powerpc: Probe whether the compiler understands -mabi=no-altivec Thomas Huth
@ 2021-06-22 13:55 ` Thomas Huth
  2021-06-22 14:12   ` Claudio Imbrenda
  2021-06-23  7:33   ` Janosch Frank
  2021-06-22 13:55 ` [kvm-unit-tests PATCH 4/4] Test compilation with Clang on aarch64, ppc64le and s390x in Travis-CI Thomas Huth
  2021-06-22 16:25 ` [kvm-unit-tests PATCH 0/4] Test compiling with Clang in the Travis-CI Paolo Bonzini
  4 siblings, 2 replies; 9+ messages in thread
From: Thomas Huth @ 2021-06-22 13:55 UTC (permalink / raw)
  To: kvm, Paolo Bonzini
  Cc: Laurent Vivier, Janosch Frank, Cornelia Huck, Claudio Imbrenda,
	David Hildenbrand

According to the Principles of Operation, the epsw instruction
does not touch the second register if it is r0. With GCC we were
lucky so far that it never tried to use r0 here, but when compiling
the kvm-unit-tests with Clang, this indeed happens and leads to
very weird crashes. Thus let's make sure to never use r0 for the
second operand of the epsw instruction.

Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 lib/s390x/asm/arch_def.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/s390x/asm/arch_def.h b/lib/s390x/asm/arch_def.h
index 3aa5da9..15cf7d4 100644
--- a/lib/s390x/asm/arch_def.h
+++ b/lib/s390x/asm/arch_def.h
@@ -265,7 +265,7 @@ static inline uint64_t extract_psw_mask(void)
 
 	asm volatile(
 		"	epsw	%0,%1\n"
-		: "+r" (mask_upper), "+r" (mask_lower) : : );
+		: "=r" (mask_upper), "=a" (mask_lower));
 
 	return (uint64_t) mask_upper << 32 | mask_lower;
 }
-- 
2.27.0


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

* [kvm-unit-tests PATCH 4/4] Test compilation with Clang on aarch64, ppc64le and s390x in Travis-CI
  2021-06-22 13:55 [kvm-unit-tests PATCH 0/4] Test compiling with Clang in the Travis-CI Thomas Huth
                   ` (2 preceding siblings ...)
  2021-06-22 13:55 ` [kvm-unit-tests PATCH 3/4] lib/s390x: Fix the epsw inline assembly Thomas Huth
@ 2021-06-22 13:55 ` Thomas Huth
  2021-06-22 16:25 ` [kvm-unit-tests PATCH 0/4] Test compiling with Clang in the Travis-CI Paolo Bonzini
  4 siblings, 0 replies; 9+ messages in thread
From: Thomas Huth @ 2021-06-22 13:55 UTC (permalink / raw)
  To: kvm, Paolo Bonzini
  Cc: Laurent Vivier, Janosch Frank, Cornelia Huck, Claudio Imbrenda,
	David Hildenbrand

Travis-CI recently changed their policy so that builds on the non-x86
build machines are possible without consuming any credits again. We can
use these systems to test compilation of the non-x86 code with Clang.
Unfortunately, the qemu-system-s390x of Ubuntu 20.04 seems to be buggy,
so that the s390x binaries cause that QEMU to crash. Thus we can only
run the TCG tests for ppc64le and aarch64.

Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 .travis.yml | 44 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)
 create mode 100644 .travis.yml

diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..4fcb687
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,44 @@
+dist: focal
+language: c
+cache: ccache
+compiler: clang
+git:
+  submodules: false
+
+jobs:
+  include:
+
+    - arch: arm64
+      addons:
+        apt_packages: qemu-system-aarch64
+      env:
+      - CONFIG="--arch=arm64 --cc=clang"
+      - TESTS="cache gicv2-active gicv2-ipi gicv2-mmio gicv3-active gicv3-ipi
+          pci-test pmu-cycle-counter pmu-event-counter-config pmu-sw-incr
+          selftest-setup selftest-smp selftest-vectors-kernel
+          selftest-vectors-user timer"
+
+    - arch: ppc64le
+      addons:
+        apt_packages: clang-11 qemu-system-ppc
+      env:
+      - CONFIG="--arch=ppc64 --endian=little --cc=clang-11 --cflags=-no-integrated-as"
+      - TESTS="emulator rtas-get-time-of-day rtas-get-time-of-day-base
+          rtas-set-time-of-day selftest-setup spapr_hcall"
+
+    - arch: s390x
+      addons:
+        apt_packages: clang-11 qemu-system-s390x
+      env:
+      - CONFIG="--arch=s390x --cc=clang-11 --cflags=-no-integrated-as"
+      - TESTS=""
+
+before_script:
+  - mkdir -p build && cd build
+  - $TRAVIS_BUILD_DIR/configure $CONFIG
+script:
+  - make -j3
+  - if [ -n "$TESTS" ]; then
+      ACCEL="${ACCEL:-tcg}" ./run_tests.sh -v $TESTS | tee results.txt &&
+      grep -q PASS results.txt && ! grep -q FAIL results.txt ;
+    fi
-- 
2.27.0


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

* Re: [kvm-unit-tests PATCH 3/4] lib/s390x: Fix the epsw inline assembly
  2021-06-22 13:55 ` [kvm-unit-tests PATCH 3/4] lib/s390x: Fix the epsw inline assembly Thomas Huth
@ 2021-06-22 14:12   ` Claudio Imbrenda
  2021-06-22 16:40     ` Thomas Huth
  2021-06-23  7:33   ` Janosch Frank
  1 sibling, 1 reply; 9+ messages in thread
From: Claudio Imbrenda @ 2021-06-22 14:12 UTC (permalink / raw)
  To: Thomas Huth
  Cc: kvm, Paolo Bonzini, Laurent Vivier, Janosch Frank, Cornelia Huck,
	David Hildenbrand

On Tue, 22 Jun 2021 15:55:16 +0200
Thomas Huth <thuth@redhat.com> wrote:

> According to the Principles of Operation, the epsw instruction
> does not touch the second register if it is r0. With GCC we were
> lucky so far that it never tried to use r0 here, but when compiling
> the kvm-unit-tests with Clang, this indeed happens and leads to
> very weird crashes. Thus let's make sure to never use r0 for the
> second operand of the epsw instruction.
> 
> Signed-off-by: Thomas Huth <thuth@redhat.com>

Reviewed-by: Claudio Imbrenda <imbrenda@linux.ibm.com>

maybe also mention in the patch description why you changed + to =

> ---
>  lib/s390x/asm/arch_def.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/lib/s390x/asm/arch_def.h b/lib/s390x/asm/arch_def.h
> index 3aa5da9..15cf7d4 100644
> --- a/lib/s390x/asm/arch_def.h
> +++ b/lib/s390x/asm/arch_def.h
> @@ -265,7 +265,7 @@ static inline uint64_t extract_psw_mask(void)
>  
>  	asm volatile(
>  		"	epsw	%0,%1\n"
> -		: "+r" (mask_upper), "+r" (mask_lower) : : );
> +		: "=r" (mask_upper), "=a" (mask_lower));
>  
>  	return (uint64_t) mask_upper << 32 | mask_lower;
>  }


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

* Re: [kvm-unit-tests PATCH 0/4] Test compiling with Clang in the Travis-CI
  2021-06-22 13:55 [kvm-unit-tests PATCH 0/4] Test compiling with Clang in the Travis-CI Thomas Huth
                   ` (3 preceding siblings ...)
  2021-06-22 13:55 ` [kvm-unit-tests PATCH 4/4] Test compilation with Clang on aarch64, ppc64le and s390x in Travis-CI Thomas Huth
@ 2021-06-22 16:25 ` Paolo Bonzini
  4 siblings, 0 replies; 9+ messages in thread
From: Paolo Bonzini @ 2021-06-22 16:25 UTC (permalink / raw)
  To: Thomas Huth, kvm
  Cc: Laurent Vivier, Janosch Frank, Cornelia Huck, Claudio Imbrenda,
	David Hildenbrand

On 22/06/21 15:55, Thomas Huth wrote:
> Travis-CI recently changed their policy so that builds on the non-x86
> build machines are possible without consuming any credits again.
> While we're already testing the non-x86 builds in the gitlab-CI with
> the GCC cross-compilers, we could still benefit from the non-x86
> builders in the Travis-CI by compiling the code with Clang there, too
> (since there are AFAIK no Clang cross-compilers available in the usual
> distros on x86).

Looks good apart from Claudio's remark.  Thanks very much!

Paolo


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

* Re: [kvm-unit-tests PATCH 3/4] lib/s390x: Fix the epsw inline assembly
  2021-06-22 14:12   ` Claudio Imbrenda
@ 2021-06-22 16:40     ` Thomas Huth
  0 siblings, 0 replies; 9+ messages in thread
From: Thomas Huth @ 2021-06-22 16:40 UTC (permalink / raw)
  To: Claudio Imbrenda
  Cc: kvm, Paolo Bonzini, Laurent Vivier, Janosch Frank, Cornelia Huck,
	David Hildenbrand

On 22/06/2021 16.12, Claudio Imbrenda wrote:
> On Tue, 22 Jun 2021 15:55:16 +0200
> Thomas Huth <thuth@redhat.com> wrote:
> 
>> According to the Principles of Operation, the epsw instruction
>> does not touch the second register if it is r0. With GCC we were
>> lucky so far that it never tried to use r0 here, but when compiling
>> the kvm-unit-tests with Clang, this indeed happens and leads to
>> very weird crashes. Thus let's make sure to never use r0 for the
>> second operand of the epsw instruction.
>>
>> Signed-off-by: Thomas Huth <thuth@redhat.com>
> 
> Reviewed-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
> 
> maybe also mention in the patch description why you changed + to =

Yes, that makes sense. I'll add something like:

While we're at it, also change the constraint modifier from "+" to "=" since 
these are only output parameters, not input.

  Thomas


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

* Re: [kvm-unit-tests PATCH 3/4] lib/s390x: Fix the epsw inline assembly
  2021-06-22 13:55 ` [kvm-unit-tests PATCH 3/4] lib/s390x: Fix the epsw inline assembly Thomas Huth
  2021-06-22 14:12   ` Claudio Imbrenda
@ 2021-06-23  7:33   ` Janosch Frank
  1 sibling, 0 replies; 9+ messages in thread
From: Janosch Frank @ 2021-06-23  7:33 UTC (permalink / raw)
  To: Thomas Huth, kvm, Paolo Bonzini
  Cc: Laurent Vivier, Cornelia Huck, Claudio Imbrenda, David Hildenbrand

On 6/22/21 3:55 PM, Thomas Huth wrote:
> According to the Principles of Operation, the epsw instruction
> does not touch the second register if it is r0. With GCC we were
> lucky so far that it never tried to use r0 here, but when compiling
> the kvm-unit-tests with Clang, this indeed happens and leads to
> very weird crashes. Thus let's make sure to never use r0 for the
> second operand of the epsw instruction.
> 
> Signed-off-by: Thomas Huth <thuth@redhat.com>
> ---
>  lib/s390x/asm/arch_def.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/lib/s390x/asm/arch_def.h b/lib/s390x/asm/arch_def.h
> index 3aa5da9..15cf7d4 100644
> --- a/lib/s390x/asm/arch_def.h
> +++ b/lib/s390x/asm/arch_def.h
> @@ -265,7 +265,7 @@ static inline uint64_t extract_psw_mask(void)
>  
>  	asm volatile(
>  		"	epsw	%0,%1\n"
> -		: "+r" (mask_upper), "+r" (mask_lower) : : );
> +		: "=r" (mask_upper), "=a" (mask_lower));
>  
>  	return (uint64_t) mask_upper << 32 | mask_lower;
>  }
> 

With Claudio's nits fixed:
Acked-by: Janosch Frank <frankja@linux.ibm.com>

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

end of thread, other threads:[~2021-06-23  7:34 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-22 13:55 [kvm-unit-tests PATCH 0/4] Test compiling with Clang in the Travis-CI Thomas Huth
2021-06-22 13:55 ` [kvm-unit-tests PATCH 1/4] configure: Add the possibility to specify additional cflags Thomas Huth
2021-06-22 13:55 ` [kvm-unit-tests PATCH 2/4] powerpc: Probe whether the compiler understands -mabi=no-altivec Thomas Huth
2021-06-22 13:55 ` [kvm-unit-tests PATCH 3/4] lib/s390x: Fix the epsw inline assembly Thomas Huth
2021-06-22 14:12   ` Claudio Imbrenda
2021-06-22 16:40     ` Thomas Huth
2021-06-23  7:33   ` Janosch Frank
2021-06-22 13:55 ` [kvm-unit-tests PATCH 4/4] Test compilation with Clang on aarch64, ppc64le and s390x in Travis-CI Thomas Huth
2021-06-22 16:25 ` [kvm-unit-tests PATCH 0/4] Test compiling with Clang in the Travis-CI Paolo Bonzini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.