From 2e93fd86ddbdf1c8617d5891afc01f833acb9bdd Mon Sep 17 00:00:00 2001 From: kettenis Date: Thu, 26 Jul 2018 13:20:53 +0000 Subject: [PATCH] Add infrastructure to install lld as the default linker. The old GNU linker will be installed as /usr/bin/ld.bfd on supported systems. This allows users to fall back on the old linker by using the -fuse-ld=bfd option on systems where lld is the default linker. Switch armv7 to use lld as the default linker. On arm64 we already use lld as the default linker. Other platforms will keep using the GNU linker for now. ok patrick@, deraadt@, phessler@ --- gnu/usr.bin/binutils-2.17/Makefile.bsd-wrapper | 14 +++++++++++--- gnu/usr.bin/binutils-2.17/ld/Makefile.in | 2 +- gnu/usr.bin/clang/lld/Makefile | 4 ++-- share/mk/bsd.own.mk | 9 ++++++++- 4 files changed, 22 insertions(+), 7 deletions(-) diff --git a/gnu/usr.bin/binutils-2.17/Makefile.bsd-wrapper b/gnu/usr.bin/binutils-2.17/Makefile.bsd-wrapper index e7c44d0d8bf..81634c49866 100644 --- a/gnu/usr.bin/binutils-2.17/Makefile.bsd-wrapper +++ b/gnu/usr.bin/binutils-2.17/Makefile.bsd-wrapper @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile.bsd-wrapper,v 1.14 2017/06/12 18:49:34 espie Exp $ +# $OpenBSD: Makefile.bsd-wrapper,v 1.15 2018/07/26 13:20:53 kettenis Exp $ .include @@ -35,7 +35,10 @@ MAN+= binutils/doc/ar.1 binutils/doc/ranlib.1 \ SUBDIRS+= ld gas CONF_SUBDIRS+= ld gas INST_SUBDIRS+= ld gas -MAN+= gas/doc/as.1 ld/ld.1 +MAN+= gas/doc/as.1 ld/ld.bfd.1 +.if ${LINKER_VERSION:L} == "bfd" +MLINKS+= ld.bfd.1 ld.1 +.endif .endif # Used by the GNU Makefile @@ -96,8 +99,9 @@ do-config: .USE gas/doc/as.1: config.status cd ${.OBJDIR}/gas/doc && ${MAKE} as.1 -ld/ld.1: config.status +ld/ld.bfd.1: config.status cd ${.OBJDIR}/ld && ${MAKE} ld.1 + mv ld/ld.1 ld/ld.bfd.1 config: do-config .ifndef GLOBAL_AUTOCONF_CACHE @@ -120,6 +124,10 @@ install: maninstall INSTALL_DATA='${INSTALL} -c -o ${DOCOWN} -g ${DOCGRP} -m ${NONBINMODE}' \ INSTALL_INFO_HOST_MODULES='${INSTALL_INFO_HOST_MODULES}' \ install install-info +.if ${LINKER_VERSION:L} == "bfd" + rm -f ${DESTDIR}${PREFIX}/bin/ld + ln ${DESTDIR}${PREFIX}/bin/ld.bfd ${DESTDIR}${PREFIX}/bin/ld +.endif clean cleandir: -@if [ -e Makefile ]; then ${MAKE} distclean; fi diff --git a/gnu/usr.bin/binutils-2.17/ld/Makefile.in b/gnu/usr.bin/binutils-2.17/ld/Makefile.in index 5436b9f2832..fbf0fd7da18 100644 --- a/gnu/usr.bin/binutils-2.17/ld/Makefile.in +++ b/gnu/usr.bin/binutils-2.17/ld/Makefile.in @@ -142,7 +142,7 @@ EMUL = @EMUL@ EMULATION_LIBPATH = @EMULATION_LIBPATH@ EMULATION_OFILES = @EMULATION_OFILES@ EMUL_EXTRA_OFILES = @EMUL_EXTRA_OFILES@ -EXEEXT = @EXEEXT@ +EXEEXT = .bfd GMOFILES = @GMOFILES@ GMSGFMT = @GMSGFMT@ GT_NO = @GT_NO@ diff --git a/gnu/usr.bin/clang/lld/Makefile b/gnu/usr.bin/clang/lld/Makefile index d133133ae5e..130ef1c1558 100644 --- a/gnu/usr.bin/clang/lld/Makefile +++ b/gnu/usr.bin/clang/lld/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.13 2018/04/06 14:44:04 patrick Exp $ +# $OpenBSD: Makefile,v 1.14 2018/07/26 13:20:53 kettenis Exp $ .include @@ -7,7 +7,7 @@ BINDIR= /usr/bin SRCS= lld.cpp TARGET_ARCH?= ${MACHINE_ARCH} -.if ${TARGET_ARCH} == "aarch64" +.if ${LINKER_VERSION:L} == "lld" LINKS= ${BINDIR}/ld.lld ${BINDIR}/ld MLINKS= ld.lld.1 ld.1 .endif diff --git a/share/mk/bsd.own.mk b/share/mk/bsd.own.mk index 2dcbb3b1a7a..b7e1a0f6f0b 100644 --- a/share/mk/bsd.own.mk +++ b/share/mk/bsd.own.mk @@ -1,4 +1,4 @@ -# $OpenBSD: bsd.own.mk,v 1.189 2018/01/19 16:54:54 kettenis Exp $ +# $OpenBSD: bsd.own.mk,v 1.190 2018/07/26 13:20:53 kettenis Exp $ # $NetBSD: bsd.own.mk,v 1.24 1996/04/13 02:08:09 thorpej Exp $ # Host-specific overrides @@ -18,6 +18,7 @@ YP?= yes CLANG_ARCH=aarch64 amd64 arm i386 sparc64 GCC4_ARCH=alpha hppa mips64 mips64el powerpc sh sparc64 GCC3_ARCH=m88k +LLD_ARCH=aarch64 arm # m88k: ? PIE_ARCH=alpha amd64 arm hppa i386 mips64 mips64el powerpc sh sparc64 @@ -49,6 +50,12 @@ BUILD_CLANG?=yes BUILD_CLANG?=no .endif +.if !empty(LLD_ARCH:M${_arch}) +LINKER_VERSION?=lld +.else +LINKER_VERSION?=bfd +.endif + .if !empty(STATICPIE_ARCH:M${_arch}) STATICPIE?=-pie .endif -- 2.20.1