Mercurial > projects > ldc
comparison dmd/mars.c @ 547:b0005772a88e
Add -enable/-disable for specific features.
Allow setting target os with -t.
Clean up the help message.
author | Christian Kamm <kamm incasoftware de> |
---|---|
date | Tue, 26 Aug 2008 19:31:47 +0200 |
parents | 406aee3416bb |
children | 8d709660cd24 |
comparison
equal
deleted
inserted
replaced
546:406aee3416bb | 547:b0005772a88e |
---|---|
163 LLVMDC Homepage: http://www.dsource.org/projects/llvmdc\n\ | 163 LLVMDC Homepage: http://www.dsource.org/projects/llvmdc\n\ |
164 Usage:\n\ | 164 Usage:\n\ |
165 llvmdc files.d ... { -switch }\n\ | 165 llvmdc files.d ... { -switch }\n\ |
166 \n\ | 166 \n\ |
167 files.d D source files\n%s\ | 167 files.d D source files\n%s\ |
168 -annotate annotate the bitcode with human readable source code\n\ | 168 -of<filename> name output file to <filename>\n\ |
169 -o- do not write object file\n\ | |
170 -od<objdir> write object files to directory <objdir>\n\ | |
171 -op do not strip paths from source file\n\ | |
172 -oq write object files with fully qualified names\n\ | |
173 \n\ | |
169 -c do not link\n\ | 174 -c do not link\n\ |
170 -cov do code coverage analysis\n\ | 175 -L<linkerflag> pass <linkerflag> to llvm-ld\n\ |
176 \n\ | |
177 -g add symbolic debug info\n\ | |
178 -gc add symbolic debug info, pretend to be C\n\ | |
179 \n\ | |
180 -w enable warnings\n\ | |
181 \n\ | |
182 -H generate 'header' file\n\ | |
183 -Hd<hdrdir> write 'header' file to <hdrdir> directory\n\ | |
184 -Hf<filename> write 'header' file to <filename>\n\ | |
185 \n\ | |
171 -D generate documentation\n\ | 186 -D generate documentation\n\ |
172 -Dd<docdir> write documentation file to <docdir> directory\n\ | 187 -Dd<docdir> write documentation file to <docdir> directory\n\ |
173 -Df<filename> write documentation file to <filename>\n\ | 188 -Df<filename> write documentation file to <filename>\n\ |
174 -d allow deprecated features\n\ | 189 \n\ |
175 -debug compile in debug code\n\ | 190 Codegen control:\n\ |
176 -debug=level compile in debug code <= level\n\ | |
177 -debug=ident compile in debug code identified by ident\n\ | |
178 -debuglib=name set symbolic debug library to name\n\ | |
179 -defaultlib=name set default library to name\n\ | |
180 -dis disassemble module after compiling\n\ | |
181 -g add symbolic debug info\n\ | |
182 -gc add symbolic debug info, pretend to be C\n\ | |
183 -H generate 'header' file\n\ | |
184 -Hd<hdrdir> write 'header' file to <hdrdir> directory\n\ | |
185 -Hf<filename> write 'header' file to <filename>\n\ | |
186 --help print help\n\ | |
187 -I<path> where to look for imports\n\ | |
188 -J<path> where to look for string imports\n\ | |
189 -ignore ignore unsupported pragmas\n\ | |
190 -inline do function inlining\n\ | |
191 -L<linkerflag> pass <linkerflag> to llvm-ld\n\ | |
192 -m<arch> emit code specific to <arch> being one of:\n\ | 191 -m<arch> emit code specific to <arch> being one of:\n\ |
193 x86 x86-64 ppc32 ppc64\n\ | 192 x86 x86-64 ppc32 ppc64\n\ |
193 -t<os> emit code specific to <os> being one of:\n\ | |
194 Linux, Windows, MacOSX\n\ | |
195 \n\ | |
196 -O optimize, same as -O2\n\ | |
197 -O<n> optimize at level <n> (0-5)\n\ | |
198 -inline do function inlining\n\ | |
199 \n\ | |
200 -debug enables asserts, invariants, contracts, boundscheck\n\ | |
201 and sets debug=1\n\ | |
202 -release disables asserts, invariants, contracts boundscheck\n\ | |
203 \n\ | |
204 -enable-<feature> and\n\ | |
205 -disable-<feature> where <feature> is one of\n\ | |
206 asserts assert statements (default: on)\n\ | |
207 invariants class and struct invariants (default: on)\n\ | |
208 contracts function contracts (default: on)\n\ | |
209 boundscheck array bounds checking (default: on)\n\ | |
210 -debug=level compile in debug stmts <= level (default: 0)\n\ | |
211 -debug=ident compile in debug stmts identified by ident\n\ | |
212 -version=level compile in version code >= level\n\ | |
213 -version=ident compile in version code identified by ident\n\ | |
214 \n\ | |
194 -noasm do not allow use of inline asm\n\ | 215 -noasm do not allow use of inline asm\n\ |
195 -nofloat do not emit reference to floating point\n\ | 216 -nofloat do not emit reference to floating point\n\ |
196 -noruntime do not allow code that generates implicit runtime calls\n\ | 217 -noruntime do not allow code that generates implicit runtime calls\n\ |
197 -noverify do not run the validation pass before writing bitcode\n\ | 218 -noverify do not run the validation pass before writing bitcode\n\ |
198 -O optimize, same as -O2\n\ | 219 -unittest compile in unit tests\n\ |
199 -O<n> optimize at level <n> (0-5)\n\ | 220 -d allow deprecated features\n\ |
200 -o- do not write object file\n\ | 221 \n\ |
201 -od<objdir> write object files to directory <objdir>\n\ | 222 -annotate annotate the bitcode with human readable source code\n\ |
202 -of<filename> name output file to <filename>\n\ | 223 -dis disassemble module after compiling\n\ |
203 -op do not strip paths from source file\n\ | 224 -ignore ignore unsupported pragmas\n\ |
204 -oq write object files with fully qualified names\n\ | |
205 -profile profile runtime performance of generated code\n\ | 225 -profile profile runtime performance of generated code\n\ |
206 -quiet suppress unnecessary messages\n\ | 226 -cov do code coverage analysis\n\ |
207 -release compile release version\n\ | 227 \n\ |
208 -run srcfile args... run resulting program, passing args\n\ | 228 Path options:\n\ |
209 -R<path> provide path to the directory containing the runtime library\n\ | 229 -R<path> provide path to the directory containing the runtime library\n\ |
210 -unittest compile in unit tests\n\ | 230 -I<path> where to look for imports\n\ |
231 -J<path> where to look for string imports\n\ | |
232 -debuglib=name set symbolic debug library to name (currently ignored)\n\ | |
233 -defaultlib=name set default library to name (currently ignored)\n\ | |
234 \n\ | |
235 Misc options:\n\ | |
211 -v verbose\n\ | 236 -v verbose\n\ |
212 -vv very verbose (does not include -v)\n\ | 237 -vv very verbose (does not include -v)\n\ |
213 -v1 D language version 1\n\ | 238 -quiet suppress unnecessary messages\n\ |
214 -version=level compile in version code >= level\n\ | 239 -run srcfile args... run resulting program, passing args\n\ |
215 -version=ident compile in version code identified by ident\n\ | 240 --help print help\n\ |
216 -w enable warnings\n\ | |
217 ", | 241 ", |
218 #if WIN32 | 242 #if WIN32 |
219 " @cmdfile read arguments from cmdfile\n" | 243 " @cmdfile read arguments from cmdfile\n" |
220 #else | 244 #else |
221 "" | 245 "" |
269 global.params.useArrayBounds = 1; | 293 global.params.useArrayBounds = 1; |
270 global.params.useSwitchError = 1; | 294 global.params.useSwitchError = 1; |
271 global.params.useInline = 0; // this one messes things up to a point where codegen breaks | 295 global.params.useInline = 0; // this one messes things up to a point where codegen breaks |
272 global.params.llvmInline = 0; // use this one instead to know if inline passes should be run | 296 global.params.llvmInline = 0; // use this one instead to know if inline passes should be run |
273 global.params.obj = 1; | 297 global.params.obj = 1; |
274 global.params.Dversion = 2; | 298 global.params.Dversion = 1; |
275 global.params.quiet = 1; | 299 global.params.quiet = 1; |
276 | 300 |
277 global.params.linkswitches = new Array(); | 301 global.params.linkswitches = new Array(); |
278 global.params.libfiles = new Array(); | 302 global.params.libfiles = new Array(); |
279 global.params.objfiles = new Array(); | 303 global.params.objfiles = new Array(); |
395 global.params.novalidate = 1; | 419 global.params.novalidate = 1; |
396 else if (strcmp(p + 1, "dis") == 0) | 420 else if (strcmp(p + 1, "dis") == 0) |
397 global.params.disassemble = 1; | 421 global.params.disassemble = 1; |
398 else if (strcmp(p + 1, "annotate") == 0) | 422 else if (strcmp(p + 1, "annotate") == 0) |
399 global.params.llvmAnnotate = 1; | 423 global.params.llvmAnnotate = 1; |
424 else if (strncmp(p + 1, "enable-", 7) == 0 || | |
425 strncmp(p + 1, "disable-", 8) == 0) | |
426 { | |
427 bool enable = (p[1] == 'e'); | |
428 char* feature = p + 1 + (enable ? 7 : 8); | |
429 if (strcmp(feature, "asserts") == 0) | |
430 global.params.useAssert = enable; | |
431 else if (strcmp(feature, "boundscheck") == 0) | |
432 global.params.useArrayBounds = enable; | |
433 else if (strcmp(feature, "contracts") == 0) | |
434 { | |
435 global.params.useIn = enable; | |
436 global.params.useOut = enable; | |
437 } | |
438 else if (strcmp(feature, "invariants") == 0) | |
439 global.params.useInvariants = enable; | |
440 else | |
441 error("unrecognized feature '%s'", feature); | |
442 } | |
400 else if (strcmp(p + 1, "noasm") == 0) | 443 else if (strcmp(p + 1, "noasm") == 0) |
401 global.params.useInlineAsm = 0; | 444 global.params.useInlineAsm = 0; |
402 else if (p[1] == 'o') | 445 else if (p[1] == 'o') |
403 { | 446 { |
404 switch (p[2]) | 447 switch (p[2]) |
498 else if (strcmp(p + 1, "nofloat") == 0) | 541 else if (strcmp(p + 1, "nofloat") == 0) |
499 global.params.nofloat = 1; | 542 global.params.nofloat = 1; |
500 else if (strcmp(p + 1, "quiet") == 0) | 543 else if (strcmp(p + 1, "quiet") == 0) |
501 global.params.quiet = 1; | 544 global.params.quiet = 1; |
502 else if (strcmp(p + 1, "release") == 0) | 545 else if (strcmp(p + 1, "release") == 0) |
503 global.params.release = 1; | 546 { |
547 global.params.useInvariants = 0; | |
548 global.params.useIn = 0; | |
549 global.params.useOut = 0; | |
550 global.params.useAssert = 0; | |
551 global.params.useArrayBounds = 0; | |
552 } | |
504 else if (strcmp(p + 1, "unittest") == 0) | 553 else if (strcmp(p + 1, "unittest") == 0) |
505 global.params.useUnitTests = 1; | 554 global.params.useUnitTests = 1; |
506 else if (p[1] == 'I') | 555 else if (p[1] == 'I') |
507 { | 556 { |
508 if (!global.params.imppath) | 557 if (!global.params.imppath) |
542 goto Lerror; | 591 goto Lerror; |
543 } | 592 } |
544 else if (p[6]) | 593 else if (p[6]) |
545 goto Lerror; | 594 goto Lerror; |
546 else | 595 else |
596 { | |
597 global.params.useInvariants = 1; | |
598 global.params.useIn = 1; | |
599 global.params.useOut = 1; | |
600 global.params.useAssert = 1; | |
601 global.params.useArrayBounds = 1; | |
547 global.params.debuglevel = 1; | 602 global.params.debuglevel = 1; |
603 } | |
548 } | 604 } |
549 else if (memcmp(p + 1, "version", 5) == 0) | 605 else if (memcmp(p + 1, "version", 5) == 0) |
550 { | 606 { |
551 // Parse: | 607 // Parse: |
552 // -version=number | 608 // -version=number |
615 } | 671 } |
616 else if (p[1] == 'm') | 672 else if (p[1] == 'm') |
617 { | 673 { |
618 global.params.llvmArch = p+2; | 674 global.params.llvmArch = p+2; |
619 } | 675 } |
676 else if (p[1] == 't') | |
677 { | |
678 if(strcmp(p + 2, "Linux") == 0) | |
679 global.params.os = OSLinux; | |
680 else if(strcmp(p + 2, "Windows") == 0) | |
681 global.params.os = OSWindows; | |
682 else if(strcmp(p + 2, "MacOSX") == 0) | |
683 global.params.os = OSMacOSX; | |
684 else | |
685 error("unrecognized target os '%s'", p + 2); | |
686 } | |
620 else | 687 else |
621 { | 688 { |
622 Lerror: | 689 Lerror: |
623 error("unrecognized switch '%s'", argv[i]); | 690 error("unrecognized switch '%s'", argv[i]); |
624 continue; | 691 continue; |
636 fatal(); | 703 fatal(); |
637 } | 704 } |
638 if (files.dim == 0) | 705 if (files.dim == 0) |
639 { usage(); | 706 { usage(); |
640 return EXIT_FAILURE; | 707 return EXIT_FAILURE; |
641 } | |
642 | |
643 if (global.params.release) | |
644 { global.params.useInvariants = 0; | |
645 global.params.useIn = 0; | |
646 global.params.useOut = 0; | |
647 global.params.useAssert = 0; | |
648 global.params.useArrayBounds = 0; | |
649 global.params.useSwitchError = 0; | |
650 } | 708 } |
651 | 709 |
652 if (global.params.run) | 710 if (global.params.run) |
653 global.params.quiet = 1; | 711 global.params.quiet = 1; |
654 | 712 |