forked from dlang/dlang.org
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dcompiler.dd
1129 lines (955 loc) · 29.1 KB
/
dcompiler.dd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
Ddoc
$(D_S dmd - $(WINDOWS Windows)$(LINUX Linux)$(OSX Mac OS X)$(FREEBSD FreeBSD) D Compiler,
$(UL
$(WINDOWS $(LI dmd for $(LINK2 dmd-linux.html, Linux)))
$(WINDOWS $(LI dmd for $(LINK2 dmd-osx.html, OSX)))
$(WINDOWS $(LI dmd for $(LINK2 dmd-freebsd.html, FreeBSD)))
$(LINUX $(LI dmd for $(LINK2 dmd-windows.html, Windows)))
$(LINUX $(LI dmd for $(LINK2 dmd-osx.html, OSX)))
$(LINUX $(LI dmd for $(LINK2 dmd-freebsd.html, FreeBSD)))
$(OSX $(LI dmd for $(LINK2 dmd-windows.html, Windows)))
$(OSX $(LI dmd for $(LINK2 dmd-linux.html, Linux)))
$(OSX $(LI dmd for $(LINK2 dmd-freebsd.html, FreeBSD)))
$(FREEBSD $(LI dmd for $(LINK2 dmd-windows.html, Windows)))
$(FREEBSD $(LI dmd for $(LINK2 dmd-linux.html, Linux)))
$(FREEBSD $(LI dmd for $(LINK2 dmd-osx.html, OSX)))
$(LI $(RELATIVE_LINK2 requirements, Requirements and Downloads))
$(LI $(RELATIVE_LINK2 files, Files))
$(LI $(RELATIVE_LINK2 installation, Installation))
$(WINDOWS $(LI $(RELATIVE_LINK2 example, Example)))
$(LI $(RELATIVE_LINK2 switches, Compiler Arguments and Switches))
$(LI $(RELATIVE_LINK2 linking, Linking))
$(LI $(RELATIVE_LINK2 environment, Environment Variables))
$(WINDOWS $(LI $(RELATIVE_LINK2 sc_ini, sc.ini Initialization File)))
$(UNIX $(LI $(DMD_CONF) Initialization File))
$(WINDOWS $(LI $(RELATIVE_LINK2 problems, Common Installation Problems)))
$(LI $(RELATIVE_LINK2 differences, Differences between Windows and Linux versions))
$(LI $(RELATIVE_LINK2 interface_files, D Interface Files))
$(LI $(RELATIVE_LINK2 library, Building Libraries))
$(LI $(RELATIVE_LINK2 compiling_dmd, Compiling dmd))
$(LI $(RELATIVE_LINK2 compiling_phobos, Compiling Phobos))
)
$(H2 $(LNAME2 requirements, Requirements and Downloads))
$(OL
$(LI $(LINK2 http://www.digitalmars.com/d/download.html, Download D Compiler))
$(WINDOWS
$(LI Windows operating system, Windows XP or later, 32 or 64 bit)
$(LI Download
<a href="http://ftp.digitalmars.com/dmc.zip" title="download dmc.zip">
dmc.zip (C and C++ compiler)</a> for Win32
(not required, but it complements dmd for Windows)
)
)
$(LINUX
$(LI 32 bit x86 and 64 bit x86-64 Linux operating system)
$(LI Gnu C compiler (gcc))
)
$(OSX
$(LI 32 bit x86 Mac OSX operating system)
$(LI Gnu C compiler (gcc))
)
$(FREEBSD
$(LI 32 bit x86 FreeBSD 7.1 operating system)
$(LI Gnu C compiler (gcc))
)
)
$(H2 $(LNAME2 files, Files))
$(DL
$(DT $(D $(DMDDIR)$(SEP)src$(SEP)phobos$(SEP))
$(DD D runtime library source)
)
$(DT $(D $(DMDDIR)$(SEP)src$(SEP)dmd$(SEP))
$(DD D compiler front end source under dual (GPL and Artistic) license)
)
$(DT $(D $(DMDDIR)$(SEP)html$(SEP)d$(SEP))
$(DD Documentation)
)
$(DT $(D $(DMDDIR)$(SEP)samples$(SEP)d$(SEP))
$(DD Sample D programs)
)
$(WINDOWS
$(DT $(D $(DMDDIR)\windows\bin\dmd.exe)
$(DD D compiler executable)
)
$(DT $(D $(DMDDIR)\windows\bin\$(LINK2 http://www.digitalmars.com/ctg/shell.html, shell.exe))
$(DD Simple command line shell)
)
$(DT $(D $(DMDDIR)\windows\bin\sc.ini)
$(DD Global compiler settings)
)
$(DT $(D $(DMDDIR)\windows\lib\$(LIB))
$(DD D runtime library)
)
)
$(LINUX
$(DT $(D $(DMDDIR)/linux/bin/dmd)
$(DD D compiler executable)
)
$(DT $(D $(DMDDIR)/linux/bin/$(DUMPOBJ))
$(DD Elf file dumper)
)
$(DT $(D $(DMDDIR)/linux/bin/$(OBJ2ASM))
$(DD Elf file disassembler)
)
$(DT $(D $(DMDDIR)/linux/bin/$(SHELL))
$(DD Simple command line shell)
)
$(DT $(D $(DMDDIR)/linux/bin/$(DMD_CONF))
$(DD Global compiler settings (copy to $(D /etc/dmd.conf)))
)
$(DT $(D $(DMDDIR)/linux/lib/$(LIB))
$(DD D runtime library (copy to $(D /usr/lib/$(LIB))))
)
)
$(FREEBSD
$(DT $(D $(DMDDIR)/freebsd/bin/dmd)
$(DD D compiler executable)
)
$(DT $(D $(DMDDIR)/freebsd/bin/$(DUMPOBJ))
$(DD Elf file dumper)
)
$(DT $(D $(DMDDIR)/freebsd/bin/$(OBJ2ASM))
$(DD Elf file disassembler)
)
$(DT $(D $(DMDDIR)/freebsd/bin/$(SHELL))
$(DD Simple command line shell)
)
$(DT $(D $(DMDDIR)/freebsd/bin/$(DMD_CONF))
$(DD Global compiler settings (copy to $(D /etc/dmd.conf)))
)
$(DT $(D $(DMDDIR)/freebsd/lib/$(LIB))
$(DD D runtime library (copy to $(D /usr/lib/$(LIB))))
)
)
$(OSX
$(DT $(D $(DMDDIR)/osx/bin/dmd)
$(DD D compiler executable)
)
$(DT $(D $(DMDDIR)/osx/bin/$(DUMPOBJ))
$(DD Mach-O file dumper)
)
$(DT $(D $(DMDDIR)/osx/bin/$(OBJ2ASM))
$(DD Mach-O file disassembler)
)
$(DT $(D $(DMDDIR)/osx/bin/$(SHELL))
$(DD Simple command line shell)
)
$(DT $(D $(DMDDIR)/osx/bin/$(DMD_CONF))
$(DD Global compiler settings (copy to $(D /etc/dmd.conf)))
)
$(DT $(D $(DMDDIR)/osx/lib/$(LIB))
$(DD D runtime library (copy to $(D /usr/lib/$(LIB))))
)
)
)
$(H2 $(LNAME2 installation, Installation))
$(WINDOWS
$(P Open a console window (for Windows XP this is done by
clicking on [Start][Command Prompt]).
All the tools are command line tools, which means
they are run from a console window.
Switch to the root directory.
Unzip the files in the root directory.
$(D dmd.zip) will create
a $(D $(DMDDIR)) directory with all the files in it.
$(D dmc.zip) will create
a $(D \dm) directory with all the files in it.
)
$(P A typical session might look like:)
$(CONSOLE
C:\Documents and Settings\Your Name>cd \
C:\>unzip dmd.zip
C:\>unzip dmc.zip
)
)
$(LINUX
$(LI Unzip the archive into your home directory.
It will create
a $(D ~/dmd) directory with all the files in it.
All the tools are command line tools, which means
they are run from a console window.)
$(LI Copy $(D $(DMD_CONF)) to $(D /etc):
$(CONSOLE
cp $(DMDDIR)/linux/bin/$(DMD_CONF) /etc
)
)
$(LI Put $(D $(DMDDIR)/linux/bin) on your $(B PATH),
or copy the linux executables
to $(D /usr/local/bin))
$(LI Copy the library to $(D /usr/lib):
$(CONSOLE
cp $(DMDDIR)/linux/lib/$(LIB) /usr/lib
)
)
)
$(FREEBSD
$(LI Unzip the archive into your home directory.
It will create
a $(D ~/dmd) directory with all the files in it.
All the tools are command line tools, which means
they are run from a console window.)
$(LI Copy $(D $(DMD_CONF)) to $(D /etc):
$(CONSOLE
cp $(DMDDIR)/freebsd/bin/dmd.conf /etc
)
)
$(LI Put $(D $(DMDDIR)/freebsd/bin) on your $(B PATH),
or copy the FreeBSD executables
to $(D /usr/local/bin))
$(LI Copy the library to $(D /usr/lib):
$(CONSOLE
cp $(DMDDIR)/freebsd/lib/$(LIB) /usr/lib
)
)
)
$(OSX
$(LI Put the dmd zip file into your home directory,
and unzip it:
$(CONSOLE
unzip dmd.$(I VERSION).zip
)
where $(I VERSION) is the particular version of the zip file.
)
$(LI It will create
a $(D ~/$(DMDDIR)) directory with all the files in it.
All the tools are command line tools, which means
they are run from a console window.)
$(LI Verify that this works by creating $(D hello.d) in your home directory
with these contents:
---
import std.stdio;
void main() {
writeln("hello world!");
}
---
and compile and run it with:
$(CONSOLE
$(DMDDIR)/osx/bin/dmd hello
./hello
)
and it should print:
$(CONSOLE
hello world!
)
)
$(LI To install a global copy:)
$(LI Copy binaries to $(D /usr/local/bin):
$(CONSOLE
sudo cp $(DMDDIR)/osx/bin/{dmd,$(DUMPOBJ),$(OBJ2ASM),$(SHELL),rdmd} /usr/local/bin
sudo cp $(DMDDIR)/osx/bin/dmdx.conf /usr/local/bin/$(DMD_CONF)
)
)
$(LI Copy the library to $(D /usr/lib):
$(CONSOLE
sudo cp $(DMDDIR)/osx/lib/$(LIB) /usr/lib
)
)
)
$(WINDOWS
$(H2 $(H2 $(LNAME2 example, Example)))
$(P Run:)
$(CONSOLE
$(DMDDIR)$(SEP)$(OS)$(SEP)bin$(SEP)$(SHELL) all.sh
)
$(P in the $(D $(DMDDIR)$(SEP)samples$(SEP)d) directory for several small examples.)
)
$(H2 $(LNAME2 switches, Compiler Arguments and Switches))
$(DL
$(DT $(B dmd) $(I files)... -$(I switches)...
$(DD )
)
$(DT $(I files)...
$(DD
$(TABLE2 File Extensions,
$(TR
$(TH Extension)
$(TH File Type)
)
$(TR
$(TD $(I none))
$(TD D source files)
)
$(TR
$(TD $(B .d))
$(TD D source files)
)
$(TR
$(TD $(B .dd))
$(TD $(LINK2 ddoc.html, Ddoc) source files)
)
$(TR
$(TD $(B .di))
$(TD $(RELATIVE_LINK2 interface_files, D interface files))
)
$(TR
$(TD $(B .$(OBJEXT)))
$(TD Object files to link in)
)
$(TR
$(TD $(B .$(LIBEXT)))
$(TD Object code libraries to search)
)
$(WINDOWS
$(TR
$(TD $(B .exe))
$(TD Output executable file)
)
$(TR
$(TD $(B .def))
$(TD $(LINK2 http://www.digitalmars.com/ctg/ctgDefFiles.html, module definition file))
)
$(TR
$(TD $(B .res))
$(TD resource file)
)
)
)
)
)
$(SWITCH $(B @)$(I cmdfile),
If $(I cmdfile) is an environment variable,
read the compiler arguments and switches from
the value of that variable.
Otherwise, read compiler arguments and switches from
the text file $(I cmdfile).
The file may contain single-line comments starting
with the hash symbol ($(CODE #)).
)
$(SWITCH $(B -c),
compile only, do not link
)
$(SWITCH2 -cov,
$(P Perform $(LINK2 code_coverage.html, code coverage analysis) and generate
.lst file with report.)
---
dmd -cov -unittest myprog.d
---
)
$(SWITCH $(B -cov=)$(I nnn),
Perform $(LINK2 code_coverage.html, code coverage analysis), generate
.lst file with report, and error at runtime if code coverage is less than
$(I nnn)% of the executable lines. This can be integrated into the build
test process to ensure minimum unit test coverage.
)
$(SWITCH $(B -D),
generate $(LINK2 ddoc.html, documentation) from source
)
$(SWITCH $(B -Dd)$(I docdir),
write documentation file to $(I docdir) directory. $(B -op)
can be used if the original package hierarchy should
be retained
)
$(SWITCH $(B -Df)$(I filename),
write documentation file to $(I filename)
)
$(SWITCH $(B -d),
Silently allow $(DDLINK deprecate,deprecate,deprecated features) and use of symbols with
$(DDSUBLINK attribute, deprecated, deprecated attributes).
)
$(SWITCH $(B -dw),
treat use of deprecated features and attributes as warnings
$(B (this is the default))
)
$(SWITCH $(B -de),
treat use of deprecated features and attributes as errors
)
$(SWITCH $(B -debug),
compile in $(LINK2 version.html#debug, debug) code
)
$(SWITCH $(B -debug=)$(I level),
compile in $(LINK2 version.html#debug, debug level) <= $(I level)
)
$(SWITCH $(B -debug=)$(I ident),
compile in $(LINK2 version.html#debug, debug identifier) $(I ident)
)
$(SWITCH $(B -debuglib=)$(I libname),
Link in $(I libname) as the default library when
compiling for symbolic debugging instead of $(B $(LIB)).
If $(I libname) is not supplied, then no default library is linked in.
)
$(SWITCH $(B -defaultlib=)$(I libname),
Link in $(I libname) as the default library when
not compiling for symbolic debugging instead of $(B $(LIB)).
If $(I libname) is not supplied, then no default library is linked in.
)
$(SWITCH $(B -deps=)$(I filename),
write module dependencies as text to $(I filename)
)
$(UNIX
$(SWITCH $(B -fPIC),
generate Position Independent Code (which is used
for building shared libraries).
$(OSX This is always on for OSX.)
)
)
$(SWITCH $(B -g),
$(WINDOWS
add CodeView symbolic debug info with
$(LINK2 abi.html#codeview, D extensions)
for debuggers such as
$(LINK2 http://ddbg.mainia.de/releases.html, Ddbg)
)
$(UNIX
add Dwarf symbolic debug info with
$(LINK2 abi.html#dwarf, D extensions)
for debuggers $(LINUX such as
$(LINK2 http://www.zerobugs.org/, ZeroBUGS))
)
)
$(SWITCH $(B -gc),
$(WINDOWS
add CodeView symbolic debug info in C format
for debuggers such as
$(D $(DMDDIR)\bin\windbg)
)
$(UNIX
add Dwarf symbolic debug info in C format
for debuggers such as
$(D gdb)
)
)
$(SWITCH $(B -gs),
always generate standard stack frame
)
$(SWITCH $(B -H),
generate $(RELATIVE_LINK2 interface_files, D interface file)
)
$(SWITCH $(B -Hd)$(I dir),
write D interface file to $(I dir) directory. $(B -op)
can be used if the original package hierarchy should
be retained
)
$(SWITCH $(B -Hf)$(I filename),
write D interface file to $(I filename)
)
$(SWITCH $(B --help),
print brief help to console
)
$(SWITCH $(B -I)$(I path),
where to look for
$(LINK2 module.html#ImportDeclaration, imports).
$(I path) is a ; separated
list of paths. Multiple $(B -I)'s can be used, and the paths
are searched in the same order.
)
$(SWITCH $(B -ignore),
ignore unsupported pragmas
)
$(SWITCH $(B -inline),
inline expand functions at the discretion of the compiler.
This can improve performance, at the expense of making
it more difficult to use a debugger on it.
)
$(SWITCH $(B -J)$(I path),
where to look for files for
$(LINK2 expression.html#ImportExpression, $(I ImportExpression))s.
This switch is required in order to use $(I ImportExpression)s.
$(I path) is a ; separated
list of paths. Multiple $(B -J)'s can be used, and the paths
are searched in the same order.
)
$(SWITCH $(B -L)$(I linkerflag),
pass $(I linkerflag) to the
$(WINDOWS $(LINK2 http://www.digitalmars.com/ctg/optlink.html, linker))
$(UNIX linker), for example,
$(WINDOWS $(D -L/ma/li))$(UNIX $(D -L-M))
)
$(SWITCH $(B -lib),
generate library file as output instead of object file(s).
All compiled source files, as well as object files and library
files specified on the command line, are inserted into
the output library.
Compiled source modules may be partitioned into several object
modules to improve granularity.
The name of the library is taken from the name of the first
source module to be compiled. This name can be overridden with
the $(B -of) switch.
)
$(UNIX
$(SWITCH $(B -m32),
compile a 32 bit executable. This is the default for the
32 bit dmd.
)
$(SWITCH $(B -m64),
compile a 64 bit executable. This is the default for the 64 bit dmd.
)
)
$(WINDOWS
$(SWITCH $(B -m32),
Compile a 32 bit executable. This is the default.
The generated object code is in OMF and is meant to be used with the
$(LINK2 http://www.digitalmars.com/download/freecompiler.html, Digital Mars C/C++ compiler).
)
$(SWITCH $(B -m64),
Compile a 64 bit executable.
The generated object code is in MS-COFF and is meant to be used with the
$(LINK2 http://www.amazon.com/gp/product/B0038KTO8S/ref=as_li_qf_sp_asin_il_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=B0038KTO8S&linkCode=as2&tag=classicempire, Microsoft Visual Studio 10)
or later compiler.
)
)
$(SWITCH $(B -main),
Add a default $(D main()) function when compiling. This is useful when
unittesting a library, as it enables the user to run the unittests
in a library without having to manually define an entry-point function.
)
$(SWITCH $(B -man),
$(WINDOWS
open default browser on this page
)
$(LINUX
open browser specified by the $(B BROWSER)
environment variable on this page. If $(B BROWSER) is
undefined, $(B x-www-browser) is assumed.
)
$(FREEBSD
open browser specified by the $(B BROWSER)
environment variable on this page. If $(B BROWSER) is
undefined, $(B x-www-browser) is assumed.
)
$(OSX
open browser specified by the $(B BROWSER)
environment variable on this page. If $(B BROWSER) is
undefined, $(B Safari) is assumed.
)
)
$(SWITCH $(B -map),
generate a .map file
)
$(SWITCH $(B -noboundscheck),
turns off all array bounds checking, even for safe functions
)
$(SWITCH $(B -O),
Optimize generated code. For fastest executables, compile
with the $(B -O -release -inline -noboundscheck) switches together.
)
$(SWITCH $(B -o-),
Suppress generation of object file. Useful in
conjuction with $(B -D) or $(B -H) flags.
)
$(SWITCH $(B -od)$(I objdir),
$(DD write object files relative to directory $(I objdir)
instead of to the current directory. $(B -op)
can be used if the original package hierarchy should
be retained)
)
$(SWITCH $(B -of)$(I filename),
Set output file name to $(I filename) in the output
directory. The output file can be an object file,
executable file, or library file depending on the other
switches.
)
$(SWITCH $(B -op),
normally the path for $(B .d) source files is stripped
off when generating an object, interface, or Ddoc file
name. $(B -op) will leave it on.
)
$(SWITCH $(B -profile),
$(LINK2 http://www.digitalmars.com/ctg/trace.html, profile)
the runtime performance
of the generated code
)
$(SWITCH $(B -property),
enforce use of @property on property functions
)
$(SWITCH $(B -quiet),
suppress non-essential compiler messages
)
$(SWITCH $(B -release),
compile release version, which means not generating
code for contracts and asserts. Array bounds checking
is not done for system and trusted functions.
)
$(SWITCH $(B -run) $(I srcfile args...)
compile, link, and run the program $(I srcfile) with the
rest of the
command line, $(I args...), as the arguments to the program.
No .$(OBJEXT) or executable file is left behind.
)
$(COMMENT
$(SWITCH $(B -safe),
Statically checks the modules being compiled to ensure they
conform to the $(LINK2 safed.html, safe memory model).
)
)
$(UNIX
$(SWITCH2 -shared,
generate shared library
)
)
$(WINDOWS
$(SWITCH2 -shared,
generate DLL library
)
)
$(SWITCH $(B -unittest),
compile in $(LINK2 unittest.html, unittest) code, turns on asserts, and sets the
$(D unittest) $(LINK2 version.html#PredefinedVersions, version identifier)
)
$(SWITCH $(B -v),
verbose
)
$(SWITCH $(B -version=)$(I level),
compile in $(LINK2 version.html#version, version level) >= $(I level)
)
$(SWITCH $(B -version=)$(I ident),
compile in $(LINK2 version.html#version, version identifier) $(I ident)
)
$(SWITCH $(B -vtls),
print informational messages identifying variables defaulting
to thread local storage. Handy for migrating to shared model.
)
$(SWITCH $(B -w),
enable $(LINK2 warnings.html, warnings)
)
$(SWITCH $(B -wi),
enable $(LINK2 warnings.html, informational warnings (i.e. compilation
still proceeds normally))
)
$(SWITCH $(B -X),
generate JSON file
)
$(SWITCH $(B -Xf)$(I filename),
write JSON file to $(I filename)
)
)
$(WINDOWS
$(P Empty switches, i.e. "", are ignored.)
)
$(H2 $(LNAME2 linking, Linking))
$(P Linking is done directly by the $(B dmd) compiler after a successful
compile. To prevent $(B dmd) from running the linker, use the
$(B -c) switch.
)
$(WINDOWS
$(P 32 bit programs must be linked with the D runtime library $(B phobos.lib),
followed by the Digital Mars C runtime library $(B snn.lib).
This is done automatically as long as the directories for the
libraries are on the LIB environment variable path. A typical
way to set LIB would be:
)
$(CONSOLE
set LIB=$(DMDDIR)\lib;\dm\lib
)
$(P If the $(B dmd) command is used to both compile and link
to an executable, it will make certain optimizations that are
valid only for Windows executable files. Do not use the resulting
.obj files in a DLL.
To compile modules into .obj files that can be used in an exe or
DLL, compile with $(B -c) and $(B -shared).
)
$(P Linking 32 bit programs is done using the
$(LINK2 http://www.digitalmars.com/ctg/optlink.html, optlink) linker.
)
$(P Linking 64 bit programs is done using the
Microsoft linker.
)
)
$(UNIX
$(P The actual linking is done by running $(B gcc).
This ensures compatibility with modules compiled with $(B gcc).
)
)
$(H2 $(LNAME2 environment, Environment Variables))
$(P The D compiler dmd uses the following environment variables:
)
$(DL
$(WINDOWS
$(DT $(B DFLAGS))
$(DD The value of $(B DFLAGS) is treated as if it were appended to the
command line to $(B dmd.exe).)
$(DT $(B LIB))
$(DD The linker uses $(B LIB) to search for library files. For D, it will
normally be set to:)
$(CONSOLE
set LIB=$(DMDDIR)\lib;\dm\lib
)
$(DT $(B LINKCMD))
$(DD $(B dmd) normally runs the linker by looking for $(B link.exe)
along the $(B PATH). To use a specific linker for 32 bit programs instead, set the
$(B LINKCMD) environment variable to it. For example:)
$(CONSOLE
set LINKCMD=\dmd\windows\bin\link
)
$(DT $(B LINKCMD64))
$(DD $(B dmd) normally runs the linker by looking for $(B link.exe)
along the $(B PATH). To use a specific linker for 64 bit programs instead, set the
$(B LINKCMD64) environment variable to it. For example:)
$(CONSOLE
set LINKCMD64=C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\amd64\link.exe
)
$(DT $(B PATH))
$(DD If the linker is not found in the same directory as $(B dmd.exe)
is in, the $(B PATH) is searched for it.
$(B Note:) other linkers named
$(B link.exe) will likely not work.
Make sure the Digital Mars $(B link.exe)
is found first in the $(B PATH) before other $(B link.exe)'s,
or use $(B LINKCMD) to specifically identify which linker
to use.)
)
$(UNIX
$(DT $(B CC))
$(DD $(B dmd) normally runs the linker by looking for $(B gcc)
along the $(B PATH). To use a specific linker instead, set the
$(B CC) environment variable to it. For example:)
$(CONSOLE
set CC=gcc
)
$(DT $(B BROWSER)
$(DD This sets the browser used to open the manual page with
the $(B -man) switch. It defaults to $(D x-www-browser).
)
)
$(DT $(B DFLAGS))
$(DD The value of $(B DFLAGS) is treated as if it were appended to the
command line to $(B dmd).)
)
)
$(WINDOWS
$(H2 $(LNAME2 sc_ini, sc.ini Initialization File))
$(P $(B dmd) will look for the initialization file $(B sc.ini) in the
following sequence of directories:
)
$(OL
$(LI current working directory)
$(LI directory specified by the $(B HOME) environment variable)
$(LI directory $(B dmd.exe) resides in)
)
$(P If found, environment variable
settings in the file will override any existing settings.
This is handy to make $(B dmd) independent of programs with
conflicting use of environment variables.
)
$(H3 Initialization File Format)
$(P Comments are lines that begin with $(D ;) and are ignored.
)
$(P Environment variables follow the $(D [Environment]) section
heading, in $(I NAME)=$(I value) pairs.
The $(I NAME)s are treated as upper case.
Comments are lines that start with ;.
For example:
)
$(SCINI
; sc.ini file for dmd
; Names enclosed by %% are searched for in the existing environment
; and inserted. The special name %@P% is replaced with the path
; to this file.
[Environment]
LIB="%@P%\..\lib";\dm\lib
DFLAGS="-I%@P%\..\src\phobos" "-I%@P%\..\src\druntime\import"
LINKCMD="%@P%\..\..\dm\bin"
DDOCFILE=mysettings.ddoc
)
$(H3 Location Independence of sc.ini)
$(P The $(B %@P%) is replaced with the path to $(D sc.ini).
Thus, if the fully qualified file name $(D sc.ini) is
$(D c:$(DMDDIR)\bin\sc.ini), then $(B %@P%) will be replaced with
$(D c:$(DMDDIR)\bin), and the above $(D sc.ini) will be
interpreted as:
)
$(SCINI
[Environment]
LIB="c:$(DMDDIR)\bin\..\lib";\dm\lib
DFLAGS="-Ic:$(DMDDIR)\bin\..\src\phobos" "-Ic:$(DMDDIR)\bin\..\src\druntime\import"
LINKCMD="c:$(DMDDIR)\bin\..\..\dm\bin"
DDOCFILE=mysettings.ddoc
)
$(P This enables your dmd setup to be moved around without having
to re-edit $(D sc.ini).
)
)
$(UNIX
$(H2 $(LNAME2 dmd_conf, dmd.conf Initialization File))
$(P The dmd file $(D dmd.conf) is the same as $(D sc.ini)
for Windows, it's just that the file has a different name,
enabling a setup common to both Windows and this system to be created
without having to re-edit the file.)
$(P $(B dmd) will look for the initialization file $(D dmd.conf) in the
following sequence of directories:)
$(OL
$(LI current working directory)
$(LI directory specified by the $(B HOME) environment variable)
$(LI directory $(B dmd) resides in)
$(LI $(D /etc/))
)
$(P If found, environment variable
settings in the file will override any existing settings.
This is handy to make $(B dmd) independent of programs with
conflicting use of environment variables.
)
$(P Environment variables follow the $(D [Environment]) section
heading, in $(I NAME)=$(I value) pairs.
The $(I NAME)s are treated as upper case.
Comments are lines that start with ;.
For example:
)
$(SCINI
; dmd.conf file for dmd
; Names enclosed by %% are searched for in the existing environment
; and inserted. The special name %@P% is replaced with the path
; to this file.
[Environment]
DFLAGS=-I%@P%/../src/phobos -I%@P%/../src/druntime/import
)
)
$(WINDOWS
$(H2 $(LNAME2 problems, Common Installation Problems))
$(UL
$(LI Using Cygwin's $(B unzip) utility has been known to cause
strange problems.
)
$(LI Running the compiler under Cygwin's command shell has
been also known to cause problems. Try getting it to work
under the regular Windows shell $(B cmd.exe) before trying Cygwin's.
)
$(LI Installing $(B dmd) and $(B dmc) into directory paths with spaces
in them causes problems.
)
)
)
<hr>
$(H2 $(LNAME2 differences, Differences between Windows and Linux versions))
$(UL
$(LI String literals are read-only under Linux.
Attempting to write to them
will cause a segment violation.)
)
<hr>
$(H2 $(LNAME2 interface_files, D Interface Files))
$(P When an import declaration is processed in a D source file,
the compiler searches for the D source file corresponding to
the import, and processes that source file to extract the
information needed from it. Alternatively, the compiler can
instead look for a corresponding $(I D interface file).
A D interface file contains only what an import of the module
needs, rather than the whole implementation of that module.
)
$(P The advantages of using a D interface file for imports rather
than a D source file are:
)
$(UL
$(LI D interface files are often significantly smaller and much
faster to process than the corresponding D source file.)
$(LI They can be used to hide the source code, for example,
one can ship an object code library along with D interface files
rather than the complete source code.)
)
$(P D interface files can be created by the compiler from a
D source file by using the $(B -H) switch to the compiler.
D interface files have the $(B .di) file extension.
When the compiler resolves an import declaration, it first looks
for a $(B .di) D interface file, then it looks for a D source
file.
)