diff options
author | Ben Hutchings <ben@decadent.org.uk> | 2020-08-29 22:29:52 +0100 |
---|---|---|
committer | Ben Hutchings <ben@decadent.org.uk> | 2020-08-29 22:53:10 +0100 |
commit | 95a3123c94abc28c65f33c9589693dde9f140fe1 (patch) | |
tree | 54c46bd2685740885711f4b7f1641b489bef0335 | |
parent | c56bb7ba64124c6e2324a52b2cd5cec79dbbb050 (diff) | |
download | klibc-95a3123c94abc28c65f33c9589693dde9f140fe1.tar.gz |
[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@decadent.org.uk>
-rw-r--r-- | klcc/Kbuild | 1 | ||||
-rw-r--r-- | klcc/klcc.in | 2 | ||||
-rw-r--r-- | scripts/Kbuild.klibc | 2 | ||||
-rw-r--r-- | usr/klibc/Kbuild | 3 |
4 files changed, 6 insertions, 2 deletions
diff --git a/klcc/Kbuild b/klcc/Kbuild index 0e625802a30450..ca46c6ce1f211b 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 7b3b8f3b7d6b75..fab32391443a85 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"); -@sharedopt = (@EMAIN, "${prefix}/${KCROSS}lib/interp.o"); +@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 bfe6edb3aa0157..28b5e85629a764 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 0a1933e6d6406a..dea94d06218d8a 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)/ |