Skip to content

Commit

Permalink
Monster stdenv cleanup, avoiding unnecessary work, untangling depende…
Browse files Browse the repository at this point in the history
…ncies, and removing unnecessary references.

Fixes NixOS#15, fixes NixOS#28, fixes NixOS#31, fixes NixOS#35.
  • Loading branch information
copumpkin committed Jan 19, 2015
1 parent 541d7f7 commit 41380d9
Show file tree
Hide file tree
Showing 10 changed files with 175 additions and 82 deletions.
24 changes: 15 additions & 9 deletions pkgs/build-support/clang-wrapper/builder.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,31 @@ mkdir -p $out/nix-support


if test -z "$nativeLibc"; then
dynamicLinker="$libc/lib/$dynamicLinker"
echo $dynamicLinker > $out/nix-support/dynamic-linker
if [[ "$dynamicLinker" == *"dyld" ]]; then
# TODO: figure out a way to inject our dynamic linker here
:
else
dynamicLinker="$libc/lib/$dynamicLinker"
echo $dynamicLinker > $out/nix-support/dynamic-linker

if test -e $libc/lib/32/ld-linux.so.2; then
echo $libc/lib/32/ld-linux.so.2 > $out/nix-support/dynamic-linker-m32
fi

if test -e $libc/lib/32/ld-linux.so.2; then
echo $libc/lib/32/ld-linux.so.2 > $out/nix-support/dynamic-linker-m32
# The dynamic linker is passed in `ldflagsBefore' to allow
# explicit overrides of the dynamic linker by callers to clang/ld
# (the *last* value counts, so ours should come first).
echo "-dynamic-linker $dynamicLinker" > $out/nix-support/libc-ldflags-before
fi


# The "-B$libc/lib/" flag is a quick hack to force clang to link
# against the crt1.o from our own glibc, rather than the one in
# /usr/lib. (This is only an issue when using an `impure'
# compiler/linker, i.e., one that searches /usr/lib and so on.)
echo "-B$libc/lib/ -idirafter $libc/include" > $out/nix-support/libc-cflags

echo "-L$libc/lib" > $out/nix-support/libc-ldflags

# The dynamic linker is passed in `ldflagsBefore' to allow
# explicit overrides of the dynamic linker by callers to clang/ld
# (the *last* value counts, so ours should come first).
echo "-dynamic-linker $dynamicLinker" > $out/nix-support/libc-ldflags-before
fi

if test -n "$nativeTools"; then
Expand Down
2 changes: 2 additions & 0 deletions pkgs/build-support/clang-wrapper/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ stdenv.mkDerivation {
(if stdenv.cross.arch == "arm" then "ld-linux.so.3" else
if stdenv.cross.arch == "mips" then "ld.so.1" else
if stdenv.lib.hasSuffix "pc-gnu" stdenv.cross.config then "ld.so.1" else
if stdenv.isDarwin then "dyld" else
abort "don't know the name of the dynamic linker for this platform");
};

Expand All @@ -81,6 +82,7 @@ stdenv.mkDerivation {
if stdenv.isArm then "ld-linux.so.3" else
if stdenv.system == "powerpc-linux" then "ld.so.1" else
if stdenv.system == "mips64el-linux" then "ld.so.1" else
if stdenv.isDarwin then "dyld" else
abort "don't know the name of the dynamic linker for this platform")
else "";

Expand Down
4 changes: 3 additions & 1 deletion pkgs/development/libraries/gmp/5.1.x.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ stdenv.mkDerivation (rec {

patches = stdenv.lib.optional stdenv.isDarwin ./need-size-t.patch;

configureFlags =
# CC=cc works regardless of gcc or clang, and this prevents the generated output from retaining
# unnecessary absolute references to our bootstrap tools during the darwin stdenv bootstrapping
configureFlags = [ "CC=cc" ] ++
# Build a "fat binary", with routines for several sub-architectures
# (x86), except on Solaris where some tests crash with "Memory fault".
# See <http://hydra.nixos.org/build/2760931>, for instance.
Expand Down
3 changes: 2 additions & 1 deletion pkgs/development/libraries/icu/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@ stdenv.mkDerivation {

preConfigure = ''
sed -i -e "s|/bin/sh|${stdenv.shell}|" configure
export INSTALL='install -c'
'';

configureFlags = "--disable-debug" +
configureFlags = "--disable-debug CC=cc CXX=c++ SHELL=bash" +
stdenv.lib.optionalString stdenv.isDarwin " --enable-rpath";

enableParallelBuilding = true;
Expand Down
13 changes: 13 additions & 0 deletions pkgs/development/libraries/libc++/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,19 @@ stdenv.mkDerivation rec {
"-DLIBCXX_CXX_ABI=libcxxabi"
];

# Through some mysterious cmake voodoo, the build decides to pass in both -lc++abi and
# a straight reference to our libc++abi.dylib, which happen to actually be different
# during the pure-darwin stdenv bootstrap, and thus lead to our generated libc++ being
# linked to two separate libc++abi libraries! This kills it, but there's probably a
# cleaner way...
preBuild = stdenv.lib.optionalString stdenv.isDarwin ''
substituteInPlace lib/CMakeFiles/cxx.dir/link.txt \
--replace "-lc++abi" ""
'';

# We also need this to prevent more spurious libc++abi linkage...
NIX_SKIP_CXXABI = "true";

enableParallelBuilding = true;

inherit libcxxabi;
Expand Down
8 changes: 3 additions & 5 deletions pkgs/development/tools/build-managers/cmake/default.nix
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
{ stdenv, fetchurl, fetchpatch, replace, curl, expat, zlib, bzip2, libarchive
, useNcurses ? false, ncurses, useQt4 ? false, qt4, wantPS ? false, ps ? null
, useNcurses ? false, ncurses, useQt4 ? false, qt4, ps
}:

with stdenv.lib;

assert wantPS -> (ps != null);

let
os = stdenv.lib.optionalString;
majorVersion = "2.8";
Expand Down Expand Up @@ -50,10 +48,10 @@ stdenv.mkDerivation rec {
++ optional useNcurses ncurses
++ optional useQt4 qt4;

propagatedBuildInputs = optional wantPS ps;
propagatedBuildInputs = optional stdenv.isDarwin ps;

CMAKE_PREFIX_PATH = stdenv.lib.concatStringsSep ":" buildInputs;

configureFlags =
"--docdir=/share/doc/${name} --mandir=/share/man --system-libs"
+ stdenv.lib.optionalString useQt4 " --qt-gui";
Expand Down
21 changes: 14 additions & 7 deletions pkgs/os-specific/darwin/libSystem/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -92,16 +92,9 @@ stdenv.mkDerivation rec {
#endif /* __TARGETCONDITIONALS__ */
EOF
# The startup object files
cp ${csu}/lib/* $out/lib
# This probably doesn't belong here, but we want to stay similar to glibc, which includes resolv internally...
# TODO: add darwin-conditional libresolv dependency to packages that need it instead of this...
ln -s ${libresolv}/lib/libresolv.9.dylib $out/lib/libresolv.9.dylib
ln -s libresolv.9.dylib $out/lib/libresolv.dylib
# selectively re-export functions from libsystem_c and libsystem_kernel
# to provide a consistent interface across OSX verions
mkdir -p $out/lib/system
Expand Down Expand Up @@ -132,6 +125,20 @@ stdenv.mkDerivation rec {
for name in c dbm dl info m mx poll proc pthread rpcsvc gcc_s.10.4 gcc_s.10.5; do
ln -s libSystem.dylib $out/lib/lib$name.dylib
done
# This probably doesn't belong here, but we want to stay similar to glibc, which includes resolv internally...
cp ${libresolv}/lib/libresolv.9.dylib $out/lib/libresolv.9.dylib
resolv_libSystem=$(otool -L "$out/lib/libresolv.9.dylib" | tail -n +3 | grep -o "$NIX_STORE.*-\S*") || true
echo $libs
chmod +w $out/lib/libresolv.9.dylib
install_name_tool \
-id $out/lib/libresolv.9.dylib \
-change "$resolv_libSystem" $out/lib/libSystem.dylib \
$out/lib/libresolv.9.dylib
ln -s libresolv.9.dylib $out/lib/libresolv.dylib
otool -L $out/lib/libresolv.dylib
'';

meta = with stdenv.lib; {
Expand Down
4 changes: 3 additions & 1 deletion pkgs/shells/bash/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ stdenv.mkDerivation rec {
" bash_cv_job_control_missing=nomissing bash_cv_sys_named_pipes=nomissing";
};

configureFlags = baseConfigureFlags;
# The CC=cc prevents the generated bashbug script from permanently holding onto a
# reference to our bootstrap compiler during darwin stdenv bootstrapping
configureFlags = baseConfigureFlags + " CC=cc";

# Note: Bison is needed because the patches above modify parse.y.
nativeBuildInputs = [bison]
Expand Down
Loading

0 comments on commit 41380d9

Please sign in to comment.