K
K
kolomiec_artiom2018-07-03 19:19:45
C++ / C#
kolomiec_artiom, 2018-07-03 19:19:45

What are the advantages of compiling in 4 steps rather than 1?

Good evening, dear connoisseurs!
The following question arose:
In the gcc compiler for the C language, you can write several options for commands to get an executable file:
1st way:
gcc -o main.exe main.c
2nd way:

gcc –E main.c > main.i
gcc –S main.i
gcc –c main.s
gcc –o main.exe main.o

And the question arose: what is the advantage of the second method over the first?
There is an assumption that in large projects this allows not to rebuild the project completely, but only its changed part

Answer the question

In order to leave comments, you need to log in

1 answer(s)
1
15432, 2018-07-03
@kolomiec_artiom

gcc is a collection of tools, each doing its own thing. In the first case, everything is automatically redirected to the next one in the chain, in the second, step by step. The ability to fully control the compilation process is useful - maybe I want to look at the assembler listing, or look at the result of the optimizer and understand why the code in these assembly parameters suddenly stopped working, look for compiler bugs .. well, or tritely try different linker parameters without affecting the rest of the compilation steps .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question