From patchwork Wed May 16 14:14:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 914669 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40mH0c1xK2z9s2L for ; Thu, 17 May 2018 00:30:40 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Ytl0rZOi"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 40mH0b6NlGzF13r for ; Thu, 17 May 2018 00:30:39 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Ytl0rZOi"; dkim-atps=neutral X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:400e:c05::241; helo=mail-pg0-x241.google.com; envelope-from=npiggin@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Ytl0rZOi"; dkim-atps=neutral Received: from mail-pg0-x241.google.com (mail-pg0-x241.google.com [IPv6:2607:f8b0:400e:c05::241]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 40mGfz0fBtzF1KG for ; Thu, 17 May 2018 00:15:22 +1000 (AEST) Received: by mail-pg0-x241.google.com with SMTP id v7-v6so375357pgs.0 for ; Wed, 16 May 2018 07:15:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=F/tqM1BZOACDSv8gFkl2RxYhPBI36mVx+/i4FmXK1CQ=; b=Ytl0rZOi6bP8iKRZBFpKmMZcdBsn12mi9l1sqSdv3XPqKd5YhLH7z7hXWZchbM8dMa e5sNMBHtqe22f6fXqf+K2AmqDNLLpqMVmXYYhkhGYIJV9RwzAuAlOvaa6bJit6o363vb +IMg060uaIhYEhS+J7wr8Av3w0q6IqedQpE597qxhXqK4Cjr3tl+EPec2hKdAMO+BbyE tw6pAAcXy3bzglz8djvX9ZYGg/zRtvj6mgT/rpKCX1pWn/7zaAOXlGoSyUyKFSldS2iX GAT8q2D6CzAFNFWDcHZLLdxLE+Ax3NhAkpsVD3Cek17n0aCWqj/8NmyHjX321WsKmyMs hBpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=F/tqM1BZOACDSv8gFkl2RxYhPBI36mVx+/i4FmXK1CQ=; b=czqWzlzCiDQNXQxsW/aNvP1Z4O0TF1GLi0pkWDHVcumdEIPyKkBZOJY2vZlHT+mr8L 51xopiFEV1J9bOID9frHYLip2DYW1CPKIBR3FDwZrYXoAsFpxyJun5qU6AxEZ+EJWa1l 3zmGN8YEVaBml31An0gDaocLQhDq9yxJmpWtYLhc1JXOFc4hTpMooweQMIgRCT8wez+D KFl9IKzmPpdiL3GKdOPjkL/9POEfrmrX1mflVH74KDOiyAvN1WD1HZgicmPPUUbHSbGS eJktsos0NmpA0hEf/hn1G1EEi5aWXP5PLb3dlBq7WEzpEAfBFGRQwXf/rBdd9V/M4cEP KGNw== X-Gm-Message-State: ALKqPwdBDsQYfudby2Y0oZN8WSZWvEt4N2qT8cMGQipAXaTtfpvYSsSq cvVNk/AIqvMTbi0it3zHTq8= X-Google-Smtp-Source: AB8JxZrnTTCjy2MCjlhqT2BwmyqNLXLk0GOIzOq1dkQthQuo844WBJkTk1VNFL6IaUj+SMiHGKshEg== X-Received: by 2002:a62:578e:: with SMTP id i14-v6mr1158260pfj.119.1526480120847; Wed, 16 May 2018 07:15:20 -0700 (PDT) Received: from roar.au.ibm.com (59-102-70-78.tpgi.com.au. [59.102.70.78]) by smtp.gmail.com with ESMTPSA id h130-v6sm7365162pfc.98.2018.05.16.07.15.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 May 2018 07:15:19 -0700 (PDT) From: Nicholas Piggin To: linux-kbuild@vger.kernel.org Subject: [PATCH v4 3/4] powerpc/kbuild: Use flags variables rather than overriding LD/CC/AS Date: Thu, 17 May 2018 00:14:57 +1000 Message-Id: <20180516141458.18996-4-npiggin@gmail.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180516141458.18996-1-npiggin@gmail.com> References: <20180516141458.18996-1-npiggin@gmail.com> X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Masahiro Yamada , linuxppc-dev@lists.ozlabs.org, Nicholas Piggin Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" The powerpc toolchain can compile combinations of 32/64 bit and big/little endian, so it's convenient to consider, e.g., `CC -m64 -mbig-endian` To be the C compiler for the purpose of invoking it to build target artifacts. So overriding the the CC variable to include these flags works for this purpose. Unfortunately that is not compatible with the way the proposed new Kconfig macro language implementation, which gets confused by the the $(CC) environment variable changing. After previous patches in this series, these flags can be carefully passed in using the usual kbuild flags variables instead. Acked-by: Steven Rostedt (VMware) Signed-off-by: Nicholas Piggin --- Since v3: - Added 32/64 flags to recordmcount.pl invocation of the toolchain, similarly to BE/LE. This fixes problems with toolchain default target bitness != kernel target bitness. I kept Steven's ack because it's much the same powerpc specific change, okay? - Added a similar fix for mismatched toolchain default endianness or bitness to the gcc-check-mprofile-kernel.sh script. This was pulled in from patch 4 and improved (added comment and endianness flags). arch/powerpc/Makefile | 16 +++++++++------- .../powerpc/tools/gcc-check-mprofile-kernel.sh | 12 ++++++++---- scripts/recordmcount.pl | 18 +++++++++++++++++- 3 files changed, 34 insertions(+), 12 deletions(-) diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile index 167b26a0780c..6faf1d6ad9dd 100644 --- a/arch/powerpc/Makefile +++ b/arch/powerpc/Makefile @@ -75,13 +75,15 @@ endif endif ifeq ($(CONFIG_CPU_LITTLE_ENDIAN),y) -override LD += -EL +KBUILD_CFLAGS += -mlittle-endian +LDFLAGS += -EL LDEMULATION := lppc GNUTARGET := powerpcle MULTIPLEWORD := -mno-multiple KBUILD_CFLAGS_MODULE += $(call cc-option,-mno-save-toc-indirect) else -override LD += -EB +KBUILD_CFLAGS += $(call cc-option,-mbig-endian) +LDFLAGS += -EB LDEMULATION := ppc GNUTARGET := powerpc MULTIPLEWORD := -mmultiple @@ -94,19 +96,19 @@ aflags-$(CONFIG_CPU_BIG_ENDIAN) += $(call cc-option,-mabi=elfv1) aflags-$(CONFIG_CPU_LITTLE_ENDIAN) += -mabi=elfv2 endif -cflags-$(CONFIG_CPU_LITTLE_ENDIAN) += -mlittle-endian -cflags-$(CONFIG_CPU_BIG_ENDIAN) += $(call cc-option,-mbig-endian) ifneq ($(cc-name),clang) cflags-$(CONFIG_CPU_LITTLE_ENDIAN) += -mno-strict-align endif +cflags-$(CONFIG_CPU_BIG_ENDIAN) += $(call cc-option,-mbig-endian) +cflags-$(CONFIG_CPU_LITTLE_ENDIAN) += -mlittle-endian aflags-$(CONFIG_CPU_BIG_ENDIAN) += $(call cc-option,-mbig-endian) aflags-$(CONFIG_CPU_LITTLE_ENDIAN) += -mlittle-endian ifeq ($(HAS_BIARCH),y) -override AS += -a$(BITS) -override LD += -m elf$(BITS)$(LDEMULATION) -override CC += -m$(BITS) +KBUILD_CFLAGS += -m$(BITS) +KBUILD_AFLAGS += -m$(BITS) -Wl,-a$(BITS) +LDFLAGS += -m elf$(BITS)$(LDEMULATION) KBUILD_ARFLAGS += --target=elf$(BITS)-$(GNUTARGET) endif diff --git a/arch/powerpc/tools/gcc-check-mprofile-kernel.sh b/arch/powerpc/tools/gcc-check-mprofile-kernel.sh index 061f8035bdbe..a7dd0e5d9f98 100755 --- a/arch/powerpc/tools/gcc-check-mprofile-kernel.sh +++ b/arch/powerpc/tools/gcc-check-mprofile-kernel.sh @@ -7,17 +7,21 @@ set -o pipefail # To debug, uncomment the following line # set -x +# -mprofile-kernel is only supported on 64le, so this should not be invoked +# for other targets. Therefore we can pass in -m64 and -mlittle-endian +# explicitly, to take care of toolchains defaulting to other targets. + # Test whether the compile option -mprofile-kernel exists and generates # profiling code (ie. a call to _mcount()). echo "int func() { return 0; }" | \ - $* -S -x c -O2 -p -mprofile-kernel - -o - 2> /dev/null | \ - grep -q "_mcount" + $* -m64 -mlittle-endian -S -x c -O2 -p -mprofile-kernel - -o - \ + 2> /dev/null | grep -q "_mcount" # Test whether the notrace attribute correctly suppresses calls to _mcount(). echo -e "#include \nnotrace int func() { return 0; }" | \ - $* -S -x c -O2 -p -mprofile-kernel - -o - 2> /dev/null | \ - grep -q "_mcount" && \ + $* -m64 -mlittle-endian -S -x c -O2 -p -mprofile-kernel - -o - \ + 2> /dev/null | grep -q "_mcount" && \ exit 1 echo "OK" diff --git a/scripts/recordmcount.pl b/scripts/recordmcount.pl index 191eb949d52c..fe06e77c15eb 100755 --- a/scripts/recordmcount.pl +++ b/scripts/recordmcount.pl @@ -266,13 +266,29 @@ if ($arch eq "x86_64") { $objcopy .= " -O elf32-sh-linux"; } elsif ($arch eq "powerpc") { + my $ldemulation; + $local_regex = "^[0-9a-fA-F]+\\s+t\\s+(\\.?\\S+)"; # See comment in the sparc64 section for why we use '\w'. $function_regex = "^([0-9a-fA-F]+)\\s+<(\\.?\\w*?)>:"; $mcount_regex = "^\\s*([0-9a-fA-F]+):.*\\s\\.?_mcount\$"; + if ($endian eq "big") { + $cc .= " -mbig-endian "; + $ld .= " -EB "; + $ldemulation = "ppc" + } else { + $cc .= " -mlittle-endian "; + $ld .= " -EL "; + $ldemulation = "lppc" + } if ($bits == 64) { - $type = ".quad"; + $type = ".quad"; + $cc .= " -m64 "; + $ld .= " -m elf64".$ldemulation." "; + } else { + $cc .= " -m32 "; + $ld .= " -m elf32".$ldemulation." "; } } elsif ($arch eq "arm") {