static void addLinkSanitizerLibArgsForDarwin(const ArgList &Args, ArgStringList &Arguments, StringRef Sanitizer, const ToolChain &TC, bool shared = true) { // Sanitizer runtime libraries requires C++. Arguments.push_back("-lc++"); // Add explicit dependency on -lc++abi, as -lc++ doesn't re-export // all RTTI-related symbols that are used. Arguments.push_back("-lc++abi"); auto LibName = TC.sanitizerRuntimeLibName(Sanitizer, shared); TC.addLinkRuntimeLib(Args, Arguments, LibName); if (shared) addLinkRuntimeLibRPath(Args, Arguments, LibName, TC); }
static void addLinkSanitizerLibArgsForLinux(const ArgList &Args, ArgStringList &Arguments, StringRef Sanitizer, const ToolChain &TC) { TC.addLinkRuntimeLib(Args, Arguments, TC.sanitizerRuntimeLibName(Sanitizer)); // Code taken from // https://github.com/apple/swift-clang/blob/ab3cbe7/lib/Driver/Tools.cpp#L3264-L3276 // There's no libpthread or librt on RTEMS. if (TC.getTriple().getOS() != llvm::Triple::RTEMS) { Arguments.push_back("-lpthread"); Arguments.push_back("-lrt"); } Arguments.push_back("-lm"); // There's no libdl on FreeBSD or RTEMS. if (TC.getTriple().getOS() != llvm::Triple::FreeBSD && TC.getTriple().getOS() != llvm::Triple::RTEMS) Arguments.push_back("-ldl"); }