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

Posix: Make LDC_INSTALL_LTOPLUGIN & LDC_INSTALL_LLVM_RUNTIME_LIBS default to ON if LLVM is linked statically #3673

Merged
merged 7 commits into from
Feb 21, 2021
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
2 changes: 0 additions & 2 deletions .azure-pipelines/1-posix-setup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ steps:
curl -L -o clang.tar.xz https://github.com/llvm/llvm-project/releases/download/llvmorg-$CLANG_VERSION/clang+llvm-$CLANG_VERSION-x86_64-linux-gnu-ubuntu-16.04.tar.xz
mkdir clang
tar -xf clang.tar.xz --strip 1 -C clang
# Use ld.gold per default, so that LTO is tested
sudo update-alternatives --install /usr/bin/ld ld /usr/bin/ld.gold 99
fi
# Install lit
curl -OL https://bootstrap.pypa.io/2.7/get-pip.py
Expand Down
2 changes: 1 addition & 1 deletion .azure-pipelines/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ steps:
set INSTALL_DIR=%CD%/install
mkdir build
cd build
cmake -G Ninja %BUILD_SOURCESDIRECTORY% -DCMAKE_C_COMPILER:PATH=clang-cl.exe -DCMAKE_CXX_COMPILER:PATH=clang-cl.exe -DCMAKE_BUILD_TYPE=Release %EXTRA_CMAKE_FLAGS% -DCMAKE_INSTALL_PREFIX=%INSTALL_DIR% -DINCLUDE_INSTALL_DIR=%INSTALL_DIR%/import -DLLVM_ROOT_DIR=%CD%/../llvm -DD_COMPILER=%CD%/../bootstrap-ldc/bin/ldmd2
cmake -G Ninja %BUILD_SOURCESDIRECTORY% -DCMAKE_C_COMPILER:PATH=clang-cl.exe -DCMAKE_CXX_COMPILER:PATH=clang-cl.exe -DCMAKE_BUILD_TYPE=Release -DLLVM_ROOT_DIR=%CD%/../llvm -DD_COMPILER=%CD%/../bootstrap-ldc/bin/ldmd2 -DCMAKE_INSTALL_PREFIX=%INSTALL_DIR% -DINCLUDE_INSTALL_DIR=%INSTALL_DIR%/import %EXTRA_CMAKE_FLAGS%
ninja -j4 all ldc2-unittest all-test-runners || exit /b
bin\ldc2 --version
displayName: Build LDC & LDC D unittests & defaultlib unittest runners
Expand Down
6 changes: 2 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ commonSteps: &commonSteps
llvm-dev zlib1g-dev libclang-common-$LIBCLANG_COMMON_VERSION-dev \
$libcurl_pkg curl gdb python tzdata unzip zip \
$EXTRA_APT_PACKAGES
# Use ld.gold per default, so that LTO is tested
update-alternatives --install /usr/bin/ld ld /usr/bin/ld.gold 99
else
# Download & extract CMake
curl -L -o cmake.tar.gz https://github.com/Kitware/CMake/releases/download/v3.19.4/cmake-3.19.4-macos-universal.tar.gz
Expand Down Expand Up @@ -114,7 +112,7 @@ jobs:
- CI_OS: linux
- LIBCLANG_COMMON_VERSION: "6.0"
- HOST_LDC_VERSION: 1.24.0
- EXTRA_CMAKE_FLAGS: "-DMULTILIB=ON -DRT_SUPPORT_SANITIZERS=ON -DBUILD_LTO_LIBS=ON -DLDC_INSTALL_LTOPLUGIN=ON -DLDC_INSTALL_LLVM_RUNTIME_LIBS=ON"
- EXTRA_CMAKE_FLAGS: "-DMULTILIB=ON -DRT_SUPPORT_SANITIZERS=ON -DBUILD_LTO_LIBS=ON"
Ubuntu-20.04-sharedLibsOnly-gdmd:
<<: *commonSteps
docker:
Expand All @@ -125,7 +123,7 @@ jobs:
- LIBCLANG_COMMON_VERSION: "10"
- EXTRA_APT_PACKAGES: gdmd
- HOST_LDC_VERSION: 1.24.0
- EXTRA_CMAKE_FLAGS: "-DBUILD_SHARED_LIBS=ON -DBUILD_LTO_LIBS=ON -DLDC_INSTALL_LTOPLUGIN=ON -DLDC_INSTALL_LLVM_RUNTIME_LIBS=ON -DD_COMPILER=gdmd -DLDC_LINK_MANUALLY=ON"
- EXTRA_CMAKE_FLAGS: "-DBUILD_SHARED_LIBS=ON -DBUILD_LTO_LIBS=ON -DD_COMPILER=gdmd -DLDC_LINK_MANUALLY=ON"
macOS-x64:
<<: *commonSteps
macos:
Expand Down
8 changes: 3 additions & 5 deletions .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,6 @@ install_ubuntu_prerequisites_template: &INSTALL_UBUNTU_PREREQUISITES_TEMPLATE
llvm-dev zlib1g-dev libclang-common-$LIBCLANG_COMMON_VERSION-dev \
$libcurl_pkg curl gdb python tzdata unzip zip \
$EXTRA_APT_PACKAGES
# Use ld.gold per default, so that LTO is tested
update-alternatives --install /usr/bin/ld ld /usr/bin/ld.gold 99
# Download & extract host LDC
curl --max-time 300 --retry 3 -L -o ldc2.tar.xz https://github.com/ldc-developers/ldc/releases/download/v$HOST_LDC_VERSION/ldc2-$HOST_LDC_VERSION-linux-x86_64.tar.xz
mkdir host-ldc
Expand Down Expand Up @@ -117,7 +115,7 @@ task:
environment:
CI_OS: linux
LIBCLANG_COMMON_VERSION: "6.0"
EXTRA_CMAKE_FLAGS: "-DMULTILIB=ON -DRT_SUPPORT_SANITIZERS=ON -DBUILD_LTO_LIBS=ON -DLDC_INSTALL_LTOPLUGIN=ON -DLDC_INSTALL_LLVM_RUNTIME_LIBS=ON"
EXTRA_CMAKE_FLAGS: "-DMULTILIB=ON -DRT_SUPPORT_SANITIZERS=ON -DBUILD_LTO_LIBS=ON"
PARALLELISM: 8
<< : *INSTALL_UBUNTU_PREREQUISITES_TEMPLATE
<< : *COMMON_STEPS_TEMPLATE
Expand All @@ -133,7 +131,7 @@ task:
CI_OS: linux
LIBCLANG_COMMON_VERSION: "11"
EXTRA_APT_PACKAGES: "gdmd"
EXTRA_CMAKE_FLAGS: "-DBUILD_SHARED_LIBS=ON -DBUILD_LTO_LIBS=ON -DLDC_INSTALL_LTOPLUGIN=ON -DLDC_INSTALL_LLVM_RUNTIME_LIBS=ON -DD_COMPILER=gdmd -DLDC_LINK_MANUALLY=ON"
EXTRA_CMAKE_FLAGS: "-DBUILD_SHARED_LIBS=ON -DBUILD_LTO_LIBS=ON -DD_COMPILER=gdmd -DLDC_LINK_MANUALLY=ON"
PARALLELISM: 8
# for gdmd:
LANG: C.UTF-8
Expand Down Expand Up @@ -169,7 +167,7 @@ task:
timeout_in: 60m
environment:
CI_OS: freebsd
EXTRA_CMAKE_FLAGS: -DBUILD_LTO_LIBS=ON -DLDC_INSTALL_LTOPLUGIN=ON -DLDC_INSTALL_LLVM_RUNTIME_LIBS=ON -DLDC_INSTALL_LLVM_RUNTIME_LIBS_OS=freebsd -DD_COMPILER_FLAGS="-flto=full -defaultlib=phobos2-ldc-lto,druntime-ldc-lto" -DEXTRA_CXXFLAGS=-flto=full
EXTRA_CMAKE_FLAGS: -DBUILD_LTO_LIBS=ON -DD_COMPILER_FLAGS="-flto=full -defaultlib=phobos2-ldc-lto,druntime-ldc-lto" -DEXTRA_CXXFLAGS=-flto=full
PARALLELISM: 4
GITHUB_TOKEN: ENCRYPTED[0955bd48c8d4e5391446fc0149d0719ad0b63df27ec9e6c180a5730a5b10dc7f28f09d1383423db158d21380ee2b022a]
# use clang from the `llvm` ports package to be installed, incl. lld support for .deplibs (`pragma(lib, "execinfo")`)
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/supported_llvm_versions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,6 @@ jobs:
cmake -G Ninja . \
-DCMAKE_BUILD_TYPE=Release \
-DLLVM_ROOT_DIR=$PWD/llvm \
-DLDC_INSTALL_LTOPLUGIN=ON \
-DLDC_INSTALL_LLVM_RUNTIME_LIBS=ON \
-DLDC_LINK_MANUALLY=OFF \
${{ matrix.cmake_opts }}
ninja -j2 all ldc2-unittest all-test-runners
Expand Down
4 changes: 1 addition & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ addons:
- gdb
- ninja-build

# Download & extract prebuilt vanilla LLVM if not in cache
# Download & extract prebuilt LLVM if not in cache
before_install:
- nproc
- if [ "$TRAVIS_OS_NAME" = "linux" ]; then free; fi
Expand All @@ -51,8 +51,6 @@ script:
cmake -G Ninja . \
-DCMAKE_BUILD_TYPE=Release \
-DLLVM_ROOT_DIR=$LLVM_ROOT_DIR \
-DLDC_INSTALL_LTOPLUGIN=ON \
-DLDC_INSTALL_LLVM_RUNTIME_LIBS=ON \
-DLDC_LINK_MANUALLY=OFF \
$OPTS
# Build LDC & LDC D unittests & defaultlib unittest runners
Expand Down
26 changes: 14 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,10 @@ append("-DLDC_LLVM_VER=${LDC_LLVM_VER}" LDC_CXXFLAGS)
append("\"-DLDC_LIBDIR_SUFFIX=R\\\"(${LIB_SUFFIX})\\\"\"" LDC_CXXFLAGS)
append("-DLDC_HOST_${D_COMPILER_ID}=1" LDC_CXXFLAGS)
append("-DLDC_HOST_FE_VER=${D_COMPILER_FE_VERSION}" LDC_CXXFLAGS)
# If the LLVM is shared, add its lib dir to the hardcoded list used for library lookups.
if(LLVM_IS_SHARED)
append("\"-DLDC_LLVM_LIBDIR=R\\\"(${LLVM_LIBRARY_DIRS})\\\"\"" LDC_CXXFLAGS)
endif()

#
# LLD integration (requires headers & libs)
Expand Down Expand Up @@ -632,7 +636,11 @@ if(LDC_ENABLE_PLUGINS)
elseif(UNIX)
# For plugin support, we need to link with --export-dynamic on Unix.
# Make sure the linker supports --export-dynamic (on Solaris it is not supported and also not needed).
set(CMAKE_REQUIRED_QUIET_BAK ${CMAKE_REQUIRED_QUIET})
set(CMAKE_REQUIRED_QUIET ON) # suppress status messages
CHECK_LINK_FLAG("--export-dynamic" LINKER_ACCEPTS_EXPORT_DYNAMIC_FLAG)
set(CMAKE_REQUIRED_QUIET ${CMAKE_REQUIRED_QUIET_BAK})

if(LINKER_ACCEPTS_EXPORT_DYNAMIC_FLAG)
set(LDC_LINKERFLAG_LIST "${LDC_LINKERFLAG_LIST};-Wl,--export-dynamic")
endif()
Expand Down Expand Up @@ -715,10 +723,10 @@ endfunction()
#
# Locate LLVM's LTO binary and use it
#
if(APPLE)
set(LDC_INSTALL_LTOPLUGIN_DEFAULT ON)
else()
if(WIN32 OR LLVM_IS_SHARED)
set(LDC_INSTALL_LTOPLUGIN_DEFAULT OFF)
else()
set(LDC_INSTALL_LTOPLUGIN_DEFAULT ON)
endif()
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)
Expand All @@ -744,10 +752,10 @@ endif()
# Locate ASan and other LLVM compiler-rt libraries, and copy them to our lib folder
# Location is LLVM_LIBRARY_DIRS/clang/<version>/lib/<OS>/ , for example LLVM_LIBRARY_DIRS/clang/4.0.0/lib/darwin/
#
if(APPLE OR WIN32)
set(LDC_INSTALL_LLVM_RUNTIME_LIBS_DEFAULT ON)
else()
if(LLVM_IS_SHARED)
set(LDC_INSTALL_LLVM_RUNTIME_LIBS_DEFAULT OFF)
else()
set(LDC_INSTALL_LLVM_RUNTIME_LIBS_DEFAULT ON)
endif()
set(LDC_INSTALL_LLVM_RUNTIME_LIBS ${LDC_INSTALL_LLVM_RUNTIME_LIBS_DEFAULT} CACHE BOOL "Copy/install LLVM compiler-rt libraries (ASan, libFuzzer, ...) from LLVM/Clang into LDC lib dir when available.")
function(copy_compilerrt_lib llvm_lib_name ldc_lib_name fixup_dylib)
Expand Down Expand Up @@ -804,12 +812,6 @@ if (LDC_INSTALL_LLVM_RUNTIME_LIBS)
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)
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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is XRay still not available on Windows?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, sadly not, at least not up to & including v11; I haven't checked 12 yet.

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()
endif()

Expand Down
45 changes: 37 additions & 8 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,18 @@ jobs:
x64:
MODEL: 64
ARCH: x64
EXTRA_CMAKE_FLAGS: -DBUILD_LTO_LIBS=ON -DD_COMPILER_FLAGS="-O -flto=full -defaultlib=phobos2-ldc-lto,druntime-ldc-lto" -DEXTRA_CXXFLAGS=-flto=full
EXTRA_CMAKE_FLAGS: >
-DBUILD_LTO_LIBS=ON
-DD_COMPILER_FLAGS="-O -flto=full -defaultlib=phobos2-ldc-lto,druntime-ldc-lto"
-DEXTRA_CXXFLAGS=-flto=full
x86:
MODEL: 32
ARCH: x86
# Undefined symbol errors with FullLTO; ThinLTO works.
EXTRA_CMAKE_FLAGS: -DBUILD_LTO_LIBS=ON -DD_COMPILER_FLAGS="-O -flto=thin -defaultlib=phobos2-ldc-lto,druntime-ldc-lto" -DEXTRA_CXXFLAGS=-flto=thin
EXTRA_CMAKE_FLAGS: >
-DBUILD_LTO_LIBS=ON
-DD_COMPILER_FLAGS="-O -flto=thin -defaultlib=phobos2-ldc-lto,druntime-ldc-lto"
-DEXTRA_CXXFLAGS=-flto=thin
# Let CMake configure 64-bit clang-cl for 32-bit code emission.
CFLAGS: -m32
CXXFLAGS: -m32
Expand Down Expand Up @@ -60,8 +66,15 @@ jobs:
# To improve portability of the generated binaries, link the C++ standard library statically.
# Also don't use relax relocations for the C(++) parts of the default libraries in order to
# support older user binutils (e.g., Ubuntu 14.04).
BOOTSTRAP_CMAKE_FLAGS: -DBUILD_LTO_LIBS=ON -DLDC_INSTALL_LTOPLUGIN=ON
EXTRA_CMAKE_FLAGS: -DMULTILIB=ON -DBUILD_LTO_LIBS=ON -DCMAKE_EXE_LINKER_FLAGS=-static-libstdc++ -DJITRT_EXTRA_LDFLAGS=-static-libstdc++ -DRT_CFLAGS=-Wa,-mrelax-relocations=no -DLDC_INSTALL_LTOPLUGIN=ON -DLDC_INSTALL_LLVM_RUNTIME_LIBS=ON -DD_COMPILER_FLAGS="-O -flto=full -defaultlib=phobos2-ldc-lto,druntime-ldc-lto" -DEXTRA_CXXFLAGS=-flto=full
BOOTSTRAP_CMAKE_FLAGS: -DBUILD_LTO_LIBS=ON
EXTRA_CMAKE_FLAGS: >
-DMULTILIB=ON
-DBUILD_LTO_LIBS=ON
-DCMAKE_EXE_LINKER_FLAGS=-static-libstdc++
-DJITRT_EXTRA_LDFLAGS=-static-libstdc++
-DRT_CFLAGS=-Wa,-mrelax-relocations=no
-DD_COMPILER_FLAGS="-O -flto=full -defaultlib=phobos2-ldc-lto,druntime-ldc-lto"
-DEXTRA_CXXFLAGS=-flto=full
steps:
- template: .azure-pipelines/1-posix-setup.yml
- template: .azure-pipelines/2-posix-build_native.yml
Expand Down Expand Up @@ -94,7 +107,10 @@ jobs:
CI_OS: osx
ARCH: x86_64
BOOTSTRAP_CMAKE_FLAGS: -DBUILD_LTO_LIBS=ON
EXTRA_CMAKE_FLAGS: -DBUILD_LTO_LIBS=ON -DD_COMPILER_FLAGS="-O -flto=full -defaultlib=phobos2-ldc-lto,druntime-ldc-lto" -DEXTRA_CXXFLAGS=-flto=full
EXTRA_CMAKE_FLAGS: >
-DBUILD_LTO_LIBS=ON
-DD_COMPILER_FLAGS="-O -flto=full -defaultlib=phobos2-ldc-lto,druntime-ldc-lto"
-DEXTRA_CXXFLAGS=-flto=full
MACOSX_DEPLOYMENT_TARGET: 10.9
IOS_DEPLOYMENT_TARGET: 12.0
steps:
Expand All @@ -121,7 +137,10 @@ jobs:
variables:
CI_OS: osx
ARCH: arm64
EXTRA_CMAKE_FLAGS: -DBUILD_LTO_LIBS=ON -DD_COMPILER_FLAGS="-O -flto=full -defaultlib=phobos2-ldc-lto,druntime-ldc-lto" -DEXTRA_CXXFLAGS=-flto=full
EXTRA_CMAKE_FLAGS: >
-DBUILD_LTO_LIBS=ON
-DD_COMPILER_FLAGS="-O -flto=full -defaultlib=phobos2-ldc-lto,druntime-ldc-lto"
-DEXTRA_CXXFLAGS=-flto=full
EXTRA_CMAKE_FLAGS_CROSS: -DCMAKE_OSX_ARCHITECTURES=arm64
MACOSX_DEPLOYMENT_TARGET: 11.0
IOS_DEPLOYMENT_TARGET: 12.0
Expand All @@ -142,11 +161,21 @@ jobs:
matrix:
armv7a:
ARCH: armv7a
EXTRA_CMAKE_FLAGS_CROSS: -DANDROID_ABI=armeabi-v7a -DANDROID_NATIVE_API_LEVEL=21 -DANDROID_STL=c++_static -DCMAKE_CROSSCOMPILING=True
EXTRA_CMAKE_FLAGS_CROSS: >
-DANDROID_ABI=armeabi-v7a
-DANDROID_NATIVE_API_LEVEL=21
-DANDROID_STL=c++_static
-DCMAKE_CROSSCOMPILING=True
ANDROID_X86_ABI: x86
aarch64:
ARCH: aarch64
EXTRA_CMAKE_FLAGS_CROSS: -DANDROID_ABI=arm64-v8a -DANDROID_NATIVE_API_LEVEL=21 -DANDROID_STL=c++_static -DCMAKE_CROSSCOMPILING=True
EXTRA_CMAKE_FLAGS_CROSS: >
-DANDROID_ABI=arm64-v8a
-DANDROID_NATIVE_API_LEVEL=21
-DANDROID_STL=c++_static
-DCMAKE_CROSSCOMPILING=True
-DLDC_INSTALL_LLVM_RUNTIME_LIBS_OS=android
-DLDC_INSTALL_LLVM_RUNTIME_LIBS_ARCH=aarch64-android
ANDROID_X86_ABI: x86_64
steps:
- template: .azure-pipelines/1-posix-setup.yml
Expand Down
10 changes: 10 additions & 0 deletions cmake/Modules/FindLLVM.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
# The following variables are defined:
# LLVM_FOUND - true if LLVM was found
# LLVM_CXXFLAGS - C++ compiler flags for files that include LLVM headers.
# LLVM_ENABLE_ASSERTIONS - Whether LLVM was built with enabled assertions (ON/OFF).
# LLVM_INCLUDE_DIRS - Directory containing LLVM include files.
# LLVM_IS_SHARED - Whether LLVM is going to be linked dynamically (ON) or statically (OFF).
# LLVM_LDFLAGS - Linker flags to add when linking against LLVM
# (includes -LLLVM_LIBRARY_DIRS).
# LLVM_LIBRARIES - Full paths to the library files to link against.
Expand All @@ -16,6 +18,7 @@
# X86 for x86_64 and i686 hosts.
# LLVM_ROOT_DIR - The root directory of the LLVM installation.
# llvm-config is searched for in ${LLVM_ROOT_DIR}/bin.
# LLVM_TARGETS_TO_BUILD - List of built LLVM targets.
# LLVM_VERSION_MAJOR - Major version of LLVM.
# LLVM_VERSION_MINOR - Minor version of LLVM.
# LLVM_VERSION_STRING - Full LLVM version string (e.g. 6.0.0svn).
Expand Down Expand Up @@ -122,6 +125,13 @@ 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}")

llvm_set(SHARED_MODE shared-mode)
if(LLVM_SHARED_MODE STREQUAL "shared")
set(LLVM_IS_SHARED ON)
else()
set(LLVM_IS_SHARED OFF)
endif()

llvm_set(LDFLAGS ldflags)
llvm_set(SYSTEM_LIBS system-libs)
string(REPLACE "\n" " " LLVM_LDFLAGS "${LLVM_LDFLAGS} ${LLVM_SYSTEM_LIBS}")
Expand Down
18 changes: 17 additions & 1 deletion driver/linker-gcc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ std::string getLTOGoldPluginPath() {
exe_path::prependLibDir("LLVMgold-ldc.so"),
// Perhaps the user copied the plugin to LDC's lib dir.
exe_path::prependLibDir("LLVMgold.so"),
#ifdef LDC_LLVM_LIBDIR
LDC_LLVM_LIBDIR "/LLVMgold.so",
#endif
#if __LP64__
"/usr/local/lib64/LLVMgold.so",
#endif
Expand Down Expand Up @@ -162,6 +165,12 @@ std::string getLTOdylibPath() {
if (llvm::sys::fs::exists(searchPath))
return searchPath;

#ifdef LDC_LLVM_LIBDIR
searchPath = LDC_LLVM_LIBDIR "/libLTO.dylib";
if (llvm::sys::fs::exists(searchPath))
return searchPath;
#endif

return "";
}
}
Expand Down Expand Up @@ -247,14 +256,21 @@ std::string getRelativeClangCompilerRTLibPath(const llvm::Twine &name,

void appendFullLibPathCandidates(std::vector<std::string> &paths,
const llvm::Twine &filename) {
llvm::SmallString<128> candidate;
for (const char *dir : ConfigFile::instance.libDirs()) {
llvm::SmallString<128> candidate(dir);
candidate = dir;
llvm::sys::path::append(candidate, filename);
paths.emplace_back(candidate.data(), candidate.size());
}

// for backwards compatibility
paths.push_back(exe_path::prependLibDir(filename));

#ifdef LDC_LLVM_LIBDIR
candidate = LDC_LLVM_LIBDIR;
llvm::sys::path::append(candidate, filename);
paths.emplace_back(candidate.data(), candidate.size());
#endif
}

// Returns candidates of full paths to a compiler-rt lib.
Expand Down
2 changes: 1 addition & 1 deletion shippable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ env:
matrix:
- LLVM_VERSION=11.0.1
HOST_LDC_VERSION=1.24.0
EXTRA_CMAKE_FLAGS="-DBUILD_LTO_LIBS=ON -DCMAKE_EXE_LINKER_FLAGS=-static-libstdc++ -DJITRT_EXTRA_LDFLAGS=-static-libstdc++ -DLDC_INSTALL_LTOPLUGIN=ON -DLDC_INSTALL_LLVM_RUNTIME_LIBS=ON -DLDC_INSTALL_LLVM_RUNTIME_LIBS_ARCH=aarch64"
EXTRA_CMAKE_FLAGS="-DBUILD_LTO_LIBS=ON -DCMAKE_EXE_LINKER_FLAGS=-static-libstdc++ -DJITRT_EXTRA_LDFLAGS=-static-libstdc++ -DLDC_INSTALL_LLVM_RUNTIME_LIBS_ARCH=aarch64"

build:
ci:
Expand Down
12 changes: 2 additions & 10 deletions tests/PGO/lit.local.cfg
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
import os
import platform
import re

# Add "PGO_RT" feature if the runtime library is available
for file in os.listdir(config.ldc2_lib_dir):
m = re.match('.*profile.*', file)
if m is not None:
config.available_features.add('PGO_RT')
continue
# Add "PGO_RT" feature, assuming the `profile` compiler-rt library is available
config.available_features.add('PGO_RT')

if (config.llvm_version >= 700):
config.substitutions.append( ('%allow-deprecated-dag-overlap ', '-allow-deprecated-dag-overlap ') )
Expand Down
11 changes: 3 additions & 8 deletions tests/instrument/lit.local.cfg
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
import os
import platform
import re

# Add "XRay_RT" feature if the runtime library is available
for file in os.listdir(config.ldc2_lib_dir):
m = re.match('.*xray.*', file)
if m is not None:
config.available_features.add('XRay_RT')
continue
# Add "XRay_RT" feature on non-Windows, assuming the compiler-rt libraries are available
if (platform.system() != 'Windows'):
config.available_features.add('XRay_RT')
1 change: 1 addition & 0 deletions tests/linking/thinlto_modulecdtors.d
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// ThinLTO: Test that module ctors/dtors are called

// REQUIRES: LTO
// UNSUPPORTED: FreeBSD

// RUN: %ldc -flto=thin -O3 -run %s | FileCheck %s

Expand Down
1 change: 1 addition & 0 deletions tests/linking/thinlto_modulecdtors_2.d
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// REQUIRES: LTO
// UNSUPPORTED: FreeBSD

// RUN: %ldc -flto=thin -O3 %S/inputs/thinlto_ctor.d -run %s | FileCheck --check-prefix=EXECUTE %s

Expand Down
Loading