-
Notifications
You must be signed in to change notification settings - Fork 6.2k
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
Require C++17 #9481
Require C++17 #9481
Conversation
Summary: Drop support for some old compilers by requiring C++17 standard (or higher). See facebook#9388 Test Plan: CI config updated TODO: finish sanitizing CircleCI config
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.
This generally looks good to me.
For the Linux boxes, I wonder if using "-j$(nproc)" might be a better paradigm. The parallelism seems to inconsistent.
$(CXX) $(CXXFLAGS) $@.cc -o$@ ../librocksdb.a -I../include -O2 -std=c++11 $(PLATFORM_LDFLAGS) $(PLATFORM_CXXFLAGS) $(EXEC_LDFLAGS) | ||
$(CXX) $(CXXFLAGS) $@.cc -o$@ ../librocksdb.a -I../include -O2 -std=c++17 $(PLATFORM_LDFLAGS) $(PLATFORM_CXXFLAGS) $(EXEC_LDFLAGS) |
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.
What happens if the examples do not specify a --std? Won't it build with the default for the compiler? And if that is less than 17, what will happen?
If we are requiring that std be set and be at least 17, then that probably also needs to be updated on the README/build instructions. If 17 is the lowest we are supporting (and most/all compilers default to it or higher), then I do not know this line is necessary.
- run: (mkdir build && cd build && cmake -DWITH_GFLAGS=1 .. && make V=1 -j20 && ctest -j20) 2>&1 | .circleci/cat_ignore_eagain | ||
- run: (mkdir build && cd build && cmake -DWITH_GFLAGS=1 .. && make V=1 -j20 && ctest -j20) |
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.
Can you please add a comment (could be in the PR and not the config file) as to why you are dropping the redirection everywhere?
I'm not touching this at this time.
You'll get errors like undefined |
@pdillinger has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
resource_class: 2xlarge | ||
steps: | ||
- pre-steps | ||
- install-gflags | ||
- upgrade-cmake | ||
- run: (mkdir build && cd build && cmake -DWITH_GFLAGS=1 .. && make V=1 -j20 && ctest -j20) 2>&1 | .circleci/cat_ignore_eagain | ||
- run: (mkdir build && cd build && cmake -DWITH_GFLAGS=1 .. && make V=1 -j20 && ctest -j20) |
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.
Should this be -j 32? Every other use of 2xlarge used -j32
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.
This PR is not about parallelism in CircleCI
@@ -338,7 +340,7 @@ jobs: | |||
- pre-steps | |||
- install-gflags | |||
- install-benchmark | |||
- run: (mkdir build && cd build && cmake -DWITH_GFLAGS=1 -DWITH_BENCHMARK=1 .. && make V=1 -j20 && ctest -j20) 2>&1 | .circleci/cat_ignore_eagain | |||
- run: (mkdir build && cd build && cmake -DWITH_GFLAGS=1 -DWITH_BENCHMARK=1 .. && make V=1 -j20 && ctest -j20) |
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.
-j32?
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.
This PR is not about parallelism in CircleCI
resource_class: xlarge | ||
steps: | ||
- pre-steps | ||
- install-benchmark | ||
- run: DEBUG_LEVEL=0 make microbench 2>&1 | .circleci/cat_ignore_eagain | ||
- run: DEBUG_LEVEL=0 make microbench |
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.
No make parallelism?
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.
This PR is not about parallelism in CircleCI
resource_class: large | ||
steps: | ||
- pre-steps | ||
- install-gflags | ||
- run: | ||
name: "Build examples" | ||
command: | | ||
OPT=-DTRAVIS V=1 make -j4 static_lib && cd examples && make -j4 | ../.circleci/cat_ignore_eagain | ||
OPT=-DTRAVIS V=1 make -j4 static_lib && cd examples && make -j4 |
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.
-j 8?
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.
This PR is not about parallelism in CircleCI
CMakeLists.txt
Outdated
if(HAVE_THREAD_LOCAL) | ||
add_definitions(-DROCKSDB_SUPPORT_THREAD_LOCAL) | ||
endif() | ||
# Thread-local is part of C++11 (TODO: clean up this flag) |
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.
C++17 or part of the C++ standard. (It is a bit confusing to say C++11 when we say we support 17 only.
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.
C++11 is factually accurate. I'm pointing out that the check has been effectively obsolete for a long time.
@@ -50,7 +50,7 @@ to build a portable binary, add `PORTABLE=1` before your make commands, like thi | |||
## Supported platforms | |||
|
|||
* **Linux - Ubuntu** | |||
* Upgrade your gcc to version at least 4.8 to get C++11 support. | |||
* Upgrade your gcc to version at least 7 to get C++17 support. |
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.
Should this mention clang?
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.
It's not the default compiler on Ubuntu
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.
Understood that it is not the default compiler. Nowhere in INSTALL does it say we support clang (on any platform) and what the minimum clang version is. Can we add that somewhere?
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.
It's near the top, "We do depend on newer gcc/clang with C++17 support (GCC >= 7, Clang >= 5)."
include/rocksdb/slice.h
Outdated
@@ -44,11 +41,9 @@ class Slice { | |||
/* implicit */ | |||
Slice(const std::string& s) : data_(s.data()), size_(s.size()) {} | |||
|
|||
#ifdef __cpp_lib_string_view | |||
// Create a slice that refers to the same contents as "sv" | |||
/* implicit */ | |||
Slice(std::string_view sv) : data_(sv.data()), size_(sv.size()) {} |
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.
Should this pass in a const std::string_view& ?
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.
OK
@pdillinger has updated the pull request. You must reimport the pull request before landing. |
1 similar comment
@pdillinger has updated the pull request. You must reimport the pull request before landing. |
@pdillinger has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
1 similar comment
@pdillinger has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
This reverts commit fd3e0f4.
Summary: After facebook#9481, we are using newer default compiler for build-format-compatible CircleCI nightly job, which fails on building 2.2.fb.branch branch because it tries to use a pre-compiled libsnappy.a that is checked into the repo (!). This works around that by setting SNAPPY_LDFLAGS=-lsnappy, which is only understood by such old versions. Test Plan: Run check_format_compatible.sh on Ubuntu 20 AWS machine, watch nightly run
Summary: ... seen only in internal clang-analyze runs after #9481 * Mostly, this works around falsely reported leaks by using std::unique_ptr in some places where clang-analyze was getting confused. (I didn't see any changes in C++17 that could make our Status implementation leak memory.) * Also fixed SetBGError returning address of a stack variable. * Also fixed another false null deref report by adding an assert. Also, use SKIP_LINK=1 to speed up `make analyze` Pull Request resolved: #9515 Test Plan: Was able to reproduce the reported errors locally and verify they're fixed (except SetBGError). Otherwise, existing tests Reviewed By: hx235 Differential Revision: D34054630 Pulled By: pdillinger fbshipit-source-id: 38600ef3da75ddca307dff96b7a1a523c2885c2e
Summary: After #9481, we are using newer default compiler for build-format-compatible CircleCI nightly job, which fails on building 2.2.fb.branch branch because it tries to use a pre-compiled libsnappy.a that is checked into the repo (!). This works around that by setting SNAPPY_LDFLAGS=-lsnappy, which is only understood by such old versions. Pull Request resolved: #9517 Test Plan: Run check_format_compatible.sh on Ubuntu 20 AWS machine, watch nightly run Reviewed By: hx235 Differential Revision: D34055561 Pulled By: pdillinger fbshipit-source-id: 45f9d428dd082f026773bfa8d9dd4dad66fc9378
Summary: Drop support for some old compilers by requiring C++17 standard
(or higher). See #9388
First modification based on this is to remove some conditional compilation in slice.h (also
better for ODR)
Also in this PR:
some cases
./random_test: error while loading shared libraries: librocksdb.so.6.29: cannot open shared object file: No such file or directory
)Test Plan: CircleCI config substantially updated.
compilers, to ensure compatibility
around a kernel bug that should not affect anything but Ubuntu 16.
Ubuntu 20.
apt-key add
to fix some apt "couldn't be verified" errorsadd-apt-repository
beforeapt-get update
as manual testing indicated thereverse might not work.
Travis:
AppVeyor:
VS >= 2017
Also local testing with old gflags (out of necessity when using ROCKSDB_NO_FBCODE=1).