1. Jun 13, 2024
    • Louis Dionne's avatar
    • Louis Dionne's avatar
      [libc++] Overhaul the PSTL dispatching mechanism (#88131) · 9540950a
      Louis Dionne authored
      The experimental PSTL's current dispatching mechanism was designed with
      flexibility in mind. However, while reviewing the in-progress OpenMP
      backend, I realized that the dispatching mechanism based on ADL and
      default definitions in the frontend had several downsides. To name a
      few:
      
      1. The dispatching of an algorithm to the back-end and its default
         implementation is bundled together via `_LIBCPP_PSTL_CUSTOMIZATION_POINT`.
         This makes the dispatching really confusing and leads to annoyances
         such as variable shadowing and weird lambda captures in the front-end.
      2. The distinction between back-end functions and front-end algorithms
         is not as clear as it could be, which led us to call one where we meant
         the other in a few cases. This is bad due to the exception requirements
         of the PSTL: calling a front-end algorithm inside the implementation of
         a back-end is incorrect for exception-safety.
      3. There are two levels of back-end dispatching in the PSTL, which treat
         CPU backends as a special case. This was confusing and not as flexible
         as we'd like. For example, there was no straightforward way to dispatch
         all uses of `unseq` to a specific back-end from the OpenMP backend,
         or for CPU backends to fall back on each other.
      
      This patch rewrites the backend dispatching mechanism to solve these
      problems, but doesn't touch any of the actual implementation of
      algorithms. Specifically, this rewrite has the following
      characteristics:
      
      - There is a single level of backend dispatching, however partial backends can
        be stacked to provide a full implementation of the PSTL. The two-level dispatching
        that was used for CPU-based backends is handled by providing CPU-based basis 
        operations as simple helpers that can easily be reused when defining any PSTL 
        backend.
      
      - The default definitions for algorithms are separated from their dispatching logic.
      
      - The front-end is thus simplified a whole lot and made very consistent
        for all algorithms, which makes it easier to audit the front-end for
        things like exception-correctness, appropriate forwarding, etc.
      
      Fixes #70718
      9540950a
    • Rodrigo Salazar's avatar
      [libcxx] Correct and clean-up filesystem operations error_code paths (#88341) · 11399028
      Rodrigo Salazar authored
      3 error_code related cleanups/corrections in the std::filesystem
      operations functions.
      
      1. In `__copy`, the `ec->clear()` is unnecessary as `ErrorHandler` at
      the start of each function clears the error_code as part of its
      initialization.
      
      2. In `__copy`, in the recursive codepath we are not checking the
      error_code result of `it.increment(m_ec2)` immediately after use in the
      for loop condition (and we aren't checking it after the final increment
      when we don't enter the loop).
      
      3. In `__weakly_canonical`, it makes calls to `__canonical` (which
      internally uses OS APIs implementing POSIX `realpath`) and we are not
      checking the error code result from the `__canonical` call. Both
      `weakly_canonical` and `canonical` are supposed to set the error_code
      when underlying OS APIs result in an error
      (https://eel.is/c++draft/fs.err.report#3.1). With this change we
      propagate up the error_code from `__canonical` caused by any underlying
      OS API failure up to the `__weakly_canonical`. Essentially, if
      `__canonical` thinks an error code should be set, then
      `__weakly_canonical` must as well. Before this change it would be
      throwing an exception in the non-error_code form of the function when
      `__canonical` fails, while not setting the error code in the error_code
      form of the function (an inconsistency).
      
      Added a little coverage in weakly_canonical.pass.cpp for the error_code
      forms of the API that was missing. Though I am lacking utilities in
      libcxx testing to add granular testing of the failure scenarios (like
      forcing realpath to fail for a given path, as it could if you had
      something like a flaky remote filesystem).
      11399028
    • Martin Storsjö's avatar
      [libcxx] [ci] Update Clang for Windows jobs to 18.1.x (#95228) · bce24987
      Martin Storsjö authored
      Pick the latest version available in Chocolatey (18.1.6) and llvm-mingw
      (20240606, which includes LLVM 18.1.7).
      
      Also add the flag "--allow-downgrade" when installing a specific version
      of LLVM. If the preinstalled version is higher than the requested one,
      Chocolatey would otherwise error out when requesting installing a lower
      version. This will avoid errors in the future, if the runner image comes
      preinstalled with a newer version of LLVM.
      
      (This currently seems to happen with a recent version of the GitHub
      Actions runner image, version 20240610.1.0 has LLVM 18.1.6 already
      preinstalled, and will error out when trying to install the 17.0.6
      version that we previously requested.)
      bce24987
    • Simon Pilgrim's avatar
      1216e704
  2. Jun 12, 2024