www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Building a project with CMAKE

reply berni <berni example.com> writes:
I'm using CMAKE to build my project. With 
https://github.com/dcarp/cmake-d this works almost. The only 
thing I do not manage to get working is running cmake in release 
mode. When I use -DCMAKE_BUILD_TYPE=Release I get some linker 
errors, which I do not get, when compiling manually. (In both 
cases gdc/linux is used.)

I allready could figure out, that it's due to the -O3 compiler 
flag used in release mode. It looks like cmake compiles all *.d 
files separately and while doing so, removes some functions when 
optimizing them. Later, when linking everything together, they 
are missing. (But I'm not sure on this.)

Here is my project: https://github.com/crocopaw/croco/tree/devel

Anybody here who has experience with CMAKE and D and could help?
Feb 28 2017
next sibling parent reply berni <berni example.com> writes:
On Tuesday, 28 February 2017 at 17:09:28 UTC, berni wrote:
 I'm using CMAKE to build my project. [...]
Just a note: I now asked the same question on the cmake mailing list. Maybe, it's the better place to do so...
Mar 02 2017
next sibling parent Nicholas Wilson <iamthewilsonator hotmail.com> writes:
On Thursday, 2 March 2017 at 09:13:40 UTC, berni wrote:
 On Tuesday, 28 February 2017 at 17:09:28 UTC, berni wrote:
 I'm using CMAKE to build my project. [...]
Just a note: I now asked the same question on the cmake mailing list. Maybe, it's the better place to do so...
I would take a look at what ldc does with their CMakeLists.txt[1] and associated files. 1: https://github.com/ldc-developers/ldc/blob/master/CMakeLists.txt
Mar 02 2017
prev sibling parent reply berni <berni example.com> writes:
On Thursday, 2 March 2017 at 09:13:40 UTC, berni wrote:
 Just a note: I now asked the same question on the cmake mailing 
 list. Maybe, it's the better place to do so...
After some help of cmake people and a morning of more investigations, I'm quite sure I found a bug in gdc. Meanwhile I've got a small example that compiles with gdc but leads to a linking error when compiled with -O3.
Mar 03 2017
parent reply Seb <seb wilzba.ch> writes:
On Friday, 3 March 2017 at 10:21:51 UTC, berni wrote:
 On Thursday, 2 March 2017 at 09:13:40 UTC, berni wrote:
 Just a note: I now asked the same question on the cmake 
 mailing list. Maybe, it's the better place to do so...
After some help of cmake people and a morning of more investigations, I'm quite sure I found a bug in gdc. Meanwhile I've got a small example that compiles with gdc but leads to a linking error when compiled with -O3.
Is there any specific reason why you can't use DMD or LDC? It's easy to install: curl i.dlang.io | bash -s ldc (they both have a more recent front-end which might save you a lot of pain)
Mar 03 2017
parent reply berni <berni example.com> writes:
On Friday, 3 March 2017 at 13:21:56 UTC, Seb wrote:
 Is there any specific reason why you can't use DMD or LDC?
gdc produces faster binaries. ;-) I've got installed the other two compilers too and they work.
Mar 03 2017
parent reply =?UTF-8?Q?Ali_=c3=87ehreli?= <acehreli yahoo.com> writes:
On 03/03/2017 06:58 AM, berni wrote:
 On Friday, 3 March 2017 at 13:21:56 UTC, Seb wrote:
 Is there any specific reason why you can't use DMD or LDC?
gdc produces faster binaries. ;-) I've got installed the other two compilers too and they work.
I haven't compared them myself but I am under the following impression. - dmd compiles the quickest and ldc compiles the slowest. - dmd produces the slowest binary and ldc produces the fastest binary. Which would put gdc in between the two. Is your experience different? Ali
Mar 03 2017
parent reply berni <berni example.com> writes:
On Friday, 3 March 2017 at 20:10:25 UTC, Ali Çehreli wrote:
 Which would put gdc in between the two. Is your experience 
 different?
Actually, I've got not much experience. A few weeks ago I ran a test where ldc was in between dmd and gdc. But I missed the -release flags then. With that flag it's faster, but still slower than gdc on that one (B below). With an other testcase, where I compared them, gdc and ldc are on equals speed (A below). A) dmd 52s, gdc 22s, ldc 22s B) dmd 432s, gdc 280s, ldc 310s
Mar 03 2017
parent reply Johan Engelen <j j.nl> writes:
On Friday, 3 March 2017 at 22:06:11 UTC, berni wrote:
 On Friday, 3 March 2017 at 20:10:25 UTC, Ali Çehreli wrote:
 Which would put gdc in between the two. Is your experience 
 different?
Actually, I've got not much experience. A few weeks ago I ran a test where ldc was in between dmd and gdc. But I missed the -release flags then. With that flag it's faster, but still slower than gdc on that one (B below). With an other testcase, where I compared them, gdc and ldc are on equals speed (A below). A) dmd 52s, gdc 22s, ldc 22s B) dmd 432s, gdc 280s, ldc 310s
If you think you have a good testcase, it's nice for compiler devs like me to open a new thread about the difference that you found between the compilers (so that we can try and improve things). Depending on language/Phobos/druntime versions of DMD, LDC, and GDC, it's not always clear if the comparison is fair and the results can be skewed. (that said, I think on average, gcc creates slightly faster binaries than clang, but those are highly developed compilers, and LDC (at least) isn't. So I am not surprised if GDC creates slightly faster binaries than LDC for some test cases. For other test cases, LDC wins, but those are not so interesting. Because I work on LDC, I'm always keen on seeing testcases where _GDC_ wins.) Thanks! Johan
Mar 04 2017
parent reply berni <berni example.com> writes:
On Saturday, 4 March 2017 at 10:02:15 UTC, Johan Engelen wrote:
 If you think you have a good testcase, it's nice for compiler 
 devs like me to open a new thread about the difference that you 
 found between the compilers (so that we can try and improve 
 things).
I'm not sure, if my "testcase" is generally a good one. Here is some background: In the last 10 years I developed about 200 programs for checking logical puzzles (like sudoku), all written in java. About a year ago I decided to make these programs free software. But as I have to refactor them anyway and I dislike java meanwhile I decided to change the language when doing so. I decided on a special puzzle type, called double mine (similar to minesweeper, but in every row and column, there have to be exactly two mines and mines may not touch, not even diagonally), to check out different languages. Speed was just one criterion when doing this. At that time D wasn't among the candidates, because I did not know of this language at all. I added D later (with almost no knowledge about D) and checked out all three compilers. If you think, this program could be usefull for you, I can email it to you...
Mar 04 2017
parent Johan Engelen <j j.nl> writes:
On Saturday, 4 March 2017 at 18:45:22 UTC, berni wrote:
 [...]

 If you think, this program could be usefull for you, I can 
 email it to you...
The smaller the testcase, the better. You mentioned that for testcase "B" there is a ~10% performance difference between GDC and LDC, so that's definitely worth looking into. It's best to submit it in our issue tracker on github: https://github.com/ldc-developers/ldc/issues So whenever someone has time and interest to look at runtime performance improvements, there are testcases to investigate :) cheers, Johan
Mar 05 2017
prev sibling parent reply Russel Winder via Digitalmars-d-learn <digitalmars-d-learn puremagic.com> writes:
On Tue, 2017-02-28 at 17:09 +0000, berni via Digitalmars-d-learn wrote:
 I'm using CMAKE to build my project. With=C2=A0
 https://github.com/dcarp/cmake-d this works almost. The only=C2=A0
 thing I do not manage to get working is running cmake in release=C2=A0
 mode. When I use -DCMAKE_BUILD_TYPE=3DRelease I get some linker=C2=A0
 errors, which I do not get, when compiling manually. (In both=C2=A0
 cases gdc/linux is used.)
=20
 I allready could figure out, that it's due to the -O3 compiler=C2=A0
 flag used in release mode. It looks like cmake compiles all *.d=C2=A0
 files separately and while doing so, removes some functions when=C2=A0
 optimizing them. Later, when linking everything together, they=C2=A0
 are missing. (But I'm not sure on this.)
=20
 Here is my project: https://github.com/crocopaw/croco/tree/devel
=20
 Anybody here who has experience with CMAKE and D and could help?
I do not have an immediate answer, but=E2=80=A6 CLion requires CMake, with CMake-D in a fit state we could use CLion with D =E2=80=93 albeit very rough and ready way, at least initially. I am = sure the DLanguage IDEA plugin can be made to work with CLion. If this combination can be made to work at all, then it can be improved over time. Personally I am now at the stage that without an IDE I don't start a project using that language. The important IDEs are JetBrains family and Eclipse. Anything else is niche or an also ran. At least currently. I am about to not use D for a new project because C++, Rust and Go have good IDEs. And I am an Emacs person. I guess I will have to join Emacs Anonymous as I do not use it any more except for LaTeX and AsciiDoc files. OK I use the Emacs bindings in the IDEs obviously. Unless the combination I proposed actually works. I will give it a go. --=20 Russel. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D Dr Russel Winder t: +44 20 7585 2200 voip: sip:russel.winder ekiga.n= et 41 Buckmaster Road m: +44 7770 465 077 xmpp: russel winder.org.uk London SW11 1EN, UK w: www.russel.org.uk skype: russel_winder
Mar 02 2017
parent bauss <jj_1337 live.dk> writes:
On Thursday, 2 March 2017 at 12:42:00 UTC, Russel Winder wrote:
 On Tue, 2017-02-28 at 17:09 +0000, berni via 
 Digitalmars-d-learn wrote:
 [...]
I do not have an immediate answer, but… CLion requires CMake, with CMake-D in a fit state we could use CLion with D – albeit very rough and ready way, at least initially. I am sure the DLanguage IDEA plugin can be made to work with CLion. If this combination can be made to work at all, then it can be improved over time. Personally I am now at the stage that without an IDE I don't start a project using that language. The important IDEs are JetBrains family and Eclipse. Anything else is niche or an also ran. At least currently. I am about to not use D for a new project because C++, Rust and Go have good IDEs. And I am an Emacs person. I guess I will have to join Emacs Anonymous as I do not use it any more except for LaTeX and AsciiDoc files. OK I use the Emacs bindings in the IDEs obviously. Unless the combination I proposed actually works. I will give it a go.
While it's true that they have better IDE's, I often find IDE's too bulky so I often end up using Atom or something similar with cmd plugins in which way it kinda acts like an IDE. Only thing that sucks using editors like that is debugging, but generally it's not a big deal to just run the code in an IDE and then debug it.
Mar 02 2017