Calypso icon indicating copy to clipboard operation
Calypso copied to clipboard

import cstddef error and compiler hangs

Open John-Colvin opened this issue 9 years ago • 6 comments

% cat calypsoTest.d
modmap (C++) "ql/quantlib.hpp";

import (C++) quantlib;
% ~/Git/Calypso/build/bin/ldc2 -cpp-args -std=c++11 -L-lquantlib -L-lstdc++ calypsoTest.d
In file included from calypso_cache.h:1:
In file included from /usr/local/include/ql/quantlib.hpp:4:
In file included from /usr/local/include/ql/qldefines.hpp:38:
In file included from /usr/local/include/boost/config.hpp:44:
/usr/local/include/boost/config/select_stdlib_config.hpp:18:12: fatal error: 'cstddef' file not found
#  include <cstddef>
           ^

then the compiler hangs indefinitely. OS X 10.11.1, LLVM 3.6.2

John-Colvin avatar Oct 26 '15 10:10 John-Colvin

Thanks John for testing and sorry for the bumpy ride,

The default include paths Clang is looking into look incorrect. You can see the paths with -cpp-args -v (makes Clang verbose during PCH generation), could you check out what's wrong or missing?

Syniurge avatar Oct 26 '15 15:10 Syniurge

-cpp-args -v -std=c++11 didn't work (it didn't recognise -std=c++11), nor did -ccp-args -v -cpp-args -std=c++11 (it seemed to ignore -v), but just -cpp-args -v gave me

clang version 3.6.2 
Target: x86_64-apple-darwin15.0.0
Thread model: posix
clang -cc1 version 3.6.2 based upon LLVM 3.6.2 default target x86_64-apple-darwin15.0.0
ignoring nonexistent directory "/Users/john/Git/Calypso/build/bin/../include/c++/v1"
ignoring nonexistent directory "/usr/include/c++/v1"
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/include
 /Users/john/Git/Calypso/build/bin/../lib/clang-ldc/3.6.2/include
 /usr/include
 /System/Library/Frameworks (framework directory)
 /Library/Frameworks (framework directory)
End of search list.
In file included from calypso_cache.h:1:
In file included from /usr/local/include/ql/quantlib.hpp:4:
In file included from /usr/local/include/ql/qldefines.hpp:38:
In file included from /usr/local/include/boost/config.hpp:44:
/usr/local/include/boost/config/select_stdlib_config.hpp:18:12: fatal error: 'cstddef' file not found
#  include <cstddef>

John-Colvin avatar Oct 27 '15 00:10 John-Colvin

Where are your C++ standard lib headers located? As a workaround to the broken detection you can manually add the path with -cpp-args -isystem -cpp-args /path/to/libc++headers so cstddef may be found.

-cpp-args -v -cpp-args -std=c++11 should work btw, the purpose of -cpp-args is to append each following argument to the Clang "command line".

Syniurge avatar Oct 27 '15 00:10 Syniurge

I tried this Quantlib example on OS X also and I can't get it to work either. Some parts of Quantlib work on Linux and I tried to just copy over the build file and test file (minimal as above), but I ran into the same errors.

Trying to add '-cpp-args -I/usr/local/opt/llvm/include/c++/v1' to my command line ends up with strange control characters being printed ... along with 'error' like this:

binary    /Users/wilsonk/Downloads/calypso/build/bin/ldc2
version   1eabff (DMD v2.066.1, LLVM 3.6.2)
config    /Users/wilsonk/Downloads/calypso/build/bin/ldc2.conf
predefs   LDC all D_Version2 assert X86_64 D_InlineAsm_X86_64 D_HardFloat
          LittleEndian D_LP64 D_PIC OSX darwin Posix LDC_LLVM_306
