Hans-Peter Nilsson <h...@bitrange.com> wrote:

> On Wed, 21 Oct 2020, Iain Sandoe wrote:
> 
>> Arnaud Charlet <char...@adacore.com> wrote:
>> 
>>>> This patch breaks bootstrap on Darwin platforms.
>>>> 
>>>> Pierre-Marie de Rodat <dero...@adacore.com> wrote:
>>>> 
>>>>> The modification file time precision now defined by OS.
>>>>> 
>>>>> Tested on x86_64-pc-linux-gnu, committed on trunk
>>>>> 
>>>>> gcc/ada/
>>>>> 
>>>>>   * adaint.c (__gnat_file_time): New routine.
>>>>>   (__gnat_copy_attribs): Copy timestamps in nanoseconds.
>>>>>   * libgnat/a-direct.adb (C_Modification_Time): Bind to
>>>>>   __gnat_file_time.
>>>>>   (Modification_Time): Call to C_Modification_Time.<patch.diff>
>>>> 
>>>> #if defined(st_mtime)
>>>> 
>>>> is a necessary test - but the fields in the stat structure on Darwin
>>>> platforms are
>>>> named st_{a,c,m}timespec rather than the Linux st_{a,c,m}tim.
>>> 
>>> What about instead putting above extern long long __gnat_file_time the
>>> following:
>>> 
>>> #if __APPLE__
>>> #define st_mtim st_mtimespec
>>> #define st_atim st_atimespec
>>> #endif
>>> 
>>> To avoid having the two (nested) #if __APPLE__ and keep the code easier
>>> to follow?
>> 
>> works for me (the test patch was drafted quickly to allow bootstrap to
>> continue)
>> - I can amend the patch and (re-)test more widely.
>> 
>> Iain
> 
> For future reference, TRT for this kind of problem is to
> autoconf for the right struct field name, using AC_CHECK_MEMBER
> or AC_CHECK_MEMBERS (then use e.g. #if HAVE_STAT_ST_MTIM / #if
> HAVE_STAT_ST_MTIMESPEC, definitely not #if __APPLE__).

I’m not diasgreeing with your technical comment; now I am in a difficult 
position.
I don’t have resources at the moment to make the changes you suggest, and
Darwin is bootstrap-broken (at least for Ada).

so .. the attached is a workaround - now I’ve resolved the second bootstrap 
issue
on powerpc-darwin, I was able to test it more widely.

I have *not* applied the patch, pending a “proper” solution at some unspecified
time in the future .. 

Iain


======

Darwin has timeval entries for file access and modification
times but they are named differently from those on Linux (and
presumably everywhere else, since no other platform has
reported an issue).
---
 gcc/ada/adaint.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/gcc/ada/adaint.c b/gcc/ada/adaint.c
index b7406a03c31..560f3529442 100644
--- a/gcc/ada/adaint.c
+++ b/gcc/ada/adaint.c
@@ -237,6 +237,11 @@ UINT __gnat_current_ccs_encoding;
 
 #include "adaint.h"
 
+#if defined (__APPLE__) && defined (st_mtime)
+#define st_atim st_atimespec
+#define st_mtim st_mtimespec
+#endif
+
 /* Define symbols O_BINARY and O_TEXT as harmless zeroes if they are not
    defined in the current system. On DOS-like systems these flags control
    whether the file is opened/created in text-translation mode (CR/LF in
-- 
2.24.1



Reply via email to