Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH] support/bootlin-toolchains: don't depend on non-existent gcc version
@ 2023-10-07 20:57 Yann E. MORIN
  2023-10-08  9:32 ` Arnout Vandecappelle via buildroot
  0 siblings, 1 reply; 3+ messages in thread
From: Yann E. MORIN @ 2023-10-07 20:57 UTC (permalink / raw)
  To: buildroot; +Cc: Yann E. MORIN, Vincent Fazio

Commit a0d2a5cfec0a (support/scripts/gen-bootlin-toolchains: generate
BR2_ARCH_NEEDS_GCC_AT_LEAST_X guard) added a negative dependency to the
gcc version required by the configured architecture.

However, when the toolchain is using the latest gcc version currently
known to Buildroot, this generates a dependency on a non-existing gcc
version. For example, a toolchain using gcc 13, the most recent version
currently known to Buildroot, this would generate a dependency against
BR2_ARCH_NEEDS_GCC_AT_LEAST_14, which does not exist yet.

This dependency is in practice a no-op, because the symbol is missing,
so Kconfig evaluates it to false, and since it is negated, the
dependency is fulfilled. Still, this is spurious and semantically
incorrect.

We fix that by extracting the most recent gcc version that an
architecture may require, and use that to decide whether the guard is
needed for the toolchain.

Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
Cc: Vincent Fazio <vfazio@xes-inc.com>
---
 support/scripts/gen-bootlin-toolchains | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)

diff --git a/support/scripts/gen-bootlin-toolchains b/support/scripts/gen-bootlin-toolchains
index 4344221213..3b5f65515d 100755
--- a/support/scripts/gen-bootlin-toolchains
+++ b/support/scripts/gen-bootlin-toolchains
@@ -305,7 +305,7 @@ class Toolchain:
         return os.path.join(BASE_URL, self.arch, "fragments",
                             self.fname_prefix + ".frag")
 
-    def gen_config_in_options(self, f):
+    def gen_config_in_options(self, f, latest_gcc):
         f.write("config %s\n" % self.option_name)
         f.write("\tbool \"%s %s %s %s\"\n" %
                 (self.arch, self.libc, self.variant, self.version))
@@ -339,7 +339,8 @@ class Toolchain:
                 assert m, "Cannot get gcc version for toolchain %s" % self.fname_prefix
                 selects.append("BR2_TOOLCHAIN_GCC_AT_LEAST_%s" % m[1])
                 # respect the GCC requirement for the selected CPU/arch tuning
-                depends.append("!BR2_ARCH_NEEDS_GCC_AT_LEAST_%s" % str(int(m[1]) + 1))
+                if int(m[1]) + 1 <= latest_gcc:
+                    depends.append("!BR2_ARCH_NEEDS_GCC_AT_LEAST_%s" % str(int(m[1]) + 1))
 
             # kernel headers version
             if frag.startswith("BR2_TOOLCHAIN_EXTERNAL_HEADERS_"):
@@ -462,6 +463,17 @@ class Toolchain:
             (self.arch, self.libc, self.variant, self.version, self.option_name)
 
 
+def get_latest_gcc():
+    match = "config BR2_ARCH_NEEDS_GCC_AT_LEAST_"
+    with open("arch/Config.in", "r") as f:
+        latest = sorted([
+            int(line[len(match):].strip().split("_")[0])
+            for line in f.readlines()
+            if line.startswith(match)
+        ])[-1]
+    return latest
+
+
 def get_toolchains():
     toolchains = list()
     for arch, details in arches.items():
@@ -494,6 +506,7 @@ def get_toolchains():
 
 
 def gen_config_in_options(toolchains, fpath):
+    latest_gcc = get_latest_gcc()
     with open(fpath, "w") as f:
         f.write(AUTOGENERATED_COMMENT)
 
@@ -520,7 +533,7 @@ def gen_config_in_options(toolchains, fpath):
         f.write("\tprompt \"Bootlin toolchain variant\"\n")
 
         for toolchain in toolchains:
-            toolchain.gen_config_in_options(f)
+            toolchain.gen_config_in_options(f, latest_gcc)
 
         f.write("endchoice\n")
         f.write("endif\n")
-- 
2.25.1

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-11-08 22:05 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-07 20:57 [Buildroot] [PATCH] support/bootlin-toolchains: don't depend on non-existent gcc version Yann E. MORIN
2023-10-08  9:32 ` Arnout Vandecappelle via buildroot
2023-11-08 22:05   ` Thomas Petazzoni via buildroot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox