Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 09 Mar 2026 07:04:00 +0000
From:      Gleb Popov <arrowd@FreeBSD.org>
To:        ports-committers@FreeBSD.org, dev-commits-ports-all@FreeBSD.org, dev-commits-ports-main@FreeBSD.org
Subject:   git: 98214c958ae1 - main - lang/ghc: Add patch fixing the semaphore-compat package
Message-ID:  <69ae70e0.25dc5.2f60c415@gitrepo.freebsd.org>

index | next in thread | raw e-mail

The branch main has been updated by arrowd:

URL: https://cgit.FreeBSD.org/ports/commit/?id=98214c958ae1eb4c552dd9f446287395e337c076

commit 98214c958ae1eb4c552dd9f446287395e337c076
Author:     Gleb Popov <arrowd@FreeBSD.org>
AuthorDate: 2026-03-08 19:47:05 +0000
Commit:     Gleb Popov <arrowd@FreeBSD.org>
CommitDate: 2026-03-09 07:03:51 +0000

    lang/ghc: Add patch fixing the semaphore-compat package
---
 lang/ghc/Makefile                                  |  2 +-
 ...raries_semaphore-compat_src_System_Semaphore.hs | 44 ++++++++++++++++++++++
 2 files changed, 45 insertions(+), 1 deletion(-)

diff --git a/lang/ghc/Makefile b/lang/ghc/Makefile
index 2f7372af499e..bf68f31f513d 100644
--- a/lang/ghc/Makefile
+++ b/lang/ghc/Makefile
@@ -1,6 +1,6 @@
 PORTNAME=	ghc
 PORTVERSION=	${GHC_VERSION}
-PORTREVISION?=	1
+PORTREVISION?=	2
 CATEGORIES=	lang haskell
 MASTER_SITES=	https://www.haskell.org/ghc/dist/${PORTVERSION}/:source \
 		LOCAL/arrowd/:boot
diff --git a/lang/ghc/files/patch-libraries_semaphore-compat_src_System_Semaphore.hs b/lang/ghc/files/patch-libraries_semaphore-compat_src_System_Semaphore.hs
new file mode 100644
index 000000000000..75e3f07b62c5
--- /dev/null
+++ b/lang/ghc/files/patch-libraries_semaphore-compat_src_System_Semaphore.hs
@@ -0,0 +1,44 @@
+--- libraries/semaphore-compat/src/System/Semaphore.hs.orig	2025-09-10 16:05:58 UTC
++++ libraries/semaphore-compat/src/System/Semaphore.hs
+@@ -138,7 +138,7 @@ create_sem sem_str init_toks = do
+           { Posix.semCreate    = True
+           , Posix.semExclusive = True }
+   mb_sem <- MC.try @_ @MC.SomeException $
+-    Posix.semOpen sem_str flags Posix.stdFileMode init_toks
++    Posix.semOpen (fixedUpName sem_str) flags Posix.stdFileMode init_toks
+   return $ case mb_sem of
+     Left  err -> Left $ MC.throwM err
+     Right sem -> Right $ mk_sem sem
+@@ -162,7 +162,7 @@ openSemaphore nm@(SemaphoreName sem_name) = do
+     flags = Posix.OpenSemFlags
+           { Posix.semCreate    = False
+           , Posix.semExclusive = False }
+-  sem <- Posix.semOpen sem_name flags Posix.stdFileMode 0
++  sem <- Posix.semOpen (fixedUpName sem_name) flags Posix.stdFileMode 0
+ #endif
+   return $
+     Semaphore
+@@ -216,7 +216,7 @@ destroySemaphore sem =
+ #if defined(mingw32_HOST_OS)
+   Win32.closeHandle (Win32.semaphoreHandle $ semaphore sem)
+ #else
+-  Posix.semUnlink (getSemaphoreName $ semaphoreName sem)
++  Posix.semUnlink (fixedUpName $ getSemaphoreName $ semaphoreName sem)
+ #endif
+ 
+ -- | Query the current semaphore value (how many tokens it has available).
+@@ -351,3 +351,14 @@ random_strings = do
+   CClock t <- Posix.systemTime <$> Posix.getProcessTimes
+ #endif
+   return $ fmap ( \ i -> iToBase62 (i + fromIntegral t) ) (0 :| [1..])
++
++fixedUpName :: String -> String
++#if !defined(freebsd_HOST_OS)
++fixedUpName = id
++#else
++-- On FreeBSD the semaphore name has to start with '/'
++-- and not have any more '/' inside
++fixedUpName ('/':rest) = '/' : filter (/= '/') rest
++fixedUpName (notSlash:rest) = '/':notSlash:filter (/= '/') rest
++fixedUpName n = n
++#endif


home | help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?69ae70e0.25dc5.2f60c415>