Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

need -Qunused-arguments with -fuse-lld for cc-option tests #366

Closed
nickdesaulniers opened this issue Feb 14, 2019 · 14 comments
Closed

need -Qunused-arguments with -fuse-lld for cc-option tests #366

nickdesaulniers opened this issue Feb 14, 2019 · 14 comments
Assignees
Labels
[ARCH] x86_64 This bug impacts ARCH=x86_64 [BUG] linux A bug that should be fixed in the mainline kernel. [TOOL] lld The issue is relevant to LLD linker wontfix This will not be worked on

Comments

@nickdesaulniers
Copy link
Member

nickdesaulniers commented Feb 14, 2019

When trying LLD with x86, I was seeing:

$ make CC=clang HOSTCC=clang LD=ld.lld -j46
scripts/kconfig/conf  --syncconfig Kconfig
You are building kernel with non-retpoline compiler.
Please update your compiler.
arch/x86/Makefile:298: recipe for target 'checkbin' failed

Looks like __cc-option adds -Werror which breaks the cc-option for the RETPOLINE_CFLAGS. ex:

$ clang -fuse-ld=ld.lld -x c -c /dev/null
clang-9: warning: argument unused during compilation: '-fuse-ld=lld' [-Wunused-command-line-argument]
$ clang -fuse-ld=ld.lld -x c -c /dev/null -Werror
clang-9: error: argument unused during compilation: '-fuse-ld=lld' [-Werror,-Wunused-command-line-argument]
$ clang -fuse-ld=ld.lld -x c -c /dev/null -Werror -Qunused-arguments
$
diff --git a/Makefile b/Makefile
index 8011555745aa..84c2335e8e4a 100644
--- a/Makefile
+++ b/Makefile
@@ -501,7 +501,7 @@ CLANG_FLAGS += --gcc-toolchain=$(GCC_TOOLCHAIN)
 endif
 CLANG_FLAGS    += -no-integrated-as
 ifneq ($(shell $(LD) --version 2>&1 | head -n 1 | grep LLD),)
-CLANG_FLAGS    += -fuse-ld=lld
+CLANG_FLAGS    += -fuse-ld=lld -Qunused-arguments
 endif
 KBUILD_CFLAGS  += $(CLANG_FLAGS)
 KBUILD_AFLAGS  += $(CLANG_FLAGS)
@nickdesaulniers nickdesaulniers added [BUG] linux A bug that should be fixed in the mainline kernel. [ARCH] x86_64 This bug impacts ARCH=x86_64 [TOOL] lld The issue is relevant to LLD linker labels Feb 14, 2019
@nickdesaulniers nickdesaulniers self-assigned this Feb 14, 2019
@nickdesaulniers nickdesaulniers added the [PATCH] Exists There is a patch that fixes this issue label Feb 14, 2019
@nathanchance
Copy link
Member

Turns out this fixes #357.

I think that the -Qunused-arguments line can just be moved up because KBUILD_CPPFLAGS is supplied to __cc-option via cc-option: https://github.com/torvalds/linux/blob/v5.0-rc6/scripts/Kbuild.include#L119-L120

diff --git a/Makefile b/Makefile
index 28728a394362..cfaef110bb33 100644
--- a/Makefile
+++ b/Makefile
@@ -509,6 +509,7 @@ endif
 KBUILD_CFLAGS  += $(CLANG_FLAGS)
 KBUILD_AFLAGS  += $(CLANG_FLAGS)
 export CLANG_FLAGS
+KBUILD_CPPFLAGS += $(call cc-option,-Qunused-arguments,)
 endif
 
 RETPOLINE_CFLAGS_GCC := -mindirect-branch=thunk-extern -mindirect-branch-register
@@ -703,7 +704,6 @@ stackp-flags-$(CONFIG_STACKPROTECTOR_STRONG)      := -fstack-protector-strong
 KBUILD_CFLAGS += $(stackp-flags-y)
 
 ifdef CONFIG_CC_IS_CLANG
-KBUILD_CPPFLAGS += $(call cc-option,-Qunused-arguments,)
 KBUILD_CFLAGS += $(call cc-disable-warning, format-invalid-specifier)
 KBUILD_CFLAGS += $(call cc-disable-warning, gnu)
 KBUILD_CFLAGS += $(call cc-disable-warning, address-of-packed-member)

@nickdesaulniers
Copy link
Member Author

Does -Qunused-arguments work as a CPPFLAG? (I had it as a CFLAG). If so, we don't need to wrap it in a cc-option call there, since I'm pretty sure that block is clang only.

@nathanchance
Copy link
Member

nathanchance commented Feb 17, 2019

Does -Qunused-arguments work as a CPPFLAG?

It should, as I believe it has been there since Clang support was first added.

If so, we don't need to wrap it in a cc-option call there, since I'm pretty sure that block is clang only.

