> Date: Sun, 22 Jan 2017 11:47:46 +1000
> From: Patrick Wildt <[email protected]>
>
> Hi,
>
> for arm64 our goal is to use lld. Even though we really need lld 4.0,
> which is not yet released, it is already a good start to have lld 3.9.1
> make infrastructure available. This diff adds the neccesary Makefiles
> and modified lld to not use Mach-O/COFF (so that we don't need those
> libraries as well).
>
> ok?
ok kettenis@
> diff --git a/gnu/llvm/tools/lld/tools/lld/lld.cpp
> b/gnu/llvm/tools/lld/tools/lld/lld.cpp
> index 8805e02e8c4..0623b17c8b8 100644
> --- a/gnu/llvm/tools/lld/tools/lld/lld.cpp
> +++ b/gnu/llvm/tools/lld/tools/lld/lld.cpp
> @@ -104,10 +104,12 @@ int main(int Argc, const char **Argv) {
> switch (parseFlavor(Args)) {
> case Gnu:
> return !elf::link(Args);
> +#ifndef __OpenBSD__
> case WinLink:
> return !coff::link(Args);
> case Darwin:
> return !mach_o::link(Args);
> +#endif
> default:
> die("lld is a generic driver.\n"
> "Invoke ld.lld (Unix), ld (Mac) or lld-link (Windows) instead.");
> diff --git a/gnu/usr.bin/clang/Makefile b/gnu/usr.bin/clang/Makefile
> index 3fe54e8030f..f8a1dbebe0c 100644
> --- a/gnu/usr.bin/clang/Makefile
> +++ b/gnu/usr.bin/clang/Makefile
> @@ -41,6 +41,8 @@ SUBDIR+=libLLVMProfileData
> SUBDIR+=libLLVMCoverage
> SUBDIR+=libLLVMDebugInfoCodeView
> SUBDIR+=libLLVMGlobalISel
> +SUBDIR+=libLLVMLTO
> +SUBDIR+=libLLVMPasses
>
> .if ${LLVM_ARCH} != ""
> SUBDIR+=include/llvm/${LLVM_ARCH}
> @@ -70,5 +72,11 @@ SUBDIR+=libclangFrontendTool
>
> SUBDIR+=clang
>
> +SUBDIR+=liblldConfig
> +SUBDIR+=liblldCore
> +SUBDIR+=liblldELF
> +
> +SUBDIR+=lld
> +
> .include <bsd.obj.mk>
> .include <bsd.subdir.mk>
> diff --git a/gnu/usr.bin/clang/include/lld/Config/Version.inc
> b/gnu/usr.bin/clang/include/lld/Config/Version.inc
> new file mode 100644
> index 00000000000..b13178ffaa5
> --- /dev/null
> +++ b/gnu/usr.bin/clang/include/lld/Config/Version.inc
> @@ -0,0 +1,5 @@
> +/* $OpenBSD: Version.inc,v 1.2 2017/01/14 20:12:41 patrick Exp $ */
> +
> +#define LLD_VERSION 3.9.1
> +#define LLD_VERSION_MAJOR 3
> +#define LLD_VERSION_MINOR 9
> diff --git a/gnu/usr.bin/clang/libLLVMLTO/Makefile
> b/gnu/usr.bin/clang/libLLVMLTO/Makefile
> new file mode 100644
> index 00000000000..d2ee9ead2e4
> --- /dev/null
> +++ b/gnu/usr.bin/clang/libLLVMLTO/Makefile
> @@ -0,0 +1,24 @@
> +# $OpenBSD: Makefile,v 1.2 2017/01/14 20:12:41 patrick Exp $
> +
> +LIB= LLVMLTO
> +NOPIC=
> +NOPROFILE=
> +
> +CPPFLAGS+= -I${LLVM_SRCS}/include/llvm/LTO
> +
> +.include <bsd.own.mk>
> +SRCS= LTO.cpp \
> + LTOModule.cpp \
> + LTOCodeGenerator.cpp \
> + UpdateCompilerUsed.cpp \
> + ThinLTOCodeGenerator.cpp
> +
> +.PATH: ${.CURDIR}/../../../llvm/lib/LTO
> +
> +depend:
> + # Nothing here so far ...
> +
> +install:
> + # Nothing here so far ...
> +
> +.include <bsd.lib.mk>
> diff --git a/gnu/usr.bin/clang/libLLVMPasses/Makefile
> b/gnu/usr.bin/clang/libLLVMPasses/Makefile
> new file mode 100644
> index 00000000000..8edb7f71c4d
> --- /dev/null
> +++ b/gnu/usr.bin/clang/libLLVMPasses/Makefile
> @@ -0,0 +1,20 @@
> +# $OpenBSD: Makefile,v 1.2 2017/01/14 20:12:41 patrick Exp $
> +
> +LIB= LLVMPasses
> +NOPIC=
> +NOPROFILE=
> +
> +CPPFLAGS+= -I${LLVM_SRCS}/include/llvm/Passes
> +
> +.include <bsd.own.mk>
> +SRCS= PassBuilder.cpp
> +
> +.PATH: ${.CURDIR}/../../../llvm/lib/Passes
> +
> +depend:
> + # Nothing here so far ...
> +
> +install:
> + # Nothing here so far ...
> +
> +.include <bsd.lib.mk>
> diff --git a/gnu/usr.bin/clang/liblldConfig/Makefile
> b/gnu/usr.bin/clang/liblldConfig/Makefile
> new file mode 100644
> index 00000000000..1ceb93e66a9
> --- /dev/null
> +++ b/gnu/usr.bin/clang/liblldConfig/Makefile
> @@ -0,0 +1,19 @@
> +# $OpenBSD: Makefile,v 1.1 2016/09/05 10:56:50 pascal Exp $
> +
> +LIB= lldConfig
> +NOPROFILE=
> +
> +CPPFLAGS+= -I${LLVM_SRCS}/tools/lld/include
> +
> +.include <bsd.own.mk>
> +SRCS= Version.cpp
> +
> +.PATH: ${.CURDIR}/../../../llvm/tools/lld/lib/Config
> +
> +depend:
> + # Nothing here so far ...
> +
> +install:
> + # Nothing here so far ...
> +
> +.include <bsd.lib.mk>
> diff --git a/gnu/usr.bin/clang/liblldCore/Makefile
> b/gnu/usr.bin/clang/liblldCore/Makefile
> new file mode 100644
> index 00000000000..b35185dc8f0
> --- /dev/null
> +++ b/gnu/usr.bin/clang/liblldCore/Makefile
> @@ -0,0 +1,26 @@
> +# $OpenBSD: Makefile,v 1.1 2016/09/05 10:56:50 pascal Exp $
> +
> +LIB= lldCore
> +NOPROFILE=
> +
> +CPPFLAGS+= -I${LLVM_SRCS}/tools/lld/include
> +
> +.include <bsd.own.mk>
> +SRCS= DefinedAtom.cpp \
> + Error.cpp \
> + File.cpp \
> + LinkingContext.cpp \
> + Reader.cpp \
> + Resolver.cpp \
> + SymbolTable.cpp \
> + Writer.cpp
> +
> +.PATH: ${.CURDIR}/../../../llvm/tools/lld/lib/Core
> +
> +depend:
> + # Nothing here so far ...
> +
> +install:
> + # Nothing here so far ...
> +
> +.include <bsd.lib.mk>
> diff --git a/gnu/usr.bin/clang/liblldELF/Makefile
> b/gnu/usr.bin/clang/liblldELF/Makefile
> new file mode 100644
> index 00000000000..cc56bf0a8f3
> --- /dev/null
> +++ b/gnu/usr.bin/clang/liblldELF/Makefile
> @@ -0,0 +1,45 @@
> +# $OpenBSD: Makefile,v 1.1 2016/09/05 10:56:50 pascal Exp $
> +
> +LIB= lldELF
> +NOPROFILE=
> +
> +CPPFLAGS+= -I${LLVM_SRCS}/tools/lld/include
> +
> +.include <bsd.own.mk>
> +SRCS= Driver.cpp \
> + DriverUtils.cpp \
> + EhFrame.cpp \
> + Error.cpp \
> + ICF.cpp \
> + InputFiles.cpp \
> + InputSection.cpp \
> + LinkerScript.cpp \
> + LTO.cpp \
> + MarkLive.cpp \
> + OutputSections.cpp \
> + Relocations.cpp \
> + ScriptParser.cpp \
> + Strings.cpp \
> + SymbolListFile.cpp \
> + SymbolTable.cpp \
> + Symbols.cpp \
> + Target.cpp \
> + Thunks.cpp \
> + Writer.cpp
> +
> +.PATH: ${.CURDIR}/../../../llvm/tools/lld/ELF
> +
> +Driver.o: Options.inc
> +
> +Options.inc: Options.td
> + ${.OBJDIR}/../llvm-tblgen/llvm-tblgen -gen-opt-parser-defs \
> + -I ${LLVM_SRCS}/include \
> + -o ${.TARGET} ${.ALLSRC}
> +
> +depend:
> + # Nothing here so far ...
> +
> +install:
> + # Nothing here so far ...
> +
> +.include <bsd.lib.mk>
> diff --git a/gnu/usr.bin/clang/lld/Makefile b/gnu/usr.bin/clang/lld/Makefile
> new file mode 100644
> index 00000000000..286a4ab5eb9
> --- /dev/null
> +++ b/gnu/usr.bin/clang/lld/Makefile
> @@ -0,0 +1,59 @@
> +# $OpenBSD: Makefile,v 1.2 2017/01/14 20:12:41 patrick Exp $
> +
> +NOMAN=
> +PROG= lld
> +BINDIR= /usr/bin
> +SRCS= lld.cpp
> +
> +LDADD+= -ltermlib
> +DPADD+= ${LIBTERMLIB}
> +
> +CPPFLAGS+= ${CLANG_INCLUDES}
> +CPPFLAGS+= -I${.CURDIR}/../../../llvm/tools/lld/include
> +
> +.PATH: ${.CURDIR}/../../../llvm/tools/lld/tools/lld
> +
> +depend:
> + # Nothing here so far ...
> +
> +LLVM_LIBDEPS= lldCore \
> + lldELF \
> + lldConfig \
> + LLVMLTO \
> + LLVMPasses \
> + LLVMOption \
> + LLVMObjCARCOpts \
> + LLVMipo \
> + LLVMVectorize \
> + LLVMLinker \
> + LLVMIRReader \
> + LLVMAsmParser \
> + ${BACKEND_ASMPARSER} \
> + ${BACKEND_CODEGEN} \
> + LLVMSelectionDAG \
> + LLVMAsmPrinter \
> + LLVMCodeGen \
> + LLVMTarget \
> + LLVMScalarOpts \
> + LLVMInstCombine \
> + LLVMInstrumentation \
> + LLVMProfileData \
> + LLVMCoverage \
> + LLVMDebugInfoCodeView \
> + LLVMGlobalISel \
> + LLVMTransformUtils \
> + LLVMBitWriter \
> + LLVMAnalysis \
> + ${BACKEND_DESC} \
> + LLVMObject \
> + LLVMMCParser \
> + LLVMBitReader \
> + LLVMMCDisassembler \
> + ${BACKEND_INFO} \
> + ${BACKEND_ASMPRINTER} \
> + LLVMMC \
> + ${BACKEND_UTILS} \
> + LLVMCore \
> + LLVMSupport
> +
> +.include <bsd.prog.mk>
>
>