annotate gen/main.cpp @ 1635:601d3eea4a68

Make -nodefaultlib override -de{fault,bug}lib=foo instead of vice versa.
author Matti Niemenmaa <matti.niemenmaa+hg@iki.fi>
date Fri, 05 Mar 2010 21:40:51 +0200
parents def7a1d494fd
children 9176437d98be
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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"
1518
26d061e61b02 Initialize LLVM target and asmprinter for the native and extra targets.
Christian Kamm <kamm incasoftware de>
parents: 1484
diff changeset
7 #include "gen/llvm-version.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
8 #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
9 #include "llvm/Linker.h"
1535
61f12f4651b5 Don't use llvm::getGlobalContext() anymore
Benjamin Kramer <benny.kra@gmail.com>
parents: 1534
diff changeset
10 #include "llvm/LLVMContext.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
11 #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
12 #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
13 #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
14 #include "llvm/Target/TargetOptions.h"
1544
8863cf7236e6 We need to parse mArch ourselves now
Benjamin Kramer <benny.kra@gmail.com>
parents: 1543
diff changeset
15 #include "llvm/Target/TargetRegistry.h"
1518
26d061e61b02 Initialize LLVM target and asmprinter for the native and extra targets.
Christian Kamm <kamm incasoftware de>
parents: 1484
diff changeset
16 #include "llvm/Target/TargetSelect.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
17
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 <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
19 #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
20 #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
21 #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
22
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
23 #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
24 #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
25 #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
26 #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
27 #endif
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
28
1103
b30fe7e1dbb9 - Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1073
diff changeset
29 #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
30 #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
31
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 "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
33 #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
34 #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
35 #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
36 #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
37
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
38 #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
39 #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
40 #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
41 #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
42 #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
43 #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
44 #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
45
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
46 #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
47 #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
48 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
49
1103
b30fe7e1dbb9 - Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1073
diff changeset
50 #include "gen/configfile.h"
b30fe7e1dbb9 - Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1073
diff changeset
51
989
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
52 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
53 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
54 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
55
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
56 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
57 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
58 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
59
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
60 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
61 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
62 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
63 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
64 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
65 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
66
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
67 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
68 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
69 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
70 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
71 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
72 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
73
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
74 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
75 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
76 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
77 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
78 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
79 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
80
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
81 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
82 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
83 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
84 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
85 "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
86 }
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
87
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
88 // 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
89 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
90 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
91 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
92
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
93 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
94 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
95 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
96 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
97 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
98 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
99 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
100 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
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 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
103 }
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
104 } else {
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
105 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
106 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
107 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
108 continue;
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
109 } else {
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
110 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
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 }
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
114 }
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
115
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
116 // 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
117 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
118 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
119 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
120 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
121 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
122 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
123 }
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
124 }
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
125
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
126 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
127 {
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
128 // 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
129 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
130
989
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
131 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
132 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
133 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
134 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
135
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
136 // 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
137 #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
138 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
139 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
140 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
141 #else
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
142 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
143 #endif
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.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
145
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.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
147 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
148 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
149 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
150
1311dabc6a1f Merged xfBuild patch for dependency tree generation. See #286.
Christian Kamm <kamm incasoftware de>
parents: 1390
diff changeset
151 global.params.moduleDeps = NULL;
1311dabc6a1f Merged xfBuild patch for dependency tree generation. See #286.
Christian Kamm <kamm incasoftware de>
parents: 1390
diff changeset
152 global.params.moduleDepsFile = NULL;
999
2b6c2e961f25 Added some missing version identifiers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 997
diff changeset
153
989
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
154 // 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
155 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
156 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
157 VersionCondition::addPredefinedGlobalIdent("all");
999
2b6c2e961f25 Added some missing version identifiers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 997
diff changeset
158 #if DMDV2
2b6c2e961f25 Added some missing version identifiers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 997
diff changeset
159 VersionCondition::addPredefinedGlobalIdent("D_Version2");
2b6c2e961f25 Added some missing version identifiers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 997
diff changeset
160 #endif
2b6c2e961f25 Added some missing version identifiers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 997
diff changeset
161
1103
b30fe7e1dbb9 - Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1073
diff changeset
162 // 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
163 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
164 #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
165 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
166 {
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
167 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
168 }
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
169 #endif
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
170
1103
b30fe7e1dbb9 - Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1073
diff changeset
171 // 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
172 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
173 final_args.reserve(argc);
b30fe7e1dbb9 - Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1073
diff changeset
174
1197
1546b5162152 Make sure -run doesn't consume the config file flags.
Christian Kamm <kamm incasoftware de>
parents: 1187
diff changeset
175 // 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
176 int run_argnum = 1;
1546b5162152 Make sure -run doesn't consume the config file flags.
Christian Kamm <kamm incasoftware de>
parents: 1187
diff changeset
177 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
178 ++run_argnum;
1546b5162152 Make sure -run doesn't consume the config file flags.
Christian Kamm <kamm incasoftware de>
parents: 1187
diff changeset
179 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
180
b30fe7e1dbb9 - Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1073
diff changeset
181 // read the configuration file
b30fe7e1dbb9 - Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1073
diff changeset
182 ConfigFile cfg_file;
b30fe7e1dbb9 - Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1073
diff changeset
183
b30fe7e1dbb9 - Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1073
diff changeset
184 // 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
185 #if DMDV2
b30fe7e1dbb9 - Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1073
diff changeset
186 #define CFG_FILENAME "ldc2.conf"
b30fe7e1dbb9 - Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1073
diff changeset
187 #else
b30fe7e1dbb9 - Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1073
diff changeset
188 #define CFG_FILENAME "ldc.conf"
b30fe7e1dbb9 - Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1073
diff changeset
189 #endif
b30fe7e1dbb9 - Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1073
diff changeset
190 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
191 #undef CFG_FILENAME
b30fe7e1dbb9 - Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1073
diff changeset
192
b30fe7e1dbb9 - Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1073
diff changeset
193 // 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
194 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
195
1197
1546b5162152 Make sure -run doesn't consume the config file flags.
Christian Kamm <kamm incasoftware de>
parents: 1187
diff changeset
196 // 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
197 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
198
1103
b30fe7e1dbb9 - Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1073
diff changeset
199 #if 0
b30fe7e1dbb9 - Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1073
diff changeset
200 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
201 {
b30fe7e1dbb9 - Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1073
diff changeset
202 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
203 }
b30fe7e1dbb9 - Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1073
diff changeset
204 #endif
b30fe7e1dbb9 - Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1073
diff changeset
205
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 // 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
207 cl::SetVersionPrinter(&printVersion);
1103
b30fe7e1dbb9 - Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1073
diff changeset
208 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
209
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
210 // 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
211 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
212 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
213 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
214 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
215 }
7d3b47852a7a Print the path to the configuration file being used if `-v` is passed.
Frits van Bommel <fvbommel wxs.nl>
parents: 1482
diff changeset
216
989
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
217 // 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
218 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
219 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
220 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
221
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
222 // 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
223 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
224 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
225
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
226 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
227 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
228 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
229 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
230
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
231 #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
232 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
233 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
234 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
235 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
236 #endif
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
237
1402
1311dabc6a1f Merged xfBuild patch for dependency tree generation. See #286.
Christian Kamm <kamm incasoftware de>
parents: 1390
diff changeset
238 initFromString(global.params.moduleDepsFile, moduleDepsFile);
1311dabc6a1f Merged xfBuild patch for dependency tree generation. See #286.
Christian Kamm <kamm incasoftware de>
parents: 1390
diff changeset
239 if (global.params.moduleDepsFile != NULL)
1311dabc6a1f Merged xfBuild patch for dependency tree generation. See #286.
Christian Kamm <kamm incasoftware de>
parents: 1390
diff changeset
240 {
1311dabc6a1f Merged xfBuild patch for dependency tree generation. See #286.
Christian Kamm <kamm incasoftware de>
parents: 1390
diff changeset
241 global.params.moduleDeps = new OutBuffer;
1311dabc6a1f Merged xfBuild patch for dependency tree generation. See #286.
Christian Kamm <kamm incasoftware de>
parents: 1390
diff changeset
242 }
1311dabc6a1f Merged xfBuild patch for dependency tree generation. See #286.
Christian Kamm <kamm incasoftware de>
parents: 1390
diff changeset
243
989
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(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
245 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
246 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
247 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
248 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
249 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
250
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
251 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
252 (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
253 && !(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
254 ? OUTPUTFLAGdefault
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
255 : 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
256 ? OUTPUTFLAGset
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
257 : 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 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
259 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
260 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
261
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
262 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
263 // 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
264 // 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
265 // 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
266 // 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
267 // 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
268 // 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
269 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
270 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
271 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
272 } else {
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
273 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
274 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
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 }
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
277
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
278
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
279 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
280 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
281 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
282 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
283 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
284
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
285 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
286 {
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
287 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
288 }
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
289 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
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 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
292 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
293 }
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
294
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
295 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
296 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
297 {
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
298 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
299 llvm::NoFramePointerElim = true;
80a326087f59 Disable frame pointer elimination when -g or -gc is passed.
Christian Kamm <kamm incasoftware de>
parents: 1197
diff changeset
300 }
989
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
301 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
302 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
303
1635
601d3eea4a68 Make -nodefaultlib override -de{fault,bug}lib=foo instead of vice versa.
Matti Niemenmaa <matti.niemenmaa+hg@iki.fi>
parents: 1587
diff changeset
304 if (!noDefaultLib)
989
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
305 {
1635
601d3eea4a68 Make -nodefaultlib override -de{fault,bug}lib=foo instead of vice versa.
Matti Niemenmaa <matti.niemenmaa+hg@iki.fi>
parents: 1587
diff changeset
306 if (libs)
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 {
1635
601d3eea4a68 Make -nodefaultlib override -de{fault,bug}lib=foo instead of vice versa.
Matti Niemenmaa <matti.niemenmaa+hg@iki.fi>
parents: 1587
diff changeset
308 for (int i = 0; i < libs->dim; i++)
601d3eea4a68 Make -nodefaultlib override -de{fault,bug}lib=foo instead of vice versa.
Matti Niemenmaa <matti.niemenmaa+hg@iki.fi>
parents: 1587
diff changeset
309 {
601d3eea4a68 Make -nodefaultlib override -de{fault,bug}lib=foo instead of vice versa.
Matti Niemenmaa <matti.niemenmaa+hg@iki.fi>
parents: 1587
diff changeset
310 char* lib = (char *)libs->data[i];
601d3eea4a68 Make -nodefaultlib override -de{fault,bug}lib=foo instead of vice versa.
Matti Niemenmaa <matti.niemenmaa+hg@iki.fi>
parents: 1587
diff changeset
311 char *arg = (char *)mem.malloc(strlen(lib) + 3);
601d3eea4a68 Make -nodefaultlib override -de{fault,bug}lib=foo instead of vice versa.
Matti Niemenmaa <matti.niemenmaa+hg@iki.fi>
parents: 1587
diff changeset
312 strcpy(arg, "-l");
601d3eea4a68 Make -nodefaultlib override -de{fault,bug}lib=foo instead of vice versa.
Matti Niemenmaa <matti.niemenmaa+hg@iki.fi>
parents: 1587
diff changeset
313 strcpy(arg+2, lib);
601d3eea4a68 Make -nodefaultlib override -de{fault,bug}lib=foo instead of vice versa.
Matti Niemenmaa <matti.niemenmaa+hg@iki.fi>
parents: 1587
diff changeset
314 global.params.linkswitches->push(arg);
601d3eea4a68 Make -nodefaultlib override -de{fault,bug}lib=foo instead of vice versa.
Matti Niemenmaa <matti.niemenmaa+hg@iki.fi>
parents: 1587
diff changeset
315 }
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
316 }
1635
601d3eea4a68 Make -nodefaultlib override -de{fault,bug}lib=foo instead of vice versa.
Matti Niemenmaa <matti.niemenmaa+hg@iki.fi>
parents: 1587
diff changeset
317 else
601d3eea4a68 Make -nodefaultlib override -de{fault,bug}lib=foo instead of vice versa.
Matti Niemenmaa <matti.niemenmaa+hg@iki.fi>
parents: 1587
diff changeset
318 {
1527
f19adff18813 A couple of ldc2 tweaks now druntime compiles.
Robert Clipsham <robert@octarineparrot.com>
parents: 1524
diff changeset
319 #if DMDV2
1635
601d3eea4a68 Make -nodefaultlib override -de{fault,bug}lib=foo instead of vice versa.
Matti Niemenmaa <matti.niemenmaa+hg@iki.fi>
parents: 1587
diff changeset
320 global.params.linkswitches->push(mem.strdup("-ldruntime-ldc"));
1527
f19adff18813 A couple of ldc2 tweaks now druntime compiles.
Robert Clipsham <robert@octarineparrot.com>
parents: 1524
diff changeset
321 #else
1635
601d3eea4a68 Make -nodefaultlib override -de{fault,bug}lib=foo instead of vice versa.
Matti Niemenmaa <matti.niemenmaa+hg@iki.fi>
parents: 1587
diff changeset
322 global.params.linkswitches->push(mem.strdup("-lldc-runtime"));
601d3eea4a68 Make -nodefaultlib override -de{fault,bug}lib=foo instead of vice versa.
Matti Niemenmaa <matti.niemenmaa+hg@iki.fi>
parents: 1587
diff changeset
323 global.params.linkswitches->push(mem.strdup("-ltango-cc-tango"));
601d3eea4a68 Make -nodefaultlib override -de{fault,bug}lib=foo instead of vice versa.
Matti Niemenmaa <matti.niemenmaa+hg@iki.fi>
parents: 1587
diff changeset
324 global.params.linkswitches->push(mem.strdup("-ltango-gc-basic"));
601d3eea4a68 Make -nodefaultlib override -de{fault,bug}lib=foo instead of vice versa.
Matti Niemenmaa <matti.niemenmaa+hg@iki.fi>
parents: 1587
diff changeset
325 // pass the runtime again to resolve issues
601d3eea4a68 Make -nodefaultlib override -de{fault,bug}lib=foo instead of vice versa.
Matti Niemenmaa <matti.niemenmaa+hg@iki.fi>
parents: 1587
diff changeset
326 // with linking order
601d3eea4a68 Make -nodefaultlib override -de{fault,bug}lib=foo instead of vice versa.
Matti Niemenmaa <matti.niemenmaa+hg@iki.fi>
parents: 1587
diff changeset
327 global.params.linkswitches->push(mem.strdup("-lldc-runtime"));
1523
833337c65fd3 Fixed some unmerged parts of the D2 frontend.
Robert Clipsham <robert@octarineparrot.com>
parents: 1484
diff changeset
328 #endif
1635
601d3eea4a68 Make -nodefaultlib override -de{fault,bug}lib=foo instead of vice versa.
Matti Niemenmaa <matti.niemenmaa+hg@iki.fi>
parents: 1587
diff changeset
329 }
989
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
330 }
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
331
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
332 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
333 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
334
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
335 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
336 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
337
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
338 // 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
339
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
340 // 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
341 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
342 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
343 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
344 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
345 // 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
346 } 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
347 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
348 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
349 } 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
350 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
351 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
352 } 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
353 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
354 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
355 } 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
356 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
357 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
358 } 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
359 // 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
360 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
361 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
362 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
363 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
364 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
365 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
366 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
367
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
368 }
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 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
370 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
371 }
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 // 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
374 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
375 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
376
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
377 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
378 {
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
379 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
380 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
381 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
382 }
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
383 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
384 {
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
385 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
386 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
387 }
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
388 else
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
389 {
1433
f79971a45bee Fix #309: allow -of with multiple source files if -singleobj is given.
Christian Kamm <kamm incasoftware de>
parents: 1415
diff changeset
390 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
391 {
55051098d9fc Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents: 999
diff changeset
392 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
393 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
394 }
989
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
395 }
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
396
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
397 // 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
398 Ir ir;
1021
d1ec9ff0e9ba Implemented basic -m32 and -m64 options.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1007
diff changeset
399
d1ec9ff0e9ba Implemented basic -m32 and -m64 options.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1007
diff changeset
400 // check -m32/64 sanity
d1ec9ff0e9ba Implemented basic -m32 and -m64 options.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1007
diff changeset
401 if (m32bits && m64bits)
d1ec9ff0e9ba Implemented basic -m32 and -m64 options.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1007
diff changeset
402 error("cannot use both -m32 and -m64 options");
1544
8863cf7236e6 We need to parse mArch ourselves now
Benjamin Kramer <benny.kra@gmail.com>
parents: 1543
diff changeset
403 else if ((m32bits || m64bits) && (!mArch.empty() || !mTargetTriple.empty()))
1021
d1ec9ff0e9ba Implemented basic -m32 and -m64 options.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1007
diff changeset
404 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
405 if (global.errors)
d1ec9ff0e9ba Implemented basic -m32 and -m64 options.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1007
diff changeset
406 fatal();
d1ec9ff0e9ba Implemented basic -m32 and -m64 options.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1007
diff changeset
407
d1ec9ff0e9ba Implemented basic -m32 and -m64 options.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1007
diff changeset
408 // override triple if needed
d1ec9ff0e9ba Implemented basic -m32 and -m64 options.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1007
diff changeset
409 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
410 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
411 {
d1ec9ff0e9ba Implemented basic -m32 and -m64 options.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1007
diff changeset
412 defaultTriple = DEFAULT_ALT_TARGET_TRIPLE;
d1ec9ff0e9ba Implemented basic -m32 and -m64 options.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1007
diff changeset
413 }
d1ec9ff0e9ba Implemented basic -m32 and -m64 options.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1007
diff changeset
414
989
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
415 // 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
416 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
417 {
1544
8863cf7236e6 We need to parse mArch ourselves now
Benjamin Kramer <benny.kra@gmail.com>
parents: 1543
diff changeset
418 if (!mArch.empty())
989
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
419 {
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
420 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
421 fatal();
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
422 }
1021
d1ec9ff0e9ba Implemented basic -m32 and -m64 options.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1007
diff changeset
423 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
424 }
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
425 else
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
426 {
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
427 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
428 }
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
429
1570
ab03cfb3a212 Remove dummy module hack.
Benjamin Kramer <benny.kra@gmail.com>
parents: 1569
diff changeset
430 std::string triple = 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
431
1518
26d061e61b02 Initialize LLVM target and asmprinter for the native and extra targets.
Christian Kamm <kamm incasoftware de>
parents: 1484
diff changeset
432 // Allocate target machine.
26d061e61b02 Initialize LLVM target and asmprinter for the native and extra targets.
Christian Kamm <kamm incasoftware de>
parents: 1484
diff changeset
433
26d061e61b02 Initialize LLVM target and asmprinter for the native and extra targets.
Christian Kamm <kamm incasoftware de>
parents: 1484
diff changeset
434 // first initialize llvm
1543
21d691518d82 Use TargetRegistry instead of TargetMachineRegistry for Target lookups
Benjamin Kramer <benny.kra@gmail.com>
parents: 1535
diff changeset
435 #define LLVM_TARGET(A) LLVMInitialize##A##TargetInfo(); LLVMInitialize##A##Target(); LLVMInitialize##A##AsmPrinter();
1518
26d061e61b02 Initialize LLVM target and asmprinter for the native and extra targets.
Christian Kamm <kamm incasoftware de>
parents: 1484
diff changeset
436 // this is defined to be LLVM_TARGET(target name 1) LLVM_TARGET(target name 2) ...
26d061e61b02 Initialize LLVM target and asmprinter for the native and extra targets.
Christian Kamm <kamm incasoftware de>
parents: 1484
diff changeset
437 LDC_TARGETS
26d061e61b02 Initialize LLVM target and asmprinter for the native and extra targets.
Christian Kamm <kamm incasoftware de>
parents: 1484
diff changeset
438 #undef LLVM_TARGET
26d061e61b02 Initialize LLVM target and asmprinter for the native and extra targets.
Christian Kamm <kamm incasoftware de>
parents: 1484
diff changeset
439
1544
8863cf7236e6 We need to parse mArch ourselves now
Benjamin Kramer <benny.kra@gmail.com>
parents: 1543
diff changeset
440 const llvm::Target *theTarget = NULL;
1518
26d061e61b02 Initialize LLVM target and asmprinter for the native and extra targets.
Christian Kamm <kamm incasoftware de>
parents: 1484
diff changeset
441 // Check whether the user has explicitly specified an architecture to compile for.
1544
8863cf7236e6 We need to parse mArch ourselves now
Benjamin Kramer <benny.kra@gmail.com>
parents: 1543
diff changeset
442 if (mArch.empty())
989
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
443 {
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
444 std::string Err;
1570
ab03cfb3a212 Remove dummy module hack.
Benjamin Kramer <benny.kra@gmail.com>
parents: 1569
diff changeset
445 theTarget = llvm::TargetRegistry::lookupTarget(triple, Err);
1543
21d691518d82 Use TargetRegistry instead of TargetMachineRegistry for Target lookups
Benjamin Kramer <benny.kra@gmail.com>
parents: 1535
diff changeset
446 if (theTarget == 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
447 {
997
4f12ec3216cf Missing %s error param in main.cpp
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 989
diff changeset
448 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
449 fatal();
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
450 }
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
451 }
1543
21d691518d82 Use TargetRegistry instead of TargetMachineRegistry for Target lookups
Benjamin Kramer <benny.kra@gmail.com>
parents: 1535
diff changeset
452 else
21d691518d82 Use TargetRegistry instead of TargetMachineRegistry for Target lookups
Benjamin Kramer <benny.kra@gmail.com>
parents: 1535
diff changeset
453 {
1544
8863cf7236e6 We need to parse mArch ourselves now
Benjamin Kramer <benny.kra@gmail.com>
parents: 1543
diff changeset
454 for (llvm::TargetRegistry::iterator it = llvm::TargetRegistry::begin(),
8863cf7236e6 We need to parse mArch ourselves now
Benjamin Kramer <benny.kra@gmail.com>
parents: 1543
diff changeset
455 ie = llvm::TargetRegistry::end(); it != ie; ++it)
8863cf7236e6 We need to parse mArch ourselves now
Benjamin Kramer <benny.kra@gmail.com>
parents: 1543
diff changeset
456 {
8863cf7236e6 We need to parse mArch ourselves now
Benjamin Kramer <benny.kra@gmail.com>
parents: 1543
diff changeset
457 if (mArch == it->getName())
8863cf7236e6 We need to parse mArch ourselves now
Benjamin Kramer <benny.kra@gmail.com>
parents: 1543
diff changeset
458 {
8863cf7236e6 We need to parse mArch ourselves now
Benjamin Kramer <benny.kra@gmail.com>
parents: 1543
diff changeset
459 theTarget = &*it;
8863cf7236e6 We need to parse mArch ourselves now
Benjamin Kramer <benny.kra@gmail.com>
parents: 1543
diff changeset
460 break;
8863cf7236e6 We need to parse mArch ourselves now
Benjamin Kramer <benny.kra@gmail.com>
parents: 1543
diff changeset
461 }
8863cf7236e6 We need to parse mArch ourselves now
Benjamin Kramer <benny.kra@gmail.com>
parents: 1543
diff changeset
462 }
8863cf7236e6 We need to parse mArch ourselves now
Benjamin Kramer <benny.kra@gmail.com>
parents: 1543
diff changeset
463
8863cf7236e6 We need to parse mArch ourselves now
Benjamin Kramer <benny.kra@gmail.com>
parents: 1543
diff changeset
464 if (!theTarget)
8863cf7236e6 We need to parse mArch ourselves now
Benjamin Kramer <benny.kra@gmail.com>
parents: 1543
diff changeset
465 {
8863cf7236e6 We need to parse mArch ourselves now
Benjamin Kramer <benny.kra@gmail.com>
parents: 1543
diff changeset
466 error("invalid target '%s'", mArch.c_str());
8863cf7236e6 We need to parse mArch ourselves now
Benjamin Kramer <benny.kra@gmail.com>
parents: 1543
diff changeset
467 fatal();
8863cf7236e6 We need to parse mArch ourselves now
Benjamin Kramer <benny.kra@gmail.com>
parents: 1543
diff changeset
468 }
1543
21d691518d82 Use TargetRegistry instead of TargetMachineRegistry for Target lookups
Benjamin Kramer <benny.kra@gmail.com>
parents: 1535
diff changeset
469 }
989
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
470
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
471 // 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
472 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
473 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
474 {
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
475 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
476 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
477 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
478 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
479 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
480 }
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
481
1570
ab03cfb3a212 Remove dummy module hack.
Benjamin Kramer <benny.kra@gmail.com>
parents: 1569
diff changeset
482 std::auto_ptr<llvm::TargetMachine> target(theTarget->createTargetMachine(triple, FeaturesStr));
989
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
483 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
484 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
485 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
486
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
487 // 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
488 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
489 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
490
1543
21d691518d82 Use TargetRegistry instead of TargetMachineRegistry for Target lookups
Benjamin Kramer <benny.kra@gmail.com>
parents: 1535
diff changeset
491 global.params.llvmArch = theTarget->getName();
989
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
492
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
493 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
494 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
495 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
496 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
497 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
498 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
499 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
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 }
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
502 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
503 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
504 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
505 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
506 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
507 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
508 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
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 }
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
511 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
512 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
513 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
514 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
515 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
516 }
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
517 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
518 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
519 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
520 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
521 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
522 }
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
523 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
524 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
525 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
526 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
527 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
528 }
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
529 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
530 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
531 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
532 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
533 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
534 }
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
535 else {
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
536 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
537 fatal();
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
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
540 // endianness
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
541 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
542 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
543 }
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
544 else {
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
545 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
546 }
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
547
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
548 // 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
549 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
550 VersionCondition::addPredefinedGlobalIdent("LLVM64");
999
2b6c2e961f25 Added some missing version identifiers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 997
diff changeset
551 // FIXME: is this always correct?
2b6c2e961f25 Added some missing version identifiers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 997
diff changeset
552 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
553 }
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
554
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
555 // 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
556 // 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
557 // 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
558 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
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 // windows
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
561 // 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
562 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
563 {
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
564 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
565 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
566 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
567 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
568 }
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
569 // 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
570 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
571 {
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
572 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
573 fatal();
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
574 }
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
575 // linux
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
576 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
577 {
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
578 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
579 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
580 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
581 }
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
582 // darwin
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
583 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
584 {
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
585 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
586 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
587 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
588 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
589 }
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
590 // freebsd
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
591 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
592 {
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
593 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
594 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
595 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
596 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
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 // solaris
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
599 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
600 {
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
601 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
602 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
603 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
604 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
605 }
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
606 // unsupported
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
607 else
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
608 {
1463
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents: 1433
diff changeset
609 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
610 fatal();
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
611 }
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
612
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
613 // 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
614 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
615 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
616
999
2b6c2e961f25 Added some missing version identifiers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 997
diff changeset
617 #if DMDV2
2b6c2e961f25 Added some missing version identifiers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 997
diff changeset
618 // unittests?
2b6c2e961f25 Added some missing version identifiers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 997
diff changeset
619 if (global.params.useUnitTests)
2b6c2e961f25 Added some missing version identifiers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 997
diff changeset
620 VersionCondition::addPredefinedGlobalIdent("unittest");
2b6c2e961f25 Added some missing version identifiers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 997
diff changeset
621 #endif
2b6c2e961f25 Added some missing version identifiers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 997
diff changeset
622
989
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
623 // Initialization
1147
dbe4af57b240 Changed use of toObjFile to a new codegen method.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1103
diff changeset
624 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
625 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
626 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
627 initPrecedence();
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
628
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
629 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
630
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
631 //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
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 // 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
634 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
635 {
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
636 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
637 {
55051098d9fc Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents: 999
diff changeset
638 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
639 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
640
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
641 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
642 {
55051098d9fc Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents: 999
diff changeset
643 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
644 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
645 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
646 }
989
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
647 }
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
648 }
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
649
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
650 // 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
651 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
652 {
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
653 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
654 {
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 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
656 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
657
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
658 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
659 {
55051098d9fc Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents: 999
diff changeset
660 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
661 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
662 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
663 }
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 }
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
665 }
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
666
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
667 // 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
668 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
669 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
670 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
671 { 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
672 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
673 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
674
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
675 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
676
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
677 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
678 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
679 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
680 {
989
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
681 #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
682 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
683 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
684 #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
685 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
686 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
687 #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
688 {
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 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
690 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
691 }
989
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
692
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
693 #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
694 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
695 #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
696 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
697 #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
698 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
699 #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
700 {
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 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
702 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
703 }
989
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
704
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
705 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
706 {
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 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
708 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
709 }
989
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
710
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
711 #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
712 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
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 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
715 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
716 }
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 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
719 {
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 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
721 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
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 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
725 {
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 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
727 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
728 }
55051098d9fc Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents: 999
diff changeset
729 #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
730
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 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
732 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
733 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
734 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
735 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
736 {
55051098d9fc Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents: 999
diff changeset
737 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
738 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
739 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
740 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
741 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
742
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 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
744 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
745 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
746 {
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 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
748 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
749 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
750 }
55051098d9fc Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents: 999
diff changeset
751 }
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 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
753 { 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
754 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
755 }
55051098d9fc Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents: 999
diff changeset
756 }
55051098d9fc Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents: 999
diff changeset
757 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
758 { 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
759 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
760 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
761 }
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
762
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
763 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
764 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
765 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
766 }
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
767
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
768 // 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
769 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
770 {
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
771 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
772 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
773 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
774 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
775 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
776 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
777 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
778 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
779 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
780 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
781 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
782 {
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 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
784
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
785 // 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
786 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
787 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
788 }
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 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
791 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
792 #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
793 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
794 {
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
795 /* 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
796 * 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
797 * 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
798 * 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
799 */
55051098d9fc Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents: 999
diff changeset
800 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
801 {
55051098d9fc Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents: 999
diff changeset
802 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
803 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
804 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
805 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
806 }
989
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
807 }
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
808 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
809 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
810 #endif
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
811
1587
def7a1d494fd Merge DMD 1.051
Christian Kamm <kamm incasoftware de>
parents: 1586
diff changeset
812 // load all unconditional imports for better symbol resolving
def7a1d494fd Merge DMD 1.051
Christian Kamm <kamm incasoftware de>
parents: 1586
diff changeset
813 for (int i = 0; i < modules.dim; i++)
def7a1d494fd Merge DMD 1.051
Christian Kamm <kamm incasoftware de>
parents: 1586
diff changeset
814 {
def7a1d494fd Merge DMD 1.051
Christian Kamm <kamm incasoftware de>
parents: 1586
diff changeset
815 m = (Module *)modules.data[i];
def7a1d494fd Merge DMD 1.051
Christian Kamm <kamm incasoftware de>
parents: 1586
diff changeset
816 if (global.params.verbose)
def7a1d494fd Merge DMD 1.051
Christian Kamm <kamm incasoftware de>
parents: 1586
diff changeset
817 printf("importall %s\n", m->toChars());
def7a1d494fd Merge DMD 1.051
Christian Kamm <kamm incasoftware de>
parents: 1586
diff changeset
818 m->importAll(0);
def7a1d494fd Merge DMD 1.051
Christian Kamm <kamm incasoftware de>
parents: 1586
diff changeset
819 }
def7a1d494fd Merge DMD 1.051
Christian Kamm <kamm incasoftware de>
parents: 1586
diff changeset
820 if (global.errors)
def7a1d494fd Merge DMD 1.051
Christian Kamm <kamm incasoftware de>
parents: 1586
diff changeset
821 fatal();
def7a1d494fd Merge DMD 1.051
Christian Kamm <kamm incasoftware de>
parents: 1586
diff changeset
822
989
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
823 // 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
824 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
825 {
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
826 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
827 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
828 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
829 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
830 }
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
831 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
832 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
833
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
834 // 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
835 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
836 {
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
837 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
838 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
839 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
840 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
841 }
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
842 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
843 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
844
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
845 // 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
846 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
847 {
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 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
849 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
850 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
851 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
852 }
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
853 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
854 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
855
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
856 #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
857 // 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
858 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
859 {
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
860 /* 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
861 * 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
862 * 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
863 * 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
864 */
55051098d9fc Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents: 999
diff changeset
865 if (!global.params.useArrayBounds && !global.params.useAssert)
1532
c88b16d4a13c Remove all of the now unecessary #if LLVM_REV
Benjamin Kramer <benny.kra@gmail.com>
parents: 1527
diff changeset
866 #else
1482
d9c5f5a43403 Run `semantic3` on imported modules, and emit new symbols with
Frits van Bommel <fvbommel wxs.nl>
parents: 1463
diff changeset
867 // 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
868 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
869 {
d9c5f5a43403 Run `semantic3` on imported modules, and emit new symbols with
Frits van Bommel <fvbommel wxs.nl>
parents: 1463
diff changeset
870 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
871 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
872 #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
873 {
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
874 // 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
875 // 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
876 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
877 {
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 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
879 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
880 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
881 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
882 }
55051098d9fc Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents: 999
diff changeset
883 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
884 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
885 }
989
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
886
1482
d9c5f5a43403 Run `semantic3` on imported modules, and emit new symbols with
Frits van Bommel <fvbommel wxs.nl>
parents: 1463
diff changeset
887 #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
888 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
889 {
55051098d9fc Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents: 999
diff changeset
890 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
891 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
892 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
893 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
894 }
1482
d9c5f5a43403 Run `semantic3` on imported modules, and emit new symbols with
Frits van Bommel <fvbommel wxs.nl>
parents: 1463
diff changeset
895 #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
896 }
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
897 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
898 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
899
1402
1311dabc6a1f Merged xfBuild patch for dependency tree generation. See #286.
Christian Kamm <kamm incasoftware de>
parents: 1390
diff changeset
900 // 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
901 if (global.params.moduleDepsFile != NULL)
1311dabc6a1f Merged xfBuild patch for dependency tree generation. See #286.
Christian Kamm <kamm incasoftware de>
parents: 1390
diff changeset
902 {
1311dabc6a1f Merged xfBuild patch for dependency tree generation. See #286.
Christian Kamm <kamm incasoftware de>
parents: 1390
diff changeset
903 assert (global.params.moduleDepsFile != NULL);
1311dabc6a1f Merged xfBuild patch for dependency tree generation. See #286.
Christian Kamm <kamm incasoftware de>
parents: 1390
diff changeset
904
1311dabc6a1f Merged xfBuild patch for dependency tree generation. See #286.
Christian Kamm <kamm incasoftware de>
parents: 1390
diff changeset
905 File deps(global.params.moduleDepsFile);
1311dabc6a1f Merged xfBuild patch for dependency tree generation. See #286.
Christian Kamm <kamm incasoftware de>
parents: 1390
diff changeset
906 OutBuffer* ob = global.params.moduleDeps;
1311dabc6a1f Merged xfBuild patch for dependency tree generation. See #286.
Christian Kamm <kamm incasoftware de>
parents: 1390
diff changeset
907 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
908 deps.write();
1311dabc6a1f Merged xfBuild patch for dependency tree generation. See #286.
Christian Kamm <kamm incasoftware de>
parents: 1390
diff changeset
909 }
1311dabc6a1f Merged xfBuild patch for dependency tree generation. See #286.
Christian Kamm <kamm incasoftware de>
parents: 1390
diff changeset
910
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
911 // 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
912 std::vector<llvm::Module*> llvmModules;
1570
ab03cfb3a212 Remove dummy module hack.
Benjamin Kramer <benny.kra@gmail.com>
parents: 1569
diff changeset
913 llvm::LLVMContext& context = llvm::getGlobalContext();
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
914
989
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
915 // 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
916 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
917 {
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
918 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
919 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
920 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
921 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
922 {
1535
61f12f4651b5 Don't use llvm::getGlobalContext() anymore
Benjamin Kramer <benny.kra@gmail.com>
parents: 1534
diff changeset
923 llvm::Module* lm = m->genLLVMModule(context, &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
924 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
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(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
928 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
929 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
930 }
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
931 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
932 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
933 }
55051098d9fc Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents: 999
diff changeset
934 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
935 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
936 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
937 {
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 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
939 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
940 }
989
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
941 }
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
942
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
943 // 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
944 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
945 {
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
946 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
947 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
948 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
949
1535
61f12f4651b5 Don't use llvm::getGlobalContext() anymore
Benjamin Kramer <benny.kra@gmail.com>
parents: 1534
diff changeset
950 llvm::Linker linker(name, name, context);
1532
c88b16d4a13c Remove all of the now unecessary #if LLVM_REV
Benjamin Kramer <benny.kra@gmail.com>
parents: 1527
diff changeset
951
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
952 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
953 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
954 {
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
955 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
956 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
957 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
958 }
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
959
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
960 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
961 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
962 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
963 }
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
964
989
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
965 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
966 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
967 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
968
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
969 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
970 {
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
971 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
972 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
973 }
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
974 else
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
975 {
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
976 if (global.params.link)
1586
7f728c52e63c Fix several 'reaches end of function' warnings by making fatal noreturn.
Christian Kamm <kamm incasoftware de>
parents: 1576
diff changeset
977 status = 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
978
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
979 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
980 {
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
981 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
982 {
1313
2bebd938548f Fix typo in function name
Frits van Bommel <fvbommel wxs.nl>
parents: 1260
diff changeset
983 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
984
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
985 /* 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
986 */
55051098d9fc Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents: 999
diff changeset
987 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
988 {
55051098d9fc Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents: 999
diff changeset
989 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
990 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
991 }
55051098d9fc Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents: 999
diff changeset
992 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
993 }
989
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
994 }
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
995 }
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
996
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
997 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
998 }