Skip to content

Commit

Permalink
Drop support for LLVM 9 and LLVM 10
Browse files Browse the repository at this point in the history
  • Loading branch information
kinke committed Jul 28, 2023
1 parent 1a93fc7 commit 9ce5780
Show file tree
Hide file tree
Showing 43 changed files with 46 additions and 3,948 deletions.
25 changes: 8 additions & 17 deletions .github/workflows/supported_llvm_versions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,17 @@ jobs:
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
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 10, 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
os: macos-11
host_dc: ldc-beta
Expand Down Expand Up @@ -132,10 +127,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 @@ -28,7 +28,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 @@ -46,9 +46,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 @@ -593,12 +593,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
13 changes: 2 additions & 11 deletions driver/codegenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,7 @@
#if LDC_LLVM_VER >= 1400
#include "llvm/IR/DiagnosticInfo.h"
#endif
#if LDC_LLVM_VER >= 1100
#include "llvm/IR/LLVMRemarkStreamer.h"
#else
#include "llvm/IR/RemarkStreamer.h"
#endif
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/ToolOutputFile.h"
Expand Down Expand Up @@ -66,13 +62,8 @@ createAndSetDiagnosticsOutputFile(IRState &irs, llvm::LLVMContext &ctx,
// If there is instrumentation data available, also output function hotness
const bool withHotness = opts::isUsingPGOProfile();

auto remarksFileOrError =
#if LDC_LLVM_VER >= 1100
llvm::setupLLVMOptimizationRemarks(
#else
llvm::setupOptimizationRemarks(
#endif
ctx, diagnosticsFilename, "", "", withHotness);
auto remarksFileOrError = llvm::setupLLVMOptimizationRemarks(
ctx, diagnosticsFilename, "", "", withHotness);
if (llvm::Error e = remarksFileOrError.takeError()) {
irs.dmodule->error("Could not create file %s: %s",
diagnosticsFilename.c_str(),
Expand Down
4 changes: 0 additions & 4 deletions driver/ldmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -512,11 +512,7 @@ void translateArgs(const llvm::SmallVectorImpl<const char *> &ldmdArgs,
} else if (strcmp(p + 1, "gf") == 0) {
ldcArgs.push_back("-g");
} else if (strcmp(p + 1, "gs") == 0) {
#if LDC_LLVM_VER >= 1100
ldcArgs.push_back("-frame-pointer=all");
#else
ldcArgs.push_back("-disable-fp-elim");
#endif
} else if (strcmp(p + 1, "gx") == 0) {
goto Lnot_in_ldc;
} else if (strcmp(p + 1, "gt") == 0) {
Expand Down
Loading

0 comments on commit 9ce5780

Please sign in to comment.