comparison gen/runtime.cpp @ 986:a8cb25d478c4

Use LLVM-style command line (instead of DMD-style) Note: For a backward compatible interface, use the new bin/ldmd script. It supports all old options while passing on anything it doesn't recognize. Some changes caused by this: * -debug and -version are now -d-debug and -d-version due to a conflict with standard LLVM options. * All "flag" options now allow an optional =true/=1/=false/=0 suffix. * Some "hidden debug switches" starting with "--" were renamed because LLVM doesn't care about the number of dashes, so they were conflicting with other options (such as -c). The new versions start with "-hidden-debug-" instead of "--" * --help works, but has a non-zero exit code. This breaks some Tango scripts which use it to test for compiler existence. See tango.patch. Some changes not (directly) caused by this; * (-enable/-disable)-FOO options are now available for pre- and postconditions. * -march is used instead of -m (like other LLVM programs), but -m is an alias for it. * -defaultlib, -debuglib, -d-debug and -d-version allow comma-separated values. The effect should be identical to specifying the same option multiple times. I decided against allowing these for some other options because paths might contain commas on some systems. * -fPIC is removed in favor of the standard LLVM option -relocation-model=pic Bug: * If -run is specified as the last argument in DFLAGS, no error is generated. (Not very serious IMHO)
author Frits van Bommel <fvbommel wxs.nl>
date Wed, 25 Feb 2009 17:34:51 +0100
parents 340acf1535d0
children f528e55fb32f
comparison
equal deleted inserted replaced
985:bce024c60adc 986:a8cb25d478c4
1 #include "gen/llvm.h" 1 #include "gen/llvm.h"
2 #include "llvm/Module.h" 2 #include "llvm/Module.h"
3 #include "llvm/Bitcode/ReaderWriter.h" 3 #include "llvm/Bitcode/ReaderWriter.h"
4 #include "llvm/Support/MemoryBuffer.h" 4 #include "llvm/Support/MemoryBuffer.h"
5 #include "llvm/Support/CommandLine.h"
5 6
6 #include "root.h" 7 #include "root.h"
7 #include "mars.h" 8 #include "mars.h"
8 #include "lexer.h" 9 #include "lexer.h"
9 #include "dsymbol.h" 10 #include "dsymbol.h"
13 #include "gen/runtime.h" 14 #include "gen/runtime.h"
14 #include "gen/logger.h" 15 #include "gen/logger.h"
15 #include "gen/tollvm.h" 16 #include "gen/tollvm.h"
16 #include "gen/irstate.h" 17 #include "gen/irstate.h"
17 18
19 //////////////////////////////////////////////////////////////////////////////////////////////////
20
21 static llvm::cl::opt<bool> noruntime("noruntime",
22 llvm::cl::desc("Do not allow code that generates implicit runtime calls"),
23 llvm::cl::ZeroOrMore);
24
25 //////////////////////////////////////////////////////////////////////////////////////////////////
26
18 static llvm::Module* M = NULL; 27 static llvm::Module* M = NULL;
19 static bool runtime_failed = false; 28 static bool runtime_failed = false;
20 29
21 static void LLVM_D_BuildRuntimeModule(); 30 static void LLVM_D_BuildRuntimeModule();
22 31
42 51
43 ////////////////////////////////////////////////////////////////////////////////////////////////// 52 //////////////////////////////////////////////////////////////////////////////////////////////////
44 53
45 llvm::Function* LLVM_D_GetRuntimeFunction(llvm::Module* target, const char* name) 54 llvm::Function* LLVM_D_GetRuntimeFunction(llvm::Module* target, const char* name)
46 { 55 {
47 if (global.params.noruntime) { 56 if (noruntime) {
48 error("No implicit runtime calls allowed with -noruntime option enabled"); 57 error("No implicit runtime calls allowed with -noruntime option enabled");
49 fatal(); 58 fatal();
50 } 59 }
51 60
52 if (!M) { 61 if (!M) {
78 llvm::GlobalVariable* gv = target->getNamedGlobal(name); 87 llvm::GlobalVariable* gv = target->getNamedGlobal(name);
79 if (gv) { 88 if (gv) {
80 return gv; 89 return gv;
81 } 90 }
82 91
83 if (global.params.noruntime) { 92 if (noruntime) {
84 error("No implicit runtime calls allowed with -noruntime option enabled"); 93 error("No implicit runtime calls allowed with -noruntime option enabled");
85 fatal(); 94 fatal();
86 } 95 }
87 96
88 if (!M) { 97 if (!M) {