ifeq (yes,$(build-shared))
# These indicate whether to link using the built ld.so or the installed one.
+ifeq ($(with-lld),no)
installed-rtld-LDFLAGS = -Wl,-dynamic-linker=$(rtlddir)/$(rtld-installed-name)
built-rtld-LDFLAGS = -Wl,-dynamic-linker=$(elf-objpfx)ld.so
+else
+installed-rtld-LDFLAGS = -Wl,-dynamic-linker,$(rtlddir)/$(rtld-installed-name)
+built-rtld-LDFLAGS = -Wl,-dynamic-linker,$(elf-objpfx)ld.so
+endif
ifndef rtld-LDFLAGS
rtld-LDFLAGS = $(installed-rtld-LDFLAGS)
# Non-string format arguments come from debugging prints in ld.so.
+cflags += -Wno-format-security
+ifeq ($(with-lld),yes)
+LDFLAGS.so += -fuse-ld=lld
+LDFLAGS-rtld += -fuse-ld=lld
+LDFLAGS += -fuse-ld=lld
+endif
+
endif # with-clang == yes
+cflags += $(cflags-cpu) $(+gccwarn) $(+merge-constants) $(+math-flags) \
with_binutils
with_selinux
with_clang
+with_lld
with_headers
with_default_link
enable_sanity_checks
--with-binutils=PATH specify location of binutils (as and ld)
--with-selinux if building with SELinux support
--with-clang if building with clang (temporary)
+ --with-lld if building/linking with lld (temporary)
--with-headers=PATH location of system headers to use (for example
/usr/src/linux/include) [default=compiler default]
--with-default-link do not use explicit linker scripts
config_vars="$config_vars
with-clang = $with_clang"
+# Check whether --with-lld was given.
+if test "${with_lld+set}" = set; then :
+ withval=$with_lld; with_lld=$withval
+else
+ with_lld=no
+fi
+
+config_vars="$config_vars
+with-lld = $with_lld"
+
# Check whether --with-headers was given.
if test "${with_headers+set}" = set; then :
gnu_ld=$libc_cv_prog_ld_gnu
+if test "$with_clang" = no; then
# Accept binutils 2.25 or newer.
for ac_prog in $AS
do
AS=: critic_missing="$critic_missing as"
fi
+fi
+if test "$with_lld" = no; then
if test -n "`$LD --version | sed -n 's/^GNU \(gold\).*$/\1/p'`"; then
# Accept gold 1.14 or higher
for ac_prog in $LD
LD=: critic_missing="$critic_missing GNU ld"
fi
+fi
fi
# These programs are version sensitive.
[with_clang=$withval],
[with_clang=no])
LIBC_CONFIG_VAR([with-clang], [$with_clang])
+dnl This is a temporary hack, to help with BFD LD vs LLD debugging.
+AC_ARG_WITH([lld],
+ AC_HELP_STRING([--with-lld],
+ [if building/linking with lld (temporary)]),
+ [with_lld=$withval],
+ [with_lld=no])
+LIBC_CONFIG_VAR([with-lld], [$with_lld])
AC_ARG_WITH([headers],
AC_HELP_STRING([--with-headers=PATH],
LIBC_PROG_BINUTILS
+if test "$with_clang" = no; then
# Accept binutils 2.25 or newer.
AC_CHECK_PROG_VER(AS, $AS, --version,
[GNU assembler.* \([0-9]*\.[0-9.]*\)],
[2.1[0-9][0-9]*|2.2[5-9]*|2.[3-9][0-9]*|[3-9].*|[1-9][0-9]*],
AS=: critic_missing="$critic_missing as")
+fi
+if test "$with_lld" = no; then
if test -n "`$LD --version | sed -n 's/^GNU \(gold\).*$/\1/p'`"; then
# Accept gold 1.14 or higher
AC_CHECK_PROG_VER(LD, $LD, --version,
[2.1[0-9][0-9]*|2.2[5-9]*|2.[3-9][0-9]*|[3-9].*|[1-9][0-9]*],
LD=: critic_missing="$critic_missing GNU ld")
fi
+fi
# These programs are version sensitive.
AC_CHECK_TOOL_PREFIX
rm -f $@.o
mv -f $@T $@
+# For lld, add to regexp below for optional address and size to be at front of line.
$(objpfx)librtld.mk: $(objpfx)librtld.map Makefile
LC_ALL=C \
- sed -n 's@^$(common-objpfx)\([^(]*\)(\([^)]*\.os\)) *.*$$@\1 \2@p' \
+ sed -n 's@^[0-9a-f ]*$(common-objpfx)\([^(]*\)(\([^)]*\.os\)) *.*$$@\1 \2@p' \
$< | \
while read lib file; do \
case $$lib in \
#endif
_dl_setup_hash (&GL(dl_rtld_map));
GL(dl_rtld_map).l_real = &GL(dl_rtld_map);
+#if defined(__clang__)
+ /* Work around an lld complaint that _begin cannot have a reloc and
+ also be absolute because of _begin=0 on linker line. */
+ GL(dl_rtld_map).l_map_start = (ElfW(Addr)) 0;
+#else
GL(dl_rtld_map).l_map_start = (ElfW(Addr)) _begin;
+#endif
GL(dl_rtld_map).l_map_end = (ElfW(Addr)) _end;
GL(dl_rtld_map).l_text_end = (ElfW(Addr)) _etext;
/* Copy the TLS related data if necessary. */