What would be the best way to compile a project with GDC?

H. S. Teoh hsteoh at quickfur.ath.cx
Thu Aug 1 10:57:10 PDT 2013


On Thu, Aug 01, 2013 at 07:46:05PM +0200, Gary Willoughby wrote:
> I've just finished a project in D and have been using rdmd to
> compile during testing. While this is nice, i now want to try other
> compilers to see if i get any speed gains.

Based on my experience, you will, with gdc / ldc. The optimizers in
gdc/ldc are much more mature than in dmd; I've compared the disassembly
and measured running times with gdc -O3 vs. dmd -O, and gdc consistently
produces code that performs 20-30% faster. YMMV, of course, since the
exact amount of speed gain depends on what your code does.


> Because i use rdmd it takes care of passing everything to dmd. Now i
> want to try GDC and i need to pass the files in the correct order for
> compilation. I've first tried to write a bash script with all the
> files listed correctly and passed all the necessary flags to dmd
> but i can never get the order of the files correct.

Huh? It shouldn't matter what order the files are. If it does, it sounds
like a bug!


> There must be a simpler way to pass these files to dmd in the right
> order? rdmd does it somehow.
> 
> Any ideas? How do you handle compiling projects with 50+ source
> files?

Use a real build system. ;-)  I recommend SCons (http://scons.org/) or
tup (http://gittup.org/tup/). Both require some amount of learning to
use effectively, though. If all else fails there's always makefiles, but
I rather use them only as a last resort.


T

-- 
Life is unfair. Ask too much from it, and it may decide you don't deserve what you have now either.


More information about the Digitalmars-d-learn mailing list