From nobody Mon May 30 18:30:28 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 2C3E61B4C230; Mon, 30 May 2022 18:30:29 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4LBkVY0QY8z3HTL; Mon, 30 May 2022 18:30:29 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1653935429; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=yGUg44v9S5rhpKRPMlT9+GsbA40mCIozbUx6h+X16j8=; b=MNrvO2fkW6BbUhEBi/FmN/C898sd65C3yBLUs0z36DpOkQhsNDlItDrs2wED/qzr8RdD91 MIUSQvXJNryW4mR6nbFCGY6VyVceyPdLIdzDTNJY0F9+RJPBqoqiuvcC8cCN80oRdsYtYj +sbTrLPo85fzMqkZ29RYpuLL7N8xS5dtQoLatVBDK/FXkDyvrp8jEwzyhvAiitx6bmyMYl 91qEliwIgOZ0tyAtZUWWZMrtnTAQsW50Hhg3FT/+isAivqSk5XhmBnTa0TNOLS6V5eOSqV 9u5XCwh/9jijIgQgLz5NK+Y4hsahpD/90sBtEQiiy2vSo+B2SUgC8Qvrf23mKw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id C98751C723; Mon, 30 May 2022 18:30:28 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 24UIUSMF084089; Mon, 30 May 2022 18:30:28 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 24UIUS9r084088; Mon, 30 May 2022 18:30:28 GMT (envelope-from git) Date: Mon, 30 May 2022 18:30:28 GMT Message-Id: <202205301830.24UIUS9r084088@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Dimitry Andric Subject: git: e51efab4a4d4 - stable/13 - clang: Skip attempts to access /proc/self/fd List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dim X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: e51efab4a4d4f5916da96658e6682fd06d7d2ace Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1653935429; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=yGUg44v9S5rhpKRPMlT9+GsbA40mCIozbUx6h+X16j8=; b=dYsKE1pcRdvQ1vzrdvrNX5c6mpsNDtOnPslO6BjHHrvCJFl/0q9vg0Jp13tWZg+om9+wZA dkm5IccDc3cN6/2DUCLHHWb0CFn2DuRxNKaVL4qM81bsV540+LS3KSR2dLytLTfiSemrFM qLDQl2yPI8035rfR9sGJbXoP2JDKEAQbwTZtOIbf7Gd/8WS1FwimCMTs6Aj1gg+ltVd0ym 5sxgzNXjl4KSkJuLoJmt9B9JZiIWyK3rFG+nfEPFqAOsy5w8Ddnpj7uxqr2TFkLKUq0Xpw uMlV9ZvKSG3c8CiIRnzY0M60UblcVNP2KUEBAc97+buAXM76BewOb9fS8BsolQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1653935429; a=rsa-sha256; cv=none; b=t6CQKrKXVSEiNB3nnTZfr9TQcaGCz8gvjhd9hdynrH6CfZ63n+U189w32MtnQiLikG+MAJ VtkXuv7mObyY4odJKtQJdrd/lpC9NcUSU5UYOjA12dhSUtizxEcBMqGv1UVHt/j0HPuCSD VDG1QqMdz+NdBr+wYPv3QAn9kX1kF10zi6NtT/o7KOfK/XfSlOx1IuhHaV18cam4zOmP/1 rfgayCtt6whRXdxNhkLJ9OdiwBBKg8jE9BHQ8n+SYR+6XGJy1mw7QD9V1vTHt00dF5lIvU hASgaYVZjEAA91W7oZwPrdbyV1tr0swbP7/OTLlj52fBUpAAmXfzPez1m1zSbA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by dim: URL: https://cgit.FreeBSD.org/src/commit/?id=e51efab4a4d4f5916da96658e6682fd06d7d2ace commit e51efab4a4d4f5916da96658e6682fd06d7d2ace Author: Mateusz Guzik AuthorDate: 2022-03-27 18:01:38 +0000 Commit: Dimitry Andric CommitDate: 2022-05-30 18:27:43 +0000 clang: Skip attempts to access /proc/self/fd In contrast to Linux it does not provide entries which can be readlinked -- these are just regular files, not giving the expected outcome. That's on top of procfs not being mounted by default to begin with. Reviewed by: dim Differential Revision: https://reviews.freebsd.org/D34684 (cherry picked from commit 30ed48b0a50a062415addcac216371a55e1f6a66) --- contrib/llvm-project/llvm/lib/Support/Unix/Path.inc | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/contrib/llvm-project/llvm/lib/Support/Unix/Path.inc b/contrib/llvm-project/llvm/lib/Support/Unix/Path.inc index c37b3a54644a..8c2af5ee0f8d 100644 --- a/contrib/llvm-project/llvm/lib/Support/Unix/Path.inc +++ b/contrib/llvm-project/llvm/lib/Support/Unix/Path.inc @@ -930,7 +930,15 @@ ErrorOr directory_entry::status() const { return s; } -#if !defined(F_GETPATH) +// +// FreeBSD optionally provides /proc/self/fd, but it is incompatible with +// Linux. The thing to use is realpath. +// +#if !defined(__FreeBSD__) +#define TRY_PROC_SELF_FD +#endif + +#if !defined(F_GETPATH) && defined(TRY_PROC_SELF_FD) static bool hasProcSelfFD() { // If we have a /proc filesystem mounted, we can quickly establish the // real name of the file with readlink @@ -1117,6 +1125,7 @@ std::error_code openFileForRead(const Twine &Name, int &ResultFD, RealPath->append(Buffer, Buffer + strlen(Buffer)); #else char Buffer[PATH_MAX]; +#if defined(TRY_PROC_SELF_FD) if (hasProcSelfFD()) { char ProcPath[64]; snprintf(ProcPath, sizeof(ProcPath), "/proc/self/fd/%d", ResultFD); @@ -1124,13 +1133,16 @@ std::error_code openFileForRead(const Twine &Name, int &ResultFD, if (CharCount > 0) RealPath->append(Buffer, Buffer + CharCount); } else { +#endif SmallString<128> Storage; StringRef P = Name.toNullTerminatedStringRef(Storage); // Use ::realpath to get the real path name if (::realpath(P.begin(), Buffer) != nullptr) RealPath->append(Buffer, Buffer + strlen(Buffer)); +#if defined(TRY_PROC_SELF_FD) } +#endif #endif return std::error_code(); }