I have a makefile that compiles C++ files with a rule rather like this:
$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(FILE) $(DEFINE) $(INCLUDE) $(USER_CXXFLAGS)" For a particular configuration of the build system, $(CXXFLAGS) includes the value -O2. But, I can add my own flags to $(USER_CXXFLAGS), and for easier debugging want to add -O0. The end result of this is that when compilation is done, the compiler command line will include multiple conflicting instructions about how to optimize.
Which one does it use? I suspect it's reasonable to assume that the last specified option takes precedence, but given that position matters for some G++ options I don't want to make that assumption. Is this behavior documented somewhere? I read the man pages but was unable to find any specification about repeated options in general.
-std=c99vs-std=gnu11, so I would expect the same to apply to other options such as-O.-O0option has taken effect over the previous-O2but I'll still welcome anyone who quotes whatever deeply buried documentation states that this is true in all cases.