From nobody Sun Mar 27 18:02:28 2022 X-Original-To: dev-commits-src-main@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 19D581A328D9; Sun, 27 Mar 2022 18:02: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 4KRNvn0483z4R5m; Sun, 27 Mar 2022 18:02:29 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1648404149; 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=Zx90jyg0jy/JmFtPb50GmZenJRfau2dE9O/E1Tb/3z4=; b=hwAn5rU63lQUvXqC/PbPn1fVIf9p66orJN7CpyhOFJDfplcx8KRv9DbkQGDzRkHrdu9Vkh 3e8hNUYZh4JfWN67ZYO6qXm1avwCtaZjCeSY6hi0OO6zz8xTgqB6pKzLU2MrJh4IZ7htVH Ind+N99I0ZXUx09lb+PpVGJgJF2IyyfcJe9gzEDu2DEQjftCGVCgD8Jx6KUmFrHmhE39zw OAZ8PxWXyFoDChAqzCB2iI08miuzwUpj+A7osUi052eX3N79twZqcoFbkKXsyurSGiBGga tIoOBLi6/Evbxt7s8F0vvyFFRqGzCEmDxvod3iRw9B5qC853mAo/keDQuaJrSQ== 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 D70451A30F; Sun, 27 Mar 2022 18:02: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 22RI2SgX061000; Sun, 27 Mar 2022 18:02:28 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 22RI2SaF060999; Sun, 27 Mar 2022 18:02:28 GMT (envelope-from git) Date: Sun, 27 Mar 2022 18:02:28 GMT Message-Id: <202203271802.22RI2SaF060999@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mateusz Guzik Subject: git: 30ed48b0a50a - main - clang: Skip attempts to access /proc/self/fd List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 30ed48b0a50a062415addcac216371a55e1f6a66 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1648404149; 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=Zx90jyg0jy/JmFtPb50GmZenJRfau2dE9O/E1Tb/3z4=; b=fDoUuCM60vK/elbCXo3voUAYiYuBd5WNhf/uPZr+keGfENAgAXuuNQTp4U3qtE0/iWKP9h UfCTUWuuvhYIM/tR84JSMp8ddOwvEsTjtekLpozaVpq9lHUZ8jdORD8xTnX//wKnz6RIuK Y8u/C9FDIwwAj5QQ5PS3Yox4mO3wR95d0ptSHL8qZ6hsEZ2TrovJFDfpL397io2tlVNK3g Vwoog2OoKLr+/32Oi9vxi1nrS4lx1tbzXkCMkzyZm67srCV9jZ2S3KFODdrmfje2Qq9Qy8 8Wi7NATaaRFplEy1l34HSOdYL1pqAyVdZRTr6ndYTUqIuUkbkKoUoBhhdu8OPg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1648404149; a=rsa-sha256; cv=none; b=O9enenEZQj4A+m5Fs7Tp11mNrl7G2AkQMfQmqf56AVNCKd7X8BjSxACkRy33s6TgiKQzRB hjXBelQLmBXWPc+y5xxdRLspySsq6Zmxo3RXJC65D519BgMVkDsTutLoL2guvgbVq8s1us wHN+1j9M/i4h1RsO6ZvAdUFNdj1zKIPfvU9eDL9BP1hDzMDTNysMv+TwTID3capwzywsYh ow6U7SgYZOX7kneY6ktAXWIrsu7b8fgC6OrrZDwbWqwHIUSpN9+o4Joz89cxyezRWI+O3I 6ZfB0aPV416ATYg2ymI6LNaRYm0wq67kOxCVdRxTk7j+1qXlLpTlZgN230x8+g== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=30ed48b0a50a062415addcac216371a55e1f6a66 commit 30ed48b0a50a062415addcac216371a55e1f6a66 Author: Mateusz Guzik AuthorDate: 2022-03-27 18:01:38 +0000 Commit: Mateusz Guzik CommitDate: 2022-03-27 18:01:38 +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 --- 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(); }