-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tsify lib/compilers #4609
Tsify lib/compilers #4609
Conversation
execute: false, | ||
demangle: false, | ||
libraryCode: false, | ||
trim: false, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these the right defaults?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need: demangle: true
but everything else looks good to me. @partouf is that the right default for libraryCode
- I think so.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
both demangle and libraryCode and are defaulted to true in the UI, but so are directives and commentOnly, I think we leave the defaults to the UI and people using the API should do everything manually. Because then they'll know what might be filtered out - instead of having everything filtered out by default and then they don't know what they might be missing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't really know what this is doing, but it's probably missing binaryObject if the goal is to init all possible filters.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please, do add it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BaseCompiler.getDefaultFilters
is implemented as
compiler-explorer/lib/base-compiler.ts
Lines 2755 to 2768 in 784393b
getDefaultFilters() { | |
return { | |
binary: false, | |
execute: false, | |
demangle: true, | |
intel: true, | |
commentOnly: true, | |
directives: true, | |
labels: true, | |
optOutput: false, | |
libraryCode: false, | |
trim: false, | |
}; | |
} |
It looks like the return type should be ParseFiltersAndOutputOptions
so I will update it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dkm What should the default for binaryObject
be?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am pretty sure false
. I think we could "just" try that and fix it up (in order to get this merged)
{ | ||
text: objResult.stdout, | ||
}, | ||
], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unsure if this is correct, just made a best guess for how to put this in a ParsedAsmResult
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very good question .. this will need to be tested. But...I wonder how it worked before if this isn't quite right ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm cool with finding out by merging and dealing with the consequences
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With the regression in #4668 I'm wondering how this worked before 🤔
{ | ||
text: `<No output: javap returned ${objResult.code}>`, | ||
}, | ||
]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here
const maxSize = this.env.ceProps('max-asm-size', 64 * 1024 * 1024); | ||
const optPromise = result.hasOptOutput ? this.processOptOutput(result.optPath) : Promise.resolve(''); | ||
const asmPromise = ( | ||
filters.binary | ||
? this.objdump(outputFilename, {}, maxSize, filters.intel, filters.demangle, filters) | ||
? this.objdump(outputFilename, {}, maxSize, filters.intel, filters.demangle, false, false, filters) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typescript uncovered a bug here, staticReloc
and dynamicReloc
weren't being passed. Is passing false for both appropriate?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think so: @dkm I think is the one to know for certain.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, passing false is valid in case of doubt. Using true will add extra parameters to objdumper
, which may or may not be a good idea (don't know anything about nvcc
tools)
const dirPath = path.dirname(outputFilename); | ||
const execBinary = this.getExecutableFilename(dirPath); | ||
if (await utils.fileExists(execBinary)) { | ||
return super.objdump(execBinary, result, maxSize, intelAsm, demangle); | ||
return super.objdump(execBinary, result, maxSize, intelAsm, demangle, staticReloc, dynamicReloc, filters); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, three arguments weren't being passed and also weren't present in the parameter list. I went ahead and just added them to the parameters / forwarded.
return exec.execute(python, python_args, options); | ||
} | ||
logger.error(`Invalid ppci path ${compiler}`); | ||
assert(false, `Invalid ppci path ${compiler}`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think an assert here is appropriate. Something to kill the code path is needed otherwise TS isn't happy that undefined is being returned.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How is assert(false) better than throw new Error()
in this case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that'd be more or less equivalent. assert
does ultimately throw a new Error internally. So it's just whatever extra diagnostics assert
adds in.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it. Maybe we should make a fatalError(); that makes it clear? (I just have a vague dislike of assert(false)
but that's mainly C PTSD..:)
const match = line.replace(/\x1B\[[\d;]*[Km]/g, '').match(re); | ||
if (match) { | ||
lineObj.text = `<source>:${match[1]} ${match[2].trim()}`; | ||
lineObj.tag = { | ||
severity: 0, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if this is correct, some severity is needed for the tag
text: 'Failed to run compiler to get MLIR code', | ||
}, | ||
], | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if this is correct, made a best effort to get things into the correct form
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
100%
@@ -37,7 +37,7 @@ export type ParsedAsmResult = { | |||
parsingTime?: string; | |||
filteredCount?: number; | |||
externalParserUsed?: boolean; | |||
objdumpTime?: number; | |||
objdumpTime?: number | string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apparently it's set to a string in one of the compilers
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh that's odd - which compiler? Seems like it ought not to be (maybe a TODO?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
java
was the only compiler erroring however other compilers do similar assignments, e.g. clang does result.objdumpTime = objResult.execTime;
but result
is any
(objResult.execTime
is a string). I'm not sure how this type is used throughout the codebase, I'll go ahead and add a TODO.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Its set to a string, but the frontend always takes that into account. There was a good reason for it, but I really can’t remember why. But it is what it is. We can change it later on when we have a clear view of what everything is and should be
Ok, not sure what is causing that test to fail. Will investigate more tomorrow. |
449865a
to
76f8595
Compare
Ah shoot lots of merge conflicts because I did npm run lint on main, should have waited |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ran out of time at 32/78 files reviewd. looking good though!
lib/base-compiler.ts
Outdated
@@ -98,7 +98,7 @@ export class BaseCompiler implements ICompiler { | |||
protected toolchainPath: any; | |||
public possibleArguments: CompilerArguments; | |||
protected possibleTools: ITool[]; | |||
protected demanglerClass: any; | |||
protected demanglerClass: any; // TODO(jeremy-rifkin): Will be able to do better once #4607 lands |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#4607 has landed now (yay)
@@ -1254,7 +1254,7 @@ export class BaseCompiler implements ICompiler { | |||
} | |||
} | |||
|
|||
getExecutableFilename(dirPath, outputFilebase, key?) { | |||
getExecutableFilename(dirPath: string, outputFilebase: string, key?) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we know what the key?
type is? looks like : any
from getOutputFilename
though I suspect it's possible to imrpove on that...though not in this PR necessarily
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think key "should" be something that looks like the result of https://github.com/compiler-explorer/compiler-explorer/blob/main/lib/base-compiler.ts#L1681 and in some cases what's returned by https://github.com/compiler-explorer/compiler-explorer/blob/main/lib/base-compiler.ts#L1685 - in theory at least
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll probably defer this to another PR, this PR is a big enough review already :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
100%
execute: false, | ||
demangle: false, | ||
libraryCode: false, | ||
trim: false, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need: demangle: true
but everything else looks good to me. @partouf is that the right default for libraryCode
- I think so.
@@ -49,8 +50,8 @@ export class JaktCompiler extends BaseCompiler { | |||
maxSize: number, | |||
intelAsm, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
aren't these also boolean
too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure, this matches the definition in BaseCompiler at the moment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
got it :)
{ | ||
text: objResult.stdout, | ||
}, | ||
], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very good question .. this will need to be tested. But...I wonder how it worked before if this isn't quite right ...
I'm really not happy about all the constructors getting passed the type |
@partouf You're absolutely right, I'm not sure why I did that 😄 I went ahead and fixed the |
I realised I just did a couple of these in separate PRs; whoops. Will review this instead 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! I think we should fail forward. I'm a bit confused about the TODOs that refer their own PR number...are those planned to be done before merging? If so: great, if not then they will refer to a closed issue :)
lib/base-compiler.ts
Outdated
@@ -99,7 +99,8 @@ export class BaseCompiler implements ICompiler { | |||
protected toolchainPath: any; | |||
public possibleArguments: CompilerArguments; | |||
protected possibleTools: ITool[]; | |||
protected demanglerClass: any; | |||
// TODO(jeremy-rifkin): Will be able to do better once #4607 lands |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#4607 has landed (but the TODO stands)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah shoot I wasn't paying attention here, ty!
@@ -1254,7 +1254,7 @@ export class BaseCompiler implements ICompiler { | |||
} | |||
} | |||
|
|||
getExecutableFilename(dirPath, outputFilebase, key?) { | |||
getExecutableFilename(dirPath: string, outputFilebase: string, key?) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
100%
lib/base-compiler.ts
Outdated
@@ -2225,7 +2231,9 @@ export class BaseCompiler implements ICompiler { | |||
|
|||
if (!bypassCache) { | |||
const cacheRetreiveTimeStart = process.hrtime.bigint(); | |||
const result = await this.env.cacheGet(key); | |||
// TODO: Because key coantains a CompilerInfo which contains a function member it can't be assigned to a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is the "todo" part? This seems like a reason to cast to any for sure, but I'm not sure what the action to take is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO to eliminate the ugly any
cast, key
should be cacheable (if it's not that's a big problem), it's just a matter of getting the types lined up
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll update it to be more clear
execute: false, | ||
demangle: false, | ||
libraryCode: false, | ||
trim: false, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am pretty sure false
. I think we could "just" try that and fix it up (in order to get this merged)
@@ -49,8 +50,8 @@ export class JaktCompiler extends BaseCompiler { | |||
maxSize: number, | |||
intelAsm, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
got it :)
{ | ||
text: objResult.stdout, | ||
}, | ||
], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm cool with finding out by merging and dealing with the consequences
lib/compilers/ldc.ts
Outdated
// These options make LDC produce an AST dump in a separate file `<inputFilename>.cg`. | ||
const newOptions = options.concat('-vcg-ast'); | ||
const execOptions = this.getDefaultExecOptions(); | ||
// TODO(#4609) generateAST expects to return a ResultLine[] not a string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This TODO refers to itself? Should be a separate issue unless you plan o nfixing it before merging?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was trying to do the same thing we did in #4490, I can make a separate issue for this though
return exec.execute(python, python_args, options); | ||
} | ||
logger.error(`Invalid ppci path ${compiler}`); | ||
assert(false, `Invalid ppci path ${compiler}`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How is assert(false) better than throw new Error()
in this case?
text: 'Failed to run compiler to get MLIR code', | ||
}, | ||
], | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
100%
@@ -37,7 +37,8 @@ export type ParsedAsmResult = { | |||
parsingTime?: string; | |||
filteredCount?: number; | |||
externalParserUsed?: boolean; | |||
objdumpTime?: number; | |||
// TODO(#4609) A few compilers seem to assign strings here. It might be ok but we should look into it more. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another self-referencing TODO?
woo! |
No description provided.