You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kudu.apache.org by ad...@apache.org on 2017/05/04 20:12:20 UTC

[2/3] kudu git commit: Silence clang -Waddress-of-packed-member warning

Silence clang -Waddress-of-packed-member warning

macOS/clang 4.0 builds have become polluted with warnings like:

In file included from ../../src/kudu/tablet/deltamemstore.cc:22:
In file included from ../../src/kudu/tablet/deltafile.h:34:
In file included from ../../src/kudu/tablet/deltamemstore.h:33:
../../src/kudu/tablet/concurrent_btree.h:386:33: warning: taking address of packed member 'version_' of class or structure 'kudu::tablet::btree::NodeBase<kudu::tablet::DMSTreeTraits>' may result in an unaligned pointer value [-Waddress-of-packed-member]
    VersionField::SetInserting(&version_);
                                ^~~~~~~~
../../src/kudu/tablet/concurrent_btree.h:721:11: note: in instantiation of member function 'kudu::tablet::btree::NodeBase<kudu::tablet::DMSTreeTraits>::SetInserting' requested here
    this->SetInserting();
          ^
../../src/kudu/tablet/concurrent_btree.h:707:12: note: in instantiation of member function 'kudu::tablet::btree::LeafNode<kudu::tablet::DMSTreeTraits>::InsertNew' requested here
    return InsertNew(mut->idx(), mut->key(), val, mut->arena());
           ^
../../src/kudu/tablet/concurrent_btree.h:1316:19: note: in instantiation of member function 'kudu::tablet::btree::LeafNode<kudu::tablet::DMSTreeTraits>::Insert' requested here
    switch (node->Insert(mutation, val)) {
                  ^
../../src/kudu/tablet/concurrent_btree.h:869:19: note: in instantiation of member function 'kudu::tablet::btree::CBTree<kudu::tablet::DMSTreeTraits>::Insert' requested here
    return tree_->Insert(this, val);
                  ^
../../src/kudu/tablet/deltamemstore.cc:103:31: note: in instantiation of member function 'kudu::tablet::btree::PreparedMutation<kudu::tablet::DMSTreeTraits>::Insert' requested here
  if (PREDICT_FALSE(!mutation.Insert(update.slice()))) {

This is because of clang's -Waddress-of-packed-member warning which has
been committed and reverted and committed again in the clang codebase.

Chromium also silenced this (multiple times), see:
https://bugs.chromium.org/p/chromium/issues/detail?id=637306

This patch makes clang ignore that warning, but if we just left it
at that older versions of clang would then complain about the unknown
warning, so this also makes clang ignore unknown warnings. The
alternative would be have clang ignore the warning only for
certain versions, but then we'd have to do that separately for macOS
and linux which seems more code to add and maintain.

Note that this warning can't be ignored locally, with pragmas, because
then GCC would spew warnings about unknown pragmas. Moreover the GCC
warnings themselves can't be ignored because of a long standing bug.

See: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53431

Change-Id: I03518bcca43ea6c891a7f622972465c1ea87ce63
Reviewed-on: http://gerrit.cloudera.org:8080/6693
Tested-by: Kudu Jenkins
Reviewed-by: Todd Lipcon <to...@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/kudu/repo
Commit: http://git-wip-us.apache.org/repos/asf/kudu/commit/62178794
Tree: http://git-wip-us.apache.org/repos/asf/kudu/tree/62178794
Diff: http://git-wip-us.apache.org/repos/asf/kudu/diff/62178794

Branch: refs/heads/master
Commit: 621787943ad2b3c300408b17250fc28ae0e70dec
Parents: c36e6c4
Author: David Alves <dr...@apache.org>
Authored: Wed Apr 19 14:02:53 2017 -0700
Committer: David Ribeiro Alves <da...@gmail.com>
Committed: Thu May 4 20:08:50 2017 +0000

----------------------------------------------------------------------
 CMakeLists.txt | 7 +++++++
 1 file changed, 7 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kudu/blob/62178794/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3aa6911..c3b7169 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -242,6 +242,13 @@ if ("${COMPILER_FAMILY}" STREQUAL "clang")
   # ATTRIBUTE_DEPRECATED in its signature.
   set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wdocumentation-deprecated-sync")
 
+  # Avoid 'taking address of packed member' warnings, which pollute macOs/clang 4.0 builds.
+  # This is also done in chromium. See:
+  # https://bugs.chromium.org/p/chromium/issues/detail?id=619640
+  # Unfortunately older versions of clang complain about not knowing the warning, so
+  # this also disables the warning about unknown warnings.
+  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unknown-warning-option -Wno-address-of-packed-member")
+
   # Only hardcode -fcolor-diagnostics if stderr is opened on a terminal. Otherwise
   # the color codes show up as noisy artifacts.
   #