wd=$(pwd)
cd ./LZ4-prefix/src/LZ4-stamp
sed -I.orig ‘s/make cmake/gmake cmake/’ LZ4-configure-RelWithDebInfo.cmake
sed -I.orig ‘s/MOREFLAGS=-fPIC make/MOREFLAGS=-fPIC gmake/’ LZ4-build-RelWithDebInfo.cmake
sed -I.orig ‘s/make install/gmake install/’ LZ4-install-RelWithDebInfo.cmake
cd ${wd}
Build
I then build thus:
cmake --build . – -j8
Error
The build fails with several messages like this:
[5064/6803] Generating G__std_valarray.cxx, …/…/lib/libvalarrayDict.rootmap
FAILED: core/clingutils/G__std_valarray.cxx lib/libvalarrayDict.rootmap
cd /home/rmason/Software/Root/64-bit/core/clingutils && /home/rmason/Software/Root/64-bit/core/rootcling_stage1/src/rootcling_stage1 -f G__std_valarray.cxx -s
/home/rmason/Software/Root/64-bit/lib/libvalarrayDict.so -excludePath /home/rmason/Software/Root/root-6.10.08 -excludePath /home/rmason/Software/Root/64-bit
-rml libvalarrayDict.so -rmf /home/rmason/Software/Root/64-bit/lib/libvalarrayDict.rootmap -I/home/rmason/Software/Root/root-6.10.08 -I/home/rmason/Software/R
oot/root-6.10.08/interpreter/cling/include -I/home/rmason/Software/Root/64-bit/include -I/home/rmason/Software/Root/root-6.10.08/interpreter/llvm/src/include
-I/home/rmason/Software/Root/64-bit/interpreter/llvm/src/include -I/home/rmason/Software/Root/root-6.10.08/interpreter/llvm/src/tools/clang/include -I/home/rm
ason/Software/Root/64-bit/interpreter/llvm/src/tools/clang/include -I/home/rmason/Software/Root/root-6.10.08/core/clingutils/res -I/home/rmason/Software/Root/
root-6.10.08/core/clingutils/…/foundation/res -I/home/rmason/Software/Root/64-bit/etc/cling/cint valarray /home/rmason/Software/Root/root-6.10.08/core/clingu
tils/src/valarrayLinkdef.h
terminate called after throwing an instance of 'std::logic_error’
what(): basic_string::_M_construct null not valid
Based on some searching, this may be caused by an attempt to assign a null pointer to a string. Unfortunately I have no idea where in the code this is happening. I would appreciate some help in tracking the problem down.
I tried a build with GCC6 and C++14 on Linux, but I cannot reproduce the issue you have.
Could you please try with the master branch instead of 6.10/08? Also, if C++14 fails, please try with C++11.
We do not have a FreeBSD machine to test, unfortunately. We’d need to set one up.
During configuration cmake complained that SITypeRewriter.cpp was
missing from ‘root/interpreter/llvm/src/lib/Target/AMDGPU/CMakeLists.txt’.
I added it.
The master branch then fails like this:
root/interpreter/llvm/src/lib/Target/AMDGPU/SITypeRewriter.cpp:154:42:
error: ‘llvm::FunctionPass* llvm::createSITypeRewriter()’ should have
been declared inside 'llvm’
FunctionPass *llvm::createSITypeRewriter() {
FAILED: core/base/G__Core.cxx lib/libCore.rootmap
cd /home/rmason/Software/Root-Master/gcc6-c++14-build/thebuild/core/base && /usr/local/bin/cmake -E env LD_LIBRARY_PATH=/home/rmason/Software/Root-Master/gcc6-c++14-build/thebuild/lib::/opt/local/lib:/opt/lib/root:/opt/lib:/home/rmason/Software/Scalapack/64-bit-cmake/lib:/opt/local/lib:/opt/lib/root:/opt/lib:/home/rmason/Software/Scalapack/64-bit-cmake/lib:/usr/local/lib/gcc6:/usr/local/lib/gcc6 /home/rmason/Software/Root-Master/gcc6-c++14-build/thebuild/core/rootcling_stage1/src/rootcling_stage1 -v2 -f G__Core.cxx [snip]
terminate called after throwing an instance of 'std::logic_error'
what(): basic_string::_M_construct null not valid
Child aborted
I got a backtrace from the core dump:
#0 0x00000008054e339a in thr_kill () from /lib/libc.so.7
#1 0x00000008054e3386 in raise () from /lib/libc.so.7
#2 0x00000008054e3309 in abort () from /lib/libc.so.7
#3 0x0000000805120b2d in __gnu_cxx::__verbose_terminate_handler () at /wrkdirs/usr/ports/lang/gcc6/work/gcc-6.4.0/libstdc++-v3/libsupc++/vterminate.cc:95
#4 0x000000080511db68 in __cxxabiv1::__terminate (handler=<optimized out>)
at /wrkdirs/usr/ports/lang/gcc6/work/gcc-6.4.0/libstdc++-v3/libsupc++/eh_terminate.cc:47
#5 0x000000080511dbd1 in std::terminate () at /wrkdirs/usr/ports/lang/gcc6/work/gcc-6.4.0/libstdc++-v3/libsupc++/eh_terminate.cc:57
#6 0x000000080511dde8 in __cxxabiv1::__cxa_throw (obj=obj@entry=0x80607f140, tinfo=0x805416a38 <typeinfo for std::logic_error>,
dest=0x8051367b0 <std::logic_error::~logic_error()>) at /wrkdirs/usr/ports/lang/gcc6/work/gcc-6.4.0/libstdc++-v3/libsupc++/eh_throw.cc:87
#7 0x000000080514ca47 in std::__throw_logic_error (__s=__s@entry=0x2eba0a8 "basic_string::_M_construct null not valid")
at /wrkdirs/usr/ports/lang/gcc6/work/gcc-6.4.0/libstdc++-v3/src/c++11/functexcept.cc:74
#8 0x00000000005e28fa in std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_construct<char const*> (
__end=0xffffffffffffffff <error: Cannot access memory at address 0xffffffffffffffff>, __beg=0x0, this=0x7fffffffac20)
at /usr/local/lib/gcc6/include/c++/bits/basic_string.tcc:212
#9 std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_construct_aux<char const*> (
__end=0xffffffffffffffff <error: Cannot access memory at address 0xffffffffffffffff>, __beg=0x0, this=0x7fffffffac20)
at /usr/local/lib/gcc6/include/c++/bits/basic_string.h:196
#10 std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_construct<char const*> (
__end=0xffffffffffffffff <error: Cannot access memory at address 0xffffffffffffffff>, __beg=0x0, this=0x7fffffffac20)
at /usr/local/lib/gcc6/include/c++/bits/basic_string.h:215
#11 std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string (__a=..., __s=0x0, this=0x7fffffffac20)
at /usr/local/lib/gcc6/include/c++/bits/basic_string.h:456
#12 GetIncludeDir () at /home/rmason/Software/Root-Master/root/core/rootcling_stage1/src/rootcling_stage1.cxx:26
#13 0x00000000005b99c1 in RootClingMain (argc=<optimized out>, argc@entry=209, argv=argv@entry=0x7fffffffcde0, isDeep=isDeep@entry=false,
isGenreflex=isGenreflex@entry=false) at /home/rmason/Software/Root-Master/root/core/dictgen/src/rootcling_impl.cxx:4219
#14 0x00000000005c62e1 in ROOT_rootcling_Driver (argc=209, argv=0x7fffffffcde0, config=...)
at /home/rmason/Software/Root-Master/root/core/dictgen/src/rootcling_impl.cxx:6099
#15 0x00000000004c7245 in main (argc=<optimized out>, argv=<optimized out>)
at /home/rmason/Software/Root-Master/root/core/rootcling_stage1/src/rootcling_stage1.cxx:45
Line 26 in root/core/rootcling_stage1/src/rootcling_stage1.cxx is
static std::string incdir = std::string(getenv("ROOTSYS")) + "/include";
In my build, ROOTSYS is unset. Running a simple test program with a call to getenv() on an unset environment variable ends with the same error as the call to rootcling_stage1:
terminate called after throwing an instance of 'std::logic_error’
what(): basic_string::_M_construct null not valid
You can probably work around this issue by setting ROOTSYS manually to the build folder (e.g. ROOTSYS=/home/username/root-build/) and then call make from that. Maybe that’s enough to make your build succeed.
In general CMake is responsible for setting this variable, but I’m not sure why this is not happening in your build setup. I started a FreeBSD build and we’ll see if it also fails there.
I see, the problem is that you have a GNU C++ library but the BSD C library, and we assume people that use the GNU C++ also use the GNU C library. Can you test this patch if it fixes it?
diff --git a/interpreter/cling/lib/Interpreter/Interpreter.cpp b/interpreter/cling/lib/Interpreter/Interpreter.cpp
index 291ac70418..569076e73e 100644
--- a/interpreter/cling/lib/Interpreter/Interpreter.cpp
+++ b/interpreter/cling/lib/Interpreter/Interpreter.cpp
@@ -404,7 +404,7 @@ namespace cling {
// Intercept all atexit calls, as the Interpreter and functions will be long
// gone when the -native- versions invoke them.
-#if defined(__GLIBCXX__) && !defined(__APPLE__)
+#if defined(__GLIBC__) && !defined(__APPLE__)
const char* LinkageCxx = "extern \"C++\"";
const char* Attr = LangOpts.CPlusPlus ? " throw () " : "";
const char* cxa_atexit_is_noexcept = LangOpts.CPlusPlus ? " noexcept" : "";
The next error I’ve encountered is that you’ll need to link with -lelf and then I get:
I think your problems appear from the mix of FreeBSD libc and the GNU STL. The problem is that the GNU STL expects to get a glibc where these functions have a different signature (glibc is in this regard really broken and clang has usually some hacks to get this somehow working).
What I would recommend is using clang and the libc++ from LLVM, not the stdlibc++ from GNU. This should get you to the state where __progname is the problem.
However, I haven’t progressed beyond this error so far. The FreeBSD mailing list doesn’t seem to have any advice on the issue and I don’t have an (easy) solution for fixing this.
I think ROOT could support FreeBSD in the future, but it seems to be a bit more work than just a few lines here and there. The only thing I can think of for getting this to work in the neare future is that you could try getting ROOT running in a Linux docker that’s hosted by FreeBSD.