]> git.baikalelectronics.ru Git - kernel.git/commit
x86/build: Fix location of '-plugin-opt=' flags
authorNathan Chancellor <nathan@kernel.org>
Tue, 18 May 2021 19:01:06 +0000 (12:01 -0700)
committerIngo Molnar <mingo@kernel.org>
Wed, 19 May 2021 11:05:53 +0000 (13:05 +0200)
commit5415084d25889c9edc5653b4038386a91b67ab11
treec82f2820b1f474eaca539e113088eee54571f6ee
parentecb077849ced5a50b709dfc680016914e60a36c2
x86/build: Fix location of '-plugin-opt=' flags

Commit 79ec35c6084e ("x86, build: allow LTO to be selected") added a
couple of '-plugin-opt=' flags to KBUILD_LDFLAGS because the code model
and stack alignment are not stored in LLVM bitcode.

However, these flags were added to KBUILD_LDFLAGS prior to the
emulation flag assignment, which uses ':=', so they were overwritten
and never added to $(LD) invocations.

The absence of these flags caused misalignment issues in the
AMDGPU driver when compiling with CONFIG_LTO_CLANG, resulting in
general protection faults.

Shuffle the assignment below the initial one so that the flags are
properly passed along and all of the linker flags stay together.

At the same time, avoid any future issues with clobbering flags by
changing the emulation flag assignment to '+=' since KBUILD_LDFLAGS is
already defined with ':=' in the main Makefile before being exported for
modification here as a result of commit:

  dc0d6627e0a3 ("kbuild: clear LDFLAGS in the top Makefile")

Fixes: 79ec35c6084e ("x86, build: allow LTO to be selected")
Reported-by: Anthony Ruhier <aruhier@mailbox.org>
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Tested-by: Anthony Ruhier <aruhier@mailbox.org>
Cc: stable@vger.kernel.org
Link: https://github.com/ClangBuiltLinux/linux/issues/1374
Link: https://lore.kernel.org/r/20210518190106.60935-1-nathan@kernel.org
arch/x86/Makefile