diff --git a/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/BUCK b/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/BUCK index 7ea630148b4..693f6f967a5 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/BUCK @@ -11,8 +11,8 @@ rn_xplat_cxx_library( ], prefix = "react/fabric", ), - compiler_flags_enable_exceptions = True, - compiler_flags_enable_rtti = True, # dynamic_cast used within Binding.cpp + compiler_flags_enable_exceptions = False, + compiler_flags_enable_rtti = False, # for YogaLayoutableShadowNode? fbandroid_allow_jni_merging = True, labels = ["supermodule:xplat/default/public.react_native.infra"], platforms = ANDROID, diff --git a/ReactCommon/react/config/BUCK b/ReactCommon/react/config/BUCK index 3fec8b7c1d5..1d81785820c 100644 --- a/ReactCommon/react/config/BUCK +++ b/ReactCommon/react/config/BUCK @@ -18,6 +18,8 @@ rn_xplat_cxx_library( ], prefix = "react/config", ), + compiler_flags_enable_exceptions = True, + compiler_flags_enable_rtti = True, # for ReactNativeConfig fbobjc_compiler_flags = APPLE_COMPILER_FLAGS, fbobjc_preprocessor_flags = get_preprocessor_flags_for_build_mode() + get_apple_inspector_flags(), force_static = True, diff --git a/ReactCommon/react/renderer/components/view/BUCK b/ReactCommon/react/renderer/components/view/BUCK index d78b21f2cf8..b82e163974f 100644 --- a/ReactCommon/react/renderer/components/view/BUCK +++ b/ReactCommon/react/renderer/components/view/BUCK @@ -35,6 +35,8 @@ rn_xplat_cxx_library( ], prefix = "react/renderer/components/view", ), + compiler_flags_enable_exceptions = False, + compiler_flags_enable_rtti = False, # YogaLayoutableShadowNode fbobjc_compiler_flags = APPLE_COMPILER_FLAGS, fbobjc_preprocessor_flags = get_preprocessor_flags_for_build_mode() + get_apple_inspector_flags(), force_static = True, diff --git a/ReactCommon/react/renderer/core/BUCK b/ReactCommon/react/renderer/core/BUCK index feb8f6569be..d4d9420c193 100644 --- a/ReactCommon/react/renderer/core/BUCK +++ b/ReactCommon/react/renderer/core/BUCK @@ -32,8 +32,8 @@ rn_xplat_cxx_library( ], prefix = "react/renderer/core", ), - compiler_flags_enable_exceptions = True, - compiler_flags_enable_rtti = True, # Needed for DebugStringConvertible - need to find a non-RTTI way to do this / enable RTTI for debug builds only + compiler_flags_enable_exceptions = False, + compiler_flags_enable_rtti = False, # Needed for DebugStringConvertible - need to find a non-RTTI way to do this / enable RTTI for debug builds only. Also EventBeat/AsyncEventBeat fbobjc_compiler_flags = APPLE_COMPILER_FLAGS, fbobjc_preprocessor_flags = get_preprocessor_flags_for_build_mode() + get_apple_inspector_flags(), force_static = True, diff --git a/ReactCommon/react/renderer/core/LayoutableShadowNode.cpp b/ReactCommon/react/renderer/core/LayoutableShadowNode.cpp index a1ad4dda15f..3e8a531306a 100644 --- a/ReactCommon/react/renderer/core/LayoutableShadowNode.cpp +++ b/ReactCommon/react/renderer/core/LayoutableShadowNode.cpp @@ -17,6 +17,19 @@ namespace facebook { namespace react { +LayoutableShadowNode::LayoutableShadowNode( + ShadowNodeFragment const &fragment, + ShadowNodeFamily::Shared const &family, + ShadowNodeTraits traits) + : ShadowNode(fragment, family, traits), layoutMetrics_({}) {} + +LayoutableShadowNode::LayoutableShadowNode( + ShadowNode const &sourceShadowNode, + ShadowNodeFragment const &fragment) + : ShadowNode(sourceShadowNode, fragment), + layoutMetrics_(static_cast(sourceShadowNode) + .layoutMetrics_) {} + LayoutMetrics LayoutableShadowNode::computeRelativeLayoutMetrics( ShadowNodeFamily const &descendantNodeFamily, LayoutableShadowNode const &ancestorNode, @@ -118,19 +131,6 @@ LayoutMetrics LayoutableShadowNode::computeRelativeLayoutMetrics( return layoutMetrics; } -LayoutableShadowNode::LayoutableShadowNode( - ShadowNodeFragment const &fragment, - ShadowNodeFamily::Shared const &family, - ShadowNodeTraits traits) - : ShadowNode(fragment, family, traits), layoutMetrics_({}) {} - -LayoutableShadowNode::LayoutableShadowNode( - ShadowNode const &sourceShadowNode, - ShadowNodeFragment const &fragment) - : ShadowNode(sourceShadowNode, fragment), - layoutMetrics_(static_cast(sourceShadowNode) - .layoutMetrics_) {} - ShadowNodeTraits LayoutableShadowNode::BaseTraits() { auto traits = ShadowNodeTraits{}; traits.set(ShadowNodeTraits::Trait::LayoutableKind); @@ -202,16 +202,6 @@ Float LayoutableShadowNode::lastBaseline(Size size) const { return 0; } -void LayoutableShadowNode::layoutTree( - LayoutContext layoutContext, - LayoutConstraints layoutConstraints) { - // Default implementation does nothing. -} - -void LayoutableShadowNode::layout(LayoutContext layoutContext) { - // Default implementation does nothing. -} - ShadowNode::Shared LayoutableShadowNode::findNodeAtPoint( ShadowNode::Shared node, Point point) { diff --git a/ReactCommon/react/renderer/core/LayoutableShadowNode.h b/ReactCommon/react/renderer/core/LayoutableShadowNode.h index b816b54a2cf..0844a1c563c 100644 --- a/ReactCommon/react/renderer/core/LayoutableShadowNode.h +++ b/ReactCommon/react/renderer/core/LayoutableShadowNode.h @@ -70,7 +70,7 @@ class LayoutableShadowNode : public ShadowNode { */ virtual void layoutTree( LayoutContext layoutContext, - LayoutConstraints layoutConstraints); + LayoutConstraints layoutConstraints)=0; /* * Measures the node (and node content, probably recursively) with @@ -101,7 +101,7 @@ class LayoutableShadowNode : public ShadowNode { * - Calculate and assign `LayoutMetrics` for the children; * - Call itself recursively on every child if needed. */ - virtual void layout(LayoutContext layoutContext); + virtual void layout(LayoutContext layoutContext)=0; /* * Returns layout metrics computed during previous layout pass. diff --git a/ReactCommon/react/renderer/debug/BUCK b/ReactCommon/react/renderer/debug/BUCK index e4b2ee23035..73bed3edf81 100644 --- a/ReactCommon/react/renderer/debug/BUCK +++ b/ReactCommon/react/renderer/debug/BUCK @@ -31,6 +31,8 @@ rn_xplat_cxx_library( ], prefix = "react/renderer/debug", ), + compiler_flags_enable_exceptions = True, + compiler_flags_enable_rtti = True, # DebugStringConvertible fbobjc_compiler_flags = APPLE_COMPILER_FLAGS, fbobjc_preprocessor_flags = get_preprocessor_flags_for_build_mode() + get_apple_inspector_flags(), force_static = True, diff --git a/tools/build_defs/oss/rn_defs.bzl b/tools/build_defs/oss/rn_defs.bzl index 45a732449da..ea1cfb6e505 100644 --- a/tools/build_defs/oss/rn_defs.bzl +++ b/tools/build_defs/oss/rn_defs.bzl @@ -80,7 +80,7 @@ def get_react_native_preprocessor_flags(): return [] # Building is not supported in OSS right now -def rn_xplat_cxx_library(name, compiler_flags_enable_exceptions = True, compiler_flags_enable_rtti = True, **kwargs): +def rn_xplat_cxx_library(name, compiler_flags_enable_exceptions = False, compiler_flags_enable_rtti = False, **kwargs): visibility = kwargs.get("visibility", []) kwargs = { k: v @@ -97,17 +97,31 @@ def rn_xplat_cxx_library(name, compiler_flags_enable_exceptions = True, compiler # or being overridden in compiler_flags, it's very likely that the flag is set # app-wide or that we're otherwise in some special mode. kwargs["compiler_flags"] = kwargs.get("compiler_flags", []) + kwargs["fbobjc_compiler_flags"] = kwargs.get("fbobjc_compiler_flags", []) + kwargs["fbandroid_compiler_flags"] = kwargs.get("fbandroid_compiler_flags", []) + kwargs["windows_compiler_flags"] = kwargs.get("windows_compiler_flags", []) kwargs["compiler_flags"] = ["-std=c++17"] + kwargs["compiler_flags"] kwargs["compiler_flags"] = ["-Wall"] + kwargs["compiler_flags"] kwargs["compiler_flags"] = ["-Werror"] + kwargs["compiler_flags"] + + # RTTI and exceptions allowed for ObjC/iOS, macos, Windows unconditionally for now + kwargs["fbobjc_compiler_flags"] = ["-fexceptions"] + kwargs["fbobjc_compiler_flags"] + kwargs["windows_compiler_flags"] = ["-fno-exceptions"] + kwargs["windows_compiler_flags"] + kwargs["fbobjc_compiler_flags"] = ["-frtti"] + kwargs["fbobjc_compiler_flags"] + kwargs["windows_compiler_flags"] = ["-frtti"] + kwargs["windows_compiler_flags"] + + # For now, we allow turning off RTTI and exceptions for android builds only if compiler_flags_enable_exceptions: - kwargs["compiler_flags"] = ["-fexceptions"] + kwargs["compiler_flags"] + kwargs["fbandroid_compiler_flags"] = ["-fexceptions"] + kwargs["fbandroid_compiler_flags"] else: - kwargs["compiler_flags"] = ["-fno-exceptions"] + kwargs["compiler_flags"] + # TODO: fbjni currently DOES NOT WORK with -fno-exceptions, which breaks MOST RN Android modules + kwargs["fbandroid_compiler_flags"] = ["-fexceptions"] + kwargs["fbandroid_compiler_flags"] + #kwargs["fbandroid_compiler_flags"] = ["-fno-exceptions"] + kwargs["fbandroid_compiler_flags"] + if compiler_flags_enable_rtti: - kwargs["compiler_flags"] = ["-frtti"] + kwargs["compiler_flags"] + kwargs["fbandroid_compiler_flags"] = ["-frtti"] + kwargs["fbandroid_compiler_flags"] else: - kwargs["compiler_flags"] = ["-fno-rtti"] + kwargs["compiler_flags"] + kwargs["fbandroid_compiler_flags"] = ["-fno-rtti"] + kwargs["fbandroid_compiler_flags"] native.cxx_library( name = name,