diff options
Diffstat (limited to 'lib/compilers')
-rw-r--r-- | lib/compilers/ada.ts | 74 | ||||
-rw-r--r-- | lib/compilers/cc65.ts | 13 | ||||
-rw-r--r-- | lib/compilers/jakt.ts | 14 | ||||
-rw-r--r-- | lib/compilers/llvm-mos.ts | 13 | ||||
-rw-r--r-- | lib/compilers/racket.ts | 2 | ||||
-rw-r--r-- | lib/compilers/rust.ts | 2 | ||||
-rw-r--r-- | lib/compilers/z88dk.ts | 2 |
7 files changed, 79 insertions, 41 deletions
diff --git a/lib/compilers/ada.ts b/lib/compilers/ada.ts index 89f500f4b..6c867e7ab 100644 --- a/lib/compilers/ada.ts +++ b/lib/compilers/ada.ts @@ -51,10 +51,23 @@ export class AdaCompiler extends BaseCompiler { return path.join(dirPath, 'example'); } - override getOutputFilename(dirPath) { + override getOutputFilename(dirPath: string, outputFilebase: string, key?: any): string { // The basename here must match the value used in the pragma Source_File // in the user provided source. - return path.join(dirPath, 'example.out'); + + // Beware that GNAT is picky on output filename: + // - the basename must match the unit name (emits error otherwise) + // - can't do "-c -o foo.out", output must end with .o + // - "foo.o" may be used by intermediary file, so "-o foo.o" will not + // work if building an executable. + + if (key && key.filters && key.filters.binary) { + return path.join(dirPath, 'example'); + } else if (key && key.filters && key.filters.binaryObject) { + return path.join(dirPath, 'example.o'); + } else { + return path.join(dirPath, 'example.s'); + } } override prepareArguments(userOptions, filters, backendOptions, inputFilename, outputFilename, libraries) { @@ -80,11 +93,11 @@ export class AdaCompiler extends BaseCompiler { gnatmake_opts.push(`--RTS=${this.compiler.adarts}`); } - if (backendOptions.produceGnatDebug && this.compiler.supportsGnatDebugViews) + if (!filters.execute && backendOptions.produceGnatDebug && this.compiler.supportsGnatDebugViews) // This is using stdout gnatmake_opts.push('-gnatGL'); - if (backendOptions.produceGnatDebugTree && this.compiler.supportsGnatDebugViews) + if (!filters.execute && backendOptions.produceGnatDebugTree && this.compiler.supportsGnatDebugViews) // This is also using stdout gnatmake_opts.push('-gnatdt'); @@ -95,9 +108,7 @@ export class AdaCompiler extends BaseCompiler { inputFilename, ); - if (filters.binary) { - gnatmake_opts.push('-o', outputFilename); - } else { + if (!filters.execute && !filters.binary && !filters.binaryObject) { gnatmake_opts.push( '-S', // Generate ASM '-c', // Compile only @@ -112,6 +123,24 @@ export class AdaCompiler extends BaseCompiler { gnatmake_opts.push(opt); } } + } else if (filters.binaryObject) { + gnatmake_opts.push( + '-c', // Compile only + ); + + // produce assembly output in outputFilename + compiler_opts.push('-o', outputFilename); + + if (this.compiler.intelAsm && filters.intel) { + for (const opt of this.compiler.intelAsm.split(' ')) { + gnatmake_opts.push(opt); + } + } + // if (this.compiler.intelAsm && filters.intel) { + // options = options.concat(this.compiler.intelAsm.split(' ')); + // } + } else { + gnatmake_opts.push('-o', outputFilename); } // Spread the options coming from outside (user, backend or config options) @@ -146,35 +175,4 @@ export class AdaCompiler extends BaseCompiler { return gnatmake_opts.concat('-cargs', compiler_opts, '-largs', linker_opts, '-bargs', binder_opts); } - - override async runCompiler( - compiler: string, - options: string[], - inputFilename: string, - execOptions: ExecutionOptions, - ): Promise<CompilationResult> { - if (!execOptions) { - execOptions = this.getDefaultExecOptions(); - } - - if (!execOptions.customCwd) { - execOptions.customCwd = path.dirname(inputFilename); - } - - // create a subdir so that files automatically created by GNAT don't - // conflict with anything else in parent dir. - const appHome = path.dirname(inputFilename); - const temp_dir = path.join(appHome, 'tempsub'); - await fs.mkdir(temp_dir); - - // Set the working directory to be the temp directory that has been created - execOptions.appHome = appHome; - execOptions.customCwd = temp_dir; - - const result = await this.exec(compiler, options, execOptions); - return { - ...this.transformToCompilationResult(result, inputFilename), - languageId: this.getCompilerResultLanguageId(), - }; - } } diff --git a/lib/compilers/cc65.ts b/lib/compilers/cc65.ts index bbb5467cb..8eb286a60 100644 --- a/lib/compilers/cc65.ts +++ b/lib/compilers/cc65.ts @@ -98,9 +98,20 @@ export class Cc65Compiler extends BaseCompiler { maxSize: number, intelAsm, demangle, + staticReloc, + dynamicReloc, filters: ParseFiltersAndOutputOptions, ) { - const res = await super.objdump(outputFilename, result, maxSize, intelAsm, demangle, filters); + const res = await super.objdump( + outputFilename, + result, + maxSize, + intelAsm, + demangle, + staticReloc, + dynamicReloc, + filters, + ); const dirPath = path.dirname(outputFilename); const nesFile = path.join(dirPath, 'example.nes'); diff --git a/lib/compilers/jakt.ts b/lib/compilers/jakt.ts index e9948fb88..a9ef1e3e5 100644 --- a/lib/compilers/jakt.ts +++ b/lib/compilers/jakt.ts @@ -49,9 +49,21 @@ export class JaktCompiler extends BaseCompiler { maxSize: number, intelAsm, demangle, + staticReloc, + dynamicReloc, filters: ParseFiltersAndOutputOptions, ) { - const objdumpResult = await super.objdump(outputFilename, result, maxSize, intelAsm, demangle, filters); + const objdumpResult = await super.objdump( + outputFilename, + result, + maxSize, + intelAsm, + demangle, + staticReloc, + dynamicReloc, + filters, + ); + objdumpResult.languageId = 'asm'; return objdumpResult; } diff --git a/lib/compilers/llvm-mos.ts b/lib/compilers/llvm-mos.ts index b5eb03686..af18a4dd7 100644 --- a/lib/compilers/llvm-mos.ts +++ b/lib/compilers/llvm-mos.ts @@ -62,6 +62,8 @@ export class LLVMMOSCompiler extends ClangCompiler { maxSize: number, intelAsm, demangle, + staticReloc, + dynamicReloc, filters: ParseFiltersAndOutputOptions, ) { if (!outputFilename.endsWith('.elf') && (await utils.fileExists(outputFilename + '.elf'))) { @@ -69,7 +71,16 @@ export class LLVMMOSCompiler extends ClangCompiler { } intelAsm = false; - const res = await super.objdump(outputFilename, result, maxSize, intelAsm, demangle, filters); + const res = await super.objdump( + outputFilename, + result, + maxSize, + intelAsm, + demangle, + staticReloc, + dynamicReloc, + filters, + ); if (this.compiler.exe.includes('nes')) { let nesFile = outputFilename; diff --git a/lib/compilers/racket.ts b/lib/compilers/racket.ts index f77ba783a..f67275eb4 100644 --- a/lib/compilers/racket.ts +++ b/lib/compilers/racket.ts @@ -97,6 +97,8 @@ export class RacketCompiler extends BaseCompiler { maxSize: number, intelAsm: any, demangle: any, + staticReloc, + dynamicReloc, filters: ParseFiltersAndOutputOptions, ): Promise<any> { // Decompile to assembly via `raco decompile` with `disassemble` package diff --git a/lib/compilers/rust.ts b/lib/compilers/rust.ts index b0cb6484c..0fbce4e0c 100644 --- a/lib/compilers/rust.ts +++ b/lib/compilers/rust.ts @@ -138,6 +138,8 @@ export class RustCompiler extends BaseCompiler { if (this.linker) { options = options.concat(`-Clinker=${this.linker}`); } + } else if (filters.binaryObject) { + options = options.concat(['--crate-type', 'lib']); } else { if (!userRequestedEmit) { options = options.concat('--emit', 'asm'); diff --git a/lib/compilers/z88dk.ts b/lib/compilers/z88dk.ts index b5d73dd1a..ee388b9b9 100644 --- a/lib/compilers/z88dk.ts +++ b/lib/compilers/z88dk.ts @@ -116,6 +116,8 @@ export class z88dkCompiler extends BaseCompiler { maxSize: number, intelAsm, demangle, + staticReloc, + dynamicReloc, filters: ParseFiltersAndOutputOptions, ) { outputFilename = this.getObjdumpOutputFilename(outputFilename); |