On Fri, Aug 11 2017, Mike Larkin <mlar...@azathoth.net> wrote:
> On Fri, Aug 11, 2017 at 05:29:23PM -0400, Jeremie Courreges-Anglas wrote:
>> On Fri, Aug 11 2017, Jeremie Courreges-Anglas <j...@wxcvbn.org> wrote:
>> > On Fri, Aug 11 2017, Christian Weisgerber <na...@mips.inka.de> wrote:
>> >> On 2017-08-10, Jeremie Courreges-Anglas <j...@wxcvbn.org> 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: *** [<builtin>: 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 -0000
+++ patches/patch-io_h  11 Aug 2017 23:13:27 -0000
@@ -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 -0000
+++ patches/patch-main_c        11 Aug 2017 23:13:27 -0000
@@ -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

Reply via email to