Skip to contentSkip to conversation

Ensure that MIPS target code is compiled for the O32 ABI.

PATCH Superseded Mark H Weaver 3 participants 29 messages Aug 19, 2015 – Oct 15, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Ensure that MIPS target code is compiled for the O32 ABI.

Include -mabi=32 in CFLAGS_PLATFORM and CCASFLAGS_PLATFORM to compile code for the O32 ABI when targetting MIPS, since the MIPS assembly code in GRUB assumes this. This flag is also needed when compiling asm-tests/mips.S from configure, because GNU as rejects MIPS register names such as $t2 unless the O32 ABI is selected.

---
 conf/Makefile.common | 4 ++++
 configure.ac         | 7 +++++--
 2 files changed, 9 insertions(+), 2 deletions(-)
conf/Makefile.common +4 -0
index fcb8d2e..bd125da 100644
@@ -20,6 +20,10 @@ endif
 if COND_powerpc_ieee1275
   CFLAGS_PLATFORM += -mcpu=powerpc
 endif
+if COND_mips
+  CFLAGS_PLATFORM += -mabi=32
+  CCASFLAGS_PLATFORM = -mabi=32
+endif
 
 #FIXME: discover and check XEN headers
 CPPFLAGS_XEN = -I/usr/include
configure.ac +5 -2
index c864311..1f5e8a2 100644
@@ -2,7 +2,8 @@
 
 # Process this file with autoconf to produce a configure script.
 
-# Copyright (C) 2002,2003,2004,2005,2006,2007,2008,2009,2010  Free Software Foundation, Inc.
+# Copyright (C) 2002,2003,2004,2005,2006,2007,2008,2009,2010,2011,
+#   2012,2013,2014,2015  Free Software Foundation, Inc.
 #
 # This configure.ac is free software; the author
 # gives unlimited permission to copy and/or distribute it,
@@ -599,9 +600,11 @@ fi
 
 AC_CACHE_CHECK([for options to compile assembly], [grub_cv_cc_target_asm_compile], [
 test_program=
+test_ccasflags=
 case "x$target_cpu-$platform" in
      xmips-* | xmipsel-*)
         test_program=mips
+        test_ccasflags=-mabi=32
 	;;
      xi386-pc)
        test_program=i386-pc
@@ -618,7 +621,7 @@ if test x"$test_program" = x ; then
 else
   found=no
   for arg in "" "-no-integrated-as"; do
-    cmdline="$TARGET_CC -c -o /dev/null $TARGET_CCASFLAGS $arg $TARGET_CPPFLAGS $srcdir/asm-tests/$test_program.S"
+    cmdline="$TARGET_CC -c -o /dev/null $TARGET_CCASFLAGS $test_ccasflags $arg $TARGET_CPPFLAGS $srcdir/asm-tests/$test_program.S"
     echo "Running $cmdline" >&AS_MESSAGE_LOG_FD
     if $cmdline >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD; then
       grub_cv_cc_target_asm_compile="$arg"
Signature · 1 line
2.4.3
#1 lore raw

19.08.2015 21:35, Mark H Weaver пишет:

Quoted 15 lines

Include -mabi=32 in CFLAGS_PLATFORM and CCASFLAGS_PLATFORM to compile code for the O32 ABI when targetting MIPS, since the MIPS assembly code in GRUB assumes this. This flag is also needed when compiling asm-tests/mips.S from configure, because GNU as rejects MIPS register names such as $t2 unless the O32 ABI is selected.

---
  conf/Makefile.common | 4 ++++
  configure.ac         | 7 +++++--
  2 files changed, 9 insertions(+), 2 deletions(-)
conf/Makefile.common +0 -0
index fcb8d2e..bd125da 100644

conf/Makefile.common endif · line 27

Quoted 8 lines
conf/Makefile.common +4 -0
@@ -20,6 +20,10 @@ endif
  if COND_powerpc_ieee1275
    CFLAGS_PLATFORM += -mcpu=powerpc
  endif
+if COND_mips
+  CFLAGS_PLATFORM += -mabi=32
+  CCASFLAGS_PLATFORM = -mabi=32
+endif
 

Does it work with clang?

Quoted 38 lines
conf/Makefile.common +0 -0
  #FIXME: discover and check XEN headers
  CPPFLAGS_XEN = -I/usr/include
configure.ac +5 -2
index c864311..1f5e8a2 100644
@@ -2,7 +2,8 @@
 
  # Process this file with autoconf to produce a configure script.
 
-# Copyright (C) 2002,2003,2004,2005,2006,2007,2008,2009,2010  Free Software Foundation, Inc.
+# Copyright (C) 2002,2003,2004,2005,2006,2007,2008,2009,2010,2011,
+#   2012,2013,2014,2015  Free Software Foundation, Inc.
  #
  # This configure.ac is free software; the author
  # gives unlimited permission to copy and/or distribute it,
@@ -599,9 +600,11 @@ fi
 
  AC_CACHE_CHECK([for options to compile assembly], [grub_cv_cc_target_asm_compile], [
  test_program=
+test_ccasflags=
  case "x$target_cpu-$platform" in
       xmips-* | xmipsel-*)
          test_program=mips
+        test_ccasflags=-mabi=32
  	;;
       xi386-pc)
         test_program=i386-pc
@@ -618,7 +621,7 @@ if test x"$test_program" = x ; then
  else
    found=no
    for arg in "" "-no-integrated-as"; do
-    cmdline="$TARGET_CC -c -o /dev/null $TARGET_CCASFLAGS $arg $TARGET_CPPFLAGS $srcdir/asm-tests/$test_program.S"
+    cmdline="$TARGET_CC -c -o /dev/null $TARGET_CCASFLAGS $test_ccasflags $arg $TARGET_CPPFLAGS $srcdir/asm-tests/$test_program.S"
      echo "Running $cmdline" >&AS_MESSAGE_LOG_FD
      if $cmdline >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD; then
        grub_cv_cc_target_asm_compile="$arg"
#2 lore raw
Quoted 11 lines · Andrei Borzenkov

19.08.2015 21:35, Mark H Weaver пишет:

Quoted 10 lines

Include -mabi=32 in CFLAGS_PLATFORM and CCASFLAGS_PLATFORM to compile code for the O32 ABI when targetting MIPS, since the MIPS assembly code in GRUB assumes this. This flag is also needed when compiling asm-tests/mips.S from configure, because GNU as rejects MIPS register names such as $t2 unless the O32 ABI is selected.

---
  conf/Makefile.common | 4 ++++
  configure.ac         | 7 +++++--
  2 files changed, 9 insertions(+), 2 deletions(-)
Quoted 15 lines

conf/Makefile.common endif · line 27

Quoted 13 lines
conf/Makefile.common +4 -0
index fcb8d2e..bd125da 100644
@@ -20,6 +20,10 @@ endif
  if COND_powerpc_ieee1275
    CFLAGS_PLATFORM += -mcpu=powerpc
  endif
+if COND_mips
+  CFLAGS_PLATFORM += -mabi=32
+  CCASFLAGS_PLATFORM = -mabi=32
+endif
 

Does it work with clang?

Based on the error message below, clang seems to accept and understand the -mabi=32 option, but the version of clang that we have in GNU Guix (which uses the N32 ABI on MIPS) seems to lack support for compiling for O32:

  mhw@librenote:~$ clang -mabi=32 mips.S 
  error: unknown target CPU 'mips32r2'

However, it doesn't work without that option either:

  mhw@librenote:~$ clang mips.S 
  mips.S: Assembler messages:
  mips.S:7: Error: invalid operands `ld $t2,0($t6)'
  mips.S:10: Error: invalid operands `addiu $t7,$s0,(b-a)'
  clang-3.6: error: assembler command failed with exit code 1 (use -v to see invocation)

This is the same failure that occurs with gcc when configured to use the N32 ABI by default. I also tried passing -fno-integrated-as in both cases above, but it made no difference.

Mark

#3 lore raw

22.08.2015 21:04, Mark H Weaver пишет:

Quoted 8 lines
Quoted 6 lines · Andrei Borzenkov

19.08.2015 21:35, Mark H Weaver пишет:

Quoted 5 lines

Include -mabi=32 in CFLAGS_PLATFORM and CCASFLAGS_PLATFORM to compile code for the O32 ABI when targetting MIPS, since the MIPS assembly code in GRUB assumes this. This flag is also needed when compiling asm-tests/mips.S from configure, because GNU as rejects MIPS register names such as $t2 unless the O32 ABI is selected.

BTW, I assume this did work at some point; so this needs more verbose explanation what changed and why it stopped working.

Quoted 21 lines
Quoted 5 lines
Quoted 5 lines
---
   conf/Makefile.common | 4 ++++
   configure.ac         | 7 +++++--
   2 files changed, 9 insertions(+), 2 deletions(-)
Quoted 15 lines

conf/Makefile.common endif · line 27

Quoted 13 lines
conf/Makefile.common +4 -0
index fcb8d2e..bd125da 100644
@@ -20,6 +20,10 @@ endif
   if COND_powerpc_ieee1275
     CFLAGS_PLATFORM += -mcpu=powerpc
   endif
+if COND_mips
+  CFLAGS_PLATFORM += -mabi=32
+  CCASFLAGS_PLATFORM = -mabi=32
+endif
 

Does it work with clang?

Quoted 8 lines

Based on the error message below, clang seems to accept and understand the -mabi=32 option, but the version of clang that we have in GNU Guix (which uses the N32 ABI on MIPS) seems to lack support for compiling for O32:

   mhw@librenote:~$ clang -mabi=32 mips.S
   error: unknown target CPU 'mips32r2'

