-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a dev shell for opentitan #8
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
{ | ||
pkgs, | ||
ncurses5-fhs, | ||
bazel_ot, | ||
python_ot, | ||
verilator_ot, | ||
edaTools ? [], | ||
wrapCCWith, | ||
gcc-unwrapped, | ||
pkg-config, | ||
... | ||
}: let | ||
edaExtraDeps = with pkgs; [elfutils openssl]; | ||
|
||
# Bazel rules_rust expects build PIE binary in opt build but doesn't request PIE/PIC, so force PIC | ||
gcc-patched = wrapCCWith { | ||
cc = gcc-unwrapped; | ||
nixSupport.cc-cflags = ["-fPIC"]; | ||
}; | ||
|
||
# Bazel filters out all environment including PKG_CONFIG_PATH. Append this inside wrapper. | ||
pkg-config-patched = pkg-config.override { | ||
extraBuildCommands = '' | ||
echo "export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/lib/pkgconfig" >> $out/nix-support/utils.bash | ||
''; | ||
}; | ||
in | ||
(pkgs.buildFHSEnv { | ||
name = "opentitan"; | ||
targetPkgs = _: | ||
with pkgs; | ||
[ | ||
bazel_ot | ||
python_ot | ||
verilator_ot | ||
|
||
# For serde-annotate which can be built with just cargo | ||
rustup | ||
|
||
# Bazel downloads Rust compilers which are not patchelfed and they need this. | ||
zlib | ||
openssl | ||
curl | ||
|
||
gcc-patched | ||
pkg-config-patched | ||
|
||
libxcrypt-legacy | ||
udev | ||
libftdi1 | ||
libusb1 # needed for libftdi1 pkg-config | ||
ncurses5-fhs | ||
|
||
srecord | ||
|
||
# For documentation | ||
hugo | ||
doxygen | ||
] | ||
++ map (tool: | ||
tool.override { | ||
extraDependencies = edaExtraDeps; | ||
}) | ||
edaTools; | ||
extraOutputsToInstall = ["dev"]; | ||
|
||
extraBwrapArgs = [ | ||
# OpenSSL included in the Python downloaded by Bazel makes use of these paths. | ||
"--symlink ${pkgs.openssl.out}/etc/ssl/openssl.cnf /etc/ssl/openssl.cnf" | ||
"--symlink /etc/ssl/certs/ca-certificates.crt /etc/ssl/cert.pem" | ||
]; | ||
}) | ||
.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
runCommand, | ||
bazelisk, | ||
bazel_6, | ||
... | ||
}: | ||
# OpenTitan requires a specific version of Bazel. | ||
# We *could* package our own Bazel, but it can't be a simple override since Bazel build process | ||
# require a lot of Internet dependencies. | ||
# | ||
# For simplicity we'll just let bazelisk do the heavyloading. | ||
# | ||
# This package basically just creates an alias from bazel to bazelisk and adds the auto completion | ||
# which is absent in bazelisk. | ||
runCommand "bazel" {} '' | ||
cp -r ${bazelisk} $out | ||
chmod -R +w $out | ||
ln -s $out/bin/bazelisk $out/bin/bazel | ||
cp -r ${bazel_6}/share $out/share | ||
'' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
runCommand, | ||
ncurses5, | ||
patchelf, | ||
... | ||
}: | ||
# If SONAME is specified, lookup cache files created by ldconfig will only use the SONAME and will ignore | ||
# the filename, this casues libtinfo.so to not be found under FHS. Patch ncurses5 to provide a libtinfo.so | ||
# with proper SONAME. | ||
runCommand "ncurses5" { | ||
outputs = ["out" "dev" "man"]; | ||
} '' | ||
cp -r ${ncurses5} $out | ||
chmod +w $out/lib | ||
cp -L --no-preserve=mode --remove-destination `realpath $out/lib/libtinfo.so.5` $out/lib/libtinfo.so.5 | ||
${patchelf}/bin/patchelf --set-soname libtinfo.so.5 $out/lib/libtinfo.so.5 | ||
cp -r ${ncurses5.dev} $dev | ||
cp -r ${ncurses5.man} $man | ||
'' |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you pull out the wrapped/overridden packages into a let binding?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done