Skip to content

Commit 5dcec2d

Browse files
authored
bluespec: Add darwin support and withDocs (#389298)
2 parents f45b574 + 761c728 commit 5dcec2d

File tree

1 file changed

+59
-27
lines changed

1 file changed

+59
-27
lines changed

pkgs/by-name/bl/bluespec/package.nix

Lines changed: 59 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@
2222
asciidoctor,
2323
texliveFull,
2424
which,
25+
# install -m 644 lib/libstp.dylib /private/tmp/nix-build-bluespec-2024.07.drv-5/source/inst/lib/SAT
26+
# install: cannot stat 'lib/libstp.dylib': No such file or directory
27+
# https://github.com/B-Lang-org/bsc/pull/600 might fix it
28+
stubStp ? !stdenv.hostPlatform.isDarwin,
29+
withDocs ? true,
2530
}:
2631

2732
let
@@ -54,10 +59,13 @@ stdenv.mkDerivation rec {
5459

5560
enableParallelBuilding = true;
5661

57-
outputs = [
58-
"out"
59-
"doc"
60-
];
62+
outputs =
63+
[
64+
"out"
65+
]
66+
++ lib.optionals withDocs [
67+
"doc"
68+
];
6169

6270
# https://github.com/B-Lang-org/bsc/pull/278 is still applicable, but will probably not be applied as such
6371
# there is work ongoing: https://github.com/B-Lang-org/bsc/issues/595 https://github.com/B-Lang-org/bsc/pull/600
@@ -70,14 +78,19 @@ stdenv.mkDerivation rec {
7078

7179
preBuild = ''
7280
patchShebangs \
81+
src/vendor/stp/src/AST/genkinds.pl \
7382
src/Verilog/copy_module.pl \
7483
src/comp/update-build-version.sh \
7584
src/comp/update-build-system.sh \
7685
src/comp/wrapper.sh
7786
7887
substituteInPlace src/comp/Makefile \
79-
--replace 'BINDDIR' 'BINDIR' \
80-
--replace 'install-bsc install-bluetcl' 'install-bsc install-bluetcl $(UTILEXES) install-utils'
88+
--replace-fail 'install-bsc install-bluetcl' 'install-bsc install-bluetcl $(UTILEXES) install-utils'
89+
90+
# For darwin
91+
# ld: library not found for -ltcl8.5
92+
substituteInPlace ./platform.sh \
93+
--replace-fail 'TCLSH=/usr/bin/tclsh' 'TCLSH=`which tclsh`'
8194
8295
# allow running bsc to bootstrap
8396
export LD_LIBRARY_PATH=$PWD/inst/lib/SAT
@@ -107,15 +120,26 @@ stdenv.mkDerivation rec {
107120
perl
108121
pkg-config
109122
texliveFull
123+
tcl
110124
];
111125

112-
makeFlags = [
113-
"release"
114-
"NO_DEPS_CHECKS=1" # skip the subrepo check (this deriviation uses yices-src instead of the subrepo)
115-
"NOGIT=1" # https://github.com/B-Lang-org/bsc/issues/12
116-
"LDCONFIG=ldconfig" # https://github.com/B-Lang-org/bsc/pull/43
117-
"STP_STUB=1" # uses yices as a SMT solver and stub out STP
118-
];
126+
env.NIX_CFLAGS_COMPILE = toString (
127+
lib.optionals (stdenv.cc.isClang) [
128+
# wide_data.cxx:1750:15: error: variable length arrays in C++ are a Clang extension [-Werror,-Wvla-cxx-extension]
129+
"-Wno-error"
130+
]
131+
);
132+
133+
makeFlags =
134+
[
135+
"NO_DEPS_CHECKS=1" # skip the subrepo check (this deriviation uses yices-src instead of the subrepo)
136+
"NOGIT=1" # https://github.com/B-Lang-org/bsc/issues/12
137+
"LDCONFIG=ldconfig" # https://github.com/SRI-CSL/yices2/blob/fda0a325ea7923f152ea9f9a5d20eddfd1d96224/Makefile.build#L66
138+
(if withDocs then "release" else "install-src")
139+
]
140+
++ lib.optionals stubStp [
141+
"STP_STUB=1" # uses yices as a SMT solver and stub out STP
142+
];
119143

120144
doCheck = true;
121145

@@ -124,25 +148,33 @@ stdenv.mkDerivation rec {
124148
iverilog
125149
];
126150

127-
checkTarget = "check-smoke"; # this is the shortest check but "check-suite" tests much more
128-
129-
installPhase = ''
130-
mkdir -p $out
131-
mv inst/bin $out
132-
mv inst/lib $out
133-
134-
# fragile, I know..
135-
mkdir -p $doc/share/doc/bsc
136-
mv inst/README $doc/share/doc/bsc
137-
mv inst/ReleaseNotes.* $doc/share/doc/bsc
138-
mv inst/doc/*.pdf $doc/share/doc/bsc
139-
'';
151+
# /nix/store/7y0vlsf6l8lr3vjsbrirqrsbx4mwqiwf-cctools-binutils-darwin-1010.6/bin/strip: error: unknown argument '-u'
152+
# make[1]: *** [Makefile:97: smoke_test_bluesim] Error 1
153+
checkTarget = lib.optionalString (!stdenv.hostPlatform.isDarwin) "check-smoke"; # this is the shortest check but "check-suite" tests much more
154+
155+
installPhase =
156+
''
157+
mkdir -p $out
158+
mv inst/bin $out
159+
mv inst/lib $out
160+
161+
''
162+
+ lib.optionalString withDocs ''
163+
# fragile, I know..
164+
mkdir -p $doc/share/doc/bsc
165+
mv inst/README $doc/share/doc/bsc
166+
mv inst/ReleaseNotes.* $doc/share/doc/bsc
167+
mv inst/doc/*.pdf $doc/share/doc/bsc
168+
'';
140169

141170
meta = {
142171
description = "Toolchain for the Bluespec Hardware Definition Language";
143172
homepage = "https://github.com/B-Lang-org/bsc";
144173
license = lib.licenses.bsd3;
145-
platforms = [ "x86_64-linux" ];
174+
platforms = [
175+
"x86_64-linux"
176+
"aarch64-darwin"
177+
];
146178
mainProgram = "bsc";
147179
# darwin fails at https://github.com/B-Lang-org/bsc/pull/35#issuecomment-583731562
148180
# aarch64 fails, as GHC fails with "ghc: could not execute: opt"

0 commit comments

Comments
 (0)