diff --git a/omrmakefiles/rules.zos.mk b/omrmakefiles/rules.zos.mk index 5f4e566b7fc..44cd5b95ee8 100644 --- a/omrmakefiles/rules.zos.mk +++ b/omrmakefiles/rules.zos.mk @@ -42,12 +42,22 @@ endif ifeq ($(OMR_ENHANCED_WARNINGS),1) endif -# Enable Debugging Symbols +# Enable debugging symbols? ifeq ($(ENABLE_DDR),yes) - GLOBAL_CFLAGS += -Wc,debug - GLOBAL_CXXFLAGS += -Wc,debug -else ifeq ($(OMR_DEBUG),1) -endif + # Optimization is limited when using '-Wc,debug', but *.dbg files are required for DDR. + # Override compile commands to compile twice: once with '-Wc,debug', and a second time + # without that option. + + define COMPILE_C_COMMAND + $(CC) $(CPPFLAGS) $(MODULE_CPPFLAGS) $(GLOBAL_CPPFLAGS) -c $(GLOBAL_CFLAGS) $(MODULE_CFLAGS) $(CFLAGS) -Wc,debug -o $@ $< + $(CC) $(CPPFLAGS) $(MODULE_CPPFLAGS) $(GLOBAL_CPPFLAGS) -c $(GLOBAL_CFLAGS) $(MODULE_CFLAGS) $(CFLAGS) -o $@ $< + endef + + define COMPILE_CXX_COMMAND + $(CXX) $(CPPFLAGS) $(MODULE_CPPFLAGS) $(GLOBAL_CPPFLAGS) -c $(GLOBAL_CXXFLAGS) $(MODULE_CXXFLAGS) $(CXXFLAGS) -Wc,debug -o $@ $< + $(CXX) $(CPPFLAGS) $(MODULE_CPPFLAGS) $(GLOBAL_CPPFLAGS) -c $(GLOBAL_CXXFLAGS) $(MODULE_CXXFLAGS) $(CXXFLAGS) -o $@ $< + endef +endif # ENABLE_DDR # Enable Optimizations ifeq ($(OMR_OPTIMIZE),1)