Skip to content
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

Cmake + llvm + wine to work in tree view #6423

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

ramang-unity
Copy link
Contributor

When trying to upload a zip and use cmake + llvm + wine it was not working with compile explorer. These changes were required.

@@ -3083,6 +3083,14 @@ export class BaseCompiler implements ICompiler {
if (result.inputFilename) {
result.inputFilename = utils.maskRootdir(result.inputFilename);
}

if (result.asm) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On our machine running compile explorer the source was in /tmp/compile-exploer-[some random chars]/main.cpp for example. Thus the main.cpp would never match in the tree view with this to highlight source code to match the asm.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I 100% understand the reasoning, but this is probably not the best way to solve the problem. I'll have a think about it

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not 100% following what's happening here, but we can't have this in the mainline version of CE; it's a pretty core thing that ought to be handled elsewhere.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I take the cmake template it will create a main.cpp with a CMakeLists.txt. On our server it would compile that file into a /tmp folder. While on godbolt it would be in the /app folder. Then on our server when we would hover over the C++ code it would not high light the equivalent asm. To solve that I had to do this code change. I'm not sure why. If there is a proper way to fix that I am completely open :)

@@ -50,11 +51,17 @@ export class ExternalParserBase implements IExternalParser {
private getObjdumpStarterScriptContent(filters: ParseFiltersAndOutputOptions) {
const parserArgs = this.getParserArguments(filters, true);

let winePrefix = "";
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When the objdump is an exe it would not work. I'm not sure if this is the best way to find out if the objdump is an exe, please let me know if there is a better way.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Winedebug things are probably best to leave to CE itself, but there probably isn't a way to set WINEDEBUG at the moment (although it's slightly insane wine requires this to run this, but that's a different can of worms probably)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should also probably check if this is running on linux as well.

@@ -80,7 +80,7 @@ export function maskRootdir(filepath: string): string {
.replace(/^\/app\//, '');
} else {
const re = getRegexForTempdir();
return filepath.replace(re, '/app/').replace(/^\/app\//, '');
return filepath.replace(/\\/, '/').replace(re, '/app/').replace(/^\/app\//, '');
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When using an objdump that is an exe it would return a path with \. This fixes that.

Copy link
Contributor

@partouf partouf May 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this work with paths on linux that have spaces? (cmdline they are sometimes written as \ and it's a bit of strange escape exception. I guess it would be ok until users actually passed \ and it might be ok to error on that)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't check with spaces. The wine clang objdump would send a path like /something/something\main.cpp

@@ -80,7 +80,7 @@
.replace(/^\/app\//, '');
} else {
const re = getRegexForTempdir();
return filepath.replace(re, '/app/').replace(/^\/app\//, '');
return filepath.replace(/\\/, '/').replace(re, '/app/').replace(/^\/app\//, '');

Check failure

Code scanning / CodeQL

Incomplete string escaping or encoding High

This replaces only the first occurrence of /\/.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this error worth heeding here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not a regex expert so I'm going with a yes. Is this the proper fix to handle the case above?

@partouf partouf added the waiting Waiting for something label May 29, 2024
@partouf partouf self-assigned this May 29, 2024
@partouf partouf marked this pull request as draft May 29, 2024 16:16
@partouf
Copy link
Contributor

partouf commented May 29, 2024

It will be a while until I'll be coming back to this PR, sorry for the delay

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
waiting Waiting for something
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants