From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable 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 List-Id: 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 --- 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 @@ =20 #if defined (__APPLE__) #include +#include #endif =20 #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 =3D 0; -#else +#elif defined (__APPLE__) + /* Determine whether the current volume is case-sensitive. */ + { + /* Formulate a query for the volume capabilities. */ + struct attrlist attrList + =3D {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 =3D 0; + + /* Query the current working directory. */ + if (getattrlist (".", + &attrList, + &retBuf, + sizeof (retBuf), + 0) =3D=3D 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 =3D 1; + } +#else /* Neither Windows nor Apple. */ file_names_case_sensitive_cache =3D 1; #endif } --=20 2.39.3 (Apple Git-145)