Yeah, I was thinking the same thing. I assume there was good reason for wrapping it initially (maybe an older version of Clang doesn't support it?) but given that I wouldn't recommend anything less than clang 7 right now, I think we'd be fine to unwrap it.

@nickdesaulniers
Copy link
Member Author

Oh, I remembered now why I didn't move -Qunused-arguments. When not using LLD, we still want that flag; your approach of using it with clang regardless of linker is better than my initial suggestion.

@nickdesaulniers
Copy link
Member Author

Just hit this again internally when trying to build KASAN builds.

@dileks
Copy link
Collaborator

dileks commented Feb 25, 2019

Isn't this Clang specific, so do it unconditionally and pass to both KBUILD_CFLAGS and KBUILD_CPPFLAGS (by not knowing if you can pass -no-integrated-as to KBUILD_CPPFLAGS)?

CLANG_FLAGS	+= -no-integrated-as
CLANG_FLAGS	+= -Qunused-arguments
KBUILD_CFLAGS	+= $(CLANG_FLAGS)
KBUILD_AFLAGS	+= $(CLANG_FLAGS)
KBUILD_CPPFLAGS += $(CLANG_FLAGS)
export CLANG_FLAGS

[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Makefile#n502

@dileks
Copy link
Collaborator

dileks commented Feb 25, 2019

Or like this:

CLANG_FLAGS	+= -no-integrated-as
KBUILD_CFLAGS	+= $(CLANG_FLAGS)
KBUILD_AFLAGS	+= $(CLANG_FLAGS)
export CLANG_FLAGS
KBUILD_CFLAGS   += -Qunused-arguments
KBUILD_CPPFLAGS += -Qunused-arguments

@nathanchance
Copy link
Member

I agree that we can probably drop cc-option but I think that Qunused-arguments shouldn't be added to KBUILD_CFLAGS otherwise we won't catch issues like #307.

@dileks
Copy link
Collaborator

dileks commented Feb 25, 2019

Agreed.
Will this be part of the lld patchset (was sent by @nickdesaulniers to linux-kbuild ML)?

@dileks
Copy link
Collaborator

dileks commented Feb 25, 2019

See this one how import KBUILD_CPPFLAGS are:

"ftrace: Build with CPPFLAGS to get -Qunused-arguments"

[1] https://git.kernel.org/linus/5a4630aadb9a9525474e9ac92965829f990cb5c4

@nickdesaulniers
Copy link
Member Author

Will this be part of the lld patchset

I will include it in the next revision I send. Sorry for a quiet week; performance review season at work right now. ☹️ 🔫

@dileks
Copy link
Collaborator

dileks commented Feb 25, 2019

I was able to use LLD as linker:

KConfig (will try with enabled later):

scripts/config -d CRYPTO_SHA512_SSSE3

Patchset:

$ git log --oneline --no-merges origin/HEAD..
8ad71b67b524 (for-5.0/lld-nickd-v2) Makefile: lld: set -O2 linker flag when linking with LLD
074326c6337c Makefile: lld: tell clang to use lld
b25bec66b4fd Makefile: clang: choose GCC_TOOLCHAIN_DIR not on LD
0112a3cb6e75 init/Kconfig: add config support for detecting linker
da5f007eb18e (for-5.0/lld-dileks) kbuild: clang: lld: Move -Qunused-arguments CPPFLAGS
ceb8873a6687 (for-5.1/scsi-fcoe) scsi: fcoe: make use of fip_mode enum complete
aadf16734696 (for-5.0/kvm-x86-cbl-asmgoto) KVM: x86: asm-goto: Workaround CBL issue #315 and #316
0670525ded48 (for-5.0/x86-cbl-asmgoto) WIP: asm goto: x86: convert some __always_inline functions to macros

Plus this diff:

$ git diff
diff --git a/arch/x86/kernel/vmlinux.lds.S b/arch/x86/kernel/vmlinux.lds.S
index 0d618ee634ac..ee3b5c7d662e 100644
--- a/arch/x86/kernel/vmlinux.lds.S
+++ b/arch/x86/kernel/vmlinux.lds.S
@@ -401,7 +401,7 @@ SECTIONS
  * Per-cpu symbols which need to be offset from __per_cpu_load
  * for the boot processor.
  */
-#define INIT_PER_CPU(x) init_per_cpu__##x = x + __per_cpu_load
+#define INIT_PER_CPU(x) init_per_cpu__##x = ABSOLUTE(x) + __per_cpu_load
 INIT_PER_CPU(gdt_page);
 INIT_PER_CPU(irq_stack_union);
 
diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
index 3d7a6a9c2370..f687c834810c 100644
--- a/include/asm-generic/vmlinux.lds.h
+++ b/include/asm-generic/vmlinux.lds.h
@@ -733,7 +733,7 @@
                KEEP(*(.orc_unwind_ip))                                 \
                __stop_orc_unwind_ip = .;                               \
        }                                                               \
-       . = ALIGN(6);                                                   \
+       . = ALIGN(8);                                                   \
        .orc_unwind : AT(ADDR(.orc_unwind) - LOAD_OFFSET) {             \
                __start_orc_unwind = .;                                 \
                KEEP(*(.orc_unwind))                                    \

Attached patch inspired by #366.

kbuild-clang-lld-Move-Qunused-arguments-CPPFLAGS-patch.txt

@nickdesaulniers
Copy link
Member Author

nickdesaulniers commented Apr 2, 2019

@nickdesaulniers nickdesaulniers added [PATCH] Submitted A patch has been submitted for review and removed [PATCH] Exists There is a patch that fixes this issue labels Apr 2, 2019
@nickdesaulniers
Copy link
Member Author

Will follow up with #342

@nickdesaulniers nickdesaulniers added the wontfix This will not be worked on label May 13, 2019
mainey pushed a commit to mainey/dream that referenced this issue Jun 3, 2019
This is needed because clang doesn't select which linker to use based on
$LD but rather -fuse-ld={bfd,gold,lld,<absolute path to linker>}.  This
is problematic especially for cc-ldoption, which checks for linker flag
support via invoking the compiler, rather than the linker.

Select the linker via absolute path from $PATH via `which`. This allows
you to build with:

$ make LD=ld.lld
$ make LD=ld.lld-8
$ make LD=/path/to/ld.lld

Add -Qunused-arguments to KBUILD_CPPFLAGS when using LLD, as otherwise
Clang likes to complain about -fuse-lld= being unused when compiling but
not linking (-c) such as when cc-option is used.

Link: ClangBuiltLinux/linux#342
Link: ClangBuiltLinux/linux#366
Link: ClangBuiltLinux/linux#357
Suggested-by: Nathan Chancellor <natechancellor@gmail.com>
Suggested-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
subhajeetmuhuri pushed a commit to AOSiP-Devices/kernel_zuk_msm8996 that referenced this issue Jun 3, 2019
This is needed because clang doesn't select which linker to use based on
$LD but rather -fuse-ld={bfd,gold,lld,<absolute path to linker>}.  This
is problematic especially for cc-ldoption, which checks for linker flag
support via invoking the compiler, rather than the linker.

Select the linker via absolute path from $PATH via `which`. This allows
you to build with:

$ make LD=ld.lld
$ make LD=ld.lld-8
$ make LD=/path/to/ld.lld

Add -Qunused-arguments to KBUILD_CPPFLAGS when using LLD, as otherwise
Clang likes to complain about -fuse-lld= being unused when compiling but
not linking (-c) such as when cc-option is used.

Link: ClangBuiltLinux/linux#342
Link: ClangBuiltLinux/linux#366
Link: ClangBuiltLinux/linux#357
Suggested-by: Nathan Chancellor <natechancellor@gmail.com>
Suggested-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
subhajeetmuhuri pushed a commit to AOSiP-Devices/kernel_zuk_msm8996 that referenced this issue Jun 19, 2019
This is needed because clang doesn't select which linker to use based on
$LD but rather -fuse-ld={bfd,gold,lld,<absolute path to linker>}.  This
is problematic especially for cc-ldoption, which checks for linker flag
support via invoking the compiler, rather than the linker.

Select the linker via absolute path from $PATH via `which`. This allows
you to build with:

$ make LD=ld.lld
$ make LD=ld.lld-8
$ make LD=/path/to/ld.lld

Add -Qunused-arguments to KBUILD_CPPFLAGS when using LLD, as otherwise
Clang likes to complain about -fuse-lld= being unused when compiling but
not linking (-c) such as when cc-option is used.

Link: ClangBuiltLinux/linux#342
Link: ClangBuiltLinux/linux#366
Link: ClangBuiltLinux/linux#357
Suggested-by: Nathan Chancellor <natechancellor@gmail.com>
Suggested-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
@tpimh tpimh removed the [PATCH] Submitted A patch has been submitted for review label Jun 24, 2019
subhajeetmuhuri pushed a commit to AOSiP-Devices/kernel_zuk_msm8996 that referenced this issue Jul 22, 2019
This is needed because clang doesn't select which linker to use based on
$LD but rather -fuse-ld={bfd,gold,lld,<absolute path to linker>}.  This
is problematic especially for cc-ldoption, which checks for linker flag
support via invoking the compiler, rather than the linker.

Select the linker via absolute path from $PATH via `which`. This allows
you to build with:

$ make LD=ld.lld
$ make LD=ld.lld-8
$ make LD=/path/to/ld.lld

Add -Qunused-arguments to KBUILD_CPPFLAGS when using LLD, as otherwise
Clang likes to complain about -fuse-lld= being unused when compiling but
not linking (-c) such as when cc-option is used.

Link: ClangBuiltLinux/linux#342
Link: ClangBuiltLinux/linux#366
Link: ClangBuiltLinux/linux#357
Suggested-by: Nathan Chancellor <natechancellor@gmail.com>
Suggested-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
k4ngcaribug pushed a commit to k4ngcaribug/kernel_xiaomi_ysl that referenced this issue May 18, 2024
The recently added support for -fuse-ld=lld is problematic for kbuild in
that cc-option tests that add -Werror -c -fuse-ld=lld, as -c implies
that no linker is invoked, and thus -fuse-ld=lld is an unused flag.
Therefor, -Qunused-arguments needs to be set sooner in the Makefile,
otherwise cc-option will fail when building with:

$ make LD=ld.lld

Also, -Qunused-arguments has been supported by Clang for a long time;
there's no need to wrap it in cc-option.

Bug: 63740206
Bug: 124794189
Change-Id: I90fb78fab1197db781ede09327783f616e5fbfaf
Link: ClangBuiltLinux/linux#366
Suggested-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Yousef Algadri <yusufgadrie@gmail.com>
Signed-off-by: Raphiel Rollerscaperers <rapherion@raphielgang.org>
Signed-off-by: Twisted <36546624+TwistedPrime@users.noreply.github.com>
Signed-off-by: MadeOfGreat <ravenklawasd@gmail.com>
Signed-off-by: GhostMaster69-dev <rathore6375@gmail.com>
ghazzor pushed a commit to stufss/kernel_samsung_M215F_CVH1 that referenced this issue May 19, 2024
The recently added support for -fuse-ld=lld is problematic for kbuild in
that cc-option tests that add -Werror -c -fuse-ld=lld, as -c implies
that no linker is invoked, and thus -fuse-ld=lld is an unused flag.
Therefor, -Qunused-arguments needs to be set sooner in the Makefile,
otherwise cc-option will fail when building with:

$ make LD=ld.lld

Also, -Qunused-arguments has been supported by Clang for a long time;
there's no need to wrap it in cc-option.

Bug: 63740206
Bug: 124794189
Change-Id: I90fb78fab1197db781ede09327783f616e5fbfaf
Link: ClangBuiltLinux/linux#366
Suggested-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
diphons pushed a commit to diphons/sdm845-419 that referenced this issue May 23, 2024
This is needed because clang doesn't select which linker to use based on
$LD but rather -fuse-ld={bfd,gold,lld,<absolute path to linker>}.  This
is problematic especially for cc-ldoption, which checks for linker flag
support via invoking the compiler, rather than the linker.

Select the linker via absolute path from $PATH via `which`. This allows
you to build with:

$ make LD=ld.lld
$ make LD=ld.lld-8
$ make LD=/path/to/ld.lld

Add -Qunused-arguments to KBUILD_CPPFLAGS when using LLD, as otherwise
Clang likes to complain about -fuse-lld= being unused when compiling but
not linking (-c) such as when cc-option is used.

Link: ClangBuiltLinux/linux#342
Link: ClangBuiltLinux/linux#366
Link: ClangBuiltLinux/linux#357
Suggested-by: Nathan Chancellor <natechancellor@gmail.com>
Suggested-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Carlos Ayrton Lopez Arroyo <15030201@itcelaya.edu.mx>
Signed-off-by: Little-W <1405481963@qq.com>
k4ngcaribug pushed a commit to k4ngcaribug/kernel_xiaomi_ysl that referenced this issue May 24, 2024
The recently added support for -fuse-ld=lld is problematic for kbuild in
that cc-option tests that add -Werror -c -fuse-ld=lld, as -c implies
that no linker is invoked, and thus -fuse-ld=lld is an unused flag.
Therefor, -Qunused-arguments needs to be set sooner in the Makefile,
otherwise cc-option will fail when building with:

$ make LD=ld.lld

Also, -Qunused-arguments has been supported by Clang for a long time;
there's no need to wrap it in cc-option.

Bug: 63740206
Bug: 124794189
Change-Id: I90fb78fab1197db781ede09327783f616e5fbfaf
Link: ClangBuiltLinux/linux#366
Suggested-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Yousef Algadri <yusufgadrie@gmail.com>
Signed-off-by: Raphiel Rollerscaperers <rapherion@raphielgang.org>
Signed-off-by: Twisted <36546624+TwistedPrime@users.noreply.github.com>
Signed-off-by: MadeOfGreat <ravenklawasd@gmail.com>
Signed-off-by: GhostMaster69-dev <rathore6375@gmail.com>
bibi09456 pushed a commit to bibi09456/android_kernel_asus_sdm636 that referenced this issue May 29, 2024
The recently added support for -fuse-ld=lld is problematic for kbuild in
that cc-option tests that add -Werror -c -fuse-ld=lld, as -c implies
that no linker is invoked, and thus -fuse-ld=lld is an unused flag.
Therefor, -Qunused-arguments needs to be set sooner in the Makefile,
otherwise cc-option will fail when building with:

$ make LD=ld.lld

Also, -Qunused-arguments has been supported by Clang for a long time;
there's no need to wrap it in cc-option.

Bug: 63740206
Bug: 124794189
Change-Id: I90fb78fab1197db781ede09327783f616e5fbfaf
Link: ClangBuiltLinux/linux#366
Suggested-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Divyanshu-Modi <divyan.m05@gmail.com>
Signed-off-by: Kunmun <kunmun.devroms@gmail.com>
ghazzor pushed a commit to stufss/kernel_samsung_M215F_CVH1 that referenced this issue Jun 10, 2024
The recently added support for -fuse-ld=lld is problematic for kbuild in
that cc-option tests that add -Werror -c -fuse-ld=lld, as -c implies
that no linker is invoked, and thus -fuse-ld=lld is an unused flag.
Therefor, -Qunused-arguments needs to be set sooner in the Makefile,
otherwise cc-option will fail when building with:

$ make LD=ld.lld

Also, -Qunused-arguments has been supported by Clang for a long time;
there's no need to wrap it in cc-option.

Bug: 63740206
Bug: 124794189
Change-Id: I90fb78fab1197db781ede09327783f616e5fbfaf
Link: ClangBuiltLinux/linux#366
Suggested-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
ghazzor pushed a commit to stufss/kernel_samsung_M215F_CVH1 that referenced this issue Jun 11, 2024
The recently added support for -fuse-ld=lld is problematic for kbuild in
that cc-option tests that add -Werror -c -fuse-ld=lld, as -c implies
that no linker is invoked, and thus -fuse-ld=lld is an unused flag.
Therefor, -Qunused-arguments needs to be set sooner in the Makefile,
otherwise cc-option will fail when building with:

$ make LD=ld.lld

Also, -Qunused-arguments has been supported by Clang for a long time;
there's no need to wrap it in cc-option.

Bug: 63740206
Bug: 124794189
Change-Id: I90fb78fab1197db781ede09327783f616e5fbfaf
Link: ClangBuiltLinux/linux#366
Suggested-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
LMAO-armv8 pushed a commit to stufss/kernel_samsung_M215F_CVH1 that referenced this issue Jun 13, 2024
The recently added support for -fuse-ld=lld is problematic for kbuild in
that cc-option tests that add -Werror -c -fuse-ld=lld, as -c implies
that no linker is invoked, and thus -fuse-ld=lld is an unused flag.
Therefor, -Qunused-arguments needs to be set sooner in the Makefile,
otherwise cc-option will fail when building with:

$ make LD=ld.lld

Also, -Qunused-arguments has been supported by Clang for a long time;
there's no need to wrap it in cc-option.

Bug: 63740206
Bug: 124794189
Change-Id: I90fb78fab1197db781ede09327783f616e5fbfaf
Link: ClangBuiltLinux/linux#366
Suggested-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
ghazzor pushed a commit to stufss/kernel_samsung_M215F_CVH1 that referenced this issue Jun 14, 2024
The recently added support for -fuse-ld=lld is problematic for kbuild in
that cc-option tests that add -Werror -c -fuse-ld=lld, as -c implies
that no linker is invoked, and thus -fuse-ld=lld is an unused flag.
Therefor, -Qunused-arguments needs to be set sooner in the Makefile,
otherwise cc-option will fail when building with:

$ make LD=ld.lld

Also, -Qunused-arguments has been supported by Clang for a long time;
there's no need to wrap it in cc-option.

Bug: 63740206
Bug: 124794189
Change-Id: I90fb78fab1197db781ede09327783f616e5fbfaf
Link: ClangBuiltLinux/linux#366
Suggested-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
ghazzor pushed a commit to ghazzor/moto_2 that referenced this issue Jun 22, 2024
The recently added support for -fuse-ld=lld is problematic for kbuild in
that cc-option tests that add -Werror -c -fuse-ld=lld, as -c implies
that no linker is invoked, and thus -fuse-ld=lld is an unused flag.
Therefor, -Qunused-arguments needs to be set sooner in the Makefile,
otherwise cc-option will fail when building with:

$ make LD=ld.lld

Also, -Qunused-arguments has been supported by Clang for a long time;
there's no need to wrap it in cc-option.

Bug: 63740206
Bug: 124794189
Change-Id: I90fb78fab1197db781ede09327783f616e5fbfaf
Link: ClangBuiltLinux/linux#366
Suggested-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
Rohail33 pushed a commit to Rohail33/Realking_kernel_sm8250 that referenced this issue Jul 6, 2024
This is needed because clang doesn't select which linker to use based on
$LD but rather -fuse-ld={bfd,gold,lld,<absolute path to linker>}.  This
is problematic especially for cc-ldoption, which checks for linker flag
support via invoking the compiler, rather than the linker.

Select the linker via absolute path from $PATH via `which`. This allows
you to build with:

$ make LD=ld.lld
$ make LD=ld.lld-8
$ make LD=/path/to/ld.lld

Add -Qunused-arguments to KBUILD_CPPFLAGS when using LLD, as otherwise
Clang likes to complain about -fuse-lld= being unused when compiling but
not linking (-c) such as when cc-option is used.

Link: ClangBuiltLinux/linux#342
Link: ClangBuiltLinux/linux#366
Link: ClangBuiltLinux/linux#357
Suggested-by: Nathan Chancellor <natechancellor@gmail.com>
Suggested-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Carlos Ayrton Lopez Arroyo <15030201@itcelaya.edu.mx>
Signed-off-by: Little-W <1405481963@qq.com>
MocaRafee pushed a commit to Mocaness/WhyredKernel that referenced this issue Jul 12, 2024
The recently added support for -fuse-ld=lld is problematic for kbuild in
that cc-option tests that add -Werror -c -fuse-ld=lld, as -c implies
that no linker is invoked, and thus -fuse-ld=lld is an unused flag.
Therefor, -Qunused-arguments needs to be set sooner in the Makefile,
otherwise cc-option will fail when building with:

$ make LD=ld.lld

Also, -Qunused-arguments has been supported by Clang for a long time;
there's no need to wrap it in cc-option.

Bug: 63740206
Bug: 124794189
Change-Id: I90fb78fab1197db781ede09327783f616e5fbfaf
Link: ClangBuiltLinux/linux#366
Suggested-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Yousef Algadri <yusufgadrie@gmail.com>
Signed-off-by: Raphiel Rollerscaperers <rapherion@raphielgang.org>
ExtremeXT pushed a commit to ExtremeXT/android_kernel_samsung_exynos9820 that referenced this issue Aug 3, 2024
The recently added support for -fuse-ld=lld is problematic for kbuild in
that cc-option tests that add -Werror -c -fuse-ld=lld, as -c implies
that no linker is invoked, and thus -fuse-ld=lld is an unused flag.
Therefor, -Qunused-arguments needs to be set sooner in the Makefile,
otherwise cc-option will fail when building with:

$ make LD=ld.lld

Also, -Qunused-arguments has been supported by Clang for a long time;
there's no need to wrap it in cc-option.

Bug: 63740206
Bug: 124794189
Change-Id: I90fb78fab1197db781ede09327783f616e5fbfaf
Link: ClangBuiltLinux/linux#366
Suggested-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
ExtremeXT pushed a commit to ExtremeXT/android_kernel_samsung_exynos9820 that referenced this issue Aug 6, 2024
The recently added support for -fuse-ld=lld is problematic for kbuild in
that cc-option tests that add -Werror -c -fuse-ld=lld, as -c implies
that no linker is invoked, and thus -fuse-ld=lld is an unused flag.
Therefor, -Qunused-arguments needs to be set sooner in the Makefile,
otherwise cc-option will fail when building with:

$ make LD=ld.lld

Also, -Qunused-arguments has been supported by Clang for a long time;
there's no need to wrap it in cc-option.

Bug: 63740206
Bug: 124794189
Change-Id: I90fb78fab1197db781ede09327783f616e5fbfaf
Link: ClangBuiltLinux/linux#366
Suggested-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
ExtremeXT pushed a commit to ExtremeXT/android_kernel_samsung_exynos9820 that referenced this issue Aug 6, 2024
The recently added support for -fuse-ld=lld is problematic for kbuild in
that cc-option tests that add -Werror -c -fuse-ld=lld, as -c implies
that no linker is invoked, and thus -fuse-ld=lld is an unused flag.
Therefor, -Qunused-arguments needs to be set sooner in the Makefile,
otherwise cc-option will fail when building with:

$ make LD=ld.lld

Also, -Qunused-arguments has been supported by Clang for a long time;
there's no need to wrap it in cc-option.

Bug: 63740206
Bug: 124794189
Change-Id: I90fb78fab1197db781ede09327783f616e5fbfaf
Link: ClangBuiltLinux/linux#366
Suggested-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
ExtremeXT pushed a commit to ExtremeXT/android_kernel_samsung_exynos9820 that referenced this issue Aug 6, 2024
The recently added support for -fuse-ld=lld is problematic for kbuild in
that cc-option tests that add -Werror -c -fuse-ld=lld, as -c implies
that no linker is invoked, and thus -fuse-ld=lld is an unused flag.
Therefor, -Qunused-arguments needs to be set sooner in the Makefile,
otherwise cc-option will fail when building with:

$ make LD=ld.lld

Also, -Qunused-arguments has been supported by Clang for a long time;
there's no need to wrap it in cc-option.

Bug: 63740206
Bug: 124794189
Change-Id: I90fb78fab1197db781ede09327783f616e5fbfaf
Link: ClangBuiltLinux/linux#366
Suggested-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
Rohail33 pushed a commit to Rohail33/Realking_kernel_sm8250 that referenced this issue Aug 16, 2024
This is needed because clang doesn't select which linker to use based on
$LD but rather -fuse-ld={bfd,gold,lld,<absolute path to linker>}.  This
is problematic especially for cc-ldoption, which checks for linker flag
support via invoking the compiler, rather than the linker.

Select the linker via absolute path from $PATH via `which`. This allows
you to build with:

$ make LD=ld.lld
$ make LD=ld.lld-8
$ make LD=/path/to/ld.lld

Add -Qunused-arguments to KBUILD_CPPFLAGS when using LLD, as otherwise
Clang likes to complain about -fuse-lld= being unused when compiling but
not linking (-c) such as when cc-option is used.

Link: ClangBuiltLinux/linux#342
Link: ClangBuiltLinux/linux#366
Link: ClangBuiltLinux/linux#357
Suggested-by: Nathan Chancellor <natechancellor@gmail.com>
Suggested-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Carlos Ayrton Lopez Arroyo <15030201@itcelaya.edu.mx>
Signed-off-by: Little-W <1405481963@qq.com>
L1ghtzin pushed a commit to Bomb-Projects/kernel_motorola_msm8937 that referenced this issue Sep 7, 2024
The recently added support for -fuse-ld=lld is problematic for kbuild in
that cc-option tests that add -Werror -c -fuse-ld=lld, as -c implies
that no linker is invoked, and thus -fuse-ld=lld is an unused flag.
Therefor, -Qunused-arguments needs to be set sooner in the Makefile,
otherwise cc-option will fail when building with:

$ make LD=ld.lld

Also, -Qunused-arguments has been supported by Clang for a long time;
there's no need to wrap it in cc-option.

Bug: 63740206
Bug: 124794189
Change-Id: I90fb78fab1197db781ede09327783f616e5fbfaf
Link: ClangBuiltLinux/linux#366
Suggested-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
dhelo11 pushed a commit to dhelo11/android_kernel_xiaomi_santoni_4.9 that referenced this issue Sep 9, 2024
The recently added support for -fuse-ld=lld is problematic for kbuild in
that cc-option tests that add -Werror -c -fuse-ld=lld, as -c implies
that no linker is invoked, and thus -fuse-ld=lld is an unused flag.
Therefor, -Qunused-arguments needs to be set sooner in the Makefile,
otherwise cc-option will fail when building with:

$ make LD=ld.lld

Also, -Qunused-arguments has been supported by Clang for a long time;
there's no need to wrap it in cc-option.

Bug: 63740206
Bug: 124794189
Change-Id: I90fb78fab1197db781ede09327783f616e5fbfaf
Link: ClangBuiltLinux/linux#366
Suggested-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Yousef Algadri <yusufgadrie@gmail.com>
Signed-off-by: Raphiel Rollerscaperers <rapherion@raphielgang.org>
Signed-off-by: Twisted <36546624+TwistedPrime@users.noreply.github.com>
Signed-off-by: MadeOfGreat <ravenklawasd@gmail.com>
Signed-off-by: GhostMaster69-dev <rathore6375@gmail.com>
Rve27 pushed a commit to Rv-Trees/android_kernel_xiaomi_sdm845 that referenced this issue Sep 11, 2024
The recently added support for -fuse-ld=lld is problematic for kbuild in
that cc-option tests that add -Werror -c -fuse-ld=lld, as -c implies
that no linker is invoked, and thus -fuse-ld=lld is an unused flag.
Therefor, -Qunused-arguments needs to be set sooner in the Makefile,
otherwise cc-option will fail when building with:

$ make LD=ld.lld

Also, -Qunused-arguments has been supported by Clang for a long time;
there's no need to wrap it in cc-option.

Bug: 63740206
Bug: 124794189
Change-Id: I90fb78fab1197db781ede09327783f616e5fbfaf
Link: ClangBuiltLinux/linux#366
Suggested-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Rve <rve27github@gmail.com>
Rve27 pushed a commit to Rv-Trees/android_kernel_xiaomi_sdm845 that referenced this issue Sep 14, 2024
The recently added support for -fuse-ld=lld is problematic for kbuild in
that cc-option tests that add -Werror -c -fuse-ld=lld, as -c implies
that no linker is invoked, and thus -fuse-ld=lld is an unused flag.
Therefor, -Qunused-arguments needs to be set sooner in the Makefile,
otherwise cc-option will fail when building with:

$ make LD=ld.lld

Also, -Qunused-arguments has been supported by Clang for a long time;
there's no need to wrap it in cc-option.

Bug: 63740206
Bug: 124794189
Change-Id: I90fb78fab1197db781ede09327783f616e5fbfaf
Link: ClangBuiltLinux/linux#366
Suggested-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Rve <rve27github@gmail.com>
Kneba pushed a commit to Tiktodz/android_kernel_asus_sdm636 that referenced this issue Sep 26, 2024
The recently added support for -fuse-ld=lld is problematic for kbuild in
that cc-option tests that add -Werror -c -fuse-ld=lld, as -c implies
that no linker is invoked, and thus -fuse-ld=lld is an unused flag.
Therefor, -Qunused-arguments needs to be set sooner in the Makefile,
otherwise cc-option will fail when building with:

$ make LD=ld.lld

Also, -Qunused-arguments has been supported by Clang for a long time;
there's no need to wrap it in cc-option.

Bug: 63740206
Bug: 124794189
Change-Id: I90fb78fab1197db781ede09327783f616e5fbfaf
Link: ClangBuiltLinux/linux#366
Suggested-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Kneba <abenkenary3@gmail.com>
socaindra pushed a commit to socaindra/kernel_asus_sdm636 that referenced this issue Sep 27, 2024
The recently added support for -fuse-ld=lld is problematic for kbuild in
that cc-option tests that add -Werror -c -fuse-ld=lld, as -c implies
that no linker is invoked, and thus -fuse-ld=lld is an unused flag.
Therefor, -Qunused-arguments needs to be set sooner in the Makefile,
otherwise cc-option will fail when building with:

$ make LD=ld.lld

Also, -Qunused-arguments has been supported by Clang for a long time;
there's no need to wrap it in cc-option.

Bug: 63740206
Bug: 124794189
Change-Id: I90fb78fab1197db781ede09327783f616e5fbfaf
Link: ClangBuiltLinux/linux#366
Suggested-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Kneba <abenkenary3@gmail.com>
ghost pushed a commit to Kurumi-Tokito/lineage_kernel_nokia_sdm660 that referenced this issue Oct 11, 2024
kbuild: Allow forcing the alternative LLD linker via Kconfig

LLD is a relatively new linker from the LLVM Project that aims to be a
faster and more modern alternative to the GNU gold and bfd linkers from
binutils: https://lld.llvm.org/

I've also found that it offers more insightful diagnostics when
something goes wrong, e.g. when there are undefined references. It does
also appear to speed up the overall build time by 4-10s as compared to
ld.bfd.

These new config options will only allow fully-working configurations:
  - gold/lld when Clang LTO is enabled
  - bfd/lld otherwise

Signed-off-by: Danny Lin <danny@kdrag0n.dev>
Signed-off-by: Adam W. Willis <return.of.octobot@gmail.com>
Signed-off-by: Yaroslav Furman <yaro330@gmail.com>

BACKPORT: FROMLIST: Makefile: lld: set -O2 linker flag when linking w…

…ith LLD

For arm64:
0.34% size improvement with lld -O2 over lld for vmlinux.
3.3% size improvement with lld -O2 over lld for Image.lz4-dtb.

Link: ClangBuiltLinux/linux#343
Suggested-by: Rui Ueyama <ruiu@google.com>
Suggested-by: Nathan Chancellor <natechancellor@gmail.com>
Reviewed-by: Nathan Chancellor <natechancellor@gmail.com>
Tested-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
(am from https://patchwork.kernel.org/patch/10806729/)
Signed-off-by: Adam W. Willis <return.of.octobot@gmail.com>
Signed-off-by: Yaroslav Furman <yaro330@gmail.com>

BACKPORT: FROMLIST: Makefile: lld: tell clang to use lld

This is needed because clang doesn't select which linker to use based on
$LD but rather -fuse-ld={bfd,gold,lld,<absolute path to linker>}.  This
is problematic especially for cc-ldoption, which checks for linker flag
support via invoking the compiler, rather than the BACKPORT: FROMLIST: Makefile: lld: tell clang to use lld

This is needed because clang doesn't select which linker to use based on
$LD but rather -fuse-ld={bfd,gold,lld,<absolute path to linker>}.  This
is problematic especially for cc-ldoption, which checks for linker flag
support via invoking the compiler, rather than the linker.

Select the linker via absolute path from $PATH via `which`. This allows
you to build with:

$ make LD=ld.lld
$ make LD=ld.lld-8
$ make LD=/path/to/ld.lld

Add -Qunused-arguments to KBUILD_CPPFLAGS sooner, as otherwise
Clang likes to complain about -fuse-lld= being unused when compiling but
not linking (-c) such as when cc-option is used. There's no need to
guard with cc-option.

Link: ClangBuiltLinux/linux#342
Link: ClangBuiltLinux/linux#366
Link: ClangBuiltLinux/linux#357
Suggested-by: Nathan Chancellor <natechancellor@gmail.com>
Suggested-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
Reviewed-by: Nathan Chancellor <natechancellor@gmail
Signed-off-by: Divyanshu-Modi <divyan.m05@gmail.com>
Signed-off-by: Kunmun <kunmun.devroms@gmail.com>
MocaRafee pushed a commit to Mocaness/WhyredKernel that referenced this issue Nov 9, 2024
The recently added support for -fuse-ld=lld is problematic for kbuild in
that cc-option tests that add -Werror -c -fuse-ld=lld, as -c implies
that no linker is invoked, and thus -fuse-ld=lld is an unused flag.
Therefor, -Qunused-arguments needs to be set sooner in the Makefile,
otherwise cc-option will fail when building with:

$ make LD=ld.lld

Also, -Qunused-arguments has been supported by Clang for a long time;
there's no need to wrap it in cc-option.

Bug: 63740206
Bug: 124794189
Change-Id: I90fb78fab1197db781ede09327783f616e5fbfaf
Link: ClangBuiltLinux/linux#366
Suggested-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Yousef Algadri <yusufgadrie@gmail.com>
Signed-off-by: Raphiel Rollerscaperers <rapherion@raphielgang.org>
MocaRafee pushed a commit to Mocaness/WhyredKernel that referenced this issue Nov 9, 2024
The recently added support for -fuse-ld=lld is problematic for kbuild in
that cc-option tests that add -Werror -c -fuse-ld=lld, as -c implies
that no linker is invoked, and thus -fuse-ld=lld is an unused flag.
Therefor, -Qunused-arguments needs to be set sooner in the Makefile,
otherwise cc-option will fail when building with:

$ make LD=ld.lld

Also, -Qunused-arguments has been supported by Clang for a long time;
there's no need to wrap it in cc-option.

Bug: 63740206
Bug: 124794189
Change-Id: I90fb78fab1197db781ede09327783f616e5fbfaf
Link: ClangBuiltLinux/linux#366
Suggested-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Yousef Algadri <yusufgadrie@gmail.com>
Signed-off-by: Raphiel Rollerscaperers <rapherion@raphielgang.org>
MocaRafee pushed a commit to Mocaness/WhyredKernel that referenced this issue Nov 9, 2024
The recently added support for -fuse-ld=lld is problematic for kbuild in
that cc-option tests that add -Werror -c -fuse-ld=lld, as -c implies
that no linker is invoked, and thus -fuse-ld=lld is an unused flag.
Therefor, -Qunused-arguments needs to be set sooner in the Makefile,
otherwise cc-option will fail when building with:

$ make LD=ld.lld

Also, -Qunused-arguments has been supported by Clang for a long time;
there's no need to wrap it in cc-option.

Bug: 63740206
Bug: 124794189
Change-Id: I90fb78fab1197db781ede09327783f616e5fbfaf
Link: ClangBuiltLinux/linux#366
Suggested-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Yousef Algadri <yusufgadrie@gmail.com>
Signed-off-by: Raphiel Rollerscaperers <rapherion@raphielgang.org>
MocaRafee pushed a commit to Mocaness/WhyredKernel that referenced this issue Nov 9, 2024
The recently added support for -fuse-ld=lld is problematic for kbuild in
that cc-option tests that add -Werror -c -fuse-ld=lld, as -c implies
that no linker is invoked, and thus -fuse-ld=lld is an unused flag.
Therefor, -Qunused-arguments needs to be set sooner in the Makefile,
otherwise cc-option will fail when building with:

$ make LD=ld.lld

Also, -Qunused-arguments has been supported by Clang for a long time;
there's no need to wrap it in cc-option.

Bug: 63740206
Bug: 124794189
Change-Id: I90fb78fab1197db781ede09327783f616e5fbfaf
Link: ClangBuiltLinux/linux#366
Suggested-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Yousef Algadri <yusufgadrie@gmail.com>
Signed-off-by: Raphiel Rollerscaperers <rapherion@raphielgang.org>
MocaRafee pushed a commit to Mocaness/WhyredKernel that referenced this issue Nov 9, 2024
The recently added support for -fuse-ld=lld is problematic for kbuild in
that cc-option tests that add -Werror -c -fuse-ld=lld, as -c implies
that no linker is invoked, and thus -fuse-ld=lld is an unused flag.
Therefor, -Qunused-arguments needs to be set sooner in the Makefile,
otherwise cc-option will fail when building with:

$ make LD=ld.lld

Also, -Qunused-arguments has been supported by Clang for a long time;
there's no need to wrap it in cc-option.

Bug: 63740206
Bug: 124794189
Change-Id: I90fb78fab1197db781ede09327783f616e5fbfaf
Link: ClangBuiltLinux/linux#366
Suggested-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Yousef Algadri <yusufgadrie@gmail.com>
Signed-off-by: Raphiel Rollerscaperers <rapherion@raphielgang.org>
KanonifyX pushed a commit to KanonifyX/android_kernel_tama_sdm845 that referenced this issue Dec 5, 2024
The recently added support for -fuse-ld=lld is problematic for kbuild in
that cc-option tests that add -Werror -c -fuse-ld=lld, as -c implies
that no linker is invoked, and thus -fuse-ld=lld is an unused flag.
Therefor, -Qunused-arguments needs to be set sooner in the Makefile,
otherwise cc-option will fail when building with:

$ make LD=ld.lld

Also, -Qunused-arguments has been supported by Clang for a long time;
there's no need to wrap it in cc-option.

Bug: 63740206
Bug: 124794189
Change-Id: I90fb78fab1197db781ede09327783f616e5fbfaf
Link: ClangBuiltLinux/linux#366
Suggested-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Yousef Algadri <yusufgadrie@gmail.com>
Signed-off-by: Raphiel Rollerscaperers <rapherion@raphielgang.org>
Signed-off-by: Twisted <36546624+TwistedPrime@users.noreply.github.com>
Signed-off-by: MadeOfGreat <ravenklawasd@gmail.com>
Signed-off-by: CloudedQuartz <ravenklawasd@gmail.com>
Signed-off-by: Dakkshesh <dakkshesh5@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[ARCH] x86_64 This bug impacts ARCH=x86_64 [BUG] linux A bug that should be fixed in the mainline kernel. [TOOL] lld The issue is relevant to LLD linker wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

4 participants