Skip to content

Conversation

vasild
Copy link
Contributor

@vasild vasild commented Nov 20, 2020

Use std::filesystem::rename() instead of std::rename(). We rely on the
destination to be overwritten if it exists, but std::rename()'s behavior
is implementation-defined in this case.

@maflcko
Copy link
Member

maflcko commented Nov 20, 2020

Please update doc/dependencies to gcc 8 (from 7), as std::fs is not included in gcc 7

Edit: And clang-7

@vasild
Copy link
Contributor Author

vasild commented Nov 20, 2020

Updated. I am not sure if this PR shouldn't be put on hold until CentOS 23 starts shipping with a recent enough compiler?

@maflcko
Copy link
Member

maflcko commented Nov 20, 2020

Maybe adding -lstdc++fs to the build flags via configure by default fixes the compile errors?

@laanwj
Copy link
Member

laanwj commented Nov 23, 2020

Concept ACK! That's another WIN32 specific hack less.

But yes it's probably going to be a looong time before this can be merged.

@vasild
Copy link
Contributor Author

vasild commented Nov 23, 2020

I will leave this as is (open, with failing CI) until the compilers we support catch up with C++17 filesystem support.

@DrahtBot
Copy link
Contributor

DrahtBot commented Nov 23, 2020

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Conflicts

No conflicts as of last run.

@vasild
Copy link
Contributor Author

vasild commented Nov 24, 2020

Removed the changes to doc/dependencies.md as those will be carried by #20460 (bumping minimum compiler version requirements), also they caused conflicts.

@luke-jr
Copy link
Member

luke-jr commented Nov 25, 2020

:>Removed the changes to doc/dependencies.md as those will be carried by #20460 (bumping minimum compiler version requirements), also they caused conflicts.

You should probably rebase this PR on top of that then...

@vasild
Copy link
Contributor Author

vasild commented Nov 25, 2020

@luke-jr that's right, but #20460 is just an issue/idea, without a patch (yet)...

@laanwj
Copy link
Member

laanwj commented Dec 3, 2020

I will leave this as is (open, with failing CI) until the compilers we support catch up with C++17 filesystem support.

I don't think labeling this as "waiting for author" is quite right.

@laanwj laanwj added this to the Future milestone Dec 3, 2020
@maflcko
Copy link
Member

maflcko commented Dec 3, 2020

This pull is waiting for the author to rebase on the pull that fixes #20460 . Is there a better label?

@vasild
Copy link
Contributor Author

vasild commented Dec 3, 2020

There is no fix for the issue #20460 yet.

This PR is waiting for newer compilers to hit the master branch (docs and ci).

fanquake added a commit that referenced this pull request Sep 28, 2021
…irements

182de7b ci: update minimum compiler requirements for std::filesystem (fanquake)
04f5baf doc: update minimum compiler requirements for std::filesystem (fanquake)

Pull request description:

  This increases the minimum required compiler versions to Clang 7 and GCC 8.1. This has been split out of #20744 (migration to `std::filesystem`), as it's also a requirement for some other changes, such as #20452 or #20457 which want to make use of `std::from_chars`. As well as #20435, which is also `std::filesystem` related. Given that the `std::filesystem` changes are moving ahead, splitting out this change to let other PRs take advantage of the new requirements seems worthwhile.

  Clang 7 has been available in Debian since [Stretch (oldoldstable)](https://packages.debian.org/stretch/clang-7) and in Ubuntu since [Bionic (18.04)](https://packages.ubuntu.com/bionic-updates/clang-7). GCC 8 has been available in Debian since [Buster (oldstable)](https://packages.debian.org/buster/gcc) and in Ubuntu since [Bionic (18.04)](https://packages.ubuntu.com/bionic/gcc-8). CentOS 8 also packages GCC 8.

  The CI changes here give us one build with GCC 8, and another using Clang 7 on top of libc++.

  Note that the minimum required libc++ in dependencies.md is unchanged as, at least for `<filesystem>`, and the `*_chars` use cases, libc++ 7 [should be sufficient](https://en.cppreference.com/w/cpp/compiler_support/17).

  I've tested that building `<filesystem>` code using Clang 7 & libc++ works. i.e `clang++-7 -std=c++17 fs.cpp -stdlib=libc++ -lc++fs`. Also that building `<filesystem>` code with Clang 7 and libstdc++ 8 works. i.e `clang++-7 -std=c++17  fs.cpp -lstdc++fs`.

ACKs for top commit:
  MarcoFalke:
    review ACK 182de7b

Tree-SHA512: 5bc151c4be58005711eed6bd8a091f3417f75a0218c11c08cffff9d749edadd965726bb7856a8e693e96e69ed0596989cda1aac4b29fb6d30705b1687a5b3363
@fanquake
Copy link
Member

There is no fix for the issue #20460 yet.

If you want, you can now rebase on top of #20744.

@maflcko
Copy link
Member

maflcko commented Sep 28, 2021

If you want, you can now rebase on top of #20744.

I think a rebase is not (strictly) needed, just a (force) push to re-trigger CI.

@fanquake
Copy link
Member

I think a rebase is not (strictly) needed, just a (force) push to re-trigger CI.

Sure, but this can't be merged before #20744 in any case.

@vasild
Copy link
Contributor Author

vasild commented Sep 28, 2021

166b1542d7...99b151df9c: rebase

This PR is waiting for newer compilers to hit the master branch

#23060 did just that (merged).

I don't think this PR depends on #20744. @fanquake, why do you think this PR cannot be merged before #20744?

@fanquake
Copy link
Member

I don't think this PR depends on #20744. @fanquake, why do you think this PR cannot be merged before #20744?

Because we are either using boost::filesystem or std::filesystem. We're not going to have the repo exist in some awkward middle ground where we are using both. In any case, using std::filesystem is not necessarily straight forward, and likely requires the changes in #22937 before it can be used.

@fanquake
Copy link
Member

Another reason is that this doesn't have any build system support for properly using std::filesystem, and the additional linker flags that may be needed, i.e 7219288.

Copy link
Contributor

@ryanofsky ryanofsky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Conditional code review ACK 99b151d if this is rebased and .string() is replaced by .native() (see comment below).

This is just a review of the c++ code, disregarding build issues. IIUC the new rename function may not be callable on all platforms without some of the build changes in #20744.

Use std::filesystem::rename() instead of std::rename(). We rely on the
destination to be overwritten if it exists, but std::rename()'s behavior
is implementation-defined in this case.
@vasild
Copy link
Contributor Author

vasild commented Nov 2, 2021

99b151df9c...a9ab42ca97: rebase due to conflicts and pick up a suggestion.

This now depends on #20744 in two ways:

  • Build system changes to make it compile on all platforms
  • Assumes that our custom fs::path is std::filesystem::path (passes a variable of type fs::path to std::filesystem::rename()).

Invalidates ACK from @ryanofsky (conditional)

Copy link
Contributor

@ryanofsky ryanofsky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code review ACK a9ab42c assuming #20744 is merged first (it requires #20744 to build)

@DrahtBot
Copy link
Contributor

DrahtBot commented Feb 3, 2022

🐙 This pull request conflicts with the target branch and needs rebase.

Want to unsubscribe from rebase notifications on this pull request? Just convert this pull request to a "draft".

@fanquake
Copy link
Member

I've rebased this in #24308.

@fanquake
Copy link
Member

Going to close this in favour of #24308.

@fanquake fanquake closed this Feb 10, 2022
@vasild vasild deleted the rename branch February 10, 2022 13:24
maflcko pushed a commit that referenced this pull request Feb 11, 2022
ee822d8 util: use stronger-guarantee rename method (Vasil Dimov)

Pull request description:

  Use std::filesystem::rename() instead of std::rename(). We rely on the
  destination to be overwritten if it exists, but std::rename()'s behavior
  is implementation-defined in this case.

  This is a rebase of #20435 by vasild.

ACKs for top commit:
  MarcoFalke:
    review ACK ee822d8
  hebasto:
    Approach ACK ee822d8.
  vasild:
    ACK ee822d8

Tree-SHA512: 8f65f154d235c2704f18008d9d40ced3c5d84e4d55653aa70bde345066b6083c84667b5a2f4d69eeaad0bec6c607645e21ddd2bf85617bdec4a2e33752e2059a
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Feb 11, 2022
ee822d8 util: use stronger-guarantee rename method (Vasil Dimov)

Pull request description:

  Use std::filesystem::rename() instead of std::rename(). We rely on the
  destination to be overwritten if it exists, but std::rename()'s behavior
  is implementation-defined in this case.

  This is a rebase of bitcoin#20435 by vasild.

ACKs for top commit:
  MarcoFalke:
    review ACK ee822d8
  hebasto:
    Approach ACK ee822d8.
  vasild:
    ACK ee822d8

Tree-SHA512: 8f65f154d235c2704f18008d9d40ced3c5d84e4d55653aa70bde345066b6083c84667b5a2f4d69eeaad0bec6c607645e21ddd2bf85617bdec4a2e33752e2059a
@bitcoin bitcoin locked and limited conversation to collaborators Feb 10, 2023
@maflcko maflcko removed this from the Future milestone Jul 23, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants