Skip to content
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

cmake support for linux and osx #1358

Merged
merged 3 commits into from Sep 28, 2016
Merged

cmake support for linux and osx #1358

merged 3 commits into from Sep 28, 2016

Conversation

tchaikov
Copy link
Contributor

tested on macos and gnu/linux

@ghost
Copy link

ghost commented Sep 27, 2016

Thank you for your pull request. As you may know, we require contributors to sign our Contributor License Agreement, and we don't seem to have you on file and listed as active anymore. In order for us to review and merge your code, please email cla@fb.com with your details so we can update your status.

@ghost
Copy link

ghost commented Sep 27, 2016

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks!

@siying
Copy link
Contributor

siying commented Sep 27, 2016

@yuslepukhin can you help take a look at it?

@ghost ghost added the CLA Signed label Sep 27, 2016
@siying
Copy link
Contributor

siying commented Sep 27, 2016

Windows build seems to be failing.

@tchaikov
Copy link
Contributor Author

tchaikov commented Sep 28, 2016

@siying the Windows build failure is fixed.

[ RUN      ] DBBloomFilterTest.BloomFilterRate
No output has been received in the last 10m0s, this potentially indicates a stalled build or something wrong with the build itself.
Check the details on how to adjust your build configuration on: https://docs.travis-ci.com/user/common-build-problems/#Build-times-out-because-no-output-was-received
The build has been terminated

And the test failure above is irrelevant to this change.

@ghost ghost added the CLA Signed label Sep 28, 2016
* port part of build_detect_platform not covered by thirdparty.inc
  to cmake.
  - detect fallocate()
  - detect malloc_usable_size()
  - detect JeMalloc
  - detect snappy
* check for asan,tsan,ubsan
* create 'build_version.cc' in build directory.
* add `check` target to support 'make check'.
* add `tools` target to match its counterpart in Makefile.
* use `date` on non-win32 platforms.
* pass different cflags on non-win32 platforms
* detect pthead library using FindThread cmake module.
* enable CMP0042 to silence the cmake warning on osx
* reorder the linked libraries. because testutillib references gtest, to
  enable the linker to find the referenced symbols, we need to put gtest
  after testutillib.

Signed-off-by: Marcus Watts <mwatts@redhat.com>
Signed-off-by: Kefu Chai <kchai@redhat.com>
Signed-off-by: Kefu Chai <kchai@redhat.com>
testharness.cc is included in librocksdb sources, and it uses gtest. but
gtest is not supposed to be part of the public API of librocksdb. so, in
this change, the testharness.cc is moved out out librocksdb, and is
built as an object target, then linked with the tools and tests instead.

Signed-off-by: Marcus Watts <mwatts@redhat.com>
Signed-off-by: Kefu Chai <kchai@redhat.com>
@yuslepukhin
Copy link
Contributor

Looks good. Please, document all the test failures. Also, did you get a change running standalone test executables, besides db_test and db_test2? I will get to all the unimplemented features soon if somebody else does not get those first.

@siying
Copy link
Contributor

siying commented Sep 28, 2016

@yuslepukhin thank you for taking a look. should I press the "merge" bottom?

@yuslepukhin
Copy link
Contributor

@siying Lets merge it, it is a better cross platform cmake start than we ever had. Thank you @tchaikov

@siying siying merged commit 21f4bb5 into facebook:master Sep 28, 2016
@adsharma
Copy link
Contributor

adsharma commented Sep 28, 2016

Thanks for your contribution and Sorry for commenting late:

# This cmake build is for Windows 64-bit only.

You want to edit this comment at the top of the CMakeLists.txt

#ifdef WIN32 #else ..

Why not separate these into cmake files of its own? There is some risk if these things are order sensitive. Should be a solvable problem though.

Simple RPM/DEB creation using continuous integration (I used packagecloud.io) can be built on top of this. It's not a replacement for distro packaging, but still useful to automate testing of CI generated bits. There is precedent in the Linux kernel doing this.

@adsharma
Copy link
Contributor

tested with devtoolset-3:

Linking CXX executable arena_test
librocksdblib.a(env_posix.cc.o): In function `rocksdb::(anonymous namespace)::PosixEnv::NowNanos()':
env_posix.cc:(.text+0x2909): undefined reference to `clock_gettime'

Two comments: why is the library called librocksdblib.a and not librocksdb.a?
Also target_link_libraries needs "rt"

@adsharma
Copy link
Contributor

du -sh build
1.4G    build

Using rocksdb-shared for tests should cut down disk usage significantly.

@tchaikov tchaikov deleted the wip-cmake branch September 29, 2016 01:48
@tchaikov
Copy link
Contributor Author

Why not separate these into cmake files of its own?

i think it would be easier for the posterity to read when maintaining this building system.

why is the library called librocksdblib.a and not librocksdb.a?

it's not intentional. and yes, it should be librocksdb.a.

@adsharma
Copy link
Contributor

i think it would be easier for the posterity to read when maintaining this building system.

I interpret that to mean you agree with splitting into platform specific cmake files.
Happy to review it if you submit a PR.

Once that's done, we can forward port the following snippets from #1135:

  • librocksdb-.so, so the shared libraries can co-exist and versioned properly
  • deb/rpm packaging support (move them to the cmake subdir to avoid polluting top level)
  • ${ROCKSDB_LIB} seems to represent shared lib on windows and static on linux. Reconcile.
  • circle.yml + packagecloud integration (code here: https://github.com/adsharma/rocksdb/commits/cmake_451)
  • verify that benchmarks are at parity relative to the ones built by the current system.

Happy to pitch in as much as I can.

@tchaikov
Copy link
Contributor Author

I interpret that to mean you agree with splitting into platform specific cmake files.

@adsharma, no, i meant it would be easier in current way.

librocksdb-.so, so the shared libraries can co-exist and versioned properly

yeah, i am all for this.

@yuslepukhin
Copy link
Contributor

On Windows when building it produces two things rocksdb.dll and rocksdb.lib. For the DLL it also produces import library rocksdb.lib. So in order that import library does not mix up or overwrite the stati library the latter is called rocksdblib.lib

@yuslepukhin
Copy link
Contributor

It is important that c_tests properly links to import library so it can test the exported interfaces the DLL that is actually used instead of the static library.

@adsharma
Copy link
Contributor

Thanks for explaining. I didn't grok the difference between static, dynamic and import library when I wrote #1364.

How about:

${ROCKSDB_LIB} = shared
${ROCKSDB_STATIC_LIB} = static
${ROCKSDB_IMPORT_LIB} = import lib 

so the distinction is clear?

@yuslepukhin
Copy link
Contributor

@adsharma Not sure where you would actually explicitly use ${ROCKSDB_IMPORT_LIB}

  • Not present on non-Windows
  • On Windows the name it is automatically derived from the DLL name
  • When linking you do not explicitly specify that either, You simply say link to the shared target and CMake knows to put there import library

@adsharma
Copy link
Contributor

@yuslepukhin: Sounds good. Let's stick with just the first two then.
We should be able to control the name of the file on disk via:

set_target_properties(OUTPUT_NAME, ...)

@yuslepukhin
Copy link
Contributor

@adsharma Speaking about the names. Did not look here, but the original build had ARTIFACT_SUFFIX. This was primarily for building libraries and binaries with _je suffix if they are built with JEMALLOC. We run 4 builds from the same build directory and end up with two sets of Debug and two sets of Release binaries so we can easily internally package them from the same location. _je suffix provides the way out so we would like to keep that if possible.

@yuslepukhin
Copy link
Contributor

@adsharma set_target_properties sound a little complex. Simply setting the name of the target different on Windows will do.

@adsharma
Copy link
Contributor

adsharma commented Dec 4, 2016

@yuslepukhin: could you take another look at #1364?

adsharma referenced this pull request Jan 24, 2017
Summary:
After make install, I see a directory hierarchy that looks like

```
./usr
./usr/include
./usr/include/rocksdb
./usr/include/rocksdb/filter_policy.h
[..]
./usr/include/rocksdb/iterator.h
./usr/include/rocksdb/utilities
./usr/include/rocksdb/utilities/ldb_cmd_execute_result.h
./usr/include/rocksdb/utilities/lua
./usr/include/rocksdb/utilities/lua/rocks_lua_custom_library.h
./usr/include/rocksdb/utilities/lua/rocks_lua_util.h
./usr/include/rocksdb/utilities/lua/rocks_lua_compaction_filter.h
./usr/include/rocksdb/utilities/backupable_db.h
[..]
./usr/include/rocksdb/utilities/env_registry.h
[..]
./usr/include/rocksdb/env.h
./usr/lib64
./usr/lib64/librocksdb.so.5
./usr/lib64/librocksdb.so.5.0.0
./usr/lib64/librocksdb.so
./usr/lib64/librocksdb.a
```
Closes #1798

Differential Revision: D4456536

Pulled By: yiwu-arbug

fbshipit-source-id: 5494e91
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants