Skip to content

Commit

Permalink
llvmPackages_git.llvm: add checks for the LLVM version
Browse files Browse the repository at this point in the history
this is a backport of 8afa321
from #194634 (llvmPackages_15)
  • Loading branch information
rrbutani authored and alyssais committed Apr 17, 2023
1 parent 9984ca0 commit 4917dc7
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions pkgs/development/compilers/llvm/git/llvm/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,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";

Expand Down

0 comments on commit 4917dc7

Please sign in to comment.