* [PATCH 1/4] sandbox: make CC_HAS_LINUX_I386_SUPPORT depend on GCC
@ 2025-02-17 10:46 Ahmad Fatoum
2025-02-17 10:46 ` [PATCH 2/4] Makefile: clang: fix typo in -Wno-typdef-redefinition flag Ahmad Fatoum
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Ahmad Fatoum @ 2025-02-17 10:46 UTC (permalink / raw)
To: barebox; +Cc: Ahmad Fatoum
CC_HAS_LINUX_I386_SUPPORT enables build for 32-bit with a 64-bit GCC
toolchain. This seems not to work correctly on clang:
CC arch/sandbox/os/common.o
In file included from arch/sandbox/os/common.c:23:
In file included from /usr/lib/llvm-16/lib/clang/16/include/limits.h:21:
/usr/include/limits.h:26:10: fatal error:
'bits/libc-header-start.h' file not found
#include <bits/libc-header-start.h>
So disable it for now.
Fixes: f41c4d7c5649 ("Makefile: add LLVM/clang support")
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
arch/sandbox/Kconfig | 1 +
1 file changed, 1 insertion(+)
diff --git a/arch/sandbox/Kconfig b/arch/sandbox/Kconfig
index 0b6cc75098be..c1a51d4f021d 100644
--- a/arch/sandbox/Kconfig
+++ b/arch/sandbox/Kconfig
@@ -40,6 +40,7 @@ config CC_IS_64BIT
config CC_HAS_LINUX_I386_SUPPORT
def_bool $(cc-option,-m32) && $(ld-option,-m elf_i386)
+ depends on CC_IS_GCC
config 64BIT
bool
--
2.39.5
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 2/4] Makefile: clang: fix typo in -Wno-typdef-redefinition flag
2025-02-17 10:46 [PATCH 1/4] sandbox: make CC_HAS_LINUX_I386_SUPPORT depend on GCC Ahmad Fatoum
@ 2025-02-17 10:46 ` Ahmad Fatoum
2025-02-17 10:46 ` [PATCH 3/4] kbuild: actually include Makefile.clang for clang builds Ahmad Fatoum
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Ahmad Fatoum @ 2025-02-17 10:46 UTC (permalink / raw)
To: barebox; +Cc: Ahmad Fatoum
The file was not used so far, so the typo wasn't noticed. A later
commit is going to change that, so prepare for it by fixing the typo.
Fixes: f41c4d7c5649 ("Makefile: add LLVM/clang support")
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
scripts/Makefile.clang | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scripts/Makefile.clang b/scripts/Makefile.clang
index c0302ff82670..874110ea83ad 100644
--- a/scripts/Makefile.clang
+++ b/scripts/Makefile.clang
@@ -1,5 +1,5 @@
# SPDX-License-Identifier: GPL-2.0-only
-CLANG_FLAGS += -Wno-typdef-redefinition
+CLANG_FLAGS += -Wno-typedef-redefinition
CLANG_FLAGS += -Werror=unknown-warning-option
CLANG_FLAGS += -Werror=ignored-optimization-argument
CLANG_FLAGS += -Werror=option-ignored
--
2.39.5
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 3/4] kbuild: actually include Makefile.clang for clang builds
2025-02-17 10:46 [PATCH 1/4] sandbox: make CC_HAS_LINUX_I386_SUPPORT depend on GCC Ahmad Fatoum
2025-02-17 10:46 ` [PATCH 2/4] Makefile: clang: fix typo in -Wno-typdef-redefinition flag Ahmad Fatoum
@ 2025-02-17 10:46 ` Ahmad Fatoum
2025-02-17 10:46 ` [PATCH 4/4] Makefile: clang: fail non-sandbox LLVM builds early Ahmad Fatoum
2025-02-17 11:19 ` [PATCH 1/4] sandbox: make CC_HAS_LINUX_I386_SUPPORT depend on GCC Sascha Hauer
3 siblings, 0 replies; 5+ messages in thread
From: Ahmad Fatoum @ 2025-02-17 10:46 UTC (permalink / raw)
To: barebox; +Cc: Ahmad Fatoum
Makefile.clang is included depending on CONFIG_CC_IS_CLANG, but its
location in the Makefile was before the config variables are included.
Instead of moving it farther down and risk it being included too late,
let's do as Linux does and consult CC_VERSION_TEXT instead of any
config variables.
Fixes: f41c4d7c5649 ("Makefile: add LLVM/clang support")
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
Makefile | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/Makefile b/Makefile
index b5a7d0b9918b..a80e1b60d534 100644
--- a/Makefile
+++ b/Makefile
@@ -563,7 +563,13 @@ ifdef building_out_of_srctree
{ echo "# this is build directory, ignore it"; echo "*"; } > .gitignore
endif
-ifeq ($(CONFIG_CC_IS_CLANG),y)
+# The expansion should be delayed until arch/$(SRCARCH)/Makefile is included.
+# Some architectures define CROSS_COMPILE in arch/$(SRCARCH)/Makefile.
+# CC_VERSION_TEXT is referenced from Kconfig (so it needs export),
+# and from include/config/auto.conf.cmd to detect the compiler upgrade.
+CC_VERSION_TEXT = $(subst $(pound),,$(shell LC_ALL=C $(CC) --version 2>/dev/null | head -n 1))
+
+ifneq ($(findstring clang,$(CC_VERSION_TEXT)),)
include $(srctree)/scripts/Makefile.clang
endif
@@ -578,7 +584,7 @@ include $(srctree)/scripts/Makefile.defconf
# KBUILD_DEFCONFIG may point out an alternative default configuration
# used for 'make defconfig'
include $(srctree)/arch/$(SRCARCH)/Makefile
-export KBUILD_DEFCONFIG
+export KBUILD_DEFCONFIG CC_VERSION_TEXT
config: outputmakefile scripts_basic FORCE
$(Q)$(MAKE) $(build)=scripts/kconfig $@
--
2.39.5
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 4/4] Makefile: clang: fail non-sandbox LLVM builds early
2025-02-17 10:46 [PATCH 1/4] sandbox: make CC_HAS_LINUX_I386_SUPPORT depend on GCC Ahmad Fatoum
2025-02-17 10:46 ` [PATCH 2/4] Makefile: clang: fix typo in -Wno-typdef-redefinition flag Ahmad Fatoum
2025-02-17 10:46 ` [PATCH 3/4] kbuild: actually include Makefile.clang for clang builds Ahmad Fatoum
@ 2025-02-17 10:46 ` Ahmad Fatoum
2025-02-17 11:19 ` [PATCH 1/4] sandbox: make CC_HAS_LINUX_I386_SUPPORT depend on GCC Sascha Hauer
3 siblings, 0 replies; 5+ messages in thread
From: Ahmad Fatoum @ 2025-02-17 10:46 UTC (permalink / raw)
To: barebox; +Cc: Steffen Trumtrar, Ahmad Fatoum
The sandbox architecture is the only architecture so far that has been
validated to build to completion with clang and function correctly
afterwards.
Until other architectures follow suit, fail the build gracefully for them.
Note that in Linux, CLANG_TARGET_FLAGS_sandbox expands to
$(CLANG_TARGET_FLAGS_$(SRCARCH)). This requires that we have support for
non-sandbox architectures in the first place. Until we do, just make it
a no-op by setting CLANG_TARGET_FLAGS to the same target triple that's used
by default anyway.
Reported-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
scripts/Makefile.clang | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/scripts/Makefile.clang b/scripts/Makefile.clang
index 874110ea83ad..7e4dfb8622d3 100644
--- a/scripts/Makefile.clang
+++ b/scripts/Makefile.clang
@@ -1,4 +1,14 @@
# SPDX-License-Identifier: GPL-2.0-only
+
+CLANG_TARGET_FLAGS_sandbox := $(shell $(CC) -print-target-triple)
+CLANG_TARGET_FLAGS := $(CLANG_TARGET_FLAGS_$(SRCARCH))
+
+ifeq ($(CLANG_TARGET_FLAGS),)
+$(error add '--target=' option to scripts/Makefile.clang)
+else
+CLANG_FLAGS += --target=$(CLANG_TARGET_FLAGS)
+endif
+
CLANG_FLAGS += -Wno-typedef-redefinition
CLANG_FLAGS += -Werror=unknown-warning-option
CLANG_FLAGS += -Werror=ignored-optimization-argument
--
2.39.5
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/4] sandbox: make CC_HAS_LINUX_I386_SUPPORT depend on GCC
2025-02-17 10:46 [PATCH 1/4] sandbox: make CC_HAS_LINUX_I386_SUPPORT depend on GCC Ahmad Fatoum
` (2 preceding siblings ...)
2025-02-17 10:46 ` [PATCH 4/4] Makefile: clang: fail non-sandbox LLVM builds early Ahmad Fatoum
@ 2025-02-17 11:19 ` Sascha Hauer
3 siblings, 0 replies; 5+ messages in thread
From: Sascha Hauer @ 2025-02-17 11:19 UTC (permalink / raw)
To: barebox, Ahmad Fatoum
On Mon, 17 Feb 2025 11:46:08 +0100, Ahmad Fatoum wrote:
> CC_HAS_LINUX_I386_SUPPORT enables build for 32-bit with a 64-bit GCC
> toolchain. This seems not to work correctly on clang:
>
> CC arch/sandbox/os/common.o
> In file included from arch/sandbox/os/common.c:23:
> In file included from /usr/lib/llvm-16/lib/clang/16/include/limits.h:21:
> /usr/include/limits.h:26:10: fatal error:
> 'bits/libc-header-start.h' file not found
> #include <bits/libc-header-start.h>
>
> [...]
Applied, thanks!
[1/4] sandbox: make CC_HAS_LINUX_I386_SUPPORT depend on GCC
https://git.pengutronix.de/cgit/barebox/commit/?id=15af5003ba06 (link may not be stable)
[2/4] Makefile: clang: fix typo in -Wno-typdef-redefinition flag
https://git.pengutronix.de/cgit/barebox/commit/?id=35309a815da3 (link may not be stable)
[3/4] kbuild: actually include Makefile.clang for clang builds
https://git.pengutronix.de/cgit/barebox/commit/?id=c5370032370a (link may not be stable)
[4/4] Makefile: clang: fail non-sandbox LLVM builds early
https://git.pengutronix.de/cgit/barebox/commit/?id=aaea175ad00f (link may not be stable)
Best regards,
--
Sascha Hauer <s.hauer@pengutronix.de>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-02-17 11:19 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-02-17 10:46 [PATCH 1/4] sandbox: make CC_HAS_LINUX_I386_SUPPORT depend on GCC Ahmad Fatoum
2025-02-17 10:46 ` [PATCH 2/4] Makefile: clang: fix typo in -Wno-typdef-redefinition flag Ahmad Fatoum
2025-02-17 10:46 ` [PATCH 3/4] kbuild: actually include Makefile.clang for clang builds Ahmad Fatoum
2025-02-17 10:46 ` [PATCH 4/4] Makefile: clang: fail non-sandbox LLVM builds early Ahmad Fatoum
2025-02-17 11:19 ` [PATCH 1/4] sandbox: make CC_HAS_LINUX_I386_SUPPORT depend on GCC Sascha Hauer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox