From: Iain Sandoe <iain@sandoe.co.uk>
To: Simon Wright <simon@pushface.org>
Cc: Arnaud Charlet <charlet@adacore.com>,
GCC Patches <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH] Fix PR ada/111909 On Darwin, determine filesystem case sensitivity at runtime
Date: Tue, 21 Nov 2023 23:13:11 +0000 [thread overview]
Message-ID: <0CB99833-18CF-4179-BE02-DC1D0684BFA1@sandoe.co.uk> (raw)
In-Reply-To: <8D91765E-9338-49E8-A8FE-345448248181@pushface.org>
Hi Simon,
Thanks for persevering - I will keep the original patch, pending some chance to
fix the earlier OS issues.
I’ll 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 <simon@pushface.org> wrote:
>
> On 21 Nov 2023, at 11:22, Iain Sandoe <iain@sandoe.co.uk> wrote:
>>
>> Hello Simon, Arno,
>>
>>> On 17 Nov 2023, at 13:43, Simon Wright <simon@pushface.org> wrote:
>>>
>>>>
>>>>> Apple’s naming is definitely confusing in this area!
>>>>>
>>>>> In current SDKs, TARGET_OS_MAC means code is being generated for a Mac OS X variant,
>>>>> which covers OSX, IOS, Watch … ; to determine which kind of device, you have to check the
>>>>> specific define for that device - OSX corresponds to macOS, i.e. laptops, desktops.
>>>>>
>>>>> In older SDKs (specifically Xcode 3, for macOS Leopard (darwin 9) as mentioned by Iain)
>>>>> TARGET_OS_MAC means code is being generated for "Mac OS", i.e. laptops, desktops as
>>>>> above; TARGET_OS_OSX is undefined (as are TARGET_OS_IOS etc).
>>>>>
>>>>> 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.
>>>>>
>>>>> If we were compiling for iOS, using a current iOS SDK as supplied with current Xcode, then
>>>>> TARGET_OS_MAC would be set to 1, TARGET_OS_OSX would be set to 0, and
>>>>> TARGET_OS_IOS would be set to 1.
>>>>
>>>> OK so then the following is sufficient for our needs:
>>>>
>>>> #elif defined (__APPLE__)
>>>> /* By default, macOS volumes are case-insensitive, iOS
>>>> volumes are case-sensitive. */
>>>> #if TARGET_OS_IOS
>>>> file_names_case_sensitive_cache = 1;
>>>> #else
>>>> file_names_case_sensitive_cache = 0;
>>>> #endif
>>>> #else /* Neither Windows nor Apple. */
>>>> file_names_case_sensitive_cache = 1;
>>>> #endif
>>>>
>>>> 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.
>>>
>>> I can’t speak for Darwin maintainers, so I’ll leave it to Iain to comment on this suggestion.
>>
>> * We are far away from having support for watchOS (32b Arm64) so I think that is a bridge
>> that can be crossed later.
>>
>> * It seems to me that the proposed solution is better matched to the defaults on macOS/iOS.
>>
>> * 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’s 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.
>>
>> 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.
>>
>> When there’s a final proposed patch, I can add it into my testing across the systems.
>>
>> Iain
>
> Herewith my proposed patch (still in thread, though the subject of the thread isn’t still appropriate):
>
> 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.
>
> 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 treated as
> case-sensitive, which is not the default case.
>
> The true default position is that macOS file systems are
> case-insensitive, iOS file systems are case-sensitive.
>
> Apple provide a header file <TargetConditionals.h> 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.
>
> gcc/ada/Changelog:
>
> 2023-11-21 Simon Wright <simon@pushface.org>
>
> * 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.
>
> Signed-off-by: Simon Wright <simon@pushface.org>
> ---
> gcc/ada/adaint.c | 15 +++++++++++----
> 1 file changed, 11 insertions(+), 4 deletions(-)
>
> 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 */
>
> #if defined (__APPLE__)
> -#include <unistd.h>
If removing unistd.h is intentional (i.e. you determined that it’s no longer
needed for Darwin), then we should make that a separate patch.
> +#include <TargetConditionals.h>
> #endif
>
> #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 = 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 = 1;
> #else
> + file_names_case_sensitive_cache = 0;
> +#endif
> +#else /* Neither Windows nor Apple. */
> file_names_case_sensitive_cache = 1;
> #endif
> }
> --
> 2.39.3 (Apple Git-145)
>
next prev parent reply other threads:[~2023-11-21 23:13 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-29 11:51 Simon Wright
2023-10-31 8:07 ` Iain Sandoe
2023-11-03 8:39 ` Arnaud Charlet
2023-11-04 17:02 ` Simon Wright
2023-11-04 23:28 ` Iain Sandoe
2023-11-06 8:36 ` Arnaud Charlet
2023-11-11 17:47 ` Simon Wright
2023-11-11 18:10 ` Iain Sandoe
2023-11-13 16:03 ` Simon Wright
2023-11-13 16:18 ` Arnaud Charlet
2023-11-16 20:56 ` Simon Wright
2023-11-17 8:37 ` Arnaud Charlet
2023-11-17 9:06 ` Simon Wright
2023-11-17 9:29 ` Arnaud Charlet
2023-11-17 12:53 ` Simon Wright
2023-11-17 13:36 ` Arnaud Charlet
2023-11-17 13:39 ` Arnaud Charlet
2023-11-17 13:43 ` Simon Wright
2023-11-21 11:22 ` Iain Sandoe
2023-11-21 20:25 ` Simon Wright
2023-11-21 23:13 ` Iain Sandoe [this message]
2023-11-22 13:54 ` Simon Wright
2023-11-22 13:55 ` Arnaud Charlet
2023-11-22 14:48 ` Iain Sandoe
2023-11-22 15:03 ` Iain Sandoe
2023-11-22 15:13 ` Simon Wright
2023-11-28 12:16 ` Simon Wright
2023-11-28 13:50 ` Marc Poulhiès
2023-11-28 16:48 ` Marc Poulhiès
2023-11-22 14:41 ` Paul Koning
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=0CB99833-18CF-4179-BE02-DC1D0684BFA1@sandoe.co.uk \
--to=iain@sandoe.co.uk \
--cc=charlet@adacore.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=simon@pushface.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).