#65582 closed defect (fixed)

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"

Reported by: ballapete (Peter "Pete" Dyballa) Owned by: kencu (Ken)
Priority: Normal Milestone:
Component: ports Version: 2.7.2
Keywords: tiger Cc: kurthindenburg (Kurt Hindenburg), ryandesign (Ryan Carsten Schmidt), markmentovai (Mark Mentovai), cooljeanius (Eric Gallager)
Port: util-linux

Description

libtool: link: /opt/local/bin/gcc-apple-4.2 -fsigned-char -fno-common -Wall -Wextra -Wformat-security -Wimplicit-function-declaration -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wno-missing-field-initializers -Wpointer-arith -Wredundant-decls -Wsign-compare -Wstrict-prototypes -Wunused-parameter -Wunused-variable -Werror=sequence-point -pipe -Os -I/opt/local/include/LegacySupport -arch ppc -Wl,-headerpad_max_install_names -arch ppc -o hardlink misc-utils/hardlink-hardlink.o lib/hardlink-monotonic.o lib/hardlink-fileeq.o -Wl,-framework -Wl,CoreFoundation  -L/opt/local/lib /opt/local/lib/libintl.dylib ./.libs/libcommon.a -lMacportsLegacySupport
Undefined symbols:
  "_timersub", referenced from:
      _print_stats in hardlink-hardlink.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
make: *** [hardlink] Error 1

Attachments (4)

main.log (146.6 KB) - added by ballapete (Peter "Pete" Dyballa) 21 months ago.
Main.log from PPC Tiger, Mac OS X 10.4.11
hardlink-Tiger.cpp (168.7 KB) - added by ballapete (Peter "Pete" Dyballa) 21 months ago.
Pre-compiled hardlink.c file from PPC Tiger, Mac OS X 10.4.11
hardlink-Leopard.cpp (206.1 KB) - added by ballapete (Peter "Pete" Dyballa) 21 months ago.
Pre-compiled hardlink.c file from PPC Leopard, Mac OS X 10.5.8
patch-for-timersub-macro.diff (523 bytes) - added by ballapete (Peter "Pete" Dyballa) 21 months ago.
Patch for Mac OS X 10.4, Tiger, to make use of timersub() macro instead of a function by the same name

Download all attachments as: .zip

Change History (25)

Changed 21 months ago by ballapete (Peter "Pete" Dyballa)

Attachment: main.log added

Main.log from PPC Tiger, Mac OS X 10.4.11

comment:1 Changed 21 months ago by ryandesign (Ryan Carsten Schmidt)

Cc: ryandesign added

comment:2 Changed 21 months ago by ryandesign (Ryan Carsten Schmidt)

Cc: kurthindenburg markmentovai added; khindenburg@… removed

Yes, and this is a problem since getopt was replaced by util-linux so now ports that depended on getopt that used to build on Tiger don't build anymore.

comment:3 Changed 21 months ago by markmentovai (Mark Mentovai)

:info:build misc-utils/hardlink.c: In function 'print_stats':
:info:build misc-utils/hardlink.c:343: warning: implicit declaration of function 'timersub'
:info:build misc-utils/hardlink.c:343: warning: nested extern declaration of 'timersub'

That’s a problem because timersub is a macro, not a function. It seems like someone’s missing an #include of <sys/time.h>.

There are other -Wimplicit-function-declaration violations in this file too: vasprintf, strncasecmp. But those are functions, not macros, so no linker error.

comment:4 in reply to:  3 Changed 21 months ago by ballapete (Peter "Pete" Dyballa)

Replying to markmentovai:

That’s a problem because timersub is a macro, not a function. It seems like someone’s missing an #include of <sys/time.h>.

On PPC Mac OS X 10.5.8, Leopard, the port built, on PPC Mac OS X 10.4.11, it did not. There must be more…

comment:5 Changed 21 months ago by markmentovai (Mark Mentovai)

