Merge pull request #7817 from gridaphobe/cc-wrapper-isgnu-isclang

Add isGNU and isClang attributes to cc-wrapper
This commit is contained in:
Eric Seidel 2015-05-14 10:09:07 -07:00
commit 67fe5d46d4
30 changed files with 42 additions and 32 deletions

View file

@ -18,7 +18,7 @@ stdenv.mkDerivation rec {
patchShebangs share/extensions patchShebangs share/extensions
'' ''
# Clang gets misdetected, so hardcode the right answer # Clang gets misdetected, so hardcode the right answer
+ stdenv.lib.optionalString (stdenv.cc.cc.isClang or false) '' + stdenv.lib.optionalString stdenv.cc.isClang ''
substituteInPlace src/ui/tool/node.h \ substituteInPlace src/ui/tool/node.h \
--replace "#if __cplusplus >= 201103L" "#if true" --replace "#if __cplusplus >= 201103L" "#if true"
''; '';

View file

@ -6,7 +6,7 @@
, kdeSupport ? false, qt4, kdelibs , kdeSupport ? false, qt4, kdelibs
}: }:
assert stdenv.isLinux && stdenv.cc.cc.isGNU or false && stdenv.cc.libc != null; assert stdenv.isLinux && stdenv.cc.isGNU && stdenv.cc.libc != null;
let let
mirror = http://get.geo.opera.com/pub/opera; mirror = http://get.geo.opera.com/pub/opera;

View file

@ -10,6 +10,7 @@
, zlib ? null, extraPackages ? [] , zlib ? null, extraPackages ? []
, dyld ? null # TODO: should this be a setup-hook on dyld? , dyld ? null # TODO: should this be a setup-hook on dyld?
, setupHook ? ./setup-hook.sh , setupHook ? ./setup-hook.sh
, isGNU ? false, isClang ? false
}: }:
with stdenv.lib; with stdenv.lib;
@ -41,7 +42,7 @@ stdenv.mkDerivation {
# The wrapper scripts use 'cat', so we may need coreutils. # The wrapper scripts use 'cat', so we may need coreutils.
coreutils = if nativeTools then null else coreutils; coreutils = if nativeTools then null else coreutils;
passthru = { inherit nativeTools nativeLibc nativePrefix; }; passthru = { inherit nativeTools nativeLibc nativePrefix isGNU isClang; };
buildCommand = buildCommand =
'' ''

View file

@ -10,7 +10,7 @@ in
( (
assert a.stdenv ? cc ; assert a.stdenv ? cc ;
assert a.stdenv.cc.cc.isGNU or false ; assert a.stdenv.cc.isGNU ;
assert a.stdenv.cc ? libc ; assert a.stdenv.cc ? libc ;
assert a.stdenv.cc.libc != null ; assert a.stdenv.cc.libc != null ;

View file

@ -1,6 +1,6 @@
{ stdenv, fetch, cmake, libxml2, libedit, llvm, version, clang-tools-extra_src }: { stdenv, fetch, cmake, libxml2, libedit, llvm, version, clang-tools-extra_src }:
let let
gcc = if stdenv.cc.cc.isGNU or false then stdenv.cc.cc else stdenv.cc.cc.gcc; gcc = if stdenv.cc.isGNU then stdenv.cc.cc else stdenv.cc.cc.gcc;
in stdenv.mkDerivation { in stdenv.mkDerivation {
name = "clang-${version}"; name = "clang-${version}";

View file

@ -1,7 +1,7 @@
{ stdenv, fetch, cmake, libxml2, libedit, llvm, version, clang-tools-extra_src }: { stdenv, fetch, cmake, libxml2, libedit, llvm, version, clang-tools-extra_src }:
let let
gcc = if stdenv.cc.cc.isGNU or false then stdenv.cc.cc else stdenv.cc.cc.gcc; gcc = if stdenv.cc.isGNU then stdenv.cc.cc else stdenv.cc.cc.gcc;
in stdenv.mkDerivation { in stdenv.mkDerivation {
name = "clang-${version}"; name = "clang-${version}";

View file

@ -1,6 +1,6 @@
{stdenv, fetchurl, guile, texinfo}: {stdenv, fetchurl, guile, texinfo}:
assert stdenv ? cc && stdenv.cc.cc.isGNU or false; assert stdenv ? cc && stdenv.cc.isGNU;
stdenv.mkDerivation rec { stdenv.mkDerivation rec {
name = "guile-lib-0.2.2"; name = "guile-lib-0.2.2";

View file

@ -129,7 +129,7 @@ stdenv.mkDerivation rec {
"--disable-stripping" "--disable-stripping"
# Disable mmx support for 0.6.90 # Disable mmx support for 0.6.90
(verFix null "0.6.90" "--disable-mmx") (verFix null "0.6.90" "--disable-mmx")
] ++ optional (stdenv.cc.cc.isClang or false) "--cc=clang"; ] ++ optional stdenv.cc.isClang "--cc=clang";
nativeBuildInputs = [ perl pkgconfig texinfo yasm ]; nativeBuildInputs = [ perl pkgconfig texinfo yasm ];

View file

@ -21,7 +21,7 @@ stdenv.mkDerivation rec {
++ optional (precision != "double") "--enable-${precision}" ++ optional (precision != "double") "--enable-${precision}"
# all x86_64 have sse2 # all x86_64 have sse2
++ optional stdenv.isx86_64 "--enable-sse2" ++ optional stdenv.isx86_64 "--enable-sse2"
++ optional (stdenv.cc.cc.isGNU or false) "--enable-openmp"; ++ optional stdenv.cc.isGNU "--enable-openmp";
enableParallelBuilding = true; enableParallelBuilding = true;

View file

@ -18,7 +18,7 @@ stdenv.mkDerivation (rec {
patches = [ ./deadlock.patch ] patches = [ ./deadlock.patch ]
++ map fetchurl (import ./debian-patches.nix) ++ map fetchurl (import ./debian-patches.nix)
++ stdenv.lib.optional (stdenv.cc.cc.isClang or false) ./returnval.patch; ++ stdenv.lib.optional stdenv.cc.isClang ./returnval.patch;
meta = with stdenv.lib; { meta = with stdenv.lib; {

View file

@ -7,7 +7,7 @@
with stdenv.lib; with stdenv.lib;
assert !stdenv.isDarwin -> stdenv.cc.cc.isGNU or false; assert !stdenv.isDarwin -> stdenv.cc.isGNU;
# TODO: # TODO:
# * Add gio-module-fam # * Add gio-module-fam

View file

@ -8,7 +8,7 @@
, withGd ? false, gd ? null, libpng ? null , withGd ? false, gd ? null, libpng ? null
}: }:
assert stdenv.cc.cc.isGNU or false; assert stdenv.cc.isGNU;
let let
build = import ./common.nix; build = import ./common.nix;

View file

@ -37,7 +37,7 @@ stdenv.mkDerivation rec {
makeFlags = [ makeFlags = [
"SHELL=${stdenv.shell}" "SHELL=${stdenv.shell}"
"INSTALL_ROOT=$(out)" "INSTALL_ROOT=$(out)"
] ++ optional (stdenv.cc.cc.isClang or false) "CC=clang"; ] ++ optional stdenv.cc.isClang "CC=clang";
preInstall = "mkdir -p $out/{bin,lib,man/man1,man/man3,include/gsm}"; preInstall = "mkdir -p $out/{bin,lib,man/man1,man/man3,include/gsm}";

View file

@ -10,7 +10,7 @@ stdenv.mkDerivation rec {
postPatch = '' postPatch = ''
sed -i 's/^\(CFLAGS.*\)$/\1 -fPIC/' Makefile sed -i 's/^\(CFLAGS.*\)$/\1 -fPIC/' Makefile
'' + stdenv.lib.optionalString (stdenv.cc.cc.isClang or false) '' '' + stdenv.lib.optionalString stdenv.cc.isClang ''
substituteInPlace Makefile libjbig/Makefile pbmtools/Makefile \ substituteInPlace Makefile libjbig/Makefile pbmtools/Makefile \
--replace "CC = gcc" "CC = clang" --replace "CC = gcc" "CC = clang"
''; '';

View file

@ -10,7 +10,7 @@ stdenv.mkDerivation {
# gcc 4.8 optimisations break judy. # gcc 4.8 optimisations break judy.
# http://sourceforge.net/p/judy/mailman/message/31995144/ # http://sourceforge.net/p/judy/mailman/message/31995144/
preConfigure = stdenv.lib.optionalString (stdenv.cc.cc.isGNU or false) '' preConfigure = stdenv.lib.optionalString stdenv.cc.isGNU ''
configureFlagsArray+=("CFLAGS=-fno-strict-aliasing -fno-aggressive-loop-optimizations") configureFlagsArray+=("CFLAGS=-fno-strict-aliasing -fno-aggressive-loop-optimizations")
''; '';

View file

@ -12,7 +12,7 @@ stdenv.mkDerivation rec {
nativeBuildInputs = [ pkgconfig ]; nativeBuildInputs = [ pkgconfig ];
configureFlags = if (stdenv.cc.cc.isClang or false) configureFlags = if stdenv.cc.isClang
then [ "--disable-werror" ] else null; then [ "--disable-werror" ] else null;
CXXFLAGS="--std=gnu++0x"; # For c++11 constants in lcms2.h CXXFLAGS="--std=gnu++0x"; # For c++11 constants in lcms2.h

View file

@ -12,7 +12,7 @@ stdenv.mkDerivation rec {
NIX_CFLAGS_COMPILE = if stdenv.isDarwin then "-D__unix" else null; NIX_CFLAGS_COMPILE = if stdenv.isDarwin then "-D__unix" else null;
# This dead code causes a duplicate symbol error in Clang so just remove it # This dead code causes a duplicate symbol error in Clang so just remove it
postPatch = if (stdenv.cc.cc.isClang or false) then '' postPatch = if stdenv.cc.isClang then ''
substituteInPlace jpeg/ejpeg.h --replace "int No_JPEG_Header_Flag" "" substituteInPlace jpeg/ejpeg.h --replace "int No_JPEG_Header_Flag" ""
'' else null; '' else null;

View file

@ -12,7 +12,7 @@ stdenv.mkDerivation rec {
# optimize.diff is taken from https://projects.archlinux.org/svntogit/packages.git/tree/trunk/optimize.diff?h=packages/libmad # optimize.diff is taken from https://projects.archlinux.org/svntogit/packages.git/tree/trunk/optimize.diff?h=packages/libmad
# It is included here in order to fix a build failure in Clang # It is included here in order to fix a build failure in Clang
# But it may be useful to fix other, currently unknown problems as well # But it may be useful to fix other, currently unknown problems as well
++ stdenv.lib.optional (stdenv.cc.cc.isClang or false) [ ./optimize.diff ]; ++ stdenv.lib.optional stdenv.cc.isClang [ ./optimize.diff ];
nativeBuildInputs = [ autoconf ]; nativeBuildInputs = [ autoconf ];

View file

@ -23,7 +23,7 @@ stdenv.mkDerivation {
# Clang generates warnings in Boost's header files # Clang generates warnings in Boost's header files
# -Werror causes these warnings to be interpreted as errors # -Werror causes these warnings to be interpreted as errors
# Simplest solution: disable -Werror # Simplest solution: disable -Werror
configureFlags = if (stdenv.cc.cc.isClang or false) configureFlags = if stdenv.cc.isClang
then [ "--disable-werror" ] else null; then [ "--disable-werror" ] else null;
meta = { meta = {

View file

@ -8,7 +8,7 @@ stdenv.mkDerivation rec {
sha256 = "120jkda2q58p0n68banh64vsfm3hgqnacagj425d218cr4ycdkyb"; sha256 = "120jkda2q58p0n68banh64vsfm3hgqnacagj425d218cr4ycdkyb";
}; };
NIX_LDFLAGS = stdenv.lib.optionalString (stdenv.cc.cc.isGNU or false) "-lssp"; NIX_LDFLAGS = stdenv.lib.optionalString stdenv.cc.isGNU "-lssp";
doCheck = true; doCheck = true;

View file

@ -14,7 +14,7 @@ stdenv.mkDerivation rec {
postInstall = glib.flattenInclude; postInstall = glib.flattenInclude;
patches = stdenv.lib.optional (stdenv.cc.cc.isClang or false) ./fix-clang36.patch; patches = stdenv.lib.optional stdenv.cc.isClang ./fix-clang36.patch;
meta = { meta = {
homepage = http://pixman.org; homepage = http://pixman.org;

View file

@ -12,7 +12,7 @@ stdenv.mkDerivation {
sha256 = "1b0f4wm1qmgcswmixv9mwbp86hbdqxk754hml8cjv5vajvqwdpzv"; sha256 = "1b0f4wm1qmgcswmixv9mwbp86hbdqxk754hml8cjv5vajvqwdpzv";
}; };
sourceRoot = if (stdenv.cc.cc.isClang or false) sourceRoot = if stdenv.cc.isClang
then "astyle/build/clang" then "astyle/build/clang"
else "astyle/build/gcc"; else "astyle/build/gcc";

View file

@ -80,7 +80,7 @@ in
}; };
libxkbfile = attrs: attrs // { libxkbfile = attrs: attrs // {
patches = lib.optional (stdenv.cc.cc.isClang or false) ./libxkbfile-clang36.patch; patches = lib.optional stdenv.cc.isClang ./libxkbfile-clang36.patch;
}; };
libpciaccess = attrs : attrs // { libpciaccess = attrs : attrs // {

View file

@ -90,6 +90,7 @@ rec {
cc = "/usr"; cc = "/usr";
outPath = nativePrefix; outPath = nativePrefix;
}; };
isClang = true;
}; };
}; };
pkgs = allPackages { pkgs = allPackages {
@ -129,13 +130,14 @@ rec {
cc = import ../../build-support/cc-wrapper { cc = import ../../build-support/cc-wrapper {
inherit stdenv; inherit stdenv;
nativeTools = false; nativeTools = false;
nativeLibc = true; nativeLibc = true;
binutils = pkgs.darwin.cctools; binutils = pkgs.darwin.cctools;
cc = pkgs.llvmPackages.clang-unwrapped; cc = pkgs.llvmPackages.clang-unwrapped;
coreutils = pkgs.coreutils; coreutils = pkgs.coreutils;
shell = "${pkgs.bash}/bin/bash"; shell = "${pkgs.bash}/bin/bash";
extraPackages = [ pkgs.libcxx ]; extraPackages = [ pkgs.libcxx ];
isClang = true;
}; };
shell = "${pkgs.bash}/bin/bash"; shell = "${pkgs.bash}/bin/bash";

View file

@ -91,6 +91,7 @@ rec {
nativeTools = false; nativeTools = false;
nativeLibc = false; nativeLibc = false;
cc = gccPlain; cc = gccPlain;
isGNU = true;
libc = glibc; libc = glibc;
inherit binutils coreutils; inherit binutils coreutils;
name = name; name = name;
@ -234,6 +235,7 @@ rec {
gcc = lib.makeOverridable (import ../../build-support/cc-wrapper) { gcc = lib.makeOverridable (import ../../build-support/cc-wrapper) {
nativeTools = false; nativeTools = false;
nativeLibc = false; nativeLibc = false;
isGNU = true;
cc = stage4.stdenv.cc.cc; cc = stage4.stdenv.cc.cc;
libc = stage4.pkgs.glibc; libc = stage4.pkgs.glibc;
inherit (stage4.pkgs) binutils coreutils; inherit (stage4.pkgs) binutils coreutils;

View file

@ -20,6 +20,7 @@ import ../generic rec {
inherit stdenv; inherit stdenv;
binutils = pkgs.binutils; binutils = pkgs.binutils;
cc = pkgs.gcc.cc; cc = pkgs.gcc.cc;
isGNU = true;
coreutils = pkgs.coreutils; coreutils = pkgs.coreutils;
shell = pkgs.bash + "/bin/sh"; shell = pkgs.bash + "/bin/sh";
}; };

View file

@ -1,6 +1,6 @@
{ lib, stdenv, fetchurl, readline, tcp_wrappers, pcre, makeWrapper }: { lib, stdenv, fetchurl, readline, tcp_wrappers, pcre, makeWrapper }:
assert stdenv.isLinux; assert stdenv.isLinux;
assert stdenv.cc.cc.isGNU or false; assert stdenv.cc.isGNU;
let let
version = "0.7"; version = "0.7";
debianPatch = fetchurl { debianPatch = fetchurl {

View file

@ -13,7 +13,7 @@ stdenv.mkDerivation rec {
# ./configure time check for any of this. # ./configure time check for any of this.
buildInputs = [ libevent openssl zlib torsocks ]; buildInputs = [ libevent openssl zlib torsocks ];
CFLAGS = stdenv.lib.optionalString (stdenv.cc.cc.isGNU or false) "-lgcc_s"; CFLAGS = stdenv.lib.optionalString stdenv.cc.isGNU "-lgcc_s";
# Patch 'torify' to point directly to torsocks. # Patch 'torify' to point directly to torsocks.
patchPhase = '' patchPhase = ''

View file

@ -24,7 +24,7 @@ stdenv.mkDerivation rec {
++ optional gnutlsSupport "CRYPTO=GNUTLS" ++ optional gnutlsSupport "CRYPTO=GNUTLS"
++ optional opensslSupport "CRYPTO=OPENSSL" ++ optional opensslSupport "CRYPTO=OPENSSL"
++ optional stdenv.isDarwin "SYS=darwin" ++ optional stdenv.isDarwin "SYS=darwin"
++ optional (stdenv.cc.cc.isClang or false) "CC=clang"; ++ optional stdenv.cc.isClang "CC=clang";
buildInputs = [ zlib ] buildInputs = [ zlib ]
++ optional gnutlsSupport gnutls ++ optional gnutlsSupport gnutls

View file

@ -3437,6 +3437,7 @@ let
clangWrapSelf = build: (import ../build-support/cc-wrapper) { clangWrapSelf = build: (import ../build-support/cc-wrapper) {
cc = build; cc = build;
isClang = true;
stdenv = clangStdenv; stdenv = clangStdenv;
libc = glibc; libc = glibc;
binutils = binutils; binutils = binutils;
@ -4497,6 +4498,8 @@ let
nativePrefix = stdenv.cc.nativePrefix or ""; nativePrefix = stdenv.cc.nativePrefix or "";
cc = baseCC; cc = baseCC;
libc = libc; libc = libc;
isGNU = baseCC.isGNU or false;
isClang = baseCC.isClang or false;
inherit stdenv binutils coreutils zlib; inherit stdenv binutils coreutils zlib;
}; };
@ -4536,6 +4539,7 @@ let
nativePrefix = stdenv.cc.nativePrefix or ""; nativePrefix = stdenv.cc.nativePrefix or "";
cc = baseGCC; cc = baseGCC;
libc = glibc; libc = glibc;
isGNU = true;
inherit stdenv binutils coreutils zlib; inherit stdenv binutils coreutils zlib;
setupHook = ../build-support/cc-wrapper/setup-hook-stdinc.sh; setupHook = ../build-support/cc-wrapper/setup-hook-stdinc.sh;
}; };