aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--gn/BUILD.gn7
-rw-r--r--tests/OverAlignedTest.cpp22
2 files changed, 27 insertions, 2 deletions
diff --git a/gn/BUILD.gn b/gn/BUILD.gn
index 0ae8eeca0e..614a069dff 100644
--- a/gn/BUILD.gn
+++ b/gn/BUILD.gn
@@ -83,8 +83,11 @@ config("default") {
"-Wno-unknown-warning-option", # Let older Clangs ignore newer Clangs' warnings.
]
- # High priority to fix!
- cflags += [ "-Wno-over-aligned" ]
+ if (is_android && target_cpu == "x86") {
+ # Clang seems to think new/malloc will only be 4-byte aligned on x86 Android.
+ # We're pretty sure it's actually 8-byte alignment.
+ cflags += [ "-Wno-over-aligned" ]
+ }
cflags += [
"-Wno-cast-align",
diff --git a/tests/OverAlignedTest.cpp b/tests/OverAlignedTest.cpp
new file mode 100644
index 0000000000..aea74c7daa
--- /dev/null
+++ b/tests/OverAlignedTest.cpp
@@ -0,0 +1,22 @@
+/*
+ * Copyright 2016 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "Test.h"
+#include "SkRandom.h"
+
+// Clang seems to think only 32-bit alignment is guaranteed on 32-bit x86 Android.
+// See https://reviews.llvm.org/D8357
+// This is why we have disabled -Wover-aligned there (we allocate 8-byte aligned structs in Ganesh).
+DEF_TEST(OverAligned, r) {
+ SkRandom rand;
+ // Let's test that assertion. We think it really should be providing 8-byte alignment.
+ for (int i = 0; i < 1000; i++) {
+ void* p = malloc(rand.nextRangeU(0,100));
+ REPORTER_ASSERT(r, SkIsAlign8((uintptr_t)p));
+ free(p);
+ }
+}