aboutsummaryrefslogtreecommitdiff
path: root/lib/compilers/clang.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/compilers/clang.js')
-rw-r--r--lib/compilers/clang.js42
1 files changed, 28 insertions, 14 deletions
diff --git a/lib/compilers/clang.js b/lib/compilers/clang.js
index e4c044c33..665ea6614 100644
--- a/lib/compilers/clang.js
+++ b/lib/compilers/clang.js
@@ -24,10 +24,11 @@
import fs from 'fs';
import path from 'path';
+import _ from 'underscore';
-import { BaseCompiler } from '../base-compiler';
-import { AmdgpuAsmParser } from '../parsers/asm-parser-amdgpu';
-import { SassAsmParser } from '../parsers/asm-parser-sass';
+import {BaseCompiler} from '../base-compiler';
+import {AmdgpuAsmParser} from '../parsers/asm-parser-amdgpu';
+import {SassAsmParser} from '../parsers/asm-parser-sass';
const offloadRegexp = /^#\s+__CLANG_OFFLOAD_BUNDLE__(__START__|__END__)\s+(.*)$/gm;
@@ -55,6 +56,22 @@ export class ClangCompiler extends BaseCompiler {
return super.runExecutable(executable, executeParameters, homeDir);
}
+ forceDwarf4UnlessOverridden(options) {
+ const hasOverride = _.any(options, option => {
+ return option.includes('-gdwarf-') || option.includes('-fdebug-default-version=');
+ });
+
+ if (!hasOverride) return ['-gdwarf-4'].concat(options);
+
+ return options;
+ }
+
+ optionsForFilter(filters, outputFilename) {
+ const options = super.optionsForFilter(filters, outputFilename);
+
+ return this.forceDwarf4UnlessOverridden(options);
+ }
+
runCompiler(compiler, options, inputFilename, execOptions) {
if (!execOptions) {
execOptions = this.getDefaultExecOptions();
@@ -67,8 +84,7 @@ export class ClangCompiler extends BaseCompiler {
splitDeviceCode(assembly) {
// Check to see if there is any offload code in the assembly file.
- if (!offloadRegexp.test(assembly))
- return null;
+ if (!offloadRegexp.test(assembly)) return null;
offloadRegexp.lastIndex = 0;
const matches = assembly.matchAll(offloadRegexp);
@@ -87,15 +103,12 @@ export class ClangCompiler extends BaseCompiler {
extractDeviceCode(result, filters) {
const split = this.splitDeviceCode(result.asm);
- if (!split)
- return result;
+ if (!split) return result;
- const devices = result.devices = {};
+ const devices = (result.devices = {});
for (const key of Object.keys(split)) {
- if (key.indexOf('host-') === 0)
- result.asm = split[key];
- else
- devices[key] = this.processDeviceAssembly(key, split[key], filters);
+ if (key.indexOf('host-') === 0) result.asm = split[key];
+ else devices[key] = this.processDeviceAssembly(key, split[key], filters);
}
return result;
// //result.asm = ...
@@ -118,8 +131,9 @@ export class ClangCompiler extends BaseCompiler {
}
processDeviceAssembly(deviceName, deviceAsm, filters) {
- return this.llvmIr.isLlvmIr(deviceAsm) ?
- this.llvmIr.process(deviceAsm, filters) : this.asm.process(deviceAsm, filters);
+ return this.llvmIr.isLlvmIr(deviceAsm)
+ ? this.llvmIr.process(deviceAsm, filters)
+ : this.asm.process(deviceAsm, filters);
}
}