Skip to contentSkip to conversation

kbuild: Fix CC_CAN_LINK detection

PATCH In review Mickaël Salaün 4 participants 5 messages Feb 12 – Feb 18

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kbuild: Fix CC_CAN_LINK detection

Most samples cannot be build on some environments because they depend on CC_CAN_LINK, which is set according to the result of scripts/cc-can-link.sh called by cc_can_link_user.

Because cc-can-link.sh must now build without warning, it may fail because it is calling printf() with an empty string:

+ cat
+ gcc -m32 -Werror -Wl,--fatal-warnings -x c - -o /dev/null
<stdin>: In function ‘main’:
<stdin>:4:9: error: zero-length gnu_printf format string [-Werror=format-zero-length]
cc1: all warnings being treated as errors

Fix this warning and the samples build by actually printing something.

Cc Nathan Chancellor <[email protected]>
Cc Nicolas Schier <[email protected]>
Cc Thomas Weißschuh <[email protected]>
Fixes d81d9d389b9b ("kbuild: don't enable CC_CAN_LINK if the dummy program generates warnings")
---
 scripts/cc-can-link.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/cc-can-link.sh +1 -1
index e67fd8d7b684..58dc7dd6d556 100755
@@ -5,7 +5,7 @@ cat << "END" | $@ -Werror -Wl,--fatal-warnings -x c - -o /dev/null >/dev/null 2>
 #include <stdio.h>
 int main(void)
 {
-	printf("");
+	printf("\n");
 	return 0;
 }
 END
Signature · 1 line
2.53.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 13 lines · Mickaël Salaün

Most samples cannot be build on some environments because they depend on CC_CAN_LINK, which is set according to the result of scripts/cc-can-link.sh called by cc_can_link_user.

Because cc-can-link.sh must now build without warning, it may fail because it is calling printf() with an empty string:

+ cat
+ gcc -m32 -Werror -Wl,--fatal-warnings -x c - -o /dev/null
<stdin>: In function ‘main’:
<stdin>:4:9: error: zero-length gnu_printf format string [-Werror=format-zero-length]
cc1: all warnings being treated as errors

Quoted 7 lines

Fix this warning and the samples build by actually printing something.

Cc Nathan Chancellor <[email protected]>
Cc Nicolas Schier <[email protected]>
Cc Thomas Weißschuh <[email protected]>
Fixes d81d9d389b9b ("kbuild: don't enable CC_CAN_LINK if the dummy program generates warnings")

Thanks!

In my GCC 15.2 this warning is not enabled by default.

Quoted 21 lines
---
 scripts/cc-can-link.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/cc-can-link.sh +1 -1
index e67fd8d7b684..58dc7dd6d556 100755
@@ -5,7 +5,7 @@ cat << "END" | $@ -Werror -Wl,--fatal-warnings -x c - -o /dev/null >/dev/null 2>
 #include <stdio.h>
 int main(void)
 {
-	printf("");
+	printf("\n");
 	return 0;
 }
 END
Signature · 1 line
2.53.0
#2 lore raw
Quoted 22 lines · Thomas Weißschuh
Quoted 13 lines · Mickaël Salaün

Most samples cannot be build on some environments because they depend on CC_CAN_LINK, which is set according to the result of scripts/cc-can-link.sh called by cc_can_link_user.

Because cc-can-link.sh must now build without warning, it may fail because it is calling printf() with an empty string:

+ cat
+ gcc -m32 -Werror -Wl,--fatal-warnings -x c - -o /dev/null
<stdin>: In function ‘main’:
<stdin>:4:9: error: zero-length gnu_printf format string [-Werror=format-zero-length]
cc1: all warnings being treated as errors

Quoted 7 lines

Fix this warning and the samples build by actually printing something.

Cc Nathan Chancellor <[email protected]>
Cc Nicolas Schier <[email protected]>
Cc Thomas Weißschuh <[email protected]>
Fixes d81d9d389b9b ("kbuild: don't enable CC_CAN_LINK if the dummy program generates warnings")
Quoted 5 lines

Thanks!

In my GCC 15.2 this warning is not enabled by default.

Some for me, but it is the case with GCC 13.3.0 on Ubuntu 24 LTS.

Quoted 22 lines
Quoted 22 lines
---
 scripts/cc-can-link.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/cc-can-link.sh +1 -1
index e67fd8d7b684..58dc7dd6d556 100755
@@ -5,7 +5,7 @@ cat << "END" | $@ -Werror -Wl,--fatal-warnings -x c - -o /dev/null >/dev/null 2>
 #include <stdio.h>
 int main(void)
 {
-	printf("");
+	printf("\n");
 	return 0;
 }
 END
Signature · 1 line
2.53.0
maintainer Reviewed-by on v1 1/1
#3 lore raw
In reply to Mickaël Salaün
Quoted 21 lines · Mickaël Salaün

Most samples cannot be build on some environments because they depend on CC_CAN_LINK, which is set according to the result of scripts/cc-can-link.sh called by cc_can_link_user.

Because cc-can-link.sh must now build without warning, it may fail because it is calling printf() with an empty string:

+ cat
+ gcc -m32 -Werror -Wl,--fatal-warnings -x c - -o /dev/null
<stdin>: In function ‘main’:
<stdin>:4:9: error: zero-length gnu_printf format string [-Werror=format-zero-length]
cc1: all warnings being treated as errors

Fix this warning and the samples build by actually printing something.

Cc Nathan Chancellor <[email protected]>
Cc Nicolas Schier <[email protected]>
Cc Thomas Weißschuh <[email protected]>
Fixes d81d9d389b9b ("kbuild: don't enable CC_CAN_LINK if the dummy program generates warnings")
Quoted 4 lines
---
 scripts/cc-can-link.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Thanks!

#4 lore raw
In reply to Mickaël Salaün
Quoted 8 lines · Mickaël Salaün

Most samples cannot be build on some environments because they depend on CC_CAN_LINK, which is set according to the result of scripts/cc-can-link.sh called by cc_can_link_user.

Because cc-can-link.sh must now build without warning, it may fail because it is calling printf() with an empty string:

[...]

Applied to

https://git.kernel.org/pub/scm/linux/kernel/git/kbuild/linux.git kbuild-fixes

Thanks!

[1/1] kbuild: Fix CC_CAN_LINK detection

      https://git.kernel.org/kbuild/c/be55899b71630

Please look out for regression or issue reports or other follow up comments, as they may result in the patch/series getting dropped or reverted. Patches applied to an "unstable" branch are accepted pending wider testing in -next and any post-commit review; they will generally be moved to the main branch in a week if no issues are found.

Best regards,

Signature · 1 line
Nathan Chancellor <[email protected]>