Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 757426 - dev-util/cmake-3.19.1: failed prefix build on darwin20 (error: ‘timespec_get’ has not been declared in ‘::’)
Summary: dev-util/cmake-3.19.1: failed prefix build on darwin20 (error: ‘timespec_get’...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo/Alt
Classification: Unclassified
Component: Prefix Support (show other bugs)
Hardware: All OS X
: Normal normal
Assignee: Gentoo Prefix
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-11-28 17:58 UTC by Sam James
Modified: 2021-02-17 22:50 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
build.log (file_757426.txt,421.82 KB, text/plain)
2020-11-28 17:58 UTC, Sam James
Details
build.log (file_757426.txt,418.49 KB, text/plain)
2020-11-28 17:59 UTC, Sam James
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Sam James archtester Gentoo Infrastructure gentoo-dev Security 2020-11-28 17:58:09 UTC
[ 41%] Building CXX object Source/CMakeFiles/CMakeLib.dir/cmTarget.cxx.o
cd /Users/sam/Gentoo/var/tmp/portage/dev-util/cmake-3.19.1/work/cmake-3.19.1_build/Source && /Users/sam/Gentoo/usr/x86_64-apple-darwin20/gcc-bin/10.1.0/x86_64-apple-darwin20-g++  -I/Users/sam/Gentoo/var/tmp/portage/dev-util/cmake-3.19.1/work/cmake-3.19.1_build/Utilities -I/Users/sam/Gentoo/var/tmp/portage/dev-util/cmake-3.19.1/work/cmake-3.19.1_build/Source -I/Users/sam/Gentoo/var/tmp/portage/dev-util/cmake-3.19.1/work/cmake-3.19.1/Source -I/Users/sam/Gentoo/var/tmp/portage/dev-util/cmake-3.19.1/work/cmake-3.19.1/Source/LexerParser -I/Users/sam/Gentoo/var/tmp/portage/dev-util/cmake-3.19.1/work/cmake-3.19.1/Source/CTest -I/Users/sam/Gentoo/var/tmp/portage/dev-util/cmake-3.19.1/work/cmake-3.19.1/Source/CPack -isystem /Users/sam/Gentoo/var/tmp/portage/dev-util/cmake-3.19.1/work/cmake-3.19.1/Utilities/std -isystem /Users/sam/Gentoo/var/tmp/portage/dev-util/cmake-3.19.1/work/cmake-3.19.1/Utilities -isystem /Users/sam/Gentoo/usr/include/jsoncpp  -march=native -O2 -pipe -mmacosx-version-min=11.0 -Wno-deprecated-declarations -std=c++17 -o CMakeFiles/CMakeLib.dir/cmTarget.cxx.o -c /Users/sam/Gentoo/var/tmp/portage/dev-util/cmake-3.19.1/work/cmake-3.19.1/Source/cmTarget.cxx
In file included from /Users/sam/Gentoo/usr/lib/gcc/x86_64-apple-darwin20/10.1.0/include/g++-v10/chrono:42,
                 from /Users/sam/Gentoo/var/tmp/portage/dev-util/cmake-3.19.1/work/cmake-3.19.1/Source/cmDuration.h:5,
                 from /Users/sam/Gentoo/var/tmp/portage/dev-util/cmake-3.19.1/work/cmake-3.19.1/Source/cmSystemTools.h:18,
                 from /Users/sam/Gentoo/var/tmp/portage/dev-util/cmake-3.19.1/work/cmake-3.19.1/Source/cmSystemTools.cxx:14:
/Users/sam/Gentoo/usr/lib/gcc/x86_64-apple-darwin20/10.1.0/include/g++-v10/ctime:80:11: error: ‘timespec_get’ has not been declared in ‘::’
   80 |   using ::timespec_get;
      |           ^~~~~~~~~~~~
[ 42%] Building CXX object Source/CMakeFiles/CMakeLib.dir/cmTargetPropertyComputer.cxx.o
cd /Users/sam/Gentoo/var/tmp/portage/dev-util/cmake-3.19.1/work/cmake-3.19.1_build/Source && /Users/sam/Gentoo/usr/x86_64-apple-darwin20/gcc-bin/10.1.0/x86_64-apple-darwin20-g++  -I/Users/sam/Gentoo/var/tmp/portage/dev-util/cmake-3.19.1/work/cmake-3.19.1_build/Utilities -I/Users/sam/Gentoo/var/tmp/portage/dev-util/cmake-3.19.1/work/cmake-3.19.1_build/Source -I/Users/sam/Gentoo/var/tmp/portage/dev-util/cmake-3.19.1/work/cmake-3.19.1/Source -I/Users/sam/Gentoo/var/tmp/portage/dev-util/cmake-3.19.1/work/cmake-3.19.1/Source/LexerParser -I/Users/sam/Gentoo/var/tmp/portage/dev-util/cmake-3.19.1/work/cmake-3.19.1/Source/CTest -I/Users/sam/Gentoo/var/tmp/portage/dev-util/cmake-3.19.1/work/cmake-3.19.1/Source/CPack -isystem /Users/sam/Gentoo/var/tmp/portage/dev-util/cmake-3.19.1/work/cmake-3.19.1/Utilities/std -isystem /Users/sam/Gentoo/var/tmp/portage/dev-util/cmake-3.19.1/work/cmake-3.19.1/Utilities -isystem /Users/sam/Gentoo/usr/include/jsoncpp  -march=native -O2 -pipe -mmacosx-version-min=11.0 -Wno-deprecated-declarations -std=c++17 -o CMakeFiles/CMakeLib.dir/cmTargetPropertyComputer.cxx.o -c /Users/sam/Gentoo/var/tmp/portage/dev-util/cmake-3.19.1/work/cmake-3.19.1/Source/cmTargetPropertyComputer.cxx
make[2]: *** [Source/CMakeFiles/CMakeLib.dir/build.make:2084: Source/CMakeFiles/CMakeLib.dir/cmSystemTools.cxx.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[2]: Leaving directory '/Users/sam/Gentoo/var/tmp/portage/dev-util/cmake-3.19.1/work/cmake-3.19.1_build'
make[1]: *** [CMakeFiles/Makefile2:442: Source/CMakeFiles/CMakeLib.dir/all] Error 2
make[1]: Leaving directory '/Users/sam/Gentoo/var/tmp/portage/dev-util/cmake-3.19.1/work/cmake-3.19.1_build'
make: *** [Makefile:182: all] Error 2
 * ERROR: dev-util/cmake-3.19.1::gentoo_prefix failed (compile phase):

----
Portage 3.0.10.1-prefix (python 3.7.8-final-0, prefix/darwin/macos/11.0/x64/gcc, gcc-10.1.0, unavailable, 20.1.0 x86_64)
=================================================================
System uname: Darwin-20.1.0-x86_64-i386-64bit
Timestamp of repository gentoo_prefix: Sat, 28 Nov 2020 16:58:30 +0000
Head commit of repository gentoo_prefix: 7c887c1630b20bda8ad6a5407ce37b4438b7705e
sh bash 5.1_rc3
app-shells/bash:      5.1_rc3::gentoo_prefix
dev-lang/perl:        5.30.3-r1::gentoo_prefix
dev-lang/python:      3.7.8-r2::gentoo_prefix, 3.8.5::gentoo_prefix
sys-devel/autoconf:   2.69-r5::gentoo_prefix
sys-devel/automake:   1.16.3-r1::gentoo_prefix
sys-devel/gcc:        10.1.0-r1::gentoo_prefix
sys-devel/gcc-config: 1.9.1::gentoo_prefix
sys-devel/libtool:    2.4.6-r6::gentoo_prefix
sys-devel/make:       4.3::gentoo_prefix
Repositories:

gentoo_prefix
    location: /Users/sam/Gentoo/var/db/repos/gentoo
    sync-type: rsync
    sync-uri: rsync://rsync.prefix.bitzolder.nl/gentoo-portage-prefix
    priority: -1000
    sync-rsync-verify-jobs: 1
    sync-rsync-verify-metamanifest: no
    sync-rsync-extra-opts:
    sync-rsync-verify-max-age: 24

ACCEPT_KEYWORDS="~x64-macos"
ACCEPT_LICENSE="@FREE"
CBUILD="x86_64-apple-darwin20"
CFLAGS="-march=native -O2 -pipe"
CHOST="x86_64-apple-darwin20"
CONFIG_PROTECT="/etc /usr/share/gnupg/qualified.txt"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/terminfo"
CXXFLAGS="-march=native -O2 -pipe"
DISTDIR="/Users/sam/Gentoo/var/cache/distfiles"
ENV_UNSET="CARGO_HOME DBUS_SESSION_BUS_ADDRESS DISPLAY GOBIN GOPATH PERL5LIB PERL5OPT PERLPREFIX PERL_CORE PERL_MB_OPT PERL_MM_OPT XAUTHORITY XDG_CACHE_HOME XDG_CONFIG_HOME XDG_DATA_HOME XDG_RUNTIME_DIR"
FCFLAGS=""
FEATURES="allow_broken_install_names assume-digests binpkg-docompress binpkg-dostrip binpkg-logs case-insensitive-fs config-protect-if-modified distlocks ebuild-locks fixlafiles force-prefix ipc-sandbox merge-sync multilib-strict network-sandbox news nostrip parallel-fetch pid-sandbox preserve-libs protect-owned qa-unresolved-soname-deps sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans unprivileged usersandbox"
FFLAGS=""
GENTOO_MIRRORS="http://distfiles.gentoo.org"
LANG="en_GB.UTF-8"
LDFLAGS="-Wl,-dead_strip_dylibs"
MAKEOPTS="-j4"
PKGDIR="/Users/sam/Gentoo/var/cache/binpkgs"
PORTAGE_CONFIGROOT="/Users/sam/Gentoo/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --omit-dir-times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages --exclude=/.git"
PORTAGE_TMPDIR="/Users/sam/Gentoo/var/tmp"
USE="aqua coreaudio ipv6 libglvnd ncurses nls objc objc++ prefix prefix-guest readline ssl unicode x64-macos zlib" ABI_X86="64" ADA_TARGET="gnat_2018" APACHE2_MODULES="authn_core authz_core socache_shmcb unixd actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CALLIGRA_FEATURES="karbon sheets words" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" CPU_FLAGS_X86="mmx mmxext sse sse2" ELIBC="Darwin" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock greis isync itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf skytraq superstar2 timing tsip tripmate tnt ublox ubx" INPUT_DEVICES="libinput" KERNEL="Darwin" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" LUA_SINGLE_TARGET="lua5-1" LUA_TARGETS="lua5-1" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php7-2 php7-3 php7-4" POSTGRES_TARGETS="postgres10 postgres11" PYTHON_SINGLE_TARGET="python3_7" PYTHON_TARGETS="python3_7" RUBY_TARGETS="ruby25 ruby26" USERLAND="GNU" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq steal rawnat logmark ipmark dhcpmac delude chaos account"
Unset:  CC, CPPFLAGS, CTARGET, CXX, EMERGE_DEFAULT_OPTS, INSTALL_MASK, LC_ALL, LINGUAS, PORTAGE_BINHOST, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS
Comment 1 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2020-11-28 17:58:19 UTC
Created attachment 675616 [details]
build.log
Comment 2 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2020-11-28 17:59:53 UTC
Created attachment 675619 [details]
build.log
Comment 3 Fabian Groffen gentoo-dev 2020-11-28 18:40:12 UTC
Ok, probably Catalina/Big Sur problem (>=darwin19)
Comment 4 Fabian Groffen gentoo-dev 2020-11-28 18:44:25 UTC
see also
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=248726
Comment 5 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2020-11-29 19:47:55 UTC
(In reply to Fabian Groffen from comment #4)
> see also
> https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=248726

Didn't help, I guess it's to do with the BSD/Clang libstdc++ stuff.

Interestingly, the death occurs in gcc's chrono.h - which relies on _GLIBCXX_HAVE_TIMESPEC_GET which is set to 1. Unsetting this in c++config.h 'fixes' the problem but I've got no idea why GCC believed that to be true.

I guess I need to figure out how g++config.h is setup when building gcc.
Comment 6 Fabian Groffen gentoo-dev 2020-11-29 20:13:06 UTC
Well, GLIBC isn't a thing on macOS of course, so someone is defining things that shouldn't be.  Probably, that was the BSD workaround doing: ensuring this thing wouldn't get defined.
Comment 7 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2020-11-29 21:43:42 UTC
(In reply to Fabian Groffen from comment #6)
> Well, GLIBC isn't a thing on macOS of course, so someone is defining things
> that shouldn't be.  Probably, that was the BSD workaround doing: ensuring
> this thing wouldn't get defined.

I think it's worse than that - GLIBCXX is the standard name gcc use internally for their headers, unrelated to glibc, see https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_macros.html.

I had a dig around and configure is picking it up when building libstdc++, but I didn't fully get why.

I then came across this: https://reviews.llvm.org/rG99f3b231cb21abc567c93813650cd76cfa614325

https://bugs.llvm.org/show_bug.cgi?id=47208

So... we force GCC not to detect it (because it isn't always available) via forcing ac_cv_func_timespec_get=no, or add a guard in libstdc++-v3/config.h.inc  (or libstdc++-v3/include/c_global/ctime really)?

It seems to me like this is a GCC bug in its libstdc++ implementation which was already fixed in Clang, but I don't want to rush into reporting it upstream if I'm barking up the wrong tree.
Comment 8 Fabian Groffen gentoo-dev 2020-11-30 15:39:11 UTC
timespec_get is available, but not in c++ mode:

[febe:~] fabian% gcc -o x x.c
[febe:~] fabian% g++ -o x x.c
x.c: In function ‘int main()’:
x.c:7:20: error: ‘TIME_UTC’ was not declared in this scope
    7 |  timespec_get(&ts, TIME_UTC);
      |                    ^~~~~~~~
x.c:7:2: error: ‘timespec_get’ was not declared in this scope; did you mean ‘timespec’?
    7 |  timespec_get(&ts, TIME_UTC);
      |  ^~~~~~~~~~~~
      |  timespec
[febe:~] fabian% 

this is probably due that happens in the time.h header:

#if (__DARWIN_C_LEVEL >= __DARWIN_C_FULL) && \
        ((defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) || \
        (defined(__cplusplus) && __cplusplus >= 201703L))
/* ISO/IEC 9899:201x 7.27.2.5 The timespec_get function */
#define TIME_UTC    1   /* time elapsed since epoch */
__API_AVAILABLE(macosx(10.15), ios(13.0), tvos(13.0), watchos(6.0))
int timespec_get(struct timespec *ts, int base);
#endif

By default for me, __DARWIN_C_LEVEL == __DARWIN_C_FULL and __STDC_VERSION__ is unset, while __cplusplus == 201402.  E.g. the function is not made available.
Comment 9 Fabian Groffen gentoo-dev 2020-11-30 15:41:25 UTC
(so we need g++ -std=c++17 -o x x.c)
Comment 10 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2020-11-30 15:52:42 UTC
(In reply to Fabian Groffen from comment #9)
> (so we need g++ -std=c++17 -o x x.c)

That was in CMake’s invocation though, right?
Comment 11 Fabian Groffen gentoo-dev 2020-11-30 20:16:20 UTC
this has a similar odour:

https://gitlab.kitware.com/cmake/cmake/-/issues/21135
Comment 12 Fabian Groffen gentoo-dev 2020-11-30 20:32:07 UTC
It's proven once again that messing around with POSIX standards on a UNIX system breaks stuff.

Modifying
cmLoadCommandCommand.cxx cmStandardLexer.h cmSystemTools.cxx cmTimestamp.cxx
in a way like:

-#if !defined(_WIN32) && !defined(__sun)
+#if !defined(_WIN32) && !defined(__sun) && !defined(__APPLE__)

make cmake compile without any itch here.
Comment 13 Larry the Git Cow gentoo-dev 2020-12-02 18:58:58 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=96ed1a37d7fc76b5e970158d31ce5692dbf58a12

commit 96ed1a37d7fc76b5e970158d31ce5692dbf58a12
Author:     Fabian Groffen <grobian@gentoo.org>
AuthorDate: 2020-12-02 18:58:46 +0000
Commit:     Fabian Groffen <grobian@gentoo.org>
CommitDate: 2020-12-02 18:58:54 +0000

    dev-util/cmake-3.19.1: fix compilation on Darwin
    
    Closes: https://bugs.gentoo.org/757426
    Package-Manager: Portage-3.0.9, Repoman-3.0.2
    Signed-off-by: Fabian Groffen <grobian@gentoo.org>

 dev-util/cmake/cmake-3.19.1.ebuild | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
Comment 14 Larry the Git Cow gentoo-dev 2021-02-17 22:50:14 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=a9f9f998f1fa63fea5f1c54a7e91783c6db2983b

commit a9f9f998f1fa63fea5f1c54a7e91783c6db2983b
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2021-02-17 22:49:27 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2021-02-17 22:50:03 +0000

    dev-util/cmake: fix Darwin build for 3.19.5
    
    See also: 96ed1a37d7fc76b5e970158d31ce5692dbf58a12
    Bug: https://bugs.gentoo.org/757426
    Package-Manager: Portage-3.0.14-prefix, Repoman-3.0.2
    Signed-off-by: Sam James <sam@gentoo.org>

 dev-util/cmake/cmake-3.19.5.ebuild | 2 ++
 1 file changed, 2 insertions(+)