lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAK7LNASRj_+N-MJ8nqLPqwOG2XyRcvvesPRUOoHxwoKJFE1NcQ@mail.gmail.com>
Date:   Fri, 22 Jul 2022 13:38:23 +0900
From:   Masahiro Yamada <masahiroy@...nel.org>
To:     Dimitri John Ledkov <dimitri.ledkov@...onical.com>
Cc:     Michal Marek <michal.lkml@...kovi.net>,
        Nick Desaulniers <ndesaulniers@...gle.com>,
        Linux Kbuild mailing list <linux-kbuild@...r.kernel.org>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
        Nathan Chancellor <nathan@...nel.org>,
        Tom Rix <trix@...hat.com>
Subject: Re: [PATCH] kbuild: introduce $(GCC) variable for path-prefix or version-suffix

On Wed, Jul 20, 2022 at 9:41 PM Dimitri John Ledkov
<dimitri.ledkov@...onical.com> wrote:
>
> Introduce $(GCC) variable with similar semantics to $(LLVM) for
> setting path-prefix or version-suffix.
>
> Currently to correctly and consistently use gcc-10 on Ubuntu 20.04
> LTS, to cross compile a kernel one has to do:
>
> $ make ... CROSS_COMPILE=riscv64-linux-gnu- \
>            CC=riscv64-linux-gnu-gcc-10 \
>            HOSTCC=gcc-10 \
>            HOSTCXX=g++-10


I think this way is enough.




> With this change
>
> $ make ... CROSS_COMPILE=riscv64-linux-gnu- GCC=-10
>
> is sufficient to correctly select a consistent CC/HOSTCC/HOSTCXX set.


LLVM=-13 is useful to switch all tools in the LLVM suite
such as clang-13, ld.lld-13, llvm-ar-13, etc.



When you use GCC, the other tools come from binutils.

Also, I tend to think CC and HOSTCC/HOSTCXX are different groups.
There is no strong reason for the target GCC and the host GCC
must be the same version.

You can set CC, HOSTCC, HOSTCXX indivudually.


>
> Similarly GCC=/path/to/unpacked/toolchains/ can be used to select
> toolchain outside of PATH.

I think CROSS_COMPILE=/path/to/unpacked/toolchains/ is more common
because gcc and binutils are usually bundled together.




Overall, I do not think GCC= is so useful.
(at least not so useful as LLVM= syntax)





>
> Update documentation for LLVM variable, and mention that GCC variable
> can be used in a similar fashion to set path-prefix, or
> version-suffix.
>
> Signed-off-by: Dimitri John Ledkov <dimitri.ledkov@...onical.com>
> ---
>  Documentation/kbuild/kbuild.rst | 12 ++++++++++--
>  Makefile                        | 12 +++++++++---
>  tools/testing/selftests/lib.mk  |  2 +-
>  3 files changed, 20 insertions(+), 6 deletions(-)
>
> diff --git a/Documentation/kbuild/kbuild.rst b/Documentation/kbuild/kbuild.rst
> index ef19b9c13523..6382b082018e 100644
> --- a/Documentation/kbuild/kbuild.rst
> +++ b/Documentation/kbuild/kbuild.rst
> @@ -276,5 +276,13 @@ whoami and host, respectively.
>
>  LLVM
>  ----
> -If this variable is set to 1, Kbuild will use Clang and LLVM utilities instead
> -of GCC and GNU binutils to build the kernel.
> +If this variable is set to 1, Kbuild will use Clang and LLVM utilities
> +instead of GCC and GNU binutils to build the kernel. It can also be
> +used to set a path prefix, or a version suffix, see "Building
> +Linux with Clang/LLVM".
> +
> +GCC
> +---
> +This variable can be used similar to LLVM variable above to set a path
> +prefix, or a version suffix for GNU Toolchain binaries. See examples
> +in "Building Linux with Clang/LLVM".
> diff --git a/Makefile b/Makefile
> index 00fd80c5dd6e..e7bd0b572b14 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -433,8 +433,14 @@ endif
>  HOSTCC = $(LLVM_PREFIX)clang$(LLVM_SUFFIX)
>  HOSTCXX        = $(LLVM_PREFIX)clang++$(LLVM_SUFFIX)
>  else
> -HOSTCC = gcc
> -HOSTCXX        = g++
> +ifneq ($(filter %/,$(GCC)),)
> +GCC_PREFIX := $(GCC)
> +else ifneq ($(filter -%,$(GCC)),)
> +GCC_SUFFIX := $(GCC)
> +endif
> +
> +HOSTCC = $(GCC_PREFIX)gcc$(GCC_SUFFIX)
> +HOSTCXX        = $(GCC_PREFIX)g++$(GCC_SUFFIX)
>  endif
>  HOSTPKG_CONFIG = pkg-config
>
> @@ -461,7 +467,7 @@ OBJDUMP             = $(LLVM_PREFIX)llvm-objdump$(LLVM_SUFFIX)
>  READELF                = $(LLVM_PREFIX)llvm-readelf$(LLVM_SUFFIX)
>  STRIP          = $(LLVM_PREFIX)llvm-strip$(LLVM_SUFFIX)
>  else
> -CC             = $(CROSS_COMPILE)gcc
> +CC             = $(GCC_PREFIX)$(CROSS_COMPILE)gcc$(GCC_SUFFIX)
>  LD             = $(CROSS_COMPILE)ld
>  AR             = $(CROSS_COMPILE)ar
>  NM             = $(CROSS_COMPILE)nm
> diff --git a/tools/testing/selftests/lib.mk b/tools/testing/selftests/lib.mk
> index 1a5cc3cd97ec..777757d54f42 100644
> --- a/tools/testing/selftests/lib.mk
> +++ b/tools/testing/selftests/lib.mk
> @@ -30,7 +30,7 @@ endif # CROSS_COMPILE
>
>  CC := $(LLVM_PREFIX)clang$(LLVM_SUFFIX) $(CLANG_FLAGS) -fintegrated-as
>  else
> -CC := $(CROSS_COMPILE)gcc
> +CC := $(GCC_PREFIX)$(CROSS_COMPILE)gcc$(GCC_SUFFIX)
>  endif # LLVM
>
>  ifeq (0,$(MAKELEVEL))
> --
> 2.34.1
>


--
Best Regards

Masahiro Yamada

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