diff options
author | Rahul Butani <rrbutani@users.noreply.github.com> | 2023-01-27 14:51:12 -0800 |
---|---|---|
committer | Rahul Butani <rrbutani@users.noreply.github.com> | 2023-01-27 14:51:12 -0800 |
commit | 8afa321b8ac7a52c479c5226364c48c544038c06 (patch) | |
tree | 15c663a04b572d799adc4f0b9d517581b690d800 /pkgs/development/compilers/llvm | |
parent | 386aba3115176b11eb49a0606e9dd17506273776 (diff) | |
download | nixlib-8afa321b8ac7a52c479c5226364c48c544038c06.tar nixlib-8afa321b8ac7a52c479c5226364c48c544038c06.tar.gz nixlib-8afa321b8ac7a52c479c5226364c48c544038c06.tar.bz2 nixlib-8afa321b8ac7a52c479c5226364c48c544038c06.tar.lz nixlib-8afa321b8ac7a52c479c5226364c48c544038c06.tar.xz nixlib-8afa321b8ac7a52c479c5226364c48c544038c06.tar.zst nixlib-8afa321b8ac7a52c479c5226364c48c544038c06.zip |
llvmPackages_15.llvm: add checks for the LLVM version
this is in preparation for the next commit which exposes the release information and monorepo source as overridable args (which makes it easier for users to use their own LLVM in nixpkgs) this commit only adds a check in the `llvm` package's postConfigure that makes sure the LLVM source provided matches the version we were given; the actual machinery (functionally just a cosmetic change; causes no rebuilds) is in the next commit
Diffstat (limited to 'pkgs/development/compilers/llvm')
-rw-r--r-- | pkgs/development/compilers/llvm/15/llvm/default.nix | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/pkgs/development/compilers/llvm/15/llvm/default.nix b/pkgs/development/compilers/llvm/15/llvm/default.nix index 40fb105cdc52..e0b79a9acfef 100644 --- a/pkgs/development/compilers/llvm/15/llvm/default.nix +++ b/pkgs/development/compilers/llvm/15/llvm/default.nix @@ -255,6 +255,38 @@ in stdenv.mkDerivation (rec { ) ''; + # Defensive check: some paths (that we make symlinks to) depend on the release + # version, for example: + # - https://github.com/llvm/llvm-project/blob/406bde9a15136254f2b10d9ef3a42033b3cb1b16/clang/lib/Headers/CMakeLists.txt#L185 + # + # So we want to sure that the version in the source matches the release + # version we were given. + # + # We do this check here, in the LLVM build, because it happens early. + postConfigure = let + v = lib.versions; + major = v.major release_version; + minor = v.minor release_version; + patch = v.patch release_version; + in '' + # $1: part, $2: expected + check_version() { + part="''${1^^}" + part="$(cat include/llvm/Config/llvm-config.h | grep "#define LLVM_VERSION_''${part} " | cut -d' ' -f3)" + + if [[ "$part" != "$2" ]]; then + echo >&2 \ + "mismatch in the $1 version! we have version ${release_version}" \ + "and expected the $1 version to be '$2'; the source has '$part' instead" + exit 3 + fi + } + + check_version major ${major} + check_version minor ${minor} + check_version patch ${patch} + ''; + # E.g. mesa.drivers use the build-id as a cache key (see #93946): LDFLAGS = optionalString (enableSharedLibraries && !stdenv.isDarwin) "-Wl,--build-id=sha1"; |