All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrei Borzenkov <arvidjaar@gmail.com>
To: "Vladimir 'phcoder' Serbinenko" <phcoder@gmail.com>
Cc: The development of GRUB 2 <grub-devel@gnu.org>,
	Paulo Flabiano Smorigo <pfsmorigo@linux.vnet.ibm.com>
Subject: Re: [PATCH 1/2] Add powerpc little-endian (ppc64le) flags
Date: Sat, 4 Jul 2015 09:46:59 +0300	[thread overview]
Message-ID: <20150704094659.6aa48bf5@opensuse.site> (raw)
In-Reply-To: <CAEaD8JN=UANx1AnkkCMZctmufqcctF8atYqcn-TPA1-X0K4EbQ@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 2649 bytes --]

В Tue, 30 Jun 2015 21:34:10 +0200
"Vladimir 'phcoder' Serbinenko" <phcoder@gmail.com> пишет:

> I think those flags disable only runtime libraries, not the code generation

Yes, you are right. Clang seems to be built for the whole family, i.e.
PowerPC, which seems to automatically include all three versions (ppc,
ppc64, ppc64le)

See below for details.

> Le 30 juin 2015 20:29, "Andrei Borzenkov" <arvidjaar@gmail.com> a écrit :
> 
> > В Tue, 30 Jun 2015 15:05:46 -0300
> > Paulo Flabiano Smorigo <pfsmorigo@linux.vnet.ibm.com> пишет:
> >
> > > On 2015-06-30 11:33, Vladimir 'phcoder' Serbinenko wrote:
> > > > What about clang?
> > >
> > > Not good news about clang support. This is what the toolchain team said
> > > about it:
> > >
> > > The -mbig-endian option was added around April 10th, 2014.
> > > Unfortunately, those who implemented it only implemented it for ARM and
> > > one other architecture.
> > >
> > > The option is currently accepted on Power systems, but does not have any
> > > affect on the code generation for Power.
> > >

Support for it looks rather trivial; see attached patch. Anyone has good
connection to clang development community?

Using this patch the

clang --target=powerpc64le -mbig-endian -m32 produces code for PPC32
BE, so just works:

bor@opensuse:~/build/clang-ppc/bin> ./clang  --target=powerpc64le   -c -mbig-endian -m32 /tmp/foo.c
/tmp/foo.c:1:1: warning: type specifier missing, defaults to 'int'
      [-Wimplicit-int]
foo()
^
1 warning generated.
bor@opensuse:~/build/clang-ppc/bin> file foo.o
foo.o: ELF 32-bit MSB relocatable, PowerPC or cisco 4500, version 1 (SYSV), not stripped

The problem is that in this case we do not really have any way to test
if it works in configure, so no way to fail gracefully.

> > >
> > > So, what can we do here? Maybe add a constrain in the configure file
> > > saying that it's not possible to build GRUB in a LE environment using
> > clang.
> >
> > If I understand it correctly, it is possible to build for big-endian
> > PowerPC using
> >
> > clang -target=powerpc
> >
> > but then we depend on clang being built with BE target support; and
> > e.g. openSUSE builds it with
> >

Yes, that works too. But I'm not sure how we can test for it. Brute
force would of course be

$TARGET_CC --version | grep clang && TARGET_CFLAGS=--target=powerpc

Comments? I'm inclined to use this workaround. This still may have
issues when using external assembler, but here we can simply mandate
support for clang 3.6 at the minimum, which should use integrated
assembler on PPC by default.

[-- Attachment #2: clang-ppc-endian-switch.patch --]
[-- Type: text/x-patch, Size: 1275 bytes --]

From: Andrei Borzenkov <arvidjaar@gmail.com>
Subject: [PATCH] support -big-endian/-mlittle-endian on PowerPC64

Signed-off-by: Andrei Borzenkov <arvidjaar@gmail.com>

---
 lib/Driver/Driver.cpp | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/lib/Driver/Driver.cpp b/lib/Driver/Driver.cpp
index d4b47a4..b7a6a66 100644
--- a/lib/Driver/Driver.cpp
+++ b/lib/Driver/Driver.cpp
@@ -1947,6 +1947,8 @@ static llvm::Triple computeTargetTriple(StringRef DefaultTargetTriple,
         Target.setArch(llvm::Triple::mips64el);
       else if (Target.getArch() == llvm::Triple::aarch64_be)
         Target.setArch(llvm::Triple::aarch64);
+      else if (Target.getArch() == llvm::Triple::ppc64)
+        Target.setArch(llvm::Triple::ppc64le);
     } else {
       if (Target.getArch() == llvm::Triple::mipsel)
         Target.setArch(llvm::Triple::mips);
@@ -1954,6 +1956,8 @@ static llvm::Triple computeTargetTriple(StringRef DefaultTargetTriple,
         Target.setArch(llvm::Triple::mips64);
       else if (Target.getArch() == llvm::Triple::aarch64)
         Target.setArch(llvm::Triple::aarch64_be);
+      else if (Target.getArch() == llvm::Triple::ppc64le)
+        Target.setArch(llvm::Triple::ppc64);
     }
   }
 
-- 
tg: (76af433..) e/ppc-mendian (depends on: master)

  reply	other threads:[~2015-07-04  6:47 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-30 12:56 [PATCH 0/2] Add remaining parts for ppc64le environment Paulo Flabiano Smorigo
2015-06-30 12:56 ` [PATCH 1/2] Add powerpc little-endian (ppc64le) flags Paulo Flabiano Smorigo
2015-06-30 14:03   ` Vladimir 'phcoder' Serbinenko
2015-06-30 14:29     ` Andrei Borzenkov
2015-06-30 14:33       ` Vladimir 'phcoder' Serbinenko
2015-06-30 18:05         ` Paulo Flabiano Smorigo
2015-06-30 18:28           ` Andrei Borzenkov
2015-06-30 19:34             ` Vladimir 'phcoder' Serbinenko
2015-07-04  6:46               ` Andrei Borzenkov [this message]
2015-07-05 17:38                 ` Andrei Borzenkov
2015-07-15 17:42                   ` Vladimir 'φ-coder/phcoder' Serbinenko
2015-07-16 18:55                     ` Andrei Borzenkov
2015-07-16 19:05                       ` Vladimir 'φ-coder/phcoder' Serbinenko
2015-07-16 19:30                         ` Andrei Borzenkov
2015-07-20 13:01                           ` Paulo Flabiano Smorigo
2015-07-22  3:23                     ` Andrei Borzenkov
2015-07-22 17:00                       ` Paulo Flabiano Smorigo
2015-07-15 17:36                 ` Vladimir 'φ-coder/phcoder' Serbinenko
2015-07-15 16:46             ` Vladimir 'φ-coder/phcoder' Serbinenko
2015-06-30 14:33       ` Paulo Flabiano Smorigo
2015-06-30 12:56 ` [PATCH 2/2] Suport for bi-endianess in elf file Paulo Flabiano Smorigo
2015-06-30 15:03   ` Andrei Borzenkov
2015-06-30 18:06     ` Paulo Flabiano Smorigo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150704094659.6aa48bf5@opensuse.site \
    --to=arvidjaar@gmail.com \
    --cc=grub-devel@gnu.org \
    --cc=pfsmorigo@linux.vnet.ibm.com \
    --cc=phcoder@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.