Uncaught_exceptions in C++ in conda is unavailable?

63 Views Asked by At

I was using Rstudio in a conda environment to install the recount package and when it was installing the tzdb dependency, I got this error:

* installing *source* package ‘tzdb’ ...
** package ‘tzdb’ successfully unpacked and MD5 sums checked
** using staged installation
** libs
using C++ compiler: ‘clang version 17.0.6’
using SDK: ‘MacOSX10.15.sdk’
clang++ -I"~/anaconda3/envs/CONDA_ENV/lib/R/include" -DNDEBUG  -I'~/anaconda3/envs/CONDA_ENV/lib/R/library/cpp11/include' -D_FORTIFY_SOURCE=2 -isystem ~/anaconda3/envs/CONDA_ENV/include -mmacosx-version-min=10.9 -I~/anaconda3/envs/CONDA_ENV/include   -I../inst/include -DINSTALL=dummy -DAUTO_DOWNLOAD=0 -DHAS_REMOTE_API=0 -DUSE_OS_TZDB=0 -DONLY_C_LOCALE=1 -fPIC  -march=core2 -mtune=haswell -mssse3 -ftree-vectorize -fPIC -fstack-protector-strong -O2 -pipe -stdlib=libc++ -fvisibility-inlines-hidden -fmessage-length=0 -isystem ~/anaconda3/envs/CONDA_ENV/include -fdebug-prefix-map=/Users/runner/miniforge3/conda-bld/r-base-split_1709218322135/work=/usr/local/src/conda/r-base-4.3.3 -fdebug-prefix-map=~/anaconda3/envs/CONDA_ENV=/usr/local/src/conda-prefix  -c api.cpp -o api.o
In file included from api.cpp:1:

In file included from ../inst/include/date/tz.h:99:
../inst/include/date/date.h:1067:22: error: 'uncaught_exceptions' is unavailable: introduced in macOS 10.12 - see https://conda-forge.org/docs/maintainer/knowledge_base.html#newer-c-features-with-old-sdk
 1067 |                 std::uncaught_exceptions() == 0 &&
      |                      ^
~/anaconda3/envs/CONDA_ENV/bin/../include/c++/v1/exception:185:63: note: 'uncaught_exceptions' has been explicitly marked unavailable here
  185 | _LIBCPP_FUNC_VIS _LIBCPP_AVAILABILITY_UNCAUGHT_EXCEPTIONS int uncaught_exceptions() _NOEXCEPT;

I can see that uncaught_exceptions is made unavailable inside the exception file of the C++ standard library headers.

I understand that uncaught_exceptions was introduced to the libcpp system files in macOS 10.12+ (my version is 12.6.3), but either way, conda itself installs its own versions of the system files so this should not be an issue. I have tried to update my libcxx library files on conda but that did not change anything. Is it possible to change the standard library headers for C++?

1

There are 1 best solutions below

2
Howard Hinnant On

The easiest way to fix this is to tell date.h to not use std::uncaught_exceptions(). This is done by compiling with this option on the compiler command line:

-DHAS_UNCAUGHT_EXCEPTIONS=0

Or otherwise somehow ensuring that the date configuration macro HAS_UNCAUGHT_EXCEPTIONS is set to 0 by the time date.h is seen by the compiler.