[MacPorts] #65582: util-linux @2.38_1 does not build on PPC Tiger, Mac OS X 10.4.11, because of "Undefined symbols: "_timersub", referenced from: _print_stats in hardlink-hardlink.o"

MacPorts noreply at macports.org
Wed Aug 3 16:49:51 UTC 2022


#65582: util-linux @2.38_1 does not build on PPC Tiger, Mac OS X 10.4.11, because
of "Undefined symbols:   "_timersub", referenced from:   _print_stats in
hardlink-hardlink.o"
-------------------------+--------------------
  Reporter:  ballapete   |      Owner:  (none)
      Type:  defect      |     Status:  new
  Priority:  Normal      |  Milestone:
 Component:  ports       |    Version:  2.7.2
Resolution:              |   Keywords:  tiger
      Port:  util-linux  |
-------------------------+--------------------

Comment (by ballapete):

 Leopard's sys/time.h has (well guarded):

 {{{
   128   #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
   ...
   172   #define timersub(tvp, uvp, vvp)
 \
   173           do {
 \
   174                   (vvp)->tv_sec = (tvp)->tv_sec - (uvp)->tv_sec;
 \
   175                   (vvp)->tv_usec = (tvp)->tv_usec - (uvp)->tv_usec;
 \
   176                   if ((vvp)->tv_usec < 0) {
 \
   177                           (vvp)->tv_sec--;
 \
   178                           (vvp)->tv_usec += 1000000;
 \
   179                   }
 \
   180           } while (0)
   ...
   208   #endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */
 }}}

 The pre-compiled output has:

 {{{
         569:#define _DARWIN_C_SOURCE 1
         577:#define _POSIX_C_SOURCE 200112L
         725:#undef _POSIX_C_SOURCE
         726:#define _POSIX_C_SOURCE 200112L
 }}}

 so that line #128 gives TRUE. Tiger's sys/time.h has (simple guarded):

 {{{
   146   #ifndef _POSIX_C_SOURCE
   147   #define FD_COPY(f, t)   bcopy(f, t, sizeof(*(f)))
   148   #endif  /* !_POSIX_C_SOURCE */
   149
   150   #endif  /* !_FD_SET */
   151
   152
   153   #ifndef _POSIX_C_SOURCE
   154   /*
   155    * Structure defined by POSIX.4 to be like a timeval.
   156    */
   157   #ifndef _TIMESPEC
   158   #define _TIMESPEC
   159   struct timespec {
   160           time_t  tv_sec;         /* seconds */
   161           long    tv_nsec;        /* and nanoseconds */
   162   };
   163
   164   #endif
   165
   166
   167
   168
   169   #define TIMEVAL_TO_TIMESPEC(tv, ts) {
 \
   170           (ts)->tv_sec = (tv)->tv_sec;
 \
   171           (ts)->tv_nsec = (tv)->tv_usec * 1000;
 \
   172   }
   173   #define TIMESPEC_TO_TIMEVAL(tv, ts) {
 \
   174           (tv)->tv_sec = (ts)->tv_sec;
 \
   175           (tv)->tv_usec = (ts)->tv_nsec / 1000;
 \
   176   }
   177
   178   struct timezone {
   179           int     tz_minuteswest; /* minutes west of Greenwich */
   180           int     tz_dsttime;     /* type of dst correction */
   181   };
   182   #define DST_NONE        0       /* not on dst */
   183   #define DST_USA         1       /* USA style dst */
   184   #define DST_AUST        2       /* Australian style dst */
   185   #define DST_WET         3       /* Western European dst */
   186   #define DST_MET         4       /* Middle European dst */
   187   #define DST_EET         5       /* Eastern European dst */
   188   #define DST_CAN         6       /* Canada */
   189
   190   /* Operations on timevals. */
   191   #define timerclear(tvp)         (tvp)->tv_sec = (tvp)->tv_usec = 0
   192   #define timerisset(tvp)         ((tvp)->tv_sec || (tvp)->tv_usec)
   193   #define timercmp(tvp, uvp, cmp)
 \
   194           (((tvp)->tv_sec == (uvp)->tv_sec) ?
 \
   195               ((tvp)->tv_usec cmp (uvp)->tv_usec) :
 \
   196               ((tvp)->tv_sec cmp (uvp)->tv_sec))
   197   #define timeradd(tvp, uvp, vvp)
 \
   198           do {
 \
   199                   (vvp)->tv_sec = (tvp)->tv_sec + (uvp)->tv_sec;
 \
   200                   (vvp)->tv_usec = (tvp)->tv_usec + (uvp)->tv_usec;
 \
   201                   if ((vvp)->tv_usec >= 1000000) {
 \
   202                           (vvp)->tv_sec++;
 \
   203                           (vvp)->tv_usec -= 1000000;
 \
   204                   }
 \
   205           } while (0)
   206   #define timersub(tvp, uvp, vvp)
 \
   207           do {
 \
   208                   (vvp)->tv_sec = (tvp)->tv_sec - (uvp)->tv_sec;
 \
   209                   (vvp)->tv_usec = (tvp)->tv_usec - (uvp)->tv_usec;
 \
   210                   if ((vvp)->tv_usec < 0) {
 \
   211                           (vvp)->tv_sec--;
 \
   212                           (vvp)->tv_usec += 1000000;
 \
   213                   }
 \
   214           } while (0)
   215
   216   #define timevalcmp(l, r, cmp)   timercmp(l, r, cmp) /* freebsd */
   217
   218   /*
   219    * Getkerninfo clock information structure
   220    */
   221   struct clockinfo {
   222           int     hz;             /* clock frequency */
   223           int     tick;           /* micro-seconds per hz tick */
   224           int     tickadj;        /* clock skew rate for adjtime()
 */
   225           int     stathz;         /* statistics clock frequency */
   226           int     profhz;         /* profiling clock frequency */
   227   };
   228   #endif /* ! _POSIX_C_SOURCE */
   229
   230
   231
   232   __BEGIN_DECLS
   233
   234   #ifndef _POSIX_C_SOURCE
   235   #include <time.h>
   236
   237   int     adjtime(const struct timeval *, struct timeval *);
   238   int     futimes(int, const struct timeval *);
   239   int     settimeofday(const struct timeval *, const struct timezone
 *);
   240   #endif /* ! _POSIX_C_SOURCE */
 }}}

 and the pre-compiled output has:

 {{{
         563:#define _DARWIN_C_SOURCE 1
         571:#define _POSIX_C_SOURCE 200112L
         671:#undef _POSIX_C_SOURCE
         672:#define _POSIX_C_SOURCE 200112L
 }}}

 On Leopard "/usr/include/sys/time.h" is first include on line #1682, so
 both _DARWIN_C_SOURCE and _POSIX_C_SOURCE should be defined and everything
 is fine. On Tiger it happens on line #1476, and here _POSIX_C_SOURCE is
 defined and so nothing is taken off Tiger's C header file. `misc-
 utils/hardlink.c` starts with:

 {{{
    26   #define _POSIX_C_SOURCE 200112L /* POSIX functions */
    27   #define _XOPEN_SOURCE      600  /* nftw() */
    28
    29   #include <sys/types.h>          /* stat */
    30   #include <sys/stat.h>           /* stat */
    31   #include <sys/time.h>           /* getrlimit, getrusage */
    32   #include <sys/resource.h>       /* getrlimit, getrusage */
    33   #include <fcntl.h>              /* posix_fadvise */
    34   #include <ftw.h>                /* ftw */
    35   #include <search.h>             /* tsearch() and friends */
    36   #include <signal.h>             /* SIG*, sigaction */
    37   #include <getopt.h>             /* getopt_long() */
    38   #include <ctype.h>              /* tolower() */
    39   #include <sys/ioctl.h>
 }}}

 So the fix on Tiger should be to `#undef _POSIX_C_SOURCE` before line #31
 and to `#define _POSIX_C_SOURCE 200112L` after line #31 – which I'll
 probably try a few hours later…

-- 
Ticket URL: <https://trac.macports.org/ticket/65582#comment:11>
MacPorts <https://www.macports.org/>
Ports system for macOS


More information about the macports-tickets mailing list