diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp --- a/clang/lib/Driver/ToolChains/CommonArgs.cpp +++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp @@ -838,8 +838,8 @@ TC.getTriple().isOSNetBSD() || TC.getTriple().isOSOpenBSD()) CmdArgs.push_back("-lexecinfo"); - // There is no libresolv on Android. - if (!TC.getTriple().isAndroid()) + // There is no libresolv on Android or FreeBSD. + if (!TC.getTriple().isAndroid() && !TC.getTriple().isOSFreeBSD()) CmdArgs.push_back("-lresolv"); } diff --git a/clang/test/Driver/sanitizer-ld.c b/clang/test/Driver/sanitizer-ld.c --- a/clang/test/Driver/sanitizer-ld.c +++ b/clang/test/Driver/sanitizer-ld.c @@ -107,7 +107,6 @@ // CHECK-ASAN-FREEBSD: "--export-dynamic" // CHECK-ASAN-FREEBSD: "-lpthread" // CHECK-ASAN-FREEBSD: "-lrt" -// CHECK-ASAN-FREEBSD: "-lresolv" // RUN: %clang -### %s 2>&1 \ // RUN: --target=i386-unknown-freebsd -fuse-ld=ld -fsanitize=address \