Starting with kernel>=v5.7 the build system can override the
tools vars by setting LLVM=1 [1], but older kernels still use
the default GNU tools, so to be able to use a full LLVM/Clang
build, CC should be set together with AR to the portage set
values.
Doing this avoids situations like building the kernel with
clang (using the set HOSTCC) but using gcc/gnu-ar for headers.
[1] a0d1c951ef08 kbuild: support LLVM=1 to switch the default tools to Clang/LLVM
Co-authored-by: Manoj Gupta <manojgupta@chromium.org>
Signed-off-by: Adrian Ratiu <adrian.ratiu@collabora.com>
---
eclass/kernel-2.eclass | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/eclass/kernel-2.eclass b/eclass/kernel-2.eclass
index adc1425bc2e..caeec86ff59 100644
--- a/eclass/kernel-2.eclass
+++ b/eclass/kernel-2.eclass
@@ -692,7 +692,7 @@ env_setup_xmakeopts() {
elif type -p ${CHOST}-ar >/dev/null; then
xmakeopts="${xmakeopts} CROSS_COMPILE=${CHOST}-"
fi
- xmakeopts="${xmakeopts} HOSTCC=$(tc-getBUILD_CC)"
+ xmakeopts="${xmakeopts} HOSTCC=$(tc-getBUILD_CC) CC=$(tc-getCC) AR=$(tc-getAR)" export xmakeopts
}
On Thursday, 16 December 2021 3:58:26 AM NZDT Adrian Ratiu wrote:be clang, icc, or something else
Starting with kernel>=v5.7 the build system can override the
tools vars by setting LLVM=1 [1], but older kernels still use
the default GNU tools, so to be able to use a full LLVM/Clang
build, CC should be set together with AR to the portage set
values.
Doing this avoids situations like building the kernel with
clang (using the set HOSTCC) but using gcc/gnu-ar for headers.
[1] a0d1c951ef08 kbuild: support LLVM=1 to switch the default tools to Clang/LLVM
Co-authored-by: Manoj Gupta <manojgupta@chromium.org>
Signed-off-by: Adrian Ratiu <adrian.ratiu@collabora.com>
---
eclass/kernel-2.eclass | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/eclass/kernel-2.eclass b/eclass/kernel-2.eclass
index adc1425bc2e..caeec86ff59 100644
--- a/eclass/kernel-2.eclass
+++ b/eclass/kernel-2.eclass
@@ -692,7 +692,7 @@ env_setup_xmakeopts() {
elif type -p ${CHOST}-ar >/dev/null; then
xmakeopts="${xmakeopts} CROSS_COMPILE=${CHOST}-"
fi
- xmakeopts="${xmakeopts} HOSTCC=$(tc-getBUILD_CC)"
+ xmakeopts="${xmakeopts} HOSTCC=$(tc-getBUILD_CC) CC=$(tc-getCC) AR=$(tc-getAR)" export xmakeopts
}
What's the reason for not using $LLVM here? To preserve building with
clang
for kernels < 5.7 ?
I might be missing the point, but wouldn't something along the lines of "LLVM=$(! [[ $(tc-getCC) =~ clang ]]; echo $?)" work to preserve the
correct
compiler tools?
This patch is about respecting the current CC value in portage. It could
Cheers
On Wed, 15 Dec 2021 16:58:26 +0200 Adrian Ratiu wrote:
Starting with kernel>=v5.7 the build system can override the
tools vars by setting LLVM=1 [1], but older kernels still use
the default GNU tools, so to be able to use a full LLVM/Clang
build, CC should be set together with AR to the portage set
values.
Doing this avoids situations like building the kernel with
clang (using the set HOSTCC) but using gcc/gnu-ar for headers.
[1] a0d1c951ef08 kbuild: support LLVM=1 to switch the default tools to Clang/LLVM
Co-authored-by: Manoj Gupta <manojgupta@chromium.org>
Signed-off-by: Adrian Ratiu <adrian.ratiu@collabora.com>
---
eclass/kernel-2.eclass | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/eclass/kernel-2.eclass b/eclass/kernel-2.eclass
index adc1425bc2e..caeec86ff59 100644
--- a/eclass/kernel-2.eclass
+++ b/eclass/kernel-2.eclass
@@ -692,7 +692,7 @@ env_setup_xmakeopts() {
elif type -p ${CHOST}-ar >/dev/null; then
xmakeopts="${xmakeopts} CROSS_COMPILE=${CHOST}-"
fi
- xmakeopts="${xmakeopts} HOSTCC=$(tc-getBUILD_CC)"
+ xmakeopts="${xmakeopts} HOSTCC=$(tc-getBUILD_CC) CC=$(tc-getCC) AR=$(tc-getAR)"
OBJDUMP should be exported as well
(e.g. used by scripts/Makefile.build)
export xmakeopts
}
Best regards,
Andrew Savchenko
On Thu, 16 Dec 2021 03:32:10 +0300 Andrew Savchenko wrote:
On Wed, 15 Dec 2021 16:58:26 +0200 Adrian Ratiu wrote:
Starting with kernel>=v5.7 the build system can override theOBJDUMP should be exported as well (e.g. used by
tools vars by setting LLVM=1 [1], but older kernels still use
the default GNU tools, so to be able to use a full LLVM/Clang
build, CC should be set together with AR to the portage set
values. Doing this avoids situations like building the
kernel with clang (using the set HOSTCC) but using gcc/gnu-ar
for headers. [1] a0d1c951ef08 kbuild: support LLVM=1 to
switch the default tools to Clang/LLVM Co-authored-by: Manoj
Gupta <manojgupta@chromium.org> Signed-off-by: Adrian Ratiu
<adrian.ratiu@collabora.com> ---
eclass/kernel-2.eclass | 2 +- 1 file changed, 1
insertion(+), 1 deletion(-)
diff --git a/eclass/kernel-2.eclass b/eclass/kernel-2.eclass
index adc1425bc2e..caeec86ff59 100644 ---
a/eclass/kernel-2.eclass +++ b/eclass/kernel-2.eclass @@
-692,7 +692,7 @@ env_setup_xmakeopts() {
elif type -p ${CHOST}-ar >/dev/null; then
xmakeopts="${xmakeopts} CROSS_COMPILE=${CHOST}-" fi
- xmakeopts="${xmakeopts} HOSTCC=$(tc-getBUILD_CC)" +
xmakeopts="${xmakeopts} HOSTCC=$(tc-getBUILD_CC)
CC=$(tc-getCC) AR=$(tc-getAR)"
scripts/Makefile.build)
And LD as well.
export xmakeopts
}
Best regards,
Andrew Savchenko
Best regards,
Andrew Savchenko
On Thursday, 16 December 2021 3:58:26 AM NZDT Adrian Ratiu
wrote:
Starting with kernel>=v5.7 the build system can override the
tools vars by setting LLVM=1 [1], but older kernels still use
the default GNU tools, so to be able to use a full LLVM/Clang
build, CC should be set together with AR to the portage set
values. Doing this avoids situations like building the kernel
with clang (using the set HOSTCC) but using gcc/gnu-ar for
headers. [1] a0d1c951ef08 kbuild: support LLVM=1 to switch
the default tools to Clang/LLVM Co-authored-by: Manoj Gupta
<manojgupta@chromium.org> Signed-off-by: Adrian Ratiu
<adrian.ratiu@collabora.com> ---
eclass/kernel-2.eclass | 2 +- 1 file changed, 1 insertion(+),
1 deletion(-)
diff --git a/eclass/kernel-2.eclass b/eclass/kernel-2.eclass
index adc1425bc2e..caeec86ff59 100644 ---
a/eclass/kernel-2.eclass +++ b/eclass/kernel-2.eclass @@ -692,7
+692,7 @@ env_setup_xmakeopts() {
elif type -p ${CHOST}-ar >/dev/null; then
xmakeopts="${xmakeopts} CROSS_COMPILE=${CHOST}-" fi
- xmakeopts="${xmakeopts} HOSTCC=$(tc-getBUILD_CC)" +
xmakeopts="${xmakeopts} HOSTCC=$(tc-getBUILD_CC) CC=$(tc-getCC)
AR=$(tc-getAR)" export xmakeopts
}
What's the reason for not using $LLVM here? To preserve building
with clang for kernels < 5.7 ?
I might be missing the point, but wouldn't something along the
lines of "LLVM=$(! [[ $(tc-getCC) =~ clang ]]; echo $?)" work to
preserve the correct compiler tools?
Cheers
Hi Andrew,
On Thu, 16 Dec 2021, Andrew Savchenko <bircoph@gentoo.org> wrote:
On Thu, 16 Dec 2021 03:32:10 +0300 Andrew Savchenko wrote:
On Wed, 15 Dec 2021 16:58:26 +0200 Adrian Ratiu wrote:
Starting with kernel>=v5.7 the build system can override the
tools vars by setting LLVM=1 [1], but older kernels still use
the default GNU tools, so to be able to use a full LLVM/Clang
build, CC should be set together with AR to the portage set
values. Doing this avoids situations like building the
kernel with clang (using the set HOSTCC) but using gcc/gnu-ar
for headers. [1] a0d1c951ef08 kbuild: support LLVM=1 to
switch the default tools to Clang/LLVM Co-authored-by: Manoj
Gupta <manojgupta@chromium.org> Signed-off-by: Adrian Ratiu
<adrian.ratiu@collabora.com> ---
eclass/kernel-2.eclass | 2 +- 1 file changed, 1
insertion(+), 1 deletion(-)
diff --git a/eclass/kernel-2.eclass b/eclass/kernel-2.eclass
index adc1425bc2e..caeec86ff59 100644 ---
a/eclass/kernel-2.eclass +++ b/eclass/kernel-2.eclass @@
-692,7 +692,7 @@ env_setup_xmakeopts() {
elif type -p ${CHOST}-ar >/dev/null; then
xmakeopts="${xmakeopts} CROSS_COMPILE=${CHOST}-" fi
- xmakeopts="${xmakeopts} HOSTCC=$(tc-getBUILD_CC)" +
xmakeopts="${xmakeopts} HOSTCC=$(tc-getBUILD_CC)
CC=$(tc-getCC) AR=$(tc-getAR)"
OBJDUMP should be exported as well (e.g. used by
scripts/Makefile.build)
And LD as well.
Thank you very much for the suggestions!
I only set CC and AR because there were the two which failed in my
testing, but yes, it is a good idea to be prudent and set them all
if nobody is oopposed to it.
I will leave this patch on the ML a bit in case there is more
feedback (it is also EoY season so people might be busy), then I
will send a v3 with the new variables included.
Thanks again,
Adrian
export xmakeopts
}
Best regards,
Andrew Savchenko
Best regards,
Andrew Savchenko
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 286 |
Nodes: | 16 (2 / 14) |
Uptime: | 85:44:42 |
Calls: | 6,495 |
Calls today: | 6 |
Files: | 12,099 |
Messages: | 5,277,029 |