-
Notifications
You must be signed in to change notification settings - Fork 636
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add CMake build system for valkey #1196
base: unstable
Are you sure you want to change the base?
Conversation
Signed-off-by: Eran Ifrah <[email protected]>
@PingXie see this PR instead. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## unstable #1196 +/- ##
============================================
- Coverage 70.69% 70.49% -0.21%
============================================
Files 114 114
Lines 63076 63150 +74
============================================
- Hits 44594 44516 -78
- Misses 18482 18634 +152
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to use WITH_TLS
instead of USE_TLS
? Then we have a single TLS related building variable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @eifrah-aws
Is it possible to generate |
- Force function names to lowercase in YAML config file - Parse version from version.h instead of hard-coding it - Fixed typo - Moved utility functions into their own module `Utils.cmake` - macOS: do not hard code "/usr/bin/clang", instead use `find_program` - Support for WITH_TLS=module|yes|off|1|0 - Support for WITH_RDMA=module|off|0 - Fixed (never worked for the original Makefile as well): build TLS as module on macOS Signed-off-by: Eran Ifrah <[email protected]>
Yes, but this will break Makefile users. So until CMake is agreed as the main build tool, I wouldn't go this path |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, I also find the missing CMakeLists.txt for tests:
$ find tests -name Makefile
tests/rdma/Makefile
tests/modules/Makefile
And cmake related help information in README.md
is needed?
I wonder if we should drop building TLS as a module now in CMake. Looks like RDMA can only be built as a module now, which is fine, as long as we don't support two build systems. @valkey-io/core-team thoughts? |
- Fixed comment - Use a more accurate variable name `RDMACM` as the output prefix - Avoid using condition like `if (USE_TLS EQUAL 2)`, instead use `if (BUILD_TLS_MODULE)` - Build "hello*" moodules - Build "test" modules (using conditional variable `-DBUILD_TEST_MODULES=1`) - Build "rdma-test" Signed-off-by: Eran Ifrah <[email protected]>
Signed-off-by: Eran Ifrah <[email protected]>
Signed-off-by: Eran Ifrah <[email protected]>
Fixed with recent commit |
Signed-off-by: Eran Ifrah <[email protected]>
Signed-off-by: Eran Ifrah <[email protected]>
Signed-off-by: Eran Ifrah <[email protected]>
Signed-off-by: Eran Ifrah <[email protected]>
Signed-off-by: Eran Ifrah <[email protected]>
Signed-off-by: Eran Ifrah <[email protected]>
README updated |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am fine removing building TLS as a module. No longer really seems necessary.
Before merging, we should all add it to the CI to make sure it runs as expected.
- Build of the example modules is now conditional (defaults to NO) - README.md fixup - Fixed UT build (exposed VALKEY_USE_TEST_MAIN & VALKEY_USE_TEST_SERVER_ASSERT macros only for macOS) - Added missing valkeylib for UT build (which was removed previous commit) Signed-off-by: Eran Ifrah <[email protected]>
- Moved rdma-tests source file to their own file - Unit tests are no longer handled separately - Use CMake function `ProcessorCount` to determine the number of jobs to run when invoking `make` - FreeBSD: valkey-unit-tests: link against execinfo for backtrace symbols Signed-off-by: Eran Ifrah <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Also test this PR on my local platform Ubuntu 22.04.4 LTS
, it works fine.
It would be appreciated if adding these message into commit message.
Tested-by: zhenwei pi [email protected]
Reviewed-by: zhenwei pi [email protected]
- Make `main` + `serverAssert` "weak" symbols - Set LTO using CMake proper syntax instead of hacking it into the build flags - For consistency, change all args starting with `WITH_*` to `BUILD_*`. for example: `cmake .. -DBUILD_TLS=module -DBUILD_MALLOC=jemalloc -DBUILD_UNIT_TESTS=1` - Only search for OpenSSL if BUILD_TLS is "on" or "module" Signed-off-by: Eran Ifrah <[email protected]>
Signed-off-by: Eran Ifrah <[email protected]>
Signed-off-by: Eran Ifrah <[email protected]>
@madolson per your suggestion, I made the symbols |
Signed-off-by: Eran Ifrah <[email protected]>
Signed-off-by: Eran Ifrah <[email protected]>
Yeah that is a flaky test.
Can we drop the option to build TLS as a module? I think now it is a good time to make this change. @pizhenwei do you have any concerns? |
Dropping tls module option is OK to me! |
Great, will drop it |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, was able to test and run everything locally on my x86 mac. The only pending item I have now is I would like us to add it to CI so that we don't silently break it. Let's add a separate test here: https://github.com/valkey-io/valkey/blob/unstable/.github/workflows/ci.yml#L13 that does cmake + make. I think for now just doing it on linux is fine.
@valkey-io/core-team I added the approved tag since we did discuss this in our weekly meeting. But tagging again incase anyone else would like to review before we merge.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Look ok to me. (i don't know much about it so did not do the review)
Replacing this PR #1082
NOTE:
This PR was tested on:
gmake
for buildingvalkey
With this PR, users are able to build valkey using
CMake
.Example usage:
Build
valkey-server
in Release mode with TLS enabled and usingjemalloc
as the allocator:Build
valkey-unit-tests
:Current features supported by this PR:
jemalloc
,tcmalloc
,tcmalloc_minimal
andlibc
), e.g. to enablejemalloc
pass-DBUILD_MALLOC=jemalloc
tocmake
-DBUILD_TLS=1
tocmake
)-DBUILD_SANITIZER=<address|thread|undefined>
tocmake
valkey-unit-tests
executablevalkey
under/home/you/root
pass-DCMAKE_INSTALL_PREFIX=/home/you/root
Why using
CMake
? To list some of the advantages of usingCMake
:compile_commands.json
which is required byclangd
to get a compiler accuracy code completion (in other words: your VScode will thank you)More build examples:
ASAN build:
ASAN with jemalloc:
As seen by the previous examples, any combination is allowed and co-exist on the same source tree.
Valkey installation
With this new
CMake
, it is possible to install the binary by runningmake install
or creating a packagemake package
(currently supported on Debian like distros)Example 1: build & install using
make install
:Example 2: create a
.deb
installer:Example 3: create installer for non Debian systems (e.g. FreeBSD or macOS):
Current
CMake
PR status:jemalloc
,libc
,tcmalloc
andtcmalloc_minimal
).deb
packagingrelease.h
commands.def
fmtargs.h
test_files.h