2022-03-31 03:55:42

by Nathan Chancellor

[permalink] [raw]
Subject: [PATCH 0/2] Remove '-mno-global-merge' from KBUILD_CFLAGS

As discussed at [1] and [2], this series removes '-mno-global-merge'
from KBUILD_CFLAGS for clang, as it causes warnings for UML, and it
no longer appears to be necessary, as I do not see any modpost warnings
with LLVM 11 through 15 with several different ARCH=arm and ARCH=arm64
configurations.

[1] is currently in the UML tree, destined for 5.18, but it is buggy, as
I note in [2]. This series is an alternative to [2], which has not been
picked up yet, so it is based on the current UML tree. If [2] is picked
up, I can rework the first patch to remove the '-mno-global-merge'
filtering from arch/um/Makefile; otherwise, this should be picked up in
place of [2].

I intentionally kept the first patch vague around what fixed the modpost
warnings, as I am not too sure. [3] seems somewhat likely, but I don't
think that will revert cleanly on main to test. I think the testing is
enough to show that the original issue is resolved but I do note that we
can add this flag back in the architecture specific Makefiles if needed.

Please review and ack as necessary.

[1]: https://lore.kernel.org/r/[email protected]/
[2]: https://lore.kernel.org/r/[email protected]/
[3]: https://github.com/llvm/llvm-project/commit/863bfdbfb446adaef767ff514d1f2ffb5d489562

Nathan Chancellor (2):
kbuild: Remove '-mno-global-merge'
Revert "um: clang: Strip out -mno-global-merge from USER_CFLAGS"

Makefile | 4 ----
arch/um/Makefile | 4 ----
2 files changed, 8 deletions(-)


base-commit: 82017457957a550d7d00dde419435dd74a890887
--
2.35.1


2022-03-31 04:56:42

by Nathan Chancellor

[permalink] [raw]
Subject: [PATCH 2/2] Revert "um: clang: Strip out -mno-global-merge from USER_CFLAGS"

This reverts commit 6580c5c18fb3df2b11c5e0452372f815deeff895.

This patch is buggy, as noted in the patch linked below. The root cause
has been solved by removing '-mno-global-merge' for the entire kernel.

Link: https://lore.kernel.org/r/[email protected]/
Signed-off-by: Nathan Chancellor <[email protected]>
---
arch/um/Makefile | 4 ----
1 file changed, 4 deletions(-)

diff --git a/arch/um/Makefile b/arch/um/Makefile
index 320b09cd513c..f2fe63bfd819 100644
--- a/arch/um/Makefile
+++ b/arch/um/Makefile
@@ -75,10 +75,6 @@ USER_CFLAGS = $(patsubst $(KERNEL_DEFINES),,$(patsubst -I%,,$(KBUILD_CFLAGS))) \
-D_FILE_OFFSET_BITS=64 -idirafter $(srctree)/include \
-idirafter $(objtree)/include -D__KERNEL__ -D__UM_HOST__

-ifdef CONFIG_CC_IS_CLANG
-USER_CFLAGS := $(patsubst -mno-global-merge,,$(USER_CFLAGS))
-endif
-
#This will adjust *FLAGS accordingly to the platform.
include $(srctree)/$(ARCH_DIR)/Makefile-os-$(OS)

--
2.35.1

2022-03-31 05:49:02

by Kees Cook

[permalink] [raw]
Subject: Re: [PATCH 2/2] Revert "um: clang: Strip out -mno-global-merge from USER_CFLAGS"

On Wed, Mar 30, 2022 at 04:45:28PM -0700, Nathan Chancellor wrote:
> This reverts commit 6580c5c18fb3df2b11c5e0452372f815deeff895.
>
> This patch is buggy, as noted in the patch linked below. The root cause
> has been solved by removing '-mno-global-merge' for the entire kernel.
>
> Link: https://lore.kernel.org/r/[email protected]/
> Signed-off-by: Nathan Chancellor <[email protected]>

Reviewed-by: Kees Cook <[email protected]>

--
Kees Cook

2022-04-02 16:46:58

by Masahiro Yamada

[permalink] [raw]
Subject: Re: [PATCH 0/2] Remove '-mno-global-merge' from KBUILD_CFLAGS

On Thu, Mar 31, 2022 at 8:46 AM Nathan Chancellor <[email protected]> wrote:
>
> As discussed at [1] and [2], this series removes '-mno-global-merge'
> from KBUILD_CFLAGS for clang, as it causes warnings for UML, and it
> no longer appears to be necessary, as I do not see any modpost warnings
> with LLVM 11 through 15 with several different ARCH=arm and ARCH=arm64
> configurations.
>
> [1] is currently in the UML tree, destined for 5.18, but it is buggy, as
> I note in [2]. This series is an alternative to [2], which has not been
> picked up yet, so it is based on the current UML tree. If [2] is picked
> up, I can rework the first patch to remove the '-mno-global-merge'
> filtering from arch/um/Makefile; otherwise, this should be picked up in
> place of [2].
>
> I intentionally kept the first patch vague around what fixed the modpost
> warnings, as I am not too sure. [3] seems somewhat likely, but I don't
> think that will revert cleanly on main to test. I think the testing is
> enough to show that the original issue is resolved but I do note that we
> can add this flag back in the architecture specific Makefiles if needed.
>
> Please review and ack as necessary.


Both applied to linux-kbuild/fixes.




> [1]: https://lore.kernel.org/r/[email protected]/
> [2]: https://lore.kernel.org/r/[email protected]/
> [3]: https://github.com/llvm/llvm-project/commit/863bfdbfb446adaef767ff514d1f2ffb5d489562
>
> Nathan Chancellor (2):
> kbuild: Remove '-mno-global-merge'
> Revert "um: clang: Strip out -mno-global-merge from USER_CFLAGS"
>
> Makefile | 4 ----
> arch/um/Makefile | 4 ----
> 2 files changed, 8 deletions(-)
>
>
> base-commit: 82017457957a550d7d00dde419435dd74a890887
> --
> 2.35.1
>


--
Best Regards
Masahiro Yamada