From faa85f84ce96986d4097a8df99e8fbc402c6b662 Mon Sep 17 00:00:00 2001 From: Sunbreak Date: Wed, 12 Jul 2023 06:58:41 -0700 Subject: [PATCH] set NDEBUG properly (#38314) Summary: `CMAKE_BUILD_TYPE` is `RelWithDebInfo` while `./gradlew :package:react-native:ReactAndroid:bundleReleaseAar` ## Changelog: [ANDROID] [FIXED] - Fix `CMAKE_BUILD_TYPE` match condition from https://github.com/facebook/react-native/issues/36172 Pull Request resolved: https://github.com/facebook/react-native/pull/38314 Test Plan: ### Release (does contain two `-DNDEBUG`) ``` build ReactCommon/react/renderer/components/view/CMakeFiles/rrc_view.dir/YogaLayoutableShadowNode.cpp.o: CXX_COMPILER__rrc_view_RelWithDebInfo /Volumes/sunbreak-WD/w/Sunbreak/react-native@Sunbreak/packages/react-native/ReactCommon/react/renderer/components/view/YogaLayoutableShadowNode.cpp || cmake_object_order_depends_target_rrc_view DEFINES = -Drrc_view_EXPORTS DEP_FILE = ReactCommon/react/renderer/components/view/CMakeFiles/rrc_view.dir/YogaLayoutableShadowNode.cpp.o.d FLAGS = -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -O2 -g -DNDEBUG -fPIC -Wall -Werror -std=c++17 -fexceptions -frtti -Wpedantic -Wno-gnu-zero-variadic-macro-arguments -DLOG_TAG=\"Fabric\" -DFOLLY_NO_CONFIG=1 -DFOLLY_HAVE_CLOCK_GETTIME=1 -DFOLLY_USE_LIBCPP=1 -DFOLLY_MOBILE=1 -DFOLLY_HAVE_RECVMMSG=1 -DFOLLY_HAVE_PTHREAD=1 -DFOLLY_HAVE_XSI_STRERROR_R=1 -DNDEBUG INCLUDES = -I/Volumes/sunbreak-WD/w/Sunbreak/react-native@Sunbreak/packages/react-native/ReactCommon -I/Volumes/sunbreak-WD/w/Sunbreak/react-native@Sunbreak/packages/react-native/ReactAndroid/build/third-party-ndk/folly/. -I/Volumes/sunbreak-WD/w/Sunbreak/react-native@Sunbreak/packages/react-native/ReactAndroid/build/third-party-ndk/glog/exported -I/Volumes/sunbreak-WD/w/Sunbreak/react-native@Sunbreak/packages/react-native/ReactAndroid/build/third-party-ndk/double-conversion/. -I/Volumes/sunbreak-WD/w/Sunbreak/react-native@Sunbreak/packages/react-native/ReactAndroid/build/third-party-ndk/boost/boost_1_76_0 -I/Volumes/sunbreak-WD/w/Sunbreak/react-native@Sunbreak/packages/react-native/ReactAndroid/build/third-party-ndk/fmt/include -I/Volumes/sunbreak-WD/w/Sunbreak/react-native@Sunbreak/packages/react-native/ReactAndroid/src/main/jni/first-party/fbgloginit/. -I/Volumes/sunbreak-WD/w/Sunbreak/react-native@Sunbreak/packages/react-native/ReactCommon/jsi -I/Volumes/sunbreak-WD/w/Sunbreak/react-native@Sunbreak/packages/react-native/ReactCommon/logger/. -I/Volumes/sunbreak-WD/w/Sunbreak/react-native@Sunbreak/packages/react-native/ReactCommon/react/renderer/graphics/platform/android -I/Volumes/sunbreak-WD/w/Sunbreak/react-native@Sunbreak/packages/react-native/ReactAndroid/src/main/jni/first-party/fb/include -I/Volumes/sunbreak-WD/w/Sunbreak/react-native@Sunbreak/packages/react-native/ReactAndroid/src/main/jni/first-party/yogajni/jni -I/Volumes/sunbreak-WD/w/Sunbreak/react-native@Sunbreak/packages/react-native/ReactCommon/yoga/yoga/.. -isystem /Users/sunbreak/.gradle/caches/transforms-3/a52d8ada161ee9f7b900e2f4d7543a45/transformed/fbjni-0.4.0/prefab/modules/fbjni/include OBJECT_DIR = ReactCommon/react/renderer/components/view/CMakeFiles/rrc_view.dir OBJECT_FILE_DIR = ReactCommon/react/renderer/components/view/CMakeFiles/rrc_view.dir TARGET_COMPILE_PDB = ReactCommon/react/renderer/components/view/CMakeFiles/rrc_view.dir/ TARGET_PDB = /Volumes/sunbreak-WD/w/Sunbreak/react-native@Sunbreak/packages/react-native/ReactAndroid/build/intermediates/cxx/RelWithDebInfo/394f413f/obj/arm64-v8a/librrc_view.pdb ``` Reviewed By: sammy-SC Differential Revision: D47399115 Pulled By: cortinico fbshipit-source-id: 8fc7c32f61d1085e6f357beef91726899e0ed6cf --- .../ReactAndroid/src/main/jni/first-party/fb/CMakeLists.txt | 2 +- packages/react-native/ReactCommon/jsc/CMakeLists.txt | 2 +- packages/react-native/ReactCommon/react/debug/CMakeLists.txt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/react-native/ReactAndroid/src/main/jni/first-party/fb/CMakeLists.txt b/packages/react-native/ReactAndroid/src/main/jni/first-party/fb/CMakeLists.txt index c3e3ecebbbd..16eb9527e1b 100644 --- a/packages/react-native/ReactAndroid/src/main/jni/first-party/fb/CMakeLists.txt +++ b/packages/react-native/ReactAndroid/src/main/jni/first-party/fb/CMakeLists.txt @@ -21,7 +21,7 @@ add_compile_options( -Wno-error=unused-but-set-variable -DHAVE_POSIX_CLOCKS ) -if(${CMAKE_BUILD_TYPE} MATCHES Release) +if(NOT ${CMAKE_BUILD_TYPE} MATCHES Debug) add_compile_options(-DNDEBUG) endif() diff --git a/packages/react-native/ReactCommon/jsc/CMakeLists.txt b/packages/react-native/ReactCommon/jsc/CMakeLists.txt index 5db3ff62a01..c5c17fb4048 100644 --- a/packages/react-native/ReactCommon/jsc/CMakeLists.txt +++ b/packages/react-native/ReactCommon/jsc/CMakeLists.txt @@ -34,6 +34,6 @@ target_link_libraries(jscruntime # Android has this enabled by default, but the flag is still needed for iOS. target_compile_options(jscruntime PRIVATE -DRN_FABRIC_ENABLED) -if(${CMAKE_BUILD_TYPE} MATCHES Release) +if(NOT ${CMAKE_BUILD_TYPE} MATCHES Debug) target_compile_options(jscruntime PRIVATE -DNDEBUG) endif() diff --git a/packages/react-native/ReactCommon/react/debug/CMakeLists.txt b/packages/react-native/ReactCommon/react/debug/CMakeLists.txt index ccfc69872e7..cb3497e77a1 100644 --- a/packages/react-native/ReactCommon/react/debug/CMakeLists.txt +++ b/packages/react-native/ReactCommon/react/debug/CMakeLists.txt @@ -23,6 +23,6 @@ target_include_directories(react_debug PUBLIC ${REACT_COMMON_DIR}) target_link_libraries(react_debug log folly_runtime) -if(${CMAKE_BUILD_TYPE} MATCHES Release) +if(NOT ${CMAKE_BUILD_TYPE} MATCHES Debug) target_compile_options(react_debug PUBLIC -DNDEBUG) endif()