clang-analyzer: upgrade to latest llvm release

This commit is contained in:
Jörg Thalheim 2020-07-31 09:42:19 +01:00
parent 7d04fdaa69
commit 5de26dd52d
No known key found for this signature in database
GPG Key ID: 003F2096411B5F92
3 changed files with 33 additions and 30 deletions

View File

@ -1,22 +1,24 @@
From 6ab08bc1c889e4fb9a39432b1a654eaa19ee65eb Mon Sep 17 00:00:00 2001 From 40239d92957f1969652cdd41d6d2749c41ac4338 Mon Sep 17 00:00:00 2001
From: Austin Seipp <aseipp@pobox.com> From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= <joerg@thalheim.io>
Date: Fri, 2 May 2014 12:28:23 -0500 Date: Fri, 31 Jul 2020 09:22:03 +0100
Subject: [PATCH] Fix scan-build to use NIX_CFLAGS_COMPILE Subject: [PATCH] [PATCH] Fix scan-build to use NIX_CFLAGS_COMPILE
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Austin Seipp <aseipp@pobox.com> Signed-off-by: Jörg Thalheim <joerg@thalheim.io>
--- ---
tools/scan-build/ccc-analyzer | 9 +++++++++ tools/scan-build/libexec/ccc-analyzer | 8 ++++++++
1 file changed, 9 insertions(+) 1 file changed, 8 insertions(+)
diff --git a/tools/scan-build/ccc-analyzer b/tools/scan-build/ccc-analyzer diff --git a/tools/scan-build/libexec/ccc-analyzer b/tools/scan-build/libexec/ccc-analyzer
index b463ec0..9d39dd0 100755 index 800f38b5..0fb50fb3 100755
--- a/tools/scan-build/ccc-analyzer --- a/tools/scan-build/libexec/ccc-analyzer
+++ b/tools/scan-build/ccc-analyzer +++ b/tools/scan-build/libexec/ccc-analyzer
@@ -207,6 +207,15 @@ sub Analyze { @@ -246,6 +246,14 @@ sub Analyze {
push @Args, "-Xclang", "-analyzer-viz-egraph-ubigraph"; push @Args, "-target", $AnalyzerTarget;
} }
+
+ # Add Nix flags to analysis + # Add Nix flags to analysis
+ if (defined $ENV{'NIX_CFLAGS_COMPILE'}) { + if (defined $ENV{'NIX_CFLAGS_COMPILE'}) {
+ my @nixArgs = split(/\s+/, $ENV{'NIX_CFLAGS_COMPILE'}); + my @nixArgs = split(/\s+/, $ENV{'NIX_CFLAGS_COMPILE'});
@ -25,9 +27,9 @@ index b463ec0..9d39dd0 100755
+ } + }
+ } + }
+ +
my $AnalysisArgs = GetCCArgs("--analyze", \@Args); my $AnalysisArgs = GetCCArgs($HtmlDir, "--analyze", \@Args);
@CmdArgs = @$AnalysisArgs; @CmdArgs = @$AnalysisArgs;
} }
-- --
1.8.3.2 2.27.0

View File

@ -1,26 +1,24 @@
{ stdenv, fetchurl, clang, llvmPackages, perl, makeWrapper }: { stdenv, fetchurl, clang, llvmPackages, perl, makeWrapper, python3 }:
stdenv.mkDerivation rec { stdenv.mkDerivation rec {
pname = "clang-analyzer"; pname = "clang-analyzer";
version = "3.4"; inherit (llvmPackages.clang-unwrapped) src version;
src = fetchurl {
url = "http://llvm.org/releases/${version}/clang-${version}.src.tar.gz";
sha256 = "06rb4j1ifbznl3gfhl98s7ilj0ns01p7y7zap4p7ynmqnc6pia92";
};
patches = [ ./0001-Fix-scan-build-to-use-NIX_CFLAGS_COMPILE.patch ]; patches = [ ./0001-Fix-scan-build-to-use-NIX_CFLAGS_COMPILE.patch ];
buildInputs = [ clang llvmPackages.clang perl makeWrapper ]; buildInputs = [ clang llvmPackages.clang perl python3 ];
nativeBuildInputs = [ makeWrapper ];
dontBuild = true; dontBuild = true;
installPhase = '' installPhase = ''
mkdir -p $out/bin $out/libexec mkdir -p $out/share/scan-view $out/bin
cp -R tools/scan-view $out/libexec cp -R tools/scan-view/share/* $out/share/scan-view
cp -R tools/scan-build $out/libexec cp -R tools/scan-view/bin/* $out/bin/scan-view
cp -R tools/scan-build/* $out
makeWrapper $out/libexec/scan-view/scan-view $out/bin/scan-view rm $out/bin/*.bat $out/libexec/*.bat $out/CMakeLists.txt
makeWrapper $out/libexec/scan-build/scan-build $out/bin/scan-build \
wrapProgram $out/bin/scan-build \
--add-flags "--use-cc=${clang}/bin/clang" \ --add-flags "--use-cc=${clang}/bin/clang" \
--add-flags "--use-c++=${clang}/bin/clang++" \ --add-flags "--use-c++=${clang}/bin/clang++" \
--add-flags "--use-analyzer='${llvmPackages.clang}/bin/clang'" --add-flags "--use-analyzer='${llvmPackages.clang}/bin/clang'"

View File

@ -8271,7 +8271,10 @@ in
llvmPackages = llvmPackages_latest; llvmPackages = llvmPackages_latest;
}; };
clang-analyzer = callPackage ../development/tools/analysis/clang-analyzer { }; clang-analyzer = callPackage ../development/tools/analysis/clang-analyzer {
llvmPackages = llvmPackages_latest;
inherit (llvmPackages_latest) clang;
};
#Use this instead of stdenv to build with clang #Use this instead of stdenv to build with clang
clangStdenv = if stdenv.cc.isClang then stdenv else lowPrio llvmPackages.stdenv; clangStdenv = if stdenv.cc.isClang then stdenv else lowPrio llvmPackages.stdenv;