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

C++20 compatibility: Use std::allocator_traits instead of direct members of std::allocator #44

Open
wants to merge 1 commit into
base: winport
Choose a base branch
from

Conversation

lenards-speechmatics
Copy link

Usage of direct members of std::allocator got deprecated in C++17 and
removed in C++20. The preferred usage is through std::allocator_traits.

Usage of direct members of std::allocator got deprecated in C++17 and
removed in C++20. The preferred usage is through std::allocator_traits.
@lenards-speechmatics lenards-speechmatics changed the title Use std::allocator_traits instead of direct members of std::allocator C++20 compatibility: Use std::allocator_traits instead of direct members of std::allocator Aug 23, 2022
@lenards-speechmatics
Copy link
Author

Impact: This change makes the openfst headers we use to be C++20 compatible, allowing us to build our executables in C++20 mode.

I did not check if this change allows building openfst in C++20 mode, or if all of the headers are compatible.

@kkm000
Copy link
Owner

kkm000 commented Aug 30, 2022

Thanks. Generally, we try to minimize changes w.r.t. mainline, but you seem to have a real problem that needs attention. Are you using libfst with Kaldi? This is important, since Kaldi is compiled with the latest pre-C++17 version, and is incompatible with a sudden command line change in a binary in a 1.7.x minor version (ugh!). There were possible incompatible changes in the API too. If you are decoupled from Kaldi, that should be less of a deal, we may roll the winport branch forward—these or similar changes might have been in the mainline, which is now C++17-only. BTW, the original branch is either current or nearly so.

If you are decoupled from Kaldi, and can upgrade to a higher FST version, maybe we should better apply the patch later to a higher version (edited: I used "later" in the sense "to a later version," not "in a couple months" :))? There are larger unported changes, and that would make maintenance of this particular change easier for us.

I did not check if this change allows building openfst in C++20 mode, or if all of the headers are compatible.

We have both CMake and limited VS build. You did verify that it build out of the box by default, didn't you? The latest ported builds defaults to C++11 (upstream's decision, not ours).

@jtrmal
Copy link
Collaborator

jtrmal commented Sep 1, 2022 via email

@lenards-speechmatics
Copy link
Author

in my opinion it's not worth the time to port the old openfst to a new
compiler standard, while there are actual new openfst releases compliant
with the new standard. It would just make a mess in everything -- OpenFST
is mostly templated, i.e. you would need to switch to C++20 in all of the
projects using it.

My patch should retain C++11/14/17 compatibility while adds C++20 compatibility. I confirmed compiling with the unmodified CMakeLists.txt on Linux (compiles in C++11 mode). Testing on Windows is in progress.

Upstream openfst switched to C++17. It is mostly C++20 compatible, but they missed the removal of hinted allocation in std::allocator. I submitted my patch for that on their forum https://www.openfst.org/twiki/bin/view/Forum/FstForum#Patch%20to%20make%20headers%20C++20%20comp.

@jtrmal
Copy link
Collaborator

jtrmal commented Sep 1, 2022 via email

@lenards-speechmatics
Copy link
Author

I confirm that this branch compiles on VS 2022 (MSVC 19.32.31332.0) with the unmodified CMakeLists.txt file, so in C++11 mode.

I do not propose to make openfst compile on any later standard version, I just want to make the headers to be C++20 compatible (in addition to C++11/14/17 compatible), so downstream users can use a later standard version.

@jtrmal
Copy link
Collaborator

jtrmal commented Sep 1, 2022 via email

@kkm000
Copy link
Owner

kkm000 commented Sep 2, 2022

@lenards-speechmatics, so, the decision remains where in the history to apply your patch. The winport tip is currently at 1.7.2, and this is why the patch is large. The question is, what is the lowest version that you can use? Kaldi compiles with C++20 but cannot use FST past 1.7.4 or .5, I believe. But if you're not dependent on Kaldi, it can be as recent as there is.

What can be tricky is porting your patch up. They've shacken up the codebase at least two times since 1.7.2. The higher is the version you are able to use, the better. Call your lowest number please! :)

@kkm000 kkm000 self-assigned this Sep 2, 2022
@kkm000 kkm000 added the feedback-needed Feedback in a discussion has been requested, blocked label Sep 2, 2022
@lenards-speechmatics
Copy link
Author

We do use kaldi. For 1.8.2R1 I have a smaller patch for upstream on their forum: https://www.openfst.org/twiki/bin/view/Forum/FstForum#Patch%20to%20make%20headers%20C++20%20comp, but we can't switch to that any time soon. I also don't know if that is a correct channel for upstream openfst contributions.

What would be the branch to create my PR against if I want to target the latest kaldi-compatible version of openfst?

@jtrmal
Copy link
Collaborator

jtrmal commented Sep 6, 2022

quick comment -- just realized that we might need to both merge this here and have patch in kaldi, because the kaldi patch is not applied on windows.

@kkm000
Copy link
Owner

kkm000 commented Sep 12, 2022

@jtrmal, I seem to have lost track of this, what kaldi patch? We have a standard build for Windows? Is this that old Perl script which creates VS project files, or CMake? I admit I've never built Kaldi on Windows except by picking relevant source files into a static lib.

@jtrmal
Copy link
Collaborator

jtrmal commented Sep 13, 2022 via email

@kkm000
Copy link
Owner

kkm000 commented Sep 13, 2022

@jtrmal, Ah, got it! I'd like to implement a clean CMake-based build for Kaldi, that would support Windows, too. If only we had two of me. At least two of me! :))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feedback-needed Feedback in a discussion has been requested, blocked
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants