annotate gen/main.cpp @ 1033:abfe71f5b911

Switch LLVM_InlineAsm -> D_InlineAsm. It's for real this time, hopefully.
author Christian Kamm <kamm incasoftware de>
date Tue, 03 Mar 2009 17:44:56 +0100
parents d1ec9ff0e9ba
children 12ea38902e83
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"
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
7 #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
8 #include "llvm/Target/TargetMachine.h"
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
9 #include "llvm/Target/TargetMachineRegistry.h"
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
10 #include "llvm/LinkAllVMCore.h"
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
11
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 <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
13 #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
14 #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
15 #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
16
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
17 #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
18 #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
19 #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
20 #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
21 #endif
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 #include "mem.h"
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
24 #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
25
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 "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
27 #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
28 #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
29 #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
30 #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
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 "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
33 #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
34 #include "gen/irstate.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
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
36 #include "gen/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
37 #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
38 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
39
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
40 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
41 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
42 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
43
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
44 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
45 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
46 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
47
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
48 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
49 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
50 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
51 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
52 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
53 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
54
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
55 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
56 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
57 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
58 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
59 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
60 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
61
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
62 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
63 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
64 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
65 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
66 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
67 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
68
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
69 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
70 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
71 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
72 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
73 "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
74 }
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
75
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
76 // 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
77 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
78 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
79 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
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 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
82 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
83 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
84 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
85 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
86 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
87 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
88 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
89 } else {
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
90 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
91 }
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
92 } else {
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
93 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
94 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
95 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
96 continue;
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
97 } else {
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
98 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
99 }
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
100 }
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
101 }
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
102 }
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 // 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
105 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
106 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
107 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
108 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
109 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
110 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
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 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
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 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
117 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
118 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
119 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
120
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
121 // 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
122 #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
123 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
124 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
125 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
126 #else
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
127 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
128 #endif
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
129 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
130
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
131 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
132 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
133 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
134 global.params.ddocfiles = 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
135
999
2b6c2e961f25 Added some missing version identifiers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 997
diff changeset
136
989
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
137 // 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
138 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
139 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
140 VersionCondition::addPredefinedGlobalIdent("all");
999
2b6c2e961f25 Added some missing version identifiers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 997
diff changeset
141 #if DMDV2
2b6c2e961f25 Added some missing version identifiers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 997
diff changeset
142 VersionCondition::addPredefinedGlobalIdent("D_Version2");
2b6c2e961f25 Added some missing version identifiers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 997
diff changeset
143 #endif
2b6c2e961f25 Added some missing version identifiers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 997
diff changeset
144
989
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 // read the inifile
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
147 #if DMDV2
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
148 inifile(global.params.argv0, "ldc2.conf");
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
149 #else
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
150 inifile(global.params.argv0, "ldc.conf");
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
151 #endif
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
152
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
153 // merge DFLAGS into 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
154 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
155 #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
156 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
157 {
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
158 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
159 }
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
160 #endif
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
161
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
162 // 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
163 cl::SetVersionPrinter(&printVersion);
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
164 cl::ParseCommandLineOptions(argc, argv, "LLVM-based D Compiler\n");
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
165
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
166 global.params.optimize = (global.params.optimizeLevel >= 0);
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
167
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
168 // 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
169 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
170 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
171 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
172
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
173 // 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
174 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
175 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
176
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
177 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
178 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
179 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
180 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
181
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
182 #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
183 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
184 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
185 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
186 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
187 #endif
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
188
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
189 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
190 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
191 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
192 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
193 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
194 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
195
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
196 global.params.output_o =
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
197 opts::output_o == cl::BOU_UNSET
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
198 ? OUTPUTFLAGdefault
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
199 : 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
200 ? OUTPUTFLAGset
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
201 : OUTPUTFLAGno;
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
202 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
203 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
204 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
205
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
206 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
207 // 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
208 // 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
209 // 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
210 // 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
211 // 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
212 // 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
213 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
214 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
215 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
216 } else {
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
217 global.params.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
218 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
219 }
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
220 }
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
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
223 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
224 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
225 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
226 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
227 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
228
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
229 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
230 {
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
231 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
232 }
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
233 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
234 {
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
235 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
236 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
237 }
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
238
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
239 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
240 if (global.params.symdebug)
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
241 libs = global.params.debuglibnames;
989
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
242 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
243 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
244
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
245 if (libs)
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
246 {
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
247 for (int i = 0; i < libs->dim; i++)
55051098d9fc Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents: 999
diff changeset
248 {
55051098d9fc Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents: 999
diff changeset
249 char *arg = (char *)mem.malloc(64);
55051098d9fc Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents: 999
diff changeset
250 strcpy(arg, "-l");
55051098d9fc Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents: 999
diff changeset
251 strncat(arg, (char *)libs->data[i], 64);
55051098d9fc Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents: 999
diff changeset
252 global.params.linkswitches->push(arg);
55051098d9fc Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents: 999
diff changeset
253 }
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 }
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
255 else if (!noDefaultLib)
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
256 {
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
257 char *arg;
55051098d9fc Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents: 999
diff changeset
258 arg = (char *)mem.malloc(64);
55051098d9fc Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents: 999
diff changeset
259 strcpy(arg, "-lldc-runtime");
55051098d9fc Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents: 999
diff changeset
260 global.params.linkswitches->push(arg);
55051098d9fc Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents: 999
diff changeset
261 arg = (char *)mem.malloc(64);
55051098d9fc Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents: 999
diff changeset
262 strcpy(arg, "-ltango-cc-tango");
55051098d9fc Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents: 999
diff changeset
263 global.params.linkswitches->push(arg);
55051098d9fc Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents: 999
diff changeset
264 arg = (char *)mem.malloc(64);
55051098d9fc Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents: 999
diff changeset
265 strcpy(arg, "-ltango-gc-basic");
55051098d9fc Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents: 999
diff changeset
266 global.params.linkswitches->push(arg);
55051098d9fc Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents: 999
diff changeset
267 // pass the runtime again to resolve issues
55051098d9fc Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents: 999
diff changeset
268 // with linking order
55051098d9fc Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents: 999
diff changeset
269 arg = (char *)mem.malloc(64);
55051098d9fc Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents: 999
diff changeset
270 strcpy(arg, "-lldc-runtime");
55051098d9fc Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents: 999
diff changeset
271 global.params.linkswitches->push(arg);
989
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
272 }
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
273
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
274 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
275 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
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 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
278 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
279
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
280 // 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
281
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
282 // if 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
283 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
284 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
285 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
286 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
287 // 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
288 } 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
289 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
290 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
291 } 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
292 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
293 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
294 } 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
295 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
296 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
297 } 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
298 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
299 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
300 } 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
301 // 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
302 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
303 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
304 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
305 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
306 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
307 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
308 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
309
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
310 }
55051098d9fc Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents: 999
diff changeset
311 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
312 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
313 }
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
314
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
315 // 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
316 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
317 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
318
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
319 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
320 {
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
321 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
322 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
323 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
324 }
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
325 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
326 {
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
327 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
328 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
329 }
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
330 else
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
331 {
1007
55051098d9fc Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents: 999
diff changeset
332 if (global.params.objname && 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
333 {
55051098d9fc Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents: 999
diff changeset
334 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
335 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
336 }
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
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
339 // create a proper target
1021
d1ec9ff0e9ba Implemented basic -m32 and -m64 options.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1007
diff changeset
340
d1ec9ff0e9ba Implemented basic -m32 and -m64 options.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1007
diff changeset
341 // check -m32/64 sanity
d1ec9ff0e9ba Implemented basic -m32 and -m64 options.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1007
diff changeset
342 if (m32bits && m64bits)
d1ec9ff0e9ba Implemented basic -m32 and -m64 options.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1007
diff changeset
343 error("cannot use both -m32 and -m64 options");
d1ec9ff0e9ba Implemented basic -m32 and -m64 options.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1007
diff changeset
344 else if ((m32bits || m64bits) && (mArch != 0 || !mTargetTriple.empty()))
d1ec9ff0e9ba Implemented basic -m32 and -m64 options.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1007
diff changeset
345 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
346 if (global.errors)
d1ec9ff0e9ba Implemented basic -m32 and -m64 options.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1007
diff changeset
347 fatal();
d1ec9ff0e9ba Implemented basic -m32 and -m64 options.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1007
diff changeset
348
989
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
349 llvm::Module mod("dummy");
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
350
1021
d1ec9ff0e9ba Implemented basic -m32 and -m64 options.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1007
diff changeset
351 // override triple if needed
d1ec9ff0e9ba Implemented basic -m32 and -m64 options.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1007
diff changeset
352 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
353 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
354 {
d1ec9ff0e9ba Implemented basic -m32 and -m64 options.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1007
diff changeset
355 defaultTriple = DEFAULT_ALT_TARGET_TRIPLE;
d1ec9ff0e9ba Implemented basic -m32 and -m64 options.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1007
diff changeset
356 }
d1ec9ff0e9ba Implemented basic -m32 and -m64 options.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1007
diff changeset
357
989
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
358 // 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
359 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
360 {
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
361 if (mArch != 0)
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
362 {
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
363 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
364 fatal();
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
365 }
1021
d1ec9ff0e9ba Implemented basic -m32 and -m64 options.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 1007
diff changeset
366 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
367 }
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
368 else
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
369 {
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
370 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
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 mod.setTargetTriple(global.params.targetTriple);
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
374
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
375 // Allocate target machine. First, check whether the user has
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
376 // explicitly specified an architecture to compile for.
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
377 if (mArch == 0)
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
378 {
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
379 std::string Err;
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
380 mArch = llvm::TargetMachineRegistry::getClosestStaticTargetForModule(mod, Err);
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
381 if (mArch == 0)
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
382 {
997
4f12ec3216cf Missing %s error param in main.cpp
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 989
diff changeset
383 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
384 fatal();
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
385 }
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
386 }
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
387
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
388 // 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
389 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
390 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
391 {
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
392 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
393 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
394 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
395 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
396 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
397 }
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
398
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
399 std::auto_ptr<llvm::TargetMachine> target(mArch->CtorFn(mod, FeaturesStr));
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
400 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
401 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
402 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
403
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
404 // 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
405 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
406 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
407
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
408 global.params.llvmArch = mArch->Name;
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
409
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
410 if (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
411 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
412 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
413 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
414 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
415 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
416 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
417 }
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
418 }
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
419 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
420 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
421 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
422 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
423 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
424 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
425 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
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 }
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
428 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
429 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
430 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
431 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
432 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
433 }
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
434 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
435 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
436 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
437 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
438 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
439 }
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
440 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
441 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
442 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
443 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
444 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
445 }
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
446 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
447 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
448 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
449 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
450 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
451 }
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
452 else {
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
453 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
454 fatal();
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
455 }
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
456
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
457 // endianness
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
458 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
459 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
460 }
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
461 else {
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
462 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
463 }
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
464
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
465 // 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
466 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
467 VersionCondition::addPredefinedGlobalIdent("LLVM64");
999
2b6c2e961f25 Added some missing version identifiers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 997
diff changeset
468 // FIXME: is this always correct?
2b6c2e961f25 Added some missing version identifiers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 997
diff changeset
469 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
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
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
472 // 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
473 // 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
474 // 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
475 std::string triple = global.params.targetTriple;
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
476 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
477
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
478 // windows
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
479 // 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
480 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
481 {
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
482 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
483 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
484 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
485 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
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 // 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
488 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
489 {
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
490 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
491 fatal();
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 // linux
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
494 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
495 {
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.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
497 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
498 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
499 }
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
500 // darwin
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
501 else 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
502 {
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
503 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
504 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
505 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
506 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
507 }
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
508 // freebsd
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
509 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
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 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
512 VersionCondition::addPredefinedGlobalIdent("freebsd");
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
513 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
514 }
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
515 // solaris
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
516 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
517 {
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
518 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
519 VersionCondition::addPredefinedGlobalIdent("solaris");
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
520 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
521 }
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
522 // unsupported
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
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
524 {
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
525 error("target triple '%s' is not supported", global.params.targetTriple);
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
526 fatal();
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
527 }
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 // 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
530 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
531 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
532
999
2b6c2e961f25 Added some missing version identifiers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 997
diff changeset
533 #if DMDV2
2b6c2e961f25 Added some missing version identifiers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 997
diff changeset
534 // unittests?
2b6c2e961f25 Added some missing version identifiers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 997
diff changeset
535 if (global.params.useUnitTests)
2b6c2e961f25 Added some missing version identifiers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 997
diff changeset
536 VersionCondition::addPredefinedGlobalIdent("unittest");
2b6c2e961f25 Added some missing version identifiers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 997
diff changeset
537 #endif
2b6c2e961f25 Added some missing version identifiers.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 997
diff changeset
538
989
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
539 // Initialization
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
540 Type::init();
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
541 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
542 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
543 initPrecedence();
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
544
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
545 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
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 //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
548
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
549 // 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
550 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
551 {
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
552 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
553 {
55051098d9fc Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents: 999
diff changeset
554 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
555 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
556
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
557 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
558 {
55051098d9fc Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents: 999
diff changeset
559 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
560 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
561 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
562 }
989
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
563 }
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
564 }
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
565
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
566 // 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
567 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
568 {
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
569 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
570 {
55051098d9fc Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents: 999
diff changeset
571 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
572 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
573
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
574 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
575 {
55051098d9fc Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents: 999
diff changeset
576 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
577 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
578 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
579 }
989
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
580 }
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
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
583 // 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
584 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
585 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
586 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
587 { 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
588 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
589 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
590
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
591 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
592
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
593 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
594 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
595 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
596 {
989
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
597 #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
598 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
599 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
600 #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
601 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
602 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
603 #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
604 {
55051098d9fc Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents: 999
diff changeset
605 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
606 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
607 }
989
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
608
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
609 #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
610 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
611 #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
612 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
613 #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
614 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
615 #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
616 {
55051098d9fc Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents: 999
diff changeset
617 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
618 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
619 }
989
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
620
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
621 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
622 {
55051098d9fc Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents: 999
diff changeset
623 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
624 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
625 }
989
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
626
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
627 #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
628 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
629 {
55051098d9fc Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents: 999
diff changeset
630 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
631 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
632 }
55051098d9fc Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents: 999
diff changeset
633
55051098d9fc Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents: 999
diff changeset
634 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
635 {
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 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
637 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
638 }
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
55051098d9fc Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents: 999
diff changeset
640 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
641 {
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 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
643 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
644 }
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 #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
646
55051098d9fc Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents: 999
diff changeset
647 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
648 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
649 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
650 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
651 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
652 {
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 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
654 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
655 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
656 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
657 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
658
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 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
660 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
661 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
662 {
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 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
664 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
665 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
666 }
55051098d9fc Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents: 999
diff changeset
667 }
55051098d9fc Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents: 999
diff changeset
668 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
669 { 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
670 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
671 }
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 }
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 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
674 { 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
675 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
676 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
677 }
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
678
1007
55051098d9fc Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents: 999
diff changeset
679 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
680 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
681 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
682 }
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
683
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
684 // 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
685 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
686 {
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
687 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
688 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
689 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
690 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
691 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
692 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
693 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
694 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
695 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
696 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
697 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
698 {
55051098d9fc Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents: 999
diff changeset
699 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
700
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
701 // 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
702 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
703 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
704 }
989
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
705 }
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
706 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
707 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
708 #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
709 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
710 {
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
711 /* 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
712 * 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
713 * 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
714 * 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
715 */
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 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
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 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
719 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
720 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
721 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
722 }
989
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
723 }
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
724 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
725 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
726 #endif
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
727
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
728 // 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
729 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
730 {
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
731 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
732 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
733 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
734 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
735 }
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
736 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
737 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
738
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
739 // 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
740 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
741 {
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
742 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
743 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
744 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
745 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
746 }
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
747 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
748 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
749
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
750 // 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
751 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
752 {
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
753 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
754 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
755 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
756 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
757 }
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
758 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
759 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
760
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
761 #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
762 // 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
763 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
764 {
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
765 /* 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
766 * 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
767 * 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
768 * 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
769 */
55051098d9fc Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents: 999
diff changeset
770 if (!global.params.useArrayBounds && !global.params.useAssert)
989
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
771 {
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
772 #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
773 // 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
774 // 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
775 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
776 {
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 = (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
778 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
779 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
780 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
781 }
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 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
783 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
784 #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
785 }
989
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
786
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
787 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
788 {
55051098d9fc Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents: 999
diff changeset
789 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
790 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
791 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
792 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
793 }
989
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
794 }
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
795 #endif
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
796 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
797 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
798
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
799 // 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
800 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
801 {
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
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("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
805 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
806 {
55051098d9fc Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents: 999
diff changeset
807 m->genobjfile(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
808 global.params.objfiles->push(m->objfile->name->str);
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 }
55051098d9fc Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents: 999
diff changeset
810 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
811 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
812 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
813 {
55051098d9fc Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents: 999
diff changeset
814 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
815 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
816 }
989
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
817 }
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
818
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
819 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
820 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
821 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
822
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
823 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
824 {
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
825 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
826 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
827 }
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
828 else
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
829 {
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
830 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
831 //status = runLINK();
55051098d9fc Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents: 999
diff changeset
832 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
833
1007
55051098d9fc Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents: 999
diff changeset
834 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
835 {
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
836 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
837 {
55051098d9fc Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents: 999
diff changeset
838 status = runExectuable();
989
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
839
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
840 /* 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
841 */
55051098d9fc Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents: 999
diff changeset
842 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
843 {
55051098d9fc Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents: 999
diff changeset
844 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
845 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
846 }
55051098d9fc Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move.
Christian Kamm <kamm incasoftware de>
parents: 999
diff changeset
847 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
848 }
989
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
849 }
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
850 }
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
851
420ef073448d Forgot new files that were supposed to be in last commit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff changeset
852 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
853 }