3 ms·
especially when confronted with a soup of C flags and declarations, and still not being entirely sure what the C compiler is going to emit
by hello_computer 2y ago
especially when confronted with a soup of C flags and declarations, and still not being entirely sure what the C compiler is going to emit
- kccqzy 2y agoHow is that an issue? You inspect the generated assembler. Godbolt is the industry standard tool for that, but of course just use objdump on the command line if a browser UI isn't your fancy. Mixing C is helpful because most code doesn't need to be written in raw assembly.
- deleted 2y ago[deleted]
- hello_computer 2y agokeeping assembly in asm files, c in c files, compiled by their respective compilers, then linked, has fewer footguns than inline asm
- kccqzy 2y agoYeah but then you have to maintain function interfaces between them in order to link them. The case in this article is for inserting one single asm instruction in an otherwise C codebase.
- hello_computer 2y agoplatform ABI is usually better and more clearly defined than whatever GCC & Clang feel like doing to inline ASM across versions and optimization levels
- hello_computer 2y agoand inspecting the output is obviously easy. the hard part is figuring out which flags, pragmas & directives are required to get gcc to emit what you wanted it to emit when it doesn’t.
- Joker_vD 2y agoYou also need to re-inspect it at every toolchain change/upgrade. In my experience, most programmers don't, and then we end up spending two day chasing some impossible-to-happen bug which has happened nonetheless because new Clang version had a regression in some obscure and rarely exercised part of its codegen.
- kccqzy 2y agoNo. You have a unit test to inspect it, if your other unit tests cannot cover this codegen bug. Asking programmers to re-inspect by hand is like asking programmers to run all tests manually after each commit. Of course most programmers don't.