stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* llvm-nm and lld patches for arm32
@ 2020-10-12 22:32 Nick Desaulniers
  2020-10-14 14:00 ` Sasha Levin
  0 siblings, 1 reply; 2+ messages in thread
From: Nick Desaulniers @ 2020-10-12 22:32 UTC (permalink / raw)
  To: Greg KH, Sasha Levin
  Cc: # 3.4.x, clang-built-linux, Masahiro Yamada, Russell King,
	Dmitry Golovin, Matthias Männich, Nathan Chancellor

[-- Attachment #1: Type: text/plain, Size: 819 bytes --]

Dear Stable Maintainers,
Please consider cherry-picking:

commit fe00e50b2db8 ("ARM: 8858/1: vdso: use $(LD) instead of $(CC) to
link VDSO")

to linux-4.19.y.

It cherry picks cleanly and first landed in v5.2-rc1.

It allows us to more easily use ld.lld on arm32 for Android.


Also, please consider cherry-picking:

commit 29c623d64f0d ("ARM: 8939/1: kbuild: use correct nm executable")

to both linux-5.4.y and linux-4.19.y.

It cherry picks cleanly and first landed in v5.5-rc1.

It allows us to more easily use llvm-nm on arm32 for Android.


I've attached both backports as mbox files. Please let me know if it
would be preferable in the future for me to have one email per patch
being backported.  I tested both locally, and the patches are passing
our presubmit testing in Android.
-- 
Thanks,
~Nick Desaulniers

[-- Attachment #2: 5.4.arm.llvm-nm.mbox --]
[-- Type: application/octet-stream, Size: 2447 bytes --]

From 59770e1f9b6e4b939cdc0cf1bee2e94325abc23a Mon Sep 17 00:00:00 2001
From: Dmitry Golovin <dima@golovin.in>
Date: Tue, 19 Nov 2019 16:39:42 +0100
Subject: [PATCH] ARM: 8939/1: kbuild: use correct nm executable

commit 29c623d64f0dcd6aa10e0eabd16233e77114090b upstream.

Since $(NM) variable can be easily overridden for the whole build, it's
better to use it instead of $(CROSS_COMPILE)nm. The use of $(CROSS_COMPILE)
prefixed variables where their calculated equivalents can be used is
incorrect. This fixes issues with builds where $(NM) is set to llvm-nm.

Link: https://github.com/ClangBuiltLinux/linux/issues/766

Signed-off-by: Dmitry Golovin <dima@golovin.in>
Suggested-by: Nick Desaulniers <ndesaulniers@google.com>
Cc: Matthias Maennich <maennich@google.com>
Reviewed-by: Nathan Chancellor <natechancellor@gmail.com>
Tested-by: Nathan Chancellor <natechancellor@gmail.com>
Reviewed-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
---
 arch/arm/boot/compressed/Makefile | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm/boot/compressed/Makefile b/arch/arm/boot/compressed/Makefile
index 1483966dcf23..6da67789ac22 100644
--- a/arch/arm/boot/compressed/Makefile
+++ b/arch/arm/boot/compressed/Makefile
@@ -121,7 +121,7 @@ ccflags-y := -fpic $(call cc-option,-mno-single-pic-base,) -fno-builtin \
 asflags-y := -DZIMAGE
 
 # Supply kernel BSS size to the decompressor via a linker symbol.
-KBSS_SZ = $(shell echo $$(($$($(CROSS_COMPILE)nm $(obj)/../../../../vmlinux | \
+KBSS_SZ = $(shell echo $$(($$($(NM) $(obj)/../../../../vmlinux | \
 		sed -n -e 's/^\([^ ]*\) [AB] __bss_start$$/-0x\1/p' \
 		       -e 's/^\([^ ]*\) [AB] __bss_stop$$/+0x\1/p') )) )
 LDFLAGS_vmlinux = --defsym _kernel_bss_size=$(KBSS_SZ)
@@ -165,7 +165,7 @@ $(obj)/bswapsdi2.S: $(srctree)/arch/$(SRCARCH)/lib/bswapsdi2.S
 # The .data section is already discarded by the linker script so no need
 # to bother about it here.
 check_for_bad_syms = \
-bad_syms=$$($(CROSS_COMPILE)nm $@ | sed -n 's/^.\{8\} [bc] \(.*\)/\1/p') && \
+bad_syms=$$($(NM) $@ | sed -n 's/^.\{8\} [bc] \(.*\)/\1/p') && \
 [ -z "$$bad_syms" ] || \
   ( echo "following symbols must have non local/private scope:" >&2; \
     echo "$$bad_syms" >&2; false )
-- 
2.28.0.1011.ga647a8990f-goog


[-- Attachment #3: 4.19.arm.lld.llvm-nm.mbox --]
[-- Type: application/octet-stream, Size: 5467 bytes --]

From 6b1d02e796408ffc436d950e322b205700c55fb4 Mon Sep 17 00:00:00 2001
From: Masahiro Yamada <yamada.masahiro@socionext.com>
Date: Thu, 18 Apr 2019 10:57:49 +0100
Subject: [PATCH 1/2] ARM: 8858/1: vdso: use $(LD) instead of $(CC) to link
 VDSO

commit fe00e50b2db8c60e4ec90befad1f5bab8ca2c800 upstream.

We use $(LD) to link vmlinux, modules, decompressors, etc.

VDSO is the only exceptional case where $(CC) is used as the linker
driver, but I do not know why we need to do so. VDSO uses a special
linker script, and does not link standard libraries at all.

I changed the Makefile to use $(LD) rather than $(CC). I confirmed
the same vdso.so.raw was still produced.

Users will be able to use their favorite linker (e.g. lld instead of
of bfd) by passing LD= from the command line.

My plan is to rewrite all VDSO Makefiles to use $(LD), then delete

cc-ldoption.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
---
 arch/arm/vdso/Makefile | 21 ++++++++-------------
 1 file changed, 8 insertions(+), 13 deletions(-)

diff --git a/arch/arm/vdso/Makefile b/arch/arm/vdso/Makefile
index f4efff9d3afb..fadf554d9391 100644
--- a/arch/arm/vdso/Makefile
+++ b/arch/arm/vdso/Makefile
@@ -10,12 +10,12 @@ obj-vdso := $(addprefix $(obj)/, $(obj-vdso))
 ccflags-y := -fPIC -fno-common -fno-builtin -fno-stack-protector
 ccflags-y += -DDISABLE_BRANCH_PROFILING
 
-VDSO_LDFLAGS := -Wl,-Bsymbolic -Wl,--no-undefined -Wl,-soname=linux-vdso.so.1
-VDSO_LDFLAGS += -Wl,-z,max-page-size=4096 -Wl,-z,common-page-size=4096
-VDSO_LDFLAGS += -nostdlib -shared
-VDSO_LDFLAGS += $(call cc-ldoption, -Wl$(comma)--hash-style=sysv)
-VDSO_LDFLAGS += $(call cc-ldoption, -Wl$(comma)--build-id)
-VDSO_LDFLAGS += $(call cc-ldoption, -fuse-ld=bfd)
+ldflags-y = -Bsymbolic --no-undefined -soname=linux-vdso.so.1 \
+	    -z max-page-size=4096 -z common-page-size=4096 \
+	    -nostdlib -shared \
+	    $(call ld-option, --hash-style=sysv) \
+	    $(call ld-option, --build-id) \
+	    -T
 
 obj-$(CONFIG_VDSO) += vdso.o
 extra-$(CONFIG_VDSO) += vdso.lds
@@ -37,8 +37,8 @@ KCOV_INSTRUMENT := n
 $(obj)/vdso.o : $(obj)/vdso.so
 
 # Link rule for the .so file
-$(obj)/vdso.so.raw: $(src)/vdso.lds $(obj-vdso) FORCE
-	$(call if_changed,vdsold)
+$(obj)/vdso.so.raw: $(obj)/vdso.lds $(obj-vdso) FORCE
+	$(call if_changed,ld)
 
 $(obj)/vdso.so.dbg: $(obj)/vdso.so.raw $(obj)/vdsomunge FORCE
 	$(call if_changed,vdsomunge)
@@ -48,11 +48,6 @@ $(obj)/%.so: OBJCOPYFLAGS := -S
 $(obj)/%.so: $(obj)/%.so.dbg FORCE
 	$(call if_changed,objcopy)
 
-# Actual build commands
-quiet_cmd_vdsold = VDSO    $@
-      cmd_vdsold = $(CC) $(c_flags) $(VDSO_LDFLAGS) \
-                   -Wl,-T $(filter %.lds,$^) $(filter %.o,$^) -o $@
-
 quiet_cmd_vdsomunge = MUNGE   $@
       cmd_vdsomunge = $(objtree)/$(obj)/vdsomunge $< $@
 
-- 
2.28.0.1011.ga647a8990f-goog


From 87e3ab51e723f8125517d5720825b14bd0f6e262 Mon Sep 17 00:00:00 2001
From: Dmitry Golovin <dima@golovin.in>
Date: Tue, 19 Nov 2019 16:39:42 +0100
Subject: [PATCH 2/2] ARM: 8939/1: kbuild: use correct nm executable

commit 29c623d64f0dcd6aa10e0eabd16233e77114090b upstream.

Since $(NM) variable can be easily overridden for the whole build, it's
better to use it instead of $(CROSS_COMPILE)nm. The use of $(CROSS_COMPILE)
prefixed variables where their calculated equivalents can be used is
incorrect. This fixes issues with builds where $(NM) is set to llvm-nm.

Link: https://github.com/ClangBuiltLinux/linux/issues/766

Signed-off-by: Dmitry Golovin <dima@golovin.in>
Suggested-by: Nick Desaulniers <ndesaulniers@google.com>
Cc: Matthias Maennich <maennich@google.com>
Reviewed-by: Nathan Chancellor <natechancellor@gmail.com>
Tested-by: Nathan Chancellor <natechancellor@gmail.com>
Reviewed-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
---
 arch/arm/boot/compressed/Makefile | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm/boot/compressed/Makefile b/arch/arm/boot/compressed/Makefile
index 1f5a5ffe7fcf..c762004572ef 100644
--- a/arch/arm/boot/compressed/Makefile
+++ b/arch/arm/boot/compressed/Makefile
@@ -120,7 +120,7 @@ ccflags-y := -fpic $(call cc-option,-mno-single-pic-base,) -fno-builtin -I$(obj)
 asflags-y := -DZIMAGE
 
 # Supply kernel BSS size to the decompressor via a linker symbol.
-KBSS_SZ = $(shell echo $$(($$($(CROSS_COMPILE)nm $(obj)/../../../../vmlinux | \
+KBSS_SZ = $(shell echo $$(($$($(NM) $(obj)/../../../../vmlinux | \
 		sed -n -e 's/^\([^ ]*\) [AB] __bss_start$$/-0x\1/p' \
 		       -e 's/^\([^ ]*\) [AB] __bss_stop$$/+0x\1/p') )) )
 LDFLAGS_vmlinux = --defsym _kernel_bss_size=$(KBSS_SZ)
@@ -166,7 +166,7 @@ $(obj)/bswapsdi2.S: $(srctree)/arch/$(SRCARCH)/lib/bswapsdi2.S
 # The .data section is already discarded by the linker script so no need
 # to bother about it here.
 check_for_bad_syms = \
-bad_syms=$$($(CROSS_COMPILE)nm $@ | sed -n 's/^.\{8\} [bc] \(.*\)/\1/p') && \
+bad_syms=$$($(NM) $@ | sed -n 's/^.\{8\} [bc] \(.*\)/\1/p') && \
 [ -z "$$bad_syms" ] || \
   ( echo "following symbols must have non local/private scope:" >&2; \
     echo "$$bad_syms" >&2; rm -f $@; false )
-- 
2.28.0.1011.ga647a8990f-goog


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: llvm-nm and lld patches for arm32
  2020-10-12 22:32 llvm-nm and lld patches for arm32 Nick Desaulniers
@ 2020-10-14 14:00 ` Sasha Levin
  0 siblings, 0 replies; 2+ messages in thread
