Opened 4 years ago

Last modified 3 years ago

#59453 assigned defect

R @3.5.1: Fails to compile on Mojave (10.14.6) with XCode 11 (11.1 11A1027)

Reported by: vjorlikowski Owned by: kjellpk (Kjell Konis)
Priority: Normal Milestone:
Component: ports Version: 2.6.2
Keywords: Cc: cooljeanius (Eric Gallager)
Port: R

Description

R @3.5.1 is failing to compile on a Mojave (10.14.6) system that has XCode 11 (11.1 11A1027) installed.

The build fails with:

:info:build make[4]: Entering directory `/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_math_R/R/work/R-3.5.1/src/library/tools'
:info:build installing 'sysdata.rda'
:info:build dyld: lazy symbol binding failed: Symbol not found: _timespec_get
:info:build   Referenced from: /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_math_R/R/work/R-3.5.1/lib/libR.dylib
:info:build   Expected in: /usr/lib/libSystem.B.dylib
:info:build dyld: Symbol not found: _timespec_get
:info:build   Referenced from: /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_math_R/R/work/R-3.5.1/lib/libR.dylib
:info:build   Expected in: /usr/lib/libSystem.B.dylib
:info:build /bin/sh: line 1: 31018 Done                    echo "tools:::sysdata2LazyLoadDB(\"./R/sysdata.rda\",\"../../../library/tools/R\")"
:info:build      31019 Abort trap: 6           | R_DEFAULT_PACKAGES=NULL LC_ALL=C R_ENABLE_JIT=0 TZ=UTC ../../../bin/R --vanilla --slave
:info:build make[4]: *** [sysdata] Error 134

And, when one looks at the config.log output, one finds:

configure:33502: checking whether timespec_get exists and is declared
configure:33530: /usr/bin/clang -o conftest -pipe -Os -isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk -arch x86_64 -fPIC  -I/opt/local/include -isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk  -L/opt/local/lib -Wl,-headerpad_max_install_names -Wl,-syslibroot,/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk -arch x86_64 conftest.c -lm  >&5
conftest.c:180:22: warning: 'timespec_get' is only available on macOS 10.15 or newer [-Wunguarded-availability-new]
  char *p = (char *) timespec_get;
                     ^~~~~~~~~~~~
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/time.h:199:5: note: 'timespec_get' has been marked as being introduced in macOS 10.15 here, but the deployment target is macOS 10.14.0
int timespec_get(struct timespec *ts, int base);
    ^
conftest.c:180:22: note: enclose 'timespec_get' in a __builtin_available check to silence this warning
  char *p = (char *) timespec_get;
                     ^~~~~~~~~~~~
1 warning generated.
configure:33530: $? = 0
configure:33539: result: yes

It appears that, with XCode 11, timespec_get() has been included in the system headers, causing the compiler to kvetch - but still exit successfully. As a result, the configure script is given erroneous information about timespec_get() support.

This causes a failure at link time, because timespec_get() is included in Catalina (10.15) - but not Mojave (10.14). The "strategy" for working around this *appears to be* to wrap things you're not sure will be available in builtin_available macros - which doesn't work so well for auto-generated test programs in configure.

I have to wonder how many other such library calls rely on the builtin_available check, for supporting Mojave and Catalina at the same time...

Change History (13)

comment:1 Changed 4 years ago by vjorlikowski

Cc: vjorlikowski added

comment:2 Changed 4 years ago by vjorlikowski

Cc: vjorlikowski removed

comment:3 Changed 4 years ago by vjorlikowski

Owner: set to kjellpk
Status: newassigned

comment:4 Changed 4 years ago by andyjacobson (Andy Jacobson)

Watching this one with anticipation! My workflow is broken until I get R compiled again.

comment:5 Changed 4 years ago by kjellpk (Kjell Konis)

Maintainer here. Sorry for taking 2 weeks to get to this. Unfortunately I am not able to reproduce. I have a 2010 MacBook Pro and am stuck w/ High Sierra. The only thing I can think of is the

--with-internal-tzcode use internal time-zone code [no, yes on macOS]

option. I've had to toggle it for some versions of R in the past. Could someone try adding

--without-internal-tzcode

to the configure options? Thanks.

comment:6 Changed 4 years ago by himay81 (Jamie Baxter)

Adding --without-internal-tzcode to configure.args in the Portfile (I assume that's the correct block to add it) doesn't appear to have any effect. Still seems to error out in the same fashion, complaining about _timespec_get. If I got that wrong, please advise.

config.log after this test build still warns timespec_get is only available in Catalina…

configure:33502: checking whether timespec_get exists and is declared
configure:33530: /usr/bin/clang -o conftest -pipe -Os -isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk -arch x86_64 -fPIC  -I/opt/local/include -isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk  -L/opt/local/lib -Wl,-headerpad_max_install_names -Wl,-syslibroot,/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk -arch x86_64 conftest.c -lm  >&5
conftest.c:180:22: warning: 'timespec_get' is only available on macOS 10.15 or newer [-Wunguarded-availability-new]
  char *p = (char *) timespec_get;
                     ^~~~~~~~~~~~
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/time.h:199:5: note: 'timespec_get' has been marked as being introduced in macOS 10.15 here, but the deployment target is macOS 10.14.0
int timespec_get(struct timespec *ts, int base);
    ^
conftest.c:180:22: note: enclose 'timespec_get' in a __builtin_available check to silence this warning
  char *p = (char *) timespec_get;
                     ^~~~~~~~~~~~
1 warning generated.
configure:33530: $? = 0
configure:33539: result: yes

~:$ tail -n40 /opt/local/var/macports/logs/_usr_local_ports_math_R/R/main.log

:info:build /usr/bin/clang -I"../../../../include" -DNDEBUG -I../../../include -I../../../../src/include -DHAVE_CONFIG_H -I../../../../src/main  -I/opt/local/include -isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk   -fPIC  -pipe -Os -isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk -arch x86_64  -c gramRd.c -o gramRd.o
:info:build /usr/bin/clang -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L../../../../lib -L/opt/local/lib -Wl,-headerpad_max_install_names -Wl,-syslibroot,/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk -arch x86_64 -o tools.so text.o init.o Rmd5.o md5.o signals.o install.o getfmts.o http.o gramLatex.o gramRd.o -L../../../../lib -lR -Wl,-framework -Wl,CoreFoundation
:info:build make[6]: Entering directory `/opt/local/var/macports/build/_usr_local_ports_math_R/R/work/R-3.5.1/src/library/tools/src'
:info:build mkdir ../../../../library/tools/libs
:info:build make[6]: Leaving directory `/opt/local/var/macports/build/_usr_local_ports_math_R/R/work/R-3.5.1/src/library/tools/src'
:info:build make[5]: Leaving directory `/opt/local/var/macports/build/_usr_local_ports_math_R/R/work/R-3.5.1/src/library/tools/src'
:info:build make[4]: Leaving directory `/opt/local/var/macports/build/_usr_local_ports_math_R/R/work/R-3.5.1/src/library/tools'
:info:build make[4]: Entering directory `/opt/local/var/macports/build/_usr_local_ports_math_R/R/work/R-3.5.1/src/library/tools'
:info:build installing 'sysdata.rda'
:info:build dyld: lazy symbol binding failed: Symbol not found: _timespec_get
:info:build   Referenced from: /opt/local/var/macports/build/_usr_local_ports_math_R/R/work/R-3.5.1/lib/libR.dylib
:info:build   Expected in: /usr/lib/libSystem.B.dylib
:info:build dyld: Symbol not found: _timespec_get
:info:build   Referenced from: /opt/local/var/macports/build/_usr_local_ports_math_R/R/work/R-3.5.1/lib/libR.dylib
:info:build   Expected in: /usr/lib/libSystem.B.dylib
:info:build /bin/sh: line 1: 62470 Done                    echo "tools:::sysdata2LazyLoadDB(\"./R/sysdata.rda\",\"../../../library/tools/R\")"
:info:build      62471 Abort trap: 6           | R_DEFAULT_PACKAGES=NULL LC_ALL=C R_ENABLE_JIT=0 TZ=UTC ../../../bin/R --vanilla --slave
:info:build make[4]: *** [sysdata] Error 134
:info:build make[4]: Leaving directory `/opt/local/var/macports/build/_usr_local_ports_math_R/R/work/R-3.5.1/src/library/tools'
:info:build make[3]: *** [all] Error 2
:info:build make[3]: Leaving directory `/opt/local/var/macports/build/_usr_local_ports_math_R/R/work/R-3.5.1/src/library/tools'
:info:build make[2]: *** [R] Error 1
:info:build make[2]: Leaving directory `/opt/local/var/macports/build/_usr_local_ports_math_R/R/work/R-3.5.1/src/library'
:info:build make[1]: *** [R] Error 1
:info:build make[1]: Leaving directory `/opt/local/var/macports/build/_usr_local_ports_math_R/R/work/R-3.5.1/src'
:info:build make: *** [R] Error 1
:info:build make: Leaving directory `/opt/local/var/macports/build/_usr_local_ports_math_R/R/work/R-3.5.1'
:info:build Command failed:  cd "/opt/local/var/macports/build/_usr_local_ports_math_R/R/work/R-3.5.1" && /usr/bin/make -j6 -w all 
:info:build Exit code: 2
:error:build Failed to build R: command execution failed
:debug:build Error code: CHILDSTATUS 59376 2
:debug:build Backtrace: command execution failed
:debug:build     while executing
:debug:build "system {*}$notty {*}$nice $fullcmdstring"
:debug:build     invoked from within
:debug:build "command_exec build"
:debug:build     (procedure "portbuild::build_main" line 8)
:debug:build     invoked from within
:debug:build "$procedure $targetname"
:error:build See /opt/local/var/macports/logs/_usr_local_ports_math_R/R/main.log for details.
Version 0, edited 4 years ago by himay81 (Jamie Baxter) (next)

comment:7 Changed 4 years ago by himay81 (Jamie Baxter)

Or perhaps I misunderstood? Examining configure within the R work directory, only the --with-internal-tzcode option is listed. Does --without-internal-tzcode even have any effect?

# Check whether --with-internal-tzcode was given.
if test "${with_internal_tzcode+set}" = set; then :
  withval=$with_internal_tzcode; use_internal_tzcode=${withval}
else
  use_internal_tzcode=default
fi

Do I have to manually disable use_internal_tzcode somehow instead? Forgive me for my confusion…this isn't exactly my realm of expertise here.

if test x${use_internal_tzcode} = xdefault; then
case "${host_os}" in
   darwin*)
     use_internal_tzcode=yes;
     ;;
esac
fi
if test "${use_internal_tzcode}" != yes; then
  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether mktime sets errno" >&5
$as_echo_n "checking whether mktime sets errno... " >&6; }
if ${r_cv_mktime_errno+:} false; then :
  $as_echo_n "(cached) " >&6
else
  if test "$cross_compiling" = yes; then :
  r_cv_mktime_errno=no
else
  cat confdefs.h - <<_ACEOF >conftest.$ac_ext

comment:8 Changed 4 years ago by himay81 (Jamie Baxter)

Nevermind that last post, I think. Manual editing of the configure file as below…

if test x${use_internal_tzcode} = xdefault; then
case "${host_os}" in
   darwin*)
     use_internal_tzcode=no;
     ;;
esac
fi

…in the absence of the --with-internal-tzcode flag (which should then use the default, to run the code block above) has no effect.

Relatedly…hunting around in configure and config.log has me thinking this is an Xcode (11 on Mojave) issue? From configure:

for ac_func in clock_gettime timespec_get
do
as_ac_Symbol=`$as_echo "ac_cv_have_decl_$ac_func" | $as_tr_sh`
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $ac_func exists and is declared" >&5
$as_echo_n "checking whether $ac_func exists and is declared... " >&6; }
if eval \${$as_ac_Symbol+:} false; then :
  $as_echo_n "(cached) " >&6
else
  cat confdefs.h - <<_ACEOF >conftest.$ac_ext

From config.log in checking for those functions…

configure:33488: result: no
configure:33502: checking whether clock_gettime exists and is declared
configure:33530: /usr/bin/clang -o conftest -pipe -Os -isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk -arch x86_64 -fPIC  -I/opt/local/include -isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk  -L/opt/local/lib -Wl,-headerpad_max_install_names -Wl,-syslibroot,/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk -arch x86_64 conftest.c -lm  >&5
configure:33530: $? = 0
configure:33539: result: yes
configure:33502: checking whether timespec_get exists and is declared
configure:33530: /usr/bin/clang -o conftest -pipe -Os -isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk -arch x86_64 -fPIC  -I/opt/local/include -isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk  -L/opt/local/lib -Wl,-headerpad_max_install_names -Wl,-syslibroot,/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk -arch x86_64 conftest.c -lm  >&5
conftest.c:180:22: warning: 'timespec_get' is only available on macOS 10.15 or newer [-Wunguarded-availability-new]
  char *p = (char *) timespec_get;
                     ^~~~~~~~~~~~
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/time.h:199:5: note: 'timespec_get' has been marked as being introduced in macOS 10.15 here, but the deployment target is macOS 10.14.0
int timespec_get(struct timespec *ts, int base);
    ^
conftest.c:180:22: note: enclose 'timespec_get' in a __builtin_available check to silence this warning
  char *p = (char *) timespec_get;
                     ^~~~~~~~~~~~
1 warning generated.
configure:33530: $? = 0
configure:33539: result: yes

Might the problem be something regarding changes in time.h between 10.14 and 10.15? Reverting from Xcode 11 to 10 here fixed a similar issue… https://github.com/Blizzard/node-rdkafka/issues/686#issuecomment-535909615

EDIT: Re-reading the last part of the bug trac request…oops, yeah, this seems to be some PITA bug for Xcode 11 users on Mojave…

Last edited 4 years ago by himay81 (Jamie Baxter) (previous) (diff)

comment:9 Changed 4 years ago by kjellpk (Kjell Konis)

Maintainer here. Just FYI, I am updating the port to the current version of R: #59765.

comment:10 Changed 4 years ago by vjorlikowski

So - to confirm:

1) Yes - this is an XCode 11 bug on Mojave.

2) It relies (as do most things with XCode 11 and Mojave) on first doing:

cd /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs
sudo ln -s MacOSX.sdk MacOSX10.14.sdk

so that it will even compile.
Sadly - unless the configure script is patched to allow disabling the check for timespec_get(), I don't think R will properly compile on Mojave with XCode 11.

comment:11 Changed 4 years ago by himay81 (Jamie Baxter)

Re-installing Xcode 10.3 alone appears to exhibit the same problem, it would appear. The original 10.15 SDK command line tools (installed by Xcode 11) are still present and linked, and forcing xcode-select --install does not help as it recognizes the 10.15 SDK tools as a valid install (despite Xcode 10 being installed).

Need to cleanly remove the existing command line tools (rm -rf /Library/Developer/CommandLineTools) and reinstall them after (xcode-select --install) to get the R port to build properly.

Re: vjorlikowski's second comment…

sudo ln -s /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/{MacOSX.sdk,MacOSX10.14.sdk}

Maybe I misunderstood their comment, but applying this before I removed Xcode 11 did nothing to permit R (3.5.1) to build properly on my system. Eventually went about removing Xcode 11 and reinstalling 10.3 to finally get R to build properly.

Last edited 4 years ago by himay81 (Jamie Baxter) (previous) (diff)

comment:12 Changed 4 years ago by vjorlikowski

Let me amend my comment...

"So that it will even try to make any progress through the configure script" rather than "so that it will even compile."

That's more accurate. Apologies. :)

comment:13 Changed 3 years ago by cooljeanius (Eric Gallager)

Cc: cooljeanius added
Note: See TracTickets for help on using tickets.