Re: clang breakage: memtest86+
On Fri, Aug 11 2017, Mike Larkin wrote: > On Fri, Aug 11, 2017 at 05:29:23PM -0400, Jeremie Courreges-Anglas wrote: >> On Fri, Aug 11 2017, Jeremie Courreges-Anglas wrote: >> > On Fri, Aug 11 2017, Christian Weisgerber wrote: >> >> On 2017-08-10, Jeremie Courreges-Anglas wrote: >> >> >> >>> +# XXX base gcc >> >>> +CC= /usr/bin/gcc >> > >> > Thanks for the test reports, which confirm that I'm the only one unable >> > to run memtest86+ on my machines... >> > >> >> That isn't a solution. >> > >> > It is a solution, just not a long-term one. ;) >> > >> > So here's a diff I just cooked up (I don't know where I've put the >> > previous version...). While here, respect CC. Note that as(1) is still >> > used once, which could be a problem on a clang-only box. >> > >> > Tests welcome. >> >> So with this diff memtest86+ doesn't work any more on naddy's x230 >> (it did with /usr/bin/gcc). Using gcc from ports doesn't help. >> > > I was trying just now to take a look at why it fails (since I also have > an x230) but it doesn't even build for me with clang at all: > > cc -c -O2 -pipe -Wall -march=i486 -m32 -O2 -fomit-frame-pointer -fno-builtin > -ffreestanding -fPIC -fno-stack-protector -fno-pie -fno-strict-aliasing > reloc.c > reloc.c:50:10: warning: variable 'got' is uninitialized when used here > [-Wuninitialized] > return *got; > ^~~ > reloc.c:49:26: note: initialize the variable 'got' to silence this warning > register Elf32_Addr *got asm ("%ebx"); > ^ > = NULL > 1 warning generated. > cc -O2 -pipe -Wall -march=i486 -m32 -O2 -fomit-frame-pointer -fno-builtin > -ffreestanding -fPIC -fno-stack-protector -fno-pie -c -o main.o main.c > main.c:115:7: warning: passing 'volatile ulong *' (aka 'volatile unsigned > long *') to parameter of type 'const void *' discards qualifiers > [-Wincompatible-pointer-types-discards-qualifiers] > goto *p; > ^~ > main.c:115:2: error: indirect goto in function with no address-of-label > expressions > goto *p; > ^ > 1 warning and 1 error generated. > gmake: *** [: main.o] Error 1 > *** Error 2 in . (/usr/ports/infrastructure/mk/bsd.port.mk:2705 > '/usr/ports/pobj/memtest86+-4.20/.build_done') > *** Error 1 in /usr/ports/sysutils/memtest86+ > (/usr/ports/infrastructure/mk/bsd.port.mk:2408 'all') > > If someone can give me a clue why, I can see if I can debug it further. clang just doesn't support this kind of code. Here's naddy's patch which is better than mine in my opinion (still hackish, but more readable). Note that I've committed recent changes to the port, make sure you use cvs HEAD. Index: patches/patch-io_h === RCS file: patches/patch-io_h diff -N patches/patch-io_h --- /dev/null 1 Jan 1970 00:00:00 - +++ patches/patch-io_h 11 Aug 2017 23:13:27 - @@ -0,0 +1,32 @@ +$OpenBSD$ + +Index: io.h +--- io.h.orig io.h +@@ -31,7 +31,7 @@ + */ + + #define __OUT1(s,x) \ +-extern inline void __out##s(unsigned x value, unsigned short port) { ++static inline void __out##s(unsigned x value, unsigned short port) { + + #define __OUT2(s,s1,s2) \ + __asm__ __volatile__ ("out" #s " %" s1 "0,%" s2 "1" +@@ -43,7 +43,7 @@ __OUT1(s##_p,x) __OUT2(s,s1,"w") : : "a" (value), "d" + __OUT1(s##c_p,x) __OUT2(s,s1,"") : : "a" (value), "id" (port)); SLOW_DOWN_IO; } + + #define __IN1(s) \ +-extern inline RETURN_TYPE __in##s(unsigned short port) { RETURN_TYPE _v; ++static inline RETURN_TYPE __in##s(unsigned short port) { RETURN_TYPE _v; + + #define __IN2(s,s1,s2) \ + __asm__ __volatile__ ("in" #s " %" s2 "1,%" s1 "0" +@@ -55,7 +55,7 @@ __IN1(s##_p) __IN2(s,s1,"w") : "=a" (_v) : "d" (port) + __IN1(s##c_p) __IN2(s,s1,"") : "=a" (_v) : "id" (port) ,##i ); SLOW_DOWN_IO; return _v; } + + #define __OUTS(s) \ +-extern inline void outs##s(unsigned short port, const void * addr, unsigned long count) \ ++static inline void outs##s(unsigned short port, const void * addr, unsigned long count) \ + { __asm__ __volatile__ ("cld ; rep ; outs" #s \ + : "=S" (addr), "=c" (count) : "d" (port),"0" (addr),"1" (count)); } + Index: patches/patch-main_c === RCS file: patches/patch-main_c diff -N patches/patch-main_c --- /dev/null 1 Jan 1970 00:00:00 - +++ patches/patch-main_c11 Aug 2017 23:13:27 - @@ -0,0 +1,13 @@ +$OpenBSD$ + +Index: main.c +--- main.c.orig main.c +@@ -111,6 +111,7 @@ static void __run_at(unsigned long addr) + /* Copy memtest86+ code */ + memmove((void *)addr, &_start, _end - _start); + /* Jump to the start address */ ++dummy:p = &&dummy; + p = (ulong *)(addr + startup_32 - _start); + goto *p; + } -- jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF DDCC 0DFA 74AE 1524 E7EE
Re: clang breakage: memtest86+
On Fri, Aug 11, 2017 at 05:29:23PM -0400, Jeremie Courreges-Anglas wrote: > On Fri, Aug 11 2017, Jeremie Courreges-Anglas wrote: > > On Fri, Aug 11 2017, Christian Weisgerber wrote: > >> On 2017-08-10, Jeremie Courreges-Anglas wrote: > >> > >>> +# XXX base gcc > >>> +CC= /usr/bin/gcc > > > > Thanks for the test reports, which confirm that I'm the only one unable > > to run memtest86+ on my machines... > > > >> That isn't a solution. > > > > It is a solution, just not a long-term one. ;) > > > > So here's a diff I just cooked up (I don't know where I've put the > > previous version...). While here, respect CC. Note that as(1) is still > > used once, which could be a problem on a clang-only box. > > > > Tests welcome. > > So with this diff memtest86+ doesn't work any more on naddy's x230 > (it did with /usr/bin/gcc). Using gcc from ports doesn't help. > I was trying just now to take a look at why it fails (since I also have an x230) but it doesn't even build for me with clang at all: cc -c -O2 -pipe -Wall -march=i486 -m32 -O2 -fomit-frame-pointer -fno-builtin -ffreestanding -fPIC -fno-stack-protector -fno-pie -fno-strict-aliasing reloc.c reloc.c:50:10: warning: variable 'got' is uninitialized when used here [-Wuninitialized] return *got; ^~~ reloc.c:49:26: note: initialize the variable 'got' to silence this warning register Elf32_Addr *got asm ("%ebx"); ^ = NULL 1 warning generated. cc -O2 -pipe -Wall -march=i486 -m32 -O2 -fomit-frame-pointer -fno-builtin -ffreestanding -fPIC -fno-stack-protector -fno-pie -c -o main.o main.c main.c:115:7: warning: passing 'volatile ulong *' (aka 'volatile unsigned long *') to parameter of type 'const void *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers] goto *p; ^~ main.c:115:2: error: indirect goto in function with no address-of-label expressions goto *p; ^ 1 warning and 1 error generated. gmake: *** [: main.o] Error 1 *** Error 2 in . (/usr/ports/infrastructure/mk/bsd.port.mk:2705 '/usr/ports/pobj/memtest86+-4.20/.build_done') *** Error 1 in /usr/ports/sysutils/memtest86+ (/usr/ports/infrastructure/mk/bsd.port.mk:2408 'all') If someone can give me a clue why, I can see if I can debug it further. -ml > We have several options: > - mark it broken > - force the use of /usr/bin/gcc, which obviously work work any more when > we unlink gcc on i386/amd64. > - build a binary snapshot with /usr/bin/gcc and then just use that > binary snapshot as a distfile. After all, these are standalone > programs. > > Marking it BROKEN would be a shame, memtest86+ is a useful tool. As > discussed with naddy I don't know yet which solution we'll choose in the > end, opinions welcome. > > -- > jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF DDCC 0DFA 74AE 1524 E7EE >
Re: clang breakage: memtest86+
On Fri, 11 Aug 2017 17:29:23 -0400, Jeremie Courreges-Anglas wrote: > So with this diff memtest86+ doesn't work any more on naddy's x230 > (it did with /usr/bin/gcc). Using gcc from ports doesn't help. Have you tried building it without optimization? - todd
Re: clang breakage: memtest86+
On Fri, Aug 11 2017, Jeremie Courreges-Anglas wrote: > On Fri, Aug 11 2017, Christian Weisgerber wrote: >> On 2017-08-10, Jeremie Courreges-Anglas wrote: >> >>> +# XXX base gcc >>> +CC=/usr/bin/gcc > > Thanks for the test reports, which confirm that I'm the only one unable > to run memtest86+ on my machines... > >> That isn't a solution. > > It is a solution, just not a long-term one. ;) > > So here's a diff I just cooked up (I don't know where I've put the > previous version...). While here, respect CC. Note that as(1) is still > used once, which could be a problem on a clang-only box. > > Tests welcome. So with this diff memtest86+ doesn't work any more on naddy's x230 (it did with /usr/bin/gcc). Using gcc from ports doesn't help. We have several options: - mark it broken - force the use of /usr/bin/gcc, which obviously work work any more when we unlink gcc on i386/amd64. - build a binary snapshot with /usr/bin/gcc and then just use that binary snapshot as a distfile. After all, these are standalone programs. Marking it BROKEN would be a shame, memtest86+ is a useful tool. As discussed with naddy I don't know yet which solution we'll choose in the end, opinions welcome. -- jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF DDCC 0DFA 74AE 1524 E7EE
Re: clang breakage: memtest86+
On Fri, Aug 11 2017, Christian Weisgerber wrote: > On 2017-08-10, Jeremie Courreges-Anglas wrote: > >> +# XXX base gcc >> +CC= /usr/bin/gcc Thanks for the test reports, which confirm that I'm the only one unable to run memtest86+ on my machines... > That isn't a solution. It is a solution, just not a long-term one. ;) So here's a diff I just cooked up (I don't know where I've put the previous version...). While here, respect CC. Note that as(1) is still used once, which could be a problem on a clang-only box. Tests welcome. Index: Makefile === RCS file: /d/cvs/ports/sysutils/memtest86+/Makefile,v retrieving revision 1.10 diff -u -p -r1.10 Makefile --- Makefile4 Feb 2014 10:14:52 - 1.10 +++ Makefile11 Aug 2017 20:07:02 - @@ -19,7 +19,7 @@ MASTER_SITES= ${HOMEPAGE}/download/${VE USE_GMAKE= Yes NO_TEST= Yes -MAKE_ENV= V=${VERSION} +MAKE_ENV= CC="${CC}" V=${VERSION} post-build: @cd ${WRKBUILD} && sh ${WRKDIST}/makeiso.sh Index: patches/patch-Makefile === RCS file: /d/cvs/ports/sysutils/memtest86+/patches/patch-Makefile,v retrieving revision 1.6 diff -u -p -r1.6 patch-Makefile --- patches/patch-Makefile 31 Mar 2015 18:29:51 - 1.6 +++ patches/patch-Makefile 11 Aug 2017 20:15:20 - @@ -1,7 +1,8 @@ $OpenBSD: patch-Makefile,v 1.6 2015/03/31 18:29:51 pascal Exp $ $RuOBSD: patch-Makefile,v 1.3 2009/02/07 10:28:03 form Exp $ Makefile.orig Sun Jan 23 19:11:04 2011 -+++ Makefile Tue Mar 31 17:06:38 2015 +Index: Makefile +--- Makefile.orig Makefile @@ -6,33 +6,47 @@ # # Path for the floppy disk device @@ -72,7 +73,7 @@ $RuOBSD: patch-Makefile,v 1.3 2009/02/07 test.o: test.c - $(CC) -c -Wall -march=i486 -m32 -Os -fomit-frame-pointer -fno-builtin -ffreestanding test.c -+ $(CC) -c -Wall -march=i486 -m32 -Os -fomit-frame-pointer -fno-builtin -ffreestanding -fno-pie test.c ++ $(CC) -c -Wall -march=i486 -m32 -Os -fomit-frame-pointer -fno-builtin -ffreestanding -fno-stack-protector -fno-pie test.c clean: rm -f *.o *.s *.iso memtest.bin memtest memtest_shared memtest_shared.bin Index: patches/patch-io_h === RCS file: patches/patch-io_h diff -N patches/patch-io_h --- /dev/null 1 Jan 1970 00:00:00 - +++ patches/patch-io_h 11 Aug 2017 20:17:26 - @@ -0,0 +1,34 @@ +$OpenBSD$ + +Simple fix to avoid multiple definitions error. + +Index: io.h +--- io.h.orig io.h +@@ -31,7 +31,7 @@ + */ + + #define __OUT1(s,x) \ +-extern inline void __out##s(unsigned x value, unsigned short port) { ++static inline void __out##s(unsigned x value, unsigned short port) { + + #define __OUT2(s,s1,s2) \ + __asm__ __volatile__ ("out" #s " %" s1 "0,%" s2 "1" +@@ -43,7 +43,7 @@ __OUT1(s##_p,x) __OUT2(s,s1,"w") : : "a" (value), "d" + __OUT1(s##c_p,x) __OUT2(s,s1,"") : : "a" (value), "id" (port)); SLOW_DOWN_IO; } + + #define __IN1(s) \ +-extern inline RETURN_TYPE __in##s(unsigned short port) { RETURN_TYPE _v; ++static inline RETURN_TYPE __in##s(unsigned short port) { RETURN_TYPE _v; + + #define __IN2(s,s1,s2) \ + __asm__ __volatile__ ("in" #s " %" s2 "1,%" s1 "0" +@@ -55,7 +55,7 @@ __IN1(s##_p) __IN2(s,s1,"w") : "=a" (_v) : "d" (port) + __IN1(s##c_p) __IN2(s,s1,"") : "=a" (_v) : "id" (port) ,##i ); SLOW_DOWN_IO; return _v; } + + #define __OUTS(s) \ +-extern inline void outs##s(unsigned short port, const void * addr, unsigned long count) \ ++static inline void outs##s(unsigned short port, const void * addr, unsigned long count) \ + { __asm__ __volatile__ ("cld ; rep ; outs" #s \ + : "=S" (addr), "=c" (count) : "d" (port),"0" (addr),"1" (count)); } + Index: patches/patch-main_c === RCS file: patches/patch-main_c diff -N patches/patch-main_c --- /dev/null 1 Jan 1970 00:00:00 - +++ patches/patch-main_c11 Aug 2017 20:05:21 - @@ -0,0 +1,20 @@ +$OpenBSD$ + +Unsupported with clang: + + main.c:115:2: error: indirect goto in function with no address-of-label expressions + +Index: main.c +--- main.c.orig main.c +@@ -112,7 +112,9 @@ static void __run_at(unsigned long addr) + memmove((void *)addr, &_start, _end - _start); + /* Jump to the start address */ + p = (ulong *)(addr + startup_32 - _start); +- goto *p; ++ ++ void (* volatile f)(void); ++ f = (void (* volatile)(void)) p; + } + + static unsigned long run_at_addr = 0x; -- jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF DDCC 0DFA 74AE 1524 E7EE
Re: clang breakage: memtest86+
On 2017-08-10, Jeremie Courreges-Anglas wrote: > +# XXX base gcc > +CC= /usr/bin/gcc That isn't a solution. -- Christian "naddy" Weisgerber na...@mips.inka.de
Re: clang breakage: memtest86+
On Thu, Aug 10, 2017 at 03:21:13PM -0400, Jeremie Courreges-Anglas wrote: > > I've cooked a diff to allow building memtest86+ with clang. Great. The > problem is that I just get a black screen on this x61 laptop (the only > noticeable thing is that the cursor stays in the middle of the screen). > > The only problem is, I get the same result with a build with base gcc. > > Could people please apply the diff below, build and install memtest86+, > and then test it? Just type > > > boot memtest > > at the boot(8) prompt. > > Years ago I had tested this on an x240 machine, and I blamed the failure > on my laptop being too recent. But maybe that stuff is plain broken > since years. > > Both i386 and amd64 could be tested, btw. Thanks in advance. > > PS: earlier I had tried to update the port to the latest version but > didn't get it to build. Maybe this time... > > > Index: Makefile > === > RCS file: /d/cvs/ports/sysutils/memtest86+/Makefile,v > retrieving revision 1.10 > diff -u -p -r1.10 Makefile > --- Makefile 4 Feb 2014 10:14:52 - 1.10 > +++ Makefile 10 Aug 2017 07:37:10 - > @@ -3,6 +3,9 @@ > > ONLY_FOR_ARCHS= amd64 i386 > > +# XXX base gcc > +CC= /usr/bin/gcc > + > COMMENT= thorough, stand alone memory test > VERSION= 4.20 > DISTNAME=memtest86+-${VERSION} Works fine here with your patch on my amd64 X230. Any particular reasons we're still at 4.20 instead of 5.01?
clang breakage: memtest86+
I've cooked a diff to allow building memtest86+ with clang. Great. The problem is that I just get a black screen on this x61 laptop (the only noticeable thing is that the cursor stays in the middle of the screen). The only problem is, I get the same result with a build with base gcc. Could people please apply the diff below, build and install memtest86+, and then test it? Just type > boot memtest at the boot(8) prompt. Years ago I had tested this on an x240 machine, and I blamed the failure on my laptop being too recent. But maybe that stuff is plain broken since years. Both i386 and amd64 could be tested, btw. Thanks in advance. PS: earlier I had tried to update the port to the latest version but didn't get it to build. Maybe this time... Index: Makefile === RCS file: /d/cvs/ports/sysutils/memtest86+/Makefile,v retrieving revision 1.10 diff -u -p -r1.10 Makefile --- Makefile4 Feb 2014 10:14:52 - 1.10 +++ Makefile10 Aug 2017 07:37:10 - @@ -3,6 +3,9 @@ ONLY_FOR_ARCHS=amd64 i386 +# XXX base gcc +CC=/usr/bin/gcc + COMMENT= thorough, stand alone memory test VERSION= 4.20 DISTNAME= memtest86+-${VERSION} -- jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF DDCC 0DFA 74AE 1524 E7EE