Commit Graph

35 Commits

Author SHA1 Message Date
Azat Khuzhin
a10aa9ad50 Force libunwind usage (removes gcc_eh support)
libunwind is reentrant and signal safe, and works faster then then
gcc_eh (plus it has some custom patches for problems that have been
found during it's usage in ClickHouse).

gcc_eh may be missing in the system (if gcc was not installed), and
even if it exists clickhouse uses -nodefaultlibs, so some care should be
made to make it work.

Also this library is tiny and there shouln't be any problem to require
it always (there is already tendency to require some contrib libraries,
i.e. poco).

Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
2023-07-08 20:55:50 +02:00
Robert Schulze
1477887259
Initial removal of logic under COMPILER_GCC 2023-04-11 16:27:32 +00:00
Robert Schulze
829958e13a
Merge branch 'master' into build-libcxx-and-libcxxabi-from-llvm-project 2022-11-28 16:09:14 +01:00
Azat Khuzhin
ddfea23804 Do not include libcxx library for C
If you will have the same header in both libraries you may have some
tricky failures.

And there is at least one header that exists in both: stdatomic.h

Right now there is a workaround for this header, that allows to use C++
version of this header for C - the workaround is called "set
_LIBCPP_COMPILER_CLANG_BASED not only for CXX" [1] and use include_next
[2].

  [1]: 9a457ab3c6/include/__config (L39)
  [2]: 9a457ab3c6/include/stdatomic.h (L223-L231)

However #42730 changes this, and now it fails to compile because of this.

Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
2022-11-11 14:43:14 +01:00
Robert Schulze
a9427888be
Build libcxx and libcxxabi from llvm-project
Resolves #42245
2022-10-27 09:55:27 +00:00
Robert Schulze
820e6b4276
Build with libcxx(abi) 15 2022-10-20 10:52:43 +00:00
Azat Khuzhin
dd8478422a Fix usage of generator expressions for libcxx cmake
Before, if you store clickhouse sources in /src, there was a typo and it
produce the following error:

    CMake Error in contrib/libcxx-cmake/CMakeLists.txt:
      Target "cxx" INTERFACE_INCLUDE_DIRECTORIES property contains path:

        "/src"

      which is prefixed in the source directory.

Also move "src" into PRIVATE, since it is required only for libcxx
itself.

Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
2022-09-02 14:21:43 +02: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
Raúl Marín
f061e54acb Adapt libcxx CMakefiles to LLVM 14 changes 2022-03-24 10:25:04 +01:00
Denis Glazachev
e41ed7cc6e Fix GCC compilation in macOS 2021-11-26 02:03:04 +03:00
Denis Glazachev
9de534f96c Revert special contribs and set folder manually for them until fixed 2021-10-17 23:10:01 +03:00
Alexey Milovidov
41acc52458 Preparation to build with Musl 2021-10-16 00:17:34 +03:00
Alexey Milovidov
2e0ac4b5ca Somewhat better support for paths with whitespaces 2021-04-24 22:48:44 +03:00
Alexey Milovidov
4ff812db7f Maybe better support for paths with whitespaces 2021-04-24 22:47:52 +03:00
Denis Glazachev
e8464d61f1 Fix vanilla GCC compilation in macOS 2021-04-09 04:28:24 +04:00
Danila Kutenin
797a4052d8 Update libcxx and use unstable ABI to provide better performance 2021-01-11 02:08:33 +00:00
Alexey Milovidov
d1deba0f78 Fixed bad code 2020-02-22 22:47:32 +03:00
Alexey Milovidov
fd523fa796 Fixed bad code 2020-02-22 22:45:53 +03:00
Alexey Milovidov
1ba67b1bb4 Fixed bad code 2020-02-22 22:44:31 +03:00
Ivan Lezhankin
8eb0cd82fe Add CMake macro add_warning to check if compiler supports warning 2020-01-10 13:25:14 +03:00
Alexey Milovidov
628ab6849f Fixed build 2020-01-02 19:38:09 +03:00
Alexey Milovidov
67afaa9d93 Stack trace for every exception (experimental) 2020-01-02 09:56:53 +03:00
Alexey Milovidov
dbbc13213b Added missing translation units 2019-12-20 21:36:13 +03:00
Alexey Milovidov
cea2903e72 Fixed build: set compile flags only when appropriate 2019-12-20 03:35:35 +03:00
alexey-milovidov
5e46576d20
Update CMakeLists.txt 2019-11-02 11:46:35 +03:00
Ernest Poletaev
de1e5d0e53 Fixed compile errors on macOS Catalina 2019-11-01 23:33:43 +07:00
Ivan
381947509a
Fix build for Darwin (#7149)
* Disable some contribs for cross-compilation
* Fix clang-8-darwin build
* Also fix docs
* Add diagnostics
* Check cross-compilation in each file individually.
* Disable warning for clang < 9
2019-10-02 17:35:07 +03:00
Ivan Lezhankin
8c356a3830 WIP 2019-09-15 18:20:31 +03:00
Ivan
cd5c0fc9ac
Fix build issues (#6744)
* libcxxabi uses exception handling library as public
* Don't set -stdlib for internal libc++ - it poisons the checks.
* Enable capnproto in unbundled build back
2019-08-30 20:40:27 +03:00
Ivan Lezhankin
0e606c790e Fix install of libcxx and libcxxabi 2019-08-29 16:38:18 +03:00
Ivan Lezhankin
36abd1e6fc Fix build 2019-08-29 14:09:01 +03:00
Ivan Lezhankin
85afd61c01 Fix build with internal libcxx 2019-08-29 13:44:22 +03:00
Ivan
b4339f266d
Make a better build scheme (#6500)
* Fix shared build
* Major default libs refactor
* Fix build with gcc_eh
* Link all libraries as a big group.
* Use global interface library as a group
* Build capnproto using our cmake
* Use only internal libunwind
2019-08-28 23:49:37 +03:00
Alexey Milovidov
055ec8817b Clean CMakeLists 2019-07-09 02:58:14 +03:00
Alexey Milovidov
daf84d4b84 Clean CMakeLists for cxx 2019-07-09 02:33:32 +03:00