Skip to content

Drop support for LLVM < 15, legacy pass manager and non-opaque IR pointers #4657

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

Merged
merged 9 commits into from
May 20, 2024
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
36 changes: 22 additions & 14 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ commonSteps: &commonSteps
- run:
name: Install prerequisites
command: |
set -x
set -ux
cd ..
if [ "$CI_OS" = "linux" ]; then
export DEBIAN_FRONTEND=noninteractive
if [[ "$EXTRA_CMAKE_FLAGS" = *-DMULTILIB?ON* ]]; then
if [[ "${EXTRA_CMAKE_FLAGS:-}" = *-DMULTILIB?ON* ]]; then
dpkg --add-architecture i386
gcc_pkg="g++-multilib"
libcurl_pkg="libcurl4 libcurl4:i386"
Expand All @@ -20,7 +20,13 @@ commonSteps: &commonSteps
apt-get -yq install \
git-core $gcc_pkg \
zlib1g-dev $libcurl_pkg curl gdb python3 python3-pip tzdata unzip zip \
$EXTRA_APT_PACKAGES
software-properties-common gnupg \
${EXTRA_APT_PACKAGES:-}
# set up apt.llvm.org repo for being able to install more recent LLVM versions than provided by the distro
curl -fsS https://apt.llvm.org/llvm-snapshot.gpg.key | tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc
add-apt-repository -y "deb http://apt.llvm.org/focal/ llvm-toolchain-focal-$LLVM_MAJOR main"
apt-get -q update
apt-get -yq install llvm-$LLVM_MAJOR-dev libclang-common-$LLVM_MAJOR-dev
# Download & extract CMake
curl -fL --retry 3 --max-time 300 -o cmake.tar.gz https://github.com/Kitware/CMake/releases/download/v3.27.1/cmake-3.27.1-linux-x86_64.tar.gz
mkdir cmake
Expand All @@ -39,29 +45,31 @@ commonSteps: &commonSteps
python3 -m pip install --user setuptools wheel
python3 -m pip install --user lit
python3 -c "import lit.main; lit.main.main();" --version . | head -n 1
# Download & extract host LDC
curl -fL --retry 3 --max-time 300 -o ldc2.tar.xz https://github.com/ldc-developers/ldc/releases/download/v$HOST_LDC_VERSION/ldc2-$HOST_LDC_VERSION-$CI_OS-x86_64.tar.xz
mkdir host-ldc
tar -xf ldc2.tar.xz --strip 1 -C host-ldc
rm ldc2.tar.xz
# Download & extract host LDC if HOST_LDC_VERSION is set
if [[ -v HOST_LDC_VERSION ]]; then
curl -fL --retry 3 --max-time 300 -o ldc2.tar.xz https://github.com/ldc-developers/ldc/releases/download/v$HOST_LDC_VERSION/ldc2-$HOST_LDC_VERSION-$CI_OS-x86_64.tar.xz
mkdir host-ldc
tar -xf ldc2.tar.xz --strip 1 -C host-ldc
rm ldc2.tar.xz
fi
- checkout
- run:
name: Checkout git submodules
command: git submodule update --init
- run:
name: Build LDC & LDC D unittests & defaultlib unittest runners
command: |
set -x
set -ux
cd ..
cmake --version
ninja --version
mkdir build
cd build
cmake -G Ninja $CIRCLE_WORKING_DIRECTORY \
-DCMAKE_BUILD_TYPE=Release \
-DD_COMPILER=$PWD/../host-ldc/bin/ldmd2 \
${HOST_LDC_VERSION:+-DD_COMPILER=$PWD/../host-ldc/bin/ldmd2} \
-DLDC_LINK_MANUALLY=OFF \
$EXTRA_CMAKE_FLAGS
${EXTRA_CMAKE_FLAGS:-}
ninja -j$PARALLELISM obj/ldc2.o all ldc2-unittest all-test-runners
bin/ldc2 -version
- run:
Expand Down Expand Up @@ -97,7 +105,7 @@ jobs:
environment:
- PARALLELISM: 4
- CI_OS: linux
- EXTRA_APT_PACKAGES: llvm-11-dev libclang-common-11-dev
- LLVM_MAJOR: 15
- 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 @@ -108,8 +116,8 @@ jobs:
environment:
- PARALLELISM: 4
- CI_OS: linux
- EXTRA_APT_PACKAGES: gdmd llvm-11-dev libclang-common-11-dev
- HOST_LDC_VERSION: 1.24.0
- LLVM_MAJOR: 15
- EXTRA_APT_PACKAGES: gdmd
- EXTRA_CMAKE_FLAGS: "-DBUILD_SHARED_LIBS=ON -DBUILD_LTO_LIBS=ON -DD_COMPILER=gdmd -DLDC_LINK_MANUALLY=ON"

