Skip to content

Commit

Permalink
Merge pull request #60 from NicolasT/hsc2hs-linkage-issue
Browse files Browse the repository at this point in the history
psx: work-around `hsc2hs` linking issue
  • Loading branch information
NicolasT authored Mar 31, 2024
2 parents a512fad + 49f6643 commit 2952337
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
5 changes: 4 additions & 1 deletion psx/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@

* Update vendored sources.

* Support `tasty ^>=1.5`
* Support `tasty ^>=1.5`.

* Fix build on platforms where a `hsc2hs` build links in `libgcc` which relies on
`sigfillset`. This requires the Cabal format version to be bumped to 3.6.

## 0.1.1.1 -- 2023-02-28

Expand Down
5 changes: 4 additions & 1 deletion psx/psx.cabal
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cabal-version: 2.2
cabal-version: 3.6
build-type: Simple
name: psx
version: 0.1.1.1
Expand Down Expand Up @@ -35,6 +35,7 @@ extra-source-files:
cbits/hs-psx.h
cbits/psx/psx_syscall.h
test/detect-psx.h
test/hsc2hs-stubs.c

tested-with:
GHC ==8.10.7
Expand Down Expand Up @@ -113,6 +114,7 @@ test-suite psx-test-threaded
main-is: psx-test-threaded.hs
other-modules: TestCases
c-sources: test/detect-psx.c
hsc2hs-options: -i hsc2hs-stubs.c
include-dirs: test
build-depends:
, async ^>=2.2.3
Expand All @@ -131,6 +133,7 @@ test-suite psx-test
main-is: psx-test.hs
other-modules: TestCases
c-sources: test/detect-psx.c
hsc2hs-options: -i hsc2hs-stubs.c
include-dirs: test
build-depends:
, async ^>=2.2.3
Expand Down
20 changes: 20 additions & 0 deletions psx/test/hsc2hs-stubs.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/* Stubs for linking `hsc2hs` programs to succeed.
*
* For some reason, `cabal` passes a library's `ld-options` to the C compiler
* when building `hsc2hs` C files. However, in our case, these flags request
* wrapping of (e.g.) `sigfillset`. On some platforms, `libgcc` gets linked in
* as well, and on some platforms this `libgcc` relies on `sigfillset`, hence
* linking fails unless `__wrap_sigfillset` is declared.
*
* This module relays calls to the underlying `__real_*` implementation.
*
* See https://github.com/haskell/cabal/issues/8824
*/

#include <signal.h>

extern int __real_sigfillset(sigset_t *set);

int __wrap_sigfillset(sigset_t *set) {
return __real_sigfillset(set);
}

0 comments on commit 2952337

Please sign in to comment.