From: Stan Shebs Date: Tue, 9 Jun 2020 17:09:34 +0000 (-0700) Subject: Use crt*.o files from llvm compiler-rt when building with clang X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e62db8fce49a3437dbda71e4b7058954595939f5;p=thirdparty%2Fglibc.git Use crt*.o files from llvm compiler-rt when building with clang --- diff --git a/Makeconfig b/Makeconfig index ff744a8f0d0..f5cd92014f1 100644 --- a/Makeconfig +++ b/Makeconfig @@ -661,20 +661,40 @@ libc.so-gnulib := -lgcc endif +preinit = $(addprefix $(csu-objpfx),crti.o) +postinit = $(addprefix $(csu-objpfx),crtn.o) +ifeq ($(with-clang),yes) +# With clang, use the crt*.o files from llvm's compiler-rt package. +# The files normally have an architecture name appended, in case of +# variants (32/64, le/be etc) installed in the same directory. ++prector = `$(CC) $(sysdep-LDFLAGS) --print-file-name=clang_rt.crtbegin-$(config-machine).o` ++postctor = `$(CC) $(sysdep-LDFLAGS) --print-file-name=clang_rt.crtend-$(config-machine).o` +else +prector = `$(CC) $(sysdep-LDFLAGS) --print-file-name=crtbegin.o` +postctor = `$(CC) $(sysdep-LDFLAGS) --print-file-name=crtend.o` +endif # Variants of the two previous definitions for linking PIE programs. +ifeq ($(with-clang),yes) +# compiler-rt crt*.o also works for PIE. ++prectorS = $(+prector) ++postctorS = $(+postctor) +else +prectorS = `$(CC) $(sysdep-LDFLAGS) --print-file-name=crtbeginS.o` +postctorS = `$(CC) $(sysdep-LDFLAGS) --print-file-name=crtendS.o` +endif # Variants of the two previous definitions for statically linking programs. ifeq (yes,$(enable-static-pie)) # Static PIE must use PIE variants. +prectorT = $(+prectorS) +postctorT = $(+postctorS) else +ifeq ($(with-clang),yes) +# compiler-rt crt*.o also works for static PIE. ++prectorT = $(+prector) ++postctorT = $(+postctor) +else +prectorT = `$(CC) $(sysdep-LDFLAGS) --print-file-name=crtbeginT.o` +postctorT = `$(CC) $(sysdep-LDFLAGS) --print-file-name=crtend.o` endif +endif csu-objpfx = $(common-objpfx)csu/ elf-objpfx = $(common-objpfx)elf/