Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp5261731yba; Mon, 13 May 2019 08:01:38 -0700 (PDT) X-Google-Smtp-Source: APXvYqyvJBbWHl3NLTnbNDykNvSvwAYg1XuiXHEpNQdVnfbQ/D5Ab+U7UIezaDDON88tgmXdzQCp X-Received: by 2002:a63:3d0b:: with SMTP id k11mr31176331pga.349.1557759698609; Mon, 13 May 2019 08:01:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557759698; cv=none; d=google.com; s=arc-20160816; b=teW3yHbCH6Scbk9Oj5XyTgccf63niU1fEdBhs8EjMwHO6376UM7gd1d3oDCR6cr9Ua gbxmn9tm//WKffZLcsSbJwreKGdd4arl8m9hBAlP8QH9ozpU0EPaXvjmVoyiscas295j SoDUygcw1OlthQMyzeduUHX28cQmRFkrakkomu9srT73g7zG33Fde2ptUG2ykiGIHT8f 5NmIHV4QApBhBdNa9Z5K7caBlu7H94AcajHJo4CgT0NtAyclPSIyqruiLUtcuYmM7jbJ fkBSGFxXTV0gPSEs1plByi6yvt+vU0R+Xj/lN9Ith/GY7p05TEDHm7dahhRqUD8+ig+r WaIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=5ghfMy6obv1hrpZpCwIJ2TJb+OktMKKHOCaRgouBZNU=; b=Mlv9Bk1qq+QuYzH8t7eO7NjTD7o18AoApOnNkxJa04LW4jyH4H/Rk5aD5wzIG4hyez YR1SVGFTLWRoI6fBOKe3Fc44gxm94FNqtPkazjGbfaP0LnVeNeoOwNKPK0Bjn2an8LLz OUufwBv7Hgey8pP2h1bAbhBTpmbJ0mFivbit1/IUlGUx1yJb+jptWjAWNG8T4X5rc1YZ L1YviRHargdQ+bSKNSoV6UVln56qwjYzRc0YFmCh7FwOq/J/NV5ApnKN+8lEOh1tbTjy q1ATqRowY5pgCPvI6JbqRPeN/drXhAViSODlrVgmn0fJiZVWo9hzhLsOtRMEVbeeXXQS 5p+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=RQ6ygksW; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r197si19558270pfc.243.2019.05.13.08.01.21; Mon, 13 May 2019 08:01:38 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=RQ6ygksW; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728782AbfEMLuc (ORCPT + 99 others); Mon, 13 May 2019 07:50:32 -0400 Received: from mail-it1-f193.google.com ([209.85.166.193]:37741 "EHLO mail-it1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728531AbfEMLub (ORCPT ); Mon, 13 May 2019 07:50:31 -0400 Received: by mail-it1-f193.google.com with SMTP id l7so19771021ite.2 for ; Mon, 13 May 2019 04:50:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=5ghfMy6obv1hrpZpCwIJ2TJb+OktMKKHOCaRgouBZNU=; b=RQ6ygksWQIZXg92jHryig/GzewJP/tQhrxquLavPhVBu0Y2wASBIuqsa+HGqF88A6F O+rpZdrLF7sxwiQspnZGxb6Y5DPFZTj0I2Nz7vFJshQCpB2PoElVv0MvXbkETGwCwSLe HCxPwApZSxtMvzLe4hqx+XfVSbogEkrUeU8wIZ371zkoDF3Rrpe8mJZCOlSV/9H60wUH GoIE6K7V+lSdLJb3xjsJpBen0dHq89nE1v6CNMEGE2JQEoDnFef2WlsEvw7JOgZZI1cm SLksF16OHOQLUUs/V/xSCRZRWP9YT8ia9aSVG249Txp1MJ2ydmq9/7jNJJcPj9Z7GOZd f0rw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=5ghfMy6obv1hrpZpCwIJ2TJb+OktMKKHOCaRgouBZNU=; b=cSNHTNYPltBdZS1+TvupIrwPkgyIMWjiZrmfFH8CdvpJk2P+HtN4A8dhg5H1yTRg+E heF7pVa9LP+FfaSszlLfiW+rs2FVVzvJ3QNcp0PwgaSMZdsYVsz+AHxiwho0rHtNoj8W BuzAAUGHCTvQdP+Iq+OIPB/Q4eVO9gNKZgK5g7UCmulPMGgoSluUORMK3MzXsqpL2cS/ kIUqgX9/CbKE2yTYt5jDNV9tjfSoFEInn8o6eXspqvx58oGd/u8AKtjB78shDca3qIV6 CwE5ZAPoKu2Q5b4aSX7XMIUNOJ4xps/DuUH5jdAPcZx6YDe6+vLFCjECS6o8OrT/9cPX JWNg== X-Gm-Message-State: APjAAAX9zHdp4oebLLuwUUdXC8x4HUJw9HM9xLxSI0qNzCO2/JpBkId9 OW8MesR/d833K3rDpNQQfslElTmkZb0dAek9Q/hf0g== X-Received: by 2002:a02:1384:: with SMTP id 126mr17144580jaz.72.1557748230654; Mon, 13 May 2019 04:50:30 -0700 (PDT) MIME-Version: 1.0 References: <20190412143538.11780-1-hch@lst.de> <87woiutwq4.fsf@concordia.ellerman.id.au> In-Reply-To: <87woiutwq4.fsf@concordia.ellerman.id.au> From: Dmitry Vyukov Date: Mon, 13 May 2019 13:50:19 +0200 Message-ID: Subject: Re: [PATCH, RFC] byteorder: sanity check toolchain vs kernel endianess To: Michael Ellerman Cc: Arnd Bergmann , Nick Kossifidis , Christoph Hellwig , Linus Torvalds , Andrew Morton , linux-arch , Linux Kernel Mailing List , linuxppc-dev , Andrew Donnellan Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Michael Ellerman Date: Mon, May 13, 2019 at 1:33 PM To: Dmitry Vyukov, Arnd Bergmann Cc: Nick Kossifidis, Christoph Hellwig, Linus Torvalds, Andrew Morton, linux-arch, Linux Kernel Mailing List, linuxppc-dev > Dmitry Vyukov writes: > > From: Arnd Bergmann > > Date: Sat, May 11, 2019 at 2:51 AM > > To: Dmitry Vyukov > > Cc: Nick Kossifidis, Christoph Hellwig, Linus Torvalds, Andrew Morton, > > linux-arch, Linux Kernel Mailing List, linuxppc-dev > > > >> On Fri, May 10, 2019 at 6:53 AM Dmitry Vyukov wrote: > >> > > > >> > > I think it's good to have a sanity check in-place for consistency. > >> > > >> > > >> > Hi, > >> > > >> > This broke our cross-builds from x86. I am using: > >> > > >> > $ powerpc64le-linux-gnu-gcc --version > >> > powerpc64le-linux-gnu-gcc (Debian 7.2.0-7) 7.2.0 > >> > > >> > and it says that it's little-endian somehow: > >> > > >> > $ powerpc64le-linux-gnu-gcc -dM -E - < /dev/null | grep BYTE_ORDER > >> > #define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__ > >> > > >> > Is it broke compiler? Or I always hold it wrong? Is there some > >> > additional flag I need to add? > >> > >> It looks like a bug in the kernel Makefiles to me. powerpc32 is always > >> big-endian, > >> powerpc64 used to be big-endian but is now usually little-endian. There are > >> often three separate toolchains that default to the respective user > >> space targets > >> (ppc32be, ppc64be, ppc64le), but generally you should be able to build > >> any of the > >> three kernel configurations with any of those compilers, and have the Makefile > >> pass the correct -m32/-m64/-mbig-endian/-mlittle-endian command line options > >> depending on the kernel configuration. It seems that this is not happening > >> here. I have not checked why, but if this is the problem, it should be > >> easy enough > >> to figure out. > > > > > > Thanks! This clears a lot. > > This may be a bug in our magic as we try to build kernel files outside > > of make with own flags (required to extract parts of kernel > > interfaces). > > So don't spend time looking for the Makefile bugs yet. > > OK :) > > We did have some bugs in the past (~1-2 y/ago) but AFAIK they are all > fixed now. These days I build most of my kernels with a bi-endian 64-bit > toolchain, and switching endian without running `make clean` also works. For the record, yes, it turn out to be a problem in our code (a latent bug). We actually used host (x86) gcc to build as-if ppc code that can run on the host, so it defined neither LE no BE macros. It just happened to work in the past :) +Andrew