Mercurial > projects > ldc
annotate gen/main.cpp @ 1506:76936858d1c6
Return `void*` from _d_allocclass so LLVM doesn't do weird things with it...
This allows `-instcombine` followed by `-gvn` to do devirtualization, so add
`-gvn` in strategic places in the default pass order.
author | Frits van Bommel <fvbommel wxs.nl> |
---|---|
date | Sat, 20 Jun 2009 11:39:13 +0200 |
parents | 7d3b47852a7a |
children | 26d061e61b02 833337c65fd3 |
rev | line source |
---|---|
989
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
1 // Pulled out of dmd/mars.c |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
2 |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
3 // some things are taken from llvm's llc tool |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
4 // which uses the llvm license |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
5 |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
6 #include "gen/llvm.h" |
1149
5ebe8224988b
Fixed problems introduced by previous commits that prevented Tango from compiling.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1147
diff
changeset
|
7 #include "llvm/LinkAllVMCore.h" |
1052
12ea38902e83
Add '-singleobj' command line switch that will tell LDC to link LLVM modules internally and only emit a single object file.
Christian Kamm <kamm incasoftware de>
parents:
1033
diff
changeset
|
8 #include "llvm/Linker.h" |
1149
5ebe8224988b
Fixed problems introduced by previous commits that prevented Tango from compiling.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1147
diff
changeset
|
9 #include "llvm/System/Signals.h" |
989
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
10 #include "llvm/Target/SubtargetFeature.h" |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
11 #include "llvm/Target/TargetMachine.h" |
1199
80a326087f59
Disable frame pointer elimination when -g or -gc is passed.
Christian Kamm <kamm incasoftware de>
parents:
1197
diff
changeset
|
12 #include "llvm/Target/TargetOptions.h" |
989
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
13 #include "llvm/Target/TargetMachineRegistry.h" |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
14 |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
15 #include <stdio.h> |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
16 #include <stdlib.h> |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
17 #include <assert.h> |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
18 #include <limits.h> |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
19 |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
20 #if POSIX |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
21 #include <errno.h> |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
22 #elif _WIN32 |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
23 #include <windows.h> |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
24 #endif |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
25 |
1103
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1073
diff
changeset
|
26 #include "rmem.h" |
989
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
27 #include "root.h" |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
28 |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
29 #include "mars.h" |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
30 #include "module.h" |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
31 #include "mtype.h" |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
32 #include "id.h" |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
33 #include "cond.h" |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
34 |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
35 #include "gen/logger.h" |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
36 #include "gen/linker.h" |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
37 #include "gen/irstate.h" |
1482
d9c5f5a43403
Run `semantic3` on imported modules, and emit new symbols with
Frits van Bommel <fvbommel wxs.nl>
parents:
1463
diff
changeset
|
38 #include "gen/optimizer.h" |
1052
12ea38902e83
Add '-singleobj' command line switch that will tell LDC to link LLVM modules internally and only emit a single object file.
Christian Kamm <kamm incasoftware de>
parents:
1033
diff
changeset
|
39 #include "gen/toobj.h" |
1390
c5a92bee639d
Don't try to strip metadata if we don't generate any
Frits van Bommel <fvbommel wxs.nl>
parents:
1387
diff
changeset
|
40 #include "gen/metadata.h" |
1324
b3674ad4026d
Strip metadata for -singleobj as a workaround to a LLVM linking bug.
Christian Kamm <kamm incasoftware de>
parents:
1313
diff
changeset
|
41 #include "gen/passes/Passes.h" |
989
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
42 |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
43 #include "gen/cl_options.h" |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
44 #include "gen/cl_helpers.h" |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
45 using namespace opts; |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
46 |
1103
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1073
diff
changeset
|
47 #include "gen/configfile.h" |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1073
diff
changeset
|
48 |
989
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
49 extern void getenv_setargv(const char *envvar, int *pargc, char** *pargv); |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
50 extern void backend_init(); |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
51 extern void backend_term(); |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
52 |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
53 static cl::opt<bool> noDefaultLib("nodefaultlib", |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
54 cl::desc("Don't add a default library for linking implicitly"), |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
55 cl::ZeroOrMore); |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
56 |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
57 static ArrayAdapter impPathsStore("I", global.params.imppath); |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
58 static cl::list<std::string, ArrayAdapter> importPaths("I", |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
59 cl::desc("Where to look for imports"), |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
60 cl::value_desc("path"), |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
61 cl::location(impPathsStore), |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
62 cl::Prefix); |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
63 |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
64 static ArrayAdapter defaultLibStore("defaultlib", global.params.defaultlibnames); |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
65 static cl::list<std::string, ArrayAdapter> defaultlibs("defaultlib", |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
66 cl::desc("Set default libraries for non-debug build"), |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
67 cl::value_desc("lib,..."), |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
68 cl::location(defaultLibStore), |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
69 cl::CommaSeparated); |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
70 |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
71 static ArrayAdapter debugLibStore("debuglib", global.params.debuglibnames); |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
72 static cl::list<std::string, ArrayAdapter> debuglibs("debuglib", |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
73 cl::desc("Set default libraries for debug build"), |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
74 cl::value_desc("lib,..."), |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
75 cl::location(debugLibStore), |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
76 cl::CommaSeparated); |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
77 |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
78 void printVersion() { |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
79 printf("LLVM D Compiler %s\nbased on DMD %s and %s\n%s\n%s\n", |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
80 global.ldc_version, global.version, global.llvm_version, global.copyright, global.written); |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
81 printf("D Language Documentation: http://www.digitalmars.com/d/1.0/index.html\n" |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
82 "LDC Homepage: http://www.dsource.org/projects/ldc\n"); |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
83 } |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
84 |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
85 // Helper function to handle -d-debug=* and -d-version=* |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
86 static void processVersions(std::vector<std::string>& list, char* type, |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
87 void (*setLevel)(unsigned), void (*addIdent)(const char*)) { |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
88 typedef std::vector<std::string>::iterator It; |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
89 |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
90 for(It I = list.begin(), E = list.end(); I != E; ++I) { |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
91 const char* value = I->c_str(); |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
92 if (isdigit(value[0])) { |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
93 errno = 0; |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
94 char* end; |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
95 long level = strtol(value, &end, 10); |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
96 if (*end || errno || level > INT_MAX) { |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
97 error("Invalid %s level: %s", type, I->c_str()); |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
98 } else { |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
99 setLevel((unsigned)level); |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
100 } |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
101 } else { |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
102 char* cstr = mem.strdup(value); |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
103 if (Lexer::isValidIdentifier(cstr)) { |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
104 addIdent(cstr); |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
105 continue; |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
106 } else { |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
107 error("Invalid %s identifier or level: '%s'", type, I->c_str()); |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
108 } |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
109 } |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
110 } |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
111 } |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
112 |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
113 // Helper function to handle -of, -od, etc. |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
114 static void initFromString(char*& dest, const cl::opt<std::string>& src) { |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
115 dest = 0; |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
116 if (src.getNumOccurrences() != 0) { |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
117 if (src.empty()) |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
118 error("Expected argument to '-%s'", src.ArgStr); |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
119 dest = mem.strdup(src.c_str()); |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
120 } |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
121 } |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
122 |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
123 int main(int argc, char** argv) |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
124 { |
1149
5ebe8224988b
Fixed problems introduced by previous commits that prevented Tango from compiling.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1147
diff
changeset
|
125 // stack trace on signals |
5ebe8224988b
Fixed problems introduced by previous commits that prevented Tango from compiling.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1147
diff
changeset
|
126 llvm::sys::PrintStackTraceOnErrorSignal(); |
5ebe8224988b
Fixed problems introduced by previous commits that prevented Tango from compiling.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1147
diff
changeset
|
127 |
989
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
128 Array files; |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
129 char *p, *ext; |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
130 Module *m; |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
131 int status = EXIT_SUCCESS; |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
132 |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
133 // Set some default values |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
134 #if _WIN32 |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
135 char buf[MAX_PATH]; |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
136 GetModuleFileName(NULL, buf, MAX_PATH); |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
137 global.params.argv0 = buf; |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
138 #else |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
139 global.params.argv0 = argv[0]; |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
140 #endif |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
141 global.params.useSwitchError = 1; |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
142 |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
143 global.params.linkswitches = new Array(); |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
144 global.params.libfiles = new Array(); |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
145 global.params.objfiles = new Array(); |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
146 global.params.ddocfiles = new Array(); |
1402
1311dabc6a1f
Merged xfBuild patch for dependency tree generation. See #286.
Christian Kamm <kamm incasoftware de>
parents:
1390
diff
changeset
|
147 |
1311dabc6a1f
Merged xfBuild patch for dependency tree generation. See #286.
Christian Kamm <kamm incasoftware de>
parents:
1390
diff
changeset
|
148 global.params.moduleDeps = NULL; |
1311dabc6a1f
Merged xfBuild patch for dependency tree generation. See #286.
Christian Kamm <kamm incasoftware de>
parents:
1390
diff
changeset
|
149 global.params.moduleDepsFile = NULL; |
999
2b6c2e961f25
Added some missing version identifiers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
997
diff
changeset
|
150 |
989
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
151 // Set predefined version identifiers |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
152 VersionCondition::addPredefinedGlobalIdent("LLVM"); |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
153 VersionCondition::addPredefinedGlobalIdent("LDC"); |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
154 VersionCondition::addPredefinedGlobalIdent("all"); |
999
2b6c2e961f25
Added some missing version identifiers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
997
diff
changeset
|
155 #if DMDV2 |
2b6c2e961f25
Added some missing version identifiers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
997
diff
changeset
|
156 VersionCondition::addPredefinedGlobalIdent("D_Version2"); |
2b6c2e961f25
Added some missing version identifiers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
997
diff
changeset
|
157 #endif |
2b6c2e961f25
Added some missing version identifiers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
997
diff
changeset
|
158 |
1103
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1073
diff
changeset
|
159 // merge DFLAGS environment variable into argc/argv |
989
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
160 getenv_setargv("DFLAGS", &argc, &argv); |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
161 #if 0 |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
162 for (int i = 0; i < argc; i++) |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
163 { |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
164 printf("argv[%d] = '%s'\n", i, argv[i]); |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
165 } |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
166 #endif |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
167 |
1103
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1073
diff
changeset
|
168 // build complete fixed up list of command line arguments |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1073
diff
changeset
|
169 std::vector<const char*> final_args; |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1073
diff
changeset
|
170 final_args.reserve(argc); |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1073
diff
changeset
|
171 |
1197
1546b5162152
Make sure -run doesn't consume the config file flags.
Christian Kamm <kamm incasoftware de>
parents:
1187
diff
changeset
|
172 // insert command line args until -run is reached |
1546b5162152
Make sure -run doesn't consume the config file flags.
Christian Kamm <kamm incasoftware de>
parents:
1187
diff
changeset
|
173 int run_argnum = 1; |
1546b5162152
Make sure -run doesn't consume the config file flags.
Christian Kamm <kamm incasoftware de>
parents:
1187
diff
changeset
|
174 while (run_argnum < argc && strncmp(argv[run_argnum], "-run", 4) != 0) |
1546b5162152
Make sure -run doesn't consume the config file flags.
Christian Kamm <kamm incasoftware de>
parents:
1187
diff
changeset
|
175 ++run_argnum; |
1546b5162152
Make sure -run doesn't consume the config file flags.
Christian Kamm <kamm incasoftware de>
parents:
1187
diff
changeset
|
176 final_args.insert(final_args.end(), &argv[0], &argv[run_argnum]); |
1103
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1073
diff
changeset
|
177 |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1073
diff
changeset
|
178 // read the configuration file |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1073
diff
changeset
|
179 ConfigFile cfg_file; |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1073
diff
changeset
|
180 |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1073
diff
changeset
|
181 // just ignore errors for now, they are still printed |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1073
diff
changeset
|
182 #if DMDV2 |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1073
diff
changeset
|
183 #define CFG_FILENAME "ldc2.conf" |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1073
diff
changeset
|
184 #else |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1073
diff
changeset
|
185 #define CFG_FILENAME "ldc.conf" |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1073
diff
changeset
|
186 #endif |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1073
diff
changeset
|
187 cfg_file.read(global.params.argv0, (void*)main, CFG_FILENAME); |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1073
diff
changeset
|
188 #undef CFG_FILENAME |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1073
diff
changeset
|
189 |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1073
diff
changeset
|
190 // insert config file additions to the argument list |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1073
diff
changeset
|
191 final_args.insert(final_args.end(), cfg_file.switches_begin(), cfg_file.switches_end()); |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1073
diff
changeset
|
192 |
1197
1546b5162152
Make sure -run doesn't consume the config file flags.
Christian Kamm <kamm incasoftware de>
parents:
1187
diff
changeset
|
193 // insert -run and everything beyond |
1546b5162152
Make sure -run doesn't consume the config file flags.
Christian Kamm <kamm incasoftware de>
parents:
1187
diff
changeset
|
194 final_args.insert(final_args.end(), &argv[run_argnum], &argv[argc]); |
1546b5162152
Make sure -run doesn't consume the config file flags.
Christian Kamm <kamm incasoftware de>
parents:
1187
diff
changeset
|
195 |
1103
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1073
diff
changeset
|
196 #if 0 |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1073
diff
changeset
|
197 for (size_t i = 0; i < final_args.size(); ++i) |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1073
diff
changeset
|
198 { |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1073
diff
changeset
|
199 printf("final_args[%zu] = %s\n", i, final_args[i]); |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1073
diff
changeset
|
200 } |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1073
diff
changeset
|
201 #endif |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1073
diff
changeset
|
202 |
989
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
203 // Handle fixed-up arguments! |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
204 cl::SetVersionPrinter(&printVersion); |
1103
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1073
diff
changeset
|
205 cl::ParseCommandLineOptions(final_args.size(), (char**)&final_args[0], "LLVM-based D Compiler\n", true); |
989
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
206 |
1484
7d3b47852a7a
Print the path to the configuration file being used if `-v` is passed.
Frits van Bommel <fvbommel wxs.nl>
parents:
1482
diff
changeset
|
207 // Print config file path if -v was passed |
7d3b47852a7a
Print the path to the configuration file being used if `-v` is passed.
Frits van Bommel <fvbommel wxs.nl>
parents:
1482
diff
changeset
|
208 if (global.params.verbose) { |
7d3b47852a7a
Print the path to the configuration file being used if `-v` is passed.
Frits van Bommel <fvbommel wxs.nl>
parents:
1482
diff
changeset
|
209 const std::string& path = cfg_file.path(); |
7d3b47852a7a
Print the path to the configuration file being used if `-v` is passed.
Frits van Bommel <fvbommel wxs.nl>
parents:
1482
diff
changeset
|
210 if (!path.empty()) |
7d3b47852a7a
Print the path to the configuration file being used if `-v` is passed.
Frits van Bommel <fvbommel wxs.nl>
parents:
1482
diff
changeset
|
211 printf("config %s\n", path.c_str()); |
7d3b47852a7a
Print the path to the configuration file being used if `-v` is passed.
Frits van Bommel <fvbommel wxs.nl>
parents:
1482
diff
changeset
|
212 } |
7d3b47852a7a
Print the path to the configuration file being used if `-v` is passed.
Frits van Bommel <fvbommel wxs.nl>
parents:
1482
diff
changeset
|
213 |
989
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
214 // Negated options |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
215 global.params.link = !compileOnly; |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
216 global.params.obj = !dontWriteObj; |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
217 global.params.useInlineAsm = !noAsm; |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
218 |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
219 // String options: std::string --> char* |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
220 initFromString(global.params.objname, objectFile); |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
221 initFromString(global.params.objdir, objectDir); |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
222 |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
223 initFromString(global.params.docdir, ddocDir); |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
224 initFromString(global.params.docname, ddocFile); |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
225 global.params.doDocComments |= |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
226 global.params.docdir || global.params.docname; |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
227 |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
228 #ifdef _DH |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
229 initFromString(global.params.hdrdir, hdrDir); |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
230 initFromString(global.params.hdrname, hdrFile); |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
231 global.params.doHdrGeneration |= |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
232 global.params.hdrdir || global.params.hdrname; |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
233 #endif |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
234 |
1402
1311dabc6a1f
Merged xfBuild patch for dependency tree generation. See #286.
Christian Kamm <kamm incasoftware de>
parents:
1390
diff
changeset
|
235 initFromString(global.params.moduleDepsFile, moduleDepsFile); |
1311dabc6a1f
Merged xfBuild patch for dependency tree generation. See #286.
Christian Kamm <kamm incasoftware de>
parents:
1390
diff
changeset
|
236 if (global.params.moduleDepsFile != NULL) |
1311dabc6a1f
Merged xfBuild patch for dependency tree generation. See #286.
Christian Kamm <kamm incasoftware de>
parents:
1390
diff
changeset
|
237 { |
1311dabc6a1f
Merged xfBuild patch for dependency tree generation. See #286.
Christian Kamm <kamm incasoftware de>
parents:
1390
diff
changeset
|
238 global.params.moduleDeps = new OutBuffer; |
1311dabc6a1f
Merged xfBuild patch for dependency tree generation. See #286.
Christian Kamm <kamm incasoftware de>
parents:
1390
diff
changeset
|
239 } |
1311dabc6a1f
Merged xfBuild patch for dependency tree generation. See #286.
Christian Kamm <kamm incasoftware de>
parents:
1390
diff
changeset
|
240 |
989
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
241 processVersions(debugArgs, "debug", |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
242 DebugCondition::setGlobalLevel, |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
243 DebugCondition::addGlobalIdent); |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
244 processVersions(versions, "version", |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
245 VersionCondition::setGlobalLevel, |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
246 VersionCondition::addGlobalIdent); |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
247 |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
248 global.params.output_o = |
1415
bac3931b3de3
Fix a behavioral change accidentally introduced by the move to the LLVM
Frits van Bommel <fvbommel wxs.nl>
parents:
1403
diff
changeset
|
249 (opts::output_o == cl::BOU_UNSET |
bac3931b3de3
Fix a behavioral change accidentally introduced by the move to the LLVM
Frits van Bommel <fvbommel wxs.nl>
parents:
1403
diff
changeset
|
250 && !(opts::output_bc || opts::output_ll || opts::output_s)) |
989
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
251 ? OUTPUTFLAGdefault |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
252 : opts::output_o == cl::BOU_TRUE |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
253 ? OUTPUTFLAGset |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
254 : OUTPUTFLAGno; |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
255 global.params.output_bc = opts::output_bc ? OUTPUTFLAGset : OUTPUTFLAGno; |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
256 global.params.output_ll = opts::output_ll ? OUTPUTFLAGset : OUTPUTFLAGno; |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
257 global.params.output_s = opts::output_s ? OUTPUTFLAGset : OUTPUTFLAGno; |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
258 |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
259 if (global.params.run || !runargs.empty()) { |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
260 // FIXME: how to properly detect the presence of a PositionalEatsArgs |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
261 // option without parameters? We want to emit an error in that case... |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
262 // You'd think getNumOccurrences would do it, but it just returns the |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
263 // number of parameters) |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
264 // NOTE: Hacked around it by detecting -run in getenv_setargv(), where |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
265 // we're looking for it anyway, and pre-setting the flag... |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
266 global.params.run = true; |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
267 if (!runargs.empty()) { |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
268 files.push(mem.strdup(runargs[0].c_str())); |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
269 } else { |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
270 global.params.run = false; |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
271 error("Expected at least one argument to '-run'\n"); |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
272 } |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
273 } |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
274 |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
275 |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
276 files.reserve(fileList.size()); |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
277 typedef std::vector<std::string>::iterator It; |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
278 for(It I = fileList.begin(), E = fileList.end(); I != E; ++I) |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
279 if (!I->empty()) |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
280 files.push(mem.strdup(I->c_str())); |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
281 |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
282 if (global.errors) |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
283 { |
1007
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
284 fatal(); |
989
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
285 } |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
286 if (files.dim == 0) |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
287 { |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
288 cl::PrintHelpMessage(); |
1007
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
289 return EXIT_FAILURE; |
989
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
290 } |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
291 |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
292 Array* libs; |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
293 if (global.params.symdebug) |
1199
80a326087f59
Disable frame pointer elimination when -g or -gc is passed.
Christian Kamm <kamm incasoftware de>
parents:
1197
diff
changeset
|
294 { |
1007
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
295 libs = global.params.debuglibnames; |
1199
80a326087f59
Disable frame pointer elimination when -g or -gc is passed.
Christian Kamm <kamm incasoftware de>
parents:
1197
diff
changeset
|
296 llvm::NoFramePointerElim = true; |
80a326087f59
Disable frame pointer elimination when -g or -gc is passed.
Christian Kamm <kamm incasoftware de>
parents:
1197
diff
changeset
|
297 } |
989
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
298 else |
1007
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
299 libs = global.params.defaultlibnames; |
989
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
300 |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
301 if (libs) |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
302 { |
1007
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
303 for (int i = 0; i < libs->dim; i++) |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
304 { |
1187
a95fc9fcad5c
Make sure -defaultlib and -debuglib don't get cut off if longer than 63 chars,
Frits van Bommel <fvbommel wxs.nl>
parents:
1170
diff
changeset
|
305 char* lib = (char *)libs->data[i]; |
a95fc9fcad5c
Make sure -defaultlib and -debuglib don't get cut off if longer than 63 chars,
Frits van Bommel <fvbommel wxs.nl>
parents:
1170
diff
changeset
|
306 char *arg = (char *)mem.malloc(strlen(lib) + 3); |
1007
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
307 strcpy(arg, "-l"); |
1187
a95fc9fcad5c
Make sure -defaultlib and -debuglib don't get cut off if longer than 63 chars,
Frits van Bommel <fvbommel wxs.nl>
parents:
1170
diff
changeset
|
308 strcpy(arg+2, lib); |
1007
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
309 global.params.linkswitches->push(arg); |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
310 } |
989
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
311 } |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
312 else if (!noDefaultLib) |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
313 { |
1187
a95fc9fcad5c
Make sure -defaultlib and -debuglib don't get cut off if longer than 63 chars,
Frits van Bommel <fvbommel wxs.nl>
parents:
1170
diff
changeset
|
314 global.params.linkswitches->push(mem.strdup("-lldc-runtime")); |
a95fc9fcad5c
Make sure -defaultlib and -debuglib don't get cut off if longer than 63 chars,
Frits van Bommel <fvbommel wxs.nl>
parents:
1170
diff
changeset
|
315 global.params.linkswitches->push(mem.strdup("-ltango-cc-tango")); |
a95fc9fcad5c
Make sure -defaultlib and -debuglib don't get cut off if longer than 63 chars,
Frits van Bommel <fvbommel wxs.nl>
parents:
1170
diff
changeset
|
316 global.params.linkswitches->push(mem.strdup("-ltango-gc-basic")); |
1007
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
317 // pass the runtime again to resolve issues |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
318 // with linking order |
1187
a95fc9fcad5c
Make sure -defaultlib and -debuglib don't get cut off if longer than 63 chars,
Frits van Bommel <fvbommel wxs.nl>
parents:
1170
diff
changeset
|
319 global.params.linkswitches->push(mem.strdup("-lldc-runtime")); |
989
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
320 } |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
321 |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
322 if (global.params.run) |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
323 quiet = 1; |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
324 |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
325 if (global.params.useUnitTests) |
1007
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
326 global.params.useAssert = 1; |
989
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
327 |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
328 // LDC output determination |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
329 |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
330 // if we don't link, autodetect target from extension |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
331 if(!global.params.link && global.params.objname) { |
1007
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
332 ext = FileName::ext(global.params.objname); |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
333 bool autofound = false; |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
334 if (!ext) { |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
335 // keep things as they are |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
336 } else if (strcmp(ext, global.ll_ext) == 0) { |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
337 global.params.output_ll = OUTPUTFLAGset; |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
338 autofound = true; |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
339 } else if (strcmp(ext, global.bc_ext) == 0) { |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
340 global.params.output_bc = OUTPUTFLAGset; |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
341 autofound = true; |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
342 } else if (strcmp(ext, global.s_ext) == 0) { |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
343 global.params.output_s = OUTPUTFLAGset; |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
344 autofound = true; |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
345 } else if (strcmp(ext, global.obj_ext) == 0) { |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
346 global.params.output_o = OUTPUTFLAGset; |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
347 autofound = true; |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
348 } else { |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
349 // append dot, so forceExt won't change existing name even if it contains dots |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
350 size_t len = strlen(global.params.objname); |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
351 size_t extlen = strlen("."); |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
352 char* s = (char *)mem.malloc(len + 1 + extlen + 1); |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
353 memcpy(s, global.params.objname, len); |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
354 s[len] = '.'; |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
355 s[len+1+extlen] = 0; |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
356 global.params.objname = s; |
989
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
357 |
1007
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
358 } |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
359 if(autofound && global.params.output_o == OUTPUTFLAGdefault) |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
360 global.params.output_o = OUTPUTFLAGno; |
989
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
361 } |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
362 |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
363 // only link if possible |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
364 if (!global.params.obj || !global.params.output_o) |
1007
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
365 global.params.link = 0; |
989
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
366 |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
367 if (global.params.link) |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
368 { |
1007
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
369 global.params.exefile = global.params.objname; |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
370 if (files.dim > 1) |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
371 global.params.objname = NULL; |
989
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
372 } |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
373 else if (global.params.run) |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
374 { |
1007
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
375 error("flags conflict with -run"); |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
376 fatal(); |
989
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
377 } |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
378 else |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
379 { |
1433
f79971a45bee
Fix #309: allow -of with multiple source files if -singleobj is given.
Christian Kamm <kamm incasoftware de>
parents:
1415
diff
changeset
|
380 if (global.params.objname && files.dim > 1 && !singleObj) |
1007
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
381 { |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
382 error("multiple source files, but only one .obj name"); |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
383 fatal(); |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
384 } |
989
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
385 } |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
386 |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
387 // create a proper target |
1147
dbe4af57b240
Changed use of toObjFile to a new codegen method.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1103
diff
changeset
|
388 Ir ir; |
1021
d1ec9ff0e9ba
Implemented basic -m32 and -m64 options.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
1007
diff
changeset
|
389 |
d1ec9ff0e9ba
Implemented basic -m32 and -m64 options.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
1007
diff
changeset
|
390 // check -m32/64 sanity |
d1ec9ff0e9ba
Implemented basic -m32 and -m64 options.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
1007
diff
changeset
|
391 if (m32bits && m64bits) |
d1ec9ff0e9ba
Implemented basic -m32 and -m64 options.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
1007
diff
changeset
|
392 error("cannot use both -m32 and -m64 options"); |
d1ec9ff0e9ba
Implemented basic -m32 and -m64 options.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
1007
diff
changeset
|
393 else if ((m32bits || m64bits) && (mArch != 0 || !mTargetTriple.empty())) |
d1ec9ff0e9ba
Implemented basic -m32 and -m64 options.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
1007
diff
changeset
|
394 error("-m32 and -m64 switches cannot be used together with -march and -mtriple switches"); |
d1ec9ff0e9ba
Implemented basic -m32 and -m64 options.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
1007
diff
changeset
|
395 if (global.errors) |
d1ec9ff0e9ba
Implemented basic -m32 and -m64 options.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
1007
diff
changeset
|
396 fatal(); |
d1ec9ff0e9ba
Implemented basic -m32 and -m64 options.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
1007
diff
changeset
|
397 |
989
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
398 llvm::Module mod("dummy"); |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
399 |
1021
d1ec9ff0e9ba
Implemented basic -m32 and -m64 options.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
1007
diff
changeset
|
400 // override triple if needed |
d1ec9ff0e9ba
Implemented basic -m32 and -m64 options.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
1007
diff
changeset
|
401 const char* defaultTriple = DEFAULT_TARGET_TRIPLE; |
d1ec9ff0e9ba
Implemented basic -m32 and -m64 options.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
1007
diff
changeset
|
402 if ((sizeof(void*) == 4 && m64bits) || (sizeof(void*) == 8 && m32bits)) |
d1ec9ff0e9ba
Implemented basic -m32 and -m64 options.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
1007
diff
changeset
|
403 { |
d1ec9ff0e9ba
Implemented basic -m32 and -m64 options.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
1007
diff
changeset
|
404 defaultTriple = DEFAULT_ALT_TARGET_TRIPLE; |
d1ec9ff0e9ba
Implemented basic -m32 and -m64 options.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
1007
diff
changeset
|
405 } |
d1ec9ff0e9ba
Implemented basic -m32 and -m64 options.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
1007
diff
changeset
|
406 |
989
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
407 // did the user override the target triple? |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
408 if (mTargetTriple.empty()) |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
409 { |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
410 if (mArch != 0) |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
411 { |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
412 error("you must specify a target triple as well with -mtriple when using the -march option"); |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
413 fatal(); |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
414 } |
1021
d1ec9ff0e9ba
Implemented basic -m32 and -m64 options.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
1007
diff
changeset
|
415 global.params.targetTriple = defaultTriple; |
989
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
416 } |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
417 else |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
418 { |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
419 global.params.targetTriple = mTargetTriple.c_str(); |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
420 } |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
421 |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
422 mod.setTargetTriple(global.params.targetTriple); |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
423 |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
424 // Allocate target machine. First, check whether the user has |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
425 // explicitly specified an architecture to compile for. |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
426 if (mArch == 0) |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
427 { |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
428 std::string Err; |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
429 mArch = llvm::TargetMachineRegistry::getClosestStaticTargetForModule(mod, Err); |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
430 if (mArch == 0) |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
431 { |
997
4f12ec3216cf
Missing %s error param in main.cpp
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
989
diff
changeset
|
432 error("failed to auto-select target: %s, please use the -march option", Err.c_str()); |
989
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
433 fatal(); |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
434 } |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
435 } |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
436 |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
437 // Package up features to be passed to target/subtarget |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
438 std::string FeaturesStr; |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
439 if (mCPU.size() || mAttrs.size()) |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
440 { |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
441 llvm::SubtargetFeatures Features; |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
442 Features.setCPU(mCPU); |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
443 for (unsigned i = 0; i != mAttrs.size(); ++i) |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
444 Features.AddFeature(mAttrs[i]); |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
445 FeaturesStr = Features.getString(); |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
446 } |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
447 |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
448 std::auto_ptr<llvm::TargetMachine> target(mArch->CtorFn(mod, FeaturesStr)); |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
449 assert(target.get() && "Could not allocate target machine!"); |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
450 gTargetMachine = target.get(); |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
451 gTargetData = gTargetMachine->getTargetData(); |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
452 |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
453 // get final data layout |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
454 std::string datalayout = gTargetData->getStringRepresentation(); |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
455 global.params.dataLayout = datalayout.c_str(); |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
456 |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
457 global.params.llvmArch = mArch->Name; |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
458 |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
459 if (strcmp(global.params.llvmArch,"x86")==0) { |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
460 VersionCondition::addPredefinedGlobalIdent("X86"); |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
461 global.params.isLE = true; |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
462 global.params.is64bit = false; |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
463 global.params.cpu = ARCHx86; |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
464 if (global.params.useInlineAsm) { |
1033
abfe71f5b911
Switch LLVM_InlineAsm -> D_InlineAsm. It's for real this time, hopefully.
Christian Kamm <kamm incasoftware de>
parents:
1021
diff
changeset
|
465 VersionCondition::addPredefinedGlobalIdent("D_InlineAsm_X86"); |
989
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
466 } |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
467 } |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
468 else if (strcmp(global.params.llvmArch,"x86-64")==0) { |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
469 VersionCondition::addPredefinedGlobalIdent("X86_64"); |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
470 global.params.isLE = true; |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
471 global.params.is64bit = true; |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
472 global.params.cpu = ARCHx86_64; |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
473 if (global.params.useInlineAsm) { |
1033
abfe71f5b911
Switch LLVM_InlineAsm -> D_InlineAsm. It's for real this time, hopefully.
Christian Kamm <kamm incasoftware de>
parents:
1021
diff
changeset
|
474 VersionCondition::addPredefinedGlobalIdent("D_InlineAsm_X86_64"); |
989
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
475 } |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
476 } |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
477 else if (strcmp(global.params.llvmArch,"ppc32")==0) { |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
478 VersionCondition::addPredefinedGlobalIdent("PPC"); |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
479 global.params.isLE = false; |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
480 global.params.is64bit = false; |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
481 global.params.cpu = ARCHppc; |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
482 } |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
483 else if (strcmp(global.params.llvmArch,"ppc64")==0) { |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
484 VersionCondition::addPredefinedGlobalIdent("PPC64"); |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
485 global.params.isLE = false; |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
486 global.params.is64bit = true; |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
487 global.params.cpu = ARCHppc_64; |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
488 } |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
489 else if (strcmp(global.params.llvmArch,"arm")==0) { |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
490 VersionCondition::addPredefinedGlobalIdent("ARM"); |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
491 global.params.isLE = true; |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
492 global.params.is64bit = false; |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
493 global.params.cpu = ARCHarm; |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
494 } |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
495 else if (strcmp(global.params.llvmArch,"thumb")==0) { |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
496 VersionCondition::addPredefinedGlobalIdent("Thumb"); |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
497 global.params.isLE = true; |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
498 global.params.is64bit = false; |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
499 global.params.cpu = ARCHthumb; |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
500 } |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
501 else { |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
502 error("invalid cpu architecture specified: %s", global.params.llvmArch); |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
503 fatal(); |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
504 } |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
505 |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
506 // endianness |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
507 if (global.params.isLE) { |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
508 VersionCondition::addPredefinedGlobalIdent("LittleEndian"); |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
509 } |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
510 else { |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
511 VersionCondition::addPredefinedGlobalIdent("BigEndian"); |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
512 } |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
513 |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
514 // a generic 64bit version |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
515 if (global.params.is64bit) { |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
516 VersionCondition::addPredefinedGlobalIdent("LLVM64"); |
999
2b6c2e961f25
Added some missing version identifiers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
997
diff
changeset
|
517 // FIXME: is this always correct? |
2b6c2e961f25
Added some missing version identifiers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
997
diff
changeset
|
518 VersionCondition::addPredefinedGlobalIdent("D_LP64"); |
989
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
519 } |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
520 |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
521 // parse the OS out of the target triple |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
522 // see http://gcc.gnu.org/install/specific.html for details |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
523 // also llvm's different SubTargets have useful information |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
524 std::string triple = global.params.targetTriple; |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
525 size_t npos = std::string::npos; |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
526 |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
527 // windows |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
528 // FIXME: win64 |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
529 if (triple.find("windows") != npos || triple.find("win32") != npos || triple.find("mingw") != npos) |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
530 { |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
531 global.params.os = OSWindows; |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
532 VersionCondition::addPredefinedGlobalIdent("Windows"); |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
533 VersionCondition::addPredefinedGlobalIdent("Win32"); |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
534 VersionCondition::addPredefinedGlobalIdent("mingw32"); |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
535 } |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
536 // FIXME: cygwin |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
537 else if (triple.find("cygwin") != npos) |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
538 { |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
539 error("CygWin is not yet supported"); |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
540 fatal(); |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
541 } |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
542 // linux |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
543 else if (triple.find("linux") != npos) |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
544 { |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
545 global.params.os = OSLinux; |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
546 VersionCondition::addPredefinedGlobalIdent("linux"); |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
547 VersionCondition::addPredefinedGlobalIdent("Posix"); |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
548 } |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
549 // darwin |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
550 else if (triple.find("-darwin") != npos) |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
551 { |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
552 global.params.os = OSMacOSX; |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
553 VersionCondition::addPredefinedGlobalIdent("OSX"); |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
554 VersionCondition::addPredefinedGlobalIdent("darwin"); |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
555 VersionCondition::addPredefinedGlobalIdent("Posix"); |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
556 } |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
557 // freebsd |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
558 else if (triple.find("-freebsd") != npos) |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
559 { |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
560 global.params.os = OSFreeBSD; |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
561 VersionCondition::addPredefinedGlobalIdent("freebsd"); |
1387
5855958073a9
Added new FreeBSD and Solaris predefined version identifiers.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1372
diff
changeset
|
562 VersionCondition::addPredefinedGlobalIdent("FreeBSD"); |
989
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
563 VersionCondition::addPredefinedGlobalIdent("Posix"); |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
564 } |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
565 // solaris |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
566 else if (triple.find("-solaris") != npos) |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
567 { |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
568 global.params.os = OSSolaris; |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
569 VersionCondition::addPredefinedGlobalIdent("solaris"); |
1387
5855958073a9
Added new FreeBSD and Solaris predefined version identifiers.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1372
diff
changeset
|
570 VersionCondition::addPredefinedGlobalIdent("Solaris"); |
989
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
571 VersionCondition::addPredefinedGlobalIdent("Posix"); |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
572 } |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
573 // unsupported |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
574 else |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
575 { |
1463 | 576 error("target '%s' is not yet supported", global.params.targetTriple); |
989
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
577 fatal(); |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
578 } |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
579 |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
580 // added in 1.039 |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
581 if (global.params.doDocComments) |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
582 VersionCondition::addPredefinedGlobalIdent("D_Ddoc"); |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
583 |
999
2b6c2e961f25
Added some missing version identifiers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
997
diff
changeset
|
584 #if DMDV2 |
2b6c2e961f25
Added some missing version identifiers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
997
diff
changeset
|
585 // unittests? |
2b6c2e961f25
Added some missing version identifiers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
997
diff
changeset
|
586 if (global.params.useUnitTests) |
2b6c2e961f25
Added some missing version identifiers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
997
diff
changeset
|
587 VersionCondition::addPredefinedGlobalIdent("unittest"); |
2b6c2e961f25
Added some missing version identifiers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
997
diff
changeset
|
588 #endif |
2b6c2e961f25
Added some missing version identifiers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
997
diff
changeset
|
589 |
989
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
590 // Initialization |
1147
dbe4af57b240
Changed use of toObjFile to a new codegen method.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1103
diff
changeset
|
591 Type::init(&ir); |
989
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
592 Id::initialize(); |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
593 Module::init(); |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
594 initPrecedence(); |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
595 |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
596 backend_init(); |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
597 |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
598 //printf("%d source files\n",files.dim); |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
599 |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
600 // Build import search path |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
601 if (global.params.imppath) |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
602 { |
1007
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
603 for (int i = 0; i < global.params.imppath->dim; i++) |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
604 { |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
605 char *path = (char *)global.params.imppath->data[i]; |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
606 Array *a = FileName::splitPath(path); |
989
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
607 |
1007
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
608 if (a) |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
609 { |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
610 if (!global.path) |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
611 global.path = new Array(); |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
612 global.path->append(a); |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
613 } |
989
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
614 } |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
615 } |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
616 |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
617 // Build string import search path |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
618 if (global.params.fileImppath) |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
619 { |
1007
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
620 for (int i = 0; i < global.params.fileImppath->dim; i++) |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
621 { |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
622 char *path = (char *)global.params.fileImppath->data[i]; |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
623 Array *a = FileName::splitPath(path); |
989
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
624 |
1007
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
625 if (a) |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
626 { |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
627 if (!global.filePath) |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
628 global.filePath = new Array(); |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
629 global.filePath->append(a); |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
630 } |
989
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
631 } |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
632 } |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
633 |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
634 // Create Modules |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
635 Array modules; |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
636 modules.reserve(files.dim); |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
637 for (int i = 0; i < files.dim; i++) |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
638 { Identifier *id; |
1007
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
639 char *ext; |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
640 char *name; |
989
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
641 |
1007
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
642 p = (char *) files.data[i]; |
989
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
643 |
1007
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
644 p = FileName::name(p); // strip path |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
645 ext = FileName::ext(p); |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
646 if (ext) |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
647 { |
989
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
648 #if POSIX |
1007
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
649 if (strcmp(ext, global.obj_ext) == 0 || |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
650 strcmp(ext, global.bc_ext) == 0) |
989
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
651 #else |
1007
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
652 if (stricmp(ext, global.obj_ext) == 0 || |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
653 stricmp(ext, global.bc_ext) == 0) |
989
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
654 #endif |
1007
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
655 { |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
656 global.params.objfiles->push(files.data[i]); |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
657 continue; |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
658 } |
989
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
659 |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
660 #if POSIX |
1007
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
661 if (strcmp(ext, "a") == 0) |
989
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
662 #elif __MINGW32__ |
1007
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
663 if (stricmp(ext, "a") == 0) |
989
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
664 #else |
1007
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
665 if (stricmp(ext, "lib") == 0) |
989
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
666 #endif |
1007
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
667 { |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
668 global.params.libfiles->push(files.data[i]); |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
669 continue; |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
670 } |
989
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
671 |
1007
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
672 if (strcmp(ext, global.ddoc_ext) == 0) |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
673 { |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
674 global.params.ddocfiles->push(files.data[i]); |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
675 continue; |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
676 } |
989
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
677 |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
678 #if !POSIX |
1007
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
679 if (stricmp(ext, "res") == 0) |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
680 { |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
681 global.params.resfile = (char *)files.data[i]; |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
682 continue; |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
683 } |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
684 |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
685 if (stricmp(ext, "def") == 0) |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
686 { |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
687 global.params.deffile = (char *)files.data[i]; |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
688 continue; |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
689 } |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
690 |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
691 if (stricmp(ext, "exe") == 0) |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
692 { |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
693 global.params.exefile = (char *)files.data[i]; |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
694 continue; |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
695 } |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
696 #endif |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
697 |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
698 if (stricmp(ext, global.mars_ext) == 0 || |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
699 stricmp(ext, global.hdr_ext) == 0 || |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
700 stricmp(ext, "htm") == 0 || |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
701 stricmp(ext, "html") == 0 || |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
702 stricmp(ext, "xhtml") == 0) |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
703 { |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
704 ext--; // skip onto '.' |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
705 assert(*ext == '.'); |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
706 name = (char *)mem.malloc((ext - p) + 1); |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
707 memcpy(name, p, ext - p); |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
708 name[ext - p] = 0; // strip extension |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
709 |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
710 if (name[0] == 0 || |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
711 strcmp(name, "..") == 0 || |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
712 strcmp(name, ".") == 0) |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
713 { |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
714 Linvalid: |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
715 error("invalid file name '%s'", (char *)files.data[i]); |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
716 fatal(); |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
717 } |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
718 } |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
719 else |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
720 { error("unrecognized file extension %s\n", ext); |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
721 fatal(); |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
722 } |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
723 } |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
724 else |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
725 { name = p; |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
726 if (!*name) |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
727 goto Linvalid; |
989
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
728 } |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
729 |
1007
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
730 id = new Identifier(name, 0); |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
731 m = new Module((char *) files.data[i], id, global.params.doDocComments, global.params.doHdrGeneration); |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
732 modules.push(m); |
989
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
733 } |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
734 |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
735 // Read files, parse them |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
736 for (int i = 0; i < modules.dim; i++) |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
737 { |
1007
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
738 m = (Module *)modules.data[i]; |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
739 if (global.params.verbose) |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
740 printf("parse %s\n", m->toChars()); |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
741 if (!Module::rootModule) |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
742 Module::rootModule = m; |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
743 m->importedFrom = m; |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
744 m->read(0); |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
745 m->parse(); |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
746 m->buildTargetFiles(); |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
747 m->deleteObjFile(); |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
748 if (m->isDocFile) |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
749 { |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
750 m->gendocfile(); |
989
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
751 |
1007
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
752 // Remove m from list of modules |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
753 modules.remove(i); |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
754 i--; |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
755 } |
989
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
756 } |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
757 if (global.errors) |
1007
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
758 fatal(); |
989
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
759 #ifdef _DH |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
760 if (global.params.doHdrGeneration) |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
761 { |
1007
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
762 /* Generate 'header' import files. |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
763 * Since 'header' import files must be independent of command |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
764 * line switches and what else is imported, they are generated |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
765 * before any semantic analysis. |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
766 */ |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
767 for (int i = 0; i < modules.dim; i++) |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
768 { |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
769 m = (Module *)modules.data[i]; |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
770 if (global.params.verbose) |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
771 printf("import %s\n", m->toChars()); |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
772 m->genhdrfile(); |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
773 } |
989
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
774 } |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
775 if (global.errors) |
1007
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
776 fatal(); |
989
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
777 #endif |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
778 |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
779 // Do semantic analysis |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
780 for (int i = 0; i < modules.dim; i++) |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
781 { |
1007
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
782 m = (Module *)modules.data[i]; |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
783 if (global.params.verbose) |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
784 printf("semantic %s\n", m->toChars()); |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
785 m->semantic(); |
989
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
786 } |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
787 if (global.errors) |
1007
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
788 fatal(); |
989
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
789 |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
790 // Do pass 2 semantic analysis |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
791 for (int i = 0; i < modules.dim; i++) |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
792 { |
1007
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
793 m = (Module *)modules.data[i]; |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
794 if (global.params.verbose) |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
795 printf("semantic2 %s\n", m->toChars()); |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
796 m->semantic2(); |
989
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
797 } |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
798 if (global.errors) |
1007
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
799 fatal(); |
989
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
800 |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
801 // Do pass 3 semantic analysis |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
802 for (int i = 0; i < modules.dim; i++) |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
803 { |
1007
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
804 m = (Module *)modules.data[i]; |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
805 if (global.params.verbose) |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
806 printf("semantic3 %s\n", m->toChars()); |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
807 m->semantic3(); |
989
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
808 } |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
809 if (global.errors) |
1007
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
810 fatal(); |
989
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
811 |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
812 #if !IN_LLVM |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
813 // Scan for functions to inline |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
814 if (global.params.useInline) |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
815 { |
1007
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
816 /* The problem with useArrayBounds and useAssert is that the |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
817 * module being linked to may not have generated them, so if |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
818 * we inline functions from those modules, the symbols for them will |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
819 * not be found at link time. |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
820 */ |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
821 if (!global.params.useArrayBounds && !global.params.useAssert) |
1482
d9c5f5a43403
Run `semantic3` on imported modules, and emit new symbols with
Frits van Bommel <fvbommel wxs.nl>
parents:
1463
diff
changeset
|
822 #elif LLVM_REV >= 68940 |
d9c5f5a43403
Run `semantic3` on imported modules, and emit new symbols with
Frits van Bommel <fvbommel wxs.nl>
parents:
1463
diff
changeset
|
823 // This doesn't play nice with debug info at the moment |
d9c5f5a43403
Run `semantic3` on imported modules, and emit new symbols with
Frits van Bommel <fvbommel wxs.nl>
parents:
1463
diff
changeset
|
824 if (!global.params.symdebug && willInline()) |
d9c5f5a43403
Run `semantic3` on imported modules, and emit new symbols with
Frits van Bommel <fvbommel wxs.nl>
parents:
1463
diff
changeset
|
825 { |
d9c5f5a43403
Run `semantic3` on imported modules, and emit new symbols with
Frits van Bommel <fvbommel wxs.nl>
parents:
1463
diff
changeset
|
826 global.params.useAvailableExternally = true; |
d9c5f5a43403
Run `semantic3` on imported modules, and emit new symbols with
Frits van Bommel <fvbommel wxs.nl>
parents:
1463
diff
changeset
|
827 Logger::println("Running some extra semantic3's for inlining purposes"); |
d9c5f5a43403
Run `semantic3` on imported modules, and emit new symbols with
Frits van Bommel <fvbommel wxs.nl>
parents:
1463
diff
changeset
|
828 #else |
d9c5f5a43403
Run `semantic3` on imported modules, and emit new symbols with
Frits van Bommel <fvbommel wxs.nl>
parents:
1463
diff
changeset
|
829 // IN_LLVM, but available_externally not available yet. |
d9c5f5a43403
Run `semantic3` on imported modules, and emit new symbols with
Frits van Bommel <fvbommel wxs.nl>
parents:
1463
diff
changeset
|
830 if (false) |
d9c5f5a43403
Run `semantic3` on imported modules, and emit new symbols with
Frits van Bommel <fvbommel wxs.nl>
parents:
1463
diff
changeset
|
831 { |
d9c5f5a43403
Run `semantic3` on imported modules, and emit new symbols with
Frits van Bommel <fvbommel wxs.nl>
parents:
1463
diff
changeset
|
832 #endif |
989
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
833 { |
1007
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
834 // Do pass 3 semantic analysis on all imported modules, |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
835 // since otherwise functions in them cannot be inlined |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
836 for (int i = 0; i < Module::amodules.dim; i++) |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
837 { |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
838 m = (Module *)Module::amodules.data[i]; |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
839 if (global.params.verbose) |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
840 printf("semantic3 %s\n", m->toChars()); |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
841 m->semantic3(); |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
842 } |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
843 if (global.errors) |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
844 fatal(); |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
845 } |
989
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
846 |
1482
d9c5f5a43403
Run `semantic3` on imported modules, and emit new symbols with
Frits van Bommel <fvbommel wxs.nl>
parents:
1463
diff
changeset
|
847 #if !IN_LLVM |
1007
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
848 for (int i = 0; i < modules.dim; i++) |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
849 { |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
850 m = (Module *)modules.data[i]; |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
851 if (global.params.verbose) |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
852 printf("inline scan %s\n", m->toChars()); |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
853 m->inlineScan(); |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
854 } |
1482
d9c5f5a43403
Run `semantic3` on imported modules, and emit new symbols with
Frits van Bommel <fvbommel wxs.nl>
parents:
1463
diff
changeset
|
855 #endif |
989
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
856 } |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
857 if (global.errors) |
1007
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
858 fatal(); |
989
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
859 |
1402
1311dabc6a1f
Merged xfBuild patch for dependency tree generation. See #286.
Christian Kamm <kamm incasoftware de>
parents:
1390
diff
changeset
|
860 // write module dependencies to file if requested |
1311dabc6a1f
Merged xfBuild patch for dependency tree generation. See #286.
Christian Kamm <kamm incasoftware de>
parents:
1390
diff
changeset
|
861 if (global.params.moduleDepsFile != NULL) |
1311dabc6a1f
Merged xfBuild patch for dependency tree generation. See #286.
Christian Kamm <kamm incasoftware de>
parents:
1390
diff
changeset
|
862 { |
1311dabc6a1f
Merged xfBuild patch for dependency tree generation. See #286.
Christian Kamm <kamm incasoftware de>
parents:
1390
diff
changeset
|
863 assert (global.params.moduleDepsFile != NULL); |
1311dabc6a1f
Merged xfBuild patch for dependency tree generation. See #286.
Christian Kamm <kamm incasoftware de>
parents:
1390
diff
changeset
|
864 |
1311dabc6a1f
Merged xfBuild patch for dependency tree generation. See #286.
Christian Kamm <kamm incasoftware de>
parents:
1390
diff
changeset
|
865 File deps(global.params.moduleDepsFile); |
1311dabc6a1f
Merged xfBuild patch for dependency tree generation. See #286.
Christian Kamm <kamm incasoftware de>
parents:
1390
diff
changeset
|
866 OutBuffer* ob = global.params.moduleDeps; |
1311dabc6a1f
Merged xfBuild patch for dependency tree generation. See #286.
Christian Kamm <kamm incasoftware de>
parents:
1390
diff
changeset
|
867 deps.setbuffer((void*)ob->data, ob->offset); |
1311dabc6a1f
Merged xfBuild patch for dependency tree generation. See #286.
Christian Kamm <kamm incasoftware de>
parents:
1390
diff
changeset
|
868 deps.write(); |
1311dabc6a1f
Merged xfBuild patch for dependency tree generation. See #286.
Christian Kamm <kamm incasoftware de>
parents:
1390
diff
changeset
|
869 } |
1311dabc6a1f
Merged xfBuild patch for dependency tree generation. See #286.
Christian Kamm <kamm incasoftware de>
parents:
1390
diff
changeset
|
870 |
1052
12ea38902e83
Add '-singleobj' command line switch that will tell LDC to link LLVM modules internally and only emit a single object file.
Christian Kamm <kamm incasoftware de>
parents:
1033
diff
changeset
|
871 // collects llvm modules to be linked if singleobj is passed |
12ea38902e83
Add '-singleobj' command line switch that will tell LDC to link LLVM modules internally and only emit a single object file.
Christian Kamm <kamm incasoftware de>
parents:
1033
diff
changeset
|
872 std::vector<llvm::Module*> llvmModules; |
12ea38902e83
Add '-singleobj' command line switch that will tell LDC to link LLVM modules internally and only emit a single object file.
Christian Kamm <kamm incasoftware de>
parents:
1033
diff
changeset
|
873 |
989
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
874 // Generate output files |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
875 for (int i = 0; i < modules.dim; i++) |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
876 { |
1007
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
877 m = (Module *)modules.data[i]; |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
878 if (global.params.verbose) |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
879 printf("code %s\n", m->toChars()); |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
880 if (global.params.obj) |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
881 { |
1147
dbe4af57b240
Changed use of toObjFile to a new codegen method.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1103
diff
changeset
|
882 llvm::Module* lm = m->genLLVMModule(&ir); |
1052
12ea38902e83
Add '-singleobj' command line switch that will tell LDC to link LLVM modules internally and only emit a single object file.
Christian Kamm <kamm incasoftware de>
parents:
1033
diff
changeset
|
883 if (!singleObj) |
12ea38902e83
Add '-singleobj' command line switch that will tell LDC to link LLVM modules internally and only emit a single object file.
Christian Kamm <kamm incasoftware de>
parents:
1033
diff
changeset
|
884 { |
12ea38902e83
Add '-singleobj' command line switch that will tell LDC to link LLVM modules internally and only emit a single object file.
Christian Kamm <kamm incasoftware de>
parents:
1033
diff
changeset
|
885 m->deleteObjFile(); |
12ea38902e83
Add '-singleobj' command line switch that will tell LDC to link LLVM modules internally and only emit a single object file.
Christian Kamm <kamm incasoftware de>
parents:
1033
diff
changeset
|
886 writeModule(lm, m->objfile->name->str); |
12ea38902e83
Add '-singleobj' command line switch that will tell LDC to link LLVM modules internally and only emit a single object file.
Christian Kamm <kamm incasoftware de>
parents:
1033
diff
changeset
|
887 global.params.objfiles->push(m->objfile->name->str); |
12ea38902e83
Add '-singleobj' command line switch that will tell LDC to link LLVM modules internally and only emit a single object file.
Christian Kamm <kamm incasoftware de>
parents:
1033
diff
changeset
|
888 delete lm; |
12ea38902e83
Add '-singleobj' command line switch that will tell LDC to link LLVM modules internally and only emit a single object file.
Christian Kamm <kamm incasoftware de>
parents:
1033
diff
changeset
|
889 } |
12ea38902e83
Add '-singleobj' command line switch that will tell LDC to link LLVM modules internally and only emit a single object file.
Christian Kamm <kamm incasoftware de>
parents:
1033
diff
changeset
|
890 else |
12ea38902e83
Add '-singleobj' command line switch that will tell LDC to link LLVM modules internally and only emit a single object file.
Christian Kamm <kamm incasoftware de>
parents:
1033
diff
changeset
|
891 llvmModules.push_back(lm); |
1007
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
892 } |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
893 if (global.errors) |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
894 m->deleteObjFile(); |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
895 else |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
896 { |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
897 if (global.params.doDocComments) |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
898 m->gendocfile(); |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
899 } |
989
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
900 } |
1052
12ea38902e83
Add '-singleobj' command line switch that will tell LDC to link LLVM modules internally and only emit a single object file.
Christian Kamm <kamm incasoftware de>
parents:
1033
diff
changeset
|
901 |
12ea38902e83
Add '-singleobj' command line switch that will tell LDC to link LLVM modules internally and only emit a single object file.
Christian Kamm <kamm incasoftware de>
parents:
1033
diff
changeset
|
902 // internal linking for singleobj |
12ea38902e83
Add '-singleobj' command line switch that will tell LDC to link LLVM modules internally and only emit a single object file.
Christian Kamm <kamm incasoftware de>
parents:
1033
diff
changeset
|
903 if (singleObj && llvmModules.size() > 0) |
12ea38902e83
Add '-singleobj' command line switch that will tell LDC to link LLVM modules internally and only emit a single object file.
Christian Kamm <kamm incasoftware de>
parents:
1033
diff
changeset
|
904 { |
12ea38902e83
Add '-singleobj' command line switch that will tell LDC to link LLVM modules internally and only emit a single object file.
Christian Kamm <kamm incasoftware de>
parents:
1033
diff
changeset
|
905 Module* m = (Module*)modules.data[0]; |
12ea38902e83
Add '-singleobj' command line switch that will tell LDC to link LLVM modules internally and only emit a single object file.
Christian Kamm <kamm incasoftware de>
parents:
1033
diff
changeset
|
906 char* name = m->toChars(); |
12ea38902e83
Add '-singleobj' command line switch that will tell LDC to link LLVM modules internally and only emit a single object file.
Christian Kamm <kamm incasoftware de>
parents:
1033
diff
changeset
|
907 char* filename = m->objfile->name->str; |
12ea38902e83
Add '-singleobj' command line switch that will tell LDC to link LLVM modules internally and only emit a single object file.
Christian Kamm <kamm incasoftware de>
parents:
1033
diff
changeset
|
908 |
12ea38902e83
Add '-singleobj' command line switch that will tell LDC to link LLVM modules internally and only emit a single object file.
Christian Kamm <kamm incasoftware de>
parents:
1033
diff
changeset
|
909 llvm::Linker linker(name, name); |
12ea38902e83
Add '-singleobj' command line switch that will tell LDC to link LLVM modules internally and only emit a single object file.
Christian Kamm <kamm incasoftware de>
parents:
1033
diff
changeset
|
910 std::string errormsg; |
12ea38902e83
Add '-singleobj' command line switch that will tell LDC to link LLVM modules internally and only emit a single object file.
Christian Kamm <kamm incasoftware de>
parents:
1033
diff
changeset
|
911 for (int i = 0; i < llvmModules.size(); i++) |
12ea38902e83
Add '-singleobj' command line switch that will tell LDC to link LLVM modules internally and only emit a single object file.
Christian Kamm <kamm incasoftware de>
parents:
1033
diff
changeset
|
912 { |
1390
c5a92bee639d
Don't try to strip metadata if we don't generate any
Frits van Bommel <fvbommel wxs.nl>
parents:
1387
diff
changeset
|
913 #ifdef USE_METADATA |
1324
b3674ad4026d
Strip metadata for -singleobj as a workaround to a LLVM linking bug.
Christian Kamm <kamm incasoftware de>
parents:
1313
diff
changeset
|
914 //FIXME: workaround for llvm metadata bug: |
b3674ad4026d
Strip metadata for -singleobj as a workaround to a LLVM linking bug.
Christian Kamm <kamm incasoftware de>
parents:
1313
diff
changeset
|
915 // the LinkInModule call asserts with metadata unstripped |
b3674ad4026d
Strip metadata for -singleobj as a workaround to a LLVM linking bug.
Christian Kamm <kamm incasoftware de>
parents:
1313
diff
changeset
|
916 llvm::ModulePass* stripMD = createStripMetaData(); |
b3674ad4026d
Strip metadata for -singleobj as a workaround to a LLVM linking bug.
Christian Kamm <kamm incasoftware de>
parents:
1313
diff
changeset
|
917 stripMD->runOnModule(*llvmModules[i]); |
b3674ad4026d
Strip metadata for -singleobj as a workaround to a LLVM linking bug.
Christian Kamm <kamm incasoftware de>
parents:
1313
diff
changeset
|
918 delete stripMD; |
1390
c5a92bee639d
Don't try to strip metadata if we don't generate any
Frits van Bommel <fvbommel wxs.nl>
parents:
1387
diff
changeset
|
919 #endif |
c5a92bee639d
Don't try to strip metadata if we don't generate any
Frits van Bommel <fvbommel wxs.nl>
parents:
1387
diff
changeset
|
920 |
1052
12ea38902e83
Add '-singleobj' command line switch that will tell LDC to link LLVM modules internally and only emit a single object file.
Christian Kamm <kamm incasoftware de>
parents:
1033
diff
changeset
|
921 if(linker.LinkInModule(llvmModules[i], &errormsg)) |
1372
229e02867307
Fix format-string bugs by adding __attribute__((__format__)) in all applicable
Frits van Bommel <fvbommel wxs.nl>
parents:
1347
diff
changeset
|
922 error("%s", errormsg.c_str()); |
1052
12ea38902e83
Add '-singleobj' command line switch that will tell LDC to link LLVM modules internally and only emit a single object file.
Christian Kamm <kamm incasoftware de>
parents:
1033
diff
changeset
|
923 delete llvmModules[i]; |
12ea38902e83
Add '-singleobj' command line switch that will tell LDC to link LLVM modules internally and only emit a single object file.
Christian Kamm <kamm incasoftware de>
parents:
1033
diff
changeset
|
924 } |
12ea38902e83
Add '-singleobj' command line switch that will tell LDC to link LLVM modules internally and only emit a single object file.
Christian Kamm <kamm incasoftware de>
parents:
1033
diff
changeset
|
925 |
12ea38902e83
Add '-singleobj' command line switch that will tell LDC to link LLVM modules internally and only emit a single object file.
Christian Kamm <kamm incasoftware de>
parents:
1033
diff
changeset
|
926 m->deleteObjFile(); |
12ea38902e83
Add '-singleobj' command line switch that will tell LDC to link LLVM modules internally and only emit a single object file.
Christian Kamm <kamm incasoftware de>
parents:
1033
diff
changeset
|
927 writeModule(linker.getModule(), filename); |
12ea38902e83
Add '-singleobj' command line switch that will tell LDC to link LLVM modules internally and only emit a single object file.
Christian Kamm <kamm incasoftware de>
parents:
1033
diff
changeset
|
928 global.params.objfiles->push(filename); |
12ea38902e83
Add '-singleobj' command line switch that will tell LDC to link LLVM modules internally and only emit a single object file.
Christian Kamm <kamm incasoftware de>
parents:
1033
diff
changeset
|
929 } |
12ea38902e83
Add '-singleobj' command line switch that will tell LDC to link LLVM modules internally and only emit a single object file.
Christian Kamm <kamm incasoftware de>
parents:
1033
diff
changeset
|
930 |
989
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
931 backend_term(); |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
932 if (global.errors) |
1007
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
933 fatal(); |
989
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
934 |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
935 if (!global.params.objfiles->dim) |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
936 { |
1007
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
937 if (global.params.link) |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
938 error("no object files to link"); |
989
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
939 } |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
940 else |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
941 { |
1007
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
942 if (global.params.link) |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
943 //status = runLINK(); |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
944 linkObjToExecutable(global.params.argv0); |
989
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
945 |
1007
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
946 if (global.params.run) |
989
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
947 { |
1007
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
948 if (!status) |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
949 { |
1313
2bebd938548f
Fix typo in function name
Frits van Bommel <fvbommel wxs.nl>
parents:
1260
diff
changeset
|
950 status = runExecutable(); |
989
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
951 |
1007
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
952 /* Delete .obj files and .exe file |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
953 */ |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
954 for (int i = 0; i < modules.dim; i++) |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
955 { |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
956 m = (Module *)modules.data[i]; |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
957 m->deleteObjFile(); |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
958 } |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
959 deleteExecutable(); |
55051098d9fc
Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents:
999
diff
changeset
|
960 } |
989
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
961 } |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
962 } |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
963 |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
964 return status; |
420ef073448d
Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
965 } |