-
Notifications
You must be signed in to change notification settings - Fork 1
feat: add a depends only devshell #31
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
base: master
Are you sure you want to change the base?
Conversation
|
Note: will need to also update the CI depends job once this merges to use the new shell, but I didn't want to mix CI changes in this one and in theory this new one shouldn't break the old one. |
willcl-ark
left a comment
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.
This shim is pretty neat conceptually, but personally I'd make it a bit more "nixxy", like this:
diff --git a/flake.nix b/flake.nix
index 7201ec9..8c5a88a 100644
--- a/flake.nix
+++ b/flake.nix
@@ -55,6 +55,20 @@
linuxPackages.bpftrace
];
+ # Alias gcc/g++ to clang/clang++
+ clangShim = pkgs.stdenv.mkDerivation {
+ name = "clang-shim";
+ buildInputs = [llvmTools.clang];
+ phases = ["installPhase"];
+ installPhase = ''
+ mkdir -p $out/bin
+ ln -s ${llvmTools.clang}/bin/clang $out/bin/gcc
+ ln -s ${llvmTools.clang}/bin/clang++ $out/bin/g++
+ ln -s ${llvmTools.clang}/bin/clang $out/bin/clang
+ ln -s ${llvmTools.clang}/bin/clang++ $out/bin/clang++
+ '';
+ };
+
# Will only exist in the build environment and includes everything needed
# for a depends build
dependsNativeBuildInputs = with pkgs;
@@ -64,8 +78,8 @@
cmake
curlMinimal
llvmTools.bintools
- llvmTools.clang
llvmTools.clang-tools
+ clangShim
ninja
pkg-config
xz
@@ -112,9 +126,6 @@
inherit (env) CMAKE_GENERATOR LD_LIBRARY_PATH LOCALE_ARCHIVE;
};
- # TODO: this could be ported to a gcc shell in the future to bring this closer in line
- # with our guix depends build. This would allow us to remove the shellHook hack that shims
- # in clang to masquerade as gcc
depends = pkgs.mkShellNoCC {
nativeBuildInputs = dependsNativeBuildInputs;
buildInputs = usdtPkgs;
@@ -123,19 +134,7 @@
# build system, so we unset this in the depends devshell
unset SOURCE_DATE_EPOCH
- # its not super easy to override compiler defaults in
- # depends, so as a hack we just shim in clang and pretend
- # its gcc. this is done in a tmp dir to avoid polluting the
- # users shell and is cleaned up when the shell is exited.
- TMP_GCC_SHIM=$(mktemp -d "$TMPDIR/clang-shim.XXXXXX")
-
- ln -sf $(command -v clang++) "$TMP_GCC_SHIM/g++"
- ln -sf $(command -v clang) "$TMP_GCC_SHIM/gcc"
-
- export PATH="$TMP_GCC_SHIM:$PATH"
- echo "Using fake gcc/g++ -> clang in: $TMP_GCC_SHIM"
-
- trap "rm -rf $TMP_GCC_SHIM" EXIT
+ echo "gcc/g++ are shimmed to llvm tools"
'';
inherit (env) CMAKE_GENERATOR LOCALE_ARCHIVE;
};LMK what you think?
|
Did a CI run using the shell in https://github.com/bitcoin-dev-tools/bix/actions/runs/15854794287/job/44697246541?pr=33 Feel free to cherry-pick that commit here if you like |
|
Thanks for the review, @willcl-ark , will update tomorrow! I much prefer your Also fine to go with this one for now and we can work on squaring up with guix builds as a separate task. |
|
Well in my testing the shim seemed to break nixpkgs builds: https://github.com/bitcoin-dev-tools/bix/actions/runs/15859413754/job/44712638536?pr=33 but depends build worked ok: https://github.com/bitcoin-dev-tools/bix/actions/runs/15859413749/job/44712638535?pr=33 Not sure what happened. I can perhaps look more closely later, but just a heads-up |
Add a depends devshell. This shell only includes packages needed for doing a depends build and some basic debugging tools. This needs to be a separate shell because depends building will fail if there are system packages installed. Conceptually, its also cleaner to only include the necessary dependencies for a depends build since this is precisely the scenario in which depends is useful.
2339ee4 to
92dedcf
Compare
|
Updated to use |
Add a depends devshell. This shell only includes packages needed for doing a depends build and some basic debugging tools.
This needs to be a separate shell because depends building will fail if there are system packages installed. Conceptually, its also cleaner to only include the necessary dependencies for a depends build since this is precisely the scenario in which depends is useful.
Closes #19