Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Qt5 demo #17

Closed
wilsonk opened this issue May 9, 2015 · 47 comments
Closed

Qt5 demo #17

wilsonk opened this issue May 9, 2015 · 47 comments

Comments

@wilsonk
Copy link

wilsonk commented May 9, 2015

Hello Elie,

Spectacular job on getting far enough to get a Qt demo to work. Unfortunately I can't quite get it to build here :(

I am also getting a couple new errors in the libstdc++ tests, and the pertinent one is when compiling the 'set' example. The reason this is pertinent is that I get the exact same error with the Qt5 demo, but the example is so simple with set.d that it might be easier to track down. When compiling set.d with "ldc2 -L-lstdc++ set.d" I get this error:

.
.
.
semantic3 multiset
semantic3 allocator
semantic3 new_allocator
semantic3 less
semantic3 _Rb_tree_const_iterator
semantic3 _Rb_tree_node
semantic3 _Rb_tree_iterator
code      set
code      set
ldc2: /home/wilsonk/Downloads/llvm-3.6/llvm/tools/clang/lib/CodeGen/CGClass.cpp:1524: void clang::CodeGen::CodeGenFunction::EnterDtorCleanups(const clang::CXXDestructorDecl*, clang::CXXDtorType): Assertion `(!DD->isTrivial() || DD->hasAttr<DLLExportAttr>()) && "Should not emit dtor epilogue for non-exported trivial dtor!"' failed.
#0 0x3aeecca llvm::sys::PrintStackTrace(_IO_FILE*) (/home/wilsonk/Downloads/Calypso/build/bin/ldc2+0x3aeecca)
#1 0x3aeef65 PrintStackTraceSignalHandler(void*) (/home/wilsonk/Downloads/Calypso/build/bin/ldc2+0x3aeef65)
#2 0x3aedb87 SignalHandler(int) (/home/wilsonk/Downloads/Calypso/build/bin/ldc2+0x3aedb87)
#3 0x7f00f85fb340 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x10340)
#4 0x7f00f73f6cc9 gsignal /build/buildd/eglibc-2.19/signal/../nptl/sysdeps/unix/sysv/linux/raise.c:56:0
#5 0x7f00f73fa0d8 abort /build/buildd/eglibc-2.19/stdlib/abort.c:91:0
#6 0x7f00f73efb86 __assert_fail_base /build/buildd/eglibc-2.19/assert/assert.c:92:0
#7 0x7f00f73efc32 (/lib/x86_64-linux-gnu/libc.so.6+0x2fc32)
#8 0x16789e4 clang::CodeGen::CodeGenFunction::EnterDtorCleanups(clang::CXXDestructorDecl const*, clang::CXXDtorType) (/home/wilsonk/Downloads/Calypso/build/bin/ldc2+0x16789e4)
#9 0x167803f clang::CodeGen::CodeGenFunction::EmitDestructorBody(clang::CodeGen::FunctionArgList&) (/home/wilsonk/Downloads/Calypso/build/bin/ldc2+0x167803f)
#10 0x176f470 clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl, llvm::Function*, clang::CodeGen::CGFunctionInfo const&) (/home/wilsonk/Downloads/Calypso/build/bin/ldc2+0x176f470)
#11 0x164c966 clang::CodeGen::CodeGenModule::codegenCXXStructor(clang::CXXMethodDecl const*, clang::CodeGen::StructorType) (/home/wilsonk/Downloads/Calypso/build/bin/ldc2+0x164c966)
#12 0x1831dd8 (anonymous namespace)::ItaniumCXXABI::emitCXXStructor(clang::CXXMethodDecl const*, clang::CodeGen::StructorType) (/home/wilsonk/Downloads/Calypso/build/bin/ldc2+0x1831dd8)
#13 0x177e5c0 clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/home/wilsonk/Downloads/Calypso/build/bin/ldc2+0x177e5c0)
#14 0x177cd96 clang::CodeGen::CodeGenModule::EmitDeferred() (/home/wilsonk/Downloads/Calypso/build/bin/ldc2+0x177cd96)
#15 0x1779615 clang::CodeGen::CodeGenModule::Release() (/home/wilsonk/Downloads/Calypso/build/bin/ldc2+0x1779615)
#16 0x13eb180 cpp::LangPlugin::leaveModule() (/home/wilsonk/Downloads/Calypso/build/bin/ldc2+0x13eb180)
#17 0x137a3af codegenModule(Module*) (/home/wilsonk/Downloads/Calypso/build/bin/ldc2+0x137a3af)
#18 0x137ab28 Module::genLLVMModule(llvm::LLVMContext&) (/home/wilsonk/Downloads/Calypso/build/bin/ldc2+0x137ab28)
#19 0x112a7a5 genModules(Array<Module*>&, std::vector<llvm::Module*, std::allocator<llvm::Module*> >&) (/home/wilsonk/Downloads/Calypso/build/bin/ldc2+0x112a7a5)
#20 0x112bf8c main (/home/wilsonk/Downloads/Calypso/build/bin/ldc2+0x112bf8c)
#21 0x7f00f73e1ec5 __libc_start_main /build/buildd/eglibc-2.19/csu/libc-start.c:321:0
#22 0x1100f99 _start (/home/wilsonk/Downloads/Calypso/build/bin/ldc2+0x1100f99)
Aborted

And I also see that 'trivial dtor' error above when compiling the Qt5 demo (right after Calypso tries to output the code for 'allocator').

So I am not sure if you were seeing this error for set.d or qt5demo.d or not, but I am seeing it here. I don't have any extra modulemap_d files anywhere or anything...everything is the same as a few days ago when set.d worked, so I don't know what is going on.

Have you run into this before? Any ideas on how to fix it?

Thanks,
Kelly

@Syniurge
Copy link
Owner

Syniurge commented May 9, 2015

Thanks Kelly!

Which Qt version are you using? 5.4.1 here. But I forgot to push the module maps I used, which may be the cause, could you copy them into Qt5's include/ folder and give it another shot?

I think I know what's happening with set.d, I'll push a fix asap.

@Syniurge
Copy link
Owner

Syniurge commented May 9, 2015

set.d compiles fine here, are you using a different version from the one you committed?

@Syniurge
Copy link
Owner

Syniurge commented May 9, 2015

Any difference with the latest commit?

@wilsonk
Copy link
Author

wilsonk commented May 9, 2015

Hello Elie,

Yes, the last commit fixed the set example here. I have expanded the example also and will push a PR soon.

I will close this. Thanks for the quick fix.

@wilsonk wilsonk closed this as completed May 9, 2015
@wilsonk
Copy link
Author

wilsonk commented May 9, 2015

Woops, I'll reopen this as I didn't comment on the Qt5 questions you had. I am using Qt version 5.2.1 because that is what comes with Ubuntu14.04. My command line is slightly different also, with just a couple changes for the include/lib locations:

... -cpp-args -I/usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++ -cpp-args -I/usr/include/qt5 ... -L-rpath=/usr/include/qt5 -L-rpath=/usr/lib/x86_64-linux-gnu/qt5/ ...

I didn't need the modulemap files to get the demo compiled and running here :) Woohoo! Great stuff. I'll see about getting a small tutorial together at some point here.

Thanks,
Kelly

@wilsonk wilsonk reopened this May 9, 2015
@wilsonk
Copy link
Author

wilsonk commented May 10, 2015

Hello Elie,

After this demo was changed to inherit from QtWidget, I now have to use the modulemap files to get it to compile. Just so you know.

I am sure you are aware but it also takes a VERY long time to compile. Hopefully we can look at speeding things up once some other libs work.

Also as an aside, if you fix a particular test case in the libstdc++ tests with a certain push, can you make note of it, please? That will make it easier to test here, as I have several large libs that could be tested further if I knew which push fixed which problem. Otherwise, I spend a lot of time going through at least a dozen libs re-testing after each new push.

Thanks,
Kelly

@Syniurge
Copy link
Owner

Yes compilation times make testing big libs a pain. I'm looking into how to avoid running codegen over the already compiled C++ modules if the PCH hasn't changed in the meantime, that should help a bit.

Also as an aside, if you fix a particular test case in the libstdc++ tests with a certain push, can you make note of it, please? That will make it easier to test here, as I have several large libs that could be tested further if I knew which push fixed which problem. Otherwise, I spend a lot of time going through at least a dozen libs re-testing after each new push.

Ok but currently I'm focusing on getting other libs to work, and only check if the working libstdc++ examples aren't getting broken by the new commits.

@wilsonk
Copy link
Author

wilsonk commented May 10, 2015

Ok, sounds good on the compilation speed stuff. I remember you had said we may be able to use a previously compiled PCH file. Hopefully it helps a lot.

If you are working on other libs and push a fix, it would still help to know which lib that helped with. Not a big thing, it would just make things a little more clear for me :)

@wilsonk
Copy link
Author

wilsonk commented May 15, 2015

Hello Elie,

A few things today.

One: Some time in the last ten commits or so (before today) list.d has broken and is producing an LLVM codegen error.

Two: The 'Improve the mapping of MaterializeTemporaryExpr.' commit has broken the qt5demo example here. I can pull the other fixes from today and they work, but this commit causes an error with QtDummyQString. A temp being generated when instantiating a new QString, I suppose.

Three: Now for the long and fun part :) I have tried to convert the larger Qt5 demo project listed here: http://doc.qt.io/qt-4.8/qt-mainwindows-application-example.html

This took a while to do, as I had to work around quite a few problems. Now here is the first interesting (and frustrating) part...I was able to get down to about 10 errors in the conversion and it somewhat worked, then I rebuilt Calypso with today's changes and rebuilt the demo...a bunch of 'undefined refs' showed up?!? These were problems I had previously run into and had fixed!! So it really seems like the caching mechanism was helping me along previously, and then when rebuilding from scratch it bit me in the backside. Then I went on and I commented out all the 'undefined ref' issues again and start randomly trying to fix them. I can see I am making a little headway, but I have to fix things in the exact right order to get past these errors. It is just quite strange and time consuming as I have to get this correct order again, it seems. Strange.

As an example, originally QFile.isEmpty() was not being defined, but then I somehow managed to get it working yesterday (I don't know what I changed to make it work) and now it is back to an undefined ref on this one function. QFile.isNull() does work though, so I don't know why it is just this one function??

There are a bunch of other problems that we can get into later, but one main problem for the menubars and toolbars is that the QAction(QAction_) overload isn't being picked up by Calypso... ie. if I try to bulid a new QAction with a QAction_ then I get a list of ctors in the error message and QAction(QAction) is not in that list. Not sure why. (QAction(QAction_) is the last constructor in the source code, so maybe there is an off by one error somewhere??). I think I saw a similar error for a different lib before, but I could get around it by just using a different constructor, but that won't work in this case.

Now to the biggest future problem (that I would suppose you ran into)...signals/slots require the MOC compiler! I can trick Qt into thinking that we used MOC for the signals, but the slots are definitely a problem. While looking into fixing this I ran into a project by the fellow that wrote the MOC compiler called moc-ng (https://github.com/woboq/moc-ng) that uses libclang in place of MOC. Looks interesting, and like it could be spliced into Calypso to fix this issue, but I didn't know if it was worth looking into further yet. I believe that being fully compatible with Qt would be a huge deal and really allow easy cross platform GUI development with D, so I wanted to at least point this out and get your thoughts on moc-ng and it's integration into Calypso.

Thanks,
Kelly

@Syniurge
Copy link
Owner

Sorry about the breakage, I was aware of it but 3bcf445 fixes Druntime and Phobos, which have been broken since April 23rd!

For your linking errors you shouldn't have to comment out anything, but the why some symbols are missing can be quite obscure. If your translation gets past codegen and only fails at linking make a PR and I'll investigate the linking errors. I'll have a look at QAction this evening.

So it really seems like the caching mechanism was helping me along previously, and then when rebuilding from scratch it bit me in the backside.

Yes depending on what you import C++ modules .o files might be more or less big, and whenever you import more modules emitted symbols might be spread across more .o files.

However if beforehand you were importing more C++ modules then there's a risk that a cached module object file depends on another object file that isn't being linked anymore.

So the caching is fragile for the time being, I need to emit the functions differently to avoid this.

When you get a doubt remove the calypso_cache.gen file.

Now to the biggest future problem (that I would suppose you ran into)...signals/slots require the MOC compiler! I can trick Qt into thinking that we used MOC for the signals, but the slots are definitely a problem.

Couldn't moc be replaced by D templates and mixins? I think QtD did something like that and here's an almost successful attempt to replace moc by C++11 features: http://woboq.com/blog/reflection-in-cpp-and-qt-moc.html

@wilsonk
Copy link
Author

wilsonk commented May 15, 2015

Sorry about the breakage, I was aware of it but 3bcf445 fixes Druntime and Phobos, which have been broken since April 23rd! *

Right, I had fixed Druntime and Phobos a couple weeks back with a few edits and hadn't thought about it since. Then with that change I had to revert my fixes, so I figured that is what you trying to fix. With the newest commit today for temporaries, the qt5demo project builds again, thanks.

So the caching is fragile for the time being, I need to emit the functions differently to avoid this. *

Ok, sounds good. I assumed it was a little fragile...but after looking into this a little more it doesn't seem to be the caching that is completely responsible for this. What appears to have happened is that I changed the build command to use optimization (-O3 specifically because it sped up builds even more than just caching) and that is when things broke. So it appears as though functions like QFile.isEmpty() are being optimized out, but since I hadn't rebuilt from scratch in a while, I didn't get the errors until a complete rebuild. I have rebuilt the entire project without any optimizations and everything works fine again (except the 10 or so errors I previously had).

Couldn't moc be replaced by D templates and mixins? I think QtD did something like that and here's an almost successful attempt to replace moc by C++11 features: http://woboq.com/blog/reflection-in-cpp-and-qt-moc.html *

Yes, I suppose we could look at something like what QtD is doing, but I think that is probably a few thousand lines of code (after a quick perusal), whereas I would think the moc-ng solution is probably more comprehensive and less fragile. There are a few thousand lines in moc-ng also, but there might be quite a bit of overlap with Calypso...I can take a look.

I didn't mention the C++11 fix because our C++11 support is a little spotty and that solution wasn't completely successful...moc-ng is mentioned in the last line of that page, which is actuall how I found it :)

Thanks,
Kelly

@Syniurge
Copy link
Owner

There are a bunch of other problems that we can get into later, but one main problem for the menubars and toolbars is that the QAction(QAction) overload isn't being picked up by Calypso... ie. if I try to bulid a new QAction with a QAction then I get a list of _ctors in the error message and QAction(QAction) is not in that list. Not sure why. (QAction(QAction) is the last constructor in the source code, so maybe there is an off by one error somewhere??).

I don't see it in Qt 5.4.1, this is what I have:

    explicit QAction(QObject* parent);
    QAction(const QString &text, QObject* parent);
    QAction(const QIcon &icon, const QString &text, QObject* parent);

    (...)

private:
    Q_DISABLE_COPY(QAction)  // expands to QAction (const QAction &) = delete ;

Or did you mean the first one? Try an explicit cast:

    cast(QObject*) yourAction

No idea why DMD does implicit casting from a class reference to the same class pointer yet doesn't do implicit casting from a derived class reference to the base class pointer.

@wilsonk
Copy link
Author

wilsonk commented May 16, 2015

Hello Elie,

Sorry about that, I was looking at some old 4.x code online (I think it was 4.x) and didn't look at the 5.2.1 code. I have the same code as you above and I get past the error with the explicit cast (though I could have swore I tried that, as I have had to explicitly cast in other places)...thanks, though...now the problem is that I try to add the action to a menubar like this:

    fileMenu = (cast(QMenuBar*)menuBar()).addMenu(new QString("&File"));
    (cast(QWidget)fileMenu).addAction(&newAct);

I noticed that I needed to explicitly cast fileMenu to a QWidget (or I get a similar _ctor error as with QAction). That is fine ... the newAct action is properly set up in createActions() without problems, but when I run this I get:

0x00007ffff772804b in QWidget::setParent(QWidget_, QFlagsQt::WindowType) () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
(gdb) bt
#0 0x00007ffff772804b in QWidget::setParent(QWidget_, QFlagsQt::WindowType) () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#1 0x00007ffff77282aa in QWidgetPrivate::init(QWidget_, QFlagsQt::WindowType) () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#2 0x00007ffff7857efe in QMenu::QMenu(QString const&, QWidget_) () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#3 0x00007ffff7863bf5 in QMenuBar::addMenu(QString const&) () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5

So I try to work around this by explicitly setting the parent with:

    auto mb = new QMenuBar(parentWin);
    fileMenu = mb.addMenu(new QString("&File"));
    (cast(QWidget*)fileMenu).addAction(&newAct);

but then I get this:

0x00007ffff7720f2c in QWidget::insertAction(QAction_, QAction_) () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
(gdb) bt
#0 0x00007ffff7720f2c in QWidget::insertAction(QAction_, QAction_) () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#1 0x000000000040976f in qt5demo.MainWindow.createMenus() (this=0x7ffff7ebde00) at qt5demo.d:146 ...

Ugh. So I can't really see how to get past this part. Even if all this works the actions still need a signal/slot and connection, but I would like to at least be able to see the menubars being constucted and showing up in the example.

I could post the entire bunch of code if you wanted to look at it.

Thanks,
Kelly

@Syniurge
Copy link
Owner

Hi Kelly,

I may have figured out the cause, which is also why the explicit casts were needed, this wasn't DMD's fault. I'm working on a fix but it's not a simple one.

@wilsonk
Copy link
Author

wilsonk commented May 24, 2015

Hey Elie,

Just wondering how this fix is coming as I haven't heard from you since last weekend? :) I was also wondering if you are going to the D Conference next week? I am not planning to at this point, just so you know.

I have fixed a couple things here to get the GDAL example to work, and to see if I could get a Quantlib example to work. Small things like ParenListExpr returning a new NullExpr in fromExpression, just to get past a crash and backtrace...I also fleshed out MemberExpr, as it is needed to compile my Quantlib example.

I can work out a PR for these things eventually, but they aren't critical and I didn't want to bother you too much ;)

Thanks,
Kelly

@Syniurge
Copy link
Owner

Hi Kelly,

I haven't had a moment for myself for 2/3 of the week, it's only now that I can come back to coding, in a pretty new environment :)

And no, I wanted to come at DConf but there's been an unexpected incident at my work and I need to be there on Monday and Tuesday.

About the fix the issue is that I thought D was like C++ and that « SomeClass* » is a pointer to the value, but in D it's a pointer to the reference. Albeit wrong this simplified things a great deal because it was easier to keep a 1-to-1 correspondance between DMD and Clang's types. Now DMD's TypeClass isn't enough and has to keep more info for C++ classes: pointer or reference? logical const?

This part is fixed, but also broken was the template argument deduction e.g for default arguments, DMD's deduction is "incorrect" because the additional info for C++ classes is lost. So I'm currently telling Calypso to use Clang's argument deduction. But this will put a lot more on the shoulders of toExpression and toType which are still a bit primitive.

Here's why it's taking some time..

@wilsonk
Copy link
Author

wilsonk commented May 28, 2015

Were we supposed to write a tutorial before the Conference tomorrow? I haven't started one yet because I was going to use the GDAL example, but it needs some of my local changes to work.

We could just use the Qt example but it might seem a little feature incomplete without a signal/slot solution, as that is a major part of the gui really.

@Syniurge
Copy link
Owner

Sorry, I couldn't get the time and also couldn't make the demo + the tour of Calypso workings I told Walter about. Starting from today I'm on vacations for 10 days, but work and moving to a new place made me miss the deadline.

The GDAL example would make a great tutorial. I'll go back to your PR straight after finishing the fix (in a few hours hopefully) and try to understand why it's needed.

@Syniurge
Copy link
Owner

I keep running into new errors..

@wilsonk
Copy link
Author

wilsonk commented May 29, 2015

Ugh, that's too bad, I thought we were pretty close on this one :(

Do you still think it is manageable eventually, or is Qt a no-go for the foreseeable future?

@Syniurge
Copy link
Owner

Finally, phew!

Could you try the Qt example you were working on again? I think it should be fixed now, and no more explicit casts needed.

@wilsonk
Copy link
Author

wilsonk commented May 29, 2015

Great stuff Elie. After just a quick download and test, things look good here for the expanded demo (no casts needed).

I will continue to test here and try a few things in the demo that I had to work around in the past. I will also test GDAL some more and see how it goes. I'll let you know later tonight, probably.

@wilsonk
Copy link
Author

wilsonk commented May 30, 2015

This is good now, several new things work in the expanded Qt5 example. I can actually add actions the the menubar and display icons (the menubar reacts to clicks to open and close the popup menu, but there is no action associated yet because of the signal/slot problem still).

There was several other fixes, like no segfault on shutdown, being able to pring "File Loaded" in the statusbar on the bottom of the window and no segfault when trying to setModified(false) for the textEdit widget. Hopefully I can fully flesh this thing out by tomorrow, with all the menus and toolbars, etc. (everything except the signal/slots), then I'll push the demo.

I will also look into expanding the GDAL demo since it seems to be working nicely now.

@wilsonk
Copy link
Author

wilsonk commented Jun 28, 2015

Hey Elie,

Things look like they are pretty much back to where they were a couple weeks back, except that I can't seem to coerce a parameter to a 'ref (const) QString', for example.

So if I try to just construct a QMessageBox like this:

QMessageBox.about(&parentWin, cast(const)QString("About Application"), cast(const)QString("The Application"));

then I get the error:

qt5demo.d(117): Error: function cpp.QMessageBox.QMessageBox.about (QWidget* parent, ref const(QString) title, ref const(QString) text) is not callable using argument types (QWidget*, const(QString), const(QString))

QMessageBox's signature is:

QMessageBox(Icon icon, const QString & title, const QString & text, StandardButtons buttons = NoButton, QWidget * parent = 0, Qt::WindowFlags f = Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint)

This happens in quite a few places in my expanded example. So I guess the question is: can I coerce this somehow, or does Calypso have to do it for me? :)

Thanks,
Kelly

@Syniurge
Copy link
Owner

Hey Kelly,

That's because ref parameters still don't take rvalues in D (there seems to be an end in sight: http://forum.dlang.org/thread/mm81tt$bph$1@digitalmars.com, let's hope it gets somewhere)

It's ugly but turning them into lvalues should work:

auto aboutStr = QString("About Application");
auto appStr = QString("The Application");
QMessageBox.about(&parentWin, aboutStr, appStr);

@Syniurge
Copy link
Owner

Did we cover the gist of it?

@wilsonk
Copy link
Author

wilsonk commented Aug 18, 2015

Hmm, I am getting all kinds of errors for qtdemo now? (Dozens of other warnings and possibly a few errors before the output below also!!). This is with clang-3.6.1:

/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/ostream:96:13: error: cannot define the implicit copy assignment operator for 'class std::basic_ostream<char, struct std::char_traits<char> >::sentry', because non-static reference member '_M_os' can't use copy assignment operator
      class sentry;
            ^
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/ostream:404:40: note: declared here
      basic_ostream<_CharT, _Traits>&   _M_os;
                                        ^
note: implicit copy assignment operator for 'class std::basic_ostream<char, struct std::char_traits<char> >::sentry' first required here
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/streambuf(129): Error: undefined identifier _CharT
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/streambuf(120): Error: template instance cpp.std.basic_streambuf.basic_streambuf!(char, char_traits!char) error instantiating
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/iosfwd(77):        instantiated from here: basic_ios!(char, char_traits!char)
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/streambuf(120): Error: undefined identifier _CharT
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/bits/streambuf_iterator.h(236): Error: template instance basic_streambuf!(_CharT, char_traits!char) is used as a type
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/iosfwd(86): Error: undefined identifier _CharT
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/bits/streambuf_iterator.h(241): Error: template instance basic_ostream!(_CharT, char_traits!char) is used as a type
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/bits/streambuf_iterator.h(245): Error: template instance basic_streambuf!(_CharT, char_traits!char) is used as a type
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/bits/streambuf_iterator.h(250): Error: undefined identifier _CharT
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/bits/streambuf_iterator.h(279): Error: undefined identifier const(_CharT)
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/bits/streambuf_iterator.h(223): Error: undefined identifier _CharT
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/bits/streambuf_iterator.h(216): Error: template instance cpp.std.ostreambuf_iterator.ostreambuf_iterator!(char, char_traits!char) error instantiating
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/iosfwd(77):        instantiated from here: basic_ios!(char, char_traits!char)
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/bits/basic_ios.h(103): Error: template instance num_put!(char, .std.ostreambuf_iterator.ostreambuf_iterator!(char, char_traits!char)) is used as a type
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/bits/stl_iterator_base_types.h(118): Error: undefined identifier _CharT
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/bits/stl_iterator_base_types.h(118): Error: undefined identifier _CharT
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/bits/stl_iterator_base_types.h(118): Error: undefined identifier _CharT
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/streambuf(120): Error: undefined identifier _CharT
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/bits/streambuf_iterator.h(97): Error: template instance basic_streambuf!(_CharT, char_traits!char) is used as a type
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/iosfwd(83): Error: undefined identifier _CharT
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/bits/streambuf_iterator.h(112): Error: template instance basic_istream!(_CharT, char_traits!char) is used as a type
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/bits/streambuf_iterator.h(116): Error: template instance basic_streambuf!(_CharT, char_traits!char) is used as a type
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/bits/streambuf_iterator.h(64): Error: undefined identifier _CharT

@Syniurge
Copy link
Owner

Damn.. are you enabling C++11 by any chance?

On my config the demo compiles fine with C++11 disabled, but I have libstdc++ 4.9 installed instead of 4.8.

If you confirm that C++11 was disabled, then I'll investigate with libstdc++ 4.8.

@Syniurge Syniurge reopened this Aug 18, 2015
@Syniurge
Copy link
Owner

Oops I broke the Qt demo with the latest commits, should have tested before the push.

Just to be clear to compile the demo one hour ago I checkout'd the last commit from two days ago.

@Syniurge
Copy link
Owner

Fixed by 7ad2f8d.

@wilsonk
Copy link
Author

wilsonk commented Aug 19, 2015

Ugh, we must be using different versions of libstdc++ and Qt or something??? I am not enabling c++11 support. I am just using the example qtdemo5.d from Calypso's github (not my modified version that I was testing months ago), and the same build script I have been using for months.

I get hundreds of errors like this (and then the same errors I listed in my last comment) even after 7ad2f8d ... I didn't mention them above because I just thought they were warnings (I usually get a ton of warnings when compiling the demo):

note: implicit copy assignment operator for 'struct QHashDummyNode<class QGraphicsView *, struct QHashDummyValue>' first required here
/usr/include/qt5/QtCore/./qhash.h:219:8: error: cannot define the implicit copy assignment operator for 'struct QHashDummyNode<class QGraphicsView *, struct QHashDummyValue>', because non-static const member 'key' can't use copy assignment operator
struct QHashDummyNode
       ^
/usr/include/qt5/QtCore/./qhash.h:223:15: note: declared here
    const Key key;
              ^
note: implicit copy assignment operator for 'struct QHashDummyNode<class QGraphicsView *, struct QHashDummyValue>' first required here
/usr/include/qt5/QtCore/./qhash.h:206:8: error: cannot define the implicit copy assignment operator for 'struct QHashNode<class QGraphicsWidget *, struct QHashDummyValue>', because non-static const member 'h' can't use copy assignment operator
struct QHashNode
       ^
/usr/include/qt5/QtCore/./qhash.h:209:16: note: declared here
    const uint h;
               ^
note: implicit copy assignment operator for 'struct QHashNode<class QGraphicsWidget *, struct QHashDummyValue>' first required here
/usr/include/qt5/QtCore/./qhash.h:206:8: error: cannot define the implicit copy assignment operator for 'struct QHashNode<class QGraphicsWidget *, struct QHashDummyValue>', because non-static const member 'key' can't use copy assignment operator
struct QHashNode
       ^
/usr/include/qt5/QtCore/./qhash.h:210:15: note: declared here
    const Key key;
              ^
note: implicit copy assignment operator for 'struct QHashNode<class QGraphicsWidget *, struct QHashDummyValue>' first required here
/usr/include/qt5/QtCore/./qhash.h:219:8: error: cannot define the implicit copy assignment operator for 'struct QHashDummyNode<class QGraphicsWidget *, struct QHashDummyValue>', because non-static const member 'h' can't use copy assignment operator
struct QHashDummyNode
       ^
/usr/include/qt5/QtCore/./qhash.h:222:16: note: declared here
    const uint h;
               ^
note: implicit copy assignment operator for 'struct QHashDummyNode<class QGraphicsWidget *, struct QHashDummyValue>' first required here
/usr/include/qt5/QtCore/./qhash.h:219:8: error: cannot define the implicit copy assignment operator for 'struct QHashDummyNode<class QGraphicsWidget *, struct QHashDummyValue>', because non-static const member 'key' can't use copy assignment operator
struct QHashDummyNode

@Syniurge
Copy link
Owner

The "error:" lines are from Clang, it's noise when it fails to instantiate templates which are then just marked invalid and not used, I haven't looked yet into how to turn the diagnostics off. Most libs making big usage of templates have a lot of those errors.

It's the "Error:" lines from DMD which are not good. If you're not enabling C++11 then I'll have to look into it tomorrow..

BTW I forced a push with b23a25b because a last-minute change was wrong and the fix was not working anymore, sorry about that.

@Syniurge
Copy link
Owner

Hi Kelly,

I finally got to test with libstdc++ 4.8 and it compiles fine. Does the "Error:" lines still happen to you?

My environment is:

@wilsonk
Copy link
Author

wilsonk commented Aug 26, 2015

I'm using Qt 5.2.1, clang 3.6.1 and libstdc++3.4?? I guess. Not sure how I have that old of a std c++ lib with g++-4.8 installed?

I get this set of errors:

Error: mutable method cpp.QHashDummyValue.QHashDummyValue.~this is not callable using a immutable object
/usr/include/qt5/QtCore/./qhash.h(206): Error: template instance cpp.QHashNode.QHashNode!(QHashDummyValue, QHashDummyValue) error instantiating
/usr/include/qt5/QtCore/./qdatastream.h(63):        instantiated from here: QHash!(QHashDummyValue, QHashDummyValue)
/usr/include/qt5/QtCore/./qlist.h(65):        instantiated from here: QSet!(QHashDummyValue)
(197):        instantiated from here: QList!(QHashDummyValue)
/usr/include/qt5/QtCore/./qdatastream.h(63):        instantiated from here: QHash!(QByteArray, QHashDummyValue)
/usr/include/qt5/QtCore/./qlist.h(65):        instantiated from here: QSet!(QByteArray)
/usr/include/qt5/QtCore/./qbytearray.h(119):        instantiated from here: QList!(QByteArray)
Error: mutable method cpp.QHashDummyValue.QHashDummyValue.~this is not callable using a immutable object
/usr/include/qt5/QtCore/./qhash.h(219): Error: template instance cpp.QHashDummyNode.QHashDummyNode!(QHashDummyValue, QHashDummyValue) error instantiating
/usr/include/qt5/QtCore/./qdatastream.h(63):        instantiated from here: QHash!(QHashDummyValue, QHashDummyValue)
/usr/include/qt5/QtCore/./qlist.h(65):        instantiated from here: QSet!(QHashDummyValue)
(197):        instantiated from here: QList!(QHashDummyValue)
/usr/include/qt5/QtCore/./qdatastream.h(63):        instantiated from here: QHash!(QByteArray, QHashDummyValue)
/usr/include/qt5/QtCore/./qlist.h(65):        instantiated from here: QSet!(QByteArray)
/usr/include/qt5/QtCore/./qbytearray.h(119):        instantiated from here: QList!(QByteArray)

Followed by a seg fault with this partial stack trace:

#0 0x24abc48 llvm::sys::PrintStackTrace(_IO_FILE*) (/home/wilsonk/Downloads/Calypso/build/bin/ldc2+0x24abc48)
#1 0x24ad1cb SignalHandler(int) (/home/wilsonk/Downloads/Calypso/build/bin/ldc2+0x24ad1cb)
#2 0x7f0e70a53340 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x10340)
#3 0x7f0e6fa3e6ad (/usr/lib/x86_64-linux-gnu/libstdc++.so.6+0x5b6ad)
#4 0x7f0e6fa9e4e9 std::string::assign(std::string const&) (/usr/lib/x86_64-linux-gnu/libstdc++.so.6+0xbb4e9)
#5 0x79d593 TemplateDeclaration::syntaxCopy(Dsymbol*) /home/wilsonk/Downloads/Calypso/dmd2/template.c:565:5
#6 0x92ec3f llvm::SmallVectorTemplateCommon<clang::TemplateParameterList const*, void>::isSmall() const /usr/local/include/llvm/ADT/SmallVector.h:86:12
#7 0x92ec3f llvm::SmallVectorImpl<clang::TemplateParameterList const*>::~SmallVectorImpl() /usr/local/include/llvm/ADT/SmallVector.h:405:0
#8 0x92ec3f cpp::TypeMapper::~TypeMapper() /home/wilsonk/Downloads/Calypso/dmd2/cpp/cpptypes.h:60:0
#9 0x92ec3f cpp::FuncDeclaration::cppSemantic(FuncDeclaration*, Scope*) /home/wilsonk/Downloads/Calypso/dmd2/cpp/cppdeclaration.cpp:228:0
#10 0x92ed8f cpp::FuncDeclaration::semantic(Scope*) /home/wilsonk/Downloads/Calypso/dmd2/cpp/cppdeclaration.cpp:234:24
#11 0x7a6ed1 TemplateInstance::expandMembers(Scope*) /home/wilsonk/Downloads/Calypso/dmd2/template.c:6222:9
#12 0x7a6ed1 TemplateInstance::tryExpandMembers(Scope*) /home/wilsonk/Downloads/Calypso/dmd2/template.c:6242:0
#13 0x7a33db TemplateInstance::semantic(Scope*, Array<Expression*>*) /home/wilsonk/Downloads/Calypso/dmd2/template.c:6678:5
#14 0x9309bf cpp::DeclReferencer::Reference(clang::NamedDecl const*) /home/wilsonk/Downloads/Calypso/dmd2/cpp/cppdeclaration.cpp:390:9
#15 0x934cbb clang::DeclRefExpr::hasQualifier() const /usr/local/include/clang/AST/Expr.h:1007:38
#16 0x934cbb clang::DeclRefExpr::getQualifierLoc() const /usr/local/include/clang/AST/Expr.h:1021:0
#17 0x934cbb clang::RecursiveASTVisitor<cpp::DeclReferencer>::TraverseDeclRefExpr(clang::DeclRefExpr*) /usr/local/include/clang/AST/RecursiveASTVisitor.h:1974:0

@Syniurge
Copy link
Owner

I've fixed these errors with Qt 5.2, but now I'm getting obscure errors once more with Clang modules. Trying to figure this out..

Syniurge added a commit that referenced this issue Aug 30, 2015
…t location to determine the Clang module for a decl.

0d43a79 was wrong, and can be reverted because it was trying to fix the location of extern C decls which are skipped anyway by DeclReferencer (as a workaround until Clang 3.7).

This fixes the Qt5 demo compilation against Qt 5.2.1 (#17).
@Syniurge
Copy link
Owner

Fixed with the latest commit.

@wilsonk
Copy link
Author

wilsonk commented Aug 30, 2015

Ugh, it looks like things changed but they aren't fixed for me darnit:

#0 0x24ac718 llvm::sys::PrintStackTrace(_IO_FILE*) (/home/wilsonk/Downloads/Calypso/build/bin/ldc2+0x24ac718)
#1 0x24adc9b SignalHandler(int) (/home/wilsonk/Downloads/Calypso/build/bin/ldc2+0x24adc9b)
#2 0x7f2b20ff2340 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x10340)
#3 0x9310d8 cpp::DeclReferencer::Reference(clang::NamedDecl const*) /home/wilsonk/Downloads/Calypso/dmd2/cpp/cppdeclaration.cpp:375:19
#4 0x93554b clang::DeclRefExpr::hasQualifier() const /usr/local/include/clang/AST/Expr.h:1007:38
#5 0x93554b clang::DeclRefExpr::getQualifierLoc() const /usr/local/include/clang/AST/Expr.h:1021:0
#6 0x93554b clang::RecursiveASTVisitor<cpp::DeclReferencer>::TraverseDeclRefExpr(clang::DeclRefExpr*) /usr/local/include/clang/AST/RecursiveASTVisitor.h:1974:0

@Syniurge
Copy link
Owner

I see what's happening, DeclReferencer assumes that all the specializations of a template are within the same module whereas they are scattered across QtCore, QtWidgets, etc.

In this case it's also because the module map file from utils/ is tailored for Qt 5.4/5.5, so some template specs end up in "_". It worked for me after I adjusted the QtCore.modulemap_d file for Qt 5.2 with:

cd include/QtCore
ls q*.h >header.list
modularize -root-module=QtCore -module-map-path=QtCore.modulemap ./header.list
egrep -v "^  (module|  export|\})" QtCore.modulemap >QtCore.modulemap_d

Here's a working file: https://paste.kde.org/pummmw66h

Still DeclReferencer needs fixing..

@wilsonk
Copy link
Author

wilsonk commented Aug 31, 2015

Woot, woot!! That worked. Builds and runs fine now, thanks Elie :)

I will test my larger example also.

@wilsonk
Copy link
Author

wilsonk commented Aug 31, 2015

The bigger example runs pretty well again. A few lines that used to need a work around are now running fine, also, so things are better now. Just the signal/slot problem, so hopefully I can flesh out a full example now soon.

@Syniurge
Copy link
Owner

Syniurge commented Sep 1, 2015

The build was broken again by enabling debug info, but it should still be working without "-g" though.

I'll look into it this evening.

@Syniurge
Copy link
Owner

Syniurge commented Sep 5, 2015

Still trying to figure this out, plus another new error with QColor.

One very ugly workaround for the first error is to add modmap (C++) <5.5.0/QtCore/private/qmutex_p.h>; to qt5demo.d so that QMutexData gets defined.

@Syniurge
Copy link
Owner

Syniurge commented Sep 6, 2015

The QColor error is fixed, without -g the demo builds again.

@wilsonk
Copy link
Author

wilsonk commented Sep 6, 2015

Yep, it is working here again. Thx

@wilsonk
Copy link
Author

wilsonk commented Sep 10, 2015

Hello Elie, I have a fully functional (except writing out settings??) demo of this example finally:

http://doc.qt.io/qt-4.8/qt-mainwindows-application-example.html

I have the signals and slots working and everything now...woohoo :)

We need to use the moc compiler and have a minimal C++ 'DLangMainWindow' class inheriting from QtMainWindow, then inherit from DLangMainWindow in the D code, catch the Qt signals and translate them into D signals. A few hoops to jump through but not TOO arduous once there is a small framework set up.

I will make up a PR for this and the fastflow example in the next couple days. Might try to flesh out the Makefile a little more, so that the moc compiling steps are easier (just three steps though, so easy enough). Just too tired to do it now.

@Syniurge
Copy link
Owner

Hi Kelly, awesome news! And the workaround sounds minimal and elegant.

As for me this week can be summed up by me getting bogged down trying to fix the debug info error, which is due to C++ relying on lazy instantiation whereas DMD instantiate everything, so I'm not even sure yet that it's possible to fix this without modifying Clang.

@Syniurge
Copy link
Owner

Debug info generation was fixed about 10 days ago.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants