-
Notifications
You must be signed in to change notification settings - Fork 11
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
Try to (re)generate assembly sources #22
Comments
Unfortunately, it's all usually not that easy. This might work for simplest cases, but for most real-world projects this won't work, as the compiler needs to know lots of compilation flags. So, my opinion on this, is that asm should be generated for the whole project by modification of CFLAGS (e.g. by addition of |
@dseight can you reconsider? I think there's a lot more potential "casual" uses/users of this tool. Setting up this compilation stuff in a Makefile and then having to open a terminal, I don't want to compile complex real-world projects, I just want to open a C file and see what "hello world" or simple functions compile into, out of curiosity. I don't want to set up Makefiles and create temporary .S files. When I go to https://godbolt.org/ everything is right there, I just write C code and see the assembly, I don't have to know anything about compilers or their flags or configure stuff, it just lets me type text and shows me a result. This extension should do the same. There's only 3 operating systems and 3 C compilers, on Linux you need to check for gcc then clang, on macOS for clang then gcc, on Windows for MSVC then gcc then clang and then const child_process = require("child_process");
let compilerPath = findCompiler() || 'cc';
const result = child_process.spawnSync(compilerPath, ["-g", "-x", "c", "-", "-o", "/dev/stdout", "-S", "-fno-verbose-asm"], { input: vscode.window.activeTextEditor.document.getText() }).stdout; Next, you could implement support for VS Code's already built in compilation settings. In order to get proper syntax highlighting of C code you usually have to configure .vscode/c_cpp_properties.json which should contain all the information the extension should need to build my project. If I'm able to get CodeLLDB to compile and launch my project and then debug assembly matched up to a specific line of C code, it doesn't make sense that I would then have to do a completely separate configuration step for this extension. |
And this is what godbolt.org is here for! Seriously, Compiler Explorer is a perfect match to do this very thing. You can even run your local instance of it if you wish (and if you must keep your code locally for some reason). This extension, on the other hand, was made for a completely different purpose: to see what your big project will compile into, and how things like So no, this is not something that I'll reconsider in the near future. |
It would be cool if the extension auto-generated the assembly sources. What I have to run is
gcc -g -o src/some_source.S -S src/some_source.c -masm=intel
which could be automated by just grabbing the path of the active text editor and adding it to a command template. Configuration could be extended to also allow for the asm flavour, but that's for a different issue.
The text was updated successfully, but these errors were encountered: