Merge pull request #14915 from ZhouyihaiDing/backport-php-O2

Backport #14768 to v1.10.x
diff --git a/config.m4 b/config.m4
index b8a8e98..4b5469e 100644
--- a/config.m4
+++ b/config.m4
@@ -11,8 +11,8 @@
 
   LIBS="-lpthread $LIBS"
 
-  CFLAGS="-Wall -Werror -Wno-parentheses-equality -Wno-unused-value -std=c11"
-  CXXFLAGS="-std=c++11 -fno-exceptions -fno-rtti"
+  CFLAGS="-Wall -Werror -Wno-parentheses-equality -Wno-unused-value -std=c11 -g -O2"
+  CXXFLAGS="-std=c++11 -fno-exceptions -fno-rtti -g -O2"
   GRPC_SHARED_LIBADD="-lpthread $GRPC_SHARED_LIBADD"
   PHP_REQUIRE_CXX()
   PHP_ADD_LIBRARY(pthread)
diff --git a/templates/config.m4.template b/templates/config.m4.template
index cd93fbd..c039c53 100644
--- a/templates/config.m4.template
+++ b/templates/config.m4.template
@@ -13,8 +13,8 @@
 
     LIBS="-lpthread $LIBS"
 
-    CFLAGS="-Wall -Werror -Wno-parentheses-equality -Wno-unused-value -std=c11"
-    CXXFLAGS="-std=c++11 -fno-exceptions -fno-rtti"
+    CFLAGS="-Wall -Werror -Wno-parentheses-equality -Wno-unused-value -std=c11 -g -O2"
+    CXXFLAGS="-std=c++11 -fno-exceptions -fno-rtti -g -O2"
     GRPC_SHARED_LIBADD="-lpthread $GRPC_SHARED_LIBADD"
     PHP_REQUIRE_CXX()
     PHP_ADD_LIBRARY(pthread)