Skip to content

[R-pkg-devel] Question about Clang 17 Error

5 messages · Gábor Csárdi, Reed A. Cartwright, Simon Urbanek

#
My package, RBedrock, is now throwing an error when compiled against
Clang17. The error log is here:

https://www.stats.ox.ac.uk/pub/bdr/clang17/rbedrock.log

The important part is
"""
Error: package or namespace load failed for ?rbedrock? in dyn.load(file,
DLLpath = DLLpath, ...):
 unable to load shared object
'/data/gannet/ripley/R/packages/tests-clang-trunk/rbedrock.Rcheck/00LOCK-rbedrock/00new/rbedrock/libs/rbedrock.so':

/data/gannet/ripley/R/packages/tests-clang-trunk/rbedrock.Rcheck/00LOCK-rbedrock/00new/rbedrock/libs/rbedrock.so:
undefined symbol: _ZNSt3__122__libcpp_verbose_abortEPKcz
Error: loading failed
"""
the C linker when one of the dependent libraries is a C++ library.

I cannot tell if this is an issue with my package (likely) or CRAN's
clang17 setup (less likely).

Background about the package: rbedrock is written in C but links against a
C++ library (Mojang's leveldb fork)  via the library's C-API functions. I
use a dummy .cpp file in the source directory to trigger R into using the
C++ linker. That does still seem to be happening according to the log.

Has anyone seen this before and know where I should start looking to fix it?

Thanks.

--
Reed A. Cartwright, PhD
Associate Professor of Genomics, Evolution, and Bioinformatics
School of Life Sciences and The Biodesign Institute
Arizona State University
==================
Address: The Biodesign Institute, PO Box 876401, Tempe, AZ 85287-6401 USA
Packages: The Biodesign Institute, 1001 S. McAllister Ave, Tempe, AZ
85287-6401 USA
Office: Biodesign B-220C, 1-480-965-9949
Website: http://cartwrig.ht/
#
You might be able to reproduce it with the clang17 container here:
https://r-hub.github.io/containers/
You can either run it directly or with the rhub2 package:
https://github.com/r-hub/rhub2#readme

Gabor

On Wed, Sep 27, 2023 at 8:29?PM Reed A. Cartwright
<racartwright at gmail.com> wrote:
#
I was unable to reproduce the error on the rhub's clang17 docker image.

I notice that the linking command is slightly different between systems.
And this suggests that I need to find some way to get CRAN to pass -stdlib
flag at the linking stage.

CRAN:
/usr/local/clang17/bin/clang++ -std=gnu++17 -shared
-L/usr/local/clang/lib64 -L/usr/local/clang17/lib -L/usr/local/gcc13/lib64
-L/usr/local/lib64 -o rbedrock.so actors.o bedrock_leveldb.o dummy.o init.o
key_conv.o nbt.o random.o subchunk.o support.o -L./leveldb-mcpe/build
-pthread -lleveldb -lz

RHUB:
clang++-17 -stdlib=libc++ -std=gnu++14 -shared -L/opt/R/devel/lib/R/lib
-L/usr/local/lib -o rbedrock.so actors.o bedrock_leveldb.o dummy.o init.o
key_conv.o nbt.o random.o subchunk.o support.o -L./leveldb-mcpe/build
-pthread -lleveldb -lz -L/opt/R/devel/lib/R/lib -lR

On Wed, Sep 27, 2023 at 11:36?AM G?bor Cs?rdi <csardi.gabor at gmail.com>
wrote:
#
It looks like a C++ run-time mismatch between what cmake is using to build the static library and what is used by R. Unfortunately, cmake hides the actual compiler calls so it's hard to tell the difference, but that setup relies on the correct sequence of library paths.

The rhub manually forces -stdlib=libc++ to all its CXX flags
https://github.com/r-hub/rhub-linux-builders/blob/master/fedora-clang-devel/Makevars
so it is quite different from the gannet tests-clang-trunk setup (also note the different library paths), but that's not something you can do universally in the package, because it strongly depends on the toolchain setup.

Cheers,
Simon
#
Is there any way to submit packages directly to the CRAN's clang17 setup? I
can enable verbose output for CMake and compare the output, but I'd rather
not clog up the CRAN incoming queue just to debug a linker error?

On Wed, Sep 27, 2023 at 2:43?PM Simon Urbanek <simon.urbanek at r-project.org>
wrote: