Skip to content

Commit 1723d0c

Browse files
committed
patches: Add wcslen() patch to every tree that needs it
Signed-off-by: Nathan Chancellor <[email protected]>
1 parent fe4844a commit 1723d0c

34 files changed

+937
-0
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
From git@z Thu Jan 1 00:00:00 1970
2+
Subject: [PATCH] kbuild: Add '-fno-builtin-wcslen'
3+
From: Nathan Chancellor <[email protected]>
4+
Date: Mon, 07 Apr 2025 16:22:12 -0700
5+
Message-Id: <[email protected]>
6+
MIME-Version: 1.0
7+
Content-Type: text/plain; charset="utf-8"
8+
Content-Transfer-Encoding: 7bit
9+
10+
A recent optimization change in LLVM [1] aims to transform certain loop
11+
idioms into calls to strlen() or wcslen(). This change transforms the
12+
first while loop in UniStrcat() into a call to wcslen(), breaking the
13+
build when UniStrcat() gets inlined into alloc_path_with_tree_prefix():
14+
15+
ld.lld: error: undefined symbol: wcslen
16+
>>> referenced by nls_ucs2_utils.h:54 (fs/smb/client/../../nls/nls_ucs2_utils.h:54)
17+
>>> vmlinux.o:(alloc_path_with_tree_prefix)
18+
>>> referenced by nls_ucs2_utils.h:54 (fs/smb/client/../../nls/nls_ucs2_utils.h:54)
19+
>>> vmlinux.o:(alloc_path_with_tree_prefix)
20+
21+
Disable this optimization with '-fno-builtin-wcslen', which prevents the
22+
compiler from assuming that wcslen() is available in the kernel's C
23+
library
24+
25+
26+
Link: https://github.com/llvm/llvm-project/commit/9694844d7e36fd5e01011ab56b64f27b867aa72d [1]
27+
Link: https://lore.kernel.org/r/[email protected]
28+
Signed-off-by: Nathan Chancellor <[email protected]>
29+
---
30+
Makefile | 3 +++
31+
1 file changed, 3 insertions(+)
32+
33+
diff --git a/Makefile b/Makefile
34+
index c73255fd9258..de679c70f4e8 100644
35+
--- a/Makefile
36+
+++ b/Makefile
37+
@@ -976,6 +976,9 @@ KBUILD_CFLAGS += $(call cc-option,-Werror=incompatible-pointer-types)
38+
# Require designated initializers for all marked structures
39+
KBUILD_CFLAGS += $(call cc-option,-Werror=designated-init)
40+
41+
+# Ensure compilers do not transform certain loops into calls to wcslen()
42+
+KBUILD_CFLAGS += -fno-builtin-wcslen
43+
+
44+
# change __FILE__ to the relative path from the srctree
45+
KBUILD_CPPFLAGS += $(call cc-option,-fmacro-prefix-map=$(srctree)/=)
46+
47+
---
48+
base-commit: 0af2f6be1b4281385b618cb86ad946eded089ac8
49+
change-id: 20250407-fno-builtin-wcslen-90a858ae7d54
50+
51+
Best regards,
52+
--
53+
Nathan Chancellor <[email protected]>
54+

patches/5.10/series

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
20250407_nathan_kbuild_add_fno_builtin_wcslen.patch
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
From git@z Thu Jan 1 00:00:00 1970
2+
Subject: [PATCH] kbuild: Add '-fno-builtin-wcslen'
3+
From: Nathan Chancellor <[email protected]>
4+
Date: Mon, 07 Apr 2025 16:22:12 -0700
5+
Message-Id: <[email protected]>
6+
MIME-Version: 1.0
7+
Content-Type: text/plain; charset="utf-8"
8+
Content-Transfer-Encoding: 7bit
9+
10+
A recent optimization change in LLVM [1] aims to transform certain loop
11+
idioms into calls to strlen() or wcslen(). This change transforms the
12+
first while loop in UniStrcat() into a call to wcslen(), breaking the
13+
build when UniStrcat() gets inlined into alloc_path_with_tree_prefix():
14+
15+
ld.lld: error: undefined symbol: wcslen
16+
>>> referenced by nls_ucs2_utils.h:54 (fs/smb/client/../../nls/nls_ucs2_utils.h:54)
17+
>>> vmlinux.o:(alloc_path_with_tree_prefix)
18+
>>> referenced by nls_ucs2_utils.h:54 (fs/smb/client/../../nls/nls_ucs2_utils.h:54)
19+
>>> vmlinux.o:(alloc_path_with_tree_prefix)
20+
21+
Disable this optimization with '-fno-builtin-wcslen', which prevents the
22+
compiler from assuming that wcslen() is available in the kernel's C
23+
library
24+
25+
26+
Link: https://github.com/llvm/llvm-project/commit/9694844d7e36fd5e01011ab56b64f27b867aa72d [1]
27+
Link: https://lore.kernel.org/r/[email protected]
28+
Signed-off-by: Nathan Chancellor <[email protected]>
29+
---
30+
Makefile | 3 +++
31+
1 file changed, 3 insertions(+)
32+
33+
diff --git a/Makefile b/Makefile
34+
index 6b3a24466e288..7bb6cfc2f0f13 100644
35+
--- a/Makefile
36+
+++ b/Makefile
37+
@@ -1066,6 +1066,9 @@ KBUILD_CFLAGS += $(call cc-option,-Werror=incompatible-pointer-types)
38+
# Require designated initializers for all marked structures
39+
KBUILD_CFLAGS += $(call cc-option,-Werror=designated-init)
40+
41+
+# Ensure compilers do not transform certain loops into calls to wcslen()
42+
+KBUILD_CFLAGS += -fno-builtin-wcslen
43+
+
44+
# change __FILE__ to the relative path from the srctree
45+
KBUILD_CPPFLAGS += $(call cc-option,-fmacro-prefix-map=$(srctree)/=)
46+
47+
---
48+
base-commit: 0af2f6be1b4281385b618cb86ad946eded089ac8
49+
change-id: 20250407-fno-builtin-wcslen-90a858ae7d54
50+
51+
Best regards,
52+
--
53+
Nathan Chancellor <[email protected]>
54+

patches/5.15/series

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
20250407_nathan_kbuild_add_fno_builtin_wcslen.patch
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
From git@z Thu Jan 1 00:00:00 1970
2+
Subject: [PATCH] kbuild: Add '-fno-builtin-wcslen'
3+
From: Nathan Chancellor <[email protected]>
4+
Date: Mon, 07 Apr 2025 16:22:12 -0700
5+
Message-Id: <[email protected]>
6+
MIME-Version: 1.0
7+
Content-Type: text/plain; charset="utf-8"
8+
Content-Transfer-Encoding: 7bit
9+
10+
A recent optimization change in LLVM [1] aims to transform certain loop
11+
idioms into calls to strlen() or wcslen(). This change transforms the
12+
first while loop in UniStrcat() into a call to wcslen(), breaking the
13+
build when UniStrcat() gets inlined into alloc_path_with_tree_prefix():
14+
15+
ld.lld: error: undefined symbol: wcslen
16+
>>> referenced by nls_ucs2_utils.h:54 (fs/smb/client/../../nls/nls_ucs2_utils.h:54)
17+
>>> vmlinux.o:(alloc_path_with_tree_prefix)
18+
>>> referenced by nls_ucs2_utils.h:54 (fs/smb/client/../../nls/nls_ucs2_utils.h:54)
19+
>>> vmlinux.o:(alloc_path_with_tree_prefix)
20+
21+
Disable this optimization with '-fno-builtin-wcslen', which prevents the
22+
compiler from assuming that wcslen() is available in the kernel's C
23+
library
24+
25+
26+
Link: https://github.com/llvm/llvm-project/commit/9694844d7e36fd5e01011ab56b64f27b867aa72d [1]
27+
Link: https://lore.kernel.org/r/[email protected]
28+
Signed-off-by: Nathan Chancellor <[email protected]>
29+
---
30+
Makefile | 3 +++
31+
1 file changed, 3 insertions(+)
32+
33+
diff --git a/Makefile b/Makefile
34+
index 010b5c1c3cf5..f4c95cc5ed50 100644
35+
--- a/Makefile
36+
+++ b/Makefile
37+
@@ -930,6 +930,9 @@ KBUILD_CFLAGS += $(call cc-option,-Werror=incompatible-pointer-types)
38+
# Require designated initializers for all marked structures
39+
KBUILD_CFLAGS += $(call cc-option,-Werror=designated-init)
40+
41+
+# Ensure compilers do not transform certain loops into calls to wcslen()
42+
+KBUILD_CFLAGS += -fno-builtin-wcslen
43+
+
44+
# change __FILE__ to the relative path from the srctree
45+
KBUILD_CFLAGS += $(call cc-option,-fmacro-prefix-map=$(srctree)/=)
46+
47+
---
48+
base-commit: 0af2f6be1b4281385b618cb86ad946eded089ac8
49+
change-id: 20250407-fno-builtin-wcslen-90a858ae7d54
50+
51+
Best regards,
52+
--
53+
Nathan Chancellor <[email protected]>
54+

patches/5.4/series

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
20250407_nathan_kbuild_add_fno_builtin_wcslen.patch
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
From git@z Thu Jan 1 00:00:00 1970
2+
Subject: [PATCH] kbuild: Add '-fno-builtin-wcslen'
3+
From: Nathan Chancellor <[email protected]>
4+
Date: Mon, 07 Apr 2025 16:22:12 -0700
5+
Message-Id: <[email protected]>
6+
MIME-Version: 1.0
7+
Content-Type: text/plain; charset="utf-8"
8+
Content-Transfer-Encoding: 7bit
9+
10+
A recent optimization change in LLVM [1] aims to transform certain loop
11+
idioms into calls to strlen() or wcslen(). This change transforms the
12+
first while loop in UniStrcat() into a call to wcslen(), breaking the
13+
build when UniStrcat() gets inlined into alloc_path_with_tree_prefix():
14+
15+
ld.lld: error: undefined symbol: wcslen
16+
>>> referenced by nls_ucs2_utils.h:54 (fs/smb/client/../../nls/nls_ucs2_utils.h:54)
17+
>>> vmlinux.o:(alloc_path_with_tree_prefix)
18+
>>> referenced by nls_ucs2_utils.h:54 (fs/smb/client/../../nls/nls_ucs2_utils.h:54)
19+
>>> vmlinux.o:(alloc_path_with_tree_prefix)
20+
21+
Disable this optimization with '-fno-builtin-wcslen', which prevents the
22+
compiler from assuming that wcslen() is available in the kernel's C
23+
library
24+
25+
26+
Link: https://github.com/llvm/llvm-project/commit/9694844d7e36fd5e01011ab56b64f27b867aa72d [1]
27+
Link: https://lore.kernel.org/r/[email protected]
28+
Signed-off-by: Nathan Chancellor <[email protected]>
29+
---
30+
Makefile | 3 +++
31+
1 file changed, 3 insertions(+)
32+
33+
diff --git a/Makefile b/Makefile
34+
index 89742f1246cfb..593149161053d 100644
35+
--- a/Makefile
36+
+++ b/Makefile
37+
@@ -1075,6 +1075,9 @@ KBUILD_CFLAGS += $(call cc-option,-Werror=incompatible-pointer-types)
38+
# Require designated initializers for all marked structures
39+
KBUILD_CFLAGS += $(call cc-option,-Werror=designated-init)
40+
41+
+# Ensure compilers do not transform certain loops into calls to wcslen()
42+
+KBUILD_CFLAGS += -fno-builtin-wcslen
43+
+
44+
# change __FILE__ to the relative path from the srctree
45+
KBUILD_CPPFLAGS += $(call cc-option,-fmacro-prefix-map=$(srctree)/=)
46+
47+
---
48+
base-commit: 0af2f6be1b4281385b618cb86ad946eded089ac8
49+
change-id: 20250407-fno-builtin-wcslen-90a858ae7d54
50+
51+
Best regards,
52+
--
53+
Nathan Chancellor <[email protected]>
54+

patches/6.1/series

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
8b55f8818900c99dd4f55a59a103f5b29e41eb2c.patch
2+
20250407_nathan_kbuild_add_fno_builtin_wcslen.patch
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
From git@z Thu Jan 1 00:00:00 1970
2+
Subject: [PATCH] kbuild: Add '-fno-builtin-wcslen'
3+
From: Nathan Chancellor <[email protected]>
4+
Date: Mon, 07 Apr 2025 16:22:12 -0700
5+
Message-Id: <[email protected]>
6+
MIME-Version: 1.0
7+
Content-Type: text/plain; charset="utf-8"
8+
Content-Transfer-Encoding: 7bit
9+
10+
A recent optimization change in LLVM [1] aims to transform certain loop
11+
idioms into calls to strlen() or wcslen(). This change transforms the
12+
first while loop in UniStrcat() into a call to wcslen(), breaking the
13+
build when UniStrcat() gets inlined into alloc_path_with_tree_prefix():
14+
15+
ld.lld: error: undefined symbol: wcslen
16+
>>> referenced by nls_ucs2_utils.h:54 (fs/smb/client/../../nls/nls_ucs2_utils.h:54)
17+
>>> vmlinux.o:(alloc_path_with_tree_prefix)
18+
>>> referenced by nls_ucs2_utils.h:54 (fs/smb/client/../../nls/nls_ucs2_utils.h:54)
19+
>>> vmlinux.o:(alloc_path_with_tree_prefix)
20+
21+
Disable this optimization with '-fno-builtin-wcslen', which prevents the
22+
compiler from assuming that wcslen() is available in the kernel's C
23+
library
24+
25+
26+
Link: https://github.com/llvm/llvm-project/commit/9694844d7e36fd5e01011ab56b64f27b867aa72d [1]
27+
Link: https://lore.kernel.org/r/[email protected]
28+
Signed-off-by: Nathan Chancellor <[email protected]>
29+
---
30+
Makefile | 3 +++
31+
1 file changed, 3 insertions(+)
32+
33+
diff --git a/Makefile b/Makefile
34+
index f380005d1600a..bbabaf524a963 100644
35+
--- a/Makefile
36+
+++ b/Makefile
37+
@@ -1013,6 +1013,9 @@ ifdef CONFIG_CC_IS_GCC
38+
KBUILD_CFLAGS += -fconserve-stack
39+
endif
40+
41+
+# Ensure compilers do not transform certain loops into calls to wcslen()
42+
+KBUILD_CFLAGS += -fno-builtin-wcslen
43+
+
44+
# change __FILE__ to the relative path from the srctree
45+
KBUILD_CPPFLAGS += $(call cc-option,-fmacro-prefix-map=$(srctree)/=)
46+
47+
---
48+
base-commit: 0af2f6be1b4281385b618cb86ad946eded089ac8
49+
change-id: 20250407-fno-builtin-wcslen-90a858ae7d54
50+
51+
Best regards,
52+
--
53+
Nathan Chancellor <[email protected]>
54+

patches/6.12/series

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
8b55f8818900c99dd4f55a59a103f5b29e41eb2c.patch
2+
20250407_nathan_kbuild_add_fno_builtin_wcslen.patch

0 commit comments

Comments
 (0)