-
Notifications
You must be signed in to change notification settings - Fork 72
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 ability to build with Clang #507
base: main
Are you sure you want to change the base?
Add ability to build with Clang #507
Conversation
dac18fc
to
2108d8a
Compare
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.
Thank you for your great work. I'm not completely done with the review yet and there will probably be more comments soon, but I'll post these so you can start fixing them.
I will leave a few comments that cannot be attached to individual files:
-
There are no binding-tests for Clang and macOS Apple Clang. And there may be problems similar to those that caused the Fix CMakeLists.txt, macOS guide and refactor .gitignore #492, I mean DYLD_PATH on macOS.
-
We keep a short commit history. Pls, squash commits to some parts. I propose squash into 4 like this: CI, src-fixing, CMake, README.
-
You made great descriptions for all commits, pls copy them in some way to PR description. If someone else looks at the PR, they don't look for commit descriptions, and it's also a good way to present the result.
Yes, it's branch protection rules. I left a comment about it in PR#499 |
Oh, I didn't notice there are 2 pull request, is 499 needed at all if this one exists? I suggest closing it and continuing only in this one. |
There's 3 pull requests. 499 addresses Clang on Linux, 500 -- LLVM Clang on macOS, and this PR addresses Apple Clang. |
I don't like that they are tightly coupled in CI. It seems to me that when all the fixes are already in place, it's easier to do and review everything together, rather than merge one by one, changing the architecture in the process. And do we really need a release without a pip-package on MacOS? |
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.
The second part of review.
As for constructors which is in a lot of comments. I heard about the performance of the aggregates from colleagues at work, and constantly. For example, that's why it is not recommended to use a std::pair, for some reason they added a constructor there and a regular handwritten structure will be faster. But I can't find normal proofs on the Internet.
The only thing I can do is to define constructors conditionnally -- only when aggregate initialization isn't availible. |
I don't quite understand why you can't just use brace-initialization everywhere? |
Brace-initialization calls constructor. It won't help if we want to get rid of constructors. |
It's not true? |
In terms of this page on cppreference, apparently, you suggest to use direct-list-initialization (2 variant) instead of copy-list-initialization (7 variant). Maybe this will work -- I'll check it later. But in most cases we have
|
Not working link
Use |
https://en.cppreference.com/w/cpp/language/list_initialization |
be21b26
to
eb10e2e
Compare
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.
clang-tidy made some suggestions
6fc2ab3
to
1bd7606
Compare
Due to ac2ad57. |
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.
clang-tidy made some suggestions
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.
clang-tidy made some suggestions
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.
clang-tidy made some suggestions
34a9520
to
859b5c0
Compare
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 for the corrections, it looks much better. I left a couple of minor comments and questions. Of the possible major edits, only replacing action with a composition in CI-tests, if it is possible to catch an incorrect configuration.
now I think that we should supply a pip package built with gcc even on macos, but that's not your concern anymore, maybe I'll add it myself |
3096622
to
1b9b4af
Compare
1b9b4af
to
a39e86e
Compare
20ad501
to
4750d2b
Compare
4750d2b
to
84c6dc9
Compare
33461cf
to
9e563fc
Compare
a9dff75
to
be00164
Compare
Could you describe in more detail what error is happening and why, because I didn't quite understand what they were writing in the issue without context. The solution seems ok, but I would leave a comment on why we added CC export here, unlike other places. |
The problem is, CMake somehow cannot locate |
be00164
to
d6d0eeb
Compare
Check this answer https://stackoverflow.com/a/77801270/16427597. CMake has variable to set path to |
This way I need to hard-code |
OK, then i think a comment will be enough |
- Add `set -e` in build.sh to stop build process on error - Add SYSTEM property to all `add_subdirectory` commands that add external dependencies to avoid compiler warnings that aren't related to Desbordante - Disable alloc-dealloc-mismatch check as it's false positive on Ubuntu (see comment in CMakeLists.txt) - Limit UB sanitizer "function" check to only our code when building with Clang on macOS (see comment in CMakeLists.txt) - Update googletest version from 1.13.0 to 1.14.0, because 1.13.0 produces "narrowing conversion" warning due to a bug (issue #4206, google/googletest#4206) when building with Clang. This bug was fixed in 1.14.0 (commit 3044657, google/googletest@3044657) - Disable deprecated-declaration warning on Clang-18 (see comment in CMakeLists.txt)
d6d0eeb
to
50b2ba3
Compare
50b2ba3
to
e795576
Compare
Fix Clang warnings and UB and ADDRESS sanitizer errors: - Replace INSTANTIATE_TEST_CASE_P, which is deprecated, with INSTANTIATE_TEST_SUITE_P in NDVerifier tests - Mark unused fields as [[maybe_unused]]. Use MAYBE_UNUSED_PRIVATE_FIELD macro, because GCC produces warning when [[maybe_unused]] attribute is present, and Clang -- when it isn't. (see comment in util/maybe_unused_on_clang.h) - Convert double literals to model::DoubleType and model::IntType explicitly in tests/test_types.cpp - Check that column is numeric *before* casting it to INumericType in DataStats::GetMedianAD - Don't process empty vector in GetPartition in gfd_validation.cpp (immediately return 0) - Disable tests causing float-to-long cast when result is infinity in tests/test_types.cpp - Use std::chrono::high_resolution_clock instead of std::chrono::_V2::high_resolution_clock in fastod/util/timer.h, because symbol versioning is gcc-specific - Use &Insert instead of this->Insert in KDTree constructor - Use system_clock everywhere instead of mix of system_clock and high_resolution_clock in Cords::ExecuteInternal - Add fallback behaviour in hymd::utility::MdLessPairs if operator <=> for vectors isn't availible - Add explicit #include <string> in exceptions.h - Add template keyword in CanonicalOD::IsValid to avoid most vexing parse (see cross-platform guide in wiki) - Explicitly cast kSeed_ to result_type in des/rng.h, because result_type of mt19937 is always 32-bit and it's not bound to some built-in integral type - Use reverse iterators to traverse set in reverse order, instead of strange behaviour with direct iterators in egfd_validation.cpp/ReverseConstruction
Add information about other compilers in README. Extra build instructions (Linux & Clang, macOS & LLVM CLang, macOS & GCC) are now moved to wiki
- Use simple RAII wrapper of std::thread instead of std::jthread when the latter isn't implemented - Use custom implementations of std::bitset::_Find_first and _Find_next when gcc intrinsics aren't availible. Also, implement some utility functions using custom FindFirst and FindNext
Don't use features, which behaviour is implementation-defined and differ in libstdc++ and libc++. Instead use "stable" versions: - sort pairs by value if frequencies are equal in Cords' FrequencyHandler::InitFrequencyHandler - Use std::stable_sort instead of std::sort in DES::GetRandomPopulationInDomainds - Use std::set instead of std::unordered_set in differential_functions.cpp/GetRandIndices - Use std::stable_sort in PDFTane::CalculatePFDError instead of std::sort
Add tests for Clang on Linux, LLVM Clang on macOS and Apple Clang on macOS. Also, bump boost version used in CI, as 1.8.10 produces an error on macOS with LLVM Clang. Here it's said that boost 1.85.0 works fine: bambulab/BambuStudio#3957
Aggregate initialization isn't availible on Apple Clang. Use direct-list-initialization instead wherewer possible: - Split::IndexSearchSpace - MinPickerLattice::AddGeneralizations - OneByOnePicker::AddGeneralizations - md_lattice/Specializer - MdLattice::GetAll - hymd::LhsNode - ::BatchValidator - SimilarityData::Creator - BatchValidator::MultiCardPartitionElementProvider - MD::GetDescription - order::GetIndexedByteData - python_bindings::BindOd - model::DD - dd::DistancePositionListIndex - dc::DCCandidate Define constructor elsewhere: - test_algo_interfaces/KeysTestParams - test_dc_verifier/DCTestParams - test_ind_verifier/INDVerifierTestConfig - test_pfdtane/PFDTaneValidationParams - test_tane_afd_measures/TaneValidationParams - /PdepSelfValidationParams - test_typed_column_data/TypeParsingParams
Set libraries download in alphabetical order. Bump actions/checkout to v4. Change run_tests matrix to more readable. Add env field to avoid code duplications inside job. resolves Desbordante#512
Add `export CC=...`, because otherwise CMake fails to locate a tool for scanning C++ module dependencies (no matter we don't use modules): emscripten-core/emscripten#22305
e795576
to
18d0748
Compare
Make Desbordante be able to be built with Clang on Linux and LLVM/Apple CLang on macOS:
build.sh
andCMakeLists.txt
(bump versions of some libraries and workaround some Clang bugs)README.md
See commit descriptions for more information