From 39f58677aa5e334164902a8f4a786b00f349dd6c Mon Sep 17 00:00:00 2001 From: Mattias Ellert Date: Mar 22 2020 06:56:49 +0000 Subject: Fix for linking error seen when using root's R interface: "You are probably missing the definition of Rcpp::demangler_one(char const*)" --- diff --git a/R-Rcpp-fix-include-of-execinfo.h.patch b/R-Rcpp-fix-include-of-execinfo.h.patch new file mode 100644 index 0000000..1da36c9 --- /dev/null +++ b/R-Rcpp-fix-include-of-execinfo.h.patch @@ -0,0 +1,90 @@ +diff --git a/inst/include/Rcpp/exceptions_impl.h b/inst/include/Rcpp/exceptions_impl.h +index 48b3f46d..8f450280 100644 +--- a/inst/include/Rcpp/exceptions_impl.h ++++ b/inst/include/Rcpp/exceptions_impl.h +@@ -18,16 +18,38 @@ + // You should have received a copy of the GNU General Public License + // along with Rcpp. If not, see . + ++#ifndef Rcpp__exceptions_impl__h ++#define Rcpp__exceptions_impl__h ++ ++// disable demangler on platforms where we have no support ++#ifndef RCPP_DEMANGLER_ENABLED ++# if defined(_WIN32) || \ ++ defined(__FreeBSD__) || \ ++ defined(__NetBSD__) || \ ++ defined(__OpenBSD__) || \ ++ defined(__CYGWIN__) || \ ++ defined(__sun) || \ ++ defined(_AIX) || \ ++ defined(__MUSL__) || \ ++ defined(__HAIKU__) || \ ++ defined(__ANDROID__) ++# define RCPP_DEMANGLER_ENABLED 0 ++# elif defined(__GNUC__) || defined(__clang__) ++# include ++# define RCPP_DEMANGLER_ENABLED 1 ++# else ++# define RCPP_DEMANGLER_ENABLED 0 ++# endif ++#endif ++ + namespace Rcpp { +-#if defined(__GNUC__) || defined(__clang__) +- #if defined(_WIN32) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__CYGWIN__) || defined(__sun) || defined(_AIX) || defined(__MUSL__) || defined(__HAIKU__) || defined(__ANDROID__) +- // do nothing +- #else +- #include + + // Extract mangled name e.g. ./test(baz+0x14)[0x400962] +- static std::string demangler_one(const char* input) { // #nocov start ++#if RCPP_DEMANGLER_ENABLED ++ static inline std::string demangler_one(const char* input) { // #nocov start ++ + static std::string buffer; ++ + buffer = input; + size_t last_open = buffer.find_last_of('('); + size_t last_close = buffer.find_last_of(')'); +@@ -42,19 +64,16 @@ namespace Rcpp { + function_name.resize(function_plus); + } + buffer.replace(last_open + 1, function_name.size(), demangle(function_name)); ++ + return buffer; ++ + } +- #endif + #endif + + // thread-safe; invoked prior to throwing the exception + inline void exception::record_stack_trace() + { +- #if defined(__GNUC__) || defined(__clang__) +- #if defined(_WIN32) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__CYGWIN__) || defined(__sun) || defined(_AIX) || defined(__MUSL__) || defined(__HAIKU__) || defined(__ANDROID__) +- // C++ stack not available on this system +- #else // ! (defined(_WIN32) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__CYGWIN__) || defined(__sun) || defined(_AIX) || defined(__ANDROID__) +- ++#if RCPP_DEMANGLER_ENABLED + /* inspired from http://tombarta.wordpress.com/2008/08/01/c-stack-traces-with-gcc/ */ + const size_t max_depth = 100; + int stack_depth; +@@ -66,8 +85,7 @@ namespace Rcpp { + std::transform(stack_strings + 1, stack_strings + stack_depth, + std::back_inserter(stack), demangler_one); + free(stack_strings); // malloc()ed by backtrace_symbols +- #endif +- #endif ++#endif + } + + // not thread-safe; invoked after catching the exception +@@ -86,4 +104,7 @@ namespace Rcpp { + trace.attr("class") = "Rcpp_stack_trace"; + rcpp_set_stack_trace(trace); // #nocov end + } ++ + } ++ ++#endif diff --git a/R-Rcpp.spec b/R-Rcpp.spec index 9c6ccaf..8d07d78 100644 --- a/R-Rcpp.spec +++ b/R-Rcpp.spec @@ -4,7 +4,7 @@ Name: R-%{packname} Version: 1.0.4 -Release: 1%{?dist} +Release: 2%{?dist} Summary: Seamless R and C++ Integration # The following three files uses the Boost Software License: @@ -14,6 +14,12 @@ Summary: Seamless R and C++ Integration License: GPLv2+ and Boost URL: https://cran.r-project.org/package=%{packname} Source0: %{url}&version=%{version}#/%{packname}_%{version}.tar.gz +# Fix for linking error seen when using root's R interface: +# "You are probably missing the definition of +# Rcpp::demangler_one(char const*)" +# Missing "inline" qualifier in a header file +# https://github.com/RcppCore/Rcpp/pull/1055 +Patch0: %{name}-fix-include-of-execinfo.h.patch BuildRequires: gcc-c++ BuildRequires: R-core-devel @@ -55,6 +61,9 @@ Examples for using Rcpp. %prep %setup -q -c +pushd %{packname} +%patch0 -p1 +popd dos2unix -k \ %{packname}/inst/tinytest/cpp/InternalFunction.cpp \ @@ -111,6 +120,10 @@ _R_CHECK_FORCE_SUGGESTS_=0 %{_bindir}/R CMD check %{packname} %{_libdir}/R/library/%{packname}/examples %changelog +* Sat Mar 21 2020 Mattias Ellert - 1.0.4-2 +- Fix for linking error seen when using root's R interface: + "You are probably missing the definition of Rcpp::demangler_one(char const*)" + * Fri Mar 20 2020 Mattias Ellert - 1.0.4-1 - Update to 1.0.4 - The package no longer uses knitr for vignettes, drop --ignore-vignettes