Calypso
Calypso copied to clipboard
Build Failure with Nix: fatal error: 'typeinfo' file not found
I am working on reproducible builds for LDC and you project as well using the Nix package manager.
I have ldc
working fine however I am stuck on an issue with calypso's build when it tries to compile runtime/druntime/src/ldc/eh/cpp/unwind-cxx.h:33:10
which is from what I can tell included in line one of build/runtime/calypso_cache.h
. For some reason it cannot handle the following line as it throws fatal error: 'typeinfo' file not found
stopping the build:
#include <typeinfo>
You can test my build environment on any platform that Nix support (linux, osx, cygwin, etc.) by cloning my nix expressions for your project with instructions Nekroze/ldc-calypso.nix and you can find the output of my build (with the middle (boring) part removed) at this gist.
typeinfo
is from libstdc++, if with Nix the location of the headers has to be specified then you probably have to tweak the runtime/CMakeLists.txt
file so that during the compilation of druntime, -I
options get passed to the Clang instance with ldc2 -cpp-args -I/path/to/libstdc++/headers (...)
.
-cpp-args <Clang option>
is used to pass any command-line option to Clang, and currently each option has to be preceded by -cpp-args
:
ldc2 -cpp-args -I/include1 -cpp-args -I/include2 -cpp-args --anotherc++flag (...)
I have tried adding "-DLDC_CXXFLAGS=-I${stdenv.cc.cc}/include"
to the cmake flags however that does not seem to be passed down into the runtime/CMakeLists.txt
from what I can tell it is only used in the CMakeLists.txt
in the project root.
Could LDC_CXXFLAGS
be used in runtime/CMakeLists.txt
or does cmake not work like that? unless LDC_CXXFLAGS
is not what this is designed for and I am reading it wrong.
It seems that its the dc_flags
variable from runtime/CMakeLists.txt
that I want to add that include flag too. Do I have to modify the file to accept that or can i just add "-DDC_FLAGS=-I${stdenv.cc.cc}/include"
to the cmakeFlags that get called on the root CMakeLists.txt
?
LDC_CXXFLAGS
are the flags passed during the compilation of the ldc2
binary, not the runtime.
It seems that its the
dc_flags
variable fromruntime/CMakeLists.txt
that I want to add that include flag too. Do I have to modify the file to accept that or can i just add"-DDC_FLAGS=-I${stdenv.cc.cc}/include"
to the cmakeFlags that get called on the rootCMakeLists.txt
?
Yes that's the one but it's not modifiable with -D
. However -DRT_CFLAGS="-cpp-args -I${stdenv.cc.cc}/include"
might work.
Oops RT_CFLAGS
isn't modifiable either, the correct option is D_FLAGS
.
@Syniurge @Nekroze which flag should I pass in D_FLAGS ? (I'm on OSX) I tried: -cpp-args=-I/Users/timothee/homebrew/Cellar/gcc/7.1.0/include/c++/7.1.0/x86_64-apple-darwin16.7.0/
also tried /Users/timothee/homebrew/Cellar/[email protected]/3.9.1_1/include/c++/v1/ and /Users/timothee/homebrew/Cellar/gcc/7.1.0/include/c++/7.1.0/ but it always seem to be complaining about a missing file (eg: fatal error: 'typeinfo' file not found or some other variant depending on which include I pass)
From what i wrote while working on this i think you are going too deep into the includes. Here i just gave the include folder itself and no deeper.
your link shows: ''-DD_CFLAGS="-cpp-args -I${stdenv.cc.cc}/include"'' I'm not using nix ; how would that translate on OSX ? how would i truncate any of these? /Users/timothee/homebrew/Cellar/gcc/7.1.0/include/c++/7.1.0/x86_64-apple-darwin16.7.0/ /Users/timothee/homebrew/Cellar/[email protected]/3.9.1_1/include/c++/v1/ /Users/timothee/homebrew/Cellar/gcc/7.1.0/include/c++/7.1.0/
likewise on ubuntu? any help would be appreciated
Try truncating everything after include
using ccmake ..: D_FLAGS -cpp-args=-I/Users/timothee/homebrew/Cellar/llvm/3.9.1/include
gives: fatal error: 'typeinfo' file not found
NOTE: typeinfo is under: /Users/timothee/homebrew/Cellar/llvm/3.9.1/include/c++/v1/typeinfo
EDIT:
if I have:
-cpp-args=-I/Users/timothee/usr/local/bin/../lib/clang/3.9.0/include
I get:
missing typeinfo
If i I have -cpp-args=-I/Users/timothee/homebrew/Cellar/gcc/5.3.0/include/c++/5.3.0
I get:
exception:37:10: fatal error: 'bits/c++config.h' file not found
If I have both
-cpp-args=-I/Users/timothee/homebrew/Cellar/gcc/5.3.0/include/c++/5.3.0 -cpp-args=-I/Users/timothee/usr/local/bin/../lib/clang/3.9.0/include
I also get:
Calypso/runtime/calypso/cpp/eh/unwind-cxx.h:33:10: fatal error: 'typeinfo' file not found
is that the proper way to pass multiple -cpp-args
arguments?
Well, if calypso doesn't have all default C++ includes, you'll need to pass them explicitly.
@timotheecour try -cpp-args -stdlib=libstdc++
, the unwind-cxx.h file is from GNU's libunwind and I don't really know how it fares with libc++.
And sorry for the late lazy replying, I've put Calypso aside to focus on https://github.com/dlang/dmd/pull/7018 DMD's brittleness towards referencing errors being a blocker for many C++ libraries, especially since the latest Calypso commits. But a lot of DMD's code needs to be reorganized so it's taking longer than I thought.
What seems wrong here is that the standard lib paths should automatically be detected by Clang. But I'm not familiar and haven't tested Calypso on OS X/macOS at all yet (except the Travis-CI build which never went green), a couple of people tried in the past, IIRC it worked for @wilsonk, but that may have been before the C++ exception support.
Once the DMD PR is done I'll give something like MacInCloud a go to improve OS X support.
If -cpp-args -stdlib=libstdc++
doesn't work you can also specify the GNU libstdc++ include folders manually. On multilibs systems there are two folders to include, for example .../c++/X.X
for typeinfo
and .../<triple>/c++/X.X
for bits/c++config.h
.
is that the proper way to pass multiple -cpp-args arguments?
Yes it's one of them.
@Syniurge this worked (in the sense that make succeeds, but facing other issues, cf other https://github.com/Syniurge/Calypso/issues/60):
ccmake -D LLVM_CONFIG=$homebrew_D/Cellar/[email protected]/3.9.1_1/bin/llvm-config -D D_FLAGS="-cpp-args=-I/Users/timothee/homebrew//Cellar/gcc/7.2.0/include/c++/7.2.0;-cpp-args=-I/Users/timothee/homebrew//Cellar/gcc/7.2.0//include/c++/7.2.0/x86_64-apple-darwin17.2.0" ..
the key was to use ;
in D_FLAGS
NOTE: doesn't work with llvm/5.0.0:
Calypso/deps/clang/utils/TableGen/ClangASTNodesEmitter.cpp:50:12: error: no viable conversion from returned value of type 'llvm::Twine' to function return type 'std::string' (aka 'basic_string<char, char_traits<char>, allocator<char> >')
also doesn't work with llvm/4.0.1:
Calypso/deps/clang/utils/TableGen/ClangASTNodesEmitter.cpp:50:24: error: invalid operands to binary expression ('llvm::StringRef' and 'const std::string' (aka 'const basic_string<char, char_traits<char>, allocator<char> >'))