Closed eikeschott closed 1 year ago
I tried some obvious things, but got nowhere. Maybe it is worth reporting this for stringfish, because it fails the same way in a vanilla Alpine container:
docker run -ti alpine:latest sh
apk add R gcc g++ R-dev make linux-headers
R -q -e 'options(repos = "https://cloud.r-project.org"); install.packages("stringfish")'
Thank you for your quick response. I created an issue with your example over at stringfish.
I'm not familiar with alpine linux, but the error message (from the issue: https://github.com/traversc/stringfish/issues/11) suggests something with the tbb source files from RcppParallel:
../../src/tbbmalloc/proxy.cpp:27:47: error: missing binary operator before token "("
27 | #if defined(__GLIBC_PREREQ) && !__GLIBC_PREREQ(2, 16) && _GLIBCXX_HAVE_ALIGNED_ALLOC
| ^
../../src/tbbmalloc/proxy.cpp:276:26: error: return type 'struct mallinfo' is incomplete
276 | struct mallinfo mallinfo() __THROW
| ^
... (etc)
So my suspicion is that there's an issue there. It might make sense to try to do a minimal package using tbb/RcppParallel to confirm if that is the case.
Maybe TBB is not great on musl? https://patchwork.openembedded.org/patch/171846/
I think it's likely, but I think a bit more work is needed to confirm.
What is musl/alpine?
Is there a macro #define that one can check?
There is no official #define
AFAIK, but in this container we do set __MUSL__
in CFLAGS
and CXXFLAGS
.
I have identified the issue and it's indeed a RcppParallel issue, but thankfully not a serious one.
Edit: There are two issues:
Below describes the missing macro issue:
RcppParallel has this macro define:
#ifndef RCPP_PARALLEL_USE_TBB
# if defined(__APPLE__) || defined(__gnu_linux__) || (defined(__sun) && defined(__SVR4) && !defined(__sparc))
# define RCPP_PARALLEL_USE_TBB 1
# else
# define RCPP_PARALLEL_USE_TBB 0
# endif
#endif
On ubuntu, RCPP_PARALLEL_USE_TBB
should usually be set to 1 because of __gnu_linux__
, but on Alpine this macro isn't set.
The reason this isn't set on Alpine is the __gnu_linux__
macro is defined in glibc but not in musl: https://stackoverflow.com/questions/66037729/what-does-gnu-linux-stand-for
Here's a script to test these macros:
library(Rcpp)
sourceCpp(code = '
// [[Rcpp::depends(RcppParallel)]]
#include <RcppParallel.h>
#include <Rcpp.h>
// [[Rcpp::export]]
void test_macros() {
std::cout << "RCPP_PARALLEL_USE_TBB = " << RCPP_PARALLEL_USE_TBB << std::endl;
#ifdef __APPLE__
std::cout << "__APPLE__" << std::endl;
#endif
#ifdef __gnu_linux__
std::cout << "__gnu_linux__" << std::endl;
#endif
#ifdef __sun
std::cout << "__sun" << std::endl;
#endif
#ifdef __SVR4
std::cout << "__SVR4" << std::endl;
#endif
#ifdef __sparc
std::cout << "__sparc" << std::endl;
#endif
}
')
Here's a MWE that demonstrates the issue (compiles on Ubuntu, but not on Alpine).
library(Rcpp)
sourceCpp(code = '
// [[Rcpp::depends(RcppParallel)]]
#include <RcppParallel.h>
#include <Rcpp.h>
#include <cstdlib>
#if RCPP_PARALLEL_USE_TBB
#include <tbb/enumerable_thread_specific.h>
#endif
using namespace RcppParallel;
using namespace Rcpp;
struct TestWorker : public Worker {
RVector<int> output;
tbb::enumerable_thread_specific<std::vector<int>> thread_id;
TestWorker(IntegerVector output) : output(output) {}
void operator()(std::size_t begin, std::size_t end) {
for(size_t i=begin; i<end; ++i) {
thread_id.local().push_back(i);
output[i] = thread_id.local().size();
}
}
};
// [[Rcpp::export]]
IntegerVector test(size_t n) {
IntegerVector output(n);
TestWorker t(output);
parallelFor(0, n, t, 1,2);
return output;
}
')
Presumably there is a similar macro that could be checked on Alpine. It might be a good idea to ask K. Ushey's opinion, I'll leave that to you.
I believe __linux__
should be set on all Linux systems, if the goal is to detect Linux.
TBB seems to work on Alpine if you force it. Maybe there is a reason they chose to check __gnu_linux__
instead.
A year or so later, this does not seem to be a problem any more, and stringfish installs cleanly.
Hi everyone,
I'm trying to install the
qs
package but the build process fails at a dependency ofqs
calledstringfish
. Running:gives me the following message:
I'm not too familiar with the messages I'm seeing but from what I understand it might have something to do with locales and time zone data? So I tried adding
tzdata
without success.Any ideas or pointers? Thanks in advance.