mapleFU commented on code in PR #15022:
URL: https://github.com/apache/arrow/pull/15022#discussion_r1104026087


##########
cpp/cmake_modules/SetupCxxFlags.cmake:
##########
@@ -604,76 +604,42 @@ endif()
 # For all builds:
 # For CMAKE_BUILD_TYPE=Debug
 #   -ggdb: Enable gdb debugging
-# For CMAKE_BUILD_TYPE=FastDebug
-#   Same as Debug, except with some optimizations on.
 # For CMAKE_BUILD_TYPE=Release
-#   -O2: Enable all compiler optimizations
+#   -O2 (not -O3): Enable compiler optimizations
 #   Debug symbols are stripped for reduced binary size.
 # For CMAKE_BUILD_TYPE=RelWithDebInfo
 #   Same as Release, except with debug symbols enabled.
 
 if(NOT MSVC)
-  string(REPLACE "-O3" "" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
-  string(REPLACE "-O3" "" CMAKE_CXX_FLAGS_RELWITHDEBINFO
-                 "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}")
-
-  set(RELEASE_FLAGS "-O2 -DNDEBUG")
+  set(C_RELEASE_FLAGS "")
+  if(CMAKE_C_FLAGS_RELEASE MATCHES "-O3")
+    string(APPEND C_RELEASE_FLAGS " -O2")

Review Comment:
   Thanks, the code and comment here is clear. I just want to make clear why we 
we O2, because when compiling I found the argument is "-O3 -NDEBUG -O2", which 
make me confused.
   
   I'll try some benchmark under x86, if I got benefits when enabling O3, I'd 
like to add a flag here.



##########
cpp/cmake_modules/SetupCxxFlags.cmake:
##########
@@ -604,76 +604,42 @@ endif()
 # For all builds:
 # For CMAKE_BUILD_TYPE=Debug
 #   -ggdb: Enable gdb debugging
-# For CMAKE_BUILD_TYPE=FastDebug
-#   Same as Debug, except with some optimizations on.
 # For CMAKE_BUILD_TYPE=Release
-#   -O2: Enable all compiler optimizations
+#   -O2 (not -O3): Enable compiler optimizations
 #   Debug symbols are stripped for reduced binary size.
 # For CMAKE_BUILD_TYPE=RelWithDebInfo
 #   Same as Release, except with debug symbols enabled.
 
 if(NOT MSVC)
-  string(REPLACE "-O3" "" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
-  string(REPLACE "-O3" "" CMAKE_CXX_FLAGS_RELWITHDEBINFO
-                 "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}")
-
-  set(RELEASE_FLAGS "-O2 -DNDEBUG")
+  set(C_RELEASE_FLAGS "")
+  if(CMAKE_C_FLAGS_RELEASE MATCHES "-O3")
+    string(APPEND C_RELEASE_FLAGS " -O2")

Review Comment:
   Thanks, the code and comment here is clear. I just want to make clear why we 
we O2, because when compiling I found the argument is "-O3 -NDEBUG -O2", which 
makes me confused.
   
   I'll try some benchmark under x86, if I got benefits when enabling O3, I'd 
like to add a flag here.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscr...@arrow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to