parse     t
importall t
import    object    (/Users/wilsonk/Downloads/calypso/build/import/object.di)
error: error reading 'xã'
error: error reading 'äË'Assertion failed: (TextNormal && "Text highlighted at end of diagnostic message."), function printWordWrapped, file /Users/wilsonk/Downloads/calypso/deps/clang/lib/Frontend/TextDiagnostic.cpp, line 662.
0  ldc2                     0x0000000107288984 llvm::sys::PrintStackTrace(__sFILE*) + 57
1  ldc2                     0x0000000107288e6e SignalHandler(int) + 217
2  libsystem_platform.dylib 0x00007fff82fdaf1a _sigtramp + 26
3  ldc2                     0x0000000107c2fcbc FirstTarget + 148276
4  ldc2                     0x0000000107288cf4 abort + 22
5  ldc2                     0x0000000107288cde abort + 0
6  ldc2                     0x0000000104f87dd2 printWordWrapped(llvm::raw_ostream&, llvm::StringRef, unsigned int, unsigned int, bool, unsigned int) + 1186
7  ldc2                     0x0000000104f8784f clang::TextDiagnostic::printDiagnosticMessage(llvm::raw_ostream&, bool, llvm::StringRef, unsigned int, unsigned int, bool) + 207
8  ldc2                     0x0000000104f96bc7 clang::TextDiagnosticPrinter::HandleDiagnostic(clang::DiagnosticsEngine::Level, clang::Diagnostic const&) + 951
9  ldc2                     0x00000001063fac57 clang::DiagnosticIDs::EmitDiag(clang::DiagnosticsEngine&, clang::DiagnosticIDs::Level) const + 151
10 ldc2                     0x00000001063faa7f clang::DiagnosticIDs::ProcessDiag(clang::DiagnosticsEngine&) const + 815
11 ldc2                     0x00000001063f1021 clang::DiagnosticsEngine::ProcessDiag() + 49
12 ldc2                     0x00000001063ea603 clang::DiagnosticsEngine::EmitCurrentDiagnostic(bool) + 291
13 ldc2                     0x0000000104a600cc clang::DiagnosticBuilder::Emit() + 76
14 ldc2                     0x0000000104a60061 clang::DiagnosticBuilder::~DiagnosticBuilder() + 17
15 ldc2                     0x0000000104a59c15 clang::DiagnosticBuilder::~DiagnosticBuilder() + 21
16 ldc2                     0x0000000104ec7272 clang::CompilerInstance::InitializeSourceManager(clang::FrontendInputFile const&, clang::DiagnosticsEngine&, clang::FileManager&, clang::SourceManager&, clang::FrontendOptions const&) + 1186
17 ldc2                     0x0000000104ec6db7 clang::CompilerInstance::InitializeSourceManager(clang::FrontendInputFile const&) + 103
18 ldc2                     0x0000000104f30fa0 clang::FrontendAction::BeginSourceFile(clang::CompilerInstance&, clang::FrontendInputFile const&) + 5728
19 ldc2                     0x0000000104ec8406 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 998
20 ldc2                     0x0000000104a67366 cpp::PCH::update() + 9030
21 ldc2                     0x0000000104b53392 cpp::Import::loadModule(Loc, Array<Identifier*>*, Identifier*) + 50
22 ldc2                     0x000000010495c15b Import::load(Scope*) + 1467
23 ldc2                     0x000000010495c2b3 Import::importAll(Scope*) + 67
24 ldc2                     0x000000010499ea07 Module::importAll(Scope*) + 823
25 ldc2                     0x0000000104867b3f main + 6735
26 libdyld.dylib            0x00007fff896935c9 start + 1
27 libdyld.dylib            0x0000000000000008 start + 1989593664

Seems like something is going wrong with -cpp-args and arguments with a '/' in them??? Maybe? I tried a couple other options with '/' and the same thing happens.

I might try to look into this further, if you can't think of anything off hand that could lead to this Elie.

wilsonk avatar Oct 27 '15 18:10 wilsonk

error: error reading 'xã'
error: error reading 'ä�Ë'Assertion failed: (TextNormal && "Text highlighted at end of diagnostic message."), function printWordWrapped, file /Users/wilsonk/Downloads/calypso/deps/clang/lib/Frontend/TextDiagnostic.cpp, line 662.

It seems like Clang is reading a binary file instead of a header.

Syniurge avatar Oct 27 '15 23:10 Syniurge

A similar situation happens with the qt5demo also :(

wilsonk avatar Oct 27 '15 23:10 wilsonk