xcbuild: assorted fixes and cleanups

This is in preparation for the LLVM 4 upgrade (which gets more strict
about e.g., return false in xcbuild itself) and also for using xcbuild
more extensively in the Darwin stdenv bootstrap process, which is why I
killed the unnecessary gcc dependency in the toolchain. llvm-cov pretends
to be gcov anyway, so we're fine.
This commit is contained in:
Dan Peebles 2017-03-21 23:22:15 -04:00
parent 5561abd556
commit 3263d02626
8 changed files with 40 additions and 9 deletions

View File

@ -42,6 +42,7 @@ let
passthru = {
lib = self; # compatibility with gcc, so that `stdenv.cc.cc.lib` works on both
isClang = true;
inherit llvm;
} // stdenv.lib.optionalAttrs stdenv.isLinux {
inherit gcc;
};

View File

@ -53,6 +53,7 @@ let
passthru = {
lib = self; # compatibility with gcc, so that `stdenv.cc.cc.lib` works on both
isClang = true;
inherit llvm;
} // stdenv.lib.optionalAttrs stdenv.isLinux {
inherit gcc;
};

View File

@ -42,6 +42,7 @@ let
passthru = {
lib = self; # compatibility with gcc, so that `stdenv.cc.cc.lib` works on both
isClang = true;
inherit llvm;
} // stdenv.lib.optionalAttrs stdenv.isLinux {
inherit gcc;
};

View File

@ -53,6 +53,7 @@ let
passthru = {
lib = self; # compatibility with gcc, so that `stdenv.cc.cc.lib` works on both
isClang = true;
inherit llvm;
} // stdenv.lib.optionalAttrs stdenv.isLinux {
inherit gcc;
};

View File

@ -31,6 +31,9 @@ in stdenv.mkDerivation rec {
cp -r --no-preserve=all ${linenoise} ThirdParty/linenoise
'';
# See https://github.com/facebook/xcbuild/issues/238 and remove once that's in
patches = [ ./return-false.patch ];
# Avoid a glibc >= 2.25 deprecation warning that gets fatal via -Werror.
postPatch = stdenv.lib.optionalString (!stdenv.isDarwin) ''
sed 1i'#include <sys/sysmacros.h>' \

View File

@ -0,0 +1,13 @@
diff --git a/Libraries/dependency/Tools/dependency-info-tool.cpp b/Libraries/dependency/Tools/dependency-info-tool.cpp
index 006f53c7..d469f068 100644
--- a/Libraries/dependency/Tools/dependency-info-tool.cpp
+++ b/Libraries/dependency/Tools/dependency-info-tool.cpp
@@ -271,7 +271,7 @@ main(int argc, char **argv)
*/
std::vector<uint8_t> makefileContents = std::vector<uint8_t>(contents.begin(), contents.end());
if (!filesystem.write(makefileContents, *options.output())) {
- return false;
+ return -1;
}
return 0;

View File

@ -1,4 +1,4 @@
{stdenv, writeText, toolchainName, xcbuild
{stdenv, writeText, toolchainName, xcbuild, fetchurl
, llvm, cctools, gcc, bootstrap_cmds, binutils
, yacc, flex, m4, unifdef, gperf, indent, ctags, makeWrapper}:
@ -8,15 +8,20 @@ let
Identifier = toolchainName;
};
# We could pull this out of developer_cmds but it adds an annoying loop if we want to bootstrap and
# this is just a tiny script so I'm not going to bother
mkdep-darwin-src = fetchurl {
url = "https://opensource.apple.com/source/developer_cmds/developer_cmds-63/mkdep/mkdep.sh";
sha256 = "0n4wpqfslfjs5zbys5yri8pfi2awyhlmknsf6laa5jzqbzq9x541";
executable = true;
};
in
stdenv.mkDerivation {
name = "nixpkgs.xctoolchain";
buildInputs = [ xcbuild makeWrapper ];
propagatedBuildInputs = [ llvm gcc yacc flex m4 unifdef gperf indent ]
++ stdenv.lib.optionals stdenv.isDarwin [ cctools bootstrap_cmds binutils ];
## cctools should build on Linux but it doesn't currentl
## cctools should build on Linux but it doesn't currently
buildCommand = ''
mkdir -p $out
@ -58,8 +63,6 @@ stdenv.mkDerivation {
ln -s ${unifdef}/bin/unifdefall
ln -s ${gperf}/bin/gperf
ln -s ${gcc}/bin/gcov
ln -s ${gcc}/bin/mkdep
ln -s ${indent}/bin/indent
ln -s ${ctags}/bin/ctags
'' + stdenv.lib.optionalString stdenv.isDarwin ''
@ -86,7 +89,15 @@ stdenv.mkDerivation {
ln -s ${cctools}/bin/pagestuff
ln -s ${cctools}/bin/ranlib
ln -s ${cctools}/bin/redo_prebinding
'';
'' +
# No point including the entire gcc closure if we don't already have it
(if stdenv.cc.isClang then ''
ln -s ${stdenv.cc.cc.llvm}/bin/llvm-cov gcov
ln -s ${mkdep-darwin-src} mkdep
'' else ''
ln -s ${gcc}/bin/gcov
ln -s ${gcc}/bin/mkdep
'');
}
# other commands in /bin/

View File

@ -50,10 +50,10 @@ stdenv.mkDerivation {
ln -s ${xcbuild}/Library/Xcode/Specifications $out/Library/Xcode/Specifications
mkdir -p $out/Platforms/
ln -s ${platform} $out/Platforms/
ln -s ${platform} $out/Platforms/nixpkgs.platform
mkdir -p $out/Toolchains/
ln -s ${toolchain} $out/Toolchains/
ln -s ${toolchain} $out/Toolchains/nixpkgs.xctoolahin
wrapProgram $out/bin/xcodebuild \
--add-flags "-xcconfig ${xcconfig}" \