linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Masahiro Yamada <yamada.masahiro@socionext.com>
To: Nicholas Piggin <npiggin@gmail.com>
Cc: Linux Kbuild mailing list <linux-kbuild@vger.kernel.org>,
	linuxppc-dev <linuxppc-dev@lists.ozlabs.org>,
	Segher Boessenkool <segher@kernel.crashing.org>
Subject: Re: [PATCH v5 3/4] powerpc/kbuild: Use flags variables rather than overriding LD/CC/AS
Date: Wed, 30 May 2018 23:34:09 +0900	[thread overview]
Message-ID: <CAK7LNASXBa5ATT6nx5bcvH1LCQFR--VJJXXZeoOXBc9TAAfOLA@mail.gmail.com> (raw)
In-Reply-To: <20180530121922.22122-4-npiggin@gmail.com>

2018-05-30 21:19 GMT+09:00 Nicholas Piggin <npiggin@gmail.com>:
> 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 thse flags
> works for this purpose.

When I applied this patch, I changed the following.

"the the" -> "the"
"thse" -> "these"


Please let me know if my fix-up is bad.






> Unfortunately that is not compatible with the way the proposed new
> Kconfig macro language will work.
>
> After previous patches in this series, these flags can be carefully
> passed in using flags instead.
>
> Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
>
> Since v1: removed extra -EB in the recordmcount script (thanks mpe)
> ---
>  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 <linux/compiler.h>\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") {
> --
> 2.17.0
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html



-- 
Best Regards
Masahiro Yamada

  reply	other threads:[~2018-05-30 14:35 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-30 12:19 [PATCH v5 0/4] powerpc patches for new Kconfig language Nicholas Piggin
2018-05-30 12:19 ` [PATCH v5 1/4] powerpc/kbuild: set default generic machine type for 32-bit compile Nicholas Piggin
2018-05-30 14:30   ` Masahiro Yamada
2018-05-30 14:32   ` Masahiro Yamada
2018-06-04 14:11   ` [v5, " Michael Ellerman
2018-05-30 12:19 ` [PATCH v5 2/4] powerpc/kbuild: remove CROSS32 defines from top level powerpc Makefile Nicholas Piggin
2018-06-04 14:11   ` [v5, " Michael Ellerman
2018-05-30 12:19 ` [PATCH v5 3/4] powerpc/kbuild: Use flags variables rather than overriding LD/CC/AS Nicholas Piggin
2018-05-30 14:34   ` Masahiro Yamada [this message]
2018-06-04 14:11   ` [v5, " Michael Ellerman
2018-05-30 12:19 ` [PATCH v5 4/4] powerpc/kbuild: move -mprofile-kernel check to Kconfig Nicholas Piggin
2018-05-30 14:39 ` [PATCH v5 0/4] powerpc patches for new Kconfig language Michael Ellerman
2018-05-30 14:57   ` Masahiro Yamada
2018-05-31  4:31     ` Michael Ellerman
2018-05-31  5:00       ` Masahiro Yamada
2018-05-31 11:51         ` Michael Ellerman
2018-05-31 13:08           ` Masahiro Yamada
2018-06-01 10:34             ` Michael Ellerman
2018-06-01 10:51               ` Masahiro Yamada
2018-06-01 13:22                 ` Michael Ellerman
2018-06-02  4:53                   ` Nicholas Piggin

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=CAK7LNASXBa5ATT6nx5bcvH1LCQFR--VJJXXZeoOXBc9TAAfOLA@mail.gmail.com \
    --to=yamada.masahiro@socionext.com \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=npiggin@gmail.com \
    --cc=segher@kernel.crashing.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).