From 5a4feee1826a89ea169ec34af480607650ea9d4e Mon Sep 17 00:00:00 2001 From: Ross Smyth <18294397+RossSmyth@users.noreply.github.com> Date: Fri, 6 Jun 2025 13:11:27 -0400 Subject: [PATCH] wild: init at 0.7.0 --- pkgs/by-name/wi/wild/adapterTest.nix | 99 ++++++++++++++++++++++++++++ pkgs/by-name/wi/wild/package.nix | 60 +++++++++++++++++ 2 files changed, 159 insertions(+) create mode 100644 pkgs/by-name/wi/wild/adapterTest.nix create mode 100644 pkgs/by-name/wi/wild/package.nix diff --git a/pkgs/by-name/wi/wild/adapterTest.nix b/pkgs/by-name/wi/wild/adapterTest.nix new file mode 100644 index 000000000000..db334485cd80 --- /dev/null +++ b/pkgs/by-name/wi/wild/adapterTest.nix @@ -0,0 +1,99 @@ +{ + lib, + stdenv, + makeBinaryWrapper, + gcc, + wild, + binutils-unwrapped-all-targets, + clang, + lld, + clang-tools, +}: +let + # These wrappers are REQUIRED for the Wild test suite to pass + # + # Write a wrapper for GCC that passes -B to *unwrapped* binutils. + # This ensures that if -fuse-ld=bfd is used, gcc picks up unwrapped ld.bfd + # instead of the hardcoded wrapper search directory. + # We pass it last because apparently gcc likes picking ld from the *first* -B, + # which we want our wild target directory to be if passed. + gccWrapper = stdenv.mkDerivation { + inherit (gcc) name; + dontUnpack = true; + dontConfigure = true; + dontInstall = true; + + buildInputs = [ makeBinaryWrapper ]; + buildPhase = '' + runHook preBuild + + makeWrapper ${lib.getExe gcc} $out/bin/gcc \ + --append-flag -B${binutils-unwrapped-all-targets}/bin + + runHook postBuild + ''; + + }; + + gppWrapper = stdenv.mkDerivation { + dontUnpack = true; + dontConfigure = true; + dontInstall = true; + + name = "g++-wrapped"; + buildInputs = [ makeBinaryWrapper ]; + buildPhase = '' + runHook preBuild + + makeWrapper ${lib.getExe' gcc "g++"} $out/bin/g++ \ + --append-flag -B${binutils-unwrapped-all-targets}/bin + + runHook postBuild + ''; + }; +in +{ + testWild = wild.overrideAttrs { + pname = "wild-tests"; + doCheck = true; + doInstallCheck = false; + dontBuild = true; + buildType = "debug"; + + checkInputs = [ + stdenv.cc.libc.out + stdenv.cc.libc.static + ]; + + # https://github.com/davidlattimore/wild/discussions/832#discussioncomment-14482948 + checkFlags = lib.optionals stdenv.hostPlatform.isAarch64 [ + "--skip=integration_test::program_name_71___unresolved_symbols_object_c__" + ]; + + # wild's tests compare the outputs of several different linkers. nixpkgs's + # patching and wrappers change the output behavior, so we must make sure + # that their behavior is compatible. + # + # Does not work if they are put in nativeCheckInputs or checkInputs + preCheck = '' + export LD_LIBRARY_PATH=${ + lib.makeLibraryPath [ + stdenv.cc.cc.lib + ] + }:$LD_LIBRARY_PATH + + export PATH=${ + lib.makeBinPath [ + binutils-unwrapped-all-targets + clang + gccWrapper + gppWrapper + lld + clang-tools + ] + }:$PATH + ''; + + installPhase = "touch $out"; + }; +} diff --git a/pkgs/by-name/wi/wild/package.nix b/pkgs/by-name/wi/wild/package.nix new file mode 100644 index 000000000000..544a56eebabf --- /dev/null +++ b/pkgs/by-name/wi/wild/package.nix @@ -0,0 +1,60 @@ +{ + lib, + fetchFromGitHub, + callPackage, + versionCheckHook, + rustPlatform, + pkg-config, + zstd, + nix-update-script, +}: +rustPlatform.buildRustPackage (finalAttrs: { + pname = "wild"; + version = "0.7.0"; + + src = fetchFromGitHub { + owner = "davidlattimore"; + repo = "wild"; + tag = finalAttrs.version; + hash = "sha256-x0IZuWjj0LRMj4pu2FVaD8SENm/UVtE1e4rl0EOZZZM="; + }; + + cargoHash = "sha256-5s0qS8y0+EH+R1tgN2W5/+t+GdjbQdRVLlcA2KjpHsE="; + + cargoBuildFlags = [ "-p wild-linker" ]; + + strictDeps = true; + nativeBuildInputs = [ + pkg-config + ]; + buildInputs = [ + zstd + ]; + + env.ZSTD_SYS_USE_PKG_CONFIG = true; + + doCheck = false; # Tests are ran in passthru tests + + doInstallCheck = true; + nativeInstallCheckInputs = [ versionCheckHook ]; + versionCheckProgramArg = "--version"; + + passthru = { + updateScript = nix-update-script { }; + + tests = callPackage ./adapterTest.nix { wild = finalAttrs.finalPackage; }; + }; + + meta = { + description = "Very fast linker for Linux"; + homepage = "https://github.com/davidlattimore/wild"; + changelog = "https://github.com/davidlattimore/wild/blob/${finalAttrs.version}/CHANGELOG.md"; + license = [ + lib.licenses.asl20 # or + lib.licenses.mit + ]; + mainProgram = "wild"; + maintainers = with lib.maintainers; [ RossSmyth ]; + platforms = lib.platforms.linux; + }; +})