Skip to content

Update semaphore-compat to 2.0.0.0 to fix #9993 - #11628

Merged
mergify[bot] merged 1 commit into
haskell:masterfrom
wz1000:wip/semaphore-v2
May 27, 2026
Merged

Update semaphore-compat to 2.0.0.0 to fix #9993#11628
mergify[bot] merged 1 commit into
haskell:masterfrom
wz1000:wip/semaphore-v2

Conversation

@wz1000

@wz1000 wz1000 commented Mar 17, 2026

Copy link
Copy Markdown
Contributor

Update to semaphore-compat 2.0.0 fixing #9993 and https://gitlab.haskell.org/ghc/ghc/-/issues/25087

semaphore-compat now uses a unix sockets based implementation.

Semaphore identifiers are now versioned, and we can really on the versioning
scheme to detect semaphore version mismatch with GHC and fallback gracefully if
possible.

GHC patch: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/15729

After the GHC patch lands, it will include a "Semaphore version" field in its
settings file/--info output that we can use to guide Cabal behaviour.

If this field does not exist (and ghc is 9.8+), then we assume it uses version v1 of the protocol
and this triggers a graceful degradation of behaviour to -jN without semaphore based coordination.

See also

semaphore-compat MR: https://gitlab.haskell.org/ghc/semaphore-compat/-/merge_requests/8
ghc-proposals change: ghc-proposals/ghc-proposals#673

Comment thread cabal.project Outdated
@wz1000
wz1000 force-pushed the wip/semaphore-v2 branch 3 times, most recently from 67769ee to 98685dd Compare March 19, 2026 04:30
Comment thread changelog.d/semaphore-version-compat.md Outdated
Comment thread Cabal/src/Distribution/Simple/Compiler.hs Outdated
Comment thread cabal-install/src/Distribution/Client/JobControl.hs Outdated
Comment thread cabal-install/src/Distribution/Client/JobControl.hs Outdated
Comment thread changelog.d/semaphore-version-compat.md Outdated
@Mikolaj

Mikolaj commented Apr 9, 2026

Copy link
Copy Markdown
Member

Is this needed for GHC 10 and so for Cabal 3.18? If so, how can we get this merged now?

@wz1000
wz1000 force-pushed the wip/semaphore-v2 branch 4 times, most recently from cea0774 to 2758155 Compare May 12, 2026 11:55
bgamari pushed a commit to ghc/ghc that referenced this pull request May 13, 2026
On Linux and other POSIX platforms, GHC's -jsem jobserver client now
speaks v2 of the semaphore-compat protocol, which uses Unix domain
sockets in place of POSIX named semaphores. This avoids the libc-ABI
issues that affected the old implementation. Windows is unaffected
and continues to use the v1 protocol (Win32 named semaphores); its
reported protocol version remains v1.

When GHC receives a -jsem name whose protocol version it does not
support, it emits a -Wsemaphore-version-mismatch warning and falls
back to -j<N> rather than crashing. ghc --info exposes the supported
version in a new "Semaphore version" entry so cabal-install can detect
a mismatch before invoking GHC.

Users on a cabal-install that predates the v2 update will continue to
build successfully on Linux/POSIX, but will lose the cross-process
-jsem coordination and fall back to -j<N> per GHC invocation. Users
must upgrade to a cabal-install that supports protocol v2 to recover
full parallelism.

