From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp001-out.apm-internet.net (smtp001-out.apm-internet.net [85.119.248.222]) by sourceware.org (Postfix) with ESMTPS id ED9453858D33 for ; Tue, 21 Nov 2023 23:13:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org ED9453858D33 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=sandoe.co.uk Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=sandoe.co.uk ARC-Filter: OpenARC Filter v1.0.0 sourceware.org ED9453858D33 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=85.119.248.222 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700608396; cv=none; b=hfTLGQ+G90wVXZk/3cdMJ0DYY+51o7pl203NkWNj/4xk4nq673010GD75IUwsSiRt6wLxcq6+0Xyg/Ad6dsYf5o/Lt9V9kv+ovlZLkTp45vfmW6TI2E2dXq9zabS2e9N9BtBMweOVExTNSfMDbR92U6YSEPMohgeN7sCC+uDNs0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700608396; c=relaxed/simple; bh=3D7GM3x7vp0peRH8CdcuA6PHj64yyz+mQ3Ebndn5Rjs=; h=Mime-Version:Subject:From:Date:Message-Id:To; b=vOBm3oPQS4F747wrs0PO9U129tHsnJDePD6TmFMzzzW3nxai5TGl/oY6tBinYnmRPC18+v9xxRwi9ZoV4c9GWAvs1EK/QmqHAPwLOUnAKW500TSGWmMmFWVG1NyKMABSzZACFoAOMuuxWKluGF9LD4RES6oVQwGsOJGEUFn4OVc= ARC-Authentication-Results: i=1; server2.sourceware.org Received: (qmail 49513 invoked from network); 21 Nov 2023 23:13:11 -0000 X-APM-Out-ID: 17006083914951 X-APM-Authkey: 257869/1(257869/1) 10 Received: from unknown (HELO smtpclient.apple) (81.138.1.83) by smtp001.apm-internet.net with SMTP; 21 Nov 2023 23:13:11 -0000 Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.120.41.1.4\)) Subject: Re: [PATCH] Fix PR ada/111909 On Darwin, determine filesystem case sensitivity at runtime From: Iain Sandoe In-Reply-To: <8D91765E-9338-49E8-A8FE-345448248181@pushface.org> Date: Tue, 21 Nov 2023 23:13:11 +0000 Cc: Arnaud Charlet , GCC Patches Content-Transfer-Encoding: quoted-printable Message-Id: <0CB99833-18CF-4179-BE02-DC1D0684BFA1@sandoe.co.uk> References: <20231106083644.GA2141436@adacore.com> <0296D5C3-F810-4754-862C-72D7F79563EB@googlemail.com> <8324DEB5-442B-4B18-8CA8-29A96960DD14@pushface.org> <20231113161827.GA61280@adacore.com> <5397C900-1214-4DB4-ADFA-AB4C4581475F@pushface.org> <20231117083749.GB3688470@adacore.com> <91AF9F8B-7D2E-455A-96AA-02BE299E4968@pushface.org> <20231117092931.GA2219177@adacore.com> <640DEA70-FE25-41CD-A69B-B361DFC463D5@pushface.org> <20231117133610.GA2814215@adacore.com> <314257A9-5692-4938-8D68-B2AA85B5B725@sandoe.co.uk> <8D91765E-9338-49E8-A8FE-345448248181@pushface.org> To: Simon Wright X-Mailer: Apple Mail (2.3696.120.41.1.4) X-Spam-Status: No, score=-9.4 required=5.0 tests=BAYES_00,GIT_PATCH_0,KAM_COUK,KAM_DMARC_STATUS,RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE 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: Hi Simon, Thanks for persevering - I will keep the original patch, pending some = chance to fix the earlier OS issues. I=E2=80=99ll check this on OS versions with older SDKs that do not have = the TARGET_OS_XX conditionals. ----- One small nit below, Iain > On 21 Nov 2023, at 20:25, Simon Wright wrote: >=20 > On 21 Nov 2023, at 11:22, Iain Sandoe wrote: >>=20 >> Hello Simon, Arno, >>=20 >>> On 17 Nov 2023, at 13:43, Simon Wright wrote: >>>=20 >>>>=20 >>>>> Apple=E2=80=99s naming is definitely confusing in this area! >>>>>=20 >>>>> In current SDKs, TARGET_OS_MAC means code is being generated for a = Mac OS X variant,=20 >>>>> which covers OSX, IOS, Watch =E2=80=A6 ; to determine which kind = of device, you have to check the=20 >>>>> specific define for that device - OSX corresponds to macOS, i.e. = laptops, desktops. >>>>>=20 >>>>> In older SDKs (specifically Xcode 3, for macOS Leopard (darwin 9) = as mentioned by Iain)=20 >>>>> TARGET_OS_MAC means code is being generated for "Mac OS", i.e. = laptops, desktops as=20 >>>>> above; TARGET_OS_OSX is undefined (as are TARGET_OS_IOS etc). >>>>>=20 >>>>> If we are compiling for macOS, using a current macOS SDK, then = TARGET_OS_MAC is >>>>> set to 1 and TARGET_OS_OSX is set to 1.=20 >>>>>=20 >>>>> If we were compiling for iOS, using a current iOS SDK as supplied = with current Xcode, then=20 >>>>> TARGET_OS_MAC would be set to 1, TARGET_OS_OSX would be set to 0, = and=20 >>>>> TARGET_OS_IOS would be set to 1. >>>>=20 >>>> OK so then the following is sufficient for our needs: >>>>=20 >>>> #elif defined (__APPLE__) >>>> /* By default, macOS volumes are case-insensitive, iOS >>>> volumes are case-sensitive. */ >>>> #if TARGET_OS_IOS >>>> file_names_case_sensitive_cache =3D 1; >>>> #else >>>> file_names_case_sensitive_cache =3D 0; >>>> #endif >>>> #else /* Neither Windows nor Apple. */ >>>> file_names_case_sensitive_cache =3D 1; >>>> #endif >>>>=20 >>>> We want the default to be 0, and we only care about setting it to 1 = on iOS for recent >>>> SDKs, the case of an old SDK and iOS isn't interesting at this = stage, so it's fine if we set >>>> the var to 0 in this scenario. >>>=20 >>> I can=E2=80=99t speak for Darwin maintainers, so I=E2=80=99ll leave = it to Iain to comment on this suggestion. >>=20 >> * We are far away from having support for watchOS (32b Arm64) so I = think that is a bridge >> that can be crossed later. >>=20 >> * It seems to me that the proposed solution is better matched to the = defaults on macOS/iOS. >>=20 >> * It would be better to have an automatic solution for folks (like = me) who do use case- >> sensitive file systems on macOS, but we do not have the resources = right now to figure >> out what is not working on the earlier systems. I looked briefly, = and found that the libcalls >> are thin wrappers on a syscall, so that the different behaviours we = are seeing on earlier >> OS versions reflects the kernel=E2=80=99s handling of the provided = path, rather than some improvement >> in newer library functions. That suggests to me that we will need to = wrap the call in some more >> complex logic to obtain the correct response. >>=20 >> So, I think that (with a test across the range of supported OS = versions) the proposed >> solution is an incremental improvement and we should take it. >>=20 >> When there=E2=80=99s a final proposed patch, I can add it into my = testing across the systems. >>=20 >> Iain >=20 > Herewith my proposed patch (still in thread, though the subject of the = thread isn=E2=80=99t still appropriate): >=20 > In gcc/ada/adaint.c(__gnat_get_file_names_case_sensitive), the current > 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. >=20 > The associated comment is > "By default, we suppose filesystems aren't case sensitive on > Windows and Darwin (but they are on arm-darwin)." >=20 > This means that on aarch64-apple-darwin, file names are treated as > case-sensitive, which is not the default case. >=20 > The true default position is that macOS file systems are > case-insensitive, iOS file systems are case-sensitive. >=20 > Apple provide a header file which permits a > compile-time check for the compiler target (e.g. OSX vs IOS); if > TARGET_OS_IOS is defined as 1, this is a build for iOS. >=20 > gcc/ada/Changelog: >=20 > 2023-11-21 Simon Wright >=20 > * gcc/ada/adaint.c (__gnat_get_file_names_case_sensitive): > Split out the __APPLE__ check and remove the checks for __arm__, > __arm64__. > For Apple, file names are by default case-insensitive unless > TARGET_OS_IOS is set. >=20 > Signed-off-by: Simon Wright > --- > gcc/ada/adaint.c | 15 +++++++++++---- > 1 file changed, 11 insertions(+), 4 deletions(-) >=20 > diff --git a/gcc/ada/adaint.c b/gcc/ada/adaint.c > index bb4ed2607e5..0222791ed68 100644 > --- a/gcc/ada/adaint.c > +++ b/gcc/ada/adaint.c > @@ -84,7 +84,7 @@ > #endif /* VxWorks */ > =20 > #if defined (__APPLE__) > -#include If removing unistd.h is intentional (i.e. you determined that it=E2=80=99s= no longer needed for Darwin), then we should make that a separate patch. > +#include > #endif > =20 > #if defined (__hpux__) > @@ -613,11 +613,18 @@ __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; > +#elif defined (__APPLE__) > + /* By default, macOS volumes are case-insensitive, iOS > + volumes are case-sensitive. */ > +#if TARGET_OS_IOS > + file_names_case_sensitive_cache =3D 1; > #else > + file_names_case_sensitive_cache =3D 0; > +#endif > +#else /* Neither Windows nor Apple. */ > file_names_case_sensitive_cache =3D 1; > #endif > } > --=20 > 2.39.3 (Apple Git-145) >=20