Opened 4 years ago

Closed 4 years ago

#51451 closed defect (fixed)

gnutls @3.4.12: build fails on 10.6, undefined symbol strndup.

Reported by: dbevans (David B. Evans) Owned by: Schamschula (Marius Schamschula)
Priority: Normal Milestone:
Component: ports Version:
Keywords: Cc: udbraumann, ballapete (Peter Dyballa), help@…
Port: gnutls

Description

Build fails as follows on 10.6:

/bin/sh ../libtool  --tag=CC   --mode=link /usr/bin/gcc-4.2 -W -Wabi -Waddress -Wall -Wattributes -Wbad-function-cast -Wcast-align -Wchar-subscripts -Wcomment -Wcomments -Wdeprecated -Wdeprecated-declarations -Wdisabled-optimization -Wdiv-by-zero -Wempty-body -Wendif-labels -Wextra -Wformat-extra-args -Wformat-security -Wformat-zero-length -Wimplicit -Wimplicit-function-declaration -Wimplicit-int -Winit-self -Wint-to-pointer-cast -Winvalid-pch -Wmain -Wmissing-braces -Wmissing-declarations -Wmissing-field-initializers -Wmissing-include-dirs -Wmissing-prototypes -Wmultichar -Wnested-externs -Wnonnull -Wold-style-definition -Woverflow -Woverride-init -Wpacked -Wparentheses -Wpointer-arith -Wpointer-sign -Wpointer-to-int-cast -Wpragmas -Wreturn-type -Wsequence-point -Wshadow -Wstrict-aliasing -Wstrict-prototypes -Wswitch -Wtrigraphs -Wuninitialized -Wunknown-pragmas -Wunsafe-loop-optimizations -Wunused -Wunused-function -Wunused-label -Wunused-macros -Wunused-parameter -Wunused-value -Wunused-variable -Wvariadic-macros -Wvolatile-register-var -Wwrite-strings -Wnormalized=nfc -Wno-missing-field-initializers -Wno-missing-field-initializers -Wno-format-y2k -Wno-unused-value -Wno-unused-parameter -Wno-stack-protector -Wno-int-to-pointer-cast -fdiagnostics-show-option  -pipe -Os -arch x86_64 -module -no-undefined -avoid-version -L/opt/local/lib -Wl,-headerpad_max_install_names -arch x86_64 -o libpkcs11mock1.la -rpath /opt/local/lib/gnutls pkcs11/pkcs11-mock.lo  -lintl
libtool: warning: '-no-install' is ignored for x86_64-apple-darwin10
libtool: warning: assuming '-no-fast-install' instead
libtool: link: ar cru .libs/libutils.a .libs/utils.o
libtool: link: ranlib .libs/libutils.a
libtool: link: ( cd ".libs" && rm -f "libutils.la" && ln -s "../libutils.la" "libutils.la" )
libtool: link: /usr/bin/gcc-4.2  -o .libs/libpkcs11mock1.so -bundle  pkcs11/.libs/pkcs11-mock.o   -L/opt/local/lib /opt/local/lib/libintl.dylib  -Os -arch x86_64 -Wl,-headerpad_max_install_names -arch x86_64
Undefined symbols:
  "_strndup", referenced from:
      _C_FindObjectsInit in pkcs11-mock.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