From: Sasha Levin @ 2020-10-14 14:00 UTC (permalink / raw)
  To: Nick Desaulniers
  Cc: Greg KH, # 3.4.x, clang-built-linux, Masahiro Yamada,
	Russell King, Dmitry Golovin, Matthias Männich,
	Nathan Chancellor

On Mon, Oct 12, 2020 at 03:32:46PM -0700, Nick Desaulniers wrote:
>Dear Stable Maintainers,
>Please consider cherry-picking:
>
>commit fe00e50b2db8 ("ARM: 8858/1: vdso: use $(LD) instead of $(CC) to
>link VDSO")
>
>to linux-4.19.y.
>
>It cherry picks cleanly and first landed in v5.2-rc1.
>
>It allows us to more easily use ld.lld on arm32 for Android.
>
>
>Also, please consider cherry-picking:
>
>commit 29c623d64f0d ("ARM: 8939/1: kbuild: use correct nm executable")
>
>to both linux-5.4.y and linux-4.19.y.
>
>It cherry picks cleanly and first landed in v5.5-rc1.
>
>It allows us to more easily use llvm-nm on arm32 for Android.

I've queued up the patches.

>I've attached both backports as mbox files. Please let me know if it
>would be preferable in the future for me to have one email per patch
>being backported.  I tested both locally, and the patches are passing
>our presubmit testing in Android.

If the patches apply cleanly and pass your tests as-is, it's enough to
just list the commits and let us cherry pick. No need to attach the
patches to the mail.

-- 
Thanks,
Sasha

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-10-14 14:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-12 22:32 llvm-nm and lld patches for arm32 Nick Desaulniers
2020-10-14 14:00 ` Sasha Levin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).