From patchwork Sun Oct 29 11:51:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Wright X-Patchwork-Id: 159362 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:d641:0:b0:403:3b70:6f57 with SMTP id cy1csp1644630vqb; Sun, 29 Oct 2023 04:51:56 -0700 (PDT) X-Google-Smtp-Source: AGHT+IELYCpiImXh5Uckp+DsiYlCBcuH5WN4d5moCu7SZ0xZ7fVAIg0EkOdXMn0Zh3IcG4H9RRWW X-Received: by 2002:a05:622a:1106:b0:41e:287d:f56a with SMTP id e6-20020a05622a110600b0041e287df56amr8756378qty.47.1698580316696; Sun, 29 Oct 2023 04:51:56 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1698580316; cv=pass; d=google.com; s=arc-20160816; b=CQjI842ODFN03+P86GPYY9+F19J7S0Urp9EnHzf3HLBS86zY3JBoOr3vPo0NaiVckK spT+awy9fwYGVI6IoQxn8LECV/Wvq1Y8jNg3N2rbbgBQLL7NM1sZQykE0C4ndxom1HxC KlCe3K0HGg7S3Zy4o7RiX3/P2eZEGDCsvDjeXW6tROUSGXBVra+worR0J3SrNE9NHLD3 YCpxdJO/TEB5hzsV8vZ+VDJ75hQHBsHlcBrFzzrl10unJWAlKzUrOIYQdG9cljYGlj5b zDdS5flShGx2Dr56cAlkaMPFzKr4msblaQIQX9TwXzlcEekYEKGX602DzKh+Z5LNUjdW t+tw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:to:date:message-id:subject :mime-version:content-transfer-encoding:from:arc-filter:dmarc-filter :delivered-to; bh=EeB0EWn4KdVEiMuao1NRRJtBhV0WNzYu+DZEJnimmhw=; fh=hPrbWPhweUx4V0GV9uXJqbyAzg2ABmTz7kczrAQqMmM=; b=zAwRwCadYn9G8oGCvXsH7Nffdtn0hFfosjkImKFtvzOx1yV4IFvLOZ37vKsz4ERp/h mdU8QgmilESNCxlqpUQwnQzoOphe/2bF8LuYV887GXlHdDUcIq8oqgwpB/9Cw6hc+G1W MeiMreWAv/ESc6Ptb2R2G8lgeNyqLPXOCiNQB/9mwOMositxXguri0wmT+jup4C3rrYz XngU3DecLFoRoAoG5nLFdR/ROJs3LSagoa0AFminyVOtGdLhM2YslAJUDvdTGGuXlsjl w1PfmgIvyEh+pmi5RmsKgS6NZdXsLsRiiP25tXLyEseALE7uPpBU4HPBfE4O0ZHrn/B6 DLNg== ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id k12-20020ac8474c000000b0041e5f97a708si1191141qtp.248.2023.10.29.04.51.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Oct 2023 04:51:56 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 751FB38618A9 for ; Sun, 29 Oct 2023 11:51:56 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp.hosts.co.uk (smtp.hosts.co.uk [85.233.160.19]) by sourceware.org (Postfix) with ESMTPS id 097E83858C66 for ; Sun, 29 Oct 2023 11:51:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 097E83858C66 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=pushface.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=pushface.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 097E83858C66 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=85.233.160.19 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698580294; cv=none; b=XFgZmIzUQfEqtCjsgDmvf0neSMNtaCU2EGpoRbe2DOJ9z0sNP65xh+V1W3cXNoe/p0ogvTAL/6ufdhs53SE0bAbU/TpkY5CmVBbKKfw9A4YY5cioOvKj8O2DUOBqFswZA0bt0CCrntxfyl6Qz1euFA8s9/aqomTN2KWBr/FabRs= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698580294; c=relaxed/simple; bh=30eQ9qJDnyiBQB86n7tHDjPOz36g4Xo/9F0mLVre2nk=; h=From:Mime-Version:Subject:Message-Id:Date:To; b=FQvhAPAysS38w0a3ZRJRSpRqNqOx3S6Z2O+1X/6wH2GWp738yQwmObGdM4PY3n7CooRxHBL22X8AkrtJIkpEQrps/yOSQzNjKq1YAhjD6MqN8xjpiU5Vcs13D2vjQ3F2Aw9aJ+Tz4N7VqaAJo5my53Tnk/xvAytPXgcMgF/YSik= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from host-80-43-120-208.as13285.net ([80.43.120.208] helo=smtpclient.apple) by smtp.hosts.co.uk with esmtpa (Exim) (envelope-from ) id 1qx4KJ-000C8u-4X for gcc-patches@gcc.gnu.org; Sun, 29 Oct 2023 11:51:31 +0000 From: Simon Wright Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3774.100.2.1.4\)) Subject: [PATCH] Fix PR ada/111909 On Darwin, determine filesystem case sensitivity at runtime Message-Id: <47D204E3-3595-4A4A-A0C6-13AA83E95B13@pushface.org> Date: Sun, 29 Oct 2023 11:51:20 +0000 To: gcc-patches@gcc.gnu.org X-Mailer: Apple Mail (2.3774.100.2.1.4) X-Spam-Status: No, score=-10.5 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781090554312392043 X-GMAIL-MSGID: 1781090554312392043 This change affects only Ada. In gcc/ada/adaint.c(__gnat_get_file_names_case_sensitive), the assumption for __APPLE__ is that file names are case-insensitive unless __arm__ or __arm64__ are defined, in which case file names are declared case-sensitive. The associated comment is "By default, we suppose filesystems aren't case sensitive on Windows and Darwin (but they are on arm-darwin)." This means that on aarch64-apple-darwin, file names are declared case-sensitive, which is not normally the case (but users can set up case-sensitive volumes). It's understood that GCC does not currently support iOS/tvOS/watchOS, so we assume macOS. Bootstrapped on x86_64-apple-darwin with languages c,c++,ada and regression tested (check-gnat). Also, tested with the example from PR ada/81114, extracted into 4 volumes (APFS, APFS-case-sensitive, HFS, HFS-case-sensitive; the example code built successfully on the case-sensitive volumes. Setting GNAT_FILE_NAME_CASE_SENSITIVE successfully overrode the choices made by the new code. gcc/ada/Changelog: 2023-10-29 Simon Wright PR ada/111909 * gcc/ada/adaint.c (__gnat_get_file_names_case_sensitive): Remove the checks for __arm__, __arm64__. Split out the check for __APPLE__; remove the checks for __arm__, __arm64__, and use getattrlist(2) to determine whether the current working directory is on a case-sensitive filesystem. Signed-off-by: Simon Wright Signed-off-by: Simon Wright Signed-off-by: Simon Wright Signed-off-by: Simon Wright --- gcc/ada/adaint.c | 46 ++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 42 insertions(+), 4 deletions(-) diff --git a/gcc/ada/adaint.c b/gcc/ada/adaint.c index 2a193efc002..43d166824b0 100644 --- a/gcc/ada/adaint.c +++ b/gcc/ada/adaint.c @@ -85,6 +85,7 @@ #if defined (__APPLE__) #include +#include #endif #if defined (__hpux__) @@ -613,11 +614,48 @@ __gnat_get_file_names_case_sensitive (void) else { /* By default, we suppose filesystems aren't case sensitive on - Windows and Darwin (but they are on arm-darwin). */ -#if defined (WINNT) || defined (__DJGPP__) \ - || (defined (__APPLE__) && !(defined (__arm__) || defined (__arm64__))) + Windows or DOS. */ +#if defined (WINNT) || defined (__DJGPP__) file_names_case_sensitive_cache = 0; -#else +#elif defined (__APPLE__) + /* Determine whether the current volume is case-sensitive. */ + { + /* Formulate a query for the volume capabilities. */ + struct attrlist attrList + = {ATTR_BIT_MAP_COUNT, + 0, /* reserved. */ + 0, /* commonattr. */ + ATTR_VOL_INFO | ATTR_VOL_CAPABILITIES, /* volattr. */ + 0, /* dirattr. */ + 0, /* fileattr. */ + 0 /* forkattr. */ + }; + + /* A buffer to contain just the volume capabilities. */ + struct returnBuf { + u_int32_t length; + vol_capabilities_attr_t caps; + } __attribute__ ((aligned (4), packed)) retBuf; + + /* Default to case-insensitive. */ + file_names_case_sensitive_cache = 0; + + /* Query the current working directory. */ + if (getattrlist (".", + &attrList, + &retBuf, + sizeof (retBuf), + 0) == 0) + /* The call succeeded. */ + if ((retBuf.caps.valid[VOL_CAPABILITIES_FORMAT] + & VOL_CAP_FMT_CASE_SENSITIVE)) + /* The volume could be case-sensitive. */ + if (retBuf.caps.capabilities[VOL_CAPABILITIES_FORMAT] + & VOL_CAP_FMT_CASE_SENSITIVE) + /* The volume is case-sensitive. */ + file_names_case_sensitive_cache = 1; + } +#else /* Neither Windows nor Apple. */ file_names_case_sensitive_cache = 1; #endif }