does the C language first compile to assembler and then to binary?
>>108227332Not since 1998, grandpa zoomer.
>>108227338what about Python?does it first compile to C++ and then to binary?
>>108227343It does, but Python is a subhuman nocoder language anyway.
.
>>108227332You should read up these terms:languagecompilerassemblermachine codelinker
>>108227533will this bring me closer to job prospects
>>108227820yeah they ask about it in the McDonald's job interview
>>108227332the "language" doesn't do things in that way, it is done to the language.but yes, compilers first compile to assembly, then assemble said to object files and lastly link those object files into a finished executable.you can cut those steps short using gcc or clang using-E, to stop just after preprocessing (so all the #include and #define)-S, to stop just after compiling-c, to stop just after assembling
>>108229478don't forget intermediate representation (GIMPLE or LLVM IR).
>>108227343It first compiles to special Python bytecode and then it runs the bytecode using the interpreter program.As of very recently there's also an experimental feature that compiles it to LLVM IR which is then compiled to binary/machine code.
>>108230437sure. but I think that'd be too much for someone asking whether there's an assembly intermediate.what's your favourite IR? pure AST, sea of nodes, SSA?in my homebrew compiler I've landed on something similar to sea of nodes, but not sure. I collect all subsequent operations into a single block and simplify that as much as possible.I haven't got around to doing proper reordering even across basic blocks, but some day I might.
>>108229478>compilers first compile to assemblyusually not
>>108230702>SSA?SSA is nice, as it makes many basic blocks be effectively simple pure functions with very easy to reason about properties.But the mapping of the input program to SSA can be quite complex. C is not the worst for that. (Some compiler versions don't scale well with the number of BBs.)
>>108227332C compiles into machine code which generates binary.
>>108230881gcc does, not sure how clang does it. does it go from IR to object files directly?>>108230933>makes many basic blocks be effectively simple pure functionshuh, yeah makes sense. for me it's that I've never deliberately designed my toy IR, it just grew on its own every time I needed to represent some new language structure.
>>108227820>jobshut up waggie, stop worshipping mammon
>>108231295>gcc doesno it doesn't retard. i explicitly mentioned GIMPLE above so retards like you could notice.were you one of the retards in one of the rust threads a couple of days ago by any chance?
The binary of your machine code is assembled by your compiled linker
>>108227332Why would you ask a question that can easily be searched on a search engine?No, the C compiler does not compile down to ASM without specifically flagging the compiler to do so. It links and and assembles the code using the compilers built in code generation logic. This is also compiler specific. A GCC binary may be different than an LLVM C-LANG binary for example.
>>108231913alright you just don't know what you're talking about, good to know:]>were you one of the retards in one of the rust threads a couple of days ago by any chance?no
>>108232298>>108231913it depends on the implementation. gcc does convert all front ends to assembly before running the assembler. it is usually just hidden because most people do not care what the assembly looks like or is. most of the pipeline is not written to a file. if you do `gcc file.c file2.c` it just spits out the binary and no object files, but it still creates the object files.
>>108227338>>108227332save assembler listing is optional
>>108232298search engines stopped working in 2018, stop pretending we live in a world where google cache still exists
>>108231913>>108230881Did you really think we wouldn't notice?>>108232657>>108231295This is correct.
>>108232657>>108232931>what is -fdump-tree-* :S>what is libgccjit :S
>>108233087>what is as file.s
>>108227332It depends on the specific compiler. Some compile straight to binary while others have an intermediate stage where it compiles to bytecode or assembly that's then compiled to binary. Cross-platform compilers usually compile to a intermediate stage first.
>>108227332Even visual c has an option to generate .asm … but it now says (for the last 10 years or so) that the asm is for informational purposes only and not guaranteed to assemble/compile.
>>108233117oh, i understand now. you're a jeet.have a nice day.
Modularity. retard.People like having an inbetween assembler output.
>>108227332Most compilers don't actually do this but it seems to stick around in textbook diagrams and such.As misconceptions go, it's a fairly harmless one.
>>108234405gcc does it, I know thatI'd be surprised if clang doesn't