Skip to content

Commit

Permalink
Merge pull request ldc-developers#4455 from kinke/drop_llvm_9_10
Browse files Browse the repository at this point in the history
Drop support for LLVM 9 and LLVM 10
  • Loading branch information
kinke authored Aug 1, 2023
2 parents 73f5342 + 8b3e36f commit 3b7ca36
Show file tree
Hide file tree
Showing 68 changed files with 131 additions and 4,059 deletions.
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ jobs:
environment:
- PARALLELISM: 4
- CI_OS: linux
- EXTRA_APT_PACKAGES: llvm-dev libclang-common-10-dev
- EXTRA_APT_PACKAGES: llvm-11-dev libclang-common-11-dev
- HOST_LDC_VERSION: 1.24.0
- EXTRA_CMAKE_FLAGS: "-DMULTILIB=ON -DRT_SUPPORT_SANITIZERS=ON -DBUILD_LTO_LIBS=ON"
Ubuntu-20.04-sharedLibsOnly-gdmd:
Expand All @@ -126,7 +126,7 @@ jobs:
environment:
- PARALLELISM: 4
- CI_OS: linux
- EXTRA_APT_PACKAGES: gdmd llvm-dev libclang-common-10-dev
- EXTRA_APT_PACKAGES: gdmd llvm-11-dev libclang-common-11-dev
- HOST_LDC_VERSION: 1.24.0
- EXTRA_CMAKE_FLAGS: "-DBUILD_SHARED_LIBS=ON -DBUILD_LTO_LIBS=ON -DD_COMPILER=gdmd -DLDC_LINK_MANUALLY=ON"
macOS-x64:
Expand Down
4 changes: 2 additions & 2 deletions .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ task:
environment:
CI_ARCH: x86_64
CI_OS: linux
EXTRA_APT_PACKAGES: "llvm-dev libclang-common-10-dev"
EXTRA_APT_PACKAGES: "llvm-11-dev libclang-common-11-dev"
EXTRA_CMAKE_FLAGS: "-DMULTILIB=ON -DRT_SUPPORT_SANITIZERS=ON -DBUILD_LTO_LIBS=ON"
PARALLELISM: 8
PATH: ${CIRRUS_WORKING_DIR}/../cmake/bin:${CIRRUS_WORKING_DIR}/../ninja:${PATH}
Expand Down Expand Up @@ -301,7 +301,7 @@ task:
CI_ARCH: x86_64
CI_OS: linux
HOST_LDC_VERSION: 1.9.0
EXTRA_APT_PACKAGES: "llvm-dev libclang-common-10-dev"
EXTRA_APT_PACKAGES: "llvm-11-dev libclang-common-11-dev"
EXTRA_CMAKE_FLAGS: "-DBUILD_LTO_LIBS=ON"
PARALLELISM: 8
PATH: ${CIRRUS_WORKING_DIR}/../cmake/bin:${CIRRUS_WORKING_DIR}/../ninja:${PATH}
Expand Down
35 changes: 11 additions & 24 deletions .github/workflows/supported_llvm_versions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,39 +19,30 @@ jobs:
os: ubuntu-20.04
host_dc: ldc-beta
llvm_version: 15.0.6
- job_name: Ubuntu 20.04, LLVM 14, latest LDC beta
os: ubuntu-20.04
host_dc: ldc-beta
llvm_version: 14.0.0
# the compiler-rt libs installation is somehow non-standard
cmake_flags: -DLDC_INSTALL_LLVM_RUNTIME_LIBS_OS=x86_64-unknown-linux-gnu -DLDC_INSTALL_LLVM_RUNTIME_LIBS_ARCH=""
- job_name: Ubuntu 20.04, LLVM 12, latest LDC beta
os: ubuntu-20.04
host_dc: ldc-beta
llvm_version: 12.0.1
cmake_flags: -DLIB_SUFFIX=64
- job_name: Ubuntu 20.04, LLVM 11, latest LDC beta
os: ubuntu-20.04
host_dc: ldc-beta
llvm_version: 11.1.0
cmake_flags: -DBUILD_SHARED_LIBS=ON -DRT_SUPPORT_SANITIZERS=ON
- job_name: Ubuntu 20.04, LLVM 9, latest DMD beta
cmake_flags: -DBUILD_SHARED_LIBS=ON -DLIB_SUFFIX=64
- job_name: Ubuntu 20.04, LLVM 11, latest DMD beta
os: ubuntu-20.04
host_dc: dmd-beta
llvm_version: 9.0.1
llvm_version: 11.1.0
cmake_flags: -DBUILD_SHARED_LIBS=OFF -DRT_SUPPORT_SANITIZERS=ON -DLDC_LINK_MANUALLY=ON
- job_name: macOS 11, LLVM 10, latest DMD beta
- job_name: macOS 11, LLVM 13, latest DMD beta
os: macos-11
host_dc: dmd-beta
llvm_version: 10.0.1
cmake_flags: -DBUILD_SHARED_LIBS=ON -DRT_SUPPORT_SANITIZERS=ON -DLDC_LINK_MANUALLY=ON -DCMAKE_CXX_COMPILER=/usr/bin/c++ -DCMAKE_C_COMPILER=/usr/bin/cc -DCMAKE_OSX_DEPLOYMENT_TARGET=11.0
- job_name: macOS 11, LLVM 13, latest LDC beta
llvm_version: 13.0.1
cmake_flags: -DBUILD_SHARED_LIBS=ON -DRT_SUPPORT_SANITIZERS=ON -DLDC_LINK_MANUALLY=ON -DCMAKE_CXX_COMPILER=/usr/bin/c++ -DCMAKE_C_COMPILER=/usr/bin/cc
- job_name: macOS 11, LLVM 14, latest LDC beta
os: macos-11
host_dc: ldc-beta
llvm_version: 13.0.1
cmake_flags: -DBUILD_SHARED_LIBS=OFF -DD_COMPILER_FLAGS=-gcc=/usr/bin/c++ -DCMAKE_OSX_DEPLOYMENT_TARGET=11.0
llvm_version: 14.0.6
cmake_flags: -DBUILD_SHARED_LIBS=OFF -DD_COMPILER_FLAGS=-gcc=/usr/bin/c++
name: ${{ matrix.job_name }}
runs-on: ${{ matrix.os }}
env:
MACOSX_DEPLOYMENT_TARGET: 11.6 # silence `ld: warning: object file (…) was built for newer macOS version (…) than being linked (…)`
steps:
- uses: actions/checkout@v3
with:
Expand Down Expand Up @@ -132,10 +123,6 @@ jobs:
if: success() || failure()
run: |
set -eux
# LLVM 9: libclang_rt.fuzzer-x86_64.a not compiled with -fPIC
if [[ '${{ matrix.llvm_version }}' = 9.* ]]; then
echo "config.available_features.remove('Fuzzer')" >> tests/sanitizers/lit.local.cfg
fi
# LLVM 14+ on Linux: don't use vanilla llvm-symbolizer (no support for zlib-compressed debug sections => failing ASan tests)
if [[ '${{ runner.os }}' == 'Linux' && '${{ matrix.llvm_version }}' =~ ^1[4-9]\. ]]; then
mv llvm/bin/llvm-symbolizer llvm/bin/llvm-symbolizer.bak
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
- Frontend, druntime and Phobos are at version [2.104.2](https://dlang.org/changelog/2.104.0.html). (#4440)

#### Platform support
- Supports LLVM 11.0 - 15.0.

#### Bug fixes

Expand Down
16 changes: 7 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ endfunction()
# Locate LLVM.
#

find_package(LLVM 9.0 REQUIRED
find_package(LLVM 11.0 REQUIRED
all-targets analysis asmparser asmprinter bitreader bitwriter codegen core
debuginfodwarf debuginfomsf debuginfopdb demangle
instcombine ipo instrumentation irreader libdriver linker lto mc
Expand All @@ -52,9 +52,9 @@ foreach(LLVM_SUPPORTED_TARGET ${LLVM_TARGETS_TO_BUILD})
add_definitions("-DLDC_LLVM_SUPPORTED_TARGET_${LLVM_SUPPORTED_TARGET}=1")
endforeach()

# Set MLIR support variables if it is found. Only try for LLVM >= 10.0.
# Set MLIR support variables if it is found.
# FIXME: LLVM 14+ (`mlir::OwningModuleRef` replacement)
if(NOT (LDC_LLVM_VER LESS 1000) AND NOT LDC_WITH_MLIR STREQUAL "OFF" AND LDC_LLVM_VER LESS 1400)
if(NOT LDC_WITH_MLIR STREQUAL "OFF" AND LDC_LLVM_VER LESS 1400)
include(FindMLIR)
if(MLIR_FOUND)
message(STATUS "-- Building LDC with MLIR support (${MLIR_ROOT_DIR})")
Expand Down Expand Up @@ -599,12 +599,10 @@ if(MSVC)
endif()
endif()
if(LDC_WITH_LLD)
if(NOT (LDC_LLVM_VER LESS 1000))
if(MSVC)
list(APPEND LDC_LINKERFLAG_LIST LLVMSymbolize.lib)
else()
set(LDC_LINKERFLAG_LIST -lLLVMSymbolize ${LDC_LINKERFLAG_LIST})
endif()
if(MSVC)
list(APPEND LDC_LINKERFLAG_LIST LLVMSymbolize.lib)
else()
set(LDC_LINKERFLAG_LIST -lLLVMSymbolize ${LDC_LINKERFLAG_LIST})
endif()
if (LDC_LLVM_VER LESS 1200 OR NOT LDC_LLVM_VER LESS 1400)
set(LLD_MACHO lldMachO)
Expand Down
6 changes: 2 additions & 4 deletions cmake/Modules/FindLLVM.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ set(llvm_config_names llvm-config-15.0 llvm-config150 llvm-config-15
llvm-config-13.0 llvm-config130 llvm-config-13
llvm-config-12.0 llvm-config120 llvm-config-12
llvm-config-11.0 llvm-config110 llvm-config-11
llvm-config-10.0 llvm-config100 llvm-config-10
llvm-config-9.0 llvm-config90 llvm-config-9
llvm-config)
find_program(LLVM_CONFIG
NAMES ${llvm_config_names}
Expand All @@ -51,11 +49,11 @@ if(APPLE)
NAMES ${llvm_config_names}
PATHS /opt/local/libexec/llvm-15/bin
/opt/local/libexec/llvm-14/bin /opt/local/libexec/llvm-13/bin /opt/local/libexec/llvm-12/bin
/opt/local/libexec/llvm-11/bin /opt/local/libexec/llvm-10/bin /opt/local/libexec/llvm-9.0/bin
/opt/local/libexec/llvm-11/bin
/opt/local/libexec/llvm/bin
/usr/local/opt/llvm@15/bin
/usr/local/opt/llvm@14/bin /usr/local/opt/llvm@13/bin /usr/local/opt/llvm@12/bin
/usr/local/opt/llvm@11/bin /usr/local/opt/llvm@10/bin /usr/local/opt/llvm@9/bin
/usr/local/opt/llvm@11/bin
/usr/local/opt/llvm/bin
NO_DEFAULT_PATH)
endif()
Expand Down
2 changes: 0 additions & 2 deletions driver/archiver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@
#include "llvm/Object/MachO.h"
#include "llvm/Object/ObjectFile.h"
#include "llvm/Support/Errc.h"
#if LDC_LLVM_VER >= 1100
#include "llvm/Support/Host.h"
#endif
#include "llvm/Support/Path.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/ToolDrivers/llvm-lib/LibDriver.h"
Expand Down
12 changes: 0 additions & 12 deletions driver/cache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,20 +73,12 @@ static std::error_code createSymLink(const char *to, const char *from) {
#include <windows.h>
namespace llvm {
namespace sys {
#if LDC_LLVM_VER >= 1100
namespace windows {
// Fwd declaration to an internal LLVM function.
std::error_code widenPath(const llvm::Twine &Path8,
llvm::SmallVectorImpl<wchar_t> &Path16,
size_t MaxPathLen = MAX_PATH);
}
#else
namespace path {
// Fwd declaration to an internal LLVM function.
std::error_code widenPath(const llvm::Twine &Path8,
llvm::SmallVectorImpl<wchar_t> &Path16);
}
#endif // LDC_LLVM_VER < 1100
} // namespace sys
} // namespace llvm

Expand All @@ -100,11 +92,7 @@ std::error_code createLink(FType f, const char *to, const char *from) {
//
//===----------------------------------------------------------------------===//

#if LDC_LLVM_VER >= 1100
using llvm::sys::windows::widenPath;
#else
using llvm::sys::path::widenPath;
#endif

llvm::SmallVector<wchar_t, 128> wide_from;
llvm::SmallVector<wchar_t, 128> wide_to;
Expand Down
57 changes: 1 addition & 56 deletions driver/cl_options-llvm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,51 +15,28 @@

// Pull in command-line options and helper functions from special LLVM header
// shared by multiple LLVM tools.
#if LDC_LLVM_VER >= 1100
#include "llvm/CodeGen/CommandFlags.h"
static llvm::codegen::RegisterCodeGenFlags CGF;
using namespace llvm;
#else
#include "llvm/CodeGen/CommandFlags.inc"
#endif

static cl::opt<bool>
DisableRedZone("disable-red-zone", cl::ZeroOrMore,
cl::desc("Do not emit code that uses the red zone."));

#if LDC_LLVM_VER < 1100
// legacy option
static cl::opt<bool>
disableFPElim("disable-fp-elim", cl::ZeroOrMore, cl::ReallyHidden,
cl::desc("Disable frame pointer elimination optimization"));
#endif

// Now expose the helper functions (with static linkage) via external wrappers
// in the opts namespace, including some additional helper functions.
namespace opts {

std::string getArchStr() {
#if LDC_LLVM_VER >= 1100
return codegen::getMArch();
#else
return ::MArch;
#endif
}

Optional<Reloc::Model> getRelocModel() {
#if LDC_LLVM_VER >= 1100
return codegen::getExplicitRelocModel();
#else
return ::getRelocModel();
#endif
}

Optional<CodeModel::Model> getCodeModel() {
#if LDC_LLVM_VER >= 1100
return codegen::getExplicitCodeModel();
#else
return ::getCodeModel();
#endif
}

#if LDC_LLVM_VER >= 1300
Expand All @@ -69,26 +46,16 @@ using FPK = llvm::FramePointer::FP;
#endif

llvm::Optional<FPK> framePointerUsage() {
#if LDC_LLVM_VER >= 1100
// Defaults to `FP::None`; no way to check if set explicitly by user except
// indirectly via setFunctionAttributes()...
return codegen::getFramePointerUsage();
#else
if (::FramePointerUsage.getNumOccurrences() > 0)
return ::FramePointerUsage.getValue();
if (disableFPElim.getNumOccurrences() > 0)
return disableFPElim ? llvm::FramePointer::All : llvm::FramePointer::None;
return llvm::None;
#endif
}

bool disableRedZone() { return ::DisableRedZone; }

bool printTargetFeaturesHelp() {
#if LDC_LLVM_VER >= 1100
const auto MCPU = codegen::getMCPU();
const auto MAttrs = codegen::getMAttrs();
#endif
if (MCPU == "help")
return true;
return std::any_of(MAttrs.begin(), MAttrs.end(),
Expand All @@ -98,39 +65,23 @@ bool printTargetFeaturesHelp() {
TargetOptions InitTargetOptionsFromCodeGenFlags(const llvm::Triple &triple) {
#if LDC_LLVM_VER >= 1200
return codegen::InitTargetOptionsFromCodeGenFlags(triple);
#elif LDC_LLVM_VER >= 1100
return codegen::InitTargetOptionsFromCodeGenFlags();
#else
return ::InitTargetOptionsFromCodeGenFlags();
return codegen::InitTargetOptionsFromCodeGenFlags();
#endif
}

std::string getCPUStr() {
#if LDC_LLVM_VER >= 1100
return codegen::getCPUStr();
#else
return ::getCPUStr();
#endif
}

std::string getFeaturesStr() {
#if LDC_LLVM_VER >= 1100
return codegen::getFeaturesStr();
#else
return ::getFeaturesStr();
#endif
}

#if LDC_LLVM_VER >= 1000
void setFunctionAttributes(StringRef cpu, StringRef features,
Function &function) {
#if LDC_LLVM_VER >= 1100
return codegen::setFunctionAttributes(cpu, features, function);
#else
return ::setFunctionAttributes(cpu, features, function);
#endif
}
#endif
} // namespace opts

#if LDC_WITH_LLD
Expand All @@ -142,22 +93,16 @@ TargetOptions initTargetOptionsFromCodeGenFlags() {
return ::opts::InitTargetOptionsFromCodeGenFlags(llvm::Triple());
}

#if LDC_LLVM_VER >= 1000
Optional<Reloc::Model> getRelocModelFromCMModel() {
return ::opts::getRelocModel();
}
#endif

Optional<CodeModel::Model> getCodeModelFromCMModel() {
return ::opts::getCodeModel();
}

std::string getCPUStr() { return ::opts::getCPUStr(); }

#if LDC_LLVM_VER >= 1100
std::vector<std::string> getMAttrs() { return codegen::getMAttrs(); }
#else
std::vector<std::string> getMAttrs() { return ::MAttrs; }
#endif
} // namespace lld
#endif // LDC_WITH_LLD
2 changes: 0 additions & 2 deletions driver/cl_options-llvm.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ InitTargetOptionsFromCodeGenFlags(const llvm::Triple &triple);

std::string getCPUStr();
std::string getFeaturesStr();
#if LDC_LLVM_VER >= 1000
void setFunctionAttributes(llvm::StringRef cpu, llvm::StringRef features,
llvm::Function &function);
#endif
}
8 changes: 2 additions & 6 deletions driver/cl_options_sanitizers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,12 +206,8 @@ void initializeSanitizerOptionsFromCmdline()

if (isAnySanitizerEnabled() && !fSanitizeBlacklist.empty()) {
std::string loadError;
sanitizerBlacklist =
llvm::SpecialCaseList::create(fSanitizeBlacklist,
#if LDC_LLVM_VER >= 1000
*llvm::vfs::getRealFileSystem(),
#endif
loadError);
sanitizerBlacklist = llvm::SpecialCaseList::create(
fSanitizeBlacklist, *llvm::vfs::getRealFileSystem(), loadError);
if (!sanitizerBlacklist)
error(Loc(), "-fsanitize-blacklist error: %s", loadError.c_str());
}
Expand Down
Loading

0 comments on commit 3b7ca36

Please sign in to comment.