mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-05 09:31:03 +03:00
CMake: from LLVM 7, also copy xray-basic, xray-fdr, and xray-profiling clang runtime libraries.
This commit is contained in:
parent
070fd639b4
commit
82dccbab23
2 changed files with 57 additions and 21 deletions
|
@ -796,6 +796,11 @@ if (LDC_INSTALL_LLVM_RUNTIME_LIBS)
|
|||
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)
|
||||
endif()
|
||||
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()
|
||||
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'.")
|
||||
|
@ -809,6 +814,11 @@ if (LDC_INSTALL_LLVM_RUNTIME_LIBS)
|
|||
if(NOT (LDC_LLVM_VER LESS 600))
|
||||
copy_compilerrt_lib("${LDC_INSTALL_LLVM_RUNTIME_LIBS_OS}/libclang_rt.fuzzer-${LDC_INSTALL_LLVM_RUNTIME_LIBS_ARCH}.a" "libldc_rt.fuzzer.a" FALSE)
|
||||
endif()
|
||||
if(NOT (LDC_LLVM_VER LESS 700))
|
||||
copy_compilerrt_lib("${LDC_INSTALL_LLVM_RUNTIME_LIBS_OS}/libclang_rt.xray-basic-${LDC_INSTALL_LLVM_RUNTIME_LIBS_ARCH}.a" "libldc_rt.xray-basic.a" FALSE)
|
||||
copy_compilerrt_lib("${LDC_INSTALL_LLVM_RUNTIME_LIBS_OS}/libclang_rt.xray-fdr-${LDC_INSTALL_LLVM_RUNTIME_LIBS_ARCH}.a" "libldc_rt.xray-fdr.a" FALSE)
|
||||
copy_compilerrt_lib("${LDC_INSTALL_LLVM_RUNTIME_LIBS_OS}/libclang_rt.xray-profiling-${LDC_INSTALL_LLVM_RUNTIME_LIBS_ARCH}.a" "libldc_rt.xray-profiling.a" FALSE)
|
||||
endif()
|
||||
elseif(WIN32)
|
||||
set(compilerrt_arch_suffix "x86_64")
|
||||
if(${ptr_size} EQUAL 4)
|
||||
|
@ -821,6 +831,11 @@ if (LDC_INSTALL_LLVM_RUNTIME_LIBS)
|
|||
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)
|
||||
endif()
|
||||
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()
|
||||
|
||||
if(LDC_LLVM_VER LESS 600)
|
||||
|
|
|
@ -61,6 +61,8 @@ private:
|
|||
virtual void addCppStdlibLinkFlags(const llvm::Triple &triple);
|
||||
virtual void addProfileRuntimeLinkFlags(const llvm::Triple &triple);
|
||||
virtual void addXRayLinkFlags(const llvm::Triple &triple);
|
||||
virtual bool addWholeRTLinkFlags(llvm::StringRef baseName,
|
||||
const llvm::Triple &triple);
|
||||
|
||||
virtual void addLinker();
|
||||
virtual void addUserSwitches();
|
||||
|
@ -336,32 +338,51 @@ void ArgsBuilder::addFuzzLinkFlags(const llvm::Triple &triple) {
|
|||
// Adds all required link flags for -fxray-instrument when the xray library is
|
||||
// found.
|
||||
void ArgsBuilder::addXRayLinkFlags(const llvm::Triple &triple) {
|
||||
const auto searchPaths = getFullCompilerRTLibPathCandidates("xray", triple);
|
||||
|
||||
bool linkerDarwin = triple.isOSDarwin();
|
||||
if (!triple.isOSLinux())
|
||||
warning(Loc(), "XRay is not (fully) supported on non-Linux target OS.");
|
||||
warning(Loc(), "XRay may not be fully supported on non-Linux target OS.");
|
||||
|
||||
bool libraryFoundAndLinked = addWholeRTLinkFlags("xray", triple);
|
||||
#if LDC_LLVM_VER >= 700
|
||||
// Since LLVM 7, each XRay mode was split into its own library.
|
||||
if (libraryFoundAndLinked) {
|
||||
addWholeRTLinkFlags("xray-basic", triple);
|
||||
addWholeRTLinkFlags("xray-fdr", triple);
|
||||
}
|
||||
#else
|
||||
// Before LLVM 7, XRay requires the C++ std library (but not on Darwin).
|
||||
// Only link with the C++ stdlib when the XRay library was found.
|
||||
if (libraryFoundAndLinked && !triple.isOSDarwin())
|
||||
addCppStdlibLinkFlags(triple);
|
||||
#endif
|
||||
}
|
||||
|
||||
// Returns true if library was found and added to link flags.
|
||||
bool ArgsBuilder::addWholeRTLinkFlags(llvm::StringRef baseName,
|
||||
const llvm::Triple &triple) {
|
||||
const bool linkerDarwin = triple.isOSDarwin();
|
||||
const auto searchPaths = getFullCompilerRTLibPathCandidates(baseName, triple);
|
||||
for (const auto &filepath : searchPaths) {
|
||||
IF_LOG Logger::println("Searching runtime library: %s", filepath.c_str());
|
||||
|
||||
if (llvm::sys::fs::exists(filepath) &&
|
||||
!llvm::sys::fs::is_directory(filepath)) {
|
||||
if (!linkerDarwin)
|
||||
addLdFlag("--whole-archive");
|
||||
|
||||
IF_LOG Logger::println("Found, linking with %s",
|
||||
filepath.c_str());
|
||||
args.push_back(filepath);
|
||||
|
||||
if (!linkerDarwin)
|
||||
addLdFlag("--no-whole-archive");
|
||||
|
||||
#if LDC_LLVM_VER < 700
|
||||
// Before LLVM 7, XRay requires the C++ std library (but not on Darwin).
|
||||
// Only link with the C++ stdlib when the XRay library was found.
|
||||
if (!linkerDarwin)
|
||||
addCppStdlibLinkFlags(triple);
|
||||
#endif
|
||||
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void ArgsBuilder::addCppStdlibLinkFlags(const llvm::Triple &triple) {
|
||||
if (linkNoCpp)
|
||||
return;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue