Commit Graph

24 Commits

Author SHA1 Message Date
Kefu Chai
e4c6b0b31d build: cmake: disable deprecated warning
since Seastar now deprecates a bunch of APIs which accept io_priority_class,
we started to have deprecated warnings. before migrating to V7 API,
let's disable this warning.

Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>
2023-05-05 15:31:39 +08:00
Kefu Chai
c76486c508 build: only apply -Wno-parentheses-equality to ANTLR generated sources
it turns out the only places where we have compiler warnings of
-W-parentheses-equality is the source code generated by ANTLR. strictly
speaking, this is valid C++ code, just not quite readable from the
hygienic point of view. so let's enable this warning in the source tree,
but only disable it when compiling the sources generated by ANTLR.

please note, this warning option is supported by both GCC and Clang,
so no need to test if it is supported.

for a sample of the warnings, see:
```
/home/kefu/dev/scylladb/build/cmake/cql3/CqlLexer.cpp:21752:38: error: equality comparison with extraneous parentheses [-Werror,-Wparentheses-equality]
                            if ( (LA4_0 == '$'))
                                  ~~~~~~^~~~~~
/home/kefu/dev/scylladb/build/cmake/cql3/CqlLexer.cpp:21752:38: note: remove extraneous parentheses around the comparison to silence this warning
                            if ( (LA4_0 == '$'))
                                 ~      ^     ~
```

Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>
2023-05-04 11:16:27 +08:00
Kefu Chai
662f8fa66e build: reenable -Wmissing-braces
since we've addressed all the -Wmissing-braces warnings, we can
now enable this warning.

Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>
2023-04-28 16:59:29 +08:00
Kefu Chai
ecd5bf98d9 build: cmake: set stack frame limits
* transpose include(mode.common) and include (mode.${build_mode}),
  so the former can reference the value defined by the latter.
* set stack_usage_threshold for supported build modes.

please note, this compiler option (-Wstack-usage=<bytes>) is only
supported by GCC so far.

Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>
2023-04-04 15:33:20 +08:00
Kefu Chai
066e9567ee build: cmake: use -O0 on aarch64, otherwise -Og
this addresses an oversight in b234c839e4,
which is supposed to mirror the behavior of `configure.py`.

Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>
2023-04-04 15:33:20 +08:00
Kefu Chai
e0ca80d21f build: cmake: port more cxxflags from configure.py
Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>
2023-03-26 14:01:21 +08:00
Kefu Chai
8963fe4e41 build: cmake: increase per link job mem to 4GiB
lld is multi-threaded in some phases, based on observation, it could
spawn up to 16 threads for each link job. and each job could take up
to more than 3 GiB memory in total. without the change, we can run
into OOM with a machine without abundant memory, so increase the
per-link-job mem accordingly.

Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>
2023-03-16 12:14:21 +08:00
Kefu Chai
269cce4c2c build: cmake: remove Seastar from the option name
change the option name to "LINK_MEM_PER_JOB" as this is not
a Seastar option, but a top-level project option.

Signed-off-by: Kefu Chai <tchaikov@gmail.com>
2023-03-15 15:38:46 +08:00
Kefu Chai
b25a6d5a9c build: cmake: limit the number of link job
this mirrors the settings in `configure.py`.

Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>
2023-03-07 15:34:12 +08:00
Kefu Chai
5e38845057 build: cmake: only add supported warning flags to CMAKE_CXX_FLAGS
Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>
2023-03-07 15:24:02 +08:00
Kefu Chai
2b23de31ca build: cmake: use different names for output of check_cxx_compiler_flag
* use the value of disabled_warnings, not the variable name for warning
  options, otherwise we'd checking options like `-Wno-disabled_warnings`.
* use different names for the output of check_cxx_compiler_flag() calls.
  as the output variable of check_cxx_compiler_flag(..) call is cached,
  we cannot reuse it for checking different warning options,

Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>
2023-03-07 15:24:02 +08:00
Kefu Chai
c5d1a69859 build: cmake: link couple libraries as whole archive
turns out we are using static variables to register entries in
global registries, and these variables are not directly referenced,
so linker just drops them when linking the executables or shared
libraries. to address this problem, we just link the whole archive.
another option would be create a linker script or pass
--undefined=<symbol> to linker. neither of them is straightforward.

a helper function is introduced to do this, as we cannot use CMake
3.24 as yet.

Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>
2023-03-04 13:11:25 +08:00
Kefu Chai
58f13dfa0a build: cmake: find ANTLR3 before using it
if ANTLR3's header files are not installed into the /usr/include, or
other directories searched by compiler by default. there are chances,
we cannot build the tree. so we have to find it first. as /opt/scylladb
is the directory where `scylla-antlr35-c++-dev` is installed on
debian derivatives, this directory is added so the find package module
can find the header files.

```
In file included from /home/kefu/dev/scylla/db/legacy_schema_migrator.cc:38:
In file included from /home/kefu/dev/scylla/cql3/util.hh:21:
/home/kefu/dev/scylla/build/cmake/cql3/CqlParser.hpp:55:10: fatal error: 'antlr3.hpp' file not found
         ^~~~~~~~~~~~
```

Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>
2023-03-04 13:11:25 +08:00
Kefu Chai
1aafeac023 build: cmake: find libxcrypt before using it
we should find libxcrypt library before using it. in this change,
Findlibxcrypt.cmake is added to find libxcrypt library.

Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>
2023-02-28 21:28:46 +08:00
Kefu Chai
607858db51 build: cmake: find Thrift before using it
we should find Thrift library before using it. in this change,
FindThrift.cmake is added to find Thrift library.

Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>
2023-02-28 21:28:46 +08:00
Kefu Chai
69b1e7651e build: cmake: link scylla against xxHash::xxhash
instead of adding `XXH_PRIVATE_API` to compile definitions, link
scylla against xxHash::xxhash, which provides this definition for us.

also move the comment on `XXH_PRIVATE_API` into `FindxxHash.cmake`,
where this definition is added.

Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>
2023-02-21 14:24:18 +08:00
Kefu Chai
957403663f build: cmake: build release.cc as a library
so we can attach compiling definitions in a simpler way.

this change is based on Botond Dénes's change which gives an overhaul
to the existing CMake building system.

Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>
2023-02-21 14:23:04 +08:00
Kefu Chai
d89602c6a2 build: cmake: ignore -Wparentheses-equality
antlr3 generates code like `((foo == bar))`. but Clang does not
like it. let's disable this warning. and explore other options later.

Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>
2023-02-17 18:38:44 +08:00
Kefu Chai
76355c056f build: cmake: correct generate_cql_grammar
should have escaped `&` with `\`.

Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>
2023-02-16 00:07:40 +08:00
Kefu Chai
d6746fc49c build: cmake: correct the check in Findlibdeflate.cmake
otherwise libdeflate is never found.

Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>
2023-02-16 00:07:40 +08:00
Kefu Chai
b6a8341eef build: cmake: find xxHash package
we use private API in xxHash, it'd be handy to expose it in the form
of a library target.

Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>
2023-02-16 00:07:37 +08:00
Kefu Chai
b234c839e4 build: cmake: add build mode support
Scylla uses different build mode to customize the build for different
purposes. in this change, instead of having it in a python dictionary,
the customized settings are located in their own files, and loaded
on demand. we don't support multi-config generator yet.

Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>
2023-02-16 00:07:37 +08:00
Kefu Chai
f8671188c7 build: cmake: extract cql3 and alternator out
Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>
2023-02-14 23:54:20 +08:00
Kefu Chai
9ea8a46dd6 build: cmake: use packaged libdeflate
this mirrors the change in b8b78959fb

Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>
2023-02-14 19:25:02 +08:00