[libcxx-commits] [libcxx] [libc++] remove yield from atomic::wait (PR #120012)

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Fri Jan 10 10:28:42 PST 2025


ldionne wrote:

After looking into the CI issues more (https://github.com/llvm/llvm-project/actions/runs/12432576208/job/34712280743?pr=120012), the problem is this:

```
# .---command stderr------------
  # | In file included from /__w/llvm-project/llvm-project/libcxx/test/benchmarks/atomic_wait_N_waiter_N_notifier.bench.cpp:11:
  # | /__w/llvm-project/llvm-project/libcxx/test/benchmarks/atomic_wait_helper.h:33:43: error: ambiguous use of internal linkage declaration 'PTHREAD_EXPLICIT_SCHED' defined in multiple modules [-Werror,-Wmodules-ambiguous-internal-linkage]
  # |    33 |     pthread_attr_setinheritsched(&attr_t, PTHREAD_EXPLICIT_SCHED);
  # |       |                                           ^
  # | /usr/include/pthread.h:129:33: note: expanded from macro 'PTHREAD_EXPLICIT_SCHED'
  # |   129 | #define PTHREAD_EXPLICIT_SCHED  PTHREAD_EXPLICIT_SCHED
  # |       |                                 ^
  # | /usr/include/pthread.h:128:3: note: declared here
  # |   128 |   PTHREAD_EXPLICIT_SCHED
  # |       |   ^
  # | /usr/include/pthread.h:128:3: note: declared here in module 'std.thread.support'
  # |   128 |   PTHREAD_EXPLICIT_SCHED
  # |       |   ^
  # | 1 error generated.
  # `-----------------------------
```

For context, we have the following in our `modulemap`:

```
module thread {
  ...

  module support {
    header "__thread/support.h"
    export *
  }
  module support_impl {
    textual header "__thread/support/c11.h"
    textual header "__thread/support/external.h"
    textual header "__thread/support/pthread.h" // this includes <pthread.h>
    textual header "__thread/support/windows.h"
  }

  header "thread"
  export *
}
```

So we're basically including `<pthread.h>` into the `std.thread.support` module via a transitive chain of textual includes. That means that, on a platform where `/usr/include` is *not* modularized, we're textually including `<pthread.h>` into `std.thread.support` and basically exporting everything it declares (including the `PTHREAD_EXPLICIT_SCHED` macro) from `std.thread.support`. That's wrong, since we shouldn't be exporting stuff that we don't own.

I'm not sure how to fix that. In some sense, I'd like to be able to say this:

```
module support {
    header "__thread/support.h"
    export "std::__libcpp_mutex_t"
    export "std::__libcpp_timespec_t"
    etc...
}
```

but that's not how it works. @ian-twilightcoder do you know how we can solve this problem?

https://github.com/llvm/llvm-project/pull/120012


More information about the libcxx-commits mailing list