Are you on native MIPS platform or cross-compiling? Which clang version? This works for me using current upstream clang (I do not have cross binutils so linking fails, but that's different story).

bor@bor-Latitude-E5450:~/build/grub$ ~/build/llvm/bin/clang --target=mips -mabi=32 -v -integrated-as -c asm-tests/mips.S
clang version 3.8.0 (git://github.com/llvm-mirror/clang.git 2b06a033d151865ca944dedf899e9b36aa630f42) (git://github.com/llvm-mirror/llvm.git 8f7e8462cdf3b0eed913202b81f14e2fead62be4)
Target: mips
Thread model: posix
InstalledDir: /home/bor/build/llvm/bin
 "/home/bor/build/llvm/bin/clang-3.8" -cc1 -triple mips -E 
-disable-free -main-file-name mips.S -mrelocation-model static -mthread-model posix -mdisable-fp-elim -fmath-errno -mconstructor-aliases -target-cpu mips32r2 -target-abi o32 -mfloat-abi hard -v -dwarf-column-info -coverage-file /home/bor/build/grub/mips.S -resource-dir /home/bor/build/llvm/bin/../lib/clang/3.8.0 -fdebug-compilation-dir /home/bor/build/grub -ferror-limit 19 -fmessage-length 95 -mstackrealign -fobjc-runtime=gcc -fdiagnostics-show-option -o /tmp/mips-b9949a.s -x assembler-with-cpp asm-tests/mips.S
clang -cc1 version 3.8.0 based upon LLVM 3.8.0svn default target x86_64-unknown-linux-gnu
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/include
 /home/bor/build/llvm/bin/../lib/clang/3.8.0/include
 /usr/include
End of search list.
 "/home/bor/build/llvm/bin/clang-3.8" -cc1as -triple mips -filetype obj 
-main-file-name mips.S -target-cpu mips32r2 -fdebug-compilation-dir /home/bor/build/grub -dwarf-debug-producer clang version 3.8.0 (git://github.com/llvm-mirror/clang.git 2b06a033d151865ca944dedf899e9b36aa630f42) (git://github.com/llvm-mirror/llvm.git 8f7e8462cdf3b0eed913202b81f14e2fead62be4) -mrelocation-model static -target-abi o32 -o mips.o /tmp/mips-b9949a.s

Actually this works for me also without -mabi=32 and produced object type is identical

Quoted 14 lines

However, it doesn't work without that option either:

   mhw@librenote:~$ clang mips.S
   mips.S: Assembler messages:
   mips.S:7: Error: invalid operands `ld $t2,0($t6)'
   mips.S:10: Error: invalid operands `addiu $t7,$s0,(b-a)'
   clang-3.6: error: assembler command failed with exit code 1 (use -v to see invocation)

This is the same failure that occurs with gcc when configured to use the N32 ABI by default. I also tried passing -fno-integrated-as in both cases above, but it made no difference.

Mark

#4 lore raw
Quoted 4 lines · Andrei Borzenkov

22.08.2015 21:04, Mark H Weaver пишет:

Quoted 3 lines
Quoted 1 line · Andrei Borzenkov

19.08.2015 21:35, Mark H Weaver пишет:

Quoted 8 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

Include -mabi=32 in CFLAGS_PLATFORM and CCASFLAGS_PLATFORM to compile code for the O32 ABI when targetting MIPS, since the MIPS assembly code in GRUB assumes this. This flag is also needed when compiling asm-tests/mips.S from configure, because GNU as rejects MIPS register names such as $t2 unless the O32 ABI is selected.

BTW, I assume this did work at some point; so this needs more verbose explanation what changed and why it stopped working.

It worked, and probably still works, on MIPS systems that use the O32 ABI. It has never worked on systems that use one of the newer ABIs for MIPS.

Quoted 26 lines
Quoted 26 lines
Quoted 5 lines
Quoted 5 lines
---
   conf/Makefile.common | 4 ++++
   configure.ac         | 7 +++++--
   2 files changed, 9 insertions(+), 2 deletions(-)
Quoted 15 lines

conf/Makefile.common endif · line 27

Quoted 13 lines
conf/Makefile.common +4 -0
index fcb8d2e..bd125da 100644
@@ -20,6 +20,10 @@ endif
   if COND_powerpc_ieee1275
     CFLAGS_PLATFORM += -mcpu=powerpc
   endif
+if COND_mips
+  CFLAGS_PLATFORM += -mabi=32
+  CCASFLAGS_PLATFORM = -mabi=32
+endif
 

Does it work with clang?

Based on the error message below, clang seems to accept and understand the -mabi=32 option, but the version of clang that we have in GNU Guix (which uses the N32 ABI on MIPS) seems to lack support for compiling for O32:

Quoted 5 lines
Quoted 3 lines
   mhw@librenote:~$ clang -mabi=32 mips.S
   error: unknown target CPU 'mips32r2'

Are you on native MIPS platform or cross-compiling?

I've done all of my tests on a native MIPS platform. I haven't tried cross-compiling, and would prefer to avoid it.

Quoted 1 line

Which clang version?

3.6.0.

Quoted 2 lines

This works for me using current upstream clang (I do not have cross binutils so linking fails, but that's different story).

[...]

Quoted 2 lines

Actually this works for me also without -mabi=32 and produced object type is identical

That's because the compiler you're using has been configured to use the O32 ABI by default. In that case, -mabi=32 has no effect because that flag means "compile for the O32 ABI", which is already the default.

Thanks,
Mark

#5 lore raw

PATCH v2 1/1 Ensure that MIPS target code is compiled for the O32 ABI.

In reply to Andrei Borzenkov

Include -mabi=32 in CFLAGS_PLATFORM and CCASFLAGS_PLATFORM to compile code for the O32 ABI when targetting MIPS, since the MIPS assembly code in GRUB assumes this. This flag is also needed when compiling asm-tests/mips.S from configure, because GNU as rejects MIPS register names such as $t2 unless the O32 ABI is selected.

This is needed when using a compiler that defaults to one of the newer MIPS ABIs such as N32 or N64, e.g. when natively compiling on a system that uses one of these newer MIPS ABIs.

---
 conf/Makefile.common | 4 ++++
 configure.ac         | 7 +++++--
 2 files changed, 9 insertions(+), 2 deletions(-)
conf/Makefile.common +4 -0
index fcb8d2e..bd125da 100644
@@ -20,6 +20,10 @@ endif
 if COND_powerpc_ieee1275
   CFLAGS_PLATFORM += -mcpu=powerpc
 endif
+if COND_mips
+  CFLAGS_PLATFORM += -mabi=32
+  CCASFLAGS_PLATFORM = -mabi=32
+endif
 
 #FIXME: discover and check XEN headers
 CPPFLAGS_XEN = -I/usr/include
configure.ac +5 -2
index c864311..1f5e8a2 100644
@@ -2,7 +2,8 @@
 
 # Process this file with autoconf to produce a configure script.
 
-# Copyright (C) 2002,2003,2004,2005,2006,2007,2008,2009,2010  Free Software Foundation, Inc.
+# Copyright (C) 2002,2003,2004,2005,2006,2007,2008,2009,2010,2011,
+#   2012,2013,2014,2015  Free Software Foundation, Inc.
 #
 # This configure.ac is free software; the author
 # gives unlimited permission to copy and/or distribute it,
@@ -599,9 +600,11 @@ fi
 
 AC_CACHE_CHECK([for options to compile assembly], [grub_cv_cc_target_asm_compile], [
 test_program=
+test_ccasflags=
 case "x$target_cpu-$platform" in
      xmips-* | xmipsel-*)
         test_program=mips
+        test_ccasflags=-mabi=32
 	;;
      xi386-pc)
        test_program=i386-pc
@@ -618,7 +621,7 @@ if test x"$test_program" = x ; then
 else
   found=no
   for arg in "" "-no-integrated-as"; do
-    cmdline="$TARGET_CC -c -o /dev/null $TARGET_CCASFLAGS $arg $TARGET_CPPFLAGS $srcdir/asm-tests/$test_program.S"
+    cmdline="$TARGET_CC -c -o /dev/null $TARGET_CCASFLAGS $test_ccasflags $arg $TARGET_CPPFLAGS $srcdir/asm-tests/$test_program.S"
     echo "Running $cmdline" >&AS_MESSAGE_LOG_FD
     if $cmdline >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD; then
       grub_cv_cc_target_asm_compile="$arg"
Signature · 1 line
2.5.0
#6 lore raw
Quoted 3 lines · Mark H Weaver

Include -mabi=32 in CFLAGS_PLATFORM and CCASFLAGS_PLATFORM to compile code for the O32 ABI when targetting MIPS, since the MIPS assembly code in GRUB assumes this.

Could you be more precise where we assume this? Why not fix the assembly instead?

Quoted 63 lines

This flag is also needed when compiling
asm-tests/mips.S from configure, because GNU as rejects MIPS register names such as $t2 unless the O32 ABI is selected.

This is needed when using a compiler that defaults to one of the newer MIPS ABIs such as N32 or N64, e.g. when natively compiling on a system that uses one of these newer MIPS ABIs.

---
 conf/Makefile.common | 4 ++++
 configure.ac         | 7 +++++--
 2 files changed, 9 insertions(+), 2 deletions(-)
conf/Makefile.common +4 -0
index fcb8d2e..bd125da 100644
@@ -20,6 +20,10 @@ endif
 if COND_powerpc_ieee1275
   CFLAGS_PLATFORM += -mcpu=powerpc
 endif
+if COND_mips
+  CFLAGS_PLATFORM += -mabi=32
+  CCASFLAGS_PLATFORM = -mabi=32
+endif
 
 #FIXME: discover and check XEN headers
 CPPFLAGS_XEN = -I/usr/include
configure.ac +5 -2
index c864311..1f5e8a2 100644
@@ -2,7 +2,8 @@
 
 # Process this file with autoconf to produce a configure script.
 
-# Copyright (C) 2002,2003,2004,2005,2006,2007,2008,2009,2010  Free Software Foundation, Inc.
+# Copyright (C) 2002,2003,2004,2005,2006,2007,2008,2009,2010,2011,
+#   2012,2013,2014,2015  Free Software Foundation, Inc.
 #
 # This configure.ac is free software; the author
 # gives unlimited permission to copy and/or distribute it,
@@ -599,9 +600,11 @@ fi
 
 AC_CACHE_CHECK([for options to compile assembly], [grub_cv_cc_target_asm_compile], [
 test_program=
+test_ccasflags=
 case "x$target_cpu-$platform" in
      xmips-* | xmipsel-*)
         test_program=mips
+        test_ccasflags=-mabi=32
 	;;
      xi386-pc)
        test_program=i386-pc
@@ -618,7 +621,7 @@ if test x"$test_program" = x ; then
 else
   found=no
   for arg in "" "-no-integrated-as"; do
-    cmdline="$TARGET_CC -c -o /dev/null $TARGET_CCASFLAGS $arg $TARGET_CPPFLAGS $srcdir/asm-tests/$test_program.S"
+    cmdline="$TARGET_CC -c -o /dev/null $TARGET_CCASFLAGS $test_ccasflags $arg $TARGET_CPPFLAGS $srcdir/asm-tests/$test_program.S"
     echo "Running $cmdline" >&AS_MESSAGE_LOG_FD
     if $cmdline >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD; then
       grub_cv_cc_target_asm_compile="$arg"
#7 lore raw
Quoted 5 lines · Vladimir 'φ-coder/phcoder' Serbinenko
Quoted 3 lines · Mark H Weaver

Include -mabi=32 in CFLAGS_PLATFORM and CCASFLAGS_PLATFORM to compile code for the O32 ABI when targetting MIPS, since the MIPS assembly code in GRUB assumes this.

Could you be more precise where we assume this?

Well, to begin with, most of the MIPS assembly code in GRUB uses the MIPS register names such as $tN, $sN, $aN, $vN, etc. Such code is rejected by the assembler unless the O32 ABI is being used, which makes sense since those names are based on the registers' roles in the O32 ABI.

In addition, I guess that any MIPS assembly code in *.S that is called by C (or calls into C) will need to be adjusted to use the calling conventions of the ABI in use (N32 or N64). There may be other issues as well; I haven't researched it.

Quoted 1 line

Why not fix the assembly instead?

If someone wants to do that job, I'd be pleased, but I don't have time to do it. I have too many other more important things to work on, and not enough time. Too few people are working on non-Intel platforms, leaving most of the work on both the MIPS and ARMHF ports of GNU Guix to me. Many other important packages still need to be fixed on both MIPS and ARMHF, whereas I have GRUB working well.

Regards,
Mark

#8 lore raw
In reply to Vladimir 'φ-coder/phcoder' Serbinenko

08.09.2015 20:11, Vladimir 'φ-coder/phcoder' Serbinenko пишет:

Quoted 6 lines · Mark H Weaver
Quoted 3 lines

Include -mabi=32 in CFLAGS_PLATFORM and CCASFLAGS_PLATFORM to compile code for the O32 ABI when targetting MIPS, since the MIPS assembly code in GRUB assumes this.

Could you be more precise where we assume this? Why not fix the assembly instead?

If I understand it correctly, this is not only about assembly - ABIs differ in sizes of types as well, so we'd need to define whole new CPU in grub. Not sure if it's worth it. We can consider ourselves lucky it was caught that early.

#9 lore raw
Quoted 10 lines · Andrei Borzenkov

08.09.2015 20:11, Vladimir 'φ-coder/phcoder' Serbinenko пишет:

Quoted 6 lines · Mark H Weaver
Quoted 3 lines

Include -mabi=32 in CFLAGS_PLATFORM and CCASFLAGS_PLATFORM to compile code for the O32 ABI when targetting MIPS, since the MIPS assembly code in GRUB assumes this.

Could you be more precise where we assume this? Why not fix the assembly instead?

If I understand it correctly, this is not only about assembly - ABIs differ in sizes of types as well,

Only in obscure types long double and uint128_t. We use neither.

Quoted 2 lines

so we'd need to define whole new CPU
in grub.

Nope

Quoted 2 lines

Not sure if it's worth it. We can consider ourselves lucky it was caught that early.

The differences are:
* Use of rela instead of rel section. (I've prepared a patch)
* Register names: There is no $t5 but there is $a5. I prepared a draft, cleaning up
* Different parameter/result passing in presence of either
a) >4 parameters
b) floats
c) 64-bit integers
d) structs
Neither happens between C and assembly. In all we have only following
interfaces between C and assembly:
a) Relocator call. No arguments void (*) (void);
b) void grub_main(void);
c) void
grub_decompress_core (void *src, void *dst, unsigned long srcsize,

		      unsigned long dstsize);

d) void EXPORT_FUNC(grub_arch_sync_caches) (void *address, grub_size_t
len);
e) void grub_arch_sync_dma_caches (void *address, grub_size_t len);
f) int grub_setjmp (grub_jmp_buf env) // grub_jmp_buf is an array, so
pointer
g) int grub_longjmp (grub_jmp_buf env, int val)
* $gp is caller vs callee-saved. We don't use $gp in assembly except in setjmp which is already appropriate for n32.
So, we need just few cleanups to make it work. Whether we want to continuously maintain this compatibility is another question. I'm going to commit the fixes

#10 lore raw
Quoted 6 lines · Vladimir 'φ-coder/phcoder' Serbinenko
Quoted 5 lines · Andrei Borzenkov

08.09.2015 20:11, Vladimir 'φ-coder/phcoder' Serbinenko пишет:

Quoted 4 lines · Mark H Weaver
Quoted 3 lines

Include -mabi=32 in CFLAGS_PLATFORM and CCASFLAGS_PLATFORM to compile code for the O32 ABI when targetting MIPS, since the MIPS assembly code in GRUB assumes this.

Quoted 6 lines
Quoted 5 lines
Quoted 2 lines

Could you be more precise where we assume this? Why not fix the assembly instead?

If I understand it correctly, this is not only about assembly - ABIs differ in sizes of types as well,

Only in obscure types long double and uint128_t. We use neither.

Correction: I was comparing o32 to n32. We still need to ensure that either o32 or n32 is used. It's easier to just ensure that o32 is used, so that we have less variability in the code but can be relaxed later if need be.

Quoted 3 lines

f) int grub_setjmp (grub_jmp_buf env) // grub_jmp_buf is an array, so
pointer
g) int grub_longjmp (grub_jmp_buf env, int val)

Correction: setjmp/longjmp are not adapted to n32 but we don't use them anyway. Probably it's time to delete the dead code after double checking that extras don't use it either.

#11 lore raw

10.10.2015 03:28, Vladimir 'φ-coder/phcoder' Serbinenko пишет:

Quoted 10 lines · Vladimir 'φ-coder/phcoder' Serbinenko
Quoted 9 lines · Andrei Borzenkov
Quoted 8 lines

08.09.2015 20:11, Vladimir 'φ-coder/phcoder' Serbinenko пишет:

Quoted 6 lines · Mark H Weaver
Quoted 3 lines

Include -mabi=32 in CFLAGS_PLATFORM and CCASFLAGS_PLATFORM to compile code for the O32 ABI when targetting MIPS, since the MIPS assembly code in GRUB assumes this.

Could you be more precise where we assume this? Why not fix the assembly instead?

Quoted 7 lines
Quoted 3 lines
Quoted 2 lines

If I understand it correctly, this is not only about assembly - ABIs differ in sizes of types as well,

Only in obscure types long double and uint128_t. We use neither.

Correction: I was comparing o32 to n32. We still need to ensure that either o32 or n32 is used. It's easier to just ensure that o32 is used, so that we have less variability in the code but can be relaxed later if need be.

I see that you committed my suggested patch but I find comments (and commit message) a bit misleading. While grub main code is fixed, the configure asm test not, and that was the first thing that failed.

Quoted 15 lines
Quoted 3 lines

f) int grub_setjmp (grub_jmp_buf env) // grub_jmp_buf is an array, so
pointer
g) int grub_longjmp (grub_jmp_buf env, int val)

Correction: setjmp/longjmp are not adapted to n32 but we don't use them anyway. Probably it's time to delete the dead code after double checking that extras don't use it either.

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

#12 lore raw
Quoted 13 lines · Andrei Borzenkov

10.10.2015 03:28, Vladimir 'φ-coder/phcoder' Serbinenko пишет:

Quoted 10 lines · Vladimir 'φ-coder/phcoder' Serbinenko
Quoted 9 lines · Andrei Borzenkov
Quoted 7 lines

08.09.2015 20:11, Vladimir 'φ-coder/phcoder' Serbinenko пишет:

Quoted 5 lines · Mark H Weaver
Quoted 3 lines

Include -mabi=32 in CFLAGS_PLATFORM and CCASFLAGS_PLATFORM to compile code for the O32 ABI when targetting MIPS, since the MIPS assembly

code

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line

in GRUB assumes this.

Could you be more precise where we assume this? Why not fix the

assembly

Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
Quoted 5 lines
Quoted 1 line

instead?

If I understand it correctly, this is not only about assembly - ABIs differ in sizes of types as well,

Only in obscure types long double and uint128_t. We use neither.

Quoted 7 lines
Quoted 4 lines

Correction: I was comparing o32 to n32. We still need to ensure that either o32 or n32 is used. It's easier to just ensure that o32 is used, so that we have less variability in the code but can be relaxed later if need be.

I see that you committed my suggested patch but I find comments (and

commit message) a bit misleading. While grub main code is fixed, the configure asm test not, and that was the first thing that failed.

Quoted 1 line

Can you please elaborate on how am test fails? The only failure I have seen was due to usage of $t4 and I replaced it with $t0

Quoted 22 lines
Quoted 11 lines
Quoted 3 lines

f) int grub_setjmp (grub_jmp_buf env) // grub_jmp_buf is an array, so
pointer
g) int grub_longjmp (grub_jmp_buf env, int val)

Correction: setjmp/longjmp are not adapted to n32 but we don't use them anyway. Probably it's time to delete the dead code after double checking that extras don't use it either.

Quoted 5 lines

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

#13 lore raw

14.10.2015 15:16, Vladimir 'phcoder' Serbinenko пишет:

Quoted 33 lines · Andrei Borzenkov
Quoted 13 lines

10.10.2015 03:28, Vladimir 'φ-coder/phcoder' Serbinenko пишет:

Quoted 10 lines · Vladimir 'φ-coder/phcoder' Serbinenko
Quoted 9 lines · Andrei Borzenkov
Quoted 7 lines

08.09.2015 20:11, Vladimir 'φ-coder/phcoder' Serbinenko пишет:

Quoted 5 lines · Mark H Weaver
Quoted 3 lines

Include -mabi=32 in CFLAGS_PLATFORM and CCASFLAGS_PLATFORM to compile code for the O32 ABI when targetting MIPS, since the MIPS assembly

code

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line

in GRUB assumes this.

Could you be more precise where we assume this? Why not fix the

assembly

Quoted 14 lines
Quoted 12 lines
Quoted 7 lines
Quoted 5 lines
Quoted 1 line

instead?

If I understand it correctly, this is not only about assembly - ABIs differ in sizes of types as well,

Only in obscure types long double and uint128_t. We use neither.

Correction: I was comparing o32 to n32. We still need to ensure that either o32 or n32 is used. It's easier to just ensure that o32 is used, so that we have less variability in the code but can be relaxed later if need be.

Quoted 6 lines
Quoted 1 line

I see that you committed my suggested patch but I find comments (and

commit message) a bit misleading. While grub main code is fixed, the configure asm test not, and that was the first thing that failed.

Quoted 1 line

Can you please elaborate on how am test fails? The only failure I have seen was due to usage of $t4 and I replaced it with $t0

Sorry, missed patch for asm-tests/mips.S

Quoted 30 lines
Quoted 18 lines
Quoted 11 lines
Quoted 3 lines

f) int grub_setjmp (grub_jmp_buf env) // grub_jmp_buf is an array, so
pointer
g) int grub_longjmp (grub_jmp_buf env, int val)

Correction: setjmp/longjmp are not adapted to n32 but we don't use them anyway. Probably it's time to delete the dead code after double checking that extras don't use it either.

Quoted 5 lines

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

Quoted 4 lines

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

#14 lore raw
In reply to Mark H Weaver

22.08.2015 21:04, Mark H Weaver пишет:

Quoted 45 lines
Quoted 11 lines · Andrei Borzenkov

19.08.2015 21:35, Mark H Weaver пишет:

Quoted 10 lines

Include -mabi=32 in CFLAGS_PLATFORM and CCASFLAGS_PLATFORM to compile code for the O32 ABI when targetting MIPS, since the MIPS assembly code in GRUB assumes this. This flag is also needed when compiling asm-tests/mips.S from configure, because GNU as rejects MIPS register names such as $t2 unless the O32 ABI is selected.

---
   conf/Makefile.common | 4 ++++
   configure.ac         | 7 +++++--
   2 files changed, 9 insertions(+), 2 deletions(-)
Quoted 15 lines

conf/Makefile.common endif · line 27

Quoted 13 lines
conf/Makefile.common +4 -0
index fcb8d2e..bd125da 100644
@@ -20,6 +20,10 @@ endif
   if COND_powerpc_ieee1275
     CFLAGS_PLATFORM += -mcpu=powerpc
   endif
+if COND_mips
+  CFLAGS_PLATFORM += -mabi=32
+  CCASFLAGS_PLATFORM = -mabi=32
+endif
 

Does it work with clang?

Based on the error message below, clang seems to accept and understand the -mabi=32 option, but the version of clang that we have in GNU Guix (which uses the N32 ABI on MIPS) seems to lack support for compiling for O32:

   mhw@librenote:~$ clang -mabi=32 mips.S
   error: unknown target CPU 'mips32r2'

However, it doesn't work without that option either:

   mhw@librenote:~$ clang mips.S
   mips.S: Assembler messages:
   mips.S:7: Error: invalid operands `ld $t2,0($t6)'
   mips.S:10: Error: invalid operands `addiu $t7,$s0,(b-a)'
   clang-3.6: error: assembler command failed with exit code 1 (use -v to see invocation)
Quoted 4 lines

This is the same failure that occurs with gcc when configured to use the N32 ABI by default. I also tried passing -fno-integrated-as in both cases above, but it made no difference.

Could you paste "clang -v" output for both cases? I believe I understand what's going on.

#15 lore raw
Quoted 2 lines · Andrei Borzenkov

Could you paste "clang -v" output for both cases? I believe I understand what's going on.

Okay, I've included it below. It might be relevant to mention that the MIPS port of GNU Guix is not a 'multilib' system: it includes support only for the N32 ABI. However, our gcc is still capable of generating freestanding code for the O32 ABI, as demonstrated by the fact that I've been successfully building and using GRUB on it.

Thanks,
Mark

--8<---------------cut here---------------start------------->8---

mhw@librenote:~$ clang -v -mabi=32 mips.S
clang version 3.6.0 (tags/RELEASE_360/final)
Target: mips64el-unknown-linux-gnu
Thread model: posix
Found candidate GCC installation: /gnu/store/1phn21k7w04nsc38zlzrslqcqivcn714-gcc-4.9.3-lib/lib/gcc/mips64el-unknown-linux-gnu/4.9.3
Selected GCC installation: /gnu/store/1phn21k7w04nsc38zlzrslqcqivcn714-gcc-4.9.3-lib/lib/gcc/mips64el-unknown-linux-gnu/4.9.3
Candidate multilib: .;
Selected multilib: .;
 "/gnu/store/hy0fp4z8ar362cnry5ifwmcrq2nqmjfc-clang-3.6.0/bin/clang-3.6" -cc1 -triple mips64el-unknown-linux-gnu -E -disable-free -disable-llvm-verifier -main-file-name mips.S -mrelocation-model static -mthread-model posix -mdisable-fp-elim -fmath-errno -no-integrated-as -mconstructor-aliases -fuse-init-array -target-cpu mips32r2 -target-feature -n64 -target-feature +o32 -target-abi o32 -mfloat-abi hard -v -dwarf-column-info -resource-dir /gnu/store/hy0fp4z8ar362cnry5ifwmcrq2nqmjfc-clang-3.6.0/bin/../lib/clang/3.6.0 -I/home/mhw/.guix-profile/include -internal-isystem /usr/local/include -internal-isystem /gnu/store/hy0fp4z8ar362cnry5ifwmcrq2nqmjfc-clang-3.6.0/bin/../lib/clang/3.6.0/include -internal-externc-isystem /gnu/store/cncig2c9n92ndz97pw0ply1jjc0xycmf-glibc-2.21/include -fno-dwarf-directory-asm -fdebug-compilation-dir /home/mhw -ferror-limit 19 -fmessage-length 0 -mstackrealign -fobjc-runtime=gcc -fdiagnostics-show-option -o /tmp/mips-a6494a.s -x assembler-with-cpp mips.S
