llvm-dfbsd: Import llvm-7.0.1 as wip/llvm-dfbsd

CMAKE_ARGS+=	-DLLVM_ENABLE_RTTI=ON
required for some builds of new MesaLib
and a patch for DragonFly
This commit is contained in:
David Shao 2019-02-23 20:59:03 -08:00
parent 7272a6a33c
commit 0b3eb950ce
15 changed files with 1914 additions and 0 deletions

22
llvm-dfbsd/DESCR Normal file
View File

@ -0,0 +1,22 @@
Low Level Virtual Machine (LLVM) is:
A compilation strategy designed to enable effective program optimization across
the entire lifetime of a program. LLVM supports effective optimization at
compile time, link-time (particularly interprocedural), run-time and offline
(i.e., after software is installed), while remaining transparent to developers
and maintaining compatibility with existing build scripts.
A virtual instruction set - LLVM is a low-level object code representation that
uses simple RISC-like instructions, but provides rich, language-independent,
type information and dataflow (SSA) information about operands. This combination
enables sophisticated transformations on object code, while remaining
light-weight enough to be attached to the executable. This combination is key to
allowing link-time, run-time, and offline transformations.
A compiler infrastructure - LLVM is also a collection of source code that
implements the language and compilation strategy. The primary components of the
LLVM infrastructure are the C & C++ front-end, a link-time optimization
framework with a growing set of global and interprocedural analyses and
transformations, static back-ends for the X86, X86-64, PowerPC 32/64, ARM,
Thumb, IA-64 and SPARC architectures, a back-end which emits portable C
code, and a Just-In-Time compiler for X86, X86-64, PowerPC 32/64 processors.

116
llvm-dfbsd/Makefile Normal file
View File