make[3]: *** [libpkcs11mock1.la] Error 1
make[3]: Leaving directory `/opt/local/var/macports/build/_opt_mports_dports_devel_gnutls/gnutls/work/gnutls-3.4.12/tests'

This is a common error on 10.6 -- strndup was not introduced to OS X until 10.7. A typical fix is to provide a static replacement function that is only used on 10.6 or earlier.

See this patch in libmms for one way to accomplish this.

Needless to say this blocks the build on 10.6 of any port that depends on gnutls.

Attachments (4)

main.log (2.1 MB) - added by dbevans (David B. Evans) 4 years ago.
Build log showing showing failure on 10.6
main.2.log (1.1 MB) - added by ballapete (Peter Dyballa) 4 years ago.
main.log from build on PPC Tiger
patch-tests-pkcs11-pkcs11-mock.c.diff (1.0 KB) - added by ballapete (Peter Dyballa) 4 years ago.
Tiger compatible version of patch
patch-tests-pkcs11-pkcs11-mock.c.2.diff (1.1 KB) - added by help@… 4 years ago.

Change History (24)

Changed 4 years ago by dbevans (David B. Evans)

Attachment: main.log added

Build log showing showing failure on 10.6

comment:1 Changed 4 years ago by udbraumann

Cc: braumann@… added

Cc Me!

comment:2 Changed 4 years ago by Schamschula (Marius Schamschula)

Sorry about that. I was off-line this morning, and had put together a patch, but had no way of testing it.

This patch is a better solution. Thanks David!

Fixed in r148866.

comment:3 Changed 4 years ago by dbevans (David B. Evans)

Resolution: fixed
Status: newclosed

Thanks for the quick fix!

comment:4 in reply to:  3 Changed 4 years ago by udbraumann

Fix works, thanks.

comment:5 Changed 4 years ago by ballapete (Peter Dyballa)

Resolution: fixed
Status: closedreopened

comment:6 Changed 4 years ago by ballapete (Peter Dyballa)

Cc: Peter_Dyballa@… added

Cc Me!

comment:7 Changed 4 years ago by ballapete (Peter Dyballa)

A similar error happens on PPC Tiger, Mac OS X 10.4.11:

:info:build mv -f $depbase.Tpo $depbase.Plo
:info:build libtool: compile:  /opt/local/bin/gcc-apple-4.2 -DHAVE_CONFIG_H -I. -I.. -I/opt/local/include/p11-kit-1 -I../lib/includes -I../lib/includes -I../libdane/includes -I../libdane/includes -I../extra/includes -I../extra/includes -I../lib -I../doc/examples -I/opt/local/include -W -Wabi -Waddress -Wall -Wattributes -Wbad-function-cast -Wcast-align -Wchar-subscripts -Wcomment -Wcomments -Wdeprecated -Wdeprecated-declarations -Wdisabled-optimization -Wdiv-by-zero -Wempty-body -Wendif-labels -Wextra -Wformat-extra-args -Wformat-security -Wformat-zero-length -Wimplicit -Wimplicit-function-declaration -Wimplicit-int -Winit-self -Wint-to-pointer-cast -Winvalid-pch -Wmain -Wmissing-braces -Wmissing-declarations -Wmissing-field-initializers -Wmissing-include-dirs -Wmissing-prototypes -Wmultichar -Wnested-externs -Wnonnull -Wold-style-definition -Woverflow -Woverride-init -Wpacked -Wparentheses -Wpointer-arith -Wpointer-sign -Wpointer-to-int-cast -Wpragmas -Wreturn-type -Wsequence-point -Wshadow -Wstrict-aliasing -Wstrict-prototypes -Wswitch -Wtrigraphs -Wuninitialized -Wunknown-pragmas -Wunsafe-loop-optimizations -Wunused -Wunused-function -Wunused-label -Wunused-macros -Wunused-parameter -Wunused-value -Wunused-variable -Wvariadic-macros -Wvolatile-register-var -Wwrite-strings -Wnormalized=nfc -Wno-missing-field-initializers -Wno-missing-field-initializers -Wno-format-y2k -Wno-unused-value -Wno-unused-parameter -Wno-stack-protector -Wno-int-to-pointer-cast -fdiagnostics-show-option -pipe -Os -arch ppc -MT pkcs11/pkcs11-mock.lo -MD -MP -MF pkcs11/.deps/pkcs11-mock.Tpo -c pkcs11/pkcs11-mock.c  -fno-common -DPIC -o pkcs11/.libs/pkcs11-mock.o
:info:build cc1: warning: command line option "-Wabi" is valid for C++/ObjC++ but not for C
:info:build cc1: warning: command line option "-Wdeprecated" is valid for C++/ObjC++ but not for C
:info:build pkcs11/pkcs11-mock.c:21:26: error: Availability.h: No such file or directory
:info:build pkcs11/pkcs11-mock.c:23: warning: declaration of 'strndup' shadows a built-in function [-Wshadow]
:info:build make[3]: *** [pkcs11/pkcs11-mock.lo] Error 1
:info:build make[3]: Leaving directory `/opt/local/var/macports/build/_opt_local_var_macports_sources_lil.fr.rsync.macports.org_release_tarballs_ports_devel_gnutls/gnutls/work/gnutls-3.4.12/tests'
:info:build make[2]: *** [all-recursive] Error 1
:info:build make[2]: Leaving directory `/opt/local/var/macports/build/_opt_local_var_macports_sources_lil.fr.rsync.macports.org_release_tarballs_ports_devel_gnutls/gnutls/work/gnutls-3.4.12/tests'
:info:build make[1]: *** [all-recursive] Error 1
:info:build make[1]: Leaving directory `/opt/local/var/macports/build/_opt_local_var_macports_sources_lil.fr.rsync.macports.org_release_tarballs_ports_devel_gnutls/gnutls/work/gnutls-3.4.12'
:info:build make: *** [all] Error 2
:info:build make: Leaving directory `/opt/local/var/macports/build/_opt_local_var_macports_sources_lil.fr.rsync.macports.org_release_tarballs_ports_devel_gnutls/gnutls/work/gnutls-3.4.12'
:info:build Command failed:  cd "/opt/local/var/macports/build/_opt_local_var_macports_sources_lil.fr.rsync.macports.org_release_tarballs_ports_devel_gnutls/gnutls/work/gnutls-3.4.12" && /usr/bin/make -w all 

Another port is being built so I have to wait until I can check whether the patch would work.

Changed 4 years ago by ballapete (Peter Dyballa)

Attachment: main.2.log added

main.log from build on PPC Tiger

comment:8 in reply to:  7 ; Changed 4 years ago by Schamschula (Marius Schamschula)

Replying to Peter_Dyballa@…:

A similar error happens on PPC Tiger, Mac OS X 10.4.11:

Did you run sudo port sync after the patch was committed? The patch should work for all versions of OS X, Snow Leopard and older.

If not do that and then rub sudo port clean gnutls before sudo port upgrade gnutls.

comment:9 in reply to:  8 Changed 4 years ago by ballapete (Peter Dyballa)

Replying to mps@…:

Replying to Peter_Dyballa@…:

A similar error happens on PPC Tiger, Mac OS X 10.4.11:

Did you run sudo port sync after the patch was committed?

No. I ran the regular port selfupdate. And only one patch file appeared:

-rw-r--r--   1 root  wheel  1036 20 Mai 20:30 patch-tests-pkcs11-pkcs11-mock.c.diff

which has the correct contents. I can see that patch being applied:

DEBUG: patch phase started at Sun May 22 14:59:40 CEST 2016
DEBUG: Executing org.macports.patch (gnutls)
--->  Applying patches to gnutls
--->  Applying patch-tests-pkcs11-pkcs11-mock.c.diff

But I think this line

+#include <Availability.h>

introduces the actual error, which is:

pkcs11/pkcs11-mock.c:21:26: error: Availability.h: No such file or directory

comment:10 Changed 4 years ago by ballapete (Peter Dyballa)

PPC Tiger, Mac OS X 10.4.11 has only these C header files with Availability in the name:

/Developer/SDKs/MacOSX10.3.9.sdk/Developer/Headers/CFMCarbon/AvailabilityMacros.h
/Developer/SDKs/MacOSX10.3.9.sdk/usr/include/AvailabilityMacros.h
/Developer/SDKs/MacOSX10.3.9.sdk/usr/lib/gcc/powerpc-apple-darwin7/4.0.0/include/AvailabilityMacros.h
/Developer/SDKs/MacOSX10.4u.sdk/Developer/Headers/CFMCarbon/AvailabilityMacros.h
/Developer/SDKs/MacOSX10.4u.sdk/usr/include/AvailabilityMacros.h

comment:11 Changed 4 years ago by Schamschula (Marius Schamschula)

Peter,

My original patch would have worked, but would have made for a messy Portfile (patching as a function of the Darwin version #), so I opted for David's approach. As I no longer have a Tiger machine (I do have a Leopard G5 iMac, where this update build correctly), nor do the build bots build anything older than Snow Leopard, so I have no way of testing on older, unsupported, systems.

The best approach is to make a local build tree and modify the patch file by removing

#ifdef __APPLE__ 
#include <Availability.h> 
#if __MAC_OS_X_VERSION_MIN_REQUIRED <= 1060

and

#endif
#endif

which was my original patch.

comment:12 in reply to:  11 ; Changed 4 years ago by ballapete (Peter Dyballa)

Replying to mps@…:

The best approach is to make a local build tree and modify the patch file by removing

Or trying that?

#ifdef __APPLE__ 
#if __MAC_OS_X_VERSION_MIN_REQUIRED => 1050
#include <Availability.h>
#endif
#if __MAC_OS_X_VERSION_MIN_REQUIRED <= 1060

comment:13 in reply to:  12 Changed 4 years ago by ballapete (Peter Dyballa)

GnuTLS builds with this corrected patch file. I am not sure whether I can test it on PPC Leopard, Mac OS X 10.5.8, tonight…

Last edited 4 years ago by ballapete (Peter Dyballa) (previous) (diff)

Changed 4 years ago by ballapete (Peter Dyballa)

Tiger compatible version of patch

comment:14 Changed 4 years ago by dbevans (David B. Evans)

This latest proposed fix will break builds where strndup DOES exist (10.7+). I committed a tentative fix in r149004 that updates this patch to test for 10.4 and earlier and include AvailabilityMacros.h rather than Availability.h if that's the case. Please test and advise.

comment:15 in reply to:  14 Changed 4 years ago by ballapete (Peter Dyballa)

Replying to devans@…:

Please test and advise.

On the weekend when I'll be home again!

comment:16 in reply to:  14 Changed 4 years ago by ballapete (Peter Dyballa)

Replying to devans@…:

GnuTLS @3.4.11_1 built on PPC Leopard, Mac OS X 10.5.8.

comment:17 Changed 4 years ago by help@…

Compilation is broken on OSX 10.10 when macosx_deployment_target is set to 10.6 (reason being weak-linking):

:info:build pkcs11/pkcs11-mock.c:29:15: error: static declaration of 'strndup' follows non-static declaration
:info:build static char * strndup (char const *s, size_t n);
:info:build               ^
:info:build /usr/include/string.h:132:7: note: previous declaration is here
:info:build char    *strndup(const char *, size_t) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_3);
:info:build          ^
:info:build pkcs11/pkcs11-mock.c:30:15: error: static declaration of 'strnlen' follows non-static declaration
:info:build static size_t strnlen (const char *string, size_t maxlen);
:info:build               ^
:info:build /usr/include/string.h:133:10: note: previous declaration is here
:info:build size_t   strnlen(const char *, size_t) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_3);
:info:build          ^
:info:build pkcs11/pkcs11-mock.c:33:1: error: static declaration of 'strnlen' follows non-static declaration
:info:build strnlen (const char *string, size_t maxlen)
:info:build ^
:info:build /usr/include/string.h:133:10: note: previous declaration is here
:info:build size_t   strnlen(const char *, size_t) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_3);
:info:build          ^
:info:build pkcs11/pkcs11-mock.c:40:1: error: static declaration of 'strndup' follows non-static declaration
:info:build strndup (char const *s, size_t n)
:info:build ^
:info:build /usr/include/string.h:132:7: note: previous declaration is here
:info:build char    *strndup(const char *, size_t) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_3);
:info:build          ^
:info:build 4 errors generated.

I suggest alternative fix (attached) which is less pretty (uses #defines) but seems to work.

Changed 4 years ago by help@…

comment:18 Changed 4 years ago by help@…

Cc: help@… added

Cc Me!

comment:19 in reply to:  14 Changed 4 years ago by ballapete (Peter Dyballa)

Replying to devans@…:

It was of course GnuTLS @3.4.12 that built on PPC Leopard, Mac OS X 10.5.8. And the same version also built on PPC Tiger, Mac OS X 10.4.11.

comment:20 Changed 4 years ago by dbevans (David B. Evans)

Resolution: fixed
Status: reopenedclosed
Note: See TracTickets for help on using tickets.