Skip to content
This repository was archived by the owner on May 6, 2021. It is now read-only.

Conversation

@dwm
Copy link

@dwm dwm commented Feb 8, 2015

This is a small series of commits that adds support for:

  • Building Ceph with clang/clang++ rather than gcc/g++.
  • Building Ceph with "-Wall -Weverything -Wpedantic" defined.
  • Building Ceph with AddressSanitizer instrumentation, as supported by Clang >= 3.3 and GCC >= 4.8.
  • Building Ceph with ThreadSanitizer instrumentation, as supported by Clang >= 3.2 and GCC >= 4.8.
  • Building Ceph with Clang's static analyzer active.

These can be enabled by building on a host with '-clang', '-wall', '-asan', '-tsan', and '-analyze' hostname affixes defined, respectively.

(Note that, at least for Clang 3.5, AddressSanitizer and ThreadSanitizer compilation options are mutually-exclusive.)

This series also updates fabfile.py to add the 'clang' package (and the 'clang-analyzer' package on RPM-based systems) to build-hosts.

These changes are untested, though are simple enough that they're pretty likely to work, modulo any uncaught typos.

I may also not have caught all of the different build-cases of interest, as some of the build-scripts hand off to RPM spec files or debian/rules files not stored within the tree. It's also not clear which of the current build scripts might be obsolete.

Manual testing of these compile-time options shows that:

  • Ceph does not currently build successfully with Clang 3.5; it objects to the templated IO helpers in src/include/types.h.
  • RocksDB as used by Ceph cannot be compiled with Clang 3.5 with all of the extra warnings enabled, as -Werror is also in effect at that point but it is not completely warning-clean.

dwm added 7 commits February 8, 2015 18:41
Modify the various build-script variants to use CC and CXX, rather
than asuming the use of gcc and g++ --- though they will still use
these by default if no other compiler is specified.
If the auto-builder's hostname contains '-clang', then build
Ceph using the clang and clang++ compilers, rather than using
the default.
Rather than replace the definitions of CFLAGS and CXXFLAGS when
calling configure, instead prepend to those variables.  This allows
use to later define CFLAGS and CXXFLAGS values in the calling
environment.
Update build-auto.sh to check the hostname for additional elements:

 -asan: Enable AddressSanitizer in subsequent compilations, which
        introduces extra safety-features at program run-time.
 -tsan: Enable ThreadSanitizer in subsequent compilations, which
        introduces extra safety-features at program run-time.
 -wall: Enable -Wall, -Wpedantic, -Weverything flags in subsequent
        compilations.

Note that, at least as of clang-3.5, the AddressSanitizer and
ThreadSanitizer options are mutually incompatible.

At time of writing, Ceph fails to build with -Wall -Wpedantic
-Weverthing flags defined part-way through compiling rocksdb, because
-Werror is also defined at that point.

(Of course, subsequent compilation errors may well, and even are
likely, to occur; this is just the first one we hit.)
Clang and distcc (particulrly versions of distcc < 3.2) interact
in some undesirable ways:

Specifically, clang (with all warnings enabled) can generate
spurious warnings (or errors, if -Werror is defined)! that are the
result of preprocessing files and compiling in separate stages.

Work around by exporting 'CCACHE_CPP2=yes' and definding
'-Qunused-arguments' in CFLAGS and CXXFLAGS.

See for further discussion:
http://petereisentraut.blogspot.co.uk/2011/05/ccache-and-clang.html
 *
Add 'clang' (and, on Redhat machines, 'clang-analyzer') to the set
of packages to provision.
Add support for wrapping the top-level 'make' invocation with the
contents of the BUILD_WRAPPER environment variable, and define this
variable on hosts with the -analyze suffix present.

Also disable the use of CCACHE in this case; it seems likely that
these two facilities might interact poorly.  This might be
overly conservative, however.

Note that while the static-analyzer is part of the clang project,
its use does not imply that compilation must use clang; hence if
you wish to both static-analyze and build Ceph with clang, then
both the -analyze and -clang hostname suffixes are required.
@dwm dwm changed the title Extend autobuilder to support options for clang, -Wall, ThreadSanitizer, and AddressSanitizer Extend autobuilder to support options for clang, -Wall, ThreadSanitizer, AddressSanitizer, and Clang's static analyzer. Feb 9, 2015
@dwm dwm changed the title Extend autobuilder to support options for clang, -Wall, ThreadSanitizer, AddressSanitizer, and Clang's static analyzer. Extend autobuilder to support options for clang, -Wall -Weverything -Wpedantic, ThreadSanitizer, AddressSanitizer, and Clang's static analyzer. Feb 9, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant