make manual / 10.2 Catalogue of Built-In Rules / Linking a single object file




x: y.o z.o




when x.c, y.c and z.c all exist will execute:




cc -c x.c -o x.o  # x.c compiles first

cc -c y.c -o y.o

cc -c z.c -o z.o

cc x.o y.o z.o -o x

rm -f x.o

rm -f y.o

rm -f z.o




--- 




Q1: 

The manual states that the x.c compiles first. 

But in my example code uses C++20 modules with gcc 11.2.0 it compiles last.




Q2:

rm -f *.o 

deleting object files doesn't happen in my test with gcc 11.2.0 too.







    ` x : y.o z.o ` # without x.o




or this:




    ` x : y.o z.o x.o ` # with x.o

    `    $(CXX) $(LDFLAGS) $^ $(LDLIBS) -o $@ ` # with 
recipe




The order of compiling is:




g++ -std=c++2a -fmodules-ts -g -c -o y.o c.cpp

g++ -std=c++2a -fmodules-ts -g -c -o z.o b.cpp

g++ -std=c++2a -fmodules-ts -g x.cpp y.o z.o a.o d.o -o x  # x.c compiles 
last

Reply via email to