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 9.0 #3960

Merged
merged 2 commits into from
Apr 25, 2022
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
8 changes: 3 additions & 5 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ commonSteps: &commonSteps
apt-get -q update
apt-get -yq install \
git-core cmake ninja-build $gcc_pkg \
llvm-dev zlib1g-dev libclang-common-$LIBCLANG_COMMON_VERSION-dev \
$libcurl_pkg curl gdb python3 python3-pip tzdata unzip zip \
zlib1g-dev $libcurl_pkg curl gdb python3 python3-pip tzdata unzip zip \
$EXTRA_APT_PACKAGES
else
# Download & extract CMake
Expand Down Expand Up @@ -108,7 +107,7 @@ jobs:
environment:
- PARALLELISM: 2
- CI_OS: linux
- LIBCLANG_COMMON_VERSION: "6.0"
- EXTRA_APT_PACKAGES: llvm-9-dev libclang-common-9-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 @@ -118,8 +117,7 @@ jobs:
environment:
- PARALLELISM: 2
- CI_OS: linux
- LIBCLANG_COMMON_VERSION: "10"
- EXTRA_APT_PACKAGES: gdmd
- EXTRA_APT_PACKAGES: gdmd llvm-dev libclang-common-10-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
13 changes: 5 additions & 8 deletions .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ common_steps_template: &COMMON_STEPS_TEMPLATE
ctest -j$PARALLELISM --output-on-failure -E "$excludes"

# Installs Ubuntu 18.04+ prerequisites.
# Requires env variables HOST_LDC_VERSION and LIBCLANG_COMMON_VERSION and
# supports optional EXTRA_APT_PACKAGES.
# Requires env variables HOST_LDC_VERSION and EXTRA_APT_PACKAGES.
install_ubuntu_prerequisites_template: &INSTALL_UBUNTU_PREREQUISITES_TEMPLATE
install_prerequisites_script: |
cd $CIRRUS_WORKING_DIR/..
Expand All @@ -68,8 +67,7 @@ install_ubuntu_prerequisites_template: &INSTALL_UBUNTU_PREREQUISITES_TEMPLATE
apt-get -q update
apt-get -yq install \
git-core cmake ninja-build $gcc_pkg \
llvm-dev zlib1g-dev libclang-common-$LIBCLANG_COMMON_VERSION-dev \
$libcurl_pkg curl gdb python3 python3-pip tzdata unzip zip \
zlib1g-dev $libcurl_pkg curl gdb python3 python3-pip tzdata unzip zip \
$EXTRA_APT_PACKAGES
python3 --version
# Download & extract host LDC
Expand Down Expand Up @@ -121,7 +119,7 @@ task:
timeout_in: 60m
environment:
CI_OS: linux
LIBCLANG_COMMON_VERSION: "6.0"
EXTRA_APT_PACKAGES: "llvm-9-dev libclang-common-9-dev"
EXTRA_CMAKE_FLAGS: "-DMULTILIB=ON -DRT_SUPPORT_SANITIZERS=ON -DBUILD_LTO_LIBS=ON"
PARALLELISM: 8
<< : *INSTALL_UBUNTU_PREREQUISITES_TEMPLATE
Expand All @@ -138,8 +136,7 @@ task:
timeout_in: 60m
environment:
CI_OS: linux
LIBCLANG_COMMON_VERSION: "12"
EXTRA_APT_PACKAGES: "gdmd"
EXTRA_APT_PACKAGES: "gdmd llvm-dev libclang-common-12-dev"
EXTRA_CMAKE_FLAGS: "-DBUILD_SHARED_LIBS=ON -DBUILD_LTO_LIBS=ON -DD_COMPILER=gdmd -DLDC_LINK_MANUALLY=ON"
PARALLELISM: 8
# for gdmd:
Expand All @@ -156,8 +153,8 @@ task:
timeout_in: 60m
environment:
CI_OS: linux
LIBCLANG_COMMON_VERSION: "6.0"
HOST_LDC_VERSION: 1.9.0
EXTRA_APT_PACKAGES: "llvm-9-dev libclang-common-9-dev"
EXTRA_CMAKE_FLAGS: "-DBUILD_LTO_LIBS=ON"
PARALLELISM: 8
<< : *INSTALL_UBUNTU_PREREQUISITES_TEMPLATE
Expand Down
36 changes: 8 additions & 28 deletions .github/workflows/supported_llvm_versions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,45 +13,30 @@ jobs:
llvm_version: "14.0.0"
# the compiler-rt libs installation is somehow non-standard
cmake_opts: "-DLDC_INSTALL_LLVM_RUNTIME_LIBS_OS=x86_64-unknown-linux-gnu -DLDC_INSTALL_LLVM_RUNTIME_LIBS_ARCH="
- job_name: Ubuntu 18.04, LLVM 13, latest LDC beta
os: ubuntu-18.04
host_dc: ldc-beta
llvm_version: "13.0.1"
cmake_opts: ""
- job_name: Ubuntu 18.04, LLVM 12, latest LDC beta
os: ubuntu-18.04
host_dc: ldc-beta
llvm_version: "12.0.1"
cmake_opts: ""
cmake_opts: "-DLIB_SUFFIX=64"
- job_name: Ubuntu 18.04, LLVM 11, latest LDC beta
os: ubuntu-18.04
host_dc: ldc-beta
llvm_version: "11.1.0"
cmake_opts: "-DBUILD_SHARED_LIBS=ON -DRT_SUPPORT_SANITIZERS=ON"
- job_name: Ubuntu 18.04, LLVM 9, latest LDC beta
os: ubuntu-18.04
host_dc: ldc-beta
llvm_version: "9.0.1"
cmake_opts: "-DBUILD_SHARED_LIBS=OFF -DRT_SUPPORT_SANITIZERS=ON"
- job_name: Ubuntu 18.04, LLVM 8, latest LDC beta
os: ubuntu-18.04
host_dc: ldc-beta
llvm_version: "8.0.0"
cmake_opts: "-DLIB_SUFFIX=64"
- job_name: Ubuntu 18.04, LLVM 6, latest DMD beta
- job_name: Ubuntu 18.04, LLVM 9, latest DMD beta
os: ubuntu-18.04
host_dc: dmd-beta
llvm_version: "6.0.1"
cmake_opts: "-DLDC_LINK_MANUALLY=ON"
llvm_version: "9.0.1"
cmake_opts: "-DBUILD_SHARED_LIBS=OFF -DRT_SUPPORT_SANITIZERS=ON -DLDC_LINK_MANUALLY=ON"
- job_name: macOS 10.15, LLVM 10, latest DMD beta
os: macos-10.15
host_dc: dmd-beta
llvm_version: "10.0.1"
cmake_opts: "-DBUILD_SHARED_LIBS=ON -DRT_SUPPORT_SANITIZERS=ON -DLDC_LINK_MANUALLY=ON"
- job_name: macOS 10.15, LLVM 7, latest LDC beta
- job_name: macOS 10.15, LLVM 13, latest LDC beta
os: macos-10.15
host_dc: ldc-beta
llvm_version: "7.0.0"
llvm_version: "13.0.1"
cmake_opts: "-DBUILD_SHARED_LIBS=OFF"
name: ${{ matrix.job_name }}
runs-on: ${{ matrix.os }}
Expand Down Expand Up @@ -86,7 +71,7 @@ jobs:
uses: actions/cache@v2
with:
path: llvm
key: llvm-${{ matrix.llvm_version }}-ubuntu-16.04
key: llvm-${{ matrix.llvm_version }}-${{ matrix.os }}

- name: Download & extract prebuilt vanilla LLVM ${{ matrix.llvm_version }}
run: |
Expand All @@ -103,12 +88,7 @@ jobs:
else
suffix='x86_64-linux-gnu-ubuntu-16.04'
fi
if [[ "$version" =~ ^(1.|9)\. ]]; then
llvm_url="https://github.com/llvm/llvm-project/releases/download/llvmorg-$version/clang+llvm-$version-$suffix.tar.xz"
else
llvm_url="http://releases.llvm.org/$version/clang+llvm-$version-$suffix.tar.xz"
fi
curl -fL --retry 3 --max-time 300 -o llvm.tar.xz $llvm_url
curl -fL --retry 3 --max-time 300 -o llvm.tar.xz https://github.com/llvm/llvm-project/releases/download/llvmorg-$version/clang+llvm-$version-$suffix.tar.xz
mkdir -p llvm
tar -xf llvm.tar.xz --strip 1 -C llvm
rm llvm.tar.xz
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
- All LLVM targets are enabled now (=> more targets for cross-compilation).
- For the Mac package, the minimum supported macOS version has been raised to v10.12.
- The minimum D version for bootstrapping has been raised to v2.079 (for GDC: v9.4), in line with DMD. (#3956)
- The minimum LLVM version has been raised to v9.0. (#3960)

#### Platform support
- Supports LLVM 9.0 - 14.0.

#### Bug fixes

Expand Down
21 changes: 7 additions & 14 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 6.0 REQUIRED
find_package(LLVM 9.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 @@ -629,9 +629,6 @@ if(LDC_WITH_LLD)
endif()
endif()
if(APPLE)
if(LDC_LLVM_VER LESS 700) # LLVM 6.0.0 bug, should be fixed in 6.0.1
list(APPEND LDC_LINKERFLAG_LIST -lxml2)
endif()
if(NOT (LDC_LLVM_VER LESS 1300)) # LLD 13.0.0 on Mac needs libxar
list(APPEND LDC_LINKERFLAG_LIST -lxar)
endif()
Expand Down Expand Up @@ -800,11 +797,9 @@ if (LDC_INSTALL_LLVM_RUNTIME_LIBS)
copy_compilerrt_lib("darwin/libclang_rt.profile_osx.a" "libldc_rt.profile.a" FALSE)
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)
copy_compilerrt_lib("darwin/libclang_rt.xray-profiling_osx.a" "libldc_rt.xray-profiling.a" FALSE)
endif()
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)
copy_compilerrt_lib("darwin/libclang_rt.xray-profiling_osx.a" "libldc_rt.xray-profiling.a" FALSE)
elseif(UNIX)
set(LDC_INSTALL_LLVM_RUNTIME_LIBS_OS "linux" CACHE STRING "Non-Mac Posix: OS used as directory name for the compiler-rt source libraries, e.g., 'freebsd'.")
set(LDC_INSTALL_LLVM_RUNTIME_LIBS_ARCH "x86_64" CACHE STRING "Non-Mac Posix: architecture used as libname suffix for the compiler-rt source libraries, e.g., 'aarch64'.")
Expand All @@ -821,11 +816,9 @@ if (LDC_INSTALL_LLVM_RUNTIME_LIBS)
copy_compilerrt_lib("${LDC_INSTALL_LLVM_RUNTIME_LIBS_OS}/libclang_rt.profile${compilerrt_suffix}.a" "libldc_rt.profile.a" FALSE)
copy_compilerrt_lib("${LDC_INSTALL_LLVM_RUNTIME_LIBS_OS}/libclang_rt.xray${compilerrt_suffix}.a" "libldc_rt.xray.a" FALSE)
copy_compilerrt_lib("${LDC_INSTALL_LLVM_RUNTIME_LIBS_OS}/libclang_rt.fuzzer${compilerrt_suffix}.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${compilerrt_suffix}.a" "libldc_rt.xray-basic.a" FALSE)
copy_compilerrt_lib("${LDC_INSTALL_LLVM_RUNTIME_LIBS_OS}/libclang_rt.xray-fdr${compilerrt_suffix}.a" "libldc_rt.xray-fdr.a" FALSE)
copy_compilerrt_lib("${LDC_INSTALL_LLVM_RUNTIME_LIBS_OS}/libclang_rt.xray-profiling${compilerrt_suffix}.a" "libldc_rt.xray-profiling.a" FALSE)
endif()
copy_compilerrt_lib("${LDC_INSTALL_LLVM_RUNTIME_LIBS_OS}/libclang_rt.xray-basic${compilerrt_suffix}.a" "libldc_rt.xray-basic.a" FALSE)
copy_compilerrt_lib("${LDC_INSTALL_LLVM_RUNTIME_LIBS_OS}/libclang_rt.xray-fdr${compilerrt_suffix}.a" "libldc_rt.xray-fdr.a" FALSE)
copy_compilerrt_lib("${LDC_INSTALL_LLVM_RUNTIME_LIBS_OS}/libclang_rt.xray-profiling${compilerrt_suffix}.a" "libldc_rt.xray-profiling.a" FALSE)
elseif(WIN32)
set(compilerrt_arch_suffix "x86_64")
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
Expand Down
5 changes: 0 additions & 5 deletions cmake/Modules/FindLLVM.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@ set(llvm_config_names llvm-config-14.0 llvm-config140 llvm-config-14
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-8.0 llvm-config80 llvm-config-8
llvm-config-7.0 llvm-config70 llvm-config-7
llvm-config-6.0 llvm-config60
llvm-config)
find_program(LLVM_CONFIG
NAMES ${llvm_config_names}
Expand All @@ -53,11 +50,9 @@ if(APPLE)
NAMES ${llvm_config_names}
PATHS /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-8.0/bin /opt/local/libexec/llvm-7.0/bin /opt/local/libexec/llvm-6.0/bin
/opt/local/libexec/llvm/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@8/bin /usr/local/opt/llvm@7/bin /usr/local/opt/llvm@6/bin
/usr/local/opt/llvm/bin
NO_DEFAULT_PATH)
endif()
Expand Down
10 changes: 1 addition & 9 deletions driver/args.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,13 @@ bool isRunArg(const char *arg) {
////////////////////////////////////////////////////////////////////////////////

namespace {
#if LDC_LLVM_VER >= 700
std::vector<llvm::StringRef> toRefsVector(llvm::ArrayRef<const char *> args) {
std::vector<llvm::StringRef> refs;
refs.reserve(args.size());
for (const char *arg : args)
refs.emplace_back(arg);
return refs;
}
#endif

struct ResponseFile {
llvm::SmallString<128> path;
Expand All @@ -117,7 +115,7 @@ struct ResponseFile {
if (llvm::sys::commandLineFitsWithinSystemLimits(fullArgs[0], args))
return true; // nothing to do

#if defined(_WIN32) && LDC_LLVM_VER >= 700
#if defined(_WIN32)
#if LDC_LLVM_VER >= 1200
const llvm::ErrorOr<std::wstring> wcontent =
llvm::sys::flattenWindowsCommandLine(toRefsVector(args));
Expand Down Expand Up @@ -178,14 +176,8 @@ int executeAndWait(
fullArgs.push_back(rspArg.c_str());
}

#if LDC_LLVM_VER >= 700
const std::vector<llvm::StringRef> argv = toRefsVector(fullArgs);
auto envVars = llvm::None;
#else
fullArgs.push_back(nullptr); // terminate with null
auto argv = fullArgs.data();
auto envVars = nullptr;
#endif

return llvm::sys::ExecuteAndWait(argv[0], argv, envVars, {}, 0, 0, errorMsg);
}
Expand Down
25 changes: 2 additions & 23 deletions driver/cache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -326,13 +326,9 @@ void outputIR2ObjRelevantCmdlineArgs(llvm::raw_ostream &hash_os) {
const auto codeModel = opts::getCodeModel();
if (codeModel.hasValue())
hash_os << codeModel.getValue();
#if LDC_LLVM_VER >= 800
const auto framePointerUsage = opts::framePointerUsage();
if (framePointerUsage.hasValue())
hash_os << static_cast<int>(framePointerUsage.getValue());
#else
hash_os << opts::disableFPElim();
#endif
}

// Output to `hash_os` all environment flags that influence object code output
Expand All @@ -358,11 +354,7 @@ void calculateModuleHash(llvm::Module *m, llvm::SmallString<32> &str) {
outputIR2ObjRelevantCmdlineArgs(hash_os);
outputIR2ObjRelevantEnvironmentOpts(hash_os);

#if LDC_LLVM_VER >= 700
llvm::WriteBitcodeToFile(*m, hash_os);
#else
llvm::WriteBitcodeToFile(m, hash_os);
#endif
hash_os.resultAsString(str);
IF_LOG Logger::println("Module's LLVM bitcode hash is: %s", str.c_str());
}
Expand Down Expand Up @@ -508,27 +500,14 @@ void recoverObjectFile(llvm::StringRef cacheObjectHash,
{
int FD;
if (llvm::sys::fs::openFileForWrite(cacheFile.c_str(), FD,
#if LDC_LLVM_VER >= 700
llvm::sys::fs::CD_OpenExisting,
#endif
#if LDC_LLVM_VER >= 900
llvm::sys::fs::OF_Append
#else
llvm::sys::fs::F_Append
#endif
)) {
llvm::sys::fs::OF_Append)) {
error(Loc(), "Failed to open the cached file for writing: %s",
cacheFile.c_str());
fatal();
}

#if LDC_LLVM_VER < 800
#define SET_LAST_ACCESS_AND_MOD_TIME setLastModificationAndAccessTime
#else
#define SET_LAST_ACCESS_AND_MOD_TIME setLastAccessAndModificationTime
#endif

if (llvm::sys::fs::SET_LAST_ACCESS_AND_MOD_TIME(FD, getTimeNow())) {
if (llvm::sys::fs::setLastAccessAndModificationTime(FD, getTimeNow())) {
error(Loc(), "Failed to set the cached file modification time: %s",
cacheFile.c_str());
fatal();
Expand Down
Loading