Fix Travis-CI / compiling with older versions of Clang
cover Fix Travis-CI / compiling with older versions of Clang
My last pull request enabled compiling the s390-ccw bios with Clang. However, I only tested it with Clang version 11, and older versions of Clang are a little bit more picky. Fix those issues now, too, so that the corresponding job with Clang on s390x in the Travis-CI works correctly again.
Thomas Huth (3):
pc-bios/s390-ccw: Fix inline assembly for older versions of Clang pc-bios/s390-ccw/Makefile: Check more compiler flags for Clang pc-bios/s390-ccw: Add a proper prototype for main()
pc-bios/s390-ccw/Makefile | 7 ++++--- pc-bios/s390-ccw/helper.h | 2 +- pc-bios/s390-ccw/jump2ipl.c | 4 ++-- pc-bios/s390-ccw/main.c | 3 +-- pc-bios/s390-ccw/menu.c | 8 ++++---- pc-bios/s390-ccw/s390-ccw.h | 1 + pc-bios/s390-ccw/virtio.c | 2 +- 7 files changed, 14 insertions(+), 13 deletions(-)
Signature · 1 line
2.27.0
PATCH 1/3 pc-bios/s390-ccw: Fix inline assembly for older versions of Clang
Clang versions before v11.0 insist on having the %rX or %cX register names instead of just a number. Since our Travis-CI is currently still using Clang v6.0, we have to fix this to avoid failing jobs.
--- pc-bios/s390-ccw/helper.h | 2 +- pc-bios/s390-ccw/jump2ipl.c | 4 ++-- pc-bios/s390-ccw/menu.c | 8 ++++---- pc-bios/s390-ccw/virtio.c | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-)
pc-bios/s390-ccw/helper.h +1 -1
@@ -31,7 +31,7 @@ static inline void *u32toptr(uint32_t n)static inline void yield (void ) { - asmvolatile ("diag 0,0,0x44" + asmvolatile ("diag %%r0,%%r0,0x44" : : :"memory" ,"cc" ); }
pc-bios/s390-ccw/jump2ipl.c +2 -2
@@ -64,8 +64,8 @@ void jump_to_IPL_code(uint64_t address)* We use the load normal reset to keep r15 unchanged. jump_to_IPL_2 * can then use r15 as its stack pointer. */ - asmvolatile ("lghi 1,1\n\t" -"diag 1,1,0x308\n\t" + asmvolatile ("lghi %%r1,1\n\t" +"diag %%r1,%%r1,0x308\n\t" : : :"1" ,"memory" );panic ("\n! IPL returns !\n" ); }
pc-bios/s390-ccw/menu.c +4 -4
@@ -36,9 +36,9 @@ static inline void enable_clock_int(void)uint64_t tmp =0 ; asmvolatile ( -"stctg 0,0,%0\n" +"stctg %%c0,%%c0,%0\n" "oi 6+%0, 0x8\n" -"lctlg 0,0,%0" +"lctlg %%c0,%%c0,%0" : :"Q" (tmp) :"memory" ); }
@@ -48,9 +48,9 @@ static inline void disable_clock_int(void)uint64_t tmp =0 ; asmvolatile ( -"stctg 0,0,%0\n" +"stctg %%c0,%%c0,%0\n" "ni 6+%0, 0xf7\n" -"lctlg 0,0,%0" +"lctlg %%c0,%%c0,%0" : :"Q" (tmp) :"memory" ); }
pc-bios/s390-ccw/virtio.c +1 -1
@@ -54,7 +54,7 @@ static long kvm_hypercall(unsigned long nr, unsigned long param1, register ulong r_param3 asm("4") = param3; registerlong retval asm("2" ); - asmvolatile ("diag 2,4,0x500" + asmvolatile ("diag %%r2,%%r4,0x500" :"=d" (retval) :"d" (r_nr),"0" (r_param1),"r" (r_param2),"d" (r_param3) :"memory" ,"cc" );
Signature · 1 line
2.27.0
Re: [PATCH 1/3] pc-bios/s390-ccw: Fix inline assembly for older versions of Clang
Quoted 11 lines · Thomas Huth
Clang versions before v11.0 insist on having the %rX or %cX register names instead of just a number. Since our Travis-CI is currently still using Clang v6.0, we have to fix this to avoid failing jobs.
Signed-off-by Thomas Huth <[email protected]>--- pc-bios/s390-ccw/helper.h | 2 +- pc-bios/s390-ccw/jump2ipl.c | 4 ++-- pc-bios/s390-ccw/menu.c | 8 ++++---- pc-bios/s390-ccw/virtio.c | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-)
Re: [PATCH 1/3] pc-bios/s390-ccw: Fix inline assembly for older versions of Clang
In reply to Thomas HuthQuoted 17 lines · On Wed, 12 May 2021 19:15:48 +0200 Thomas Huth <[email protected]> wrote:
Clang versions before v11.0 insist on having the %rX or %cX register names instead of just a number. Since our Travis-CI is currently still using Clang v6.0, we have to fix this to avoid failing jobs.
Signed-off-by Thomas Huth <[email protected]>--- pc-bios/s390-ccw/helper.h | 2 +- pc-bios/s390-ccw/jump2ipl.c | 4 ++-- pc-bios/s390-ccw/menu.c | 8 ++++---- pc-bios/s390-ccw/virtio.c | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-)pc-bios/s390-ccw/helper.h +0
-0
pc-bios/s390-ccw/helper.h static inline void *u32toptr(uint32_t n) · line 37
Quoted 8 lines
pc-bios/s390-ccw/helper.h +1
-1@@ -31,7 +31,7 @@ static inline void *u32toptr(uint32_t n)static inline void yield (void ) { - asmvolatile ("diag 0,0,0x44" + asmvolatile ("diag %%r0,%%r0,0x44" : : :"memory" ,"cc" ); }
Sigh, this really looks uglier, but if it pleases the compiler...
Re: [PATCH 1/3] pc-bios/s390-ccw: Fix inline assembly for older versions of Clang
Quoted 21 lines · Cornelia Huck
Quoted 18 lines · On Wed, 12 May 2021 19:15:48 +0200 Thomas Huth <[email protected]> wrote:
Clang versions before v11.0 insist on having the %rX or %cX register names instead of just a number. Since our Travis-CI is currently still using Clang v6.0, we have to fix this to avoid failing jobs.
Signed-off-by Thomas Huth <[email protected]>--- pc-bios/s390-ccw/helper.h | 2 +- pc-bios/s390-ccw/jump2ipl.c | 4 ++-- pc-bios/s390-ccw/menu.c | 8 ++++---- pc-bios/s390-ccw/virtio.c | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-)pc-bios/s390-ccw/helper.h +0
-0@@ -31,7 +31,7 @@ static inline void *u32toptr(uint32_t n)
Quoted 9 lines
pc-bios/s390-ccw/helper.h static inline void *u32toptr(uint32_t n) · line 37
Quoted 7 lines
pc-bios/s390-ccw/helper.h +1
-1static inline void yield (void ) { - asmvolatile ("diag 0,0,0x44" + asmvolatile ("diag %%r0,%%r0,0x44" : : :"memory" ,"cc" ); }Sigh, this really looks uglier, but if it pleases the compiler...
Personally I find it easier to read, it makes obvious we are accessing a register, not using an immediate value.
PATCH 2/3 pc-bios/s390-ccw/Makefile: Check more compiler flags for Clang
In reply to Thomas HuthOlder versions of Clang do not like -fno-delete-null-pointer-checks or -msoft-float. So let's add a proper check for those.
--- pc-bios/s390-ccw/Makefile | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
pc-bios/s390-ccw/Makefile +4 -3
@@ -31,10 +31,11 @@ OBJECTS = start.o main.o bootmap.o jump2ipl.o sclp.o menu.o \ QEMU_CFLAGS := -Wall $(filter -W%, $(QEMU_CFLAGS)) QEMU_CFLAGS += $(call cc-option,-Werror $(QEMU_CFLAGS),-Wno-stringop-overflow) -QEMU_CFLAGS += -ffreestanding -fno-delete-null-pointer-checks -fno-common -fPIE +QEMU_CFLAGS += -ffreestanding -fno-common -fPIE QEMU_CFLAGS += -fwrapv -fno-strict-aliasing -fno-asynchronous-unwind-tables -QEMU_CFLAGS += $(call cc-option, $(QEMU_CFLAGS), -fno-stack-protector) -QEMU_CFLAGS += -msoft-float +QEMU_CFLAGS += $(call cc-option,-Werror $(QEMU_CFLAGS),-fno-delete-null-pointer-checks) +QEMU_CFLAGS += $(call cc-option,-Werror $(QEMU_CFLAGS),-fno-stack-protector) +QEMU_CFLAGS += $(call cc-option,-Werror $(QEMU_CFLAGS),-msoft-float) QEMU_CFLAGS += $(call cc-option, $(QEMU_CFLAGS),-march=z900,-march=z10) QEMU_CFLAGS += -std=gnu99 LDFLAGS += -Wl,-pie -nostdlib
Signature · 1 line
2.27.0
Re: [PATCH 2/3] pc-bios/s390-ccw/Makefile: Check more compiler flags for Clang
+Richard
Quoted 13 lines · Thomas Huth
Older versions of Clang do not like -fno-delete-null-pointer-checks or -msoft-float. So let's add a proper check for those.
Signed-off-by Thomas Huth <[email protected]>--- pc-bios/s390-ccw/Makefile | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)pc-bios/s390-ccw/Makefile +0
-0
pc-bios/s390-ccw/Makefile OBJECTS = start.o main.o bootmap.o jump2ipl.o sclp.o menu.o \ · line 34
Quoted 5 lines
pc-bios/s390-ccw/Makefile +1
-1@@ -31,10 +31,11 @@ OBJECTS = start.o main.o bootmap.o jump2ipl.o sclp.o menu.o \ QEMU_CFLAGS := -Wall $(filter -W%, $(QEMU_CFLAGS)) QEMU_CFLAGS += $(call cc-option,-Werror $(QEMU_CFLAGS),-Wno-stringop-overflow) -QEMU_CFLAGS += -ffreestanding -fno-delete-null-pointer-checks -fno-common -fPIE +QEMU_CFLAGS += -ffreestanding -fno-common -fPIE
OK
pc-bios/s390-ccw/Makefile OBJECTS = start.o main.o bootmap.o jump2ipl.o sclp.o menu.o \ · line 37
Quoted 5 lines
pc-bios/s390-ccw/Makefile +2
-2QEMU_CFLAGS += -fwrapv -fno-strict-aliasing -fno-asynchronous-unwind-tables -QEMU_CFLAGS += $(call cc-option, $(QEMU_CFLAGS), -fno-stack-protector) -QEMU_CFLAGS += -msoft-float +QEMU_CFLAGS += $(call cc-option,-Werror $(QEMU_CFLAGS),-fno-delete-null-pointer-checks) +QEMU_CFLAGS += $(call cc-option,-Werror $(QEMU_CFLAGS),-fno-stack-protector)
OK
pc-bios/s390-ccw/Makefile OBJECTS = start.o main.o bootmap.o jump2ipl.o sclp.o menu.o \ · line 38
Quoted 1 line
pc-bios/s390-ccw/Makefile +1
-0+QEMU_CFLAGS += $(call cc-option,-Werror $(QEMU_CFLAGS),-msoft-float)
For this one I don't understand clang... How to enforce no floating point code generation?
Quoted 4 lines
pc-bios/s390-ccw/Makefile +0
-0QEMU_CFLAGS += $(call cc-option, $(QEMU_CFLAGS),-march=z900,-march=z10) QEMU_CFLAGS += -std=gnu99 LDFLAGS += -Wl,-pie -nostdlib
PATCH 3/3 pc-bios/s390-ccw: Add a proper prototype for main()
In reply to Thomas HuthOlder versions of Clang complain if there is no prototype for main(). Add one, and while we're at it, make sure that we use the same type for main.c and netmain.c - since the return value does not matter, declare the return type of main() as "void".
--- pc-bios/s390-ccw/main.c | 3 +-- pc-bios/s390-ccw/s390-ccw.h | 1 + 2 files changed, 2 insertions(+), 2 deletions(-)
pc-bios/s390-ccw/main.c +1 -2
@@ -281,7 +281,7 @@ static void probe_boot_device(void)sclp_print ("Could not find a suitable boot device (none specified)\n" ); } -int main (void ) +void main (void ) {sclp_setup ();css_setup ();
@@ -294,5 +294,4 @@ int main(void) }panic ("Failed to load OS from hard disk\n" ); -return 0 ;/* make compiler happy */ }
pc-bios/s390-ccw/s390-ccw.h +1 -0
@@ -57,6 +57,7 @@ void write_subsystem_identification(void);void write_iplb_location (void ); extern char stack[PAGE_SIZE * 8] __attribute__((__aligned__(PAGE_SIZE)));unsigned int get_loadparm_index (void ); +void main (void );/* sclp.c */ void sclp_print (const char *string);
Signature · 1 line
2.27.0
Re: [PATCH 3/3] pc-bios/s390-ccw: Add a proper prototype for main()
Quoted 35 lines · Thomas Huth
Older versions of Clang complain if there is no prototype for
main(). Add one, and while we're at it, make sure that we use the same type formain.candnetmain.c- since the return value does not matter, declare the return type ofmain()as "void".Signed-off-by Thomas Huth <[email protected]>--- pc-bios/s390-ccw/main.c | 3 +-- pc-bios/s390-ccw/s390-ccw.h | 1 + 2 files changed, 2 insertions(+), 2 deletions(-)pc-bios/s390-ccw/main.c +1
-2@@ -281,7 +281,7 @@ static void probe_boot_device(void)sclp_print ("Could not find a suitable boot device (none specified)\n" ); } -int main (void ) +void main (void ) {sclp_setup ();css_setup ();@@ -294,5 +294,4 @@ int main(void) }panic ("Failed to load OS from hard disk\n" ); -return 0 ;/* make compiler happy */ }pc-bios/s390-ccw/s390-ccw.h +0
-0
pc-bios/s390-ccw/s390-ccw.h void write_subsystem_identification(void); · line 60
Quoted 4 lines
pc-bios/s390-ccw/s390-ccw.h +1
-0@@ -57,6 +57,7 @@ void write_subsystem_identification(void);void write_iplb_location (void ); extern char stack[PAGE_SIZE * 8] __attribute__((__aligned__(PAGE_SIZE)));unsigned int get_loadparm_index (void ); +void main (void );
Can we keep the forward declaration in the source?
Re: [PATCH 3/3] pc-bios/s390-ccw: Add a proper prototype for main()
Quoted 28 lines · Philippe Mathieu-Daudé
Quoted 27 lines · Thomas Huth
Older versions of Clang complain if there is no prototype for
main(). Add one, and while we're at it, make sure that we use the same type formain.candnetmain.c- since the return value does not matter, declare the return type ofmain()as "void".Signed-off-by Thomas Huth <[email protected]>--- pc-bios/s390-ccw/main.c | 3 +-- pc-bios/s390-ccw/s390-ccw.h | 1 + 2 files changed, 2 insertions(+), 2 deletions(-)pc-bios/s390-ccw/main.c +1
-1@@ -281,7 +281,7 @@ static void probe_boot_device(void)sclp_print ("Could not find a suitable boot device (none specified)\n" ); } -int main (void ) +void main (void ) {sclp_setup ();css_setup ();@@ -294,5 +294,4 @@ int main(void) }
Quoted 14 lines
pc-bios/s390-ccw/s390-ccw.h void write_subsystem_identification(void); · line 60
Quoted 12 lines
pc-bios/s390-ccw/main.c +0
-1panic ("Failed to load OS from hard disk\n" ); -return 0 ;/* make compiler happy */ }pc-bios/s390-ccw/s390-ccw.h +1
-0@@ -57,6 +57,7 @@ void write_subsystem_identification(void);void write_iplb_location (void ); extern char stack[PAGE_SIZE * 8] __attribute__((__aligned__(PAGE_SIZE)));unsigned int get_loadparm_index (void ); +void main (void );Can we keep the forward declaration in the source?
There are two main() functions, one in main.c and one in netmain.c, that's why I think it's better to declare the prototype only in one place, i.e. in a header?
Thomas
Re: [PATCH 3/3] pc-bios/s390-ccw: Add a proper prototype for main()
Quoted 44 lines · Thomas Huth
Quoted 34 lines · Philippe Mathieu-Daudé
Quoted 33 lines · Thomas Huth
Older versions of Clang complain if there is no prototype for
main(). Add one, and while we're at it, make sure that we use the same type formain.candnetmain.c- since the return value does not matter, declare the return type ofmain()as "void".Signed-off-by Thomas Huth <[email protected]>---
pc-bios/s390-ccw/main.c | 3 +--
pc-bios/s390-ccw/s390-ccw.h| 1 +2 files changed, 2 insertions(+), 2 deletions(-)pc-bios/s390-ccw/main.c +0
-0@@ -281,7 +281,7 @@ static void probe_boot_device(void)
sclp_print("Could not find a suitable boot device (none specified)\n");
}
-int main(void)
+void main(void)
{
sclp_setup();
css_setup();pc-bios/s390-ccw/main.c +0
-1@@ -294,5 +294,4 @@ int main(void) } panic("Failed to load OS from hard disk\n"); - return 0; /* make compiler happy */ }pc-bios/s390-ccw/s390-ccw.h +0
-0Quoted 8 lines
Quoted 6 lines
pc-bios/s390-ccw/s390-ccw.h +0
-0@@ -57,6 +57,7 @@ void write_subsystem_identification(void); void write_iplb_location(void);extern char stack[PAGE_SIZE * 8]
__attribute__((__aligned__(PAGE_SIZE)));
unsigned intget_loadparm_index(void);
+void main(void);Can we keep the forward declaration in the source?
Quoted 3 lines
There are two
main()functions, one inmain.cand one innetmain.c, that's why I think it's better to declare the prototype only in one place, i.e. in a header?
Since it is a kludge to make the compiler happy, I'd rather keep it local, but I don't mind much :)
Re: [PATCH 3/3] pc-bios/s390-ccw: Add a proper prototype for main()
In reply to Thomas HuthQuoted 10 lines · On Wed, 12 May 2021 19:15:50 +0200 Thomas Huth <[email protected]> wrote:
Older versions of Clang complain if there is no prototype for
main(). Add one, and while we're at it, make sure that we use the same type formain.candnetmain.c- since the return value does not matter, declare the return type ofmain()as "void".Signed-off-by Thomas Huth <[email protected]>--- pc-bios/s390-ccw/main.c | 3 +-- pc-bios/s390-ccw/s390-ccw.h | 1 + 2 files changed, 2 insertions(+), 2 deletions(-)
It's probably not strictly needed for both to have the same prototype, but this looks sane to me.