Skip to content

Commit

Permalink
Enable trivial ABI for CanvasKit and Bazel build
Browse files Browse the repository at this point in the history
This is a follow-up to http://review.skia.org/633089

This introduces a custom platform constraint which one could
use in a platform definition. This also lets us opt-in to it
in WASM builds (since I believe those don't care about ABI
compatibility).

Change-Id: I68c498d03726e82bd62f84581be14ea12bba3f2d
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/678276
Commit-Queue: Kevin Lubick <[email protected]>
Reviewed-by: Ben Wagner <[email protected]>
Reviewed-by: John Stiles <[email protected]>
  • Loading branch information
kjlubick authored and SkCQ committed Apr 27, 2023
1 parent e72842a commit b33e464
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 0 deletions.
12 changes: 12 additions & 0 deletions bazel/platform/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,15 @@ constraint_value(
constraint_setting = ":skia_hermetic_toolchain",
visibility = ["//visibility:public"],
)

# This constraint allows us to have clang use a "trivial_abi" that saves code size but
# breaks clients that aren't expecting it.
# http://review.skia.org/633089
# https://quuxplusone.github.io/blog/2018/05/02/trivial-abi-101/
constraint_setting(name = "clang_abi_mode")

constraint_value(
name = "trivial_abi",
constraint_setting = ":clang_abi_mode",
visibility = ["//visibility:public"],
)
4 changes: 4 additions & 0 deletions defines.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,10 @@ PLATFORM_DEFINES = select({
"SK_FORCE_AAA",
],
"//conditions:default": [],
}) + select({
"//bazel/platform:trivial_abi": ["SK_TRIVIAL_ABI=[[clang::trivial_abi]]"],
"//bazel/common_config_settings:cpu_wasm": ["SK_TRIVIAL_ABI=[[clang::trivial_abi]]"],
"//conditions:default": [],
})

# Skia's public headers can work with any version of a Vulkan header. When compiling Skia internals,
Expand Down
1 change: 1 addition & 0 deletions modules/canvaskit/compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ echo "Compiling"
--args="is_debug=${IS_DEBUG} \
is_official_build=${IS_OFFICIAL_BUILD} \
is_component_build=false \
is_trivial_abi=true \
werror=true \
target_cpu=\"wasm\" \
\
Expand Down
2 changes: 2 additions & 0 deletions modules/pathkit/compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ echo "Compiling bitcode"
] \
is_debug=false \
is_official_build=true \
is_trivial_abi=true \
is_component_build=false \
werror=true \
target_cpu=\"wasm\" "
Expand All @@ -104,6 +105,7 @@ ${EMCXX} $RELEASE_CONF -std=c++17 \
--pre-js $BASE_DIR/helper.js \
--pre-js $BASE_DIR/chaining.js \
-fno-rtti -fno-exceptions -DEMSCRIPTEN_HAS_UNBOUND_TYPE_NAMES=0 \
"-DSK_TRIVIAL_ABI=[[clang::trivial_abi]]" \
$WASM_CONF \
-sERROR_ON_UNDEFINED_SYMBOLS=1 \
-sEXPORT_NAME="PathKitInit" \
Expand Down

0 comments on commit b33e464

Please sign in to comment.