Hi Simon, (please cc me on Darwin-related patches)
> On 29 Oct 2023, at 11:51, Simon Wright <si...@pushface.org> wrote: > > 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. This does not yet work on at least Darwin17 and Darwin9, even though the ‘getattrlist()` call and the `VOL_CAP_FMT_CASE_SENSITIVE` should exist on both. So we need to figure out why the current code is not working (so, not yet OK from a Darwin perspective). thanks Iain > > gcc/ada/Changelog: > > 2023-10-29 Simon Wright <si...@pushface.org> > > 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 <si...@pushface.org> > --- > 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 <unistd.h> > +#include <sys/attr.h> > #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 > } > -- > 2.39.3 (Apple Git-145) >