Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Raise min LLVM version to 6.0 #3493

Merged
merged 1 commit into from
Jul 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 5 additions & 22 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,21 @@ git:
matrix:
include:
- os: linux
d: ldc
d: ldc-beta
env: LLVM_VERSION=9.0.0 OPTS="-DBUILD_SHARED_LIBS=ON -DRT_SUPPORT_SANITIZERS=ON"
- os: linux
d: ldc-beta
d: ldc-0.17.6
env: LLVM_VERSION=8.0.0 OPTS="-DBUILD_SHARED_LIBS=OFF"
# FIXME: strange crashes, possibly due to C++ compiler mismatch
#- os: linux
# d: ldc
# env: LLVM_VERSION=7.0.1 OPTS="-DBUILD_SHARED_LIBS=ON"
- os: linux
d: ldc-beta
env: LLVM_VERSION=6.0.1 OPTS="-DBUILD_SHARED_LIBS=OFF -DLIB_SUFFIX=64 -DRT_SUPPORT_SANITIZERS=ON"
- os: linux
d: ldc
env: LLVM_VERSION=5.0.2 OPTS="-DBUILD_SHARED_LIBS=ON -DLIB_SUFFIX=64"
- os: linux
d: ldc-0.17.6
env: LLVM_VERSION=4.0.0 OPTS="-DLIB_SUFFIX=64"
- os: linux
d: dmd
env: LLVM_VERSION=3.9.1
d: dmd-beta
env: LLVM_VERSION=6.0.1 OPTS="-DLIB_SUFFIX=64"
- os: osx
osx_image: xcode10.3
d: dmd
d: dmd-beta
env: LLVM_VERSION=10.0.0 OPTS="-DBUILD_SHARED_LIBS=ON -DRT_SUPPORT_SANITIZERS=ON"
- os: osx
osx_image: xcode10.3
Expand All @@ -45,9 +36,6 @@ cache:
- llvm-7.0.1
- llvm-7.0.0
- llvm-6.0.1
- llvm-5.0.2
- llvm-4.0.0
- llvm-3.9.1

addons:
apt:
Expand Down Expand Up @@ -134,11 +122,6 @@ script:
# dmd-testsuite-debug only to reduce time-outs
DMD_TESTSUITE_MAKE_ARGS=-j3 ctest -V -R "build-run-dmd-testsuite|dmd-testsuite-debug"
else
if [ "$LLVM_VERSION" = "3.9.1" ]; then
# FIXME: assertion failure for runnable/mars1.d with DMD/LLVM 3.9.1
# job (debug only, release passes)
rm tests/d2/dmd-testsuite/runnable/mars1.d
fi
DMD_TESTSUITE_MAKE_ARGS=-j3 ctest -V -R "dmd-testsuite"
fi
# Run defaultlib unittests & druntime stand-alone tests
Expand Down
81 changes: 22 additions & 59 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ endfunction()
# Locate LLVM.
#

find_package(LLVM 3.9 REQUIRED
find_package(LLVM 6.0 REQUIRED
all-targets analysis asmparser asmprinter bitreader bitwriter codegen core
debuginfodwarf debuginfomsf debuginfopdb demangle
instcombine ipo instrumentation irreader libdriver linker lto mc
Expand Down Expand Up @@ -304,14 +304,11 @@ if (UNIX AND NOT "${LLVM_LDFLAGS}" STREQUAL "")
endif()
if(MSVC)
separate_arguments(LLVM_LDFLAGS WINDOWS_COMMAND "${LLVM_LDFLAGS}")
# LLVM 5.0+ requires diaguids.lib from MS Debug Interface Access SDK
if(NOT (LDC_LLVM_VER LESS 500))
if(NOT MSVC_IDE) # apparently not needed for VS (and spaces in path are problematic)
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
list(APPEND LLVM_LDFLAGS "$ENV{VSINSTALLDIR}DIA SDK\\lib\\amd64\\diaguids.lib")
else()
list(APPEND LLVM_LDFLAGS "$ENV{VSINSTALLDIR}DIA SDK\\lib\\diaguids.lib")
endif()
if(NOT MSVC_IDE) # apparently not needed for VS (and spaces in path are problematic)
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
list(APPEND LLVM_LDFLAGS "$ENV{VSINSTALLDIR}DIA SDK\\lib\\amd64\\diaguids.lib")
else()
list(APPEND LLVM_LDFLAGS "$ENV{VSINSTALLDIR}DIA SDK\\lib\\diaguids.lib")
endif()
endif()
else()
Expand Down Expand Up @@ -453,10 +450,7 @@ include(HandleLTOPGOBuildOptions)
set(LDC_DYNAMIC_COMPILE "AUTO" CACHE STRING "Support dynamic compilation (ON|OFF). Enabled by default.")
option(LDC_DYNAMIC_COMPILE_USE_CUSTOM_PASSES "Use custom LDC passes in jit" ON)
if(LDC_DYNAMIC_COMPILE STREQUAL "AUTO")
set(LDC_DYNAMIC_COMPILE OFF)
if (NOT (LDC_LLVM_VER LESS 500))
set(LDC_DYNAMIC_COMPILE ON)
endif()
set(LDC_DYNAMIC_COMPILE ON)
endif()
message(STATUS "Building LDC with dynamic compilation support: ${LDC_DYNAMIC_COMPILE} (LDC_DYNAMIC_COMPILE=${LDC_DYNAMIC_COMPILE})")
if(LDC_DYNAMIC_COMPILE)
Expand Down Expand Up @@ -489,8 +483,7 @@ append("-DLDC_HOST_FE_VER=${D_COMPILER_FE_VERSION}" LDC_CXXFLAGS)
# LLD integration (requires headers & libs)
#
if(NOT DEFINED LDC_WITH_LLD)
if(((LDC_LLVM_VER LESS 600) AND (EXISTS "${LLVM_INCLUDE_DIRS}/lld/Driver/Driver.h")) OR
((NOT LDC_LLVM_VER LESS 600) AND (EXISTS "${LLVM_INCLUDE_DIRS}/lld/Common/Driver.h")))
if(EXISTS "${LLVM_INCLUDE_DIRS}/lld/Common/Driver.h")
set(LDC_WITH_LLD ON)
else()
set(LDC_WITH_LLD OFF)
Expand Down Expand Up @@ -600,22 +593,13 @@ if(LDC_WITH_LLD)
set(LDC_LINKERFLAG_LIST -lLLVMSymbolize ${LDC_LINKERFLAG_LIST})
endif()
endif()
# ELF, Mach-O, MinGW and WebAssembly formats supported since LLD 6.0.0, otherwise just Windows COFF
if(NOT (LDC_LLVM_VER LESS 600))
if(MSVC)
list(APPEND LDC_LINKERFLAG_LIST lldDriver.lib lldMinGW.lib lldCOFF.lib lldELF.lib lldMachO.lib lldWasm.lib lldYAML.lib lldReaderWriter.lib lldCommon.lib lldCore.lib)
else()
set(LDC_LINKERFLAG_LIST -llldDriver -llldMinGW -llldCOFF -llldELF -llldMachO -llldWasm -llldYAML -llldReaderWriter -llldCommon -llldCore ${LDC_LINKERFLAG_LIST})
endif()
if(APPLE) # bug, should be fixed in LLVM 6.0.1
list(APPEND LDC_LINKERFLAG_LIST -lxml2)
endif()
if(MSVC)
list(APPEND LDC_LINKERFLAG_LIST lldDriver.lib lldMinGW.lib lldCOFF.lib lldELF.lib lldMachO.lib lldWasm.lib lldYAML.lib lldReaderWriter.lib lldCommon.lib lldCore.lib)
else()
if(MSVC)
list(APPEND LDC_LINKERFLAG_LIST lldCOFF.lib lldCore.lib lldDriver.lib)
else()
set(LDC_LINKERFLAG_LIST -llldCOFF -llldCore -llldDriver ${LDC_LINKERFLAG_LIST})
endif()
set(LDC_LINKERFLAG_LIST -llldDriver -llldMinGW -llldCOFF -llldELF -llldMachO -llldWasm -llldYAML -llldReaderWriter -llldCommon -llldCore ${LDC_LINKERFLAG_LIST})
endif()
if(APPLE) # bug, should be fixed in LLVM 6.0.1
list(APPEND LDC_LINKERFLAG_LIST -lxml2)
endif()
endif()

Expand Down Expand Up @@ -723,14 +707,14 @@ function(copy_and_rename_file source_path target_path)
endfunction()

#
# Locate LLVM's LTO binary and use it (LLVM >= 3.9)
# Locate LLVM's LTO binary and use it
#
if(APPLE)
set(LDC_INSTALL_LTOPLUGIN_DEFAULT ON)
else()
set(LDC_INSTALL_LTOPLUGIN_DEFAULT OFF)
endif()
set(LDC_INSTALL_LTOPLUGIN ${LDC_INSTALL_LTOPLUGIN_DEFAULT} CACHE BOOL "Copy/install the LTO plugin from the LLVM package when available (LLVM >= 3.9).")
set(LDC_INSTALL_LTOPLUGIN ${LDC_INSTALL_LTOPLUGIN_DEFAULT} CACHE BOOL "Copy/install the LTO plugin from the LLVM package when available.")
if (LDC_INSTALL_LTOPLUGIN)
if(APPLE)
set(LLVM_LTO_BINARY ${LLVM_LIBRARY_DIRS}/libLTO.dylib)
Expand Down Expand Up @@ -776,16 +760,13 @@ include(CheckTypeSize)
check_type_size(void* ptr_size)
if (LDC_INSTALL_LLVM_RUNTIME_LIBS)
# Locate LLVM sanitizer runtime libraries, and copy them to our lib folder
# Note: libFuzzer is part of compiler-rt version >= 6.0, but was part of LLVM =< 5.0

if(APPLE)
copy_compilerrt_lib("darwin/libclang_rt.asan_osx_dynamic.dylib" "libldc_rt.asan.dylib" TRUE)
copy_compilerrt_lib("darwin/libclang_rt.osx.a" "libldc_rt.builtins.a" FALSE)
copy_compilerrt_lib("darwin/libclang_rt.profile_osx.a" "libldc_rt.profile.a" FALSE)
if(NOT (LDC_LLVM_VER LESS 600))
copy_compilerrt_lib("darwin/libclang_rt.fuzzer_osx.a" "libldc_rt.fuzzer.a" FALSE)
copy_compilerrt_lib("darwin/libclang_rt.xray_osx.a" "libldc_rt.xray.a" FALSE)
endif()
copy_compilerrt_lib("darwin/libclang_rt.fuzzer_osx.a" "libldc_rt.fuzzer.a" FALSE)
copy_compilerrt_lib("darwin/libclang_rt.xray_osx.a" "libldc_rt.xray.a" FALSE)
if(NOT (LDC_LLVM_VER LESS 700))
copy_compilerrt_lib("darwin/libclang_rt.xray-basic_osx.a" "libldc_rt.xray-basic.a" FALSE)
copy_compilerrt_lib("darwin/libclang_rt.xray-fdr_osx.a" "libldc_rt.xray-fdr.a" FALSE)
Expand All @@ -798,12 +779,8 @@ if (LDC_INSTALL_LLVM_RUNTIME_LIBS)
copy_compilerrt_lib("${LDC_INSTALL_LLVM_RUNTIME_LIBS_OS}/libclang_rt.asan-${LDC_INSTALL_LLVM_RUNTIME_LIBS_ARCH}.a" "libldc_rt.asan.a" FALSE)
copy_compilerrt_lib("${LDC_INSTALL_LLVM_RUNTIME_LIBS_OS}/libclang_rt.builtins-${LDC_INSTALL_LLVM_RUNTIME_LIBS_ARCH}.a" "libldc_rt.builtins.a" FALSE)
copy_compilerrt_lib("${LDC_INSTALL_LLVM_RUNTIME_LIBS_OS}/libclang_rt.profile-${LDC_INSTALL_LLVM_RUNTIME_LIBS_ARCH}.a" "libldc_rt.profile.a" FALSE)
if(NOT (LDC_LLVM_VER LESS 500))
copy_compilerrt_lib("${LDC_INSTALL_LLVM_RUNTIME_LIBS_OS}/libclang_rt.xray-${LDC_INSTALL_LLVM_RUNTIME_LIBS_ARCH}.a" "libldc_rt.xray.a" FALSE)
endif()
if(NOT (LDC_LLVM_VER LESS 600))
copy_compilerrt_lib("${LDC_INSTALL_LLVM_RUNTIME_LIBS_OS}/libclang_rt.fuzzer-${LDC_INSTALL_LLVM_RUNTIME_LIBS_ARCH}.a" "libldc_rt.fuzzer.a" FALSE)
endif()
copy_compilerrt_lib("${LDC_INSTALL_LLVM_RUNTIME_LIBS_OS}/libclang_rt.xray-${LDC_INSTALL_LLVM_RUNTIME_LIBS_ARCH}.a" "libldc_rt.xray.a" FALSE)
copy_compilerrt_lib("${LDC_INSTALL_LLVM_RUNTIME_LIBS_OS}/libclang_rt.fuzzer-${LDC_INSTALL_LLVM_RUNTIME_LIBS_ARCH}.a" "libldc_rt.fuzzer.a" FALSE)
if(NOT (LDC_LLVM_VER LESS 700))
copy_compilerrt_lib("${LDC_INSTALL_LLVM_RUNTIME_LIBS_OS}/libclang_rt.xray-basic-${LDC_INSTALL_LLVM_RUNTIME_LIBS_ARCH}.a" "libldc_rt.xray-basic.a" FALSE)
copy_compilerrt_lib("${LDC_INSTALL_LLVM_RUNTIME_LIBS_OS}/libclang_rt.xray-fdr-${LDC_INSTALL_LLVM_RUNTIME_LIBS_ARCH}.a" "libldc_rt.xray-fdr.a" FALSE)
Expand All @@ -817,28 +794,14 @@ if (LDC_INSTALL_LLVM_RUNTIME_LIBS)
copy_compilerrt_lib("windows/clang_rt.asan-${compilerrt_arch_suffix}.lib" "ldc_rt.asan.lib" FALSE)
copy_compilerrt_lib("windows/clang_rt.builtins-${compilerrt_arch_suffix}.lib" "ldc_rt.builtins.lib" FALSE)
copy_compilerrt_lib("windows/clang_rt.profile-${compilerrt_arch_suffix}.lib" "ldc_rt.profile.lib" FALSE)
if(NOT (LDC_LLVM_VER LESS 600))
copy_compilerrt_lib("windows/clang_rt.fuzzer-${compilerrt_arch_suffix}.lib" "ldc_rt.fuzzer.lib" FALSE)
copy_compilerrt_lib("windows/clang_rt.xray-${compilerrt_arch_suffix}.lib" "ldc_rt.xray.lib" FALSE)
endif()
copy_compilerrt_lib("windows/clang_rt.fuzzer-${compilerrt_arch_suffix}.lib" "ldc_rt.fuzzer.lib" FALSE)
copy_compilerrt_lib("windows/clang_rt.xray-${compilerrt_arch_suffix}.lib" "ldc_rt.xray.lib" FALSE)
if(NOT (LDC_LLVM_VER LESS 700))
copy_compilerrt_lib("windows/clang_rt.xray-basic-${compilerrt_arch_suffix}.lib" "ldc_rt.xray-basic.lib" FALSE)
copy_compilerrt_lib("windows/clang_rt.xray-fdr-${compilerrt_arch_suffix}.lib" "ldc_rt.xray-fdr.lib" FALSE)
copy_compilerrt_lib("windows/clang_rt.xray-profiling-${compilerrt_arch_suffix}.lib" "ldc_rt.xray-profiling.lib" FALSE)
endif()
endif()

if(LDC_LLVM_VER LESS 600)
set(LLVM_LIBFUZZER_PATH ${LLVM_LIBRARY_DIRS}/libFuzzer.a)
if(EXISTS ${LLVM_LIBFUZZER_PATH})
message(STATUS "Copying libFuzzer library: ${LLVM_LIBFUZZER_PATH} --> libFuzzer.a")
file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/lib${LIB_SUFFIX})
file(COPY ${LLVM_LIBFUZZER_PATH} DESTINATION ${PROJECT_BINARY_DIR}/lib${LIB_SUFFIX})
install(FILES ${PROJECT_BINARY_DIR}/lib${LIB_SUFFIX}/libFuzzer.a DESTINATION ${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX})
else()
message(STATUS "Not found: ${LLVM_LIBFUZZER_PATH}")
endif()
endif()
endif()

#
Expand Down
23 changes: 1 addition & 22 deletions cmake/Modules/FindLLVM.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@ set(llvm_config_names llvm-config-10.0 llvm-config100 llvm-config-10
llvm-config-8.0 llvm-config80 llvm-config-8
llvm-config-7.0 llvm-config70 llvm-config-7
llvm-config-6.0 llvm-config60
llvm-config-5.0 llvm-config50
llvm-config-4.0 llvm-config40
llvm-config-3.9 llvm-config39
llvm-config)
find_program(LLVM_CONFIG
NAMES ${llvm_config_names}
Expand Down Expand Up @@ -113,19 +110,7 @@ else()
# The LLVM version string _may_ contain a git/svn suffix, so match only the x.y.z part
string(REGEX MATCH "^[0-9]+[.][0-9]+[.][0-9]+" LLVM_VERSION_BASE_STRING "${LLVM_VERSION_STRING}")

# Versions below 4.0 do not support components debuginfomsf and demangle
if(${LLVM_VERSION_STRING} MATCHES "^3\\..*")
list(REMOVE_ITEM LLVM_FIND_COMPONENTS "debuginfomsf" index)
list(REMOVE_ITEM LLVM_FIND_COMPONENTS "demangle" index)
endif()
# Versions below 6.0 do not support component windowsmanifest
if(${LLVM_VERSION_STRING} MATCHES "^[3-5]\\..*")
list(REMOVE_ITEM LLVM_FIND_COMPONENTS "windowsmanifest" index)
endif()

llvm_set(LDFLAGS ldflags)
# In LLVM 3.5+, the system library dependencies (e.g. "-lz") are accessed
# using the separate "--system-libs" flag.
llvm_set(SYSTEM_LIBS system-libs)
string(REPLACE "\n" " " LLVM_LDFLAGS "${LLVM_LDFLAGS} ${LLVM_SYSTEM_LIBS}")
llvm_set(LIBRARY_DIRS libdir true)
Expand All @@ -138,13 +123,7 @@ else()
endif()
endif()

# Versions below 4.0 do not support llvm-config --cmakedir
if(${LLVM_VERSION_STRING} MATCHES "^3\\..*")
set(LLVM_CMAKEDIR ${LLVM_LIBRARY_DIRS}/cmake/llvm)
else()
llvm_set(CMAKEDIR cmakedir)
endif()

llvm_set(CMAKEDIR cmakedir)
llvm_set(TARGETS_TO_BUILD targets-built)
string(REGEX MATCHALL "${pattern}[^ ]+" LLVM_TARGETS_TO_BUILD ${LLVM_TARGETS_TO_BUILD})

Expand Down
25 changes: 1 addition & 24 deletions driver/archiver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,8 @@
#include "llvm/Support/Errc.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/raw_ostream.h"
#include <cstring>

#if LDC_LLVM_VER >= 500
#include "llvm/ToolDrivers/llvm-lib/LibDriver.h"
#else
#include "llvm/LibDriver/LibDriver.h"
#endif
#include <cstring>

using namespace llvm;

Expand Down Expand Up @@ -70,10 +65,8 @@ int addMember(std::vector<NewArchiveMember> &Members, StringRef FileName,
NewArchiveMember::getFile(FileName, Deterministic);
failIfError(NMOrErr.takeError(), FileName);

#if LDC_LLVM_VER >= 500
// Use the basename of the object path for the member name.
NMOrErr->MemberName = sys::path::filename(NMOrErr->MemberName);
#endif

if (Pos == -1)
Members.push_back(std::move(*NMOrErr));
Expand Down Expand Up @@ -106,11 +99,7 @@ int computeNewArchiveMembers(object::Archive *OldArchive,
Error Err = Error::success();
for (auto &Child : OldArchive->children(Err)) {
auto NameOrErr = Child.getName();
#if LDC_LLVM_VER < 400
failIfError(NameOrErr.getError(), "");
#else
failIfError(NameOrErr.takeError(), "");
#endif
StringRef Name = NameOrErr.get();

auto MemberI = find_if(Members, [Name](StringRef Path) {
Expand Down Expand Up @@ -146,11 +135,7 @@ int computeNewArchiveMembers(object::Archive *OldArchive,

object::Archive::Kind getDefaultForHost() {
return Triple(sys::getProcessTriple()).isOSDarwin()
#if LDC_LLVM_VER >= 500
? object::Archive::K_DARWIN
#else
? object::Archive::K_BSD
#endif
: object::Archive::K_GNU;
}

Expand All @@ -160,11 +145,7 @@ object::Archive::Kind getKindFromMember(const NewArchiveMember &Member) {

if (OptionalObject) {
return isa<object::MachOObjectFile>(**OptionalObject)
#if LDC_LLVM_VER >= 500
? object::Archive::K_DARWIN
#else
? object::Archive::K_BSD
#endif
: object::Archive::K_GNU;
}

Expand All @@ -191,11 +172,7 @@ int performWriteOperation(object::Archive *OldArchive,
writeArchive(ArchiveName, NewMembers, Symtab, Kind, Deterministic, Thin,
std::move(OldArchiveBuf));

#if LDC_LLVM_VER >= 600
failIfError(std::move(Result), ("error writing '" + ArchiveName + "'").str());
#else
failIfError(Result.second, ("error writing '" + ArchiveName + "'").str());
#endif

return 0;
}
Expand Down
4 changes: 1 addition & 3 deletions driver/args.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//===-- args.cpp ----------------------------------------------------------===//
//
// LDC the LLVM D compiler
// LDC the LLVM D compiler
//
// This file is distributed under the BSD-style LDC license. See the LICENSE
// file for details.
Expand Down Expand Up @@ -108,9 +108,7 @@ bool has(const wchar_t *wname) { return _wgetenv(wname) != nullptr; }

std::string get(const char *name) {
#ifdef _WIN32
#if LDC_LLVM_VER >= 400
using llvm::UTF16;
#endif
const wchar_t *wvalue = wget(name);
std::string value;
if (wvalue) {
Expand Down
Loading