Top level MakeInclude(generic rules):
Build CPP files......
$(CXX) $(INCLUDES) $(CXXOPTS) -c $< -o $@
Build dependencies for cpp files
DEP = $(CXX) -xM1
-mkdir -p $(@D)
$(DEP) $(INCLUDES) $(CXXOPTS) $< \
| sed "s/\($*\)\.o[
:]*/$(BUILD_TYPE)\/\1.o $(BUILD_TYPE)\/$(@F): /g" > $@
@echo " "
Optimization level is set to –O4 with $(CXXOPTS).
Top level MakeInclude is included in makefiles of all modules.
I have around 20 source files in one of the modules. Of which, a certain 1.cpp source file is taking 2hrs to compile with 5.12 CC compiler. Probably a bug with the compiler.
SOURCES = 1.cpp\
OBJECTS = $(SOURCES:%.cpp=$(BUILD_TYPE)/%.o)
LIB_NAME_STEM = <libname>
LIB_NAME = $(BUILDHOME)/lib/lib$(LIB_NAME_STEM).a
As workaround, I set –O2 optimization level for this module, however, I am seeing a performance degradation of the process by over 10mins (normally runs for 130 mins). I wish to override –O4 level by –O2 only
for this single file alone. Is this possible? If so, please suggest the rules?
Write a rule for that one file. Example, assuming the file is foo.cpp
$(CXX) $(INCLUDES) $(CXXOPTS) -O2 -c $< -o $@
The -O options follow the rule "right-most wins", so you can copy the original rule adding -O2 after $(CXXOPTS) to cancel the effect of -O4
$(OBJECTS_1): CxxFLAGS := -O2
replaces CxxFLAGS with -O2, dropping any other options.
I think you want
$(OBJECTS_1): CxxFLAGS += -O2
which appends -O2 to the end of CxxFLAGS. The -O2 overrides the -O4 since it comes later on the command line.
BTW, this syntax works with gnu make, but not with Unix make. The Unix version of the line would be
$(OBJECTS_1):= CxxFLAGS += -O2
This syntax difference is one of the incompatibilities between gnu make and Unix make.