From 9aa8ae999ad1562e15e3aa2066549e0a0cf7ac3e Mon Sep 17 00:00:00 2001 From: Luke Granger-Brown Date: Sat, 17 Apr 2021 01:29:46 +0000 Subject: [PATCH] llvmPackages_12.llvm: fix building on older CPUs This commit patches one of the llvm-exegesis tests to swap out whatever CPU model happens to be on the build host for bdver2 (AMD Family 15h/Piledriver), which was picked because it looks like that was the intent of the test author. This provides a more predictable compilation behaviour when running on older (or possibly even newer!) machines. One of the machines that is currently part of the NixOS Hydra build farm, wendy, is using an old AMD Opteron CPU for which LLVM has no scheduling machine model. This causes one of the tests for llvm-exegesis to fail, because it segfaults trying to use the machine model to produce useful analysis results. Note that this particular test only runs on x86-64 build hosts anyway; aarch64 isn't affected. This deliberately only patches LLVM 12 to limit the rebuilds; other LLVM versions are going through staging. --- pkgs/development/compilers/llvm/12/llvm/default.nix | 6 ++++++ .../compilers/llvm/exegesis-force-bdver2.patch | 11 +++++++++++ 2 files changed, 17 insertions(+) create mode 100644 pkgs/development/compilers/llvm/exegesis-force-bdver2.patch diff --git a/pkgs/development/compilers/llvm/12/llvm/default.nix b/pkgs/development/compilers/llvm/12/llvm/default.nix index 0d0075fddc79..33bb7b931f1e 100644 --- a/pkgs/development/compilers/llvm/12/llvm/default.nix +++ b/pkgs/development/compilers/llvm/12/llvm/default.nix @@ -55,6 +55,12 @@ in stdenv.mkDerivation (rec { propagatedBuildInputs = [ ncurses zlib ]; + patches = [ + # Force a test to evaluate the saved benchmark for a CPU for which LLVM has + # an execution model. See NixOS/nixpkgs#119673. + ../../exegesis-force-bdver2.patch + ]; + postPatch = optionalString stdenv.isDarwin '' substituteInPlace cmake/modules/AddLLVM.cmake \ --replace 'set(_install_name_dir INSTALL_NAME_DIR "@rpath")' "set(_install_name_dir)" \ diff --git a/pkgs/development/compilers/llvm/exegesis-force-bdver2.patch b/pkgs/development/compilers/llvm/exegesis-force-bdver2.patch new file mode 100644 index 000000000000..c2654153ed5a --- /dev/null +++ b/pkgs/development/compilers/llvm/exegesis-force-bdver2.patch @@ -0,0 +1,11 @@ +diff --git a/test/tools/llvm-exegesis/X86/uops-CMOV16rm-noreg.s b/test/tools/llvm-exegesis/X86/uops-CMOV16rm-noreg.s +index 3fc1f31d54dc..a4c9bdd92131 100644 +--- a/test/tools/llvm-exegesis/X86/uops-CMOV16rm-noreg.s ++++ b/test/tools/llvm-exegesis/X86/uops-CMOV16rm-noreg.s +@@ -1,5 +1,6 @@ + # RUN: llvm-exegesis -mode=uops -opcode-name=CMOV16rm -benchmarks-file=%t.CMOV16rm-uops.yaml + # RUN: FileCheck -check-prefixes=CHECK-YAML -input-file=%t.CMOV16rm-uops.yaml %s ++# RUN: sed -i 's,cpu_name:.*,cpu_name: bdver2,g' %t.CMOV16rm-uops.yaml + # RUN: llvm-exegesis -mcpu=bdver2 -mode=analysis -benchmarks-file=%t.CMOV16rm-uops.yaml -analysis-clusters-output-file=- -analysis-clustering-epsilon=0.1 -analysis-inconsistency-epsilon=0.1 -analysis-numpoints=1 -analysis-clustering=naive | FileCheck -check-prefixes=CHECK-CLUSTERS %s + + # https://bugs.llvm.org/show_bug.cgi?id=41448