@ -0,0 +1,116 @@
# $NetBSD: Makefile,v 1.37 2019/02/18 16:56:40 minskim Exp $
#
# when updating this, please also update:
# devel/include-what-you-use
# devel/lldb
# devel/polly
# lang/clang
# lang/clang-static-analyzer
# lang/compiler-rt
# lang/libcxx
# lang/libcxxabi
# lang/libunwind
#
# Do not update:
# lang/libLLVM
# because pkgsrc provides multiple versions and lang/libLLVM is
# logically libLLVM4.
#
# Always update all */buildlink3.mk to require the latest stable release
# version in BUILDLINK_API_DEPENDS, as there is no backwards compatibility
DISTNAME= llvm-7.0.1.src
PKGNAME= ${DISTNAME:S/.src//}
# PKGREVISION= 1
CATEGORIES= lang devel
MASTER_SITES= http://llvm.org/releases/${PKGVERSION_NOREV}/
EXTRACT_SUFX= .tar.xz
MAINTAINER= pkgsrc-users@NetBSD.org
HOMEPAGE= http://llvm.org/
COMMENT= Low Level Virtual Machine compiler infrastructure
LICENSE= modified-bsd
USE_LANGUAGES= c c++11
USE_CMAKE= yes
GCC_REQD+= 4.8
PYTHON_FOR_BUILD_ONLY= yes
CONFIGURE_DIRS= ${WRKDIR}/build
CMAKE_ARG_PATH= ${WRKSRC}
CMAKE_ARGS+= -DCMAKE_BUILD_TYPE=Release
CMAKE_ARGS+= -DCMAKE_C_COMPILER=${CC:Q}
CMAKE_ARGS+= -DCMAKE_CXX_COMPILER=${CXX:Q}
CMAKE_ARGS+= -DCMAKE_CXX_LINK_FLAGS=${LDFLAGS:Q}
CMAKE_ARGS+= -DLLVM_BUILD_LLVM_DYLIB=ON
CMAKE_ARGS+= -DLLVM_INSTALL_UTILS=ON
CMAKE_ARGS+= -DLLVM_LINK_LLVM_DYLIB=ON
# Meson building mesa 18.2 requires this
CMAKE_ARGS+= -DLLVM_ENABLE_RTTI=ON
CMAKE_ARGS.Darwin+= -DCMAKE_LIBTOOL=/usr/bin/libtool
CHECK_PORTABILITY_SKIP= utils/buildit/build_llvm
# XXX perl is not added as a tool as it does not seem to be required
REPLACE_PERL+= utils/*.pl
REPLACE_PERL+= utils/codegen-diff
REPLACE_PERL+= utils/llvm-native-gxx
REPLACE_PYTHON+= tools/opt-viewer/*.py
REPLACE_PYTHON+= tools/sancov/*.py
REPLACE_PYTHON+= utils/*.py
REPLACE_PYTHON+= utils/Misc/zkill
REPLACE_PYTHON+= utils/bisect
REPLACE_PYTHON+= utils/clang-parse-diagnostics-file
REPLACE_PYTHON+= utils/git/find-rev
REPLACE_PYTHON+= utils/lit/tests/Inputs/googletest-format/DummySubDir/OneTest
REPLACE_PYTHON+= utils/llvm-build/llvm-build
REPLACE_PYTHON+= utils/llvm-compilers-check
REPLACE_PYTHON+= utils/llvm-lit/llvm-lit.in
TEST_TARGET= check
TEST_ENV+= LD_LIBRARY_PATH=${WRKDIR}/build/lib
# It may be that the Solaris linker is more strict here and they can be removed on
# all platforms. Change this to a patch if verified.
SUBST_CLASSES.SunOS+= lto
SUBST_STAGE.lto= pre-configure
SUBST_FILES.lto= tools/lto/lto.exports
SUBST_SED.lto= -e '/^LLVM/d'
.include "../../mk/bsd.prefs.mk"
PLIST_VARS+= notdylib
.if ${SHLIB_TYPE} == "dylib"
SOEXT= dylib
.else
SOEXT= so
PLIST.notdylib= yes
.endif
PLIST_SUBST+= SOEXT=${SOEXT}
# needs std::atomic with 64-bit CAS
.if ${MACHINE_ARCH} == "i386"
CXXFLAGS+= -march=i586
.endif
CXXFLAGS.DragonFly+= -fpermissive
.include "options.mk"
# replacing config.guess is required even for cmake.
# It is used to detect correct LLVM_HOST_TRIPLE, e.g. for NetBSD/evbarm.
post-extract:
${MKDIR} ${WRKDIR}/build
.for f in config.guess config.sub
cp ../../mk/gnu-config/${f} ${WRKSRC}/cmake/${f}
.endfor
.include "../../devel/zlib/buildlink3.mk"
.include "../../lang/python/application.mk"
.include "../../lang/python/tool.mk"
.include "../../textproc/libxml2/buildlink3.mk"
.include "../../mk/bsd.pkg.mk"

1460
llvm-dfbsd/PLIST Normal file

File diff suppressed because it is too large Load Diff

22
llvm-dfbsd/buildlink3.mk Normal file
View File

@ -0,0 +1,22 @@
# $NetBSD: buildlink3.mk,v 1.7 2018/12/09 20:04:38 adam Exp $
BUILDLINK_TREE+= llvm
.if !defined(LLVM_BUILDLINK3_MK)
LLVM_BUILDLINK3_MK:=
BUILDLINK_API_DEPENDS.llvm+= llvm>=7.0.0
BUILDLINK_PKGSRCDIR.llvm?= ../../lang/llvm
LLVM_CONFIG_PATH?= ${BUILDLINK_PREFIX.llvm}/bin/llvm-config
pkgbase := llvm
.include "../../mk/pkg-build-options.mk"
.if !empty(PKG_BUILD_OPTIONS.llvm:Mterminfo)
.include "../../mk/terminfo.buildlink3.mk"
.endif
.include "../../devel/zlib/buildlink3.mk"
.endif # LLVM_BUILDLINK3_MK
BUILDLINK_TREE+= -llvm

15
llvm-dfbsd/distinfo Normal file
View File

@ -0,0 +1,15 @@
$NetBSD: distinfo,v 1.19 2018/12/23 00:11:39 adam Exp $
SHA1 (llvm-7.0.1.src.tar.xz) = f97632fcc3186eb0d396492ef8acfc807648580f
RMD160 (llvm-7.0.1.src.tar.xz) = dae96c6f85afb60e73564dc40d02171d01ffdb8f
SHA512 (llvm-7.0.1.src.tar.xz) = ac43a3cb71a53deb55e3693653847cf20bf6f5d9056f224e6956c96d63bc59ebee9404f088eec9cabe65337b4607a905ef931354b373cf64e0004c6905a6b5df
Size (llvm-7.0.1.src.tar.xz) = 28311056 bytes
SHA1 (patch-CMakeLists.txt) = 78e2dab2bf73f7e466ca2788fe6444e39b4ebd80
SHA1 (patch-cmake_config-ix.cmake) = a345420169e4066e22d28ca6ad10840e83ccfa76
SHA1 (patch-cmake_modules_AddLLVM.cmake) = 31d4f47f03bef021a24d53147c1b66abd64e1d87
SHA1 (patch-cmake_modules_CheckAtomic.cmake) = 51e4fdf3bc24b50fc4d4bfa1ec5ba6c82ef946b4
SHA1 (patch-cmake_modules_HandleLLVMOptions.cmake) = 271e6f5a8cebf8162c4e3b758e96f451b434269b
SHA1 (patch-include_llvm-c_DataTypes.h) = 025c035e0e10871727391bd58936bd67b3e58244
SHA1 (patch-include_llvm_Analysis_ConstantFolding.h) = 56b9374da236c346565897977040255b9766cab8
SHA1 (patch-lib_Support_Unix_Path.inc) = e5cf93a65bad156ddc9688020d8d35ed9eb7e067
SHA1 (patch-tools_llvm-shlib_CMakeLists.txt) = 45278d8acc6daa3d36a1a7b15e2e3b9a75a218e6

55
llvm-dfbsd/options.mk Normal file
View File

@ -0,0 +1,55 @@
# $NetBSD: options.mk,v 1.4 2019/01/26 23:47:43 tnn Exp $
PKG_OPTIONS_VAR= PKG_OPTIONS.llvm
LLVM_TARGETS= AArch64 AMDGPU ARM BPF Hexagon Lanai Mips MSP430 NVPTX PowerPC Sparc SystemZ X86 XCore
.for tgt in ${LLVM_TARGETS}
PLIST_VARS+= ${tgt}
PKG_SUPPORTED_OPTIONS+= llvm-target-${tgt:tl}
.endfor
PKG_SUPPORTED_OPTIONS+= terminfo
# Terminfo is used for colour output, only enable it by default if terminfo
# is builtin to avoid unnecessary dependencies which could cause bootstrap
# issues.
CHECK_BUILTIN.terminfo:= yes
.include "../../mk/terminfo.builtin.mk"
CHECK_BUILTIN.terminfo:= no
.if !empty(USE_BUILTIN.terminfo:M[yY][eE][sS])
PKG_SUGGESTED_OPTIONS+= terminfo
.endif
# Probably safe to assume that only x86 users are interested in
# cross-compilation for now. This saves some build time for everyone else.
.if !empty(MACHINE_ARCH:Msparc*)
PKG_SUGGESTED_OPTIONS+= llvm-target-sparc
.elif !empty(MACHINE_ARCH:Mpowerpc*)
PKG_SUGGESTED_OPTIONS+= llvm-target-powerpc
.elif !empty(MACHINE_ARCH:Mearm*)
PKG_SUGGESTED_OPTIONS+= llvm-target-arm
.elif !empty(MACHINE_ARCH:M*mips*)
PKG_SUGGESTED_OPTIONS+= llvm-target-mips
.else
# X86 and everyone else get all targets by default.
. for tgt in ${LLVM_TARGETS}
PKG_SUGGESTED_OPTIONS+= llvm-target-${tgt:tl}
. endfor
.endif
.include "../../mk/bsd.options.mk"
.for tgt in ${LLVM_TARGETS}
. if !empty(PKG_OPTIONS:Mllvm-target-${tgt:tl})
PLIST.${tgt}= yes
LLVM_TARGETS_TO_BUILD+= ${tgt}
. endif
.endfor
.if !empty(PKG_OPTIONS:Mterminfo)
.include "../../mk/terminfo.buildlink3.mk"
.else
CMAKE_ARGS+= -DLLVM_ENABLE_TERMINFO=OFF
.endif
CMAKE_ARGS+= -DLLVM_TARGETS_TO_BUILD="${LLVM_TARGETS_TO_BUILD:ts;}"

View File

@ -0,0 +1,15 @@
$NetBSD: patch-CMakeLists.txt,v 1.1 2018/01/08 10:48:34 jperkin Exp $
Don't implement sys/regset.h workaround, fix source instead.
--- CMakeLists.txt.orig 2017-08-15 00:16:21.000000000 +0000
+++ CMakeLists.txt
@@ -809,7 +809,7 @@ endif(${CMAKE_SYSTEM_NAME} MATCHES "(Fre
if( ${CMAKE_SYSTEM_NAME} MATCHES SunOS )
# special hack for Solaris to handle crazy system sys/regset.h
- include_directories("${LLVM_MAIN_INCLUDE_DIR}/llvm/Support/Solaris")
+ #include_directories("${LLVM_MAIN_INCLUDE_DIR}/llvm/Support/Solaris")
endif( ${CMAKE_SYSTEM_NAME} MATCHES SunOS )
# Make sure we don't get -rdynamic in every binary. For those that need it,

View File

@ -0,0 +1,15 @@
$NetBSD: patch-cmake_config-ix.cmake,v 1.3 2018/08/07 10:44:50 adam Exp $
Do not generate invalid llvm-config in pkgsrc.
--- cmake/config-ix.cmake.orig 2018-01-02 17:53:08.000000000 +0000
+++ cmake/config-ix.cmake
@@ -153,7 +153,7 @@ if(NOT LLVM_USE_SANITIZER MATCHES "Memor
endif()
if(LLVM_ENABLE_TERMINFO)
set(HAVE_TERMINFO 0)
- foreach(library tinfo terminfo curses ncurses ncursesw)
+ foreach(library terminfo curses ncurses ncursesw tinfo)
string(TOUPPER ${library} library_suffix)
check_library_exists(${library} setupterm "" HAVE_TERMINFO_${library_suffix})
if(HAVE_TERMINFO_${library_suffix})

View File

@ -0,0 +1,36 @@
$NetBSD: patch-cmake_modules_AddLLVM.cmake,v 1.4 2018/12/09 20:04:38 adam Exp $
Don't use non-portable -z discard-unused on SunOS.
On Darwin, create symbolic links to shared libraries.
On Darwin, use correct install-name for shared libraries.
--- cmake/modules/AddLLVM.cmake.orig 2018-08-01 07:51:55.000000000 +0000
+++ cmake/modules/AddLLVM.cmake
@@ -218,9 +218,6 @@ function(add_link_opts target_name)
# ld64's implementation of -dead_strip breaks tools that use plugins.
set_property(TARGET ${target_name} APPEND_STRING PROPERTY
LINK_FLAGS " -Wl,-dead_strip")
- elseif(${CMAKE_SYSTEM_NAME} MATCHES "SunOS")
- set_property(TARGET ${target_name} APPEND_STRING PROPERTY
- LINK_FLAGS " -Wl,-z -Wl,discard-unused=sections")
elseif(NOT WIN32 AND NOT LLVM_LINKER_IS_GOLD AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD")
# Object files are compiled with -ffunction-data-sections.
# Versions of bfd ld < 2.23.1 have a bug in --gc-sections that breaks
@@ -517,7 +514,7 @@ function(llvm_add_library name)
endif()
if(ARG_SHARED AND UNIX)
- if(NOT APPLE AND ARG_SONAME)
+ if(ARG_SONAME)
get_target_property(output_name ${name} OUTPUT_NAME)
if(${output_name} STREQUAL "output_name-NOTFOUND")
set(output_name ${name})
@@ -1632,7 +1629,7 @@ function(llvm_setup_rpath name)
endif()
if (APPLE)
- set(_install_name_dir INSTALL_NAME_DIR "@rpath")
+ set(_install_name_dir INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib")
set(_install_rpath "@loader_path/../lib" ${extra_libdir})
elseif(UNIX)
set(_install_rpath "\$ORIGIN/../lib${LLVM_LIBDIR_SUFFIX}" ${extra_libdir})

View File

@ -0,0 +1,38 @@
$NetBSD: patch-cmake_modules_CheckAtomic.cmake,v 1.1 2018/03/31 15:13:28 he Exp $
Omit check for native 8-byte atomics, platform may not have them,
and they are actually not required here. Makes powerpc build llvm.
--- cmake/modules/CheckAtomic.cmake.orig 2016-06-23 06:39:35.000000000 +0000
+++ cmake/modules/CheckAtomic.cmake
@@ -62,18 +62,18 @@ else()
endif()
# If not, check if the library exists, and atomics work with it.
-if(NOT HAVE_CXX_ATOMICS64_WITHOUT_LIB)
- check_library_exists(atomic __atomic_load_8 "" HAVE_CXX_LIBATOMICS64)
- if(HAVE_CXX_LIBATOMICS64)
- list(APPEND CMAKE_REQUIRED_LIBRARIES "atomic")
- check_working_cxx_atomics64(HAVE_CXX_ATOMICS64_WITH_LIB)
- if (NOT HAVE_CXX_ATOMICS64_WITH_LIB)
- message(FATAL_ERROR "Host compiler must support std::atomic!")
- endif()
- else()
- message(FATAL_ERROR "Host compiler appears to require libatomic, but cannot find it.")
- endif()
-endif()
+#if(NOT HAVE_CXX_ATOMICS64_WITHOUT_LIB)
+# check_library_exists(atomic __atomic_load_8 "" HAVE_CXX_LIBATOMICS64)
+# if(HAVE_CXX_LIBATOMICS64)
+# list(APPEND CMAKE_REQUIRED_LIBRARIES "atomic")
+# check_working_cxx_atomics64(HAVE_CXX_ATOMICS64_WITH_LIB)
+# if (NOT HAVE_CXX_ATOMICS64_WITH_LIB)
+# message(FATAL_ERROR "Host compiler must support std::atomic!")
+# endif()
+# else()
+# message(FATAL_ERROR "Host compiler appears to require libatomic, but cannot find it.")
+# endif()
+#endif()
## TODO: This define is only used for the legacy atomic operations in
## llvm's Atomic.h, which should be replaced. Other code simply

View File

@ -0,0 +1,14 @@
$NetBSD: patch-cmake_modules_HandleLLVMOptions.cmake,v 1.1 2017/03/19 19:01:48 adam Exp $
DragonflyBSD support
--- cmake/modules/HandleLLVMOptions.cmake.orig 2016-01-06 19:05:19.000000000 +0000
+++ cmake/modules/HandleLLVMOptions.cmake
@@ -132,6 +132,7 @@ endif()
# Pass -Wl,-z,defs. This makes sure all symbols are defined. Otherwise a DSO
# build might work on ELF but fail on MachO/COFF.
if(NOT (${CMAKE_SYSTEM_NAME} MATCHES "Darwin" OR WIN32 OR CYGWIN OR
+ ${CMAKE_SYSTEM_NAME} MATCHES "DragonFly" OR
${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD" OR
${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD") AND
NOT LLVM_USE_SANITIZER)

View File

@ -0,0 +1,34 @@
$NetBSD: patch-include_llvm-c_DataTypes.h,v 1.1 2018/12/15 23:41:45 jperkin Exp $
Don't implement sys/regset.h workaround, fix source instead.
--- include/llvm-c/DataTypes.h.orig 2018-04-02 13:22:26.000000000 +0000
+++ include/llvm-c/DataTypes.h
@@ -87,4 +87,27 @@ typedef signed int ssize_t;
#define HUGE_VALF (float)HUGE_VAL
#endif
+#if defined(__sun)
+#include <sys/regset.h>
+#undef CS
+#undef DS
+#undef ES
+#undef FS
+#undef GS
+#undef SS
+#undef EAX
+#undef ECX
+#undef EDX
+#undef EBX
+#undef ESP
+#undef EBP
+#undef ESI
+#undef EDI
+#undef EIP
+#undef UESP
+#undef EFL
+#undef ERR
+#undef TRAPNO
+#endif
+
#endif /* LLVM_C_DATATYPES_H */

View File

@ -0,0 +1,17 @@
$NetBSD: patch-include_llvm_Analysis_ConstantFolding.h,v 1.1 2018/12/15 23:41:45 jperkin Exp $
Fix SunOS CS conflict not handled by include/llvm-c/DataTypes.h
--- include/llvm/Analysis/ConstantFolding.h.orig 2018-05-01 15:54:18.000000000 +0000
+++ include/llvm/Analysis/ConstantFolding.h
@@ -20,6 +20,10 @@
#ifndef LLVM_ANALYSIS_CONSTANTFOLDING_H
#define LLVM_ANALYSIS_CONSTANTFOLDING_H
+#ifdef __sun
+#undef CS
+#endif
+
namespace llvm {
class APInt;
template <typename T> class ArrayRef;

View File

@ -0,0 +1,22 @@
$NetBSD$
From DragonFly dports devel/llvm60
--- lib/Support/Unix/Path.inc.orig 2017-11-07 00:47:04.000000000 +0000
+++ lib/Support/Unix/Path.inc
@@ -68,13 +68,13 @@
#include <sys/types.h>
#if !defined(__APPLE__) && !defined(__OpenBSD__) && !defined(__FreeBSD__) && \
- !defined(__linux__)
+ !defined(__linux__) && !defined(__DragonFly__)
#include <sys/statvfs.h>
#define STATVFS statvfs
#define FSTATVFS fstatvfs
#define STATVFS_F_FRSIZE(vfs) vfs.f_frsize
#else
-#if defined(__OpenBSD__) || defined(__FreeBSD__)
+#if defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__DragonFly__)
#include <sys/mount.h>
#include <sys/param.h>
#elif defined(__linux__)

View File

@ -0,0 +1,33 @@
$NetBSD: patch-tools_llvm-shlib_CMakeLists.txt,v 1.4 2018/12/09 20:04:38 adam Exp $
Use the Linux style linking everywhere except Darwin and SunOS.
--- tools/llvm-shlib/CMakeLists.txt.orig 2018-08-03 10:15:36.000000000 +0000
+++ tools/llvm-shlib/CMakeLists.txt
@@ -37,12 +37,11 @@ endif()
add_llvm_library(LLVM SHARED DISABLE_LLVM_LINK_LLVM_DYLIB SONAME ${SOURCES})
list(REMOVE_DUPLICATES LIB_NAMES)
-if(("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") OR (MINGW) OR (HAIKU)
- OR ("${CMAKE_SYSTEM_NAME}" STREQUAL "FreeBSD")
- OR ("${CMAKE_SYSTEM_NAME}" STREQUAL "OpenBSD")
- OR ("${CMAKE_SYSTEM_NAME}" STREQUAL "Fuchsia")
- OR ("${CMAKE_SYSTEM_NAME}" STREQUAL "DragonFly")
- OR ("${CMAKE_SYSTEM_NAME}" STREQUAL "SunOS")) # FIXME: It should be "GNU ld for elf"
+if("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
+ set(LIB_NAMES -Wl,-all_load ${LIB_NAMES})
+elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "SunOS")
+ set(LIB_NAMES -Wl,-Bsymbolic -Wl,-z -Wl,allextract ${LIB_NAMES} -Wl,-z -Wl,defaultextract)
+else()
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/simple_version_script.map.in
${LLVM_LIBRARY_DIR}/tools/llvm-shlib/simple_version_script.map)
@@ -53,8 +52,6 @@ if(("${CMAKE_SYSTEM_NAME}" STREQUAL "Lin
# Solaris ld does not accept global: *; so there is no way to version *all* global symbols
set(LIB_NAMES -Wl,--version-script,${LLVM_LIBRARY_DIR}/tools/llvm-shlib/simple_version_script.map ${LIB_NAMES})
endif()
-elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
- set(LIB_NAMES -Wl,-all_load ${LIB_NAMES})
endif()
target_link_libraries(LLVM PRIVATE ${LIB_NAMES})