workflows:
Expand Down
40 changes: 10 additions & 30 deletions .github/workflows/supported_llvm_versions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@ jobs:
fail-fast: false
matrix:
include:
- job_name: Ubuntu 20.04, LDC-LLVM 18, latest LDC beta
- job_name: Ubuntu 20.04, LDC-LLVM 18, bootstrap LDC
os: ubuntu-20.04
host_dc: ldc-beta
host_dc: ldc-1.19.0
# FIXME: no usable official package available yet
llvm_version: https://github.com/ldc-developers/llvm-project/releases/download/ldc-v18.1.5/llvm-18.1.5-linux-x86_64.tar.xz
cmake_flags: -DRT_SUPPORT_SANITIZERS=ON
- job_name: macOS 14, LLVM 17, latest LDC beta
os: macos-14
host_dc: ldc-beta
Expand All @@ -30,30 +31,11 @@ jobs:
host_dc: ldc-beta
llvm_version: 16.0.5
cmake_flags: -DBUILD_SHARED_LIBS=OFF -DD_COMPILER_FLAGS=-gcc=/usr/bin/c++ -DCMAKE_EXE_LINKER_FLAGS=-L/opt/homebrew/opt/zstd/lib
- job_name: Ubuntu 20.04, LLVM 15, latest LDC beta
os: ubuntu-20.04
host_dc: ldc-beta
llvm_version: 15.0.6
- job_name: macOS 11, LLVM 14, latest DMD beta
os: macos-11
host_dc: dmd-beta
llvm_version: 14.0.6
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: Ubuntu 20.04, LLVM 13, latest LDC beta
os: ubuntu-20.04
host_dc: ldc-beta
llvm_version: 13.0.1
cmake_flags: -DRT_SUPPORT_SANITIZERS=ON
- job_name: Ubuntu 20.04, LLVM 12, bootstrap LDC
os: ubuntu-20.04
host_dc: ldc-1.19.0
llvm_version: 12.0.1
cmake_flags: -DBUILD_SHARED_LIBS=ON -DLIB_SUFFIX=64
- job_name: Ubuntu 20.04, LLVM 11, latest DMD beta
- job_name: Ubuntu 20.04, LLVM 15, latest DMD beta
os: ubuntu-20.04
host_dc: dmd-beta
llvm_version: 11.1.0
cmake_flags: -DBUILD_SHARED_LIBS=OFF -DRT_SUPPORT_SANITIZERS=ON -DLDC_LINK_MANUALLY=ON
llvm_version: 15.0.6
cmake_flags: -DBUILD_SHARED_LIBS=ON -DRT_SUPPORT_SANITIZERS=ON -DLIB_SUFFIX=64 -DLDC_LINK_MANUALLY=ON
name: ${{ matrix.job_name }}
runs-on: ${{ matrix.os }}
env:
Expand Down Expand Up @@ -116,10 +98,8 @@ jobs:
fi
elif [[ "$version" =~ ^1[7-9]\. ]]; then
suffix='x86_64-linux-gnu-ubuntu-22.04' # LLVM 17+
elif [[ "$version" =~ ^1[3-6]\. ]]; then
suffix='x86_64-linux-gnu-ubuntu-18.04' # LLVM 13.0.1+
else
suffix='x86_64-linux-gnu-ubuntu-16.04'
suffix='x86_64-linux-gnu-ubuntu-18.04' # LLVM 14+
fi

url="https://github.com/llvm/llvm-project/releases/download/llvmorg-$version/clang+llvm-$version-$suffix.tar.xz"
Expand All @@ -136,7 +116,7 @@ jobs:
fi

- name: 'Linux: Make lld the default linker'
if: runner.os == 'Linux' && matrix.host_dc != 'ldc-1.9.0'
if: runner.os == 'Linux'
run: |
set -eux
echo "Using lld to work around sporadic failures"
Expand All @@ -161,8 +141,8 @@ jobs:
if: success() || failure()
run: |
set -eux
# 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[1-3]\. ]]; then
# Linux: don't use vanilla llvm-symbolizer (no support for zlib-compressed debug sections => failing ASan tests)
if [[ '${{ runner.os }}' == 'Linux' ]]; then
mv llvm/bin/llvm-symbolizer llvm/bin/llvm-symbolizer.bak
fi
ctest -V -R "lit-tests"
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#### Big news

#### Platform support
- Supports LLVM 15 - 18. Support for LLVM 11 - 14 was dropped. The CLI options `-passmanager` and `-opaque-pointers` were removed.

#### Bug fixes

Expand Down
40 changes: 9 additions & 31 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 11.0 REQUIRED
find_package(LLVM 15.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 @@ -604,28 +604,15 @@ if(LDC_WITH_LLD)
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)
else()
set(LLD_MACHO lldMachO2)
endif()
set(LLD_MACHO lldMachO)
if(MSVC)
if(NOT (LDC_LLVM_VER LESS 1400))
list(APPEND LDC_LINKERFLAG_LIST lldMinGW.lib lldCOFF.lib lldELF.lib ${LLD_MACHO}.lib lldWasm.lib lldCommon.lib)
else()
list(APPEND LDC_LINKERFLAG_LIST lldDriver.lib lldMinGW.lib lldCOFF.lib lldELF.lib ${LLD_MACHO}.lib lldWasm.lib lldYAML.lib lldReaderWriter.lib lldCommon.lib lldCore.lib)
endif()
list(APPEND LDC_LINKERFLAG_LIST lldMinGW.lib lldCOFF.lib lldELF.lib ${LLD_MACHO}.lib lldWasm.lib lldCommon.lib)
else()
if(NOT (LDC_LLVM_VER LESS 1400))
set(LDC_LINKERFLAG_LIST -llldMinGW -llldCOFF -llldELF -l${LLD_MACHO} -llldWasm -llldCommon ${LDC_LINKERFLAG_LIST})
else()
set(LDC_LINKERFLAG_LIST -llldDriver -llldMinGW -llldCOFF -llldELF -l${LLD_MACHO} -llldWasm -llldYAML -llldReaderWriter -llldCommon -llldCore ${LDC_LINKERFLAG_LIST})
endif()
set(LDC_LINKERFLAG_LIST -llldMinGW -llldCOFF -llldELF -l${LLD_MACHO} -llldWasm -llldCommon ${LDC_LINKERFLAG_LIST})
endif()
if(APPLE)
if(NOT (LDC_LLVM_VER LESS 1300)) # LLD 13.0.0 on Mac needs libxar
list(APPEND LDC_LINKERFLAG_LIST -lxar)
endif()
# LLD 13.0.0 on Mac needs libxar
list(APPEND LDC_LINKERFLAG_LIST -lxar)
endif()
endif()

Expand Down Expand Up @@ -820,11 +807,7 @@ set(COMPILER_RT_LIBDIR "${COMPILER_RT_LIBDIR}/lib")
if(APPLE)
set(COMPILER_RT_LIBDIR "${COMPILER_RT_LIBDIR}/darwin")
elseif(UNIX)
if(LDC_LLVM_VER LESS 1500)
set(COMPILER_RT_LIBDIR_OS_DEFAULT "linux")
else()
set(COMPILER_RT_LIBDIR_OS_DEFAULT "x86_64-unknown-linux-gnu")
endif()
set(COMPILER_RT_LIBDIR_OS_DEFAULT "x86_64-unknown-linux-gnu")
set(COMPILER_RT_LIBDIR_OS "${COMPILER_RT_LIBDIR_OS_DEFAULT}" CACHE STRING "Non-Mac Posix: OS used as directory name for the compiler-rt source libraries, e.g., 'freebsd'.")
set(COMPILER_RT_LIBDIR "${COMPILER_RT_LIBDIR}/${COMPILER_RT_LIBDIR_OS}")
elseif(WIN32)
Expand Down Expand Up @@ -864,13 +847,8 @@ if (LDC_INSTALL_LLVM_RUNTIME_LIBS)
copy_compilerrt_lib("libclang_rt.xray-fdr_osx.a" "libldc_rt.xray-fdr.a" FALSE)
copy_compilerrt_lib("libclang_rt.xray-profiling_osx.a" "libldc_rt.xray-profiling.a" FALSE)
elseif(UNIX)
if(LDC_LLVM_VER LESS 1500)
set(LDC_INSTALL_LLVM_RUNTIME_LIBS_ARCH_DEFAULT "x86_64")
else()
set(LDC_INSTALL_LLVM_RUNTIME_LIBS_ARCH_DEFAULT "")
endif()
set(LDC_INSTALL_LLVM_RUNTIME_LIBS_ARCH "${LDC_INSTALL_LLVM_RUNTIME_LIBS_ARCH_DEFAULT}" CACHE STRING
"Non-Mac Posix: architecture used as libname suffix for the compiler-rt source libraries, e.g., 'aarch64'.")
set(LDC_INSTALL_LLVM_RUNTIME_LIBS_ARCH "" CACHE STRING
"Non-Mac Posix: architecture used as libname suffix for the compiler-rt source libraries, e.g., 'aarch64'.")
if(LDC_INSTALL_LLVM_RUNTIME_LIBS_ARCH STREQUAL "")
set(compilerrt_suffix "")
else()
Expand Down
8 changes: 0 additions & 8 deletions cmake/Modules/FindLLVM.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,6 @@ set(llvm_config_names llvm-config-18.1 llvm-config181 llvm-config-18
llvm-config-17.0 llvm-config170 llvm-config-17
llvm-config-16.0 llvm-config160 llvm-config-16
llvm-config-15.0 llvm-config150 llvm-config-15
llvm-config-14.0 llvm-config140 llvm-config-14
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)
find_program(LLVM_CONFIG
NAMES ${llvm_config_names}
Expand All @@ -52,13 +48,9 @@ if(APPLE)
NAMES ${llvm_config_names}
PATHS /opt/local/libexec/llvm-18/bin /opt/local/libexec/llvm-17/bin
/opt/local/libexec/llvm-16/bin /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/bin
/usr/local/opt/llvm@18/bin /usr/local/opt/llvm@17/bin
/usr/local/opt/llvm@16/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/bin
NO_DEFAULT_PATH)
endif()
Expand Down
5 changes: 0 additions & 5 deletions driver/args.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,17 +116,12 @@ struct ResponseFile {
return true; // nothing to do

#if defined(_WIN32)
#if LDC_LLVM_VER >= 1200
const llvm::ErrorOr<std::wstring> wcontent =
llvm::sys::flattenWindowsCommandLine(toRefsVector(args));

std::string content;
if (!wcontent || !llvm::convertWideToUTF8(*wcontent, content))
return false;
#else
const std::string content =
llvm::sys::flattenWindowsCommandLine(toRefsVector(args));
#endif
#else
std::string content;
content.reserve(65536);
Expand Down
8 changes: 0 additions & 8 deletions driver/cl_options-llvm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,7 @@ Optional<CodeModel::Model> getCodeModel() {
return codegen::getExplicitCodeModel();
}

#if LDC_LLVM_VER >= 1300
using FPK = llvm::FramePointerKind;
#else
using FPK = llvm::FramePointer::FP;
#endif

llvm::Optional<FPK> framePointerUsage() {
// Defaults to `FP::None`; no way to check if set explicitly by user except
Expand All @@ -67,11 +63,7 @@ bool printTargetFeaturesHelp() {
}

TargetOptions InitTargetOptionsFromCodeGenFlags(const llvm::Triple &triple) {
#if LDC_LLVM_VER >= 1200
return codegen::InitTargetOptionsFromCodeGenFlags(triple);
#else
return codegen::InitTargetOptionsFromCodeGenFlags();
#endif
}

std::string getCPUStr() {
Expand Down
4 changes: 0 additions & 4 deletions driver/cl_options-llvm.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,7 @@ namespace opts {
std::string getArchStr();
llvm::Optional<llvm::Reloc::Model> getRelocModel();
llvm::Optional<llvm::CodeModel::Model> getCodeModel();
#if LDC_LLVM_VER >= 1300
llvm::Optional<llvm::FramePointerKind> framePointerUsage();
#else
llvm::Optional<llvm::FramePointer::FP> framePointerUsage();
#endif

bool disableRedZone();
bool printTargetFeaturesHelp();
Expand Down
29 changes: 1 addition & 28 deletions driver/cl_options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -535,18 +535,6 @@ cl::opt<bool> noPLT(
"fno-plt", cl::ZeroOrMore,
cl::desc("Do not use the PLT to make function calls"));

static cl::opt<signed char> passmanager("passmanager",
cl::desc("Setting the passmanager (new,legacy):"), cl::ZeroOrMore,
#if LDC_LLVM_VER < 1500
cl::init(0),
#else
cl::init(1),
#endif
cl::values(
clEnumValN(0, "legacy", "Use the legacy passmanager (available for LLVM14 and below) "),
clEnumValN(1, "new", "Use the new passmanager (available for LLVM14 and above)")));
bool isUsingLegacyPassManager() { return passmanager == 0; }

// Math options
bool fFastMath; // Storage for the dynamically created ffast-math option.
llvm::FastMathFlags defaultFMF;
Expand Down Expand Up @@ -690,14 +678,10 @@ cl::opt<std::string>
"of optimizations performed by LLVM"),
cl::ValueOptional);

#if LDC_LLVM_VER >= 1300
// LLVM < 13 has "--warn-stack-size", but let's not do the effort of forwarding
// the string to that option, and instead let the user do it himself.
cl::opt<unsigned>
fWarnStackSize("fwarn-stack-size", cl::ZeroOrMore, cl::init(UINT_MAX),
cl::desc("Warn for stack size bigger than the given number"),
cl::value_desc("threshold"));
#endif

#if LDC_LLVM_SUPPORTED_TARGET_SPIRV || LDC_LLVM_SUPPORTED_TARGET_NVPTX
cl::list<std::string>
Expand Down Expand Up @@ -726,12 +710,6 @@ cl::opt<bool> dynamicCompileTlsWorkaround(
cl::Hidden);
#endif

#if LDC_LLVM_VER >= 1700
bool enableOpaqueIRPointers = true; // typed pointers are no longer supported from LLVM 17
#elif LDC_LLVM_VER >= 1400
bool enableOpaqueIRPointers = false;
#endif

static cl::extrahelp
footer("\n"
"-d-debug can also be specified without options, in which case it "
Expand Down Expand Up @@ -790,12 +768,7 @@ void createClashingOptions() {
clEnumValN(FloatABI::Hard, "hard",
"Hardware floating-point ABI and instructions")));

#if LDC_LLVM_VER >= 1400
renameAndHide("opaque-pointers", nullptr); // remove
new cl::opt<bool, true>(
"opaque-pointers", cl::ZeroOrMore, cl::location(enableOpaqueIRPointers),
cl::desc("Use opaque IR pointers (experimental!)"), cl::Hidden);
#endif
}

/// Hides command line options exposed from within LLVM that are unlikely
Expand Down Expand Up @@ -883,7 +856,7 @@ void hideLLVMOptions() {
"no-discriminators", "no-integrated-as", "no-type-check", "no-xray-index",
"nozero-initialized-in-bss", "nvptx-sched4reg",
"objc-arc-annotation-target-identifier",
"object-size-offset-visitor-max-visit-instructions", "opaque-pointers",
"object-size-offset-visitor-max-visit-instructions",
"pgo-block-coverage", "pgo-temporal-instrumentation",
"pgo-view-block-coverage-graph",
"pie-copy-relocations", "poison-checking-function-local",
Expand Down
Loading