Skip to content

Commit 8982117

Browse files
authored
Fix install on debian-sid + clang-19 (#272)
* add sid to docker-compose * reproducer * add fix
1 parent 8acbb87 commit 8982117

File tree

3 files changed

+69
-1
lines changed

3 files changed

+69
-1
lines changed

docker-compose.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,16 @@ services:
6363
volumes:
6464
- .:/s2
6565

66+
# CRAN incoming
67+
debian-sid-clang:
68+
build:
69+
context: .
70+
args:
71+
- IMAGE=debian:sid
72+
dockerfile: tools/docker/debian-clang.dockerfile
73+
volumes:
74+
- .:/s2
75+
6676
# This is what CRAN runs
6777
fedora-36:
6878
build:

src/init.cpp

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
1+
#include "absl/base/config.h"
2+
#include "absl/log/log.h"
23
#include "s2/s2debug.h"
34
#include <Rcpp.h>
45
using namespace Rcpp;
@@ -12,3 +13,36 @@ void cpp_s2_init() {
1213
// if there is another way to do so (e.g., constructing S2Loop and S2Polygon objects).
1314
absl::SetFlag(&FLAGS_s2debug, false);
1415
}
16+
17+
// Work around bug linking to gcc-built abseil-cpp from clang-built s2
18+
// https://github.com/r-spatial/s2/issues/271
19+
// https://github.com/abseil/abseil-cpp/issues/1747#issuecomment-2325811064
20+
namespace absl {
21+
22+
ABSL_NAMESPACE_BEGIN
23+
24+
namespace log_internal {
25+
26+
template LogMessage& LogMessage::operator<<(const char& v);
27+
template LogMessage& LogMessage::operator<<(const signed char& v);
28+
template LogMessage& LogMessage::operator<<(const unsigned char& v);
29+
template LogMessage& LogMessage::operator<<(const short& v); // NOLINT
30+
template LogMessage& LogMessage::operator<<(const unsigned short& v); // NOLINT
31+
template LogMessage& LogMessage::operator<<(const int& v);
32+
template LogMessage& LogMessage::operator<<(const unsigned int& v);
33+
template LogMessage& LogMessage::operator<<(const long& v); // NOLINT
34+
template LogMessage& LogMessage::operator<<(const unsigned long& v); // NOLINT
35+
template LogMessage& LogMessage::operator<<(const long long& v); // NOLINT
36+
template LogMessage& LogMessage::operator<<(
37+
const unsigned long long& v); // NOLINT
38+
template LogMessage& LogMessage::operator<<(void* const& v);
39+
template LogMessage& LogMessage::operator<<(const void* const& v);
40+
template LogMessage& LogMessage::operator<<(const float& v);
41+
template LogMessage& LogMessage::operator<<(const double& v);
42+
template LogMessage& LogMessage::operator<<(const bool& v);
43+
44+
} // namespace log_internal
45+
46+
ABSL_NAMESPACE_END
47+
48+
} // namespace absl

tools/docker/debian-clang.dockerfile

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
2+
ARG IMAGE=debian:testing
3+
4+
FROM ${IMAGE}
5+
6+
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \
7+
r-base cmake libcurl4-openssl-dev libssl-dev clang-19
8+
9+
# Not all versions of ubuntu/debian have libabsl-dev
10+
RUN apt-get install -y libabsl-dev || true
11+
12+
# Make sure we can use all cores to install things
13+
RUN mkdir ~/.R && echo "MAKEFLAGS = -j$(nproc)" > ~/.R/Makevars
14+
15+
# Use clang if that's what we're up to. Probably not complete
16+
# (e.g., doesn't consider C++11 or 14 or 20 or 23 compilers)
17+
RUN echo "CC=clang-19" >> ~/.R/Makevars
18+
RUN echo "CXX=clang++-19" >> ~/.R/Makevars
19+
RUN echo "CXX17=clang++-19" >> ~/.R/Makevars
20+
21+
RUN R -e 'install.packages(c("wk", "bit64", "Rcpp", "testthat"), repos = "https://cloud.r-project.org")'
22+
23+
CMD R CMD INSTALL /s2 --preclean && R -e 'testthat::test_local("/s2")'
24+

0 commit comments

Comments
 (0)