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-next>] [day] [month] [year] [list]
Message-Id: <20220720124137.151714-1-dimitri.ledkov@canonical.com>
Date:   Wed, 20 Jul 2022 13:41:37 +0100
From:   Dimitri John Ledkov <dimitri.ledkov@...onical.com>
To:     masahiroy@...nel.org, michal.lkml@...kovi.net,
        ndesaulniers@...gle.com
Cc:     linux-kbuild@...r.kernel.org, linux-kernel@...r.kernel.org,
        nathan@...nel.org, trix@...hat.com
Subject: [PATCH] kbuild: introduce $(GCC) variable for path-prefix or version-suffix

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

With this change

$ make ... CROSS_COMPILE=riscv64-linux-gnu- GCC=-10

is sufficient to correctly select a consistent CC/HOSTCC/HOSTCXX set.

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

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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