Allow disabling RTTI/exceptions for android builds; disable by default on Android
Summary: For fbandroid builds only, disable RTTI and exceptions by default. Changelog: [Internal] Reviewed By: philIip Differential Revision: D31632757 fbshipit-source-id: cfe0e43486df19fcaacc2b5b818b9d00ec2d427f
This commit is contained in:
Родитель
e494e4beb6
Коммит
d291a7efdd
|
@ -11,8 +11,8 @@ rn_xplat_cxx_library(
|
||||||
],
|
],
|
||||||
prefix = "react/fabric",
|
prefix = "react/fabric",
|
||||||
),
|
),
|
||||||
compiler_flags_enable_exceptions = True,
|
compiler_flags_enable_exceptions = False,
|
||||||
compiler_flags_enable_rtti = True, # dynamic_cast used within Binding.cpp
|
compiler_flags_enable_rtti = False, # for YogaLayoutableShadowNode?
|
||||||
fbandroid_allow_jni_merging = True,
|
fbandroid_allow_jni_merging = True,
|
||||||
labels = ["supermodule:xplat/default/public.react_native.infra"],
|
labels = ["supermodule:xplat/default/public.react_native.infra"],
|
||||||
platforms = ANDROID,
|
platforms = ANDROID,
|
||||||
|
|
|
@ -18,6 +18,8 @@ rn_xplat_cxx_library(
|
||||||
],
|
],
|
||||||
prefix = "react/config",
|
prefix = "react/config",
|
||||||
),
|
),
|
||||||
|
compiler_flags_enable_exceptions = True,
|
||||||
|
compiler_flags_enable_rtti = True, # for ReactNativeConfig
|
||||||
fbobjc_compiler_flags = APPLE_COMPILER_FLAGS,
|
fbobjc_compiler_flags = APPLE_COMPILER_FLAGS,
|
||||||
fbobjc_preprocessor_flags = get_preprocessor_flags_for_build_mode() + get_apple_inspector_flags(),
|
fbobjc_preprocessor_flags = get_preprocessor_flags_for_build_mode() + get_apple_inspector_flags(),
|
||||||
force_static = True,
|
force_static = True,
|
||||||
|
|
|
@ -35,6 +35,8 @@ rn_xplat_cxx_library(
|
||||||
],
|
],
|
||||||
prefix = "react/renderer/components/view",
|
prefix = "react/renderer/components/view",
|
||||||
),
|
),
|
||||||
|
compiler_flags_enable_exceptions = False,
|
||||||
|
compiler_flags_enable_rtti = False, # YogaLayoutableShadowNode
|
||||||
fbobjc_compiler_flags = APPLE_COMPILER_FLAGS,
|
fbobjc_compiler_flags = APPLE_COMPILER_FLAGS,
|
||||||
fbobjc_preprocessor_flags = get_preprocessor_flags_for_build_mode() + get_apple_inspector_flags(),
|
fbobjc_preprocessor_flags = get_preprocessor_flags_for_build_mode() + get_apple_inspector_flags(),
|
||||||
force_static = True,
|
force_static = True,
|
||||||
|
|
|
@ -32,8 +32,8 @@ rn_xplat_cxx_library(
|
||||||
],
|
],
|
||||||
prefix = "react/renderer/core",
|
prefix = "react/renderer/core",
|
||||||
),
|
),
|
||||||
compiler_flags_enable_exceptions = True,
|
compiler_flags_enable_exceptions = False,
|
||||||
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_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_compiler_flags = APPLE_COMPILER_FLAGS,
|
||||||
fbobjc_preprocessor_flags = get_preprocessor_flags_for_build_mode() + get_apple_inspector_flags(),
|
fbobjc_preprocessor_flags = get_preprocessor_flags_for_build_mode() + get_apple_inspector_flags(),
|
||||||
force_static = True,
|
force_static = True,
|
||||||
|
|
|
@ -17,6 +17,19 @@
|
||||||
namespace facebook {
|
namespace facebook {
|
||||||
namespace react {
|
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<LayoutableShadowNode const &>(sourceShadowNode)
|
||||||
|
.layoutMetrics_) {}
|
||||||
|
|
||||||
LayoutMetrics LayoutableShadowNode::computeRelativeLayoutMetrics(
|
LayoutMetrics LayoutableShadowNode::computeRelativeLayoutMetrics(
|
||||||
ShadowNodeFamily const &descendantNodeFamily,
|
ShadowNodeFamily const &descendantNodeFamily,
|
||||||
LayoutableShadowNode const &ancestorNode,
|
LayoutableShadowNode const &ancestorNode,
|
||||||
|
@ -118,19 +131,6 @@ LayoutMetrics LayoutableShadowNode::computeRelativeLayoutMetrics(
|
||||||
return layoutMetrics;
|
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<LayoutableShadowNode const &>(sourceShadowNode)
|
|
||||||
.layoutMetrics_) {}
|
|
||||||
|
|
||||||
ShadowNodeTraits LayoutableShadowNode::BaseTraits() {
|
ShadowNodeTraits LayoutableShadowNode::BaseTraits() {
|
||||||
auto traits = ShadowNodeTraits{};
|
auto traits = ShadowNodeTraits{};
|
||||||
traits.set(ShadowNodeTraits::Trait::LayoutableKind);
|
traits.set(ShadowNodeTraits::Trait::LayoutableKind);
|
||||||
|
@ -202,16 +202,6 @@ Float LayoutableShadowNode::lastBaseline(Size size) const {
|
||||||
return 0;
|
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 LayoutableShadowNode::findNodeAtPoint(
|
||||||
ShadowNode::Shared node,
|
ShadowNode::Shared node,
|
||||||
Point point) {
|
Point point) {
|
||||||
|
|
|
@ -70,7 +70,7 @@ class LayoutableShadowNode : public ShadowNode {
|
||||||
*/
|
*/
|
||||||
virtual void layoutTree(
|
virtual void layoutTree(
|
||||||
LayoutContext layoutContext,
|
LayoutContext layoutContext,
|
||||||
LayoutConstraints layoutConstraints);
|
LayoutConstraints layoutConstraints)=0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Measures the node (and node content, probably recursively) with
|
* Measures the node (and node content, probably recursively) with
|
||||||
|
@ -101,7 +101,7 @@ class LayoutableShadowNode : public ShadowNode {
|
||||||
* - Calculate and assign `LayoutMetrics` for the children;
|
* - Calculate and assign `LayoutMetrics` for the children;
|
||||||
* - Call itself recursively on every child if needed.
|
* - 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.
|
* Returns layout metrics computed during previous layout pass.
|
||||||
|
|
|
@ -31,6 +31,8 @@ rn_xplat_cxx_library(
|
||||||
],
|
],
|
||||||
prefix = "react/renderer/debug",
|
prefix = "react/renderer/debug",
|
||||||
),
|
),
|
||||||
|
compiler_flags_enable_exceptions = True,
|
||||||
|
compiler_flags_enable_rtti = True, # DebugStringConvertible
|
||||||
fbobjc_compiler_flags = APPLE_COMPILER_FLAGS,
|
fbobjc_compiler_flags = APPLE_COMPILER_FLAGS,
|
||||||
fbobjc_preprocessor_flags = get_preprocessor_flags_for_build_mode() + get_apple_inspector_flags(),
|
fbobjc_preprocessor_flags = get_preprocessor_flags_for_build_mode() + get_apple_inspector_flags(),
|
||||||
force_static = True,
|
force_static = True,
|
||||||
|
|
|
@ -80,7 +80,7 @@ def get_react_native_preprocessor_flags():
|
||||||
return []
|
return []
|
||||||
|
|
||||||
# Building is not supported in OSS right now
|
# 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", [])
|
visibility = kwargs.get("visibility", [])
|
||||||
kwargs = {
|
kwargs = {
|
||||||
k: v
|
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
|
# 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.
|
# app-wide or that we're otherwise in some special mode.
|
||||||
kwargs["compiler_flags"] = kwargs.get("compiler_flags", [])
|
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"] = ["-std=c++17"] + kwargs["compiler_flags"]
|
||||||
kwargs["compiler_flags"] = ["-Wall"] + kwargs["compiler_flags"]
|
kwargs["compiler_flags"] = ["-Wall"] + kwargs["compiler_flags"]
|
||||||
kwargs["compiler_flags"] = ["-Werror"] + 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:
|
if compiler_flags_enable_exceptions:
|
||||||
kwargs["compiler_flags"] = ["-fexceptions"] + kwargs["compiler_flags"]
|
kwargs["fbandroid_compiler_flags"] = ["-fexceptions"] + kwargs["fbandroid_compiler_flags"]
|
||||||
else:
|
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:
|
if compiler_flags_enable_rtti:
|
||||||
kwargs["compiler_flags"] = ["-frtti"] + kwargs["compiler_flags"]
|
kwargs["fbandroid_compiler_flags"] = ["-frtti"] + kwargs["fbandroid_compiler_flags"]
|
||||||
else:
|
else:
|
||||||
kwargs["compiler_flags"] = ["-fno-rtti"] + kwargs["compiler_flags"]
|
kwargs["fbandroid_compiler_flags"] = ["-fno-rtti"] + kwargs["fbandroid_compiler_flags"]
|
||||||
|
|
||||||
native.cxx_library(
|
native.cxx_library(
|
||||||
name = name,
|
name = name,
|
||||||
|
|
Загрузка…
Ссылка в новой задаче