annotate dmd/backend/glue.d @ 14:2cc604139636

Implemented Linux support for ddmd. Some parts are a bit hacky to just "get it working", that said, druntime and phobos compile, and unittests pass.
author Robert Clipsham <robert@octarineparrot.com>
date Sun, 04 Apr 2010 02:06:32 +0100
parents 10317f0c89a5
children 5c9b78899f5d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1 module dmd.backend.glue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
3 import dmd.Array;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
4 import dmd.Dsymbol;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
5 import dmd.File;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
6 import dmd.FileName;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
7 import dmd.Library;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
8 import dmd.OutBuffer;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
9 import dmd.Module;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
10 import dmd.Identifier;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
11 import dmd.AssertExp;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
12 import dmd.TOK;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
13 import dmd.Global;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
14 import dmd.Param;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
15 import dmd.backend.Config;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
16 import dmd.backend.Configv;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
17 import dmd.backend.StringTab;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
18
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
19 import core.stdc.string;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
20
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
21 __gshared Array obj_symbols_towrite;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
22
14
2cc604139636 Implemented Linux support for ddmd. Some parts are a bit hacky to just "get it working", that said, druntime and phobos compile, and unittests pass.
Robert Clipsham <robert@octarineparrot.com>
parents: 0
diff changeset
23 extern (C++) /+extern+/
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
24 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
25 __gshared Outbuffer objbuf;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
26 int go_flag(char* cp);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
27 void util_set64();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
28 void util_set386();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
29 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
30
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
31 import std.contracts;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
32 import std.string;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
33
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
34 string lastmname;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
35
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
36 struct Outbuffer
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
37 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
38 ubyte* buf; // the buffer itself
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
39 ubyte* pend; // pointer past the end of the buffer
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
40 ubyte* p; // current position in buffer
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
41 uint len; // size of buffer
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
42 uint inc; // default increment size
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
43
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
44 this(uint inc)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
45 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
46 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
47 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
48
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
49 ~this()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
50 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
51 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
52 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
53
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
54 void reset()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
55 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
56 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
57 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
58
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
59 // Reserve nbytes in buffer
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
60 void reserve(uint nbytes)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
61 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
62 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
63 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
64
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
65 // Write n zeros; return pointer to start of zeros
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
66 void* writezeros(uint n)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
67 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
68 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
69 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
70
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
71 // Position buffer to accept the specified number of bytes at offset
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
72 int position(uint offset, uint nbytes);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
73
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
74 // Write an array to the buffer, no reserve check
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
75 void writen(const(void)* b, int len)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
76 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
77 memcpy(p,b,len);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
78 p += len;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
79 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
80
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
81 // Clear bytes, no reserve check
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
82 void clearn(int len)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
83 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
84 int i;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
85 for (i=0; i< len; i++)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
86 *p++ = 0;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
87 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
88
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
89 // Write an array to the buffer.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
90 void write(const void *b, int len)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
91 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
92 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
93 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
94
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
95 void write(Outbuffer* b)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
96 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
97 write(b.buf, b.p - b.buf);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
98 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
99
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
100 /**
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
101 * Flushes the stream. This will write any buffered
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
102 * output bytes.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
103 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
104 void flush() { }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
105
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
106 /**
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
107 * Writes an 8 bit byte, no reserve check.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
108 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
109 void writeByten(char v)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
110 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
111 *p++ = v;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
112 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
113
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
114 /**
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
115 * Writes an 8 bit byte.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
116 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
117 void writeByte(int v)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
118 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
119 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
120 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
121
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
122 /**
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
123 * Writes a 16 bit little-end short, no reserve check.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
124 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
125 void writeWordn(int v)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
126 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
127 version (_WIN32) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
128 *cast(ushort*)p = cast(short)v;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
129 } else {
14
2cc604139636 Implemented Linux support for ddmd. Some parts are a bit hacky to just "get it working", that said, druntime and phobos compile, and unittests pass.
Robert Clipsham <robert@octarineparrot.com>
parents: 0
diff changeset
130 assert(0, "Check this");
2cc604139636 Implemented Linux support for ddmd. Some parts are a bit hacky to just "get it working", that said, druntime and phobos compile, and unittests pass.
Robert Clipsham <robert@octarineparrot.com>
parents: 0
diff changeset
131 p[0] = cast(ubyte)v;
2cc604139636 Implemented Linux support for ddmd. Some parts are a bit hacky to just "get it working", that said, druntime and phobos compile, and unittests pass.
Robert Clipsham <robert@octarineparrot.com>
parents: 0
diff changeset
132 p[1] = cast(ubyte)(v >> 8);
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
133 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
134 p += 2;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
135 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
136
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
137 /**
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
138 * Writes a 16 bit little-end short.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
139 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
140 void writeWord(int v)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
141 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
142 reserve(2);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
143 writeWordn(v);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
144 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
145
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
146 /**
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
147 * Writes a 16 bit big-end short.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
148 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
149 void writeShort(int v)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
150 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
151 if (pend - p < 2)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
152 reserve(2);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
153
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
154 static if (false) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
155 p[0] = (cast(ubyte*)&v)[1];
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
156 p[1] = v;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
157 } else {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
158 ubyte* q = p;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
159 q[0] = cast(ubyte)(v >> 8);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
160 q[1] = cast(ubyte)v;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
161 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
162 p += 2;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
163 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
164
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
165 /**
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
166 * Writes a 16 bit char.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
167 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
168 void writeChar(int v)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
169 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
170 writeShort(v);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
171 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
172
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
173 /**
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
174 * Writes a 32 bit int.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
175 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
176 void write32(long v)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
177 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
178 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
179 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
180
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
181 /**
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
182 * Writes a 64 bit long.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
183 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
184 ///#if __INTSIZE == 4
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
185 void write64(long v)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
186 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
187 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
188 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
189 ///#endif
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
190
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
191 /**
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
192 * Writes a 32 bit float.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
193 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
194 void writeFloat(float v)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
195 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
196 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
197 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
198
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
199 /**
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
200 * Writes a 64 bit double.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
201 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
202 void writeDouble(double v)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
203 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
204 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
205 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
206
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
207 void write(const(char)* s)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
208 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
209 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
210 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
211
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
212 void write(const(ubyte)* s)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
213 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
214 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
215 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
216
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
217 void writeString(const(char)* s)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
218 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
219 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
220 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
221
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
222 void prependBytes(const(char)* s)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
223 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
224 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
225 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
226
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
227 void bracket(char c1, char c2)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
228 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
229 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
230 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
231
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
232 /**
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
233 * Returns the number of bytes written.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
234 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
235 int size()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
236 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
237 return p - buf;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
238 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
239
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
240 char* toString()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
241 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
242 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
243 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
244
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
245 void setsize(uint size)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
246 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
247 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
248 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
249
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
250 void writesLEB128(long value)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
251 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
252 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
253 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
254
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
255 void writeuLEB128(uint value)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
256 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
257 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
258 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
259 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
260
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
261 static this()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
262 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
263 obj_symbols_towrite = new Array();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
264 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
265
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
266 /**************************************
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
267 * Append s to list of object files to generate later.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
268 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
269
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
270 void obj_append(Dsymbol s)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
271 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
272 obj_symbols_towrite.push(cast(void*)s);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
273 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
274
14
2cc604139636 Implemented Linux support for ddmd. Some parts are a bit hacky to just "get it working", that said, druntime and phobos compile, and unittests pass.
Robert Clipsham <robert@octarineparrot.com>
parents: 0
diff changeset
275 version (Bug4059)
2cc604139636 Implemented Linux support for ddmd. Some parts are a bit hacky to just "get it working", that said, druntime and phobos compile, and unittests pass.
Robert Clipsham <robert@octarineparrot.com>
parents: 0
diff changeset
276 {
2cc604139636 Implemented Linux support for ddmd. Some parts are a bit hacky to just "get it working", that said, druntime and phobos compile, and unittests pass.
Robert Clipsham <robert@octarineparrot.com>
parents: 0
diff changeset
277 private extern (C) void _Z8obj_initP9OutbufferPKcS2_(Outbuffer* objbuf, const(char)* filename, const(char)* csegname);
2cc604139636 Implemented Linux support for ddmd. Some parts are a bit hacky to just "get it working", that said, druntime and phobos compile, and unittests pass.
Robert Clipsham <robert@octarineparrot.com>
parents: 0
diff changeset
278 void obj_init(Outbuffer* objbuf, const(char)* filename, const(char)* csegname) { return _Z8obj_initP9OutbufferPKcS2_(objbuf, filename, csegname); }
2cc604139636 Implemented Linux support for ddmd. Some parts are a bit hacky to just "get it working", that said, druntime and phobos compile, and unittests pass.
Robert Clipsham <robert@octarineparrot.com>
parents: 0
diff changeset
279 }
2cc604139636 Implemented Linux support for ddmd. Some parts are a bit hacky to just "get it working", that said, druntime and phobos compile, and unittests pass.
Robert Clipsham <robert@octarineparrot.com>
parents: 0
diff changeset
280 else
2cc604139636 Implemented Linux support for ddmd. Some parts are a bit hacky to just "get it working", that said, druntime and phobos compile, and unittests pass.
Robert Clipsham <robert@octarineparrot.com>
parents: 0
diff changeset
281 {
2cc604139636 Implemented Linux support for ddmd. Some parts are a bit hacky to just "get it working", that said, druntime and phobos compile, and unittests pass.
Robert Clipsham <robert@octarineparrot.com>
parents: 0
diff changeset
282 void obj_init(Outbuffer* objbuf, const(char)* filename, const(char)* csegname);
2cc604139636 Implemented Linux support for ddmd. Some parts are a bit hacky to just "get it working", that said, druntime and phobos compile, and unittests pass.
Robert Clipsham <robert@octarineparrot.com>
parents: 0
diff changeset
283 }
2cc604139636 Implemented Linux support for ddmd. Some parts are a bit hacky to just "get it working", that said, druntime and phobos compile, and unittests pass.
Robert Clipsham <robert@octarineparrot.com>
parents: 0
diff changeset
284
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
285 extern (C++) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
286 void backend_init();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
287 void backend_term();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
288 void obj_term();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
289 void rtlsym_reset();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
290 void slist_reset();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
291 void el_reset();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
292 void cg87_reset();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
293 void out_reset();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
294 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
295
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
296 void clearStringTab()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
297 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
298 //printf("clearStringTab()\n");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
299 memset(stringTab.ptr, 0, stringTab.sizeof);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
300 stidx = 0;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
301
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
302 assertexp_sfilename = null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
303 assertexp_name = null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
304 assertexp_mn = null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
305 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
306
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
307 void obj_start(char *srcfile)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
308 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
309 //printf("obj_start()\n");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
310
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
311 out_config_init();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
312
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
313 rtlsym_reset();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
314 slist_reset();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
315 clearStringTab();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
316
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
317 obj_init(&objbuf, srcfile, null);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
318
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
319 el_reset();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
320 cg87_reset();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
321 out_reset();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
322 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
323
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
324 void obj_end(Library library, File objfile)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
325 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
326 obj_term();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
327
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
328 if (library)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
329 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
330 // Transfer image to library
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
331 library.addObject(objfile.name.toChars(), objbuf.buf, objbuf.p - objbuf.buf);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
332 objbuf.buf = null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
333 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
334 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
335 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
336 // Transfer image to file
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
337 objfile.setbuffer(objbuf.buf, objbuf.p - objbuf.buf);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
338 objbuf.buf = null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
339
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
340 string p = FileName.path(objfile.name.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
341 FileName.ensurePathExists(p);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
342 //mem.free(p);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
343
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
344 //printf("write obj %s\n", objfile.name.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
345 objfile.writev();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
346 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
347
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
348 objbuf.pend = null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
349 objbuf.p = null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
350 objbuf.len = 0;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
351 objbuf.inc = 0;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
352 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
353
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
354 void obj_write_deferred(Library library)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
355 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
356 for (int i = 0; i < obj_symbols_towrite.dim; i++)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
357 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
358 Dsymbol s = cast(Dsymbol)obj_symbols_towrite.data[i];
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
359 Module m = s.getModule();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
360
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
361 string mname;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
362 if (m)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
363 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
364 mname = m.srcfile.toChars();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
365 lastmname = mname;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
366 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
367 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
368 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
369 //mname = s->ident->toChars();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
370 mname = lastmname;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
371 assert(mname.length != 0);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
372 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
373
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
374 obj_start(cast(char*)toStringz(mname));
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
375
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
376 static int count;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
377 count++; // sequence for generating names
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
378
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
379 /* Create a module that's a doppelganger of m, with just
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
380 * enough to be able to create the moduleinfo.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
381 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
382 OutBuffer idbuf = new OutBuffer();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
383 idbuf.printf("%s.%d", m ? m.ident.toChars() : mname, count);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
384 string idstr = idbuf.extractString();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
385 idbuf.data = null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
386 Identifier id = new Identifier(idstr, TOK.TOKidentifier);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
387
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
388 Module md = new Module(mname, id, 0, 0);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
389 md.members = new Array();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
390 md.members.push(cast(void*)s); // its only 'member' is s
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
391 if (m)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
392 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
393 md.doppelganger = 1; // identify this module as doppelganger
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
394 md.md = m.md;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
395 md.aimports.push(cast(void*)m); // it only 'imports' m
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
396 md.massert = m.massert;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
397 md.marray = m.marray;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
398 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
399
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
400 md.genobjfile(0);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
401
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
402 /* Set object file name to be source name with sequence number,
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
403 * as mangled symbol names get way too long.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
404 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
405 string fname = FileName.removeExt(mname);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
406
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
407 OutBuffer namebuf = new OutBuffer();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
408 uint hash = 0;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
409 foreach (char c; s.toChars())
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
410 hash += c;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
411
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
412 namebuf.printf("%s_%x_%x.%s", fname, count, hash, global.obj_ext);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
413 fname = namebuf.extractString();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
414
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
415 //printf("writing '%s'\n", fname);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
416 File objfile = new File(fname);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
417 obj_end(library, objfile);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
418 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
419
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
420 obj_symbols_towrite.dim = 0;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
421 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
422
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
423 /**************************************
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
424 * Initialize config variables.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
425 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
426
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
427 void out_config_init()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
428 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
429 Param* params = &global.params;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
430
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
431 if (!config.target_cpu)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
432 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
433 config.target_cpu = TARGET_PentiumPro;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
434 config.target_scheduler = config.target_cpu;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
435 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
436 config.fulltypes = CVNONE;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
437 config.inline8087 = 1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
438 config.memmodel = 0;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
439 config.flags |= CFGuchar; // make sure TYchar is unsigned
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
440 version (TARGET_WINDOS) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
441 if (params.isX86_64)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
442 config.exe = EX_WIN64;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
443 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
444 config.exe = EX_NT;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
445
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
446 // Win32 eh
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
447 config.flags2 |= CFG2seh;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
448
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
449 if (params.run)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
450 config.wflags |= WFexe; // EXE file only optimizations
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
451 else if (params.link && !global.params.deffile)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
452 config.wflags |= WFexe; // EXE file only optimizations
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
453 else if (params.exefile) // if writing out EXE file
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
454 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
455 size_t len = params.exefile.length;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
456 if (len >= 4 && icmp(params.exefile[len-3..len], "exe") == 0)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
457 config.wflags |= WFexe;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
458 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
459 config.flags4 |= CFG4underscore;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
460 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
461 version (TARGET_LINUX) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
462 if (params.isX86_64)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
463 config.exe = EX_LINUX64;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
464 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
465 config.exe = EX_LINUX;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
466 config.flags |= CFGnoebp;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
467 config.flags |= CFGalwaysframe;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
468 if (params.pic)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
469 config.flags3 |= CFG3pic;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
470 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
471 version (TARGET_OSX) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
472 if (params.isX86_64)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
473 config.exe = EX_OSX64;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
474 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
475 config.exe = EX_OSX;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
476 config.flags |= CFGnoebp;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
477 config.flags |= CFGalwaysframe;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
478 if (params.pic)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
479 config.flags3 |= CFG3pic;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
480 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
481 version (TARGET_FREEBSD) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
482 if (params.isX86_64)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
483 config.exe = EX_FREEBSD64;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
484 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
485 config.exe = EX_FREEBSD;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
486 config.flags |= CFGnoebp;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
487 config.flags |= CFGalwaysframe;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
488 if (params.pic)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
489 config.flags3 |= CFG3pic;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
490 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
491 version (TARGET_SOLARIS) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
492 if (params.isX86_64)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
493 config.exe = EX_SOLARIS64;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
494 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
495 config.exe = EX_SOLARIS;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
496 config.flags |= CFGnoebp;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
497 config.flags |= CFGalwaysframe;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
498 if (params.pic)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
499 config.flags3 |= CFG3pic;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
500 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
501 config.flags2 |= CFG2nodeflib; // no default library
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
502 config.flags3 |= CFG3eseqds;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
503 static if (false) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
504 if (env.getEEcontext().EEcompile != 2)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
505 config.flags4 |= CFG4allcomdat;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
506 if (env.nochecks())
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
507 config.flags4 |= CFG4nochecks; // no runtime checking
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
508 } else version (TARGET_OSX) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
509 } else {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
510 config.flags4 |= CFG4allcomdat;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
511 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
512 if (params.trace)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
513 config.flags |= CFGtrace; // turn on profiler
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
514 if (params.nofloat)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
515 config.flags3 |= CFG3wkfloat;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
516
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
517 configv.verbose = params.verbose;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
518
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
519 if (params.optimize)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
520 go_flag(cast(char*)"-o".ptr);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
521
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
522 if (params.symdebug)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
523 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
524 version (ELFOBJ_OR_MACHOBJ) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
525 configv.addlinenumbers = 1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
526 config.fulltypes = (params.symdebug == 1) ? CVDWARF_D : CVDWARF_C;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
527 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
528 version (OMFOBJ) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
529 configv.addlinenumbers = 1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
530 config.fulltypes = CV4;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
531 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
532 if (!params.optimize)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
533 config.flags |= CFGalwaysframe;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
534 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
535 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
536 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
537 configv.addlinenumbers = 0;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
538 config.fulltypes = CVNONE;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
539 //config.flags &= ~CFGalwaysframe;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
540 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
541
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
542 if (params.isX86_64)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
543 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
544 util_set64();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
545 cod3_set64();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
546 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
547 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
548 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
549 util_set386();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
550 cod3_set386();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
551 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
552
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
553 debug {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
554 debugb = params.debugb;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
555 debugc = params.debugc;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
556 debugf = params.debugf;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
557 debugr = params.debugr;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
558 debugw = params.debugw;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
559 debugx = params.debugx;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
560 debugy = params.debugy;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
561 }
14
2cc604139636 Implemented Linux support for ddmd. Some parts are a bit hacky to just "get it working", that said, druntime and phobos compile, and unittests pass.
Robert Clipsham <robert@octarineparrot.com>
parents: 0
diff changeset
562 }