[klibc] [klibc:riscv64-enable-relax] Kbuild, klcc: Support multiple objects in KLIBCCRTSHARED
klibc-bot for Ben Hutchings
ben at decadent.org.uk
Sat Aug 29 15:36:03 PDT 2020
Commit-ID: 95a3123c94abc28c65f33c9589693dde9f140fe1
Gitweb: http://git.kernel.org/?p=libs/klibc/klibc.git;a=commit;h=95a3123c94abc28c65f33c9589693dde9f140fe1
Author: Ben Hutchings <ben at decadent.org.uk>
AuthorDate: Sat, 29 Aug 2020 22:29:52 +0100
Committer: Ben Hutchings <ben at decadent.org.uk>
CommitDate: Sat, 29 Aug 2020 22:53:10 +0100
[klibc] Kbuild, klcc: Support multiple objects in KLIBCCRTSHARED
On some architectures (notably riscv64) we need a wrapper for the main
function that is statically linked even when using a shared library.
* Allow architectures to override KLIBCCRTSHARED (they should always
append to it)
* Change klcc to use the list of filenames in KLIBCCRTSHARED, rather
than assuming it's just interp.o
Signed-off-by: Ben Hutchings <ben at decadent.org.uk>
---
klcc/Kbuild | 1 +
klcc/klcc.in | 2 +-
scripts/Kbuild.klibc | 2 +-
usr/klibc/Kbuild | 3 +++
4 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/klcc/Kbuild b/klcc/Kbuild
index 0e625802..ca46c6ce 100644
--- a/klcc/Kbuild
+++ b/klcc/Kbuild
@@ -21,6 +21,7 @@ $(obj)/$(KLIBCCROSS)klibc.config: $(src)/Kbuild \
$(Q)echo 'STRIP=$(STRIP)' >> $@
$(Q)echo 'STRIPFLAGS=$(KLIBCSTRIPFLAGS)' >> $@
$(Q)echo 'EMAIN=$(KLIBCEMAIN)' >> $@
+ $(Q)echo 'CRTSHARED=$(notdir $(KLIBCCRTSHARED))' >> $@
$(Q)echo 'BITSIZE=$(KLIBCBITSIZE)' >> $@
$(Q)echo 'VERSION=$(shell cat $(srctree)/usr/klibc/version)' >> $@
$(Q)echo 'prefix=$(INSTALLDIR)' >> $@
diff --git a/klcc/klcc.in b/klcc/klcc.in
index 7b3b8f3b..fab32391 100644
--- a/klcc/klcc.in
+++ b/klcc/klcc.in
@@ -17,7 +17,7 @@ use IPC::Open3;
# Options and libraries to pass to ld; shared versus static
@staticopt = ("${prefix}/${KCROSS}lib/crt0.o");
@staticlib = ("${prefix}/${KCROSS}lib/libc.a");
- at sharedopt = (@EMAIN, "${prefix}/${KCROSS}lib/interp.o");
+ at sharedopt = (@EMAIN, map { "${prefix}/${KCROSS}lib/$_" } @CRTSHARED);
@sharedlib = ('-R', "${prefix}/${KCROSS}lib/libc.so");
# Returns the language (-x option string) for a specific extension.
diff --git a/scripts/Kbuild.klibc b/scripts/Kbuild.klibc
index bfe6edb3..28b5e856 100644
--- a/scripts/Kbuild.klibc
+++ b/scripts/Kbuild.klibc
@@ -82,6 +82,7 @@ KLIBCCFLAGS :=
# Defaults for arch to override
KLIBCARCHINCFLAGS =
+KLIBCCRTSHARED := $(KLIBCOBJ)/interp.o
# Arch specific definitions for klibc
include $(srctree)/$(KLIBCSRC)/arch/$(KLIBCARCHDIR)/MCONFIG
@@ -141,7 +142,6 @@ KLIBCLIBGCC_DEF := $(shell $(KLIBCCC) $(KLIBCCFLAGS) $(if $(filter gcc,$(cc-nam
KLIBCLIBGCC ?= $(KLIBCLIBGCC_DEF)
KLIBCCRT0 := $(KLIBCOBJ)/arch/$(KLIBCARCHDIR)/crt0.o
KLIBCLIBC := $(KLIBCOBJ)/libc.a
-KLIBCCRTSHARED := $(KLIBCOBJ)/interp.o
KLIBCLIBCSHARED := $(KLIBCOBJ)/libc.so
# How to tell the linker main() is the entrypoint
KLIBCEMAIN ?= -e main
diff --git a/usr/klibc/Kbuild b/usr/klibc/Kbuild
index 0a1933e6..dea94d06 100644
--- a/usr/klibc/Kbuild
+++ b/usr/klibc/Kbuild
@@ -208,3 +208,6 @@ ifdef KLIBCSHAREDFLAGS
$(Q)$(install-lib) $(obj)/klibc-$(SOLIBHASH).so \
$(INSTALLROOT)$(SHLIBDIR)
endif
+
+# Directories to visit during clean and install
+subdir- := arch/$(KLIBCARCHDIR)/
More information about the klibc
mailing list