error: unknown target CPU 'mips32r2'
mhw@librenote:~$ clang -v mips.S
clang version 3.6.0 (tags/RELEASE_360/final)
Target: mips64el-unknown-linux-gnu
Thread model: posix
Found candidate GCC installation: /gnu/store/1phn21k7w04nsc38zlzrslqcqivcn714-gcc-4.9.3-lib/lib/gcc/mips64el-unknown-linux-gnu/4.9.3
Selected GCC installation: /gnu/store/1phn21k7w04nsc38zlzrslqcqivcn714-gcc-4.9.3-lib/lib/gcc/mips64el-unknown-linux-gnu/4.9.3
Candidate multilib: .;
Selected multilib: .;
 "/gnu/store/hy0fp4z8ar362cnry5ifwmcrq2nqmjfc-clang-3.6.0/bin/clang-3.6" -cc1 -triple mips64el-unknown-linux-gnu -E -disable-free -disable-llvm-verifier -main-file-name mips.S -mrelocation-model static -mthread-model posix -mdisable-fp-elim -fmath-errno -no-integrated-as -mconstructor-aliases -fuse-init-array -target-cpu mips64r2 -target-feature -o32 -target-feature +n64 -target-abi n64 -mfloat-abi hard -v -dwarf-column-info -resource-dir /gnu/store/hy0fp4z8ar362cnry5ifwmcrq2nqmjfc-clang-3.6.0/bin/../lib/clang/3.6.0 -I/home/mhw/.guix-profile/include -internal-isystem /usr/local/include -internal-isystem /gnu/store/hy0fp4z8ar362cnry5ifwmcrq2nqmjfc-clang-3.6.0/bin/../lib/clang/3.6.0/include -internal-externc-isystem /gnu/store/cncig2c9n92ndz97pw0ply1jjc0xycmf-glibc-2.21/include -fno-dwarf-directory-asm -fdebug-compilation-dir /home/mhw -ferror-limit 19 -fmessage-length 0 -mstackrealign -fobjc-runtime=gcc -fdiagnostics-show-option -o /tmp/mips-aee666.s -x assembler-with-cpp mips.S
clang -cc1 version 3.6.0 based upon LLVM 3.6.0 default target mips64el-unknown-linux-gnu
#include "..." search starts here:
#include <...> search starts here:
 /home/mhw/.guix-profile/include
 /usr/local/include
 /gnu/store/hy0fp4z8ar362cnry5ifwmcrq2nqmjfc-clang-3.6.0/bin/../lib/clang/3.6.0/include
 /gnu/store/cncig2c9n92ndz97pw0ply1jjc0xycmf-glibc-2.21/include
End of search list.
 "/home/mhw/.guix-profile/bin/as" -march mips64r2 -mabi 64 -mno-shared -KPIC -EL -o /tmp/mips-e5abd7.o /tmp/mips-aee666.s
mips.S: Assembler messages:
mips.S:7: Error: invalid operands `ld $t2,0($t6)'
mips.S:10: Error: invalid operands `addiu $t7,$s0,(b-a)'
clang-3.6: error: assembler command failed with exit code 1 (use -v to see invocation)
mhw@librenote:~$
--8<---------------cut here---------------end--------------->8---
#16 lore raw

24.08.2015 10:57, Mark H Weaver пишет:

Quoted 10 lines
Quoted 2 lines · Andrei Borzenkov

Could you paste "clang -v" output for both cases? I believe I understand what's going on.

Okay, I've included it below. It might be relevant to mention that the MIPS port of GNU Guix is not a 'multilib' system: it includes support only for the N32 ABI. However, our gcc is still capable of generating freestanding code for the O32 ABI, as demonstrated by the fact that I've been successfully building and using GRUB on it.

Quoted 7 lines

Thanks,
Mark

--8<---------------cut here---------------start------------->8---

mhw@librenote:~$ clang -v -mabi=32 mips.S
clang version 3.6.0 (tags/RELEASE_360/final)
Target: mips64el-unknown-linux-gnu

Yes, as expected. clang treats mips and mips64 as two different targets so o32 is invalid for mips64.

Could you test attached patch for both gcc and clang? Use

configure TARGET_CC=clang

From: Andrei Borzenkov <[email protected]>
Subject: [PATCH] configure: try to force o32 ABI on MIPS

GRUB expects o32 ABI, in particular used assembly is valid only in this mode. Some systems (e.g. GNU Guix) default to using newer n64 or n32 ABI. Try to find suitable options to force o32.

For GCC this is simply -mabi=32. While clang supports this option as well, o32 ABI is valid for MIPS target and n32/64 ABI are valid for MIPS64 target only, so use "-target mips -mabi=32".

---
 configure.ac | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)
configure.ac +29 -0
index c864311..d857e47 100644
@@ -597,6 +597,35 @@ int main (void);
   TARGET_LDFLAGS="$TARGET_LDFLAGS $grub_cv_target_cc_big_endian"
 fi
 
