From 597c33a8c0e2bf4e1e5cc4cd091b84eb70a68230 Mon Sep 17 00:00:00 2001 From: Chris Dalton Date: Fri, 18 Sep 2020 13:27:35 -0600 Subject: [PATCH] Fix CanvasKit warnings compiling on Mac with emsdk 2.0.0 Change-Id: Idcb37644c6c657ce66390ae12d9a55d68abab6cf Reviewed-on: https://skia-review.googlesource.com/c/skia/+/317642 Commit-Queue: Chris Dalton Reviewed-by: Kevin Lubick --- include/gpu/GrDriverBugWorkarounds.h | 1 + modules/canvaskit/compile.sh | 14 +++++++++++++- modules/skottie/src/Layer.h | 1 + samplecode/SampleTextureUpload.cpp | 2 -- src/sksl/ir/SkSLSymbol.h | 3 +++ src/utils/SkUTF.cpp | 3 ++- 6 files changed, 20 insertions(+), 4 deletions(-) diff --git a/include/gpu/GrDriverBugWorkarounds.h b/include/gpu/GrDriverBugWorkarounds.h index 3f370346fd..c57efc6016 100644 --- a/include/gpu/GrDriverBugWorkarounds.h +++ b/include/gpu/GrDriverBugWorkarounds.h @@ -34,6 +34,7 @@ enum GrDriverBugWorkaroundType { class SK_API GrDriverBugWorkarounds { public: GrDriverBugWorkarounds(); + GrDriverBugWorkarounds(const GrDriverBugWorkarounds&) = default; explicit GrDriverBugWorkarounds(const std::vector& workarounds); GrDriverBugWorkarounds& operator=(const GrDriverBugWorkarounds&) = default; diff --git a/modules/canvaskit/compile.sh b/modules/canvaskit/compile.sh index 7aa108f064..4b3fa3c6ff 100755 --- a/modules/canvaskit/compile.sh +++ b/modules/canvaskit/compile.sh @@ -262,6 +262,10 @@ set -e echo "Compiling bitcode" +# With emsdk 2.0.0 we get a false positive on tautological-value-range-compare. This appears to be +# fixed in the emsdk 2.0.4 toolchain. Disable the warning while we maintain support for 2.0.0. +EXTRA_CFLAGS+="\"-Wno-tautological-value-range-compare\"" + # Inspired by https://github.com/Zubnix/skia-wasm-port/blob/master/build_bindings.sh ./bin/gn gen ${BUILD_DIR} \ --args="cc=\"${EMCC}\" \ @@ -328,6 +332,14 @@ export EMCC_CLOSURE_ARGS="--externs $BASE_DIR/externs.js " echo "Generating final wasm" +# Disable '-s STRICT=1' outside of Linux until +# https://github.com/emscripten-core/emscripten/issues/12118 is resovled. +STRICTNESS="-s STRICT=1" +if [[ `uname` != "Linux" ]]; then + echo "Disabling '-s STRICT=1'. See: https://github.com/emscripten-core/emscripten/issues/12118" + STRICTNESS="" +fi + # Emscripten prefers that the .a files go last in order, otherwise, it # may drop symbols that it incorrectly thinks aren't used. One day, # Emscripten will use LLD, which may relax this requirement. @@ -380,8 +392,8 @@ EMCC_DEBUG=1 ${EMCXX} \ -s FILESYSTEM=0 \ -s MODULARIZE=1 \ -s NO_EXIT_RUNTIME=1 \ - -s STRICT=1 \ -s INITIAL_MEMORY=128MB \ -s WARN_UNALIGNED=1 \ -s WASM=1 \ + $STRICTNESS \ -o $BUILD_DIR/canvaskit.js diff --git a/modules/skottie/src/Layer.h b/modules/skottie/src/Layer.h index 04dbd01e22..9565a59345 100644 --- a/modules/skottie/src/Layer.h +++ b/modules/skottie/src/Layer.h @@ -18,6 +18,7 @@ class CompositionBuilder; class LayerBuilder final { public: LayerBuilder(const skjson::ObjectValue& jlayer, const SkSize& comp_size); + LayerBuilder(const LayerBuilder&) = default; ~LayerBuilder(); int index() const { return fIndex; } diff --git a/samplecode/SampleTextureUpload.cpp b/samplecode/SampleTextureUpload.cpp index 420388cbe1..39f82d8cb3 100644 --- a/samplecode/SampleTextureUpload.cpp +++ b/samplecode/SampleTextureUpload.cpp @@ -150,8 +150,6 @@ class TextureUploadSample : public Sample { } }; -const int TextureUploadSample::kMinTileSize; -const int TextureUploadSample::kMaxTileSize; DEF_SAMPLE( return new TextureUploadSample(); ) diff --git a/src/sksl/ir/SkSLSymbol.h b/src/sksl/ir/SkSLSymbol.h index 1decc00abf..5625ba1e15 100644 --- a/src/sksl/ir/SkSLSymbol.h +++ b/src/sksl/ir/SkSLSymbol.h @@ -35,6 +35,9 @@ struct Symbol : public IRNode { SkASSERT(kind >= Kind::kFirst && kind <= Kind::kLast); } + Symbol(const Symbol&) = default; + Symbol& operator=(const Symbol&) = default; + ~Symbol() override {} Kind kind() const { diff --git a/src/utils/SkUTF.cpp b/src/utils/SkUTF.cpp index 500b1ec024..a26cf5b0b4 100644 --- a/src/utils/SkUTF.cpp +++ b/src/utils/SkUTF.cpp @@ -1,6 +1,7 @@ // Copyright 2018 Google LLC. // Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +#include "include/private/SkTFitsIn.h" #include "src/utils/SkUTF.h" #include @@ -94,7 +95,7 @@ int SkUTF::CountUTF16(const uint16_t* utf16, size_t byteLength) { } int SkUTF::CountUTF32(const int32_t* utf32, size_t byteLength) { - if (!is_align4(intptr_t(utf32)) || !is_align4(byteLength) || byteLength >> 2 > INT_MAX) { + if (!is_align4(intptr_t(utf32)) || !is_align4(byteLength) || !SkTFitsIn(byteLength >> 2)) { return -1; } const uint32_t kInvalidUnicharMask = 0xFF000000; // unichar fits in 24 bits