Merge pull request #27 from oxalica/fix/clippy-darwin

Fix clippy RPath on darwin
wip/nixpkgs-raku
oxalica 3 years ago committed by GitHub
commit debcaeb783
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 13
      .github/workflows/ci.yaml
  2. 77
      rust-overlay.nix

@ -78,10 +78,11 @@ jobs:
matrix:
os: [ubuntu-latest, macos-latest]
channel: [stable, beta]
build_pkg: [rust, default]
name: Check build Rust
runs-on: ${{ matrix.os }}
env:
build_expr: (import <nixpkgs> { overlays = [ (import ./.) ]; }).rust-bin.${{ matrix.channel }}.latest.rust
build_expr: (import <nixpkgs> { overlays = [ (import ./.) ]; }).rust-bin.${{ matrix.channel }}.latest.${{ matrix.build_pkg }}
steps:
- name: Checkout
uses: actions/checkout@v2
@ -104,7 +105,7 @@ jobs:
id: cache-drv-status
uses: actions/cache@v2
with:
key: successful-drv-rust-${{ steps.instantiate.outputs.drv_path }}
key: drv-check-build-0-${{ steps.instantiate.outputs.drv_path }}
path: successful
- name: Build Rust
if: steps.cache-drv-status.outputs.cache-hit != 'true'
@ -114,13 +115,19 @@ jobs:
- name: Prepare nix-shell
if: steps.cache-drv-status.outputs.cache-hit != 'true'
run: nix-shell -p "$build_expr" --pure --command "exit"
- name: Check compile
- name: Check `rustc` works
if: steps.cache-drv-status.outputs.cache-hit != 'true'
run: |
echo 'fn main() { println!("hello, world"); }' >./test.rs
# Use nix-shell to bring propagatedBuildInputs into scope.
nix-shell -p "$build_expr" --pure --command "rustc test.rs -o test"
[[ "$(./test)" == "hello, world" ]]
- name: Check `clippy` works
if: steps.cache-drv-status.outputs.cache-hit != 'true'
run: |
echo 'fn main() { loop { break; } }' >./test.rs
nix-shell -p "$build_expr" --pure --command 'clippy-driver test.rs -W clippy::never-loop' 2>&1 | tee msg
[[ ${PIPESTATUS[0]} -eq 0 && "$(cat msg)" == *"warning: this loop never actually loops"* ]]
- name: Mark a successful build for cache
if: steps.cache-drv-status.outputs.cache-hit != 'true'
run: echo "1" >./successful

@ -199,41 +199,52 @@ let
runHook postInstall
'';
# (@nbp) TODO: Check on Windows and Mac.
# This code is inspired by patchelf/setup-hook.sh to iterate over all binaries.
preFixup = ''
setInterpreter() {
local dir="$1"
[ -e "$dir" ] || return 0
header "Patching interpreter of ELF executables and libraries in $dir"
local i
while IFS= read -r -d ''$'\0' i; do
if [[ "$i" =~ .build-id ]]; then continue; fi
if ! isELF "$i"; then continue; fi
echo "setting interpreter of $i"
if [[ -x "$i" ]]; then
# Handle executables
patchelf \
--set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
--set-rpath "${super.lib.makeLibraryPath [ self.zlib ]}:$out/lib" \
"$i" || true
else
# Handle libraries
preFixup =
let
inherit (super.lib) optionalString;
inherit (self.stdenv) hostPlatform;
in
optionalString hostPlatform.isLinux ''
setInterpreter() {
local dir="$1"
[ -e "$dir" ] || return 0
header "Patching interpreter of ELF executables and libraries in $dir"
local i
while IFS= read -r -d ''$'\0' i; do
if [[ "$i" =~ .build-id ]]; then continue; fi
if ! isELF "$i"; then continue; fi
echo "setting interpreter of $i"
if [[ -x "$i" ]]; then
# Handle executables
patchelf \
--set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
--set-rpath "${super.lib.makeLibraryPath [ self.zlib ]}:$out/lib" \
"$i" || true
else
# Handle libraries
patchelf \
--set-rpath "${super.lib.makeLibraryPath [ self.zlib ]}:$out/lib" \
"$i" || true
fi
done < <(find "$dir" -type f -print0)
}
setInterpreter $out
'' + optionalString (pname == "clippy-preview") ''
if [[ -e "$out/bin/clippy-driver" ]]; then
${optionalString hostPlatform.isLinux ''
patchelf \
--set-rpath "${super.lib.makeLibraryPath [ self.zlib ]}:$out/lib" \
"$i" || true
fi
done < <(find "$dir" -type f -print0)
}
setInterpreter $out
'' + super.lib.optionalString (pname == "clippy-preview") ''
if [[ -e "$out/bin/clippy-driver" ]]; then
patchelf \
--set-rpath "${rustc}/lib:${super.lib.makeLibraryPath [ self.zlib ]}:$out/lib" \
"$out/bin/clippy-driver" || true
fi
'';
--set-rpath "${rustc}/lib:${super.lib.makeLibraryPath [ self.zlib ]}:$out/lib" \
"$out/bin/clippy-driver" || true
''}
${optionalString hostPlatform.isDarwin ''
install_name_tool \
-add_rpath "${rustc}/lib" \
"$out/bin/clippy-driver" || true
''}
fi
'';
postFixup = ''
# Function moves well-known files from etc/

Loading…
Cancel
Save