+if test "x$target_cpu" = xmips || test "x$target_cpu" = xmipsel ; then
+  AC_CACHE_CHECK([for options to force MIPS o32 ABI], grub_cv_target_cc_mips_o32_abi, [
+    grub_cv_target_cc_mips_o32_abi=no
+    for arg in "" "-mabi=32" "-target mips -mabi=32"
+      if test x"$grub_cv_target_cc_mips_o32_abi" != xno ; then
+        break
+      fi
+      CFLAGS="$TARGET_CFLAGS $arg -Werror"
+      AC_LINK_IFELSE([AC_LANG_PROGRAM([[
+#if !defined(_ABIO32) || !defined(_MIPS_SIM) || (_MIPS_SIM != _ABIO32)
+#error not o32 ABI
+#endif
+asm (".globl start; start:");
+void __main (void);
+void __main (void) {}
+int main (void);
+]], [[]])],
+		        [grub_cv_target_cc_mips_o32_abi="$arg"], [])
+    done
+  ])
+
+  if test x"$grub_cv_target_cc_mips_o32_abi" = xno ; then
+    AC_MSG_ERROR([could not force MIPS o32 ABI])
+  fi
+
+  TARGET_CFLAGS="$TARGET_CFLAGS $grub_cv_target_cc_mips_o32_abi"
+  TARGET_CCASFLAGS="$TARGET_CCASFLAGS $grub_cv_target_cc_mips_o32_abi"
+fi
+
 AC_CACHE_CHECK([for options to compile assembly], [grub_cv_cc_target_asm_compile], [
 test_program=
 case "x$target_cpu-$platform" in
Signature · 1 line
tg: (ba218c1..) u/mips-o32 (depends on: master)
#17 lore raw

24.08.2015 11:12, Andrei Borzenkov пишет:

Quoted 19 lines

24.08.2015 10:57, Mark H Weaver пишет:

Quoted 10 lines
Quoted 2 lines · Andrei Borzenkov

Could you paste "clang -v" output for both cases? I believe I understand what's going on.

Okay, I've included it below. It might be relevant to mention that the MIPS port of GNU Guix is not a 'multilib' system: it includes support only for the N32 ABI. However, our gcc is still capable of generating freestanding code for the O32 ABI, as demonstrated by the fact that I've been successfully building and using GRUB on it.

Quoted 7 lines

Thanks,
Mark

--8<---------------cut here---------------start------------->8---

mhw@librenote:~$ clang -v -mabi=32 mips.S
clang version 3.6.0 (tags/RELEASE_360/final)
Target: mips64el-unknown-linux-gnu
Quoted 6 lines

Yes, as expected. clang treats mips and mips64 as two different targets so o32 is invalid for mips64.

Could you test attached patch for both gcc and clang? Use

configure TARGET_CC=clang

Sorry, was broken, fixed version attached.

From: Andrei Borzenkov <[email protected]>
Subject: [PATCH] configure: try to force o32 ABI on MIPS

GRUB expects o32 ABI, in particular used assembly is valid only in this mode. Some systems (e.g. GNU Guix) default to using newer n64 or n32 ABI. Try to find suitable options to force o32.

For GCC this is simply -mabi=32. While clang supports this option as well, o32 ABI is valid for MIPS target and n32/64 ABI are valid for MIPS64 target only, so use "-target mips -mabi=32".

---
 configure.ac | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)
configure.ac +29 -0
index c864311..2e73b3f 100644
@@ -597,6 +597,35 @@ int main (void);
   TARGET_LDFLAGS="$TARGET_LDFLAGS $grub_cv_target_cc_big_endian"
 fi
 
+if test "x$target_cpu" = xmips || test "x$target_cpu" = xmipsel ; then
+  AC_CACHE_CHECK([for options to force MIPS o32 ABI], grub_cv_target_cc_mips_o32_abi, [
+    grub_cv_target_cc_mips_o32_abi=no
+    for arg in "" "-mabi=32" "-target mips -mabi=32" ; do
+      if test x"$grub_cv_target_cc_mips_o32_abi" != xno ; then
+        break
+      fi
+      CFLAGS="$TARGET_CFLAGS $arg -Werror"
+      AC_LINK_IFELSE([AC_LANG_PROGRAM([[
+#if !defined(_ABIO32) || !defined(_MIPS_SIM) || (_MIPS_SIM != _ABIO32)
+#error not o32 ABI
+#endif
+asm (".globl start; start:");
+void __main (void);
+void __main (void) {}
+int main (void);
+]], [[]])],
+		        [grub_cv_target_cc_mips_o32_abi="$arg"], [])
+    done
+  ])
+
+  if test x"$grub_cv_target_cc_mips_o32_abi" = xno ; then
+    AC_MSG_ERROR([could not force MIPS o32 ABI])
+  fi
+
+  TARGET_CFLAGS="$TARGET_CFLAGS $grub_cv_target_cc_mips_o32_abi"
+  TARGET_CCASFLAGS="$TARGET_CCASFLAGS $grub_cv_target_cc_mips_o32_abi"
+fi
+
 AC_CACHE_CHECK([for options to compile assembly], [grub_cv_cc_target_asm_compile], [
 test_program=
 case "x$target_cpu-$platform" in
Signature · 1 line
tg: (ba218c1..) u/mips-o32 (depends on: master)
#18 lore raw
Quoted 6 lines · Andrei Borzenkov

24.08.2015 11:12, Andrei Borzenkov пишет:

Quoted 3 lines

Could you test attached patch for both gcc and clang? Use

configure TARGET_CC=clang

Sorry, was broken, fixed version attached.

Your patch works for me with gcc, although config.log shows this warning when building the test program in your new code with the correct flags for gcc (-mabi=32):

ld: warning: cannot find entry symbol __start; defaulting to 00000000004000d0

Here's the relevant excerpt:

--8<---------------cut here---------------start------------->8---
configure:24700: gcc -o conftest -Os -Wall -W -Wshadow -Wpointer-arith -Wundef -Wchar-subscripts -Wcomment -Wdeprecated-declarations -Wdisabled-optimization -Wdiv-by-zero -Wfloat-equal -Wformat-extra-args -Wformat-security -Wformat-y2k -Wimplicit -Wimplicit-function-declaration -Wimplicit-int -Wmain -Wmissing-braces -Wmissing-format-attribute -Wmultichar -Wparentheses -Wreturn-type -Wsequence-point -Wshadow -Wsign-compare -Wswitch -Wtrigraphs -Wunknown-pragmas -Wunused -Wunused-function -Wunused-label -Wunused-parameter -Wunused-value -Wunused-variable -Wwrite-strings -Wnested-externs -Wstrict-prototypes -g -Wredundant-decls -Wmissing-prototypes -Wmissing-declarations -Wcast-align -Wextra -Wattributes -Wendif-labels -Winit-self -Wint-to-pointer-cast -Winvalid-pch -Wmissing-field-initializers -Wnonnull -Woverflow -Wvla -Wpointer-to-int-cast -Wstrict-aliasing -Wvariadic-macros -Wvolatile-register-var -Wpointer-sign -Wmissing-include-dirs -Wmissing-prototypes -Wmissing-declarations -Wformat=2 -mabi=32 -Werror -Wall -W -DGRUB_CPU_MIPSEL=1 -DGRUB_MACHINE_MIPS_LOONGSON=1 -DGRUB_MACHINE=MIPS_LOONGSON -nostdlib -static conftest.c >&5
ld: warning: cannot find entry symbol __start; defaulting to 00000000004000d0
configure:24700: $? = 0
configure:24708: result: -mabi=32
--8<---------------cut here---------------end--------------->8---

I also worry that linking an O32 executable might be fragile on a pure non-multilib N32 system such as GNU Guix, where we lack even the gcc runtime library (libgcc_s) for O32. For now it seems to work, but I wonder if it might be more robust to do the test compilation with -c and -freestanding?

clang: with TARGET_CC=clang, it fails for me. Here are the
relevant excerpts from config.log:

--8<---------------cut here---------------start------------->8---
configure:24700: /gnu/store/yjmchvkz0kmz4s1sxc0p89imfik68qzg-clang-3.6.0/bin/clang -o conftest -Os -Wall -W -Wshadow -Wpointer-arith -Wundef -Wchar-subscripts -Wcomment -Wdeprecated-declarations -Wdisabled-optimization -Wdiv-by-zero -Wfloat-equal -Wformat-extra-args -Wformat-security -Wformat-y2k -Wimplicit -Wimplicit-function-declaration -Wimplicit-int -Wmain -Wmissing-braces -Wmissing-format-attribute -Wmultichar -Wparentheses -Wreturn-type -Wsequence-point -Wshadow -Wsign-compare -Wswitch -Wtrigraphs -Wunknown-pragmas -Wunused -Wunused-function -Wunused-label -Wunused-parameter -Wunused-value -Wunused-variable -Wwrite-strings -Wnested-externs -Wstrict-prototypes -g -Wredundant-decls -Wmissing-prototypes -Wmissing-declarations -Wcast-align -Wextra -Wattributes -Wendif-labels -Winit-self -Wint-to-pointer-cast -Winvalid-pch -Wmissing-field-initializers -Wnonnull -Woverflow -Wvla -Wpointer-to-int-cast -Wstrict-aliasing -Wvariadic-macros -Wvolatile-register-var -Wpointer-sign -Wmissing-include-dirs -Wmissing-prototypes -Wmissing-declarations -Wformat=2 -mabi=32 -Werror -Wall -W -DGRUB_CPU_MIPSEL=1 -DGRUB_MACHINE_MIPS_LOONGSON=1 -DGRUB_MACHINE=MIPS_LOONGSON -nostdlib -static conftest.c >&5
error: unknown target CPU 'mips32r2'
configure:24700: $? = 1
configure: failed program was:
[...]
configure:24700: /gnu/store/yjmchvkz0kmz4s1sxc0p89imfik68qzg-clang-3.6.0/bin/clang -o conftest -Os -Wall -W -Wshadow -Wpointer-arith -Wundef -Wchar-subscripts -Wcomment -Wdeprecated-declarations -Wdisabled-optimization -Wdiv-by-zero -Wfloat-equal -Wformat-extra-args -Wformat-security -Wformat-y2k -Wimplicit -Wimplicit-function-declaration -Wimplicit-int -Wmain -Wmissing-braces -Wmissing-format-attribute -Wmultichar -Wparentheses -Wreturn-type -Wsequence-point -Wshadow -Wsign-compare -Wswitch -Wtrigraphs -Wunknown-pragmas -Wunused -Wunused-function -Wunused-label -Wunused-parameter -Wunused-value -Wunused-variable -Wwrite-strings -Wnested-externs -Wstrict-prototypes -g -Wredundant-decls -Wmissing-prototypes -Wmissing-declarations -Wcast-align -Wextra -Wattributes -Wendif-labels -Winit-self -Wint-to-pointer-cast -Winvalid-pch -Wmissing-field-initializers -Wnonnull -Woverflow -Wvla -Wpointer-to-int-cast -Wstrict-aliasing -Wvariadic-macros -Wvolatile-register-var -Wpointer-sign -Wmissing-include-dirs -Wmissing-prototypes -Wmissing-declarations -Wformat=2 -target mips -mabi=32 -Werror -Wall -W -DGRUB_CPU_MIPSEL=1 -DGRUB_MACHINE_MIPS_LOONGSON=1 -DGRUB_MACHINE=MIPS_LOONGSON -nostdlib -static conftest.c >&5
ld: /tmp/conftest-efc530.o: compiled for a big endian system and target is little endian
ld: /tmp/conftest-efc530.o: endianness incompatible with that of the selected emulation
ld: failed to merge target specific data of file /tmp/conftest-efc530.o
ld: warning: cannot find entry symbol __start; defaulting to 00000000004000f0
collect2: error: ld returned 1 exit status
clang-3.6: error: linker (via gcc) command failed with exit code 1 (use -v to see invocation)
configure:24700: $? = 1
configure: failed program was:
[...]
--8<---------------cut here---------------end--------------->8---

I guess that "-target mips" is interpreted as requesting big endian.

I suspect that simply passing -mabi=32 is the right thing to do for clang as well, but that the clang we have built in GNU Guix doesn't include support for targetting the O32 ABI. It's possible that the only way to target O32 from a non-multilib N32 system using clang is to do cross-compilation. Or perhaps we need to explicitly request support for 'mips32r2' when building clang.

Mark

#19 lore raw

25.08.2015 21:18, Mark H Weaver пишет:

Quoted 7 lines
Quoted 5 lines · Andrei Borzenkov

24.08.2015 11:12, Andrei Borzenkov пишет:

Quoted 3 lines

Could you test attached patch for both gcc and clang? Use

configure TARGET_CC=clang

Quoted 8 lines
Quoted 1 line

Sorry, was broken, fixed version attached.

Your patch works for me with gcc, although config.log shows this warning when building the test program in your new code with the correct flags for gcc (-mabi=32):

ld: warning: cannot find entry symbol __start; defaulting to 00000000004000d0

Well, I just reused existing checks in this case; we worry about it later.

Quoted 4 lines

Here's the relevant excerpt:

--8<---------------cut here---------------start------------->8---
configure:24700: gcc -o conftest -Os -Wall -W -Wshadow -Wpointer-arith -Wundef -Wchar-subscripts -Wcomment -Wdeprecated-declarations -Wdisabled-optimization -Wdiv-by-zero -Wfloat-equal -Wformat-extra-args -Wformat-security -Wformat-y2k -Wimplicit -Wimplicit-function-declaration -Wimplicit-int -Wmain -Wmissing-braces -Wmissing-format-attribute -Wmultichar -Wparentheses -Wreturn-type -Wsequence-point -Wshadow -Wsign-compare -Wswitch -Wtrigraphs -Wunknown-pragmas -Wunused -Wunused-function -Wunused-label -Wunused-parameter -Wunused-value -Wunused-variable -Wwrite-strings -Wnested-externs -Wstrict-prototypes -g -Wredundant-decls -Wmissing-prototypes -Wmissing-declarations -Wcast-align -Wextra -Wattributes -Wendif-labels -Winit-self -Wint-to-pointer-cast -Winvalid-pch -Wmissing-field-initializers -Wnonnull -Woverflow -Wvla -Wpointer-to-int-cast -Wstrict-aliasing -Wvariadic-macros -Wvolatile-register-var -Wpointer-sign -Wmissing-include-dirs -Wmissing-prototypes -Wmissing-declarations

-Wformat=2 -mabi=32 -Werror -Wall -W -DGRUB_CPU_MIPSEL=1 -DGRUB_MACHINE_MIPS_LOONGSON=1 -DGRUB_MACHINE=MIPS_LOONGSON -nostdlib -static conftest.c >&5

Quoted 11 lines

ld: warning: cannot find entry symbol __start; defaulting to 00000000004000d0 configure:24700: $? = 0
configure:24708: result: -mabi=32
--8<---------------cut here---------------end--------------->8---

I also worry that linking an O32 executable might be fragile on a pure non-multilib N32 system such as GNU Guix, where we lack even the gcc runtime library (libgcc_s) for O32. For now it seems to work, but I wonder if it might be more robust to do the test compilation with -c and -freestanding?

It is using -nostdlib; is it not enough?

Quoted 5 lines

clang: with TARGET_CC=clang, it fails for me. Here are the
relevant excerpts from config.log:

--8<---------------cut here---------------start------------->8---
configure:24700: /gnu/store/yjmchvkz0kmz4s1sxc0p89imfik68qzg-clang-3.6.0/bin/clang -o conftest -Os -Wall -W -Wshadow -Wpointer-arith -Wundef -Wchar-subscripts -Wcomment -Wdeprecated-declarations -Wdisabled-optimization -Wdiv-by-zero -Wfloat-equal -Wformat-extra-args -Wformat-security -Wformat-y2k -Wimplicit -Wimplicit-function-declaration -Wimplicit-int -Wmain -Wmissing-braces -Wmissing-format-attribute -Wmultichar -Wparentheses -Wreturn-type -Wsequence-point -Wshadow -Wsign-compare -Wswitch -Wtrigraphs -Wunknown-pragmas -Wunused -Wunused-function -Wunused-label -Wunused-parameter -Wunused-value -Wunused-variable -Wwrite-strings -Wnested-externs -Wstrict-prototypes -g -Wredundant-decls -Wmissing-prototypes -Wmissing-declarations -Wcast-align -Wextra -Wattributes -Wendif-labels -Winit-self -Wint-to-pointer-cast -Winvalid-pch -Wmissing-field-initializers -Wnonnull -Woverflow -Wvla -Wpointer-to-int-cast -Wstrict-aliasing -Wvariadic-macros -Wvolatile-register-var -Wpointer-sign -Wmis

sing-include-dirs -Wmissing-prototypes -Wmissing-declarations -Wformat=2 -mabi=32 -Werror -Wall -W -DGRUB_CPU_MIPSEL=1 -DGRUB_MACHINE_MIPS_LOONGSON=1 -DGRUB_MACHINE=MIPS_LOONGSON -nostdlib -static conftest.c >&5

Quoted 5 lines

error: unknown target CPU 'mips32r2'
configure:24700: $? = 1
configure: failed program was:
[...]
configure:24700: /gnu/store/yjmchvkz0kmz4s1sxc0p89imfik68qzg-clang-3.6.0/bin/clang -o conftest -Os -Wall -W -Wshadow -Wpointer-arith -Wundef -Wchar-subscripts -Wcomment -Wdeprecated-declarations -Wdisabled-optimization -Wdiv-by-zero -Wfloat-equal -Wformat-extra-args -Wformat-security -Wformat-y2k -Wimplicit -Wimplicit-function-declaration -Wimplicit-int -Wmain -Wmissing-braces -Wmissing-format-attribute -Wmultichar -Wparentheses -Wreturn-type -Wsequence-point -Wshadow -Wsign-compare -Wswitch -Wtrigraphs -Wunknown-pragmas -Wunused -Wunused-function -Wunused-label -Wunused-parameter -Wunused-value -Wunused-variable -Wwrite-strings -Wnested-externs -Wstrict-prototypes -g -Wredundant-decls -Wmissing-prototypes -Wmissing-declarations -Wcast-align -Wextra -Wattributes -Wendif-labels -Winit-self -Wint-to-pointer-cast -Winvalid-pch -Wmissing-field-initializers -Wnonnull -Woverflow -Wvla -Wpointer-to-int-cast -Wstrict-aliasing -Wvariadic-macros -Wvolatile-register-var -Wpointer-sign -Wmis

sing-include-dirs -Wmissing-prototypes -Wmissing-declarations -Wformat=2 -target mips -mabi=32 -Werror -Wall -W -DGRUB_CPU_MIPSEL=1 -DGRUB_MACHINE_MIPS_LOONGSON=1 -DGRUB_MACHINE=MIPS_LOONGSON -nostdlib -static conftest.c >&5

Quoted 2 lines

ld: /tmp/conftest-efc530.o: compiled for a big endian system and target is little endian
ld: /tmp/conftest-efc530.o: endianness incompatible with that of the selected emulation

This is the same problem we had on powerpc. Your binutils are set to use little-endian output by default; we need to explicitly enable either big or little endian in this case as well. Could you try attached patch to verify? Although I guess we need to unify endianness checks for all supported platforms.

Quoted 9 lines

ld: failed to merge target specific data of file /tmp/conftest-efc530.o
ld: warning: cannot find entry symbol __start; defaulting to 00000000004000f0
collect2: error: ld returned 1 exit status
clang-3.6: error: linker (via gcc) command failed with exit code 1 (use -v to see invocation) configure:24700: $? = 1
configure: failed program was:
[...]
--8<---------------cut here---------------end--------------->8---

Quoted 5 lines

I guess that "-target mips" is interpreted as requesting big endian.

I suspect that simply passing -mabi=32 is the right thing to do for clang as well, but that the clang we have built in GNU Guix doesn't include support for targetting the O32 ABI.

As far as I can tell, clang can enable full platform (i.e. MIPS) but not platform variant. So if clang can compile for MIPS at all it should be able to produce both versions. The problem is, endianness in clang is property of target; and what makes it even worse, options that are passed to backend toolchains are also target dependent.

Quoted 7 lines

It's possible that the only
way to target O32 from a non-multilib N32 system using clang is to do cross-compilation. Or perhaps we need to explicitly request support for 'mips32r2' when building clang.

Mark

From: Andrei Borzenkov <[email protected]>
Subject: [PATCH] configure: try to force o32 ABI on MIPS

GRUB expects o32 ABI, in particular used assembly is valid only in this mode. Some systems (e.g. GNU Guix) default to using newer n64 or n32 ABI. Try to find suitable options to force o32.

For GCC this is simply -mabi=32. While clang supports this option as well, o32 ABI is valid for MIPS target and n32/64 ABI are valid for MIPS64 target only, so use "-target mips/mipsel -mabi=32".

---
 configure.ac | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)
configure.ac +29 -0
index c864311..f3c9b90 100644
@@ -597,6 +597,35 @@ int main (void);
   TARGET_LDFLAGS="$TARGET_LDFLAGS $grub_cv_target_cc_big_endian"
 fi
 
+if test "x$target_cpu" = xmips || test "x$target_cpu" = xmipsel ; then
+  AC_CACHE_CHECK([for options to force MIPS o32 ABI], grub_cv_target_cc_mips_o32_abi, [
+    grub_cv_target_cc_mips_o32_abi=no
+    for arg in "" "-mabi=32" "-target $target_cpu -mabi=32" ; do
+      if test x"$grub_cv_target_cc_mips_o32_abi" != xno ; then
+        break
+      fi
+      CFLAGS="$TARGET_CFLAGS $arg -Werror"
+      AC_LINK_IFELSE([AC_LANG_PROGRAM([[
+#if !defined(_ABIO32) || !defined(_MIPS_SIM) || (_MIPS_SIM != _ABIO32)
+#error not o32 ABI
+#endif
+asm (".globl start; start:");
+void __main (void);
+void __main (void) {}
+int main (void);
+]], [[]])],
+		        [grub_cv_target_cc_mips_o32_abi="$arg"], [])
+    done
+  ])
+
+  if test x"$grub_cv_target_cc_mips_o32_abi" = xno ; then
+    AC_MSG_ERROR([could not force MIPS o32 ABI])
+  fi
+
+  TARGET_CFLAGS="$TARGET_CFLAGS $grub_cv_target_cc_mips_o32_abi"
+  TARGET_CCASFLAGS="$TARGET_CCASFLAGS $grub_cv_target_cc_mips_o32_abi"
+fi
+
 AC_CACHE_CHECK([for options to compile assembly], [grub_cv_cc_target_asm_compile], [
 test_program=
 case "x$target_cpu-$platform" in
Signature · 1 line
tg: (8e3d2c8..) u/mips-o32 (depends on: master)
#20 lore raw
Quoted 7 lines · Andrei Borzenkov
Quoted 2 lines

ld: /tmp/conftest-efc530.o: compiled for a big endian system and target is little endian
ld: /tmp/conftest-efc530.o: endianness incompatible with that of the selected emulation

This is the same problem we had on powerpc. Your binutils are set to use little-endian output by default; we need to explicitly enable either big or little endian in this case as well. Could you try attached patch to verify?

I'm glad to report that with your new patch, GRUB successfully builds on GuixSD mips64el with TARGET_CC=clang. I haven't yet tried booting it though.

Quoted 8 lines
Quoted 6 lines

Your patch works for me with gcc, although config.log shows this warning when building the test program in your new code with the correct flags for gcc (-mabi=32):

ld: warning: cannot find entry symbol __start; defaulting to 00000000004000d0

Well, I just reused existing checks in this case; we worry about it later.

Okay. I guess the name of the start symbol depends on the platform and linker. E.g. boot/mips/loongson/fwstart.S has this:

--8<---------------cut here---------------start------------->8---
.global start,_start,__start
start:
_start:
__start:
--8<---------------cut here---------------end--------------->8---

Other platforms have only '_start', or both 'start' and '_start'.

Quoted 8 lines
Quoted 6 lines

I also worry that linking an O32 executable might be fragile on a pure non-multilib N32 system such as GNU Guix, where we lack even the gcc runtime library (libgcc_s) for O32. For now it seems to work, but I wonder if it might be more robust to do the test compilation with -c and -freestanding?

It is using -nostdlib; is it not enough?

The warning above makes me doubt the portability and future-proofness of the link step of this test. This problem could be avoided entirely by omitting the link step. The link step serves no purpose in this test, and is a potential source of portability problems.

Having said that, if you prefer to keep the link step, I guess it will probably be okay in practice to define 'start', '_start', and '__start' as above. Do as you think best.

Thanks for you help.

Mark

#21 lore raw

Hi Andrei,

Here's a patch on top of yours that omits the link step from the new autoconf test. This eliminates the warnings I encountered before:

configure.ac +1 -5
index f3c9b90..cd9fa8d 100644
@@ -605,14 +605,10 @@ if test "x$target_cpu" = xmips || test "x$target_cpu" = xmipsel ; then
         break
       fi
       CFLAGS="$TARGET_CFLAGS $arg -Werror"
-      AC_LINK_IFELSE([AC_LANG_PROGRAM([[
+      AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
 #if !defined(_ABIO32) || !defined(_MIPS_SIM) || (_MIPS_SIM != _ABIO32)
 #error not o32 ABI
 #endif
-asm (".globl start; start:");
-void __main (void);
-void __main (void) {}
-int main (void);
 ]], [[]])],
 		        [grub_cv_target_cc_mips_o32_abi="$arg"], [])
     done

Here's an updated version of your commit, incorporating the above patch:

From 8adcca69d3d9aacd20010a450aa20083a834392b Mon Sep 17 00:00:00 2001
From: Andrei Borzenkov <[email protected]>
Date: Fri, 11 Sep 2015 11:28:49 -0400
Subject: [PATCH] configure: try to force o32 ABI on MIPS

GRUB expects o32 ABI, in particular used assembly is valid only in this mode. Some systems (e.g. GNU Guix) default to using newer n64 or n32 ABI. Try to find suitable options to force o32.

For GCC this is simply -mabi=32. While clang supports this option as well, o32 ABI is valid for MIPS target and n32/64 ABI are valid for MIPS64 target only, so use "-target mips/mipsel -mabi=32".

---
 configure.ac | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)
configure.ac +25 -0
index c864311..cd9fa8d 100644
@@ -597,6 +597,31 @@ int main (void);
   TARGET_LDFLAGS="$TARGET_LDFLAGS $grub_cv_target_cc_big_endian"
 fi
 
+if test "x$target_cpu" = xmips || test "x$target_cpu" = xmipsel ; then
+  AC_CACHE_CHECK([for options to force MIPS o32 ABI], grub_cv_target_cc_mips_o32_abi, [
+    grub_cv_target_cc_mips_o32_abi=no
+    for arg in "" "-mabi=32" "-target $target_cpu -mabi=32" ; do
+      if test x"$grub_cv_target_cc_mips_o32_abi" != xno ; then
+        break
+      fi
+      CFLAGS="$TARGET_CFLAGS $arg -Werror"
+      AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+#if !defined(_ABIO32) || !defined(_MIPS_SIM) || (_MIPS_SIM != _ABIO32)
+#error not o32 ABI
+#endif
+]], [[]])],
+		        [grub_cv_target_cc_mips_o32_abi="$arg"], [])
+    done
+  ])
+
+  if test x"$grub_cv_target_cc_mips_o32_abi" = xno ; then
+    AC_MSG_ERROR([could not force MIPS o32 ABI])
+  fi
+
+  TARGET_CFLAGS="$TARGET_CFLAGS $grub_cv_target_cc_mips_o32_abi"
+  TARGET_CCASFLAGS="$TARGET_CCASFLAGS $grub_cv_target_cc_mips_o32_abi"
+fi
+
 AC_CACHE_CHECK([for options to compile assembly], [grub_cv_cc_target_asm_compile], [
 test_program=
 case "x$target_cpu-$platform" in
Signature · 1 line
2.5.0

I tested this on MIPS with GCC 5.2.0 and clang 3.6.0. It works the same as before, but the warnings are gone.

What do you think?

Mark

#22 lore raw
In reply to Mark H Weaver

13.09.2015 05:41, Mark H Weaver пишет:

Quoted 5 lines
Quoted 3 lines · Andrei Borzenkov
Quoted 2 lines

ld: /tmp/conftest-efc530.o: compiled for a big endian system and target is little endian
ld: /tmp/conftest-efc530.o: endianness incompatible with that of the selected emulation

Quoted 9 lines
Quoted 4 lines

This is the same problem we had on powerpc. Your binutils are set to use little-endian output by default; we need to explicitly enable either big or little endian in this case as well. Could you try attached patch to verify?

I'm glad to report that with your new patch, GRUB successfully builds on GuixSD mips64el with TARGET_CC=clang. I haven't yet tried booting it though.

Did you have chance to test whether compiled grub actually work?

Quoted 28 lines
Quoted 8 lines
Quoted 6 lines

Your patch works for me with gcc, although config.log shows this warning when building the test program in your new code with the correct flags for gcc (-mabi=32):

    ld: warning: cannot find entry symbol __start; defaulting to 00000000004000d0

Well, I just reused existing checks in this case; we worry about it later.

Okay. I guess the name of the start symbol depends on the platform and linker. E.g. boot/mips/loongson/fwstart.S has this:

--8<---------------cut here---------------start------------->8---
.global start,_start,__start
start:
_start:
__start:
--8<---------------cut here---------------end--------------->8---

Other platforms have only '_start', or both 'start' and '_start'.

Quoted 7 lines
Quoted 6 lines

I also worry that linking an O32 executable might be fragile on a pure non-multilib N32 system such as GNU Guix, where we lack even the gcc runtime library (libgcc_s) for O32. For now it seems to work, but I wonder if it might be more robust to do the test compilation with -c and -freestanding?

Quoted 7 lines
Quoted 1 line

It is using -nostdlib; is it not enough?

The warning above makes me doubt the portability and future-proofness of the link step of this test. This problem could be avoided entirely by omitting the link step. The link step serves no purpose in this test, and is a potential source of portability problems.

This step helped us to catch endianness mismatch; we want to ensure in this case that full toolchain works to produce final binary.

Quoted 4 lines

Having said that, if you prefer to keep the link step, I guess it will probably be okay in practice to define 'start', '_start', and '__start' as above. Do as you think best.

Please test two attached patches. They separate o32 test from endianness test. I compile-tested them using cross-binutils for mips and powerpc64le to compile for mipsel and powerpc. The first patch also adds additional _start and __start symbols to endianness tests to avoid compiler warnings.

I am interested in both native and cross compilation - i.e. please test for both --target=mipsel and --target=mips both with gcc and clang. config.log from all runs would be interesting even for successful cases.

From ca80d768a43685e3e67fe9092dc10d9c574ee596 Mon Sep 17 00:00:00 2001
From: Andrei Borzenkov <[email protected]>
Date: Sun, 13 Sep 2015 16:51:13 +0300
Subject: [PATCH 1/2] configure: try to find options to force endian on MIPS

---
 configure.ac | 43 ++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 40 insertions(+), 3 deletions(-)
configure.ac +40 -3
index c864311..4760fe8 100644
@@ -562,11 +562,11 @@ AC_COMPILE_IFELSE(
 ]])],
 [grub_cv_cc_target_clang=no], [grub_cv_cc_target_clang=yes])])
 
-if test x$target_cpu = xpowerpc; then
+if test x$target_cpu = xpowerpc -o x$target_cpu = xmips; then
   AC_CACHE_CHECK([for options to get big-endian compilation], grub_cv_target_cc_big_endian, [
     grub_cv_target_cc_big_endian=no
-    for cand in "-target powerpc -Wl,-EB" "-target powerpc" \
-		"-target powerpc-linux-gnu -Wl,-EB" "-target powerpc-linux-gnu" \
+    for cand in "-target $target_cpu -Wl,-EB" "-target $target_cpu" \
+		"-target $target_cpu-linux-gnu -Wl,-EB" "-target $target_cpu-linux-gnu" \
 		"-mbig-endian"; do
       if test x"$grub_cv_target_cc_big_endian" != xno ; then
         break
@@ -577,6 +577,8 @@ if test x$target_cpu = xpowerpc; then
 #error still little endian
 #endif
 asm (".globl start; start:");
+asm (".globl _start; _start:");
+asm (".globl __start; __start:");
 void __main (void);
 void __main (void) {}
 int main (void);
@@ -595,6 +597,41 @@ int main (void);
   TARGET_CPPFLAGS="$TARGET_CPPFLAGS $skip_linkflags"
   TARGET_CCASFLAGS="$TARGET_CCASFLAGS $skip_linkflags"
   TARGET_LDFLAGS="$TARGET_LDFLAGS $grub_cv_target_cc_big_endian"
+elif test x$target_cpu = xmipsel; then
+  AC_CACHE_CHECK([for options to get little-endian compilation], grub_cv_target_cc_little_endian, [
+    grub_cv_target_cc_little_endian=no
+    for cand in "-target $target_cpu -Wl,-EL" "-target $target_cpu" \
+		"-target $target_cpu-linux-gnu -Wl,-EL" "-target $target_cpu-linux-gnu" \
+		"-mlittle-endian"; do
+      if test x"$grub_cv_target_cc_little_endian" != xno ; then
+        break
+      fi
+      CFLAGS="$TARGET_CFLAGS $cand -Werror"
+      AC_LINK_IFELSE([AC_LANG_PROGRAM([[
+#if defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && (__ORDER_BIG_ENDIAN__ == __BYTE_ORDER__)
+#error still big endian
+#endif
+asm (".globl start; start:");
+asm (".globl _start; _start:");
+asm (".globl __start; __start:");
+void __main (void);
+void __main (void) {}
+int main (void);
+]], [[]])],
+		        [grub_cv_target_cc_little_endian="$cand"], [])
+    done
+  ])
+
+  if test x"$grub_cv_target_cc_little_endian" = xno ; then
+    AC_MSG_ERROR([could not force little-endian])
+  fi
+
+  skip_linkflags="$(echo "$grub_cv_target_cc_little_endian"|sed 's@-Wl,-EL@@')"
+
+  TARGET_CFLAGS="$TARGET_CFLAGS $skip_linkflags"
+  TARGET_CPPFLAGS="$TARGET_CPPFLAGS $skip_linkflags"
+  TARGET_CCASFLAGS="$TARGET_CCASFLAGS $skip_linkflags"
+  TARGET_LDFLAGS="$TARGET_LDFLAGS $grub_cv_target_cc_little_endian"
 fi
 
 AC_CACHE_CHECK([for options to compile assembly], [grub_cv_cc_target_asm_compile], [
Signature · 1 line
1.9.1

From b69cb301dca85c60b25f0118e5532a2b12f7bae6 Mon Sep 17 00:00:00 2001
From: Andrei Borzenkov <[email protected]>
Date: Sun, 13 Sep 2015 16:51:13 +0300
Subject: [PATCH 2/2] configure: try to force o32 ABI on MIPS

GRUB expects o32 ABI, in particular used assembly is valid only in this mode. Some systems (e.g. GNU Guix) default to using newer n64 or n32 ABI. Try to find suitable options to force o32.

For GCC this is simply -mabi=32. While clang supports this option as well, o32 ABI is valid for MIPS target and n32/64 ABI are valid for MIPS64 target only, so use "-target mips/mipsel -mabi=32".

---
 configure.ac | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)
configure.ac +31 -0
index 4760fe8..7b4e5bc 100644
@@ -634,6 +634,37 @@ int main (void);
   TARGET_LDFLAGS="$TARGET_LDFLAGS $grub_cv_target_cc_little_endian"
 fi
 
+if test "x$target_cpu" = xmips || test "x$target_cpu" = xmipsel ; then
+  AC_CACHE_CHECK([for options to force MIPS o32 ABI], grub_cv_target_cc_mips_o32_abi, [
+    grub_cv_target_cc_mips_o32_abi=no
+    for arg in "" "-mabi=32" "-target $target_cpu -mabi=32" ; do
+      if test x"$grub_cv_target_cc_mips_o32_abi" != xno ; then
+        break
+      fi
+      CFLAGS="$TARGET_CFLAGS $arg -Werror"
+      AC_LINK_IFELSE([AC_LANG_PROGRAM([[
+#if !defined(_ABIO32) || !defined(_MIPS_SIM) || (_MIPS_SIM != _ABIO32)
+#error not o32 ABI
+#endif
+asm (".globl start; start:");
+asm (".globl _start; _start:");
+asm (".globl __start; __start:");
+void __main (void);
+void __main (void) {}
+int main (void);
+]], [[]])],
+		        [grub_cv_target_cc_mips_o32_abi="$arg"], [])
+    done
+  ])
+
+  if test x"$grub_cv_target_cc_mips_o32_abi" = xno ; then
+    AC_MSG_ERROR([could not force MIPS o32 ABI])
+  fi
+
+  TARGET_CFLAGS="$TARGET_CFLAGS $grub_cv_target_cc_mips_o32_abi"
+  TARGET_CCASFLAGS="$TARGET_CCASFLAGS $grub_cv_target_cc_mips_o32_abi"
+fi
+
 AC_CACHE_CHECK([for options to compile assembly], [grub_cv_cc_target_asm_compile], [
 test_program=
 case "x$target_cpu-$platform" in
Signature · 1 line
1.9.1
#23 lore raw
Quoted 7 lines · Andrei Borzenkov

13.09.2015 05:41, Mark H Weaver пишет:

Quoted 4 lines

I'm glad to report that with your new patch, GRUB successfully builds on GuixSD mips64el with TARGET_CC=clang. I haven't yet tried booting it though.

Did you have chance to test whether compiled grub actually work?

Not yet. I'll try to do it in the next few days.

Quoted 8 lines
Quoted 5 lines

The warning above makes me doubt the portability and future-proofness of the link step of this test. This problem could be avoided entirely by omitting the link step. The link step serves no purpose in this test, and is a potential source of portability problems.

This step helped us to catch endianness mismatch; we want to ensure in this case that full toolchain works to produce final binary.

Okay, fair enough :)

Quoted 5 lines

Please test two attached patches. They separate o32 test from endianness test. I compile-tested them using cross-binutils for mips and powerpc64le to compile for mipsel and powerpc. The first patch also adds additional _start and __start symbols to endianness tests to avoid compiler warnings.

The little-endian-option test fails with GCC 5.2.0. The relevant errors from config.log are:

gcc: error: unrecognized command line option '-target'
gcc: error: unrecognized command line option '-mlittle-endian'

I guess the error messages above should be enough. Let me know if you want more.

It succeeds with clang 3.6.0. See below for the relevant excerpts of config.log.

Thanks,
Mark

--8<---------------cut here---------------start------------->8---
configure:24669: checking for options to get little-endian compilation
configure:24704: /gnu/store/yjmchvkz0kmz4s1sxc0p89imfik68qzg-clang-3.6.0/bin/clang -o conftest -Os -Wall -W -Wshadow -Wpointer-arith -Wundef -Wchar-subscripts -Wcomment -Wdeprecated-declarations -Wdisabled-optimization -Wdiv-by-zero -Wfloat-equal -Wformat-extra-args -Wformat-security -Wformat-y2k -Wimplicit -Wimplicit-function-declaration -Wimplicit-int -Wmain -Wmissing-braces -Wmissing-format-attribute -Wmultichar -Wparentheses -Wreturn-type -Wsequence-point -Wshadow -Wsign-compare -Wswitch -Wtrigraphs -Wunknown-pragmas -Wunused -Wunused-function -Wunused-label -Wunused-parameter -Wunused-value -Wunused-variable -Wwrite-strings -Wnested-externs -Wstrict-prototypes -g -Wredundant-decls -Wmissing-prototypes -Wmissing-declarations -Wcast-align -Wextra -Wattributes -Wendif-labels -Winit-self -Wint-to-pointer-cast -Winvalid-pch -Wmissing-field-initializers -Wnonnull -Woverflow -Wvla -Wpointer-to-int-cast -Wstrict-aliasing -Wvariadic-macros -Wvolatile-register-var -Wpointer-sign -Wmissing-include-dirs -Wmissing-prototypes -Wmissing-declarations -Wformat=2 -target mipsel -Wl,-EL -Werror -Wall -W -DGRUB_CPU_MIPSEL=1 -DGRUB_MACHINE_MIPS_LOONGSON=1 -DGRUB_MACHINE=MIPS_LOONGSON -nostdlib -static conftest.c >&5
ld: /tmp/conftest-78445a.o: ABI is incompatible with that of the selected emulation
ld: failed to merge target specific data of file /tmp/conftest-78445a.o
collect2: error: ld returned 1 exit status
clang-3.6: error: linker (via gcc) command failed with exit code 1 (use -v to see invocation)
configure:24704: $? = 1
configure: failed program was:
[...]
configure:24704: /gnu/store/yjmchvkz0kmz4s1sxc0p89imfik68qzg-clang-3.6.0/bin/clang -o conftest -Os -Wall -W -Wshadow -Wpointer-arith -Wundef -Wchar-subscripts -Wcomment -Wdeprecated-declarations -Wdisabled-optimization -Wdiv-by-zero -Wfloat-equal -Wformat-extra-args -Wformat-security -Wformat-y2k -Wimplicit -Wimplicit-function-declaration -Wimplicit-int -Wmain -Wmissing-braces -Wmissing-format-attribute -Wmultichar -Wparentheses -Wreturn-type -Wsequence-point -Wshadow -Wsign-compare -Wswitch -Wtrigraphs -Wunknown-pragmas -Wunused -Wunused-function -Wunused-label -Wunused-parameter -Wunused-value -Wunused-variable -Wwrite-strings -Wnested-externs -Wstrict-prototypes -g -Wredundant-decls -Wmissing-prototypes -Wmissing-declarations -Wcast-align -Wextra -Wattributes -Wendif-labels -Winit-self -Wint-to-pointer-cast -Winvalid-pch -Wmissing-field-initializers -Wnonnull -Woverflow -Wvla -Wpointer-to-int-cast -Wstrict-aliasing -Wvariadic-macros -Wvolatile-register-var -Wpointer-sign -Wmissing-include-dirs -Wmissing-prototypes -Wmissing-declarations -Wformat=2 -target mipsel -Werror -Wall -W -DGRUB_CPU_MIPSEL=1 -DGRUB_MACHINE_MIPS_LOONGSON=1 -DGRUB_MACHINE=MIPS_LOONGSON -nostdlib -static conftest.c >&5
ld: /tmp/conftest-66051b.o: ABI is incompatible with that of the selected emulation
ld: failed to merge target specific data of file /tmp/conftest-66051b.o
collect2: error: ld returned 1 exit status
clang-3.6: error: linker (via gcc) command failed with exit code 1 (use -v to see invocation)
configure:24704: $? = 1
configure: failed program was:
[...]
configure:24704: /gnu/store/yjmchvkz0kmz4s1sxc0p89imfik68qzg-clang-3.6.0/bin/clang -o conftest -Os -Wall -W -Wshadow -Wpointer-arith -Wundef -Wchar-subscripts -Wcomment -Wdeprecated-declarations -Wdisabled-optimization -Wdiv-by-zero -Wfloat-equal -Wformat-extra-args -Wformat-security -Wformat-y2k -Wimplicit -Wimplicit-function-declaration -Wimplicit-int -Wmain -Wmissing-braces -Wmissing-format-attribute -Wmultichar -Wparentheses -Wreturn-type -Wsequence-point -Wshadow -Wsign-compare -Wswitch -Wtrigraphs -Wunknown-pragmas -Wunused -Wunused-function -Wunused-label -Wunused-parameter -Wunused-value -Wunused-variable -Wwrite-strings -Wnested-externs -Wstrict-prototypes -g -Wredundant-decls -Wmissing-prototypes -Wmissing-declarations -Wcast-align -Wextra -Wattributes -Wendif-labels -Winit-self -Wint-to-pointer-cast -Winvalid-pch -Wmissing-field-initializers -Wnonnull -Woverflow -Wvla -Wpointer-to-int-cast -Wstrict-aliasing -Wvariadic-macros -Wvolatile-register-var -Wpointer-sign -Wmissing-include-dirs -Wmissing-prototypes -Wmissing-declarations -Wformat=2 -target mipsel-linux-gnu -Wl,-EL -Werror -Wall -W -DGRUB_CPU_MIPSEL=1 -DGRUB_MACHINE_MIPS_LOONGSON=1 -DGRUB_MACHINE=MIPS_LOONGSON -nostdlib -static conftest.c >&5 configure:24704: $? = 0
configure:24712: result: -target mipsel-linux-gnu -Wl,-EL
configure:24728: checking for options to force MIPS o32 ABI
configure:24761: /gnu/store/yjmchvkz0kmz4s1sxc0p89imfik68qzg-clang-3.6.0/bin/clang -o conftest -Os -Wall -W -Wshadow -Wpointer-arith -Wundef -Wchar-subscripts -Wcomment -Wdeprecated-declarations -Wdisabled-optimization -Wdiv-by-zero -Wfloat-equal -Wformat-extra-args -Wformat-security -Wformat-y2k -Wimplicit -Wimplicit-function-declaration -Wimplicit-int -Wmain -Wmissing-braces -Wmissing-format-attribute -Wmultichar -Wparentheses -Wreturn-type -Wsequence-point -Wshadow -Wsign-compare -Wswitch -Wtrigraphs -Wunknown-pragmas -Wunused -Wunused-function -Wunused-label -Wunused-parameter -Wunused-value -Wunused-variable -Wwrite-strings -Wnested-externs -Wstrict-prototypes -g -Wredundant-decls -Wmissing-prototypes -Wmissing-declarations -Wcast-align -Wextra -Wattributes -Wendif-labels -Winit-self -Wint-to-pointer-cast -Winvalid-pch -Wmissing-field-initializers -Wnonnull -Woverflow -Wvla -Wpointer-to-int-cast -Wstrict-aliasing -Wvariadic-macros -Wvolatile-register-var -Wpointer-sign -Wmissing-include-dirs -Wmissing-prototypes -Wmissing-declarations -Wformat=2 -target mipsel-linux-gnu -Werror -Wall -W -DGRUB_CPU_MIPSEL=1 -DGRUB_MACHINE_MIPS_LOONGSON=1 -DGRUB_MACHINE=MIPS_LOONGSON -nostdlib -static conftest.c >&5
configure:24761: $? = 0
configure:24769: result:
--8<---------------cut here---------------end--------------->8---

#24 lore raw

Sorry for delay.

14.09.2015 02:37, Mark H Weaver пишет:

Quoted 7 lines

The little-endian-option test fails with GCC 5.2.0. The relevant errors from config.log are:

gcc: error: unrecognized command line option '-target'
gcc: error: unrecognized command line option '-mlittle-endian'

Oh, well ... let's try once more.

From 4a3d2cfc3a1f8d0325b3964b836b5fe584784bb8 Mon Sep 17 00:00:00 2001
From: Andrei Borzenkov <[email protected]>
Date: Sun, 20 Sep 2015 07:42:12 +0300
Subject: [PATCH 1/2] configure: try to find options to force endian on MIPS

---
 configure.ac | 45 +++++++++++++++++++++++++++++++++++++++++----
 1 file changed, 41 insertions(+), 4 deletions(-)
configure.ac +41 -4
index c864311..baf8525 100644
@@ -562,12 +562,12 @@ AC_COMPILE_IFELSE(
 ]])],
 [grub_cv_cc_target_clang=no], [grub_cv_cc_target_clang=yes])])
 
-if test x$target_cpu = xpowerpc; then
+if test x$target_cpu = xpowerpc -o x$target_cpu = xmips; then
   AC_CACHE_CHECK([for options to get big-endian compilation], grub_cv_target_cc_big_endian, [
     grub_cv_target_cc_big_endian=no
-    for cand in "-target powerpc -Wl,-EB" "-target powerpc" \
-		"-target powerpc-linux-gnu -Wl,-EB" "-target powerpc-linux-gnu" \
-		"-mbig-endian"; do
+    for cand in "-target $target_cpu -Wl,-EB" "-target $target_cpu" \
+		"-target $target_cpu-linux-gnu -Wl,-EB" "-target $target_cpu-linux-gnu" \
+		"-EB" "-mbig-endian"; do
       if test x"$grub_cv_target_cc_big_endian" != xno ; then
         break
       fi
@@ -577,6 +577,8 @@ if test x$target_cpu = xpowerpc; then
 #error still little endian
 #endif
 asm (".globl start; start:");
+asm (".globl _start; _start:");
+asm (".globl __start; __start:");
 void __main (void);
 void __main (void) {}
 int main (void);
@@ -595,6 +597,41 @@ int main (void);
   TARGET_CPPFLAGS="$TARGET_CPPFLAGS $skip_linkflags"
   TARGET_CCASFLAGS="$TARGET_CCASFLAGS $skip_linkflags"
   TARGET_LDFLAGS="$TARGET_LDFLAGS $grub_cv_target_cc_big_endian"
+elif test x$target_cpu = xmipsel; then
+  AC_CACHE_CHECK([for options to get little-endian compilation], grub_cv_target_cc_little_endian, [
+    grub_cv_target_cc_little_endian=no
+    for cand in "-target $target_cpu -Wl,-EL" "-target $target_cpu" \
+		"-target $target_cpu-linux-gnu -Wl,-EL" "-target $target_cpu-linux-gnu" \
+		"-EL"; do
+      if test x"$grub_cv_target_cc_little_endian" != xno ; then
+        break
+      fi
+      CFLAGS="$TARGET_CFLAGS $cand -Werror"
+      AC_LINK_IFELSE([AC_LANG_PROGRAM([[
+#if defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && (__ORDER_BIG_ENDIAN__ == __BYTE_ORDER__)
+#error still big endian
+#endif
+asm (".globl start; start:");
+asm (".globl _start; _start:");
+asm (".globl __start; __start:");
+void __main (void);
+void __main (void) {}
+int main (void);
+]], [[]])],
+		        [grub_cv_target_cc_little_endian="$cand"], [])
+    done
+  ])
+
+  if test x"$grub_cv_target_cc_little_endian" = xno ; then
+    AC_MSG_ERROR([could not force little-endian])
+  fi
+
+  skip_linkflags="$(echo "$grub_cv_target_cc_little_endian"|sed 's@-Wl,-EL@@')"
+
+  TARGET_CFLAGS="$TARGET_CFLAGS $skip_linkflags"
+  TARGET_CPPFLAGS="$TARGET_CPPFLAGS $skip_linkflags"
+  TARGET_CCASFLAGS="$TARGET_CCASFLAGS $skip_linkflags"
+  TARGET_LDFLAGS="$TARGET_LDFLAGS $grub_cv_target_cc_little_endian"
 fi
 
 AC_CACHE_CHECK([for options to compile assembly], [grub_cv_cc_target_asm_compile], [
Signature · 1 line
1.9.1

From b609d424889ffdb3cc9191384296980e02514abb Mon Sep 17 00:00:00 2001
From: Andrei Borzenkov <[email protected]>
Date: Sun, 20 Sep 2015 07:42:12 +0300
Subject: [PATCH 2/2] configure: try to force o32 ABI on MIPS

GRUB expects o32 ABI, in particular used assembly is valid only in this mode. Some systems (e.g. GNU Guix) default to using newer n64 or n32 ABI. Try to find suitable options to force o32.

For GCC this is simply -mabi=32. While clang supports this option as well, o32 ABI is valid for MIPS target and n32/64 ABI are valid for MIPS64 target only, so use "-target mips/mipsel -mabi=32".

---
 configure.ac | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)
configure.ac +31 -0
index baf8525..d9d4222 100644
@@ -634,6 +634,37 @@ int main (void);
   TARGET_LDFLAGS="$TARGET_LDFLAGS $grub_cv_target_cc_little_endian"
 fi
 
+if test "x$target_cpu" = xmips || test "x$target_cpu" = xmipsel ; then
+  AC_CACHE_CHECK([for options to force MIPS o32 ABI], grub_cv_target_cc_mips_o32_abi, [
+    grub_cv_target_cc_mips_o32_abi=no
+    for arg in "" "-mabi=32" "-target $target_cpu -mabi=32" ; do
+      if test x"$grub_cv_target_cc_mips_o32_abi" != xno ; then
+        break
+      fi
+      CFLAGS="$TARGET_CFLAGS $arg -Werror"
+      AC_LINK_IFELSE([AC_LANG_PROGRAM([[
+#if !defined(_ABIO32) || !defined(_MIPS_SIM) || (_MIPS_SIM != _ABIO32)
+#error not o32 ABI
+#endif
+asm (".globl start; start:");
+asm (".globl _start; _start:");
+asm (".globl __start; __start:");
+void __main (void);
+void __main (void) {}
+int main (void);
+]], [[]])],
+		        [grub_cv_target_cc_mips_o32_abi="$arg"], [])
+    done
+  ])
+
+  if test x"$grub_cv_target_cc_mips_o32_abi" = xno ; then
+    AC_MSG_ERROR([could not force MIPS o32 ABI])
+  fi
+
+  TARGET_CFLAGS="$TARGET_CFLAGS $grub_cv_target_cc_mips_o32_abi"
+  TARGET_CCASFLAGS="$TARGET_CCASFLAGS $grub_cv_target_cc_mips_o32_abi"
+fi
+
 AC_CACHE_CHECK([for options to compile assembly], [grub_cv_cc_target_asm_compile], [
 test_program=
 case "x$target_cpu-$platform" in
Signature · 1 line
1.9.1
#25 lore raw
Quoted 9 lines · Andrei Borzenkov

14.09.2015 02:37, Mark H Weaver пишет:

Quoted 6 lines

The little-endian-option test fails with GCC 5.2.0. The relevant errors from config.log are:

gcc: error: unrecognized command line option '-target'
gcc: error: unrecognized command line option '-mlittle-endian'

Oh, well ... let's try once more.

Your newest patches work for me with both GCC and Clang. I think they are ready to push.

Thanks!
Mark

#26 lore raw

Did you also test cross-compile (building for BE MIPS in your case)?

Отправлено с iPhone

Quoted 19 lines

21 сент. 2015 г., в 18:09, Mark H Weaver <[email protected]> написал(а):

Quoted 9 lines · Andrei Borzenkov

14.09.2015 02:37, Mark H Weaver пишет:

Quoted 6 lines

The little-endian-option test fails with GCC 5.2.0. The relevant errors from config.log are:

gcc: error: unrecognized command line option '-target'
gcc: error: unrecognized command line option '-mlittle-endian'

Oh, well ... let's try once more.

Your newest patches work for me with both GCC and Clang. I think they are ready to push.

Thanks!
Mark

#27 lore raw
Quoted 1 line · Andrei Borzenkov

Did you also test cross-compile

No. My Yeeloong 8101B (based on the Loongson 2F processor) is my (relatively) high security machine, and I prefer to avoid running any code on it that was not built natively on it from source code. That's also the reason I have not yet tried booting GRUB compiled with clang: I have not yet compiled clang on my Yeeloong, as it would take a long time to do so.

I tested building grub with clang on a different machine (the Lemote Yeeloong 8133 laptop based on the Loongson 3A), but cannot run it there because that machine is not supported by GRUB afaict.

Quoted 1 line

(building for BE MIPS in your case)?

The Loongson 2F does not support big-endian mode.

Thanks,
Mark

#28 lore raw

Отправлено с iPhone

Quoted 12 lines

22 сент. 2015 г., в 17:03, Mark H Weaver <[email protected]> написал(а):

Quoted 1 line · Andrei Borzenkov

Did you also test cross-compile

No. My Yeeloong 8101B (based on the Loongson 2F processor) is my (relatively) high security machine, and I prefer to avoid running any code on it that was not built natively on it from source code. That's also the reason I have not yet tried booting GRUB compiled with clang: I have not yet compiled clang on my Yeeloong, as it would take a long time to do so.

Quoted 8 lines

I tested building grub with clang on a different machine (the Lemote Yeeloong 8133 laptop based on the Loongson 3A), but cannot run it there because that machine is not supported by GRUB afaict.

Quoted 1 line

(building for BE MIPS in your case)?

The Loongson 2F does not support big-endian mode.

I do not mean building for your system, but testing building for BE MIPS on native MIPS toolkit.

Quoted 2 lines

Thanks,
Mark