On PPC Mac OS X 10.5.8, Leopard, the port built, on PPC Mac OS X 10.4.11, it did not. There must be more…

Not really. On 10.5, another header that is #included must be bringing in <sys/time.h>.

Can you try introducing a patch to add that #include?

comment:6 in reply to:  5 Changed 21 months ago by ballapete (Peter "Pete" Dyballa)

Replying to markmentovai:

Can you try introducing a patch to add that #include?

Yes, I'll try to find the cause and see whether a patch can be applied!

comment:7 Changed 21 months ago by ballapete (Peter "Pete" Dyballa)

Building the port on the two different platforms shows quite a few differences already in the beginning. On Tiger -D__DARWIN_UNIX03 is used, configure detects the functioning compiler switch -Wformat-security – cause can be that on Leopard the system's /usr/bin/gcc-4.2 (version 4.2.1) gets used while on Tiger it's the augmented /opt/local/bin/gcc-apple-4.2 (version 4.2.4). Then the C header files are included in different order:

Compiling on PPC Tiger (Mac OS X 10.4.11)                                                                       | Compiling on PPC Leoprad (Mac OS X 10.5.8)
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
/opt/local/bin/gcc-apple-4.2 -DHAVE_CONFIG_H -I.  -include config.h -I./include                                 | /usr/bin/gcc-4.2 -DHAVE_CONFIG_H -I.  -include config.h -I./include
 -DLOCALEDIR=\"/opt/local/share/locale\" -D_PATH_RUNSTATEDIR=\"/opt/local/var/run\"                             |  -DLOCALEDIR=\"/opt/local/share/locale\" -D_PATH_RUNSTATEDIR=\"/opt/local/var/run\"
 -D_PATH_SYSCONFSTATICDIR=\"/opt/local/lib\"   -I/opt/local/include -D__DARWIN_UNIX03                           |  -D_PATH_SYSCONFSTATICDIR=\"/opt/local/lib\"   -I/opt/local/include
 -I/opt/local/include/LegacySupport -fsigned-char -fno-common -Wall -Wextra -Wformat-security                   |  -I/opt/local/include/LegacySupport -fsigned-char -fno-common -Wall -Wextra
 -Wimplicit-function-declaration -Wmissing-declarations -Wmissing-prototypes -Wnested-externs                   |  -Wimplicit-function-declaration -Wmissing-declarations -Wmissing-prototypes -Wnested-externs
 -Wno-missing-field-initializers -Wpointer-arith -Wredundant-decls -Wsign-compare -Wstrict-prototypes           |  -Wno-missing-field-initializers -Wpointer-arith -Wredundant-decls -Wsign-compare -Wstrict-prototypes
 -Wunused-parameter -Wunused-variable -Werror=sequence-point -pipe -Os -H -I/opt/local/include/LegacySupport    |  -Wunused-parameter -Wunused-variable -Werror=sequence-point -pipe -Os -H -I/opt/local/include/LegacySupport
 -arch ppc -MT misc-utils/hardlink-hardlink.o -MD -MP -MF misc-utils/.deps/hardlink-hardlink.Tpo -c             |  -arch ppc -MT misc-utils/hardlink-hardlink.o -MD -MP -MF misc-utils/.deps/hardlink-hardlink.Tpo -c
 -o misc-utils/hardlink-hardlink.o `test -f 'misc-utils/hardlink.c' || echo './'`misc-utils/hardlink.c          |  -o misc-utils/hardlink-hardlink.o `test -f 'misc-utils/hardlink.c' || echo './'`misc-utils/hardlink.c
                                                                                                                |