Also fix a leak in cleanupSem (#27253): cleanupSem used to snapshot
heldTokens and release them before killing the loop, while the loop's
in-flight acquire/release children could still be mutating it.
Cleanup now runs inside the loop's own exit handler, after draining
the active child via a new activeChild TVar, so the snapshot has no
concurrent mutator.

See also:
  - GHC proposal amendment:  ghc-proposals/ghc-proposals#673
  - cabal-install patch:     haskell/cabal#11628
  - semaphore-compat MR:     https://gitlab.haskell.org/ghc/semaphore-compat/-/merge_requests/8

Bump semaphore-compat submodule to 2.0.0

Fixes #25087 and #27253
@wz1000
wz1000 force-pushed the wip/semaphore-v2 branch from 2758155 to 067e12c Compare May 13, 2026 13:01
bgamari pushed a commit to ghc/ghc that referenced this pull request May 19, 2026
On Linux and other POSIX platforms, GHC's -jsem jobserver client now
speaks v2 of the semaphore-compat protocol, which uses Unix domain
sockets in place of POSIX named semaphores. This avoids the libc-ABI
issues that affected the old implementation. Windows is unaffected
and continues to use the v1 protocol (Win32 named semaphores); its
reported protocol version remains v1.

When GHC receives a -jsem name whose protocol version it does not
support, it emits a -Wsemaphore-version-mismatch warning and falls
back to -j<N> rather than crashing. ghc --info exposes the supported
version in a new "Semaphore version" entry so cabal-install can detect
a mismatch before invoking GHC.

Users on a cabal-install that predates the v2 update will continue to
build successfully on Linux/POSIX, but will lose the cross-process
-jsem coordination and fall back to -j<N> per GHC invocation. Users
must upgrade to a cabal-install that supports protocol v2 to recover
full parallelism.

Also fix a leak in cleanupSem (#27253): cleanupSem used to snapshot
heldTokens and release them before killing the loop, while the loop's
in-flight acquire/release children could still be mutating it.
Cleanup now runs inside the loop's own exit handler, after draining
the active child via a new activeChild TVar, so the snapshot has no
concurrent mutator.

See also:
  - GHC proposal amendment:  ghc-proposals/ghc-proposals#673
  - cabal-install patch:     haskell/cabal#11628
  - semaphore-compat MR:     https://gitlab.haskell.org/ghc/semaphore-compat/-/merge_requests/8

Bump semaphore-compat submodule to 2.0.0

Fixes #25087 and #27253
@wz1000
wz1000 force-pushed the wip/semaphore-v2 branch 2 times, most recently from d49fb8c to ee96ef5 Compare May 19, 2026 09:05
bgamari pushed a commit to ghc/ghc that referenced this pull request May 19, 2026
On Linux and other POSIX platforms, GHC's -jsem jobserver client now
speaks v2 of the semaphore-compat protocol, which uses Unix domain
sockets in place of POSIX named semaphores. This avoids the libc-ABI
issues that affected the old implementation. Windows is unaffected
and continues to use the v1 protocol (Win32 named semaphores); its
reported protocol version remains v1.

When GHC receives a -jsem name whose protocol version it does not
support, it emits a -Wsemaphore-version-mismatch warning and falls
back to -j<N> rather than crashing. ghc --info exposes the supported
version in a new "Semaphore version" entry so cabal-install can detect
a mismatch before invoking GHC.

Users on a cabal-install that predates the v2 update will continue to
build successfully on Linux/POSIX, but will lose the cross-process
-jsem coordination and fall back to -j<N> per GHC invocation. Users
must upgrade to a cabal-install that supports protocol v2 to recover
full parallelism.

Also fix a leak in cleanupSem (#27253): cleanupSem used to snapshot
heldTokens and release them before killing the loop, while the loop's
in-flight acquire/release children could still be mutating it.
Cleanup now runs inside the loop's own exit handler, after draining
the active child via a new activeChild TVar, so the snapshot has no
concurrent mutator.

See also:
  - GHC proposal amendment:  ghc-proposals/ghc-proposals#673
  - cabal-install patch:     haskell/cabal#11628
  - semaphore-compat MR:     https://gitlab.haskell.org/ghc/semaphore-compat/-/merge_requests/8

Bump semaphore-compat submodule to 2.0.0

Fixes #25087 and #27253
bgamari pushed a commit to ghc/ghc that referenced this pull request May 19, 2026
On Linux and other POSIX platforms, GHC's -jsem jobserver client now
speaks v2 of the semaphore-compat protocol, which uses Unix domain
sockets in place of POSIX named semaphores. This avoids the libc-ABI
issues that affected the old implementation. Windows is unaffected
and continues to use the v1 protocol (Win32 named semaphores); its
reported protocol version remains v1.

When GHC receives a -jsem name whose protocol version it does not
support, it emits a -Wsemaphore-version-mismatch warning and falls
back to -j<N> rather than crashing. ghc --info exposes the supported
version in a new "Semaphore version" entry so cabal-install can detect
a mismatch before invoking GHC.

Users on a cabal-install that predates the v2 update will continue to
build successfully on Linux/POSIX, but will lose the cross-process
-jsem coordination and fall back to -j<N> per GHC invocation. Users
must upgrade to a cabal-install that supports protocol v2 to recover
full parallelism.

Also fix a leak in cleanupSem (#27253): cleanupSem used to snapshot
heldTokens and release them before killing the loop, while the loop's
in-flight acquire/release children could still be mutating it.
Cleanup now runs inside the loop's own exit handler, after draining
the active child via a new activeChild TVar, so the snapshot has no
concurrent mutator.

See also:
  - GHC proposal amendment:  ghc-proposals/ghc-proposals#673
  - cabal-install patch:     haskell/cabal#11628
  - semaphore-compat MR:     https://gitlab.haskell.org/ghc/semaphore-compat/-/merge_requests/8

Bump semaphore-compat submodule to 2.0.0

Fixes #25087 and #27253

@sheaf sheaf left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Yes, this looks good.

Personally I would like to avoid the "normal parallelism control" phrasing (that predates this PR) as I think we can be more specific about what we are falling back to, but that's just a nitpick.

bgamari pushed a commit to ghc/ghc that referenced this pull request May 19, 2026
On Linux and other POSIX platforms, GHC's -jsem jobserver client now
speaks v2 of the semaphore-compat protocol, which uses Unix domain
sockets in place of POSIX named semaphores. This avoids the libc-ABI
issues that affected the old implementation. Windows is unaffected
and continues to use the v1 protocol (Win32 named semaphores); its
reported protocol version remains v1.

When GHC receives a -jsem name whose protocol version it does not
support, it emits a -Wsemaphore-version-mismatch warning and falls
back to -j<N> rather than crashing. ghc --info exposes the supported
version in a new "Semaphore version" entry so cabal-install can detect
a mismatch before invoking GHC.

Users on a cabal-install that predates the v2 update will continue to
build successfully on Linux/POSIX, but will lose the cross-process
-jsem coordination and fall back to -j<N> per GHC invocation. Users
must upgrade to a cabal-install that supports protocol v2 to recover
full parallelism.

Also fix a leak in cleanupSem (#27253): cleanupSem used to snapshot
heldTokens and release them before killing the loop, while the loop's
in-flight acquire/release children could still be mutating it.
Cleanup now runs inside the loop's own exit handler, after draining
the active child via a new activeChild TVar, so the snapshot has no
concurrent mutator.

See also:
  - GHC proposal amendment:  ghc-proposals/ghc-proposals#673
  - cabal-install patch:     haskell/cabal#11628
  - semaphore-compat MR:     https://gitlab.haskell.org/ghc/semaphore-compat/-/merge_requests/8

Bump semaphore-compat submodule to 2.0.0

Fixes #25087 and #27253
bgamari pushed a commit to ghc/ghc that referenced this pull request May 19, 2026
On Linux and other POSIX platforms, GHC's -jsem jobserver client now
speaks v2 of the semaphore-compat protocol, which uses Unix domain
sockets in place of POSIX named semaphores. This avoids the libc-ABI
issues that affected the old implementation. Windows is unaffected
and continues to use the v1 protocol (Win32 named semaphores); its
reported protocol version remains v1.

When GHC receives a -jsem name whose protocol version it does not
support, it emits a -Wsemaphore-version-mismatch warning and falls
back to -j<N> rather than crashing. ghc --info exposes the supported
version in a new "Semaphore version" entry so cabal-install can detect
a mismatch before invoking GHC.

Users on a cabal-install that predates the v2 update will continue to
build successfully on Linux/POSIX, but will lose the cross-process
-jsem coordination and fall back to -j<N> per GHC invocation. Users
must upgrade to a cabal-install that supports protocol v2 to recover
full parallelism.

Also fix a leak in cleanupSem (#27253): cleanupSem used to snapshot
heldTokens and release them before killing the loop, while the loop's
in-flight acquire/release children could still be mutating it.
Cleanup now runs inside the loop's own exit handler, after draining
the active child via a new activeChild TVar, so the snapshot has no
concurrent mutator.

See also:
  - GHC proposal amendment:  ghc-proposals/ghc-proposals#673
  - cabal-install patch:     haskell/cabal#11628
  - semaphore-compat MR:     https://gitlab.haskell.org/ghc/semaphore-compat/-/merge_requests/8

Bump semaphore-compat submodule to 2.0.0

Fixes #25087 and #27253
@philderbeast

Copy link
Copy Markdown
Collaborator

Could we move forward on this? I recently did a cabal install cabal-install:exe:cabal --overwrite-policy=always from the master branch (in the past week or two) to check behaviour between the master branch and some other branch (can't remember which) and I'm hitting the #9993 issue often. I'm using the following as a build check:

$ cabal build all --enable-tests --enable-benchmarks -j --semaphore --ghc-options="-Werror"

bgamari pushed a commit to ghc/ghc that referenced this pull request May 21, 2026
On Linux and other POSIX platforms, GHC's -jsem jobserver client now
speaks v2 of the semaphore-compat protocol, which uses Unix domain
sockets in place of POSIX named semaphores. This avoids the libc-ABI
issues that affected the old implementation. Windows is unaffected
and continues to use the v1 protocol (Win32 named semaphores); its
reported protocol version remains v1.

When GHC receives a -jsem name whose protocol version it does not
support, it emits a -Wsemaphore-version-mismatch warning and falls
back to -j<N> rather than crashing. ghc --info exposes the supported
version in a new "Semaphore version" entry so cabal-install can detect
a mismatch before invoking GHC.

Users on a cabal-install that predates the v2 update will continue to
build successfully on Linux/POSIX, but will lose the cross-process
-jsem coordination and fall back to -j<N> per GHC invocation. Users
must upgrade to a cabal-install that supports protocol v2 to recover
full parallelism.

Also fix a leak in cleanupSem (#27253): cleanupSem used to snapshot
heldTokens and release them before killing the loop, while the loop's
in-flight acquire/release children could still be mutating it.
Cleanup now runs inside the loop's own exit handler, after draining
the active child via a new activeChild TVar, so the snapshot has no
concurrent mutator.

See also:
  - GHC proposal amendment:  ghc-proposals/ghc-proposals#673
  - cabal-install patch:     haskell/cabal#11628
  - semaphore-compat MR:     https://gitlab.haskell.org/ghc/semaphore-compat/-/merge_requests/8

Bump semaphore-compat submodule to 2.0.0

Fixes #25087 and #27253
@wz1000
wz1000 force-pushed the wip/semaphore-v2 branch 2 times, most recently from d564a18 to 1e9c8ae Compare May 21, 2026 13:27
@wz1000

wz1000 commented May 21, 2026

Copy link
Copy Markdown
Contributor Author

https://gitlab.haskell.org/ghc/semaphore-compat/-/merge_requests/8 has been merged, which took longer than expected. I will try to merge the GHC MR tomorrow, and then this should be unblocked for merging.

@sheaf

sheaf commented May 21, 2026

Copy link
Copy Markdown
Collaborator

Could we move forward on this? I recently did a cabal install cabal-install:exe:cabal --overwrite-policy=always from the master branch (in the past week or two) to check behaviour between the master branch and some other branch (can't remember which) and I'm hitting the #9993 issue often.

@philderbeast I don't think that's related. In this PR we are fixing the situation in which GHC and Cabal were linked against different C standard libraries which have incompatible implementations of POSIX semaphores.

If you are running into another issue and are able to provide a reproducer, please open a ticket and I will investigate it.

@wz1000
wz1000 force-pushed the wip/semaphore-v2 branch from 1e9c8ae to b8817fb Compare May 21, 2026 14:00
bgamari pushed a commit to ghc/ghc that referenced this pull request May 21, 2026
On Linux and other POSIX platforms, GHC's -jsem jobserver client now
speaks v2 of the semaphore-compat protocol, which uses Unix domain
sockets in place of POSIX named semaphores. This avoids the libc-ABI
issues that affected the old implementation. Windows is unaffected
and continues to use the v1 protocol (Win32 named semaphores); its
reported protocol version remains v1.

When GHC receives a -jsem name whose protocol version it does not
support, it emits a -Wsemaphore-version-mismatch warning and falls
back to -j<N> rather than crashing. ghc --info exposes the supported
version in a new "Semaphore version" entry so cabal-install can detect
a mismatch before invoking GHC.

Users on a cabal-install that predates the v2 update will continue to
build successfully on Linux/POSIX, but will lose the cross-process
-jsem coordination and fall back to -j<N> per GHC invocation. Users
must upgrade to a cabal-install that supports protocol v2 to recover
full parallelism.

Also fix a leak in cleanupSem (#27253): cleanupSem used to snapshot
heldTokens and release them before killing the loop, while the loop's
in-flight acquire/release children could still be mutating it.
Cleanup now runs inside the loop's own exit handler, after draining
the active child via a new activeChild TVar, so the snapshot has no
concurrent mutator.

See also:
  - GHC proposal amendment:  ghc-proposals/ghc-proposals#673
  - cabal-install patch:     haskell/cabal#11628
  - semaphore-compat MR:     https://gitlab.haskell.org/ghc/semaphore-compat/-/merge_requests/8

Bump semaphore-compat submodule to 2.0.0

Fixes #25087 and #27253
@Mikolaj Mikolaj added the merge me Tell Mergify Bot to merge label May 25, 2026
@mergify mergify Bot added the ready and waiting Mergify is waiting out the cooldown period label May 25, 2026
bgamari pushed a commit to ghc/ghc that referenced this pull request May 26, 2026
On Linux and other POSIX platforms, GHC's -jsem jobserver client now
speaks v2 of the semaphore-compat protocol, which uses Unix domain
sockets in place of POSIX named semaphores. This avoids the libc-ABI
issues that affected the old implementation. Windows is unaffected
and continues to use the v1 protocol (Win32 named semaphores); its
reported protocol version remains v1.

When GHC receives a -jsem name whose protocol version it does not
support, it emits a -Wsemaphore-version-mismatch warning and falls
back to -j<N> rather than crashing. ghc --info exposes the supported
version in a new "Semaphore version" entry so cabal-install can detect
a mismatch before invoking GHC.

Users on a cabal-install that predates the v2 update will continue to
build successfully on Linux/POSIX, but will lose the cross-process
-jsem coordination and fall back to -j<N> per GHC invocation. Users
must upgrade to a cabal-install that supports protocol v2 to recover
full parallelism.

Also fix a leak in cleanupSem (#27253): cleanupSem used to snapshot
heldTokens and release them before killing the loop, while the loop's
in-flight acquire/release children could still be mutating it.
Cleanup now runs inside the loop's own exit handler, after draining
the active child via a new activeChild TVar, so the snapshot has no
concurrent mutator.

See also:
  - GHC proposal amendment:  ghc-proposals/ghc-proposals#673
  - cabal-install patch:     haskell/cabal#11628
  - semaphore-compat MR:     https://gitlab.haskell.org/ghc/semaphore-compat/-/merge_requests/8

Bump semaphore-compat submodule to 2.0.0

Fixes #25087 and #27253
bgamari pushed a commit to ghc/ghc that referenced this pull request May 26, 2026
On Linux and other POSIX platforms, GHC's -jsem jobserver client now
speaks v2 of the semaphore-compat protocol, which uses Unix domain
sockets in place of POSIX named semaphores. This avoids the libc-ABI
issues that affected the old implementation. Windows is unaffected
and continues to use the v1 protocol (Win32 named semaphores); its
reported protocol version remains v1.

When GHC receives a -jsem name whose protocol version it does not
support, it emits a -Wsemaphore-version-mismatch warning and falls
back to -j<N> rather than crashing. ghc --info exposes the supported
version in a new "Semaphore version" entry so cabal-install can detect
a mismatch before invoking GHC.

Users on a cabal-install that predates the v2 update will continue to
build successfully on Linux/POSIX, but will lose the cross-process
-jsem coordination and fall back to -j<N> per GHC invocation. Users
must upgrade to a cabal-install that supports protocol v2 to recover
full parallelism.

Also fix a leak in cleanupSem (#27253): cleanupSem used to snapshot
heldTokens and release them before killing the loop, while the loop's
in-flight acquire/release children could still be mutating it.
Cleanup now runs inside the loop's own exit handler, after draining
the active child via a new activeChild TVar, so the snapshot has no
concurrent mutator.

See also:
  - GHC proposal amendment:  ghc-proposals/ghc-proposals#673
  - cabal-install patch:     haskell/cabal#11628
  - semaphore-compat MR:     https://gitlab.haskell.org/ghc/semaphore-compat/-/merge_requests/8

Bump semaphore-compat submodule to 2.0.0

Fixes #25087 and #27253
bgamari pushed a commit to ghc/ghc that referenced this pull request May 26, 2026
On Linux and other POSIX platforms, GHC's -jsem jobserver client now
speaks v2 of the semaphore-compat protocol, which uses Unix domain
sockets in place of POSIX named semaphores. This avoids the libc-ABI
issues that affected the old implementation. Windows is unaffected
and continues to use the v1 protocol (Win32 named semaphores); its
reported protocol version remains v1.

When GHC receives a -jsem name whose protocol version it does not
support, it emits a -Wsemaphore-version-mismatch warning and falls
back to -j<N> rather than crashing. ghc --info exposes the supported
version in a new "Semaphore version" entry so cabal-install can detect
a mismatch before invoking GHC.

Users on a cabal-install that predates the v2 update will continue to
build successfully on Linux/POSIX, but will lose the cross-process
-jsem coordination and fall back to -j<N> per GHC invocation. Users
must upgrade to a cabal-install that supports protocol v2 to recover
full parallelism.

Also fix a leak in cleanupSem (#27253): cleanupSem used to snapshot
heldTokens and release them before killing the loop, while the loop's
in-flight acquire/release children could still be mutating it.
Cleanup now runs inside the loop's own exit handler, after draining
the active child via a new activeChild TVar, so the snapshot has no
concurrent mutator.

See also:
  - GHC proposal amendment:  ghc-proposals/ghc-proposals#673
  - cabal-install patch:     haskell/cabal#11628
  - semaphore-compat MR:     https://gitlab.haskell.org/ghc/semaphore-compat/-/merge_requests/8

Bump semaphore-compat submodule to 2.0.0

Fixes #25087 and #27253

(cherry picked from commit 8db331a)
bgamari pushed a commit to ghc/ghc that referenced this pull request May 26, 2026
On Linux and other POSIX platforms, GHC's -jsem jobserver client now
speaks v2 of the semaphore-compat protocol, which uses Unix domain
sockets in place of POSIX named semaphores. This avoids the libc-ABI
issues that affected the old implementation. Windows is unaffected
and continues to use the v1 protocol (Win32 named semaphores); its
reported protocol version remains v1.

When GHC receives a -jsem name whose protocol version it does not
support, it emits a -Wsemaphore-version-mismatch warning and falls
back to -j<N> rather than crashing. ghc --info exposes the supported
version in a new "Semaphore version" entry so cabal-install can detect
a mismatch before invoking GHC.

Users on a cabal-install that predates the v2 update will continue to
build successfully on Linux/POSIX, but will lose the cross-process
-jsem coordination and fall back to -j<N> per GHC invocation. Users
must upgrade to a cabal-install that supports protocol v2 to recover
full parallelism.

Also fix a leak in cleanupSem (#27253): cleanupSem used to snapshot
heldTokens and release them before killing the loop, while the loop's
in-flight acquire/release children could still be mutating it.
Cleanup now runs inside the loop's own exit handler, after draining
the active child via a new activeChild TVar, so the snapshot has no
concurrent mutator.

See also:
  - GHC proposal amendment:  ghc-proposals/ghc-proposals#673
  - cabal-install patch:     haskell/cabal#11628
  - semaphore-compat MR:     https://gitlab.haskell.org/ghc/semaphore-compat/-/merge_requests/8

Bump semaphore-compat submodule to 2.0.0

Fixes #25087 and #27253

(cherry picked from commit 8db331a)
bgamari pushed a commit to ghc/ghc that referenced this pull request May 27, 2026
On Linux and other POSIX platforms, GHC's -jsem jobserver client now
speaks v2 of the semaphore-compat protocol, which uses Unix domain
sockets in place of POSIX named semaphores. This avoids the libc-ABI
issues that affected the old implementation. Windows is unaffected
and continues to use the v1 protocol (Win32 named semaphores); its
reported protocol version remains v1.

When GHC receives a -jsem name whose protocol version it does not
support, it emits a -Wsemaphore-version-mismatch warning and falls
back to -j<N> rather than crashing. ghc --info exposes the supported
version in a new "Semaphore version" entry so cabal-install can detect
a mismatch before invoking GHC.

Users on a cabal-install that predates the v2 update will continue to
build successfully on Linux/POSIX, but will lose the cross-process
-jsem coordination and fall back to -j<N> per GHC invocation. Users
must upgrade to a cabal-install that supports protocol v2 to recover
full parallelism.

Also fix a leak in cleanupSem (#27253): cleanupSem used to snapshot
heldTokens and release them before killing the loop, while the loop's
in-flight acquire/release children could still be mutating it.
Cleanup now runs inside the loop's own exit handler, after draining
the active child via a new activeChild TVar, so the snapshot has no
concurrent mutator.

See also:
  - GHC proposal amendment:  ghc-proposals/ghc-proposals#673
  - cabal-install patch:     haskell/cabal#11628
  - semaphore-compat MR:     https://gitlab.haskell.org/ghc/semaphore-compat/-/merge_requests/8

Bump semaphore-compat submodule to 2.0.0

Fixes #25087 and #27253

(cherry picked from commit 8db331a)
@mergify mergify Bot added the merge delay passed Applied (usually by Mergify) when PR approved and received no updates for 2 days label May 27, 2026
@Mikolaj

Mikolaj commented May 27, 2026

Copy link
Copy Markdown
Member

@wz1000: apparently, before this got merged, a conflict emerged, so it has to be resolved before mergify can proceed (but this time without waiting, which we can force if needed).

…ab.haskell.org/ghc/ghc/-/issues/25087

Also update index-state and bootstrap plans to pull in new version of semaphore-compat.

semaphore-compat now uses a unix sockets based implementation.

Semaphore identifiers are now versioned, and we can really on the versioning
scheme to detect semaphore version mismatch with GHC and fallback gracefully if
possible.

GHC patch: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/15729

After the GHC patch lands, it will include a "Semaphore version" field in its
settings file/`--info` output that we can use to guide Cabal behaviour.

If this field does not exist (and ghc is 9.8+), then we assume it uses version v1 of the protocol
and this triggers a graceful degradation of behaviour to `-jN` without semaphore based coordination.

See also

semaphore-compat MR: https://gitlab.haskell.org/ghc/semaphore-compat/-/merge_requests/8

ghc-proposals change: ghc-proposals/ghc-proposals#673
@wz1000
wz1000 force-pushed the wip/semaphore-v2 branch from 96ccd50 to 2cac53b Compare May 27, 2026 16:57
@wz1000

wz1000 commented May 27, 2026

Copy link
Copy Markdown
Contributor Author

@wz1000: apparently, before this got merged, a conflict emerged, so it has to be resolved before mergify can proceed (but this time without waiting, which we can force if needed).

resolved.

@mergify mergify Bot added the queued label May 27, 2026
@mergify

mergify Bot commented May 27, 2026

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • Entered queue2026-05-27 18:41 UTC · Rule: default
  • Checks skipped · PR is already up-to-date
  • Merged2026-05-27 18:53 UTC · at 2cac53be5659a2a74f1748fd6ab1e00183a18765 · merge

This pull request spent 11 minutes 27 seconds in the queue, including 5 seconds running CI.

Required conditions to merge
  • #approved-reviews-by >= 2 [🛡 GitHub branch protection]
  • #review-threads-unresolved = 0 [🛡 GitHub branch protection]
  • any of [🛡 GitHub branch protection]:
    • check-success = Doctest Cabal
    • check-neutral = Doctest Cabal
    • check-skipped = Doctest Cabal
  • any of [🛡 GitHub branch protection]:
    • check-success = Meta checks
    • check-neutral = Meta checks
    • check-skipped = Meta checks
  • any of [🛡 GitHub branch protection]:
    • check-success = docs/readthedocs.org:cabal
    • check-neutral = docs/readthedocs.org:cabal
    • check-skipped = docs/readthedocs.org:cabal
  • any of [🛡 GitHub branch protection]:
    • check-success = Validate post job
    • check-neutral = Validate post job
    • check-skipped = Validate post job
  • any of [🛡 GitHub branch protection]:
    • check-success = fourmolu
    • check-neutral = fourmolu
    • check-skipped = fourmolu
  • any of [🛡 GitHub branch protection]:
    • check-success = hlint
    • check-neutral = hlint
    • check-skipped = hlint
  • any of [🛡 GitHub branch protection]:
    • check-success = Bootstrap post job
    • check-neutral = Bootstrap post job
    • check-skipped = Bootstrap post job
  • any of [🛡 GitHub branch protection]:
    • check-success = whitespace
    • check-neutral = whitespace
    • check-skipped = whitespace
  • any of [🛡 GitHub branch protection]:
    • check-success = Check sdist post job
    • check-neutral = Check sdist post job
    • check-skipped = Check sdist post job
  • any of [🛡 GitHub branch protection]:
    • check-success = Changelogs
    • check-neutral = Changelogs
    • check-skipped = Changelogs

@mergify
mergify Bot merged commit dd941a5 into haskell:master May 27, 2026
63 checks passed
@mergify mergify Bot removed the queued label May 27, 2026
bgamari pushed a commit to ghc/ghc that referenced this pull request Jun 2, 2026
On Linux and other POSIX platforms, GHC's -jsem jobserver client now
speaks v2 of the semaphore-compat protocol, which uses Unix domain
sockets in place of POSIX named semaphores. This avoids the libc-ABI
issues that affected the old implementation. Windows is unaffected
and continues to use the v1 protocol (Win32 named semaphores); its
reported protocol version remains v1.

When GHC receives a -jsem name whose protocol version it does not
support, it emits a -Wsemaphore-version-mismatch warning and falls
back to -j<N> rather than crashing. ghc --info exposes the supported
version in a new "Semaphore version" entry so cabal-install can detect
a mismatch before invoking GHC.

Users on a cabal-install that predates the v2 update will continue to
build successfully on Linux/POSIX, but will lose the cross-process
-jsem coordination and fall back to -j<N> per GHC invocation. Users
must upgrade to a cabal-install that supports protocol v2 to recover
full parallelism.

Also fix a leak in cleanupSem (#27253): cleanupSem used to snapshot
heldTokens and release them before killing the loop, while the loop's
in-flight acquire/release children could still be mutating it.
Cleanup now runs inside the loop's own exit handler, after draining
the active child via a new activeChild TVar, so the snapshot has no
concurrent mutator.

See also:
  - GHC proposal amendment:  ghc-proposals/ghc-proposals#673
  - cabal-install patch:     haskell/cabal#11628
  - semaphore-compat MR:     https://gitlab.haskell.org/ghc/semaphore-compat/-/merge_requests/8

Bump semaphore-compat submodule to 2.0.0

Fixes #25087 and #27253
bgamari pushed a commit to ghc/ghc that referenced this pull request Jun 10, 2026
On Linux and other POSIX platforms, GHC's -jsem jobserver client now
speaks v2 of the semaphore-compat protocol, which uses Unix domain
sockets in place of POSIX named semaphores. This avoids the libc-ABI
issues that affected the old implementation. Windows is unaffected
and continues to use the v1 protocol (Win32 named semaphores); its
reported protocol version remains v1.

When GHC receives a -jsem name whose protocol version it does not
support, it emits a -Wsemaphore-version-mismatch warning and falls
back to -j<N> rather than crashing. ghc --info exposes the supported
version in a new "Semaphore version" entry so cabal-install can detect
a mismatch before invoking GHC.

Users on a cabal-install that predates the v2 update will continue to
build successfully on Linux/POSIX, but will lose the cross-process
-jsem coordination and fall back to -j<N> per GHC invocation. Users
must upgrade to a cabal-install that supports protocol v2 to recover
full parallelism.

Also fix a leak in cleanupSem (#27253): cleanupSem used to snapshot
heldTokens and release them before killing the loop, while the loop's
in-flight acquire/release children could still be mutating it.
Cleanup now runs inside the loop's own exit handler, after draining
the active child via a new activeChild TVar, so the snapshot has no
concurrent mutator.

See also:
  - GHC proposal amendment:  ghc-proposals/ghc-proposals#673
  - cabal-install patch:     haskell/cabal#11628
  - semaphore-compat MR:     https://gitlab.haskell.org/ghc/semaphore-compat/-/merge_requests/8

Bump semaphore-compat submodule to 2.0.0

Fixes #25087 and #27253

(cherry picked from commit 8db331a)
bgamari pushed a commit to ghc/ghc that referenced this pull request Jun 10, 2026
On Linux and other POSIX platforms, GHC's -jsem jobserver client now
speaks v2 of the semaphore-compat protocol, which uses Unix domain
sockets in place of POSIX named semaphores. This avoids the libc-ABI
issues that affected the old implementation. Windows is unaffected
and continues to use the v1 protocol (Win32 named semaphores); its
reported protocol version remains v1.

When GHC receives a -jsem name whose protocol version it does not
support, it emits a -Wsemaphore-version-mismatch warning and falls
back to -j<N> rather than crashing. ghc --info exposes the supported
version in a new "Semaphore version" entry so cabal-install can detect
a mismatch before invoking GHC.

Users on a cabal-install that predates the v2 update will continue to
build successfully on Linux/POSIX, but will lose the cross-process
-jsem coordination and fall back to -j<N> per GHC invocation. Users
must upgrade to a cabal-install that supports protocol v2 to recover
full parallelism.

Also fix a leak in cleanupSem (#27253): cleanupSem used to snapshot
heldTokens and release them before killing the loop, while the loop's
in-flight acquire/release children could still be mutating it.
Cleanup now runs inside the loop's own exit handler, after draining
the active child via a new activeChild TVar, so the snapshot has no
concurrent mutator.

See also:
  - GHC proposal amendment:  ghc-proposals/ghc-proposals#673
  - cabal-install patch:     haskell/cabal#11628
  - semaphore-compat MR:     https://gitlab.haskell.org/ghc/semaphore-compat/-/merge_requests/8

Bump semaphore-compat submodule to 2.0.0

Fixes #25087 and #27253

(cherry picked from commit 8db331a)
TeofilC added a commit that referenced this pull request Jun 10, 2026
This reverts commit dd941a5, reversing
changes made to 937b961.
bgamari pushed a commit to ghc/ghc that referenced this pull request Jun 10, 2026
On Linux and other POSIX platforms, GHC's -jsem jobserver client now
speaks v2 of the semaphore-compat protocol, which uses Unix domain
sockets in place of POSIX named semaphores. This avoids the libc-ABI
issues that affected the old implementation. Windows is unaffected
and continues to use the v1 protocol (Win32 named semaphores); its
reported protocol version remains v1.

When GHC receives a -jsem name whose protocol version it does not
support, it emits a -Wsemaphore-version-mismatch warning and falls
back to -j<N> rather than crashing. ghc --info exposes the supported
version in a new "Semaphore version" entry so cabal-install can detect
a mismatch before invoking GHC.

Users on a cabal-install that predates the v2 update will continue to
build successfully on Linux/POSIX, but will lose the cross-process
-jsem coordination and fall back to -j<N> per GHC invocation. Users
must upgrade to a cabal-install that supports protocol v2 to recover
full parallelism.

Also fix a leak in cleanupSem (#27253): cleanupSem used to snapshot
heldTokens and release them before killing the loop, while the loop's
in-flight acquire/release children could still be mutating it.
Cleanup now runs inside the loop's own exit handler, after draining
the active child via a new activeChild TVar, so the snapshot has no
concurrent mutator.

See also:
  - GHC proposal amendment:  ghc-proposals/ghc-proposals#673
  - cabal-install patch:     haskell/cabal#11628
  - semaphore-compat MR:     https://gitlab.haskell.org/ghc/semaphore-compat/-/merge_requests/8

Bump semaphore-compat submodule to 2.0.0

Fixes #25087 and #27253

(cherry picked from commit 8db331a)
bgamari pushed a commit to ghc/ghc that referenced this pull request Jun 10, 2026
On Linux and other POSIX platforms, GHC's -jsem jobserver client now
speaks v2 of the semaphore-compat protocol, which uses Unix domain
sockets in place of POSIX named semaphores. This avoids the libc-ABI
issues that affected the old implementation. Windows is unaffected
and continues to use the v1 protocol (Win32 named semaphores); its
reported protocol version remains v1.

When GHC receives a -jsem name whose protocol version it does not
support, it emits a -Wsemaphore-version-mismatch warning and falls
back to -j<N> rather than crashing. ghc --info exposes the supported
version in a new "Semaphore version" entry so cabal-install can detect
a mismatch before invoking GHC.

Users on a cabal-install that predates the v2 update will continue to
build successfully on Linux/POSIX, but will lose the cross-process
-jsem coordination and fall back to -j<N> per GHC invocation. Users
must upgrade to a cabal-install that supports protocol v2 to recover
full parallelism.

Also fix a leak in cleanupSem (#27253): cleanupSem used to snapshot
heldTokens and release them before killing the loop, while the loop's
in-flight acquire/release children could still be mutating it.
Cleanup now runs inside the loop's own exit handler, after draining
the active child via a new activeChild TVar, so the snapshot has no
concurrent mutator.

See also:
  - GHC proposal amendment:  ghc-proposals/ghc-proposals#673
  - cabal-install patch:     haskell/cabal#11628
  - semaphore-compat MR:     https://gitlab.haskell.org/ghc/semaphore-compat/-/merge_requests/8

Bump semaphore-compat submodule to 2.0.0

Fixes #25087 and #27253

(cherry picked from commit 8db331a)
bgamari pushed a commit to ghc/ghc that referenced this pull request Jun 11, 2026
On Linux and other POSIX platforms, GHC's -jsem jobserver client now
speaks v2 of the semaphore-compat protocol, which uses Unix domain
sockets in place of POSIX named semaphores. This avoids the libc-ABI
issues that affected the old implementation. Windows is unaffected
and continues to use the v1 protocol (Win32 named semaphores); its
reported protocol version remains v1.

When GHC receives a -jsem name whose protocol version it does not
support, it emits a -Wsemaphore-version-mismatch warning and falls
back to -j<N> rather than crashing. ghc --info exposes the supported
version in a new "Semaphore version" entry so cabal-install can detect
a mismatch before invoking GHC.

Users on a cabal-install that predates the v2 update will continue to
build successfully on Linux/POSIX, but will lose the cross-process
-jsem coordination and fall back to -j<N> per GHC invocation. Users
must upgrade to a cabal-install that supports protocol v2 to recover
full parallelism.

Also fix a leak in cleanupSem (#27253): cleanupSem used to snapshot
heldTokens and release them before killing the loop, while the loop's
in-flight acquire/release children could still be mutating it.
Cleanup now runs inside the loop's own exit handler, after draining
the active child via a new activeChild TVar, so the snapshot has no
concurrent mutator.

See also:
  - GHC proposal amendment:  ghc-proposals/ghc-proposals#673
  - cabal-install patch:     haskell/cabal#11628
  - semaphore-compat MR:     https://gitlab.haskell.org/ghc/semaphore-compat/-/merge_requests/8

Bump semaphore-compat submodule to 2.0.0

Fixes #25087 and #27253

(cherry picked from commit 8db331a)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge delay passed Applied (usually by Mergify) when PR approved and received no updates for 2 days merge me Tell Mergify Bot to merge ready and waiting Mergify is waiting out the cooldown period

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants