diff --git a/cmake/modules/SwiftComponents.cmake b/cmake/modules/SwiftComponents.cmake index ec56a72df7778..4a12c1974b94d 100644 --- a/cmake/modules/SwiftComponents.cmake +++ b/cmake/modules/SwiftComponents.cmake @@ -53,7 +53,6 @@ # * clang-resource-dir-symlink -- install a symlink to the Clang resource # directory (which contains builtin headers) under 'lib/swift/clang'. This is # useful when Clang and Swift are installed side-by-side. -# * llvm-resource-dir-symlink -- install a symlink to the LLVM resource directory. # * stdlib -- the Swift standard library. # * stdlib-experimental -- the Swift standard library module for experimental # APIs. @@ -67,7 +66,7 @@ # * toolchain-dev-tools -- install development tools useful in a shared toolchain # * dev -- headers and libraries required to use Swift compiler as a library. set(_SWIFT_DEFINED_COMPONENTS - "autolink-driver;compiler;clang-builtin-headers;clang-resource-dir-symlink;llvm-resource-dir-symlink;clang-builtin-headers-in-clang-resource-dir;stdlib;stdlib-experimental;swift-syntax;sdk-overlay;editor-integration;tools;testsuite-tools;toolchain-dev-tools;dev;license;sourcekit-xpc-service;sourcekit-inproc;swift-remote-mirror;swift-remote-mirror-headers") + "autolink-driver;compiler;clang-builtin-headers;clang-resource-dir-symlink;clang-builtin-headers-in-clang-resource-dir;stdlib;stdlib-experimental;swift-syntax;sdk-overlay;editor-integration;tools;testsuite-tools;toolchain-dev-tools;dev;license;sourcekit-xpc-service;sourcekit-inproc;swift-remote-mirror;swift-remote-mirror-headers") macro(swift_configure_components) # Set the SWIFT_INSTALL_COMPONENTS variable to the default value if it is not passed in via -D diff --git a/lib/Driver/ToolChains.cpp b/lib/Driver/ToolChains.cpp index ce7d0bbc6883b..eab888dd65410 100644 --- a/lib/Driver/ToolChains.cpp +++ b/lib/Driver/ToolChains.cpp @@ -1063,10 +1063,13 @@ getDarwinLibraryNameSuffixForTriple(const llvm::Triple &triple) { } static std::string -getSanitizerRuntimeLibNameForDarwin(StringRef Sanitizer, const llvm::Triple &Triple) { +getSanitizerRuntimeLibNameForDarwin(StringRef Sanitizer, + const llvm::Triple &Triple, + bool shared = true) { return (Twine("libclang_rt.") + Sanitizer + "_" - + getDarwinLibraryNameSuffixForTriple(Triple) + "_dynamic.dylib").str(); + + getDarwinLibraryNameSuffixForTriple(Triple) + + (shared ? "_dynamic.dylib" : ".a")).str(); } static std::string @@ -1141,7 +1144,10 @@ addLinkRuntimeLibForLinux(const ArgList &Args, ArgStringList &Arguments, static void addLinkSanitizerLibArgsForDarwin(const ArgList &Args, ArgStringList &Arguments, - StringRef Sanitizer, const ToolChain &TC) { + 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 @@ -1149,8 +1155,8 @@ addLinkSanitizerLibArgsForDarwin(const ArgList &Args, Arguments.push_back("-lc++abi"); addLinkRuntimeLibForDarwin(Args, Arguments, - getSanitizerRuntimeLibNameForDarwin(Sanitizer, TC.getTriple()), - /*AddRPath=*/ true, TC); + getSanitizerRuntimeLibNameForDarwin(Sanitizer, TC.getTriple(), shared), + /*AddRPath=*/ shared, TC); } static void @@ -1175,40 +1181,6 @@ addLinkSanitizerLibArgsForLinux(const ArgList &Args, Arguments.push_back("-ldl"); } -static void -addLinkFuzzerLibArgsForDarwin(const ArgList &Args, - ArgStringList &Arguments, - const ToolChain &TC) { - - // libFuzzer requires C++. - Arguments.push_back("-lc++"); - - // Link libfuzzer. - SmallString<128> Dir; - getRuntimeLibraryPath(Dir, Args, TC); - llvm::sys::path::remove_filename(Dir); - llvm::sys::path::append(Dir, "llvm", "libLLVMFuzzer.a"); - SmallString<128> P(Dir); - - Arguments.push_back(Args.MakeArgString(P)); -} - -static void -addLinkFuzzerLibArgsForLinux(const ArgList &Args, - ArgStringList &Arguments, - const ToolChain &TC) { - Arguments.push_back("-lstdc++"); - - // Link libfuzzer. - SmallString<128> Dir; - getRuntimeLibraryPath(Dir, Args, TC); - llvm::sys::path::remove_filename(Dir); - llvm::sys::path::append(Dir, "llvm", "libLLVMFuzzer.a"); - SmallString<128> P(Dir); - - Arguments.push_back(Args.MakeArgString(P)); -} - ToolChain::InvocationInfo toolchains::Darwin::constructInvocation(const LinkJobAction &job, const JobContext &context) const { @@ -1348,7 +1320,8 @@ toolchains::Darwin::constructInvocation(const LinkJobAction &job, // Only link in libFuzzer for executables. if (job.getKind() == LinkKind::Executable && (context.OI.SelectedSanitizers & SanitizerKind::Fuzzer)) - addLinkFuzzerLibArgsForDarwin(context.Args, Arguments, *this); + addLinkSanitizerLibArgsForDarwin( + context.Args, Arguments, "fuzzer", *this, /*shared=*/false); if (context.Args.hasArg(options::OPT_embed_bitcode, options::OPT_embed_bitcode_marker)) { @@ -1724,7 +1697,9 @@ toolchains::GenericUnix::constructInvocation(const LinkJobAction &job, addLinkSanitizerLibArgsForLinux(context.Args, Arguments, "tsan", *this); if (context.OI.SelectedSanitizers & SanitizerKind::Fuzzer) - addLinkFuzzerLibArgsForLinux(context.Args, Arguments, *this); + addLinkRuntimeLibForLinux(context.Args, Arguments, + getSanitizerRuntimeLibNameForLinux( + "fuzzer", this->getTriple()), *this); } } diff --git a/stdlib/public/SwiftShims/CMakeLists.txt b/stdlib/public/SwiftShims/CMakeLists.txt index 3819776f2e20e..032b677e060b2 100644 --- a/stdlib/public/SwiftShims/CMakeLists.txt +++ b/stdlib/public/SwiftShims/CMakeLists.txt @@ -156,12 +156,6 @@ swift_install_symlink_component(clang-resource-dir-symlink TARGET ../clang/${CLANG_VERSION} DESTINATION "lib/swift") -# Adding link to "llvm" at install time. -swift_install_symlink_component(llvm-resource-dir-symlink - LINK_NAME llvm - TARGET ../ - DESTINATION "lib/swift") - # Possibly install Clang headers under Clang's resource directory in case we # need to use a different version of the headers than the installed Clang. This # should be used in conjunction with clang-resource-dir-symlink. diff --git a/test/Driver/fuzzer.swift b/test/Driver/fuzzer.swift index 06e6b41ef4a41..4ab6c2a9160be 100644 --- a/test/Driver/fuzzer.swift +++ b/test/Driver/fuzzer.swift @@ -1,6 +1,6 @@ // RUN: %swiftc_driver -driver-print-jobs -sanitize=fuzzer,address %s | %FileCheck -check-prefix=LIBFUZZER %s -// LIBFUZZER: libLLVMFuzzer.a +// LIBFUZZER: libclang_rt.fuzzer @_cdecl("LLVMFuzzerTestOneInput") public func fuzzOneInput(Data: UnsafePointer, Size: CLong) -> CInt { return 0; }