. /opt/local/include/LegacySupport/sys/types.h                                                                  |
.. /usr/include/sys/types.h                                                                                     | . /usr/include/sys/types.h
... /usr/include/sys/appleapiopts.h                                                                             | .. /usr/include/sys/appleapiopts.h
... /usr/include/sys/cdefs.h                                                                                    | .. /usr/include/sys/cdefs.h
... /usr/include/machine/types.h                                                                                | .. /usr/include/machine/types.h
.... /usr/include/ppc/types.h                                                                                   | ... /usr/include/ppc/types.h
..... /usr/include/ppc/_types.h                                                                                 | .... /usr/include/ppc/_types.h
... /usr/include/sys/_types.h                                                                                   | .. /usr/include/sys/_types.h
.... /usr/include/machine/_types.h                                                                              | ... /usr/include/machine/_types.h
... /usr/include/machine/endian.h                                                                               | .. /usr/include/machine/endian.h
.... /usr/include/ppc/endian.h                                                                                  | ... /usr/include/ppc/endian.h
                                                                                                                | .... /usr/include/sys/_endian.h
                                                                                                                | .. /usr/include/sys/_structs.h
. /opt/local/include/LegacySupport/sys/stat.h                                                                   | . /opt/local/include/LegacySupport/sys/stat.h
.. /opt/local/include/LegacySupport/MacportsLegacySupport.h                                                     | .. /opt/local/include/LegacySupport/MacportsLegacySupport.h
.. /usr/include/sys/stat.h                                                                                      | .. /usr/include/sys/stat.h
                                                                                                                | ... /usr/include/sys/_structs.h
. /opt/local/include/LegacySupport/sys/time.h                                                                   | . /opt/local/include/LegacySupport/sys/time.h
.. /usr/include/sys/time.h                                                                                      | .. /usr/include/sys/time.h
                                                                                                                | ... /usr/include/sys/_structs.h
                                                                                                                | ... /opt/local/include/LegacySupport/time.h
                                                                                                                | .... /opt/local/include/LegacySupport/MacportsLegacySupport.h
                                                                                                                | .... /usr/include/time.h
                                                                                                                | ..... /usr/include/_types.h
                                                                                                                | ..... /usr/include/_structs.h
                                                                                                                | ...... /usr/include/sys/_structs.h
                                                                                                                | ... /usr/include/sys/_select.h
. /usr/include/sys/resource.h                                                                                   | . /usr/include/sys/resource.h
                                                                                                                | .. /usr/include/sys/_structs.h
. /usr/include/fcntl.h                                                                                          | . /usr/include/fcntl.h
.. /opt/local/include/LegacySupport/sys/fcntl.h                                                                 | .. /opt/local/include/LegacySupport/sys/fcntl.h
... /usr/include/sys/fcntl.h                                                                                    | ... /usr/include/sys/fcntl.h
. /usr/include/ftw.h                                                                                            | . /usr/include/ftw.h
. /usr/include/search.h                                                                                         | . /usr/include/search.h
.. /usr/include/_types.h                                                                                        |
. /usr/include/signal.h                                                                                         | . /usr/include/signal.h
.. /usr/include/sys/signal.h                                                                                    | .. /usr/include/sys/signal.h
... /usr/include/machine/signal.h                                                                               | ... /usr/include/machine/signal.h
.... /usr/include/ppc/signal.h                                                                                  | .... /usr/include/ppc/signal.h
                                                                                                                | ..... /usr/include/ppc/_structs.h
                                                                                                                | ... /usr/include/sys/_structs.h
                                                                                                                | .... /usr/include/machine/_structs.h
                                                                                                                | ..... /usr/include/ppc/_structs.h
                                                                                                                | ...... /usr/include/mach/ppc/_structs.h
. /usr/include/getopt.h                                                                                         | . /usr/include/getopt.h
.. /opt/local/include/LegacySupport/unistd.h                                                                    | .. /opt/local/include/LegacySupport/unistd.h
... /opt/local/include/LegacySupport/MacportsLegacySupport.h                                                    |
... /usr/include/unistd.h                                                                                       | ... /usr/include/unistd.h
.... /opt/local/include/LegacySupport/sys/unistd.h                                                              | .... /opt/local/include/LegacySupport/sys/unistd.h
..... /usr/include/sys/unistd.h                                                                                 | ..... /usr/include/sys/unistd.h
..... /opt/local/lib/apple-gcc42/gcc/powerpc-apple-darwin8/4.2.4/include/stdint.h                               | ..... /usr/lib/gcc/powerpc-apple-darwin9/4.2.1/include/stdint.h
                                                                                                                | .... /usr/include/sys/select.h
                                                                                                                | ..... /usr/include/sys/_structs.h
. /usr/include/ctype.h                                                                                          | . /usr/include/ctype.h
.. /usr/include/runetype.h                                                                                      | .. /usr/include/runetype.h
. /usr/include/sys/ioctl.h                                                                                      | . /usr/include/sys/ioctl.h
.. /usr/include/sys/ttycom.h                                                                                    | .. /usr/include/sys/ttycom.h
... /usr/include/sys/ioccom.h                                                                                   | ... /usr/include/sys/ioccom.h
.. /usr/include/sys/filio.h                                                                                     | .. /usr/include/sys/filio.h
.. /usr/include/sys/sockio.h                                                                                    | .. /usr/include/sys/sockio.h
. ./include/nls.h                                                                                               | . ./include/nls.h
.. /usr/include/locale.h                                                                                        | .. /usr/include/locale.h
... /usr/include/_locale.h                                                                                      | ... /usr/include/_locale.h
.. /opt/local/include/libintl.h                                                                                 | .. /opt/local/include/libintl.h
... /usr/include/xlocale.h                                                                                      | ... /usr/include/xlocale.h
.... /usr/include/_xlocale.h                                                                                    | .... /usr/include/_xlocale.h
.... /usr/include/xlocale/_ctype.h                                                                              | .... /usr/include/xlocale/_ctype.h
                                                                                                                | .... /usr/include/xlocale/_time.h
.. /usr/include/langinfo.h                                                                                      | .. /usr/include/langinfo.h
... /usr/include/xlocale/_langinfo.h                                                                            | ... /usr/include/xlocale/_langinfo.h
. ./include/c.h                                                                                                 | . ./include/c.h
.. /opt/local/lib/apple-gcc42/gcc/powerpc-apple-darwin8/4.2.4/include/limits.h                                  | .. /usr/lib/gcc/powerpc-apple-darwin9/4.2.1/include/limits.h
... /opt/local/lib/apple-gcc42/gcc/powerpc-apple-darwin8/4.2.4/include/syslimits.h                              | ... /usr/lib/gcc/powerpc-apple-darwin9/4.2.1/include/syslimits.h
... /usr/include/limits.h                                                                                       | ... /usr/include/limits.h
.... /usr/include/machine/limits.h                                                                              | .... /usr/include/machine/limits.h
..... /usr/include/ppc/limits.h                                                                                 | ..... /usr/include/ppc/limits.h
...... /usr/include/ppc/_limits.h                                                                               | ...... /usr/include/ppc/_limits.h
.... /usr/include/sys/syslimits.h                                                                               | .... /usr/include/sys/syslimits.h
.. /opt/local/lib/apple-gcc42/gcc/powerpc-apple-darwin8/4.2.4/include/stddef.h                                  | .. /usr/lib/gcc/powerpc-apple-darwin9/4.2.1/include/stddef.h
.. /opt/local/include/LegacySupport/stdio.h                                                                     | .. /opt/local/include/LegacySupport/stdio.h
... /usr/include/stdio.h                                                                                        | ... /usr/include/stdio.h
.... /usr/include/xlocale/_stdio.h                                                                              | .... /usr/include/xlocale/_stdio.h
.. /opt/local/lib/apple-gcc42/gcc/powerpc-apple-darwin8/4.2.4/include/stdarg.h                                  | .. /usr/lib/gcc/powerpc-apple-darwin9/4.2.1/include/stdarg.h
.. /opt/local/include/LegacySupport/stdlib.h                                                                    | .. /opt/local/include/LegacySupport/stdlib.h
... /usr/include/stdlib.h                                                                                       | ... /usr/include/stdlib.h
                                                                                                                | .... /usr/include/available.h
.... /usr/include/sys/wait.h                                                                                    | .... /usr/include/sys/wait.h
                                                                                                                | .... /usr/include/alloca.h
.... /usr/include/xlocale/_stdlib.h                                                                             | .... /usr/include/xlocale/_stdlib.h
.. /opt/local/include/LegacySupport/string.h                                                                    | .. /opt/local/include/LegacySupport/string.h
... /usr/include/string.h                                                                                       | ... /usr/include/string.h
.... /usr/include/xlocale/_string.h                                                                             | .... /usr/include/xlocale/_string.h
.. /usr/include/errno.h                                                                                         | .. /usr/include/errno.h
... /usr/include/sys/errno.h                                                                                    | ... /usr/include/sys/errno.h
.. /opt/local/include/LegacySupport/sys/types.h                                                                 |
.. /usr/include/grp.h                                                                                           | .. /usr/include/grp.h
.. /usr/include/assert.h                                                                                        | .. /usr/include/assert.h
.. /usr/include/err.h                                                                                           | .. /usr/include/err.h
.. /usr/include/fcntl.h                                                                                         | .. /usr/include/fcntl.h
.. /opt/local/include/LegacySupport/time.h                                                                      |
... /usr/include/time.h                                                                                         |
.... /usr/include/machine/_limits.h                                                                             |
.... /usr/include/xlocale/_time.h                                                                               |
. ./include/xalloc.h                                                                                            | . ./include/xalloc.h
.. ./include/c.h                                                                                                | .. ./include/c.h
In file included from misc-utils/hardlink.c:51:                                                                 |
./include/xalloc.h: In function 'xasprintf':                                                                    |
./include/xalloc.h:104: warning: implicit declaration of function 'vasprintf'                                   |
./include/xalloc.h:104: warning: nested extern declaration of 'vasprintf'                                       |
. ./include/strutils.h                                                                                          | . ./include/strutils.h
.. /usr/include/inttypes.h                                                                                      | .. /usr/include/inttypes.h
... /usr/include/xlocale/_inttypes.h                                                                            | ... /usr/include/xlocale/_inttypes.h
.. /opt/local/include/LegacySupport/sys/types.h                                                                 |
.. /usr/include/errno.h                                                                                         | .. /usr/include/errno.h
In file included from misc-utils/hardlink.c:52:                                                                 |
./include/strutils.h: In function 'startswith_no_case':                                                         |
./include/strutils.h:242: warning: implicit declaration of function 'strncasecmp'                               |
. ./include/monotonic.h                                                                                         | . ./include/monotonic.h
. ./include/optutils.h                                                                                          | . ./include/optutils.h
.. /usr/include/assert.h                                                                                        | .. /usr/include/assert.h
.. ./include/nls.h                                                                                              | .. ./include/nls.h
.. ./include/cctype.h                                                                                           | .. ./include/cctype.h
. ./include/fileeq.h                                                                                            | . ./include/fileeq.h
.. /opt/local/lib/apple-gcc42/gcc/powerpc-apple-darwin8/4.2.4/include/stdbool.h                                 | .. /usr/lib/gcc/powerpc-apple-darwin9/4.2.1/include/stdbool.h
. ./include/statfs_magic.h                                                                                      | . ./include/statfs_magic.h
. /usr/include/regex.h                                                                                          | . /usr/include/regex.h
misc-utils/hardlink.c: In function 'print_stats':                                                               |
misc-utils/hardlink.c:343: warning: implicit declaration of function 'timersub'                                 |
misc-utils/hardlink.c:343: warning: nested extern declaration of 'timersub'                                     |
misc-utils/hardlink.c: In function 'file_xattrs_equal':                                                         |
misc-utils/hardlink.c:580: warning: unused parameter 'a'                                                        |
misc-utils/hardlink.c:580: warning: unused parameter 'b'                                                        |
misc-utils/hardlink.c: In function 'inserter':                                                                  |
misc-utils/hardlink.c:816: warning: format '%ld' expects type 'long int', but argument 4 has type 'dev_t'       |
misc-utils/hardlink.c:816: warning: format '%ld' expects type 'long int', but argument 5 has type 'ino_t'       |
                                                                                                                | misc-utils/hardlink.c: In function ‘file_xattrs_equal’:
                                                                                                                | misc-utils/hardlink.c:580: warning: unused parameter ‘a’
                                                                                                                | misc-utils/hardlink.c:580: warning: unused parameter ‘b’
                                                                                                                | misc-utils/hardlink.c: In function ‘inserter’:
                                                                                                                | misc-utils/hardlink.c:816: warning: format ‘%ld’ expects type ‘long int’, but argument 4 has type ‘dev_t’
                                                                                                                | misc-utils/hardlink.c:816: warning: format ‘%ld’ expects type ‘long int’, but argument 5 has type ‘__darwin_ino64_t’
mv -f misc-utils/.deps/hardlink-hardlink.Tpo misc-utils/.deps/hardlink-hardlink.Po                              | mv -f misc-utils/.deps/hardlink-hardlink.Tpo misc-utils/.deps/hardlink-hardlink.Po
======================================================================================================================================================================================================================================

On Tiger the macro definition is observed as that of function – this seems to be the main cause. To determine this "change" I think the pre-compiled output would be useful…

BTW, I added the line configure.cflags-append -H to Portfile in order to see which header file are included. The pre-compilation will be performed manually.

comment:8 Changed 21 months ago by ballapete (Peter "Pete" Dyballa)

What I can see is that the code of the C file is not substituted by the macro definition on Tiger:

static void print_stats(void)
{
 struct timeval end = { 0, 0 }, delta = { 0, 0 };
 char *ssz;

 gettime_monotonic(&end);
 timersub(&end, &stats.start_time, &delta);

 jlog(JLOG_SUMMARY, "%-25s %s", libintl_gettext ("Mode:"),
      opts.dry_run ? libintl_gettext ("dry-run") : libintl_gettext ("real"));
 jlog(JLOG_SUMMARY, "%-25s %s", libintl_gettext ("Method:"), opts.method);
 jlog(JLOG_SUMMARY, "%-25s %zu", libintl_gettext ("Files:"), stats.files);
 jlog(JLOG_SUMMARY, libintl_gettext ("%-25s %zu files"), libintl_gettext ("Linked:"), stats.linked);

Changed 21 months ago by ballapete (Peter "Pete" Dyballa)

Attachment: hardlink-Tiger.cpp added

Pre-compiled hardlink.c file from PPC Tiger, Mac OS X 10.4.11

Changed 21 months ago by ballapete (Peter "Pete" Dyballa)

Attachment: hardlink-Leopard.cpp added

Pre-compiled hardlink.c file from PPC Leopard, Mac OS X 10.5.8

comment:9 Changed 21 months ago by ballapete (Peter "Pete" Dyballa)

I uploaded the two pre-compiled files that you can also see what the compilers are seeing.

comment:10 Changed 21 months ago by ballapete (Peter "Pete" Dyballa)

On Leopard lines #672/673 contain:

# 277 "/usr/include/sys/cdefs.h" 3 4
#define __DARWIN_UNIX03 1

which explains why on Leopard -D__DARWIN_UNIX03 is not necessary.

comment:11 Changed 21 months ago by ballapete (Peter "Pete" Dyballa)

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…

comment:12 Changed 21 months ago by kencu (Ken)

this issue with Tiger's headers not having _DARWIN_C_SOURCE is a major headache when dealing with Tiger.

All systems from 10.5 on do have that, and software expects it.

Last edited 21 months ago by kencu (Ken) (previous) (diff)

comment:13 Changed 21 months ago by ballapete (Peter "Pete" Dyballa)

With my little patch the port built! But – gmake check fails because it seems to depend on a Linux utility:

/bin/sh ./libtool  --tag=CC   --mode=link /opt/local/bin/gcc-apple-4.2 -fsigned-char -fno-common -Wall -Wextra -Wformat-security -Wimplicit-function-declaration -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wno-missing-field-initializers -Wpointer-arith -Wredundant-decls -Wsign-compare -Wstrict-prototypes -Wunused-parameter -Wunused-variable -Werror=sequence-point -pipe -Os -H -I/opt/local/include/LegacySupport -arch ppc    -L/opt/local/lib -Wl,-headerpad_max_install_names -lMacportsLegacySupport -arch ppc -o isosize disk-utils/isosize.o -L/opt/local/lib -lintl -R/opt/local/lib -Wl,-framework -Wl,CoreFoundation libcommon.la 
libtool: link: /opt/local/bin/gcc-apple-4.2 -fsigned-char -fno-common -Wall -Wextra -Wformat-security -Wimplicit-function-declaration -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wno-missing-field-initializers -Wpointer-arith -Wredundant-decls -Wsign-compare -Wstrict-prototypes -Wunused-parameter -Wunused-variable -Werror=sequence-point -pipe -Os -H -I/opt/local/include/LegacySupport -arch ppc -Wl,-headerpad_max_install_names -arch ppc -o isosize disk-utils/isosize.o -Wl,-framework -Wl,CoreFoundation  -L/opt/local/lib /opt/local/lib/libintl.dylib ./.libs/libcommon.a -lMacportsLegacySupport
/opt/local/bin/gmkdir -p $(dirname libsmartcols/smartcols.pc)
srcdir=''; \
	test -f ./libsmartcols/smartcols.pc.in || srcdir=./; \
	sed -e 's|@prefix[@]|/opt/local|g' -e 's|@exec_prefix[@]|/opt/local|g' -e 's|@sysconfdir[@]|/opt/local/etc|g' -e 's|@datadir[@]|/opt/local/share|g' -e 's|@sbindir[@]|/opt/local/sbin|g' -e 's|@bindir[@]|/opt/local/bin|g' -e 's|@docdir[@]|/opt/local/share/doc/util-linux|g' -e 's|@includedir[@]|/opt/local/include|g' -e 's|@runstatedir[@]|/opt/local/var/run|g' -e 's|@usrlib_execdir[@]|/opt/local/lib|g' -e 's|@usrbin_execdir[@]|/opt/local/bin|g' -e 's|@usrsbin_execdir[@]|/opt/local/sbin|g' -e 's|@VERSION[@]|2.38|g' -e 's|@ADJTIME_PATH[@]|/etc/adjtime|g' -e 's|@LIBUUID_VERSION[@]|2.38.0|g' -e 's|@LIBMOUNT_VERSION[@]|2.38.0|g' -e 's|@LIBMOUNT_MAJOR_VERSION[@]|2|g' -e 's|@LIBMOUNT_MINOR_VERSION[@]|38|g' -e 's|@LIBMOUNT_PATCH_VERSION[@]|0|g' -e 's|@LIBSMARTCOLS_VERSION[@]|2.38.0|g' -e 's|@LIBFDISK_PC_REQUIRES[@]|uuid|g' -e 's|@LIBFDISK_VERSION[@]|2.38.0|g' -e 's|@LIBFDISK_MAJOR_VERSION[@]|2|g' -e 's|@LIBFDISK_MINOR_VERSION[@]|38|g' -e 's|@LIBFDISK_PATCH_VERSION[@]|0|g' -e 's|@LIBBLKID_VERSION[@]|2.38.0|g'  -e 's|@LIBSELINUX[@]||g'   -e 's|@LIBCRYPTSETUP[@]||g' -e 's|@LIBDL[@]||g'  -e 's|@vendordir[@]||g' ${srcdir}libsmartcols/smartcols.pc.in >libsmartcols/smartcols.pc.tmp
gmake[2]: Das Ziel „check-am“ wurde wegen Fehlern nicht aktualisiert.
gmake[2]: Verzeichnis „/opt/local/var/macports/build/_opt_local_var_macports_sources_nue.de.rsync.macports.org_macports_release_tarballs_ports_devel_util-linux/util-linux/work/util-linux-2.38“ wird verlassen
gmake[1]: *** [Makefile:15052: check-recursive] Fehler 1

Changed 21 months ago by ballapete (Peter "Pete" Dyballa)

Patch for Mac OS X 10.4, Tiger, to make use of timersub() macro instead of a function by the same name

comment:14 Changed 21 months ago by ballapete (Peter "Pete" Dyballa)

After installing the port hardlink reports: hardlink: cannot initialize sha256 method, use 'memcmp' fallback. Could be it can afford some more patches…

comment:15 Changed 21 months ago by ballapete (Peter "Pete" Dyballa)

The two port rarian and xmlto could be upgraded. xmlto has a small set of tests that succeeded. So let's hope that this works for more Tiger users.

I'll try another, simpler, patch: moving line #26 below line #31.

comment:16 in reply to:  15 Changed 21 months ago by ballapete (Peter "Pete" Dyballa)

Replying to ballapete:

I'll try another, simpler, patch: moving line #26 below line #31.

This patch fails because _POSIX_C_SOURCE is #define'd somewhere before! So it only works to #undef and afterwards #define again…

comment:17 Changed 21 months ago by cooljeanius (Eric Gallager)

Cc: cooljeanius added

comment:18 Changed 21 months ago by evanmiller (Evan Miller)

Try

configure.cflags-append "-include sys/time.h"

This will ensure that time.h is included before _POSIX_C_SOURCE is defined.

comment:19 Changed 21 months ago by ballapete (Peter "Pete" Dyballa)

With this additional line in Portfile building succeeds. There are some differences during configure or build phases:

before -include sys/time.h              after -include sys/time.h
==================================================================
checking for nanosleep... no            -> yes
checking for timegm... no               -> yes
checking for clock_gettime... no        -> yes
checking for setitimer... no            -> yes
                                        WARNING: timer_create/setitimer function not found; not building flock

                                        GCC -c lib/timeutils.c
                                        In file included from lib/timeutils.c:32:
                                        ./include/timeutils.h:89: warning: redundant redeclaration of 'timegm'
                                        /usr/include/time.h:154: warning: previous declaration of 'timegm' was here

                                        GCC -c misc-utils/hardlink.c
                                        In file included from misc-utils/hardlink.c:51:
                                        ./include/xalloc.h: In function 'xasprintf':
                                        ./include/xalloc.h:104: warning: implicit declaration of function 'vasprintf'
                                        ./include/xalloc.h:104: warning: nested extern declaration of 'vasprintf'
                                        In file included from misc-utils/hardlink.c:52:
                                        ./include/strutils.h: In function 'startswith_no_case':
                                        ./include/strutils.h:242: warning: implicit declaration of function 'strncasecmp'
                                        misc-utils/hardlink.c: In function 'file_xattrs_equal':
                                        misc-utils/hardlink.c:580: warning: unused parameter 'a'
                                        misc-utils/hardlink.c:580: warning: unused parameter 'b'
                                        misc-utils/hardlink.c: In function 'inserter':
                                        misc-utils/hardlink.c:816: warning: format '%ld' expects type 'long int', but argument 4 has type 'dev_t'
                                        misc-utils/hardlink.c:816: warning: format '%ld' expects type 'long int', but argument 5 has type 'ino_t'

Looks better than my patch!

comment:20 Changed 17 months ago by ballapete (Peter "Pete" Dyballa)

The problem persist – since Portfile not updated?

comment:21 Changed 17 months ago by kencu (Ken)

Owner: set to kencu
Resolution: fixed
Status: newclosed

In 57c7693a5b1b5821de65439fdd0e0cdeafd17340/macports-ports (master):

util-linux: fix build on Tiger

strict POSIX disables certain functions on Tiger
closes: #65582

Note: See TracTickets for help on using tickets.