Opened 9 months ago

Closed 7 months ago

#54948 closed defect (fixed)

optipng @0.7.6: error: no member named 'st_atim' in 'struct stat'

Reported by: fracai Owned by: ryandesign (Ryan Schmidt)
Priority: Normal Milestone:
Component: ports Version:
Keywords: highsierra Cc: galsondor (Scott G. Ainsworth), fracai, chrisminett (Chris Minett), phriedrich (phriedrich), szhorvat (Szabolcs Horvát), jowens (John Owens), khepler, jonasjonas (Frank Hellenkamp)
Port: optipng

Description

osys.c:515:25: error: no member named 'st_atim' in 'struct stat'
        times[0] = sbuf.st_atim;
                   ~~~~ ^
osys.c:516:25: error: no member named 'st_mtim' in 'struct stat'
        times[1] = sbuf.st_mtim;
                   ~~~~ ^
2 errors generated.
make[1]: *** [osys.o] Error 1

Looks like a similar issue occurred previously: https://sourceforge.net/p/optipng/bugs/47/

Attachments (1)

main.log (16.3 KB) - added by fracai 9 months ago.
build log

Download all attachments as: .zip

Change History (18)

Changed 9 months ago by fracai

Attachment: main.log added

build log

comment:1 Changed 9 months ago by kencu (Ken)

Looks identical or closely related to 54774.

comment:2 Changed 9 months ago by kencu (Ken)

Keywords: 10.13 removed
Owner: set to ryandesign
Status: newassigned
Summary: optipng 0.7.6 fails to build on MacOS 10.13optipng 0.7.6: error: no member named 'st_atim' in 'struct stat'

comment:3 Changed 9 months ago by ryandesign (Ryan Schmidt)

The bug has already been reported to the developers. I'll await their fix.

comment:4 Changed 9 months ago by galsondor (Scott G. Ainsworth)

Cc: galsondor added

comment:5 Changed 9 months ago by fracai

Cc: fracai added

comment:6 Changed 9 months ago by chrisminett (Chris Minett)

Cc: chrisminett added

comment:7 Changed 8 months ago by phriedrich (phriedrich)

Cc: phriedrich added

comment:8 Changed 8 months ago by szhorvat (Szabolcs Horvát)

Cc: szhorvat added

comment:9 Changed 7 months ago by jowens (John Owens)

Cc: jowens added

comment:10 Changed 7 months ago by khepler

Cc: khepler added

comment:11 Changed 7 months ago by jonasjonas (Frank Hellenkamp)

Cc: jonasjonas added

comment:12 Changed 7 months ago by phriedrich (phriedrich)

Is there an option in MacPorts to patch the source for a certain version of macOS?

Replacing lines 515 and 516 in src/optipng/osys.c with

        #if defined OSYS_DARWIN
             times[0] = sbuf.st_atimespec;
             times[1] = sbuf.st_mtimespec;
         #else
             times[0] = sbuf.st_atim;
             times[1] = sbuf.st_mtim;
         #endif

works for me, but I haven't tested this on older versions of OS X/macOS.

comment:13 in reply to:  12 Changed 7 months ago by ryandesign (Ryan Schmidt)

Replying to phriedrich:

Is there an option in MacPorts to patch the source for a certain version of macOS?

Of course. For example, to add a patch only on darwin 17 (macOS High Sierra) and later:

if {${os.platform} eq "darwin" && ${os.major} >= 17} {
    patchfiles-append something.patch
}

But older OS versions shouldn't see this code at all since they don't have the requisite OS functions, so a conditional patch shouldn't be needed.

comment:14 Changed 7 months ago by phriedrich (phriedrich)

Theoretically we also wouldn't need the check for OSYS_DARWIN here, since the patch is only applied in MacPorts.

So a patch like this would be enough:

diff -Naur optipng-0.7.6/src/optipng/osys.c optipng-0.7.6_hs/src/optipng/osys.c
--- optipng-0.7.6/src/optipng/osys.c  2014-10-05 05:51:00.000000000 +0200
+++ optipng-0.7.6_hs/src/optipng/osys.c 2017-12-09 18:31:59.000000000 +0100
@@ -512,8 +512,8 @@
     {
         struct timespec times[2];

-        times[0] = sbuf.st_atim;
-        times[1] = sbuf.st_mtim;
+        times[0] = sbuf.st_atimespec;
+        times[1] = sbuf.st_mtimespec;
         if (utimensat(AT_FDCWD, dest_path, times, 0) != 0)
             result = -1;
     }

Is this the right format?

comment:15 Changed 7 months ago by ryandesign (Ryan Schmidt)

Status: assignedaccepted
Summary: optipng 0.7.6: error: no member named 'st_atim' in 'struct stat'optipng @0.7.6: error: no member named 'st_atim' in 'struct stat'

I am working on the patch now. I will keep the operating system check, since MacPorts can theoretically be installed on non-Mac systems.

comment:16 Changed 7 months ago by phriedrich (phriedrich)

Thank you!

comment:17 Changed 7 months ago by ryandesign (Ryan Schmidt)

Resolution: fixed
Status: acceptedclosed

In f69d413bbcc4ed122933757146168c5103e6039f/macports-ports:

optipng: Fix build on High Sierra

Closes: #54948

Note: See TracTickets for help on using tickets.