Commit Graph

49 Commits

Author SHA1 Message Date
Azat Khuzhin
19715f1542 Enable -Wshorten-64-to-32
Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
2022-10-21 13:22:39 +02:00
Alexey Milovidov
84f42e0874 Fix 3/4 of trash 2022-09-19 08:50:53 +02:00
Alexey Milovidov
a716d78264 Support build with clang-16 2022-08-13 06:06:01 +02:00
Raúl Marín
11a274e990 Clean up constinit usage and add a comment 2022-08-11 13:27:53 +02:00
Robert Schulze
74fc53e5c2
Enable -Wc99-extension 2022-07-15 10:58:09 +00:00
Robert Schulze
1276bfdffd
Enable -Wsign-conversion 2022-07-15 08:54:21 +00:00
Robert Schulze
22abb97b91
Enable -Wc11-extensions 2022-07-14 14:36:23 +00:00
Robert Schulze
97aa9a7371
Enable -Wpacked 2022-07-14 12:36:57 +00:00
Robert Schulze
e7bc973ffb
Enable -Wshift-sign-overflow 2022-07-14 12:36:56 +00:00
Robert Schulze
3d734a0640
Enable -Wnested-anon-types 2022-07-14 12:36:55 +00:00
Robert Schulze
72d45bdff3
Enable -Wvla-extension 2022-07-14 12:36:53 +00:00
Robert Schulze
439b786156
Enable -Wunused-command-line-argument 2022-07-14 12:36:52 +00:00
Robert Schulze
da4724e7f5
Enable -Wreturn-std-move-in-c++11 2022-07-14 12:36:48 +00:00
Robert Schulze
87197f8f60
Enable -Wdeprecated-dynamic-exception-spec 2022-07-13 13:49:40 +00:00
Robert Schulze
5a4f21c50f
Support for Clang Thread Safety Analysis (TSA)
- TSA is a static analyzer build by Google which finds race conditions
  and deadlocks at compile time.

- It works by associating a shared member variable with a
  synchronization primitive that protects it. The compiler can then
  check at each access if proper locking happened before. A good
  introduction are [0] and [1].

- TSA requires some help by the programmer via annotations. Luckily,
  LLVM's libcxx already has annotations for std::mutex, std::lock_guard,
  std::shared_mutex and std::scoped_lock. This commit enables them
  (--> contrib/libcxx-cmake/CMakeLists.txt).

- Further, this commit adds convenience macros for the low-level
  annotations for use in ClickHouse (--> base/defines.h). For
  demonstration, they are leveraged in a few places.

- As we compile with "-Wall -Wextra -Weverything", the required compiler
  flag "-Wthread-safety-analysis" was already enabled. Negative checks
  are an experimental feature of TSA and disabled
  (--> cmake/warnings.cmake). Compile times did not increase noticeably.

- TSA is used in a few places with simple locking. I tried TSA also
  where locking is more complex. The problem was usually that it is
  unclear which data is protected by which lock :-(. But there was
  definitely some weird code where locking looked broken. So there is
  some potential to find bugs.

*** Limitations of TSA besides the ones listed in [1]:

- The programmer needs to know which lock protects which piece of shared
  data. This is not always easy for large classes.

- Two synchronization primitives used in ClickHouse are not annotated in
  libcxx:
  (1) std::unique_lock: A releaseable lock handle often together with
      std::condition_variable, e.g. in solve producer-consumer problems.
  (2) std::recursive_mutex: A re-entrant mutex variant. Its usage can be
      considered a design flaw + typically it is slower than a standard
      mutex. In this commit, one std::recursive_mutex was converted to
      std::mutex and annotated with TSA.

- For free-standing functions (e.g. helper functions) which are passed
  shared data members, it can be tricky to specify the associated lock.
  This is because the annotations use the normal C++ rules for symbol
  resolution.

[0] https://clang.llvm.org/docs/ThreadSafetyAnalysis.html
[1] https://static.googleusercontent.com/media/research.google.com/en//pubs/archive/42958.pdf
2022-06-20 16:13:25 +02:00
Alexey Milovidov
7c9df33bf8
Update warnings.cmake 2022-05-20 03:12:44 +03:00
Robert Schulze
34af1cb116
Throw option WEVERYTHING out
WEVERYTHING enables on Clang literally every warning. People on the
internet are divided if this is a good thing or not but ClickHouse
compiles with -Weverything + some exceptions for noisy warnings since at
least a year.

I tried to build with WEVERYTHING = OFF and the build was badly broken.
It seems nobody actually turns WEVERYTHING off. Actually, why would one
if the CI builds (configured with WEVERYTHING = ON) potentially generate
errors not generated in local development.

To simplify the build scripts and to remove the need to maintain two
sets of compiler warnings, I made WEVERYTHING the default and threw
WEVERYTHING = OFF out.
2022-05-17 15:52:53 +02:00
Robert Schulze
3eb964a9f5
Simplify: Move warnings stuff into cmake/warnings.cmake 2022-05-15 09:48:03 +02:00
Robert Schulze
a9215214b7
Remove switches for obsolete GCC version
GCC_MINIMUM_VERSION is 11 --> remove special logic for earlier GCCs.
2022-04-30 20:33:20 +02:00
Azat Khuzhin
4f8438bb34 cmake: do not allow internal libstdc++ usage
Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
2022-01-21 10:11:23 +03:00
Alexey Milovidov
1ded1e7181 Remove some trash from build 2021-11-28 08:05:24 +03:00
Alexey Milovidov
f1ff1426f2 Fix build 2021-11-21 21:23:29 +03:00
Mike Kot
d8b336a942 fix 2021-10-03 00:47:25 +02:00
Mike Kot
84505b7947 fix 2021-10-03 00:24:11 +02:00
Mike Kot
da66f4f533 Slight changes 2021-10-03 00:06:07 +02:00
Mike Kot
605268811b More warnings for clang, exper. constexpr interpreter for clang 2021-10-02 23:50:47 +02:00
Nikita Mikhaylov
513d40feb2 Fix build 2021-09-09 14:59:25 +00:00
Nikita Mikhaylov
dcf7cb4a5c Done 2021-09-08 17:33:40 +00:00
Azat Khuzhin
2fd78b7eac Add -Wundef for gcc 2021-04-18 23:40:08 +03:00
Amos Bird
061e3c7d81
Correctly place debug helpers 2021-03-31 18:28:58 +08:00
Ivan
315ff4f0d9
ANTLR4 Grammar for ClickHouse and new parser (#11298) 2020-12-04 05:15:44 +03:00
Denis Glazachev
0e6dd287e7 Fix CMake generation and build for native Xcode and AppleClang 2020-11-27 20:33:16 +04:00
Azat Khuzhin
0f5ba33be8 Exclude zero-as-null-pointer-constant for libstdc++ under WEVERYTHING 2020-10-11 22:11:18 +03:00
Azat Khuzhin
4e49812e32 Enable Wzero-as-null-pointer-constant only for libcxx
Since libstdc++ has some of such compares for 3way compare:

    /src/ch/clickhouse/src/Common/UInt128.h:61:71: warning: zero as null pointer constant [-Wzero-as-null-pointer-constant]
        bool inline operator>= (const UInt128 rhs) const { return tuple() >= rhs.tuple(); }
                                                                          ^~
                                                                          nullptr
    /usr/include/c++/10.2.0/tuple:1426:5: note: while rewriting comparison as call to 'operator<=>' declared here
        operator<=>(const tuple<_Tps...>& __t, const tuple<_Ups...>& __u)
2020-10-10 22:48:36 +03:00
Azat Khuzhin
0813c1073b Add -Wzero-as-null-pointer-constant for gcc 2020-10-10 22:45:39 +03:00
alesapin
f950198fa5 Allow to use c11 with clang pedantic 2020-10-06 19:00:42 +03:00
myrrc
7cd5c0d34f Merge remote-tracking branch 'upstream/master' into feature/cmake-flags-doc-generator 2020-09-17 19:17:09 +03:00
myrrc
ac606dca77 updated cmake/ files, added some comments 2020-09-17 18:37:23 +03:00
alesapin
fb7fc28e6f
Update warnings.cmake 2020-09-14 12:20:43 +03:00
alesapin
8075ce2809
Update warnings.cmake 2020-09-12 15:42:32 +03:00
alesapin
e25b1da29f Disable -Wstringop-overflow for gcc-10 2020-09-11 13:53:26 +03:00
alesapin
4ba8f8960b Increase frame-larger-than 2020-09-09 12:53:24 +03:00
Alexey Milovidov
cf6ccbc656 Adjustments 2020-08-03 20:44:23 +03:00
Alexey Milovidov
f5f0c788b8 Relax the limit 2020-08-03 00:10:57 +03:00
Alexey Milovidov
cf388cc32f Slightly lower the limit 2020-08-02 04:35:49 +03:00
Alexey Milovidov
48e48a1e09 Decrease maximum stack frame size while we can 2020-06-08 23:00:17 +03:00
Alexey Milovidov
475af33319 Avoid too large stack frames 2020-06-08 20:35:45 +03:00
Azat Khuzhin
23044ac02c Disable -Wsequence-point on gcc10 (otherwise it stuck on GatherUtils compiling)
clang (10.0.0 is fine BTW) will warn about this anyway on CI.

For the debug build gcc10:

- before patch:
  - concat.cpp -> >5m (stuck on cc1plus, not as)
  - has.cpp    -> >10m (stuck on cc1plus, not as)

- after this patch:
  - concat.cpp -> 1m16s
  - has.cpp    -> 4m (and most of the time eats, as from binutils 2.34.50.20200508)

Command for build:
- ninja src/Functions/GatherUtils/CMakeFiles/clickhouse_functions_gatherutils.dir/concat.cpp.o
- ninja src/Functions/GatherUtils/CMakeFiles/clickhouse_functions_gatherutils.dir/has.cpp.o

The test case should be reduced and then it can be reported to the gcc
bugzilla.

P.S. Looks like a signal not to switch to gcc10 for now
2020-05-21 21:18:34 +03:00
Alexey Milovidov
a576a4fbcd Enable extra warnings for base, utils, programs 2020-05-10 01:59:34 +03:00