Skip to content

Commit e6585a4

Browse files
committed
Merge tag 'kbuild-fixes-v5.10-2' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild
Pull Kbuild fixes from Masahiro Yamada: - Move -Wcast-align to W=3, which tends to be false-positive and there is no tree-wide solution. - Pass -fmacro-prefix-map to KBUILD_CPPFLAGS because it is a preprocessor option and makes sense for .S files as well. - Disable -gdwarf-2 for Clang's integrated assembler to avoid warnings. - Disable --orphan-handling=warn for LLD 10.0.1 to avoid warnings. - Fix undesirable line breaks in *.mod files. * tag 'kbuild-fixes-v5.10-2' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild: kbuild: avoid split lines in .mod files kbuild: Disable CONFIG_LD_ORPHAN_WARN for ld.lld 10.0.1 kbuild: Hoist '--orphan-handling' into Kconfig Kbuild: do not emit debug info for assembly with LLVM_IAS=1 kbuild: use -fmacro-prefix-map for .S sources Makefile.extrawarn: move -Wcast-align to W=3
2 parents 12c0ab6 + 7d32358 commit e6585a4

17 files changed

Lines changed: 64 additions & 24 deletions

File tree

MAINTAINERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4287,6 +4287,7 @@ B: https://github.com/ClangBuiltLinux/linux/issues
42874287
C: irc://chat.freenode.net/clangbuiltlinux
42884288
F: Documentation/kbuild/llvm.rst
42894289
F: scripts/clang-tools/
4290+
F: scripts/lld-version.sh
42904291
K: \b(?i:clang|llvm)\b
42914292

42924293
CLEANCACHE API

Makefile

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -826,7 +826,9 @@ else
826826
DEBUG_CFLAGS += -g
827827
endif
828828

829+
ifneq ($(LLVM_IAS),1)
829830
KBUILD_AFLAGS += -Wa,-gdwarf-2
831+
endif
830832

831833
ifdef CONFIG_DEBUG_INFO_DWARF4
832834
DEBUG_CFLAGS += -gdwarf-4
@@ -944,7 +946,7 @@ KBUILD_CFLAGS += $(call cc-option,-Werror=incompatible-pointer-types)
944946
KBUILD_CFLAGS += $(call cc-option,-Werror=designated-init)
945947

946948
# change __FILE__ to the relative path from the srctree
947-
KBUILD_CFLAGS += $(call cc-option,-fmacro-prefix-map=$(srctree)/=)
949+
KBUILD_CPPFLAGS += $(call cc-option,-fmacro-prefix-map=$(srctree)/=)
948950

949951
# ensure -fcf-protection is disabled when using retpoline as it is
950952
# incompatible with -mindirect-branch=thunk-extern
@@ -982,6 +984,12 @@ ifeq ($(CONFIG_RELR),y)
982984
LDFLAGS_vmlinux += --pack-dyn-relocs=relr
983985
endif
984986

987+
# We never want expected sections to be placed heuristically by the
988+
# linker. All sections should be explicitly named in the linker script.
989+
ifdef CONFIG_LD_ORPHAN_WARN
990+
LDFLAGS_vmlinux += --orphan-handling=warn
991+
endif
992+
985993
# Align the bit size of userspace programs with the kernel
986994
KBUILD_USERCFLAGS += $(filter -m32 -m64 --target=%, $(KBUILD_CFLAGS))
987995
KBUILD_USERLDFLAGS += $(filter -m32 -m64 --target=%, $(KBUILD_CFLAGS))

arch/Kconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1028,6 +1028,15 @@ config HAVE_STATIC_CALL_INLINE
10281028
bool
10291029
depends on HAVE_STATIC_CALL
10301030

1031+
config ARCH_WANT_LD_ORPHAN_WARN
1032+
bool
1033+
help
1034+
An arch should select this symbol once all linker sections are explicitly
1035+
included, size-asserted, or discarded in the linker scripts. This is
1036+
important because we never want expected sections to be placed heuristically
1037+
by the linker, since the locations of such sections can change between linker
1038+
versions.
1039+
10311040
source "kernel/gcov/Kconfig"
10321041

10331042
source "scripts/gcc-plugins/Kconfig"

arch/arm/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ config ARM
3535
select ARCH_USE_CMPXCHG_LOCKREF
3636
select ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT if MMU
3737
select ARCH_WANT_IPC_PARSE_VERSION
38+
select ARCH_WANT_LD_ORPHAN_WARN
3839
select BINFMT_FLAT_ARGVP_ENVP_ON_STACK
3940
select BUILDTIME_TABLE_SORT if MMU
4041
select CLONE_BACKWARDS

arch/arm/Makefile

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@ LDFLAGS_vmlinux += --be8
1616
KBUILD_LDFLAGS_MODULE += --be8
1717
endif
1818

19-
# We never want expected sections to be placed heuristically by the
20-
# linker. All sections should be explicitly named in the linker script.
21-
LDFLAGS_vmlinux += $(call ld-option, --orphan-handling=warn)
22-
2319
GZFLAGS :=-9
2420
#KBUILD_CFLAGS +=-pipe
2521

arch/arm/boot/compressed/Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,9 @@ LDFLAGS_vmlinux += --no-undefined
129129
# Delete all temporary local symbols
130130
LDFLAGS_vmlinux += -X
131131
# Report orphan sections
132-
LDFLAGS_vmlinux += $(call ld-option, --orphan-handling=warn)
132+
ifdef CONFIG_LD_ORPHAN_WARN
133+
LDFLAGS_vmlinux += --orphan-handling=warn
134+
endif
133135
# Next argument is a linker script
134136
LDFLAGS_vmlinux += -T
135137

arch/arm64/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ config ARM64
8181
select ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT
8282
select ARCH_WANT_FRAME_POINTERS
8383
select ARCH_WANT_HUGE_PMD_SHARE if ARM64_4K_PAGES || (ARM64_16K_PAGES && !ARM64_VA_BITS_36)
84+
select ARCH_WANT_LD_ORPHAN_WARN
8485
select ARCH_HAS_UBSAN_SANITIZE_ALL
8586
select ARM_AMBA
8687
select ARM_ARCH_TIMER

arch/arm64/Makefile

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,6 @@ LDFLAGS_vmlinux += --fix-cortex-a53-843419
2828
endif
2929
endif
3030

31-
# We never want expected sections to be placed heuristically by the
32-
# linker. All sections should be explicitly named in the linker script.
33-
LDFLAGS_vmlinux += $(call ld-option, --orphan-handling=warn)
34-
3531
ifeq ($(CONFIG_ARM64_USE_LSE_ATOMICS), y)
3632
ifneq ($(CONFIG_ARM64_LSE_ATOMICS), y)
3733
$(warning LSE atomics not supported by binutils)

arch/powerpc/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ config PPC
152152
select ARCH_USE_QUEUED_SPINLOCKS if PPC_QUEUED_SPINLOCKS
153153
select ARCH_WANT_IPC_PARSE_VERSION
154154
select ARCH_WANT_IRQS_OFF_ACTIVATE_MM
155+
select ARCH_WANT_LD_ORPHAN_WARN
155156
select ARCH_WEAK_RELEASE_ACQUIRE
156157
select BINFMT_ELF
157158
select BUILDTIME_TABLE_SORT

arch/powerpc/Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,6 @@ endif
123123
LDFLAGS_vmlinux-y := -Bstatic
124124
LDFLAGS_vmlinux-$(CONFIG_RELOCATABLE) := -pie
125125
LDFLAGS_vmlinux := $(LDFLAGS_vmlinux-y)
126-
LDFLAGS_vmlinux += $(call ld-option,--orphan-handling=warn)
127126

128127
ifdef CONFIG_PPC64
129128
ifeq ($(call cc-option-yn,-mcmodel=medium),y)

0 commit comments

Comments
 (0)