[clang] [Driver] Make use of AddFilePathLibArgs() on NetBSD. (PR #71371)

Brad Smith via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 6 01:42:29 PST 2023


https://github.com/brad0 created https://github.com/llvm/llvm-project/pull/71371

This will help using lld or mold as a linker.

>From 00a5cfdd1999d9151a0775d8c2d0a8a0a05cce47 Mon Sep 17 00:00:00 2001
From: Brad Smith <brad at comstyle.com>
Date: Sun, 5 Nov 2023 23:05:29 -0500
Subject: [PATCH] [Driver] Make use of AddFilePathLibArgs() on NetBSD.

This will help using lld or mold as a linker.
---
 clang/lib/Driver/ToolChains/NetBSD.cpp | 1 +
 clang/test/Driver/netbsd.c             | 5 +++++
 2 files changed, 6 insertions(+)

diff --git a/clang/lib/Driver/ToolChains/NetBSD.cpp b/clang/lib/Driver/ToolChains/NetBSD.cpp
index cfde8d40a77ae16..90b195a007caa78 100644
--- a/clang/lib/Driver/ToolChains/NetBSD.cpp
+++ b/clang/lib/Driver/ToolChains/NetBSD.cpp
@@ -269,6 +269,7 @@ void netbsd::Linker::ConstructJob(Compilation &C, const JobAction &JA,
 
   Args.addAllArgs(CmdArgs, {options::OPT_L, options::OPT_T_Group,
                             options::OPT_s, options::OPT_t, options::OPT_r});
+  ToolChain.AddFilePathLibArgs(Args, CmdArgs);
 
   bool NeedsSanitizerDeps = addSanitizerRuntimes(ToolChain, Args, CmdArgs);
   bool NeedsXRayDeps = addXRayRuntime(ToolChain, Args, CmdArgs);
diff --git a/clang/test/Driver/netbsd.c b/clang/test/Driver/netbsd.c
index 760cba4ac4e0c9f..f900205501ee455 100644
--- a/clang/test/Driver/netbsd.c
+++ b/clang/test/Driver/netbsd.c
@@ -461,3 +461,8 @@
 // DRIVER-PASS-INCLUDES:      "-cc1" {{.*}}"-resource-dir" "[[RESOURCE:[^"]+]]"
 // DRIVER-PASS-INCLUDES-SAME: "-internal-isystem" "[[RESOURCE]]{{/|\\\\}}include"
 // DRIVER-PASS-INCLUDES-SAME: {{^}} "-internal-externc-isystem" "{{.*}}/usr/include"
+
+// Check that the driver passes the system library path.
+// RUN: %clang -### %s --target=x86_64-unknown-netbsd 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=DRIVER-PASS-LIB-PATH
+// DRIVER-PASS-LIB-PATH:  "-L/usr/lib"



More information about the cfe-commits mailing list