File tree Expand file tree Collapse file tree 5 files changed +34
-4
lines changed Expand file tree Collapse file tree 5 files changed +34
-4
lines changed Original file line number Diff line number Diff line change 37
37
-dv VER - Disables VER
38
38
-h FILE - Puts the contents of FILE at the top of the assembly output
39
39
-bo OPT - Backend option, see below
40
+ -ka - Keep assembly
40
41
41
42
Backends:
42
43
rm86 - Real mode x86 and MS-DOS
@@ -76,6 +77,7 @@ int main(string[] args) {
76
77
string [] disabled;
77
78
string header;
78
79
string [] backendOpts;
80
+ bool keepAssembly;
79
81
80
82
for (size_t i = 1 ; i < args.length; ++ i) {
81
83
if (args[i][0 ] == ' -' ) {
@@ -238,6 +240,10 @@ int main(string[] args) {
238
240
backendOpts ~= args[i];
239
241
break ;
240
242
}
243
+ case " -ka" : {
244
+ keepAssembly = true ;
245
+ break ;
246
+ }
241
247
default : {
242
248
stderr.writefln(" Unknown flag '%s'" , args[i]);
243
249
return 1 ;
@@ -299,6 +305,7 @@ int main(string[] args) {
299
305
compiler.backend.useDebug = doDebug;
300
306
compiler.backend.exportSymbols = exportSymbols;
301
307
compiler.backend.link ~= link;
308
+ backend.keepAssembly = keepAssembly;
302
309
303
310
version s ~= compiler.backend.GetVersions();
304
311
Original file line number Diff line number Diff line change @@ -175,9 +175,30 @@ class BackendLinux86 : CompilerBackend {
175
175
linkCommand ~= " -dynamic-linker /lib64/ld-linux-x86-64.so.2" ;
176
176
}
177
177
178
+ if (useLibc) {
179
+ string [] possiblePaths = [
180
+ " /usr/lib/crt1.o" ,
181
+ " /usr/lib/x86_64-linux-gnu/crt1.o"
182
+ ];
183
+ bool crt1;
184
+
185
+ foreach (ref path ; possiblePaths) {
186
+ if (exists(path)) {
187
+ crt1 = true ;
188
+ linkCommand ~= format(" %s" , path);
189
+ }
190
+ }
191
+
192
+ linkCommand ~= " /usr/lib/crt1.o" ;
193
+ }
194
+
178
195
ret ~= linkCommand;
179
196
180
- return ret ~ format(" rm %s.asm %s.o" , compiler.outFile, compiler.outFile);
197
+ if (! keepAssembly) {
198
+ ret ~= format(" rm %s.asm %s.o" , compiler.outFile, compiler.outFile);
199
+ }
200
+
201
+ return ret;
181
202
}
182
203
183
204
override long MaxInt () => - 1 ;
@@ -201,7 +222,8 @@ class BackendLinux86 : CompilerBackend {
201
222
}
202
223
203
224
override void Init () {
204
- if (! useLibc) output ~= " global _start\n " ;
225
+ if (useLibc) output ~= " global main\n " ;
226
+ else output ~= " global _start\n " ;
205
227
206
228
output ~= " section .text\n " ;
207
229
Original file line number Diff line number Diff line change @@ -147,7 +147,7 @@ class BackendRM86 : CompilerBackend {
147
147
override string [] FinalCommands () => [
148
148
format(" mv %s %s.asm" , compiler.outFile, compiler.outFile),
149
149
format(" nasm -f bin %s.asm -o %s" , compiler.outFile, compiler.outFile),
150
- format(" rm %s.asm" , compiler.outFile)
150
+ keepAssembly? " " : format(" rm %s.asm" , compiler.outFile)
151
151
];
152
152
153
153
override long MaxInt () => 0xFFFF ;
Original file line number Diff line number Diff line change @@ -109,7 +109,7 @@ class BackendUXN : CompilerBackend {
109
109
override string [] FinalCommands () => [
110
110
format(" mv %s %s.tal" , compiler.outFile, compiler.outFile),
111
111
format(" uxnasm %s.tal %s" , compiler.outFile, compiler.outFile),
112
- format(" rm %s.tal" , compiler.outFile)
112
+ keepAssembly? " " : format(" rm %s.tal" , compiler.outFile)
113
113
];
114
114
115
115
override long MaxInt () => 0xFFFF ;
Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ class CompilerBackend {
18
18
bool useDebug;
19
19
bool exportSymbols;
20
20
string [] link;
21
+ bool keepAssembly;
21
22
22
23
abstract string [] GetVersions ();
23
24
abstract string [] FinalCommands ();
You can’t perform that action at this time.
0 commit comments