From a693c53ec47958b4317b4d10638e960f2c86a969 Mon Sep 17 00:00:00 2001 From: Michael Raskin <7c6f434c@mail.ru> Date: Wed, 2 Apr 2008 19:55:40 +0000 Subject: [PATCH] Attempts to get LLVM-gcc working are not yet succesful; but builder-defs updates are useful. svn path=/nixpkgs/trunk/; revision=11457 --- pkgs/development/compilers/llvm/builder.sh | 86 ++++++++++++++++++++ pkgs/development/compilers/llvm/llvm-gcc.nix | 28 +++++++ pkgs/top-level/all-packages.nix | 26 +++++- pkgs/top-level/builder-defs.nix | 4 +- 4 files changed, 142 insertions(+), 2 deletions(-) create mode 100644 pkgs/development/compilers/llvm/builder.sh create mode 100644 pkgs/development/compilers/llvm/llvm-gcc.nix diff --git a/pkgs/development/compilers/llvm/builder.sh b/pkgs/development/compilers/llvm/builder.sh new file mode 100644 index 00000000000..962e8d37238 --- /dev/null +++ b/pkgs/development/compilers/llvm/builder.sh @@ -0,0 +1,86 @@ +source $stdenv/setup + + +export NIX_FIXINC_DUMMY=$NIX_BUILD_TOP/dummy +mkdir $NIX_FIXINC_DUMMY + +export X_CFLAGS="-I${gmp}/include -I${mpfr}/include -L${gmp}/lib -L${mpfr}/lib"; + +# libstdc++ needs this; otherwise it will use /lib/cpp, which is a Bad +# Thing. +export CPP="gcc -E" + + +if test "$noSysDirs" = "1"; then + + if test -e $NIX_GCC/nix-support/orig-libc; then + + # Figure out what extra flags to pass to the gcc compilers + # being generated to make sure that they use our glibc. + extraCFlags="$(cat $NIX_GCC/nix-support/libc-cflags)" + extraLDFlags="$(cat $NIX_GCC/nix-support/libc-ldflags) $(cat $NIX_GCC/nix-support/libc-ldflags-before)" + + # Use *real* header files, otherwise a limits.h is generated + # that does not include Glibc's limits.h (notably missing + # SSIZE_MAX, which breaks the build). + export NIX_FIXINC_DUMMY=$(cat $NIX_GCC/nix-support/orig-libc)/include + + else + # Hack: support impure environments. + extraCFlags="-isystem /usr/include" + extraLDFlags="-L/usr/lib64 -L/usr/lib" + export NIX_FIXINC_DUMMY=/usr/include + fi + + extraCFlags="-g0 $extraCFlags" + extraLDFlags="--strip-debug $extraLDFlags" + + export NIX_EXTRA_CFLAGS=$extraCFlags + for i in $extraLDFlags; do + export NIX_EXTRA_LDFLAGS="$NIX_EXTRA_LDFLAGS -Wl,$i" + done + + makeFlagsArray=( \ + NATIVE_SYSTEM_HEADER_DIR="$NIX_FIXINC_DUMMY" \ + SYSTEM_HEADER_DIR="$NIX_FIXINC_DUMMY" \ + LIMITS_H_TEST=true \ + X_CFLAGS="$NIX_EXTRA_CFLAGS $NIX_EXTRA_LDFLAGS" \ + LDFLAGS="$NIX_EXTRA_CFLAGS $NIX_EXTRA_LDFLAGS" \ + LDFLAGS_FOR_TARGET="$NIX_EXTRA_CFLAGS $NIX_EXTRA_LDFLAGS" \ + ) +fi + + +preConfigure=preConfigure +preConfigure() { + # Perform the build in a different directory. + mkdir ../build + cd ../build + configureScript=../$sourceRoot/configure +} + + +postInstall=postInstall +postInstall() { + # Remove precompiled headers for now. They are very big and + # probably not very useful yet. + find $out/include -name "*.gch" -exec rm -rf {} \; -prune + + # Remove `fixincl' to prevent a retained dependency on the + # previous gcc. + rm -rf $out/libexec/gcc/*/*/install-tools + + # Get rid of some "fixed" header files + rm -rf $out/lib/gcc/*/*/include/root +} + + +if test -z "$staticCompiler"; then + if test -z "$profiledCompiler"; then + buildFlags="bootstrap $buildFlags" + else + buildFlags="profiledbootstrap $buildFlags" + fi +fi + +genericBuild diff --git a/pkgs/development/compilers/llvm/llvm-gcc.nix b/pkgs/development/compilers/llvm/llvm-gcc.nix new file mode 100644 index 00000000000..db1a7807592 --- /dev/null +++ b/pkgs/development/compilers/llvm/llvm-gcc.nix @@ -0,0 +1,28 @@ +args : with args; +rec { + src = fetchurl { + url = http://llvm.org/releases/2.2/llvm-gcc4.2-2.2.source.tar.gz; + sha256 = "11vjn8wn76cq63jam7y5ralq1b12r6cdipf22nsnzw90srb49qkp"; + }; + + buildInputs = [llvm bison flex perl mpfr gmp]; + configureFlags = [" --enable-llvm=$(ls -d $PWD/../llvm-?.?) "]; + makeFlags = [" -f Makefile "]; + + phaseNames = ["preConfigure" "doConfigure" "doMakeInstall"]; + + preConfigure = FullDepEntry ('' + cd .. + mkdir obj install + tar xf ${llvmSrc} + cd obj + '') ["doUnpack" "minInit"]; + configureCommand = "$(ls ../llvm-gcc*.*.source/configure)"; + + name = "llvm-gcc42-2.2"; + meta = { + description = "LLVM GCC frontend"; + }; +} + + diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index e9728de377c..b980460bdb6 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -1252,6 +1252,21 @@ let pkgs = rec { inherit stdenv; }; + g77_42 = import ../build-support/gcc-wrapper { + name = "g77-4.2"; + nativeTools = false; + nativeLibc = false; + gcc = import ../development/compilers/gcc-4.2/fortran.nix { + inherit fetchurl stdenv noSysDirs; + langF77 = true; + langCC = false; + langC = false; + inherit gmp mpfr; + }; + inherit (stdenv.gcc) binutils libc; + inherit stdenv; + }; + gcc = gcc42; gcc295 = wrapGCC (import ../development/compilers/gcc-2.95 { @@ -1524,6 +1539,15 @@ let pkgs = rec { inherit fetchurl stdenv gcc flex perl libtool; }; + llvmGccFun = builderDefsPackage (import ../development/compilers/llvm/llvm-gcc.nix) { + flex=flex2535; + bison=bison23; + inherit llvm perl mpfr gmp; + llvmSrc = llvm.src; + }; + + llvmGCC =llvmGccFun null; + mono = import ../development/compilers/mono { inherit fetchurl stdenv bison pkgconfig; inherit (gtkLibs) glib; @@ -1699,7 +1723,7 @@ let pkgs = rec { octave = import ../development/interpreters/octave { inherit stdenv fetchurl readline ncurses perl flex; - g77 = g77_41; + g77 = g77_42; }; perl = if !stdenv.isLinux then sysPerl else realPerl; diff --git a/pkgs/top-level/builder-defs.nix b/pkgs/top-level/builder-defs.nix index 5a58f14d09f..6ff09296a65 100644 --- a/pkgs/top-level/builder-defs.nix +++ b/pkgs/top-level/builder-defs.nix @@ -208,8 +208,10 @@ args: with args; with stringsWithDeps; with lib; (if args ? goSrcDir then args.goSrcDir else "") ) ["minInit"]; + configureCommand = getAttr ["configureCommand"] "./configure" args; + doConfigure = FullDepEntry (" - ./configure --prefix=\"\$prefix\" ${toString configureFlags} + ${configureCommand} --prefix=\"\$prefix\" ${toString configureFlags} ") ["minInit" "addInputs" "doUnpack"]; doAutotools = FullDepEntry ("