From da3ecd1256c4929845d954f3787d7ae2d08ee62b Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Fri, 17 Feb 2012 19:33:12 +0000 Subject: [PATCH] * gcc-apple: produce a libstdc++.dylib that doesn't depend on /usr/lib/libstdc++.dylib. svn path=/nixpkgs/branches/stdenv-updates/; revision=32365 --- .../compilers/gcc-apple64/builder.sh | 27 ++++++++++--------- .../compilers/gcc-apple64/default.nix | 26 +++++++++++------- .../gcc-apple64/fix-libstdc++-link.patch | 17 ++++++++++++ 3 files changed, 47 insertions(+), 23 deletions(-) create mode 100644 pkgs/development/compilers/gcc-apple64/fix-libstdc++-link.patch diff --git a/pkgs/development/compilers/gcc-apple64/builder.sh b/pkgs/development/compilers/gcc-apple64/builder.sh index 6072aef9d591..036678460d60 100644 --- a/pkgs/development/compilers/gcc-apple64/builder.sh +++ b/pkgs/development/compilers/gcc-apple64/builder.sh @@ -84,22 +84,32 @@ postInstall() { rm -rf $out/libexec/gcc/*/*/install-tools } + postUnpack() { - mv $libstdcxx/libstdcxx $sourceRoot/ + mv $libstdcxx/libstdcxx $sourceRoot/ } + STDCXX_INCDIR="$out/include/c++/4.2.1" genericBuild echo '-------------------------------------------------------------------------------------------------------------------------' -echo 'libstdcxx-16' +echo 'libstdcxx' echo '-------------------------------------------------------------------------------------------------------------------------' cd .. pwd +unpackPhase () { + true +} + +patchPhase() { + true +} + preConfigure() { # Perform the build in a different directory. mkdir ../build_libstdcxx @@ -111,18 +121,9 @@ preConfigure() { configureFlags="--disable-libstdcxx-pch --disable-libstdcxx-debug --disable-multilib --with-gxx-include-dir=${STDCXX_INCDIR}" } -unpackPhase () { - echo '-' -} - postInstall() { - echo '-' - echo "cp -v ${STDCXX_INCDIR}/*/bits/* ${STDCXX_INCDIR}/bits/" - cp -v ${STDCXX_INCDIR}/*/bits/* ${STDCXX_INCDIR}/bits/ -} - -patchPhase() { - echo '-' + echo "cp -v ${STDCXX_INCDIR}/*/bits/* ${STDCXX_INCDIR}/bits/" + cp -v ${STDCXX_INCDIR}/*/bits/* ${STDCXX_INCDIR}/bits/ } genericBuild diff --git a/pkgs/development/compilers/gcc-apple64/default.nix b/pkgs/development/compilers/gcc-apple64/default.nix index e2f70fbc1f56..9f46f1da1e4c 100644 --- a/pkgs/development/compilers/gcc-apple64/default.nix +++ b/pkgs/development/compilers/gcc-apple64/default.nix @@ -1,10 +1,9 @@ { stdenv, fetchurl, noSysDirs -, langC ? true, langCC ? true, langObjC ? true, langF77 ? false +, langCC ? true, langObjC ? true, langF77 ? false , profiledCompiler ? false , gmp ? null, mpfr ? null, bison ? null, flex ? null }: -assert langC; assert stdenv.isDarwin; assert langF77 -> gmp != null; @@ -12,27 +11,34 @@ let version = "4.2.1"; # Upstream GCC version, from `gcc/BASE-VER'. revision = "5666.3"; # Apple's fork revision number. in -stdenv.mkDerivation ({ + +stdenv.mkDerivation { name = "gcc-apple-${version}.${revision}"; builder = ./builder.sh; src = - stdenv.lib.optional /*langC*/ true (fetchurl { + stdenv.lib.optional true (fetchurl { url = "http://www.opensource.apple.com/tarballs/gcc/gcc-${revision}.tar.gz"; sha256 = "0nq1szgqx9ryh1qsn5n6yd55gpvf56wr8f7w1jzabb8idlvz8ikc"; }) ++ stdenv.lib.optional langCC (fetchurl { - url = http://www.opensource.apple.com/tarballs/libstdcxx/libstdcxx-39.tar.gz ; + url = http://www.opensource.apple.com/tarballs/libstdcxx/libstdcxx-39.tar.gz; sha256 = "ccf4cf432c142778c766affbbf66b61001b6c4f1107bc2b2c77ce45598786b6d"; - }) ; + }); enableParallelBuilding = true; libstdcxx = "libstdcxx-39"; + sourceRoot = "gcc-${revision}/"; + patches = - [./pass-cxxcpp.patch ] - ++ (if noSysDirs then [./no-sys-dirs.patch] else []); - inherit noSysDirs langC langCC langF77 langObjC profiledCompiler; -} // (if langF77 then {buildInputs = [gmp mpfr bison flex];} else {})) + [ ./pass-cxxcpp.patch ./fix-libstdc++-link.patch ] + ++ stdenv.lib.optional noSysDirs [ ./no-sys-dirs.patch ]; + + inherit noSysDirs langCC langF77 langObjC; + langC = true; + + buildInputs = stdenv.lib.optionals langF77 [ gmp mpfr bison flex ]; +} diff --git a/pkgs/development/compilers/gcc-apple64/fix-libstdc++-link.patch b/pkgs/development/compilers/gcc-apple64/fix-libstdc++-link.patch new file mode 100644 index 000000000000..e7b8a55a29af --- /dev/null +++ b/pkgs/development/compilers/gcc-apple64/fix-libstdc++-link.patch @@ -0,0 +1,17 @@ +Prevent our libstdc++.dylib from having a runtime dependency on +/usr/lib/libstdc++.dylib. This is caused by the implicit -lstdc++ +passed by g++ when it links libstdc++.dylib. Adding "-nostdlib" to +the g++ invocation prevents this. + +diff -ru -x '*~' libstdcxx-39-orig/libstdcxx/libstdc++-v3/src/Makefile.in libstdcxx-39/libstdcxx/libstdc++-v3/src/Makefile.in +--- x/libstdcxx/libstdc++-v3/src/Makefile.in 2006-10-16 21:08:22.000000000 +0200 ++++ y/libstdcxx/libstdc++-v3/src/Makefile.in 2012-02-17 18:44:05.210570590 +0100 +@@ -388,7 +388,7 @@ + + libstdc___la_DEPENDENCIES = ${version_dep} $(libstdc___la_LIBADD) + libstdc___la_LDFLAGS = \ +- -version-info $(libtool_VERSION) ${version_arg} -lm ++ -version-info $(libtool_VERSION) ${version_arg} -lm -Wc,-nostdlib + + + # Use special rules for the deprecated source files so that they find