diff options
Diffstat (limited to 'nixpkgs/pkgs/development/compilers')
527 files changed, 37109 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/development/compilers/abcl/default.nix b/nixpkgs/pkgs/development/compilers/abcl/default.nix new file mode 100644 index 000000000000..c48b36e5aba5 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/abcl/default.nix @@ -0,0 +1,40 @@ +{stdenv, fetchurl, ant, jre, jdk}: +stdenv.mkDerivation rec { + name = "${pname}-${version}"; + pname = "abcl"; + version = "1.5.0"; + # or fetchFromGitHub(owner,repo,rev) or fetchgit(rev) + src = fetchurl { + url = "https://common-lisp.net/project/armedbear/releases/${version}/${pname}-src-${version}.tar.gz"; + sha256 = "1hhvcg050nfpjbdmskc1cv2j38qi6qfl77a61b5cxx576kbff3lj"; + }; + configurePhase = '' + mkdir nix-tools + export PATH="$PWD/nix-tools:$PATH" + echo "echo nix-builder.localdomain" > nix-tools/hostname + chmod a+x nix-tools/* + + hostname + ''; + buildPhase = '' + ant + ''; + installPhase = '' + mkdir -p "$out"/{bin,share/doc/abcl,lib/abcl} + cp -r README COPYING CHANGES examples/ "$out/share/doc/abcl/" + cp -r dist/*.jar contrib/ "$out/lib/abcl/" + + echo "#! ${stdenv.shell}" >> "$out/bin/abcl" + echo "${jre}/bin/java -cp \"$out/lib/abcl/abcl.jar:$out/lib/abcl/abcl-contrib.jar:\$CLASSPATH\" org.armedbear.lisp.Main \"\$@\"" >> "$out/bin/abcl" + chmod a+x "$out"/bin/* + ''; + buildInputs = [jre ant jdk jre]; + meta = { + inherit version; + description = ''A JVM-based Common Lisp implementation''; + license = stdenv.lib.licenses.gpl3 ; + maintainers = [stdenv.lib.maintainers.raskin]; + platforms = stdenv.lib.platforms.linux; + homepage = https://common-lisp.net/project/armedbear/; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/adoptopenjdk-bin/generate-sources.py b/nixpkgs/pkgs/development/compilers/adoptopenjdk-bin/generate-sources.py new file mode 100755 index 000000000000..40b690048eba --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/adoptopenjdk-bin/generate-sources.py @@ -0,0 +1,63 @@ +#!/usr/bin/env nix-shell +#!nix-shell --pure -i python3 -p "python3.withPackages (ps: with ps; [ requests ])" + +import json +import re +import requests +import sys + +releases = ["openjdk11"] +oses = ["mac", "linux"] +types = ["jre", "jdk"] +impls = ["hotspot", "openj9"] + +arch_to_nixos = { + "x64": "x86_64", + "aarch64": "aarch64", +} + +def get_sha256(url): + resp = requests.get(url) + if resp.status_code != 200: + print("error: could not fetch checksum from url {}: code {}".format(url, resp.code), file=sys.stderr) + sys.exit(1) + return resp.text.strip().split(" ")[0] + +RE_RELEASE_NAME = re.compile(r'[^-]+-([0-9.]+)\+([0-9]+)') # example release name: jdk-11.0.1+13 +def generate_sources(release, assets): + out = {} + for asset in assets: + if asset["os"] not in oses: continue + if asset["binary_type"] not in types: continue + if asset["openjdk_impl"] not in impls: continue + if asset["heap_size"] != "normal": continue + if asset["architecture"] not in arch_to_nixos: continue + + version, build = RE_RELEASE_NAME.match(asset["release_name"]).groups() + + type_map = out.setdefault(asset["os"], {}) + impl_map = type_map.setdefault(asset["binary_type"], {}) + arch_map = impl_map.setdefault(asset["openjdk_impl"], { + "packageType": asset["binary_type"], + "vmType": asset["openjdk_impl"], + }) + + arch_map[arch_to_nixos[asset["architecture"]]] = { + "url": asset["binary_link"], + "sha256": get_sha256(asset["checksum_link"]), + "version": version, + "build": build, + } + + return out + +out = {} +for release in releases: + resp = requests.get("https://api.adoptopenjdk.net/v2/latestAssets/releases/" + release) + if resp.status_code != 200: + print("error: could not fetch data for release {} (code {})".format(release, resp.code), file=sys.stderr) + sys.exit(1) + out[release] = generate_sources(release, resp.json()) + +with open("sources.json", "w") as f: + json.dump(out, f, indent=2, sort_keys=True) diff --git a/nixpkgs/pkgs/development/compilers/adoptopenjdk-bin/jdk-darwin-base.nix b/nixpkgs/pkgs/development/compilers/adoptopenjdk-bin/jdk-darwin-base.nix new file mode 100644 index 000000000000..7b16d6ad9dbc --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/adoptopenjdk-bin/jdk-darwin-base.nix @@ -0,0 +1,59 @@ +sourcePerArch: + +{ swingSupport ? true # not used for now +, stdenv +, fetchurl +}: + +let cpuName = stdenv.hostPlatform.parsed.cpu.name; + result = stdenv.mkDerivation rec { + name = if sourcePerArch.packageType == "jdk" + then "adoptopenjdk-${sourcePerArch.vmType}-bin-${sourcePerArch.${cpuName}.version}" + else "adoptopenjdk-${sourcePerArch.packageType}-${sourcePerArch.vmType}-bin-${sourcePerArch.${cpuName}.version}"; + + src = fetchurl { + inherit (sourcePerArch.${cpuName}) url sha256; + }; + + # See: https://github.com/NixOS/patchelf/issues/10 + dontStrip = 1; + + installPhase = '' + cd .. + + mv $sourceRoot $out + + rm -rf $out/Home/demo + + # Remove some broken manpages. + rm -rf $out/Home/man/ja* + + # for backward compatibility + ln -s $out/Contents/Home $out/jre + + ln -s $out/Contents/Home/* $out/ + + mkdir -p $out/nix-support + + # Set JAVA_HOME automatically. + cat <<EOF >> $out/nix-support/setup-hook + if [ -z "\$JAVA_HOME" ]; then export JAVA_HOME=$out; fi + EOF + ''; + + # FIXME: use multiple outputs or return actual JRE package + passthru.jre = result; + + passthru.home = result; + + # for backward compatibility + passthru.architecture = ""; + + meta = with stdenv.lib; { + license = licenses.gpl2Classpath; + description = "AdoptOpenJDK, prebuilt OpenJDK binary"; + platforms = [ "x86_64-darwin" ]; # some inherit jre.meta.platforms + maintainers = with stdenv.lib.maintainers; [ taku0 ]; + }; + +}; in result diff --git a/nixpkgs/pkgs/development/compilers/adoptopenjdk-bin/jdk-linux-base.nix b/nixpkgs/pkgs/development/compilers/adoptopenjdk-bin/jdk-linux-base.nix new file mode 100644 index 000000000000..8e8b157aa229 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/adoptopenjdk-bin/jdk-linux-base.nix @@ -0,0 +1,118 @@ +sourcePerArch: + +{ swingSupport ? true +, stdenv +, fetchurl +, file +, xorg ? null +, glib +, libxml2 +, ffmpeg_2 +, libxslt +, libGL +, freetype +, fontconfig +, gtk2 +, pango +, cairo +, alsaLib +, atk +, gdk_pixbuf +, zlib +, elfutils +}: + +assert swingSupport -> xorg != null; + +let + rSubPaths = [ + "lib/jli" + "lib/server" + "lib/compressedrefs" # OpenJ9 + "lib/j9vm" # OpenJ9 + "lib" + ]; + + libraries = [ + stdenv.cc.libc glib libxml2 ffmpeg_2 libxslt libGL + xorg.libXxf86vm alsaLib fontconfig freetype pango gtk2 cairo gdk_pixbuf + atk zlib elfutils + ] ++ (stdenv.lib.optionals swingSupport [ + xorg.libX11 xorg.libXext xorg.libXtst xorg.libXi xorg.libXp xorg.libXt + xorg.libXrender + stdenv.cc.cc + ]); + + cpuName = stdenv.hostPlatform.parsed.cpu.name; +in + +let result = stdenv.mkDerivation rec { + name = if sourcePerArch.packageType == "jdk" + then "adoptopenjdk-${sourcePerArch.vmType}-bin-${version}" + else "adoptopenjdk-${sourcePerArch.packageType}-${sourcePerArch.vmType}-bin-${version}"; + + version = sourcePerArch.${cpuName}.version or (throw "unsupported CPU ${cpuName}"); + + src = fetchurl { + inherit (sourcePerArch.${cpuName}) url sha256; + }; + + nativeBuildInputs = [ file ]; + + # See: https://github.com/NixOS/patchelf/issues/10 + dontStrip = 1; + + installPhase = '' + cd .. + + mv $sourceRoot $out + + rm -rf $out/demo + + # Remove some broken manpages. + rm -rf $out/man/ja* + + # Remove embedded freetype to avoid problems like + # https://github.com/NixOS/nixpkgs/issues/57733 + rm $out/lib/libfreetype.so + + # for backward compatibility + ln -s $out $out/jre + + mkdir -p $out/nix-support + + # Set JAVA_HOME automatically. + cat <<EOF >> $out/nix-support/setup-hook + if [ -z "\$JAVA_HOME" ]; then export JAVA_HOME=$out; fi + EOF + ''; + + postFixup = '' + rpath+="''${rpath:+:}${stdenv.lib.concatStringsSep ":" (map (a: "$out/${a}") rSubPaths)}" + + # set all the dynamic linkers + find $out -type f -perm -0100 \ + -exec patchelf --interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \ + --set-rpath "$rpath" {} \; + + find $out -name "*.so" -exec patchelf --set-rpath "$rpath" {} \; + ''; + + rpath = stdenv.lib.strings.makeLibraryPath libraries; + + # FIXME: use multiple outputs or return actual JRE package + passthru.jre = result; + + passthru.home = result; + + # for backward compatibility + passthru.architecture = ""; + + meta = with stdenv.lib; { + license = licenses.gpl2Classpath; + description = "AdoptOpenJDK, prebuilt OpenJDK binary"; + platforms = stdenv.lib.mapAttrsToList (arch: _: arch + "-linux") sourcePerArch; # some inherit jre.meta.platforms + maintainers = with stdenv.lib.maintainers; [ taku0 ]; + }; + +}; in result diff --git a/nixpkgs/pkgs/development/compilers/adoptopenjdk-bin/jdk11-darwin.nix b/nixpkgs/pkgs/development/compilers/adoptopenjdk-bin/jdk11-darwin.nix new file mode 100644 index 000000000000..d1db77215d16 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/adoptopenjdk-bin/jdk11-darwin.nix @@ -0,0 +1,9 @@ +let + sources = builtins.fromJSON (builtins.readFile ./sources.json); +in +{ + jdk-hotspot = import ./jdk-darwin-base.nix sources.openjdk11.mac.jdk.hotspot; + jre-hotspot = import ./jdk-darwin-base.nix sources.openjdk11.mac.jre.hotspot; + jdk-openj9 = import ./jdk-darwin-base.nix sources.openjdk11.mac.jdk.openj9; + jre-openj9 = import ./jdk-darwin-base.nix sources.openjdk11.mac.jre.openj9; +} diff --git a/nixpkgs/pkgs/development/compilers/adoptopenjdk-bin/jdk11-linux.nix b/nixpkgs/pkgs/development/compilers/adoptopenjdk-bin/jdk11-linux.nix new file mode 100644 index 000000000000..755ffaab271e --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/adoptopenjdk-bin/jdk11-linux.nix @@ -0,0 +1,9 @@ +let + sources = builtins.fromJSON (builtins.readFile ./sources.json); +in +{ + jdk-hotspot = import ./jdk-linux-base.nix sources.openjdk11.linux.jdk.hotspot; + jre-hotspot = import ./jdk-linux-base.nix sources.openjdk11.linux.jre.hotspot; + jdk-openj9 = import ./jdk-linux-base.nix sources.openjdk11.linux.jdk.openj9; + jre-openj9 = import ./jdk-linux-base.nix sources.openjdk11.linux.jre.openj9; +} diff --git a/nixpkgs/pkgs/development/compilers/adoptopenjdk-bin/sources.json b/nixpkgs/pkgs/development/compilers/adoptopenjdk-bin/sources.json new file mode 100644 index 000000000000..03febb6aa355 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/adoptopenjdk-bin/sources.json @@ -0,0 +1,108 @@ +{ + "openjdk11": { + "linux": { + "jdk": { + "hotspot": { + "aarch64": { + "build": "7", + "sha256": "894a846600ddb0df474350037a2fb43e3343dc3606809a20c65e750580d8f2b9", + "url": "https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.3%2B7/OpenJDK11U-jdk_aarch64_linux_hotspot_11.0.3_7.tar.gz", + "version": "11.0.3" + }, + "packageType": "jdk", + "vmType": "hotspot", + "x86_64": { + "build": "7", + "sha256": "23cded2b43261016f0f246c85c8948d4a9b7f2d44988f75dad69723a7a526094", + "url": "https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.3%2B7/OpenJDK11U-jdk_x64_linux_hotspot_11.0.3_7.tar.gz", + "version": "11.0.3" + } + }, + "openj9": { + "packageType": "jdk", + "vmType": "openj9", + "x86_64": { + "build": "7", + "sha256": "7012edd56fc958070bc4747073de14ea08eb43081eb6ea19bdbf4763186e2d17", + "url": "https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.3%2B7_openj9-0.14.0/OpenJDK11U-jdk_x64_linux_openj9_11.0.3_7_openj9-0.14.0.tar.gz", + "version": "11.0.3" + } + } + }, + "jre": { + "hotspot": { + "aarch64": { + "build": "7", + "sha256": "de31fab70640c6d5099de5fc8fa8b4d6b484a7352fa48a9fafbdc088ca708564", + "url": "https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.3%2B7/OpenJDK11U-jre_aarch64_linux_hotspot_11.0.3_7.tar.gz", + "version": "11.0.3" + }, + "packageType": "jre", + "vmType": "hotspot", + "x86_64": { + "build": "7", + "sha256": "d2df8bc799b09c8375f79bf646747afac3d933bb1f65de71d6c78e7466ff8fe4", + "url": "https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.3%2B7/OpenJDK11U-jre_x64_linux_hotspot_11.0.3_7.tar.gz", + "version": "11.0.3" + } + }, + "openj9": { + "packageType": "jre", + "vmType": "openj9", + "x86_64": { + "build": "7", + "sha256": "14c660294832c7b2deb2845d96dce83df677e204b4f0f1fee0052764c4a56720", + "url": "https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.3%2B7_openj9-0.14.0/OpenJDK11U-jre_x64_linux_openj9_11.0.3_7_openj9-0.14.0.tar.gz", + "version": "11.0.3" + } + } + } + }, + "mac": { + "jdk": { + "hotspot": { + "packageType": "jdk", + "vmType": "hotspot", + "x86_64": { + "build": "7", + "sha256": "5ca2a24f1827bd7c110db99854693bf418f51ee3093c31332db5cd605278faad", + "url": "https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.3%2B7/OpenJDK11U-jdk_x64_mac_hotspot_11.0.3_7.tar.gz", + "version": "11.0.3" + } + }, + "openj9": { + "packageType": "jdk", + "vmType": "openj9", + "x86_64": { + "build": "7", + "sha256": "01045a99ff23bda354f82c0fd3fa6e8222e4a5acce7494e82495f47b30bc5e18", + "url": "https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.3%2B7_openj9-0.14.0/OpenJDK11U-jdk_x64_mac_openj9_11.0.3_7_openj9-0.14.0.tar.gz", + "version": "11.0.3" + } + } + }, + "jre": { + "hotspot": { + "packageType": "jre", + "vmType": "hotspot", + "x86_64": { + "build": "7", + "sha256": "9523b97288ff5d50e404565d346ed8ea8f19dd155092951af88d4be6b8414776", + "url": "https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.3%2B7/OpenJDK11U-jre_x64_mac_hotspot_11.0.3_7.tar.gz", + "version": "11.0.3" + } + }, + "openj9": { + "packageType": "jre", + "vmType": "openj9", + "x86_64": { + "build": "7", + "sha256": "150c4065a57ec368b692276e8e3320b183ee17b402b7db07e676dff5837f0c52", + "url": "https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.3%2B7_openj9-0.14.0/OpenJDK11U-jre_x64_mac_openj9_11.0.3_7_openj9-0.14.0.tar.gz", + "version": "11.0.3" + } + } + } + } + } +} \ No newline at end of file diff --git a/nixpkgs/pkgs/development/compilers/aldor/default.nix b/nixpkgs/pkgs/development/compilers/aldor/default.nix new file mode 100644 index 000000000000..604838e88316 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/aldor/default.nix @@ -0,0 +1,52 @@ +{ fetchgit, stdenv, gmp, which, flex, bison, makeWrapper +, autoconf, automake, libtool, jdk, perl }: + +stdenv.mkDerivation { + name = "aldor-1.2.0"; + + src = fetchgit { + url = "https://github.com/pippijn/aldor"; + sha256 = "19v07ffq4r1gjnmg7a8ifgjkwan9a3rwbj0qjz8fycwy221844m6"; + rev = "15471e75f3d65b93150f414ebcaf59a03054b68d"; + }; + + buildInputs = [ gmp which flex bison makeWrapper autoconf automake libtool + jdk perl ]; + + preConfigure = '' + cd aldor ; + ./autogen.sh ; + ''; + + postInstall = '' + for prog in aldor unicl javagen ; + do + wrapProgram $out/bin/$prog --set ALDORROOT $out \ + --prefix PATH : ${jdk}/bin \ + --prefix PATH : ${stdenv.cc}/bin ; + done + ''; + + meta = { + # Please become a maintainer to fix this package + broken = true; + homepage = http://www.aldor.org/; + description = "Programming language with an expressive type system"; + license = stdenv.lib.licenses.asl20; + + longDescription = '' + Aldor is a programming language with an expressive type system well-suited + for mathematical computing and which has been used to develop a number of + computer algebra libraries. Originally known as A#, Aldor was conceived as + an extension language for the Axiom system, but is now used more in other settings. + In Aldor, types and functions are first class values that can be constructed + and manipulated within programs. Pervasive support for dependent types allows + static checking of dynamic objects. What does this mean for a normal user? Aldor + solves many difficulties encountered in widely-used object-oriented programming + languages. It allows programs to use a natural style, combining the more attractive + and powerful properties of functional, object-oriented and aspect-oriented styles. + ''; + + platforms = stdenv.lib.platforms.linux; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/aliceml/default.nix b/nixpkgs/pkgs/development/compilers/aliceml/default.nix new file mode 100644 index 000000000000..08d0005c99eb --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/aliceml/default.nix @@ -0,0 +1,57 @@ +{stdenv, gcc, glibc, fetchurl, fetchgit, libtool, autoconf, automake, file, gnumake, which, zsh, m4, pkgconfig, perl, gnome2, pango, sqlite, libxml2, zlib, gmp, smlnj }: + +stdenv.mkDerivation { + name = "aliceml-1.4-7d44dc8e"; + + src = fetchgit { + url = "https://github.com/aliceml/aliceml"; + rev = "7d44dc8e4097c6f85888bbf4ff86d51fe05b0a08"; + sha256 = "1xpvia00cpig0i7qvz29sx7xjic6kd472ng722x4rapz8mjnf8bk"; + fetchSubmodules = true; + }; + + gecodeSrc = fetchurl { + url = http://www.gecode.org/download/gecode-1.3.1.tar.gz; + sha256 = "0mgc6llbq166jmlq3alvagqsg3730670zvbwwkdgsqklw70v9355"; + }; + + buildInputs = [ + stdenv gcc glibc + libtool gnumake autoconf automake + file which zsh m4 gnome2.gtk zlib gmp + gnome2.libgnomecanvas pango sqlite + libxml2 pkgconfig perl smlnj + ]; + + makePatch = ./make.patch; + seamPatch = ./seam.patch; + + phases = [ "unpackPhase" "patchPhase" "configurePhase" "buildPhase" ]; + + patchPhase = '' + sed -i -e "s@wget ..GECODE_URL. -O - | tar xz@tar xf $gecodeSrc@" make/Makefile + patch -p1 <$makePatch + patch -p1 <$seamPatch + ''; + + configurePhase = '' + make -C make setup PREFIX="$out" + ''; + + buildPhase = '' + gmp="${gmp.dev}" zlib="${zlib.dev}" PATH=$PATH:`pwd`/seam-support/install/bin make -C make all PREFIX="$out" + ''; + + meta = { + description = "Functional programming language based on Standard ML"; + longDescription = '' + Alice ML is a functional programming language based on Standard ML, + extended with rich support for concurrent, distributed, and constraint + programming. + ''; + homepage = https://www.ps.uni-saarland.de/alice/; + license = stdenv.lib.licenses.mit; + maintainers = [ stdenv.lib.maintainers.doublec ]; + broken = true; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/aliceml/make.patch b/nixpkgs/pkgs/development/compilers/aliceml/make.patch new file mode 100644 index 000000000000..78e2b28974e8 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/aliceml/make.patch @@ -0,0 +1,20 @@ +diff --git a/Makefile b/Makefile +index 6a55b06..84a6000 100644 +--- a/make/Makefile ++++ b/make/Makefile +@@ -387,6 +387,7 @@ configure-seam-linux64: + ../sources/configure \ + --prefix='$(PREFIX)' \ + --with-warnings=yes \ ++ --with-zlib='$(zlib)' \ + --disable-lightning) + + .PHONY: configure-seam-darwin64 +@@ -434,6 +435,7 @@ configure-alice-ll-linux: + (cd $(PWD)/alice/build && \ + ../sources/vm-seam/configure \ + --prefix='$(PREFIX)' \ ++ --with-gmp='$(gmp)' \ + --with-warnings=yes) + + .PHONY: rebuild-alice-ll diff --git a/nixpkgs/pkgs/development/compilers/aliceml/seam.patch b/nixpkgs/pkgs/development/compilers/aliceml/seam.patch new file mode 100644 index 000000000000..d489037fef4a --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/aliceml/seam.patch @@ -0,0 +1,13 @@ +diff --git a/Makefile.cvs b/Makefile.cvs +index b59434a..cd1316f 100644 +--- a/seam/sources/Makefile.cvs ++++ b/seam/sources/Makefile.cvs +@@ -32,7 +32,7 @@ autotools: + aclocal -I . + autoconf + automake --add-missing +- cd libltdl; aclocal; autoconf; automake --add-missing ++ cd libltdl; chmod +w *; aclocal; autoconf; automake --add-missing + + lightning: + rm -rf lightning diff --git a/nixpkgs/pkgs/development/compilers/apache-flex-sdk/default.nix b/nixpkgs/pkgs/development/compilers/apache-flex-sdk/default.nix new file mode 100644 index 000000000000..e8759ec073b3 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/apache-flex-sdk/default.nix @@ -0,0 +1,56 @@ +{ stdenv, fetchurl, makeWrapper, jre }: + +let + playerglobal_ver = "27.0"; + playerglobal = fetchurl { + url = "https://fpdownload.macromedia.com/get/flashplayer/updaters/27/playerglobal27_0.swc"; + sha256 = "0qw2bgls8qsmp80j8vpd4c7s0c8anlrk0ac8z42w89bajcdbwk2f"; + }; +in stdenv.mkDerivation rec { + name = "apache-flex-sdk-${version}"; + version = "4.16.1"; + + src = fetchurl { + url = "https://www.apache.org/dist/flex/${version}/binaries/${name}-bin.tar.gz"; + sha256 = "13iq16dqvgcpb0p35x66hzxsq5pkbr2lbwr766nnqiryinnagz8p"; + }; + + nativeBuildInputs = [ makeWrapper ]; + + buildInputs = [ jre ]; + + buildPhase = ":"; + + postPatch = '' + shopt -s extglob + for i in bin/!(aasdoc|acompc|amxmlc); do + substituteInPlace $i --replace "java " "${jre}/bin/java " + done + ''; + + installPhase = '' + t=$out/opt/apache-flex-sdk + mkdir -p $t $out/bin + mv * $t + rm $t/bin/*.bat + ln -s $t/bin/* $out/bin/ + + for i in $out/bin/!(aasdoc|acompc|amxmlc); do + wrapProgram $i \ + --set FLEX_HOME $t \ + --set PLAYERGLOBAL_HOME $t/frameworks/libs/player/ + done + + mkdir -p $t/frameworks/libs/player/${playerglobal_ver}/ + cp ${playerglobal} $t/frameworks/libs/player/${playerglobal_ver}/playerglobal.swc + ''; + + fixupPhase = ":"; + + meta = with stdenv.lib; { + description = "Flex SDK for Adobe Flash / ActionScript"; + homepage = "https://flex.apache.org/"; + license = with licenses; [ asl20 ]; + maintainers = with maintainers; [ dywedir ]; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/arachne-pnr/default.nix b/nixpkgs/pkgs/development/compilers/arachne-pnr/default.nix new file mode 100644 index 000000000000..ad68382c13ae --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/arachne-pnr/default.nix @@ -0,0 +1,44 @@ +{ stdenv, fetchFromGitHub, icestorm }: + +with builtins; + +stdenv.mkDerivation rec { + name = "arachne-pnr-${version}"; + version = "2018.09.09"; + + src = fetchFromGitHub { + owner = "yosyshq"; + repo = "arachne-pnr"; + rev = "840bdfdeb38809f9f6af4d89dd7b22959b176fdd"; + sha256 = "1dqvjvgvsridybishv4pnigw9gypxh7r7nrqp9z9qq92v7c5rxzl"; + }; + + enableParallelBuilding = true; + makeFlags = + [ "PREFIX=$(out)" + "ICEBOX=${icestorm}/share/icebox" + ]; + + patchPhase = '' + substituteInPlace ./Makefile \ + --replace 'echo UNKNOWN' 'echo ${substring 0 10 src.rev}' + ''; + + meta = { + description = "Place and route tool for FPGAs"; + longDescription = '' + Arachne-pnr implements the place and route step of + the hardware compilation process for FPGAs. It + accepts as input a technology-mapped netlist in BLIF + format, as output by the Yosys [0] synthesis suite + for example. It currently targets the Lattice + Semiconductor iCE40 family of FPGAs [1]. Its output + is a textual bitstream representation for assembly by + the IceStorm [2] icepack command. + ''; + homepage = https://github.com/cseed/arachne-pnr; + license = stdenv.lib.licenses.mit; + maintainers = with stdenv.lib.maintainers; [ shell thoughtpolice ]; + platforms = stdenv.lib.platforms.linux; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/as31/default.nix b/nixpkgs/pkgs/development/compilers/as31/default.nix new file mode 100644 index 000000000000..519992fd8c26 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/as31/default.nix @@ -0,0 +1,39 @@ +{ stdenv, fetchpatch, fetchurl, yacc }: + +let + + version = "2.3.1"; + +in stdenv.mkDerivation { + name = "as31-${version}"; + src = fetchurl { + name = "as31-${version}.tar.gz"; # Nix doesn't like the colons in the URL + url = "http://wiki.erazor-zone.de/_media/wiki:projects:linux:as31:as31-${version}.tar.gz"; + sha256 = "0mbk6z7z03xb0r0ccyzlgkjdjmdzknck4yxxmgr9k7v8f5c348fd"; + }; + + buildInputs = [ yacc ]; + + patches = [ + (fetchpatch { + name = "CVE-2012-0808.patch"; + url = "https://bugs.debian.org/cgi-bin/bugreport.cgi?att=1;bug=655496;filename=as31-mkstemps.patch;msg=5"; + sha256 = "0iia4wa8m141bwz4588yxb1dp2qwhapcii382sncm6jvwyngwh21"; + }) + ]; + + preConfigure = '' + chmod +x ./configure + ''; + + postConfigure = '' + rm as31/parser.c + ''; + + meta = with stdenv.lib; { + homepage = http://wiki.erazor-zone.de/wiki:projects:linux:as31; + description = "An 8031/8051 assembler by Ken Stauffer and Theo Deraadt which produces a variety of object code output formats"; + maintainers = with maintainers; [ aneeshusa ]; + platforms = with platforms; unix; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/asn1c/default.nix b/nixpkgs/pkgs/development/compilers/asn1c/default.nix new file mode 100644 index 000000000000..ce754813dda1 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/asn1c/default.nix @@ -0,0 +1,33 @@ +{ stdenv, fetchurl, perl }: + +stdenv.mkDerivation rec { + name = "asn1c-${version}"; + version = "0.9.28"; + + src = fetchurl { + url = "https://lionet.info/soft/asn1c-${version}.tar.gz"; + sha256 = "1fc64g45ykmv73kdndr4zdm4wxhimhrir4rxnygxvwkych5l81w0"; + }; + + outputs = [ "out" "doc" "man" ]; + + buildInputs = [ perl ]; + + preConfigure = '' + patchShebangs examples/crfc2asn1.pl + ''; + + postInstall = '' + cp -r skeletons/standard-modules $out/share/asn1c + ''; + + doCheck = true; + + meta = with stdenv.lib; { + homepage = http://lionet.info/asn1c/compiler.html; + description = "Open Source ASN.1 Compiler"; + license = licenses.bsd2; + platforms = platforms.all; + maintainers = [ maintainers.montag451 ]; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/aspectj/builder.sh b/nixpkgs/pkgs/development/compilers/aspectj/builder.sh new file mode 100755 index 000000000000..3b4393720042 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/aspectj/builder.sh @@ -0,0 +1,27 @@ +source $stdenv/setup + +export JAVA_HOME=$jre + +cat >> props <<EOF +output.dir=$out +context.javaPath=$jre +EOF + +mkdir -p $out +$jre/bin/java -jar $src -text props + +echo "Removing files at top level" +for file in $out/* +do + if test -f $file ; then + rm $file + fi +done + +cat >> $out/bin/aj-runtime-env <<EOF +#! $SHELL + +export CLASSPATH=$CLASSPATH:.:$out/lib/aspectjrt.jar +EOF + +chmod u+x $out/bin/aj-runtime-env diff --git a/nixpkgs/pkgs/development/compilers/aspectj/default.nix b/nixpkgs/pkgs/development/compilers/aspectj/default.nix new file mode 100644 index 000000000000..4b216761259d --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/aspectj/default.nix @@ -0,0 +1,21 @@ +{stdenv, fetchurl, jre}: + +stdenv.mkDerivation rec { + name = "aspectj-1.5.2"; + builder = ./builder.sh; + + src = fetchurl { + url = "http://archive.eclipse.org/tools/aspectj/${name}.jar"; + sha256 = "1b3mx248dc1xka1vgsl0jj4sm0nfjsqdcj9r9036mvixj1zj3nmh"; + }; + + inherit jre; + buildInputs = [jre]; + + meta = { + homepage = http://www.eclipse.org/aspectj/; + description = "A seamless aspect-oriented extension to the Java programming language"; + platforms = stdenv.lib.platforms.unix; + license = stdenv.lib.licenses.epl10; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/ats/default.nix b/nixpkgs/pkgs/development/compilers/ats/default.nix new file mode 100644 index 000000000000..002f34daa13b --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/ats/default.nix @@ -0,0 +1,25 @@ +{ stdenv, fetchurl, gmp }: + +stdenv.mkDerivation rec { + name = "ats-${version}"; + version = "0.2.12"; + + src = fetchurl { + url = "mirror://sourceforge/ats-lang/ats-lang-anairiats-${version}.tgz"; + sha256 = "0l2kj1fzhxwsklwmn5yj2vp9rmw4jg0b18bzwqz72bfi8i39736k"; + }; + + # this is necessary because atxt files usually include some .hats files + patches = [ ./install-atsdoc-hats-files.patch ]; + buildInputs = [ gmp ]; + + meta = { + description = "Functional programming language with dependent types"; + homepage = "http://www.ats-lang.org"; + license = stdenv.lib.licenses.gpl3Plus; + # TODO: it looks like ATS requires gcc specifically. Someone with more knowledge + # will need to experiment. + platforms = stdenv.lib.platforms.linux; + maintainers = [ stdenv.lib.maintainers.thoughtpolice ]; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/ats/install-atsdoc-hats-files.patch b/nixpkgs/pkgs/development/compilers/ats/install-atsdoc-hats-files.patch new file mode 100644 index 000000000000..93c6fa07d8a6 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/ats/install-atsdoc-hats-files.patch @@ -0,0 +1,38 @@ +--- ats-lang-anairiats-0.2.11/Makefile 2013-12-10 00:43:52.000000000 +0100 ++++ ats-lang-anairiats-0.2.11/Makefile 2014-03-02 07:49:06.985837425 +0100 +@@ -97,7 +97,7 @@ + cd $(abs_top_srcdir) + [ -d $(bindir2) ] || $(MKDIR_P) $(bindir2) + $(MKDIR_P) $(ATSLIBHOME2)/bin +- find ccomp contrib doc libats libc prelude -type d \ ++ find ccomp contrib doc libats libatsdoc libc prelude -type d \ + -exec $(MKDIR_P) $(ATSLIBHOME2)/\{} \; \ + -print + +@@ -105,7 +105,7 @@ + # + # recursively install all files in the list except .svn control files. + # +- for d in ccomp/runtime contrib doc libats libc prelude; do \ ++ for d in ccomp/runtime contrib doc libats libatsdoc libc prelude; do \ + cd $(abs_top_srcdir) && \ + $(INSTALL) -d $(ATSLIBHOME2)/"$$d" && \ + find "$$d" -name .svn -prune -o -type f \ +@@ -143,6 +143,17 @@ + $(INSTALL) -m 755 ats_env.sh $(bindir2)/"$$b" && \ + echo [ats_env.sh] is installed into $(bindir2)/"$$b"; \ + done ++# ++# install atsdoc headers ++# ++ for f in \ ++ utils/atsdoc/SATS/*.sats utils/atsdoc/DATS/*.dats utils/atsdoc/HATS/*.hats; \ ++ do \ ++ [ -f "$$f" ] || continue; \ ++ cd $(abs_top_srcdir) && \ ++ $(INSTALL) -m 644 -D "$$f" $(ATSLIBHOME2)/"$$f" && \ ++ echo "$$f"; \ ++ done + + install:: install_files + diff --git a/nixpkgs/pkgs/development/compilers/ats2/default.nix b/nixpkgs/pkgs/development/compilers/ats2/default.nix new file mode 100644 index 000000000000..df61ea2b791c --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/ats2/default.nix @@ -0,0 +1,57 @@ +{ stdenv, fetchurl, gmp +, withEmacsSupport ? true +, withContrib ? true }: + +let + versionPkg = "0.3.13" ; + + contrib = fetchurl { + url = "mirror://sourceforge/ats2-lang/ATS2-Postiats-contrib-${versionPkg}.tgz"; + sha256 = "5f64172b2df08c8563b01febc32b582b2d7b59c0c514bd2beb727e69bb8e24ee"; + }; + + postInstallContrib = stdenv.lib.optionalString withContrib + '' + local contribDir=$out/lib/ats2-postiats-*/ ; + mkdir -p $contribDir ; + tar -xzf "${contrib}" --strip-components 1 -C $contribDir ; + ''; + + postInstallEmacs = stdenv.lib.optionalString withEmacsSupport + '' + local siteLispDir=$out/share/emacs/site-lisp/ats2 ; + mkdir -p $siteLispDir ; + install -m 0644 -v ./utils/emacs/*.el $siteLispDir ; + ''; +in + +stdenv.mkDerivation rec { + name = "ats2-${version}"; + version = versionPkg; + + src = fetchurl { + url = "mirror://sourceforge/ats2-lang/ATS2-Postiats-gmp-${version}.tgz"; + sha256 = "0056ff5bfa55c9b9831dce004e7b1b9e7a98d56a9d8ae49d827f9fd0ef823c23"; + }; + + buildInputs = [ gmp ]; + + setupHook = with stdenv.lib; + let + hookFiles = + [ ./setup-hook.sh ] + ++ optional withContrib ./setup-contrib-hook.sh; + in + builtins.toFile "setupHook.sh" + (concatMapStringsSep "\n" builtins.readFile hookFiles); + + postInstall = postInstallContrib + postInstallEmacs; + + meta = with stdenv.lib; { + description = "Functional programming language with dependent types"; + homepage = "http://www.ats-lang.org"; + license = licenses.gpl3Plus; + platforms = platforms.linux; + maintainers = with maintainers; [ thoughtpolice ttuegel bbarker ]; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/ats2/setup-contrib-hook.sh b/nixpkgs/pkgs/development/compilers/ats2/setup-contrib-hook.sh new file mode 100644 index 000000000000..8c5e123b61c4 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/ats2/setup-contrib-hook.sh @@ -0,0 +1 @@ +export PATSHOMERELOC=@out@/lib/ats2-postiats-@version@ diff --git a/nixpkgs/pkgs/development/compilers/ats2/setup-hook.sh b/nixpkgs/pkgs/development/compilers/ats2/setup-hook.sh new file mode 100644 index 000000000000..67647b1edf69 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/ats2/setup-hook.sh @@ -0,0 +1 @@ +export PATSHOME=@out@/lib/ats2-postiats-@version@ diff --git a/nixpkgs/pkgs/development/compilers/avian/default.nix b/nixpkgs/pkgs/development/compilers/avian/default.nix new file mode 100644 index 000000000000..387ae906b88d --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/avian/default.nix @@ -0,0 +1,43 @@ +{ stdenv, fetchFromGitHub, zlib, jdk, CoreServices, Foundation }: + +stdenv.mkDerivation rec { + name = "avian-${version}"; + version = "1.2.0"; + + src = fetchFromGitHub { + owner = "readytalk"; + repo = "avian"; + rev = "v${version}"; + sha256 = "1j2y45cpqk3x6a743mgpg7z3ivwm7qc9jy6xirvay7ah1qyxmm48"; + }; + + buildInputs = [ zlib jdk ] + ++ stdenv.lib.optionals stdenv.isDarwin [ CoreServices Foundation ]; + + NIX_CFLAGS_COMPILE = "-Wno-error"; + + postPatch = '' + substituteInPlace makefile \ + --replace 'g++' 'c++' \ + --replace 'gcc' 'cc' + ''; + + installPhase = '' + mkdir -p $out/bin + cp build/*/avian $out/bin/ + cp build/*/avian-dynamic $out/bin/ + ''; + + meta = { + description = "Lightweight Java virtual machine"; + longDescription = '' + Avian is a lightweight virtual machine and class library designed + to provide a useful subset of Java’s features, suitable for + building self-contained applications. + ''; + homepage = https://readytalk.github.io/avian/; + license = stdenv.lib.licenses.isc; + platforms = stdenv.lib.platforms.all; + maintainers = [ stdenv.lib.maintainers.earldouglas ]; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/avra/default.nix b/nixpkgs/pkgs/development/compilers/avra/default.nix new file mode 100644 index 000000000000..88a34bd6fd6e --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/avra/default.nix @@ -0,0 +1,29 @@ +{ stdenv, fetchurl, autoconf, automake }: +stdenv.mkDerivation rec { + name = "avra-1.3.0"; + + src = fetchurl { + url = "mirror://sourceforge/avra/${name}.tar.bz2"; + sha256 = "04lp0k0h540l5pmnaai07637f0p4zi766v6sfm7cryfaca3byb56"; + }; + + buildInputs = [ autoconf automake ]; + + preConfigure = '' + cd src/ + + aclocal + autoconf + + touch NEWS README AUTHORS ChangeLog + automake -a + ''; + + meta = with stdenv.lib; { + description = "Assembler for the Atmel AVR microcontroller family"; + homepage = http://avra.sourceforge.net/; + license = licenses.gpl2Plus; + platforms = platforms.all; + maintainers = with maintainers; [ the-kenny ]; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/bigloo/default.nix b/nixpkgs/pkgs/development/compilers/bigloo/default.nix new file mode 100644 index 000000000000..bf2272a75c17 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/bigloo/default.nix @@ -0,0 +1,57 @@ +{ fetchurl, stdenv, gmp }: + +stdenv.mkDerivation rec { + name = "bigloo-${version}"; + version = "4.1a-2"; + + src = fetchurl { + url = "ftp://ftp-sop.inria.fr/indes/fp/Bigloo/bigloo${version}.tar.gz"; + sha256 = "09yrz8r0jpj7bda39fdxzrrdyhi851nlfajsyf0b6jxanz6ygcjx"; + }; + + propagatedBuildInputs = [ gmp ]; + + preConfigure = + # Help libgc's configure. + '' export CXXCPP="$CXX -E" + ''; + + patchPhase = '' + # Fix absolute paths. + sed -e 's=/bin/mv=mv=g' -e 's=/bin/rm=rm=g' \ + -e 's=/tmp=$TMPDIR=g' -i autoconf/* \ + [Mm]akefile* */[Mm]akefile* */*/[Mm]akefile* \ + */*/*/[Mm]akefile* */*/*/*/[Mm]akefile* \ + comptime/Cc/cc.scm gc/install-* + + # Make sure we don't change string lengths in the generated + # C files. + sed -e 's=/bin/rm= rm=g' -e 's=/bin/mv= mv=g' \ + -i comptime/Cc/cc.c + ''; + + checkTarget = "test"; + + # Hack to avoid TMPDIR in RPATHs. + preFixup = ''rm -rf "$(pwd)" ''; + + meta = { + description = "Efficient Scheme compiler"; + homepage = http://www-sop.inria.fr/indes/fp/Bigloo/; + license = stdenv.lib.licenses.gpl2Plus; + platforms = stdenv.lib.platforms.unix; + maintainers = with stdenv.lib.maintainers; [ thoughtpolice ]; + + longDescription = '' + Bigloo is a Scheme implementation devoted to one goal: enabling + Scheme based programming style where C(++) is usually + required. Bigloo attempts to make Scheme practical by offering + features usually presented by traditional programming languages + but not offered by Scheme and functional programming. Bigloo + compiles Scheme modules. It delivers small and fast stand alone + binary executables. Bigloo enables full connections between + Scheme and C programs, between Scheme and Java programs, and + between Scheme and C# programs. + ''; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/binaryen/default.nix b/nixpkgs/pkgs/development/compilers/binaryen/default.nix new file mode 100644 index 000000000000..7c3203fe62eb --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/binaryen/default.nix @@ -0,0 +1,41 @@ +{ stdenv, cmake, python, fetchFromGitHub, emscriptenRev ? null }: + +let + defaultVersion = "83"; + + # Map from git revs to SHA256 hashes + sha256s = { + "version_83" = "0vggd9n6anfxsdk4kiyylysi4cfm2rp39f66sq9zkg0h7vw5x5sm"; + "1.38.28" = "172s7y5f38736ic8ri3mnbdqcrkadd40a26cxcfwbscc53phl11v"; + }; +in + +stdenv.mkDerivation rec { + version = if emscriptenRev == null + then defaultVersion + else "emscripten-${emscriptenRev}"; + rev = if emscriptenRev == null + then "version_${version}" + else emscriptenRev; + name = "binaryen-${version}"; + + src = fetchFromGitHub { + owner = "WebAssembly"; + repo = "binaryen"; + sha256 = + if builtins.hasAttr rev sha256s + then builtins.getAttr rev sha256s + else null; + inherit rev; + }; + + nativeBuildInputs = [ cmake python ]; + + meta = with stdenv.lib; { + homepage = https://github.com/WebAssembly/binaryen; + description = "Compiler infrastructure and toolchain library for WebAssembly, in C++"; + platforms = platforms.all; + maintainers = with maintainers; [ asppsa ]; + license = licenses.asl20; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/bupc/default.nix b/nixpkgs/pkgs/development/compilers/bupc/default.nix new file mode 100644 index 000000000000..ad10845e98cf --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/bupc/default.nix @@ -0,0 +1,40 @@ +{ stdenv, fetchurl, perl, coreutils }: + +stdenv.mkDerivation rec { + name = "berkeley_upc-2.22.0"; + + src = fetchurl { + url = "http://upc.lbl.gov/download/release/${name}.tar.gz"; + sha256 = "041l215x8z1cvjcx7kwjdgiaf9rl2d778k6kiv8q09bc68nwd44m"; + }; + + postPatch = '' + patchShebangs . + ''; + + # Used during the configure phase + ENVCMD = "${coreutils}/bin/env"; + + nativeBuildInputs = [ coreutils ]; + buildInputs = [ perl ]; + + meta = with stdenv.lib; { + description = "A compiler for the Berkely Unified Parallel C language"; + longDescription = '' + Unified Parallel C (UPC) is an extension of the C programming language + designed for high performance computing on large-scale parallel + machines.The language provides a uniform programming model for both + shared and distributed memory hardware. The programmer is presented with + a single shared, partitioned address space, where variables may be + directly read and written by any processor, but each variable is + physically associated with a single processor. UPC uses a Single Program + Multiple Data (SPMD) model of computation in which the amount of + parallelism is fixed at program startup time, typically with a single + thread of execution per processor. + ''; + homepage = https://upc.lbl.gov/; + license = licenses.mit; + platforms = with platforms; [ linux ]; + maintainers = with maintainers; [ zimbatm ]; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/carp/default.nix b/nixpkgs/pkgs/development/compilers/carp/default.nix new file mode 100644 index 000000000000..65f0481a8010 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/carp/default.nix @@ -0,0 +1,47 @@ +{ stdenv, fetchFromGitHub, makeWrapper, clang, haskellPackages }: + +haskellPackages.mkDerivation rec { + + pname = "carp"; + version = "unstable-2018-09-15"; + + src = fetchFromGitHub { + owner = "carp-lang"; + repo = "Carp"; + rev = "cf9286c35cab1c170aa819f7b30b5871b9e812e6"; + sha256 = "1k6kdxbbaclhi40b9p3fgbkc1x6pc4v0029xjm6gny6pcdci2cli"; + }; + + buildDepends = [ makeWrapper ]; + + executableHaskellDepends = with haskellPackages; [ + HUnit blaze-markup blaze-html split cmdargs + ]; + + isExecutable = true; + + # The carp executable must know where to find its core libraries and other + # files. Set the environment variable CARP_DIR so that it points to the root + # of the Carp repo. See: + # https://github.com/carp-lang/Carp/blob/master/docs/Install.md#setting-the-carp_dir + # + # Also, clang must be available run-time because carp is compiled to C which + # is then compiled with clang. + postInstall = '' + wrapProgram $out/bin/carp \ + --set CARP_DIR $src \ + --prefix PATH : ${clang}/bin + wrapProgram $out/bin/carp-header-parse \ + --set CARP_DIR $src \ + --prefix PATH : ${clang}/bin + ''; + + description = "A statically typed lisp, without a GC, for real-time applications"; + homepage = https://github.com/carp-lang/Carp; + license = stdenv.lib.licenses.asl20; + maintainers = with stdenv.lib.maintainers; [ jluttine ]; + + # Windows not (yet) supported. + platforms = with stdenv.lib.platforms; unix ++ darwin; + +} diff --git a/nixpkgs/pkgs/development/compilers/ccl/default.nix b/nixpkgs/pkgs/development/compilers/ccl/default.nix new file mode 100644 index 000000000000..646963eedbca --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/ccl/default.nix @@ -0,0 +1,93 @@ +{ stdenv, fetchurl, bootstrap_cmds, coreutils, glibc, m4, runtimeShell }: + +let + options = rec { + /* TODO: there are also FreeBSD and Windows versions */ + x86_64-linux = { + arch = "linuxx86"; + sha256 = "0hs1f3z7crgzvinpj990kv9gvbsipxvcvwbmk54n51nasvc5025q"; + runtime = "lx86cl64"; + kernel = "linuxx8664"; + }; + i686-linux = { + arch = "linuxx86"; + sha256 = x86_64-linux.sha256; + runtime = "lx86cl"; + kernel = "linuxx8632"; + }; + armv7l-linux = { + arch = "linuxarm"; + sha256 = "0p0l1dzsygb6i1xxgbipjpxkn46xhq3jm41a34ga1qqp4x8lkr62"; + runtime = "armcl"; + kernel = "linuxarm"; + }; + x86_64-darwin = { + arch = "darwinx86"; + sha256 = "5adbea3d8b4a2e29af30d141f781c6613844f468c0ccfa11bae908c3e9641939"; + runtime = "dx86cl64"; + kernel = "darwinx8664"; + }; + armv6l-linux = armv7l-linux; + }; + cfg = options."${stdenv.hostPlatform.system}" or (throw "missing source url for platform ${stdenv.hostPlatform.system}"); +in + +stdenv.mkDerivation rec { + name = "ccl-${version}"; + version = "1.11.5"; + + src = fetchurl { + url = "https://github.com/Clozure/ccl/releases/download/v${version}/ccl-${version}-${cfg.arch}.tar.gz"; + sha256 = cfg.sha256; + }; + + buildInputs = if stdenv.isDarwin then [ bootstrap_cmds m4 ] else [ glibc m4 ]; + + CCL_RUNTIME = cfg.runtime; + CCL_KERNEL = cfg.kernel; + + postPatch = if stdenv.isDarwin then '' + substituteInPlace lisp-kernel/${CCL_KERNEL}/Makefile \ + --replace "M4 = gm4" "M4 = m4" \ + --replace "dtrace" "/usr/sbin/dtrace" \ + --replace "/bin/rm" "${coreutils}/bin/rm" \ + --replace "/bin/echo" "${coreutils}/bin/echo" + + substituteInPlace lisp-kernel/m4macros.m4 \ + --replace "/bin/pwd" "${coreutils}/bin/pwd" + '' else '' + substituteInPlace lisp-kernel/${CCL_KERNEL}/Makefile \ + --replace "/bin/rm" "${coreutils}/bin/rm" \ + --replace "/bin/echo" "${coreutils}/bin/echo" + + substituteInPlace lisp-kernel/m4macros.m4 \ + --replace "/bin/pwd" "${coreutils}/bin/pwd" + ''; + + buildPhase = '' + make -C lisp-kernel/${CCL_KERNEL} clean + make -C lisp-kernel/${CCL_KERNEL} all + + ./${CCL_RUNTIME} -n -b -e '(ccl:rebuild-ccl :full t)' -e '(ccl:quit)' + ''; + + installPhase = '' + mkdir -p "$out/share" + cp -r . "$out/share/ccl-installation" + + mkdir -p "$out/bin" + echo -e '#!${runtimeShell}\n'"$out/share/ccl-installation/${CCL_RUNTIME}"' "$@"\n' > "$out"/bin/"${CCL_RUNTIME}" + chmod a+x "$out"/bin/"${CCL_RUNTIME}" + ln -s "$out"/bin/"${CCL_RUNTIME}" "$out"/bin/ccl + ''; + + hardeningDisable = [ "format" ]; + + meta = with stdenv.lib; { + description = "Clozure Common Lisp"; + homepage = https://ccl.clozure.com/; + maintainers = with maintainers; [ raskin muflax tohl ]; + platforms = attrNames options; + license = licenses.lgpl21; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/chez/default.nix b/nixpkgs/pkgs/development/compilers/chez/default.nix new file mode 100644 index 000000000000..9216c7791433 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/chez/default.nix @@ -0,0 +1,74 @@ +{ stdenv, fetchFromGitHub +, coreutils, cctools +, ncurses, libiconv, libX11, libuuid +}: + +stdenv.mkDerivation rec { + name = "chez-scheme-${version}"; + version = "9.5.2"; + + src = fetchFromGitHub { + owner = "cisco"; + repo = "ChezScheme"; + rev = "refs/tags/v${version}"; + sha256 = "1gsjmsvsj31q5l9bjvm869y7bakrvl41yq94vyqdx8zwcr1bmpjf"; + fetchSubmodules = true; + }; + + nativeBuildInputs = [ coreutils ] ++ stdenv.lib.optional stdenv.isDarwin cctools; + buildInputs = [ ncurses libiconv libX11 libuuid ]; + + enableParallelBuilding = true; + + /* + ** We patch out a very annoying 'feature' in ./configure, which + ** tries to use 'git' to update submodules. + ** + ** We have to also fix a few occurrences to tools with absolute + ** paths in some helper scripts, otherwise the build will fail on + ** NixOS or in any chroot build. + */ + patchPhase = '' + substituteInPlace ./configure \ + --replace "git submodule init && git submodule update || exit 1" "true" + + substituteInPlace ./workarea \ + --replace "/bin/ln" ln \ + --replace "/bin/cp" cp + + substituteInPlace ./makefiles/installsh \ + --replace "/usr/bin/true" "${coreutils}/bin/true" + + substituteInPlace zlib/configure \ + --replace "/usr/bin/libtool" libtool + ''; + + /* + ** Don't use configureFlags, since that just implicitly appends + ** everything onto a --prefix flag, which ./configure gets very angry + ** about. + ** + ** Also, carefully set a manual workarea argument, so that we + ** can later easily find the machine type that we built Chez + ** for. + */ + configurePhase = '' + ./configure --threads --installprefix=$out --installman=$out/share/man + ''; + + /* + ** Clean up some of the examples from the build output. + */ + postInstall = '' + rm -rf $out/lib/csv${version}/examples + ''; + + meta = { + description = "A powerful and incredibly fast R6RS Scheme compiler"; + homepage = https://cisco.github.io/ChezScheme/; + license = stdenv.lib.licenses.asl20; + maintainers = with stdenv.lib.maintainers; [ thoughtpolice ]; + platforms = stdenv.lib.platforms.unix; + badPlatforms = [ "aarch64-linux" ]; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/chicken/4/0001-Introduce-CHICKEN_REPOSITORY_EXTRA.patch b/nixpkgs/pkgs/development/compilers/chicken/4/0001-Introduce-CHICKEN_REPOSITORY_EXTRA.patch new file mode 100644 index 000000000000..ca72ba0119f0 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/chicken/4/0001-Introduce-CHICKEN_REPOSITORY_EXTRA.patch @@ -0,0 +1,157 @@ +From 2877f33747e3871c3a682b3a0c812b8ba2e4da5a Mon Sep 17 00:00:00 2001 +From: Caolan McMahon <caolan@caolanmcmahon.com> +Date: Sat, 25 Jun 2016 11:52:28 +0100 +Subject: [PATCH] Introduce CHICKEN_REPOSITORY_EXTRA + +This environment variable works like CHICKEN_REPOSITORY but supports +multiple paths separated by `:'. Those paths are searched after +CHICKEN_REPOSITORY when loading extensions via `require-library' and +friends. It can be accessed and changed at runtime via the new procedure +`repository-extra-paths' which is analog to `repository-path'. + +Original patch by Moritz Heidkamp. +Updated by Caolan McMahon for CHICKEN 4.11.0 +--- + chicken-install.scm | 29 ++++++++++++++++++++++++----- + chicken.import.scm | 1 + + eval.scm | 37 +++++++++++++++++++++++++++++++------ + 3 files changed, 56 insertions(+), 11 deletions(-) + +diff --git a/chicken-install.scm b/chicken-install.scm +index 7bc6041..f557793 100644 +--- a/chicken-install.scm ++++ b/chicken-install.scm +@@ -120,6 +120,19 @@ + (sprintf "lib/chicken/~a" (##sys#fudge 42))) + (repository-path))))) + ++ (define (repo-paths) ++ (if *deploy* ++ *prefix* ++ (if (and *cross-chicken* (not *host-extension*)) ++ (list (make-pathname C_TARGET_LIB_HOME (sprintf "chicken/~a" C_BINARY_VERSION))) ++ (cons ++ (if *prefix* ++ (make-pathname ++ *prefix* ++ (sprintf "lib/chicken/~a" (##sys#fudge 42))) ++ (repository-path)) ++ (repository-extra-paths))))) ++ + (define (get-prefix #!optional runtime) + (cond ((and *cross-chicken* + (not *host-extension*)) +@@ -226,10 +239,13 @@ + (chicken-version) ) + ;; Duplication of (extension-information) to get custom + ;; prefix. This should be fixed. +- ((let* ((ep (##sys#canonicalize-extension-path x 'ext-version)) +- (sf (make-pathname (repo-path) ep "setup-info"))) +- (and (file-exists? sf) +- (with-input-from-file sf read))) => ++ ((let ((ep (##sys#canonicalize-extension-path x 'ext-version))) ++ (let loop ((paths (repo-paths))) ++ (cond ((null? paths) #f) ++ ((let ((sf (make-pathname (car paths) ep "setup-info"))) ++ (and (file-exists? sf) ++ (with-input-from-file sf read)))) ++ (else (loop (cdr paths)))))) => + (lambda (info) + (let ((a (assq 'version info))) + (if a +@@ -776,7 +792,10 @@ + "installed extension has no information about which egg it belongs to" + (pathname-file sf)) + #f)))) +- (glob (make-pathname (repo-path) "*" "setup-info"))) ++ (append-map ++ (lambda (path) ++ (glob (make-pathname path "*" "setup-info"))) ++ (repo-paths))) + equal?)) + + (define (list-available-extensions trans locn) +diff --git a/chicken.import.scm b/chicken.import.scm +index f6e3a19..be1637c 100644 +--- a/chicken.import.scm ++++ b/chicken.import.scm +@@ -200,6 +200,7 @@ + repl + repl-prompt + repository-path ++ repository-extra-paths + require + reset + reset-handler +diff --git a/eval.scm b/eval.scm +index 6242f62..f7d76d4 100644 +--- a/eval.scm ++++ b/eval.scm +@@ -81,6 +81,7 @@ + (define-constant source-file-extension ".scm") + (define-constant setup-file-extension "setup-info") + (define-constant repository-environment-variable "CHICKEN_REPOSITORY") ++(define-constant repository-extra-environment-variable "CHICKEN_REPOSITORY_EXTRA") + (define-constant prefix-environment-variable "CHICKEN_PREFIX") + + ; these are actually in unit extras, but that is used by default +@@ -1176,6 +1177,25 @@ + + (define ##sys#repository-path repository-path) + ++(define ##sys#repository-extra-paths ++ (let* ((repaths (get-environment-variable repository-extra-environment-variable)) ++ (repaths (if repaths ++ (let ((len (string-length repaths))) ++ (let loop ((i 0) (offset 0) (res '())) ++ (cond ((> i len) ++ (reverse res)) ++ ((or (= i len) (eq? #\: (string-ref repaths i))) ++ (loop (+ i 1) (+ i 1) (cons (substring repaths offset i) res))) ++ (else ++ (loop (+ i 1) offset res))))) ++ '()))) ++ (lambda (#!optional val) ++ (if val ++ (set! repaths val) ++ repaths)))) ++ ++(define repository-extra-paths ##sys#repository-extra-paths) ++ + (define ##sys#setup-mode #f) + + (define ##sys#find-extension +@@ -1193,6 +1213,7 @@ + (let loop ((paths (##sys#append + (if ##sys#setup-mode '(".") '()) + (if rp (list rp) '()) ++ (##sys#repository-extra-paths) + (if inc? ##sys#include-pathnames '()) + (if ##sys#setup-mode '() '("."))) )) + (and (pair? paths) +@@ -1252,12 +1273,16 @@ + [string-append string-append] + [read read] ) + (lambda (id loc) +- (and-let* ((rp (##sys#repository-path))) +- (let* ((p (##sys#canonicalize-extension-path id loc)) +- (rpath (string-append rp "/" p ".")) ) +- (cond ((file-exists? (string-append rpath setup-file-extension)) +- => (cut with-input-from-file <> read) ) +- (else #f) ) ) ) ) )) ++ (let loop ((rpaths (cons (##sys#repository-path) (##sys#repository-extra-paths)))) ++ (and (pair? rpaths) ++ (let ((rp (car rpaths))) ++ (if (not rp) ++ (loop (cdr rpaths)) ++ (let* ((p (##sys#canonicalize-extension-path id loc)) ++ (rpath (string-append rp "/" p ".")) ) ++ (cond ((file-exists? (string-append rpath setup-file-extension)) ++ => (cut with-input-from-file <> read) ) ++ (else (loop (cdr rpaths))) ) )) ))) ) )) + + (define (extension-information ext) + (##sys#extension-information ext 'extension-information) ) +-- +2.1.4 + diff --git a/nixpkgs/pkgs/development/compilers/chicken/4/chicken.nix b/nixpkgs/pkgs/development/compilers/chicken/4/chicken.nix new file mode 100644 index 000000000000..ceeff56330b2 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/chicken/4/chicken.nix @@ -0,0 +1,76 @@ +{ stdenv, fetchurl, makeWrapper, bootstrap-chicken ? null }: + +let + version = "4.13.0"; + platform = with stdenv; + if isDarwin then "macosx" + else if isCygwin then "cygwin" + else if (isFreeBSD || isOpenBSD) then "bsd" + else if isSunOS then "solaris" + else "linux"; # Should be a sane default + lib = stdenv.lib; +in +stdenv.mkDerivation { + name = "chicken-${version}"; + + binaryVersion = 8; + + src = fetchurl { + url = "https://code.call-cc.org/releases/${version}/chicken-${version}.tar.gz"; + sha256 = "0hvckhi5gfny3mlva6d7y9pmx7cbwvq0r7mk11k3sdiik9hlkmdd"; + }; + + setupHook = lib.ifEnable (bootstrap-chicken != null) ./setup-hook.sh; + + buildFlags = "PLATFORM=${platform} PREFIX=$(out) VARDIR=$(out)/var/lib"; + installFlags = "PLATFORM=${platform} PREFIX=$(out) VARDIR=$(out)/var/lib"; + + # We need a bootstrap-chicken to regenerate the c-files after + # applying a patch to add support for CHICKEN_REPOSITORY_EXTRA + patches = lib.ifEnable (bootstrap-chicken != null) [ + ./0001-Introduce-CHICKEN_REPOSITORY_EXTRA.patch + ]; + + buildInputs = [ + makeWrapper + ] ++ (lib.ifEnable (bootstrap-chicken != null) [ + bootstrap-chicken + ]); + + preBuild = lib.ifEnable (bootstrap-chicken != null) '' + # Backup the build* files - those are generated from hostname, + # git-tag, etc. and we don't need/want that + mkdir -p build-backup + mv buildid buildbranch buildtag.h build-backup + + # Regenerate eval.c after the patch + make spotless $buildFlags + + mv build-backup/* . + ''; + + postInstall = '' + for f in $out/bin/* + do + wrapProgram $f \ + --prefix PATH : ${stdenv.cc}/bin + done + ''; + + # TODO: Assert csi -R files -p '(pathname-file (repository-path))' == binaryVersion + + meta = { + homepage = http://www.call-cc.org/; + license = stdenv.lib.licenses.bsd3; + maintainers = with stdenv.lib.maintainers; [ the-kenny ]; + platforms = stdenv.lib.platforms.linux; # Maybe other non-darwin Unix + description = "A portable compiler for the Scheme programming language"; + longDescription = '' + CHICKEN is a compiler for the Scheme programming language. + CHICKEN produces portable and efficient C, supports almost all + of the R5RS Scheme language standard, and includes many + enhancements and extensions. CHICKEN runs on Linux, macOS, + Windows, and many Unix flavours. + ''; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/chicken/4/default.nix b/nixpkgs/pkgs/development/compilers/chicken/4/default.nix new file mode 100644 index 000000000000..8d29c7c9a2b5 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/chicken/4/default.nix @@ -0,0 +1,21 @@ +{ newScope } : +let + callPackage = newScope self; + + self = { + pkgs = self; + + fetchegg = callPackage ./fetchegg { }; + + eggDerivation = callPackage ./eggDerivation.nix { }; + + chicken = callPackage ./chicken.nix { + bootstrap-chicken = self.chicken.override { bootstrap-chicken = null; }; + }; + + chickenEggs = callPackage ./eggs.nix { }; + + egg2nix = callPackage ./egg2nix.nix { }; + }; + +in self diff --git a/nixpkgs/pkgs/development/compilers/chicken/4/egg2nix.nix b/nixpkgs/pkgs/development/compilers/chicken/4/egg2nix.nix new file mode 100644 index 000000000000..d0f3b8a4e261 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/chicken/4/egg2nix.nix @@ -0,0 +1,27 @@ +{ stdenv, eggDerivation, fetchurl, chickenEggs }: + +# Note: This mostly reimplements the default.nix already contained in +# the tarball. Is there a nicer way than duplicating code? + +let + version = "0.5"; +in +eggDerivation { + src = fetchurl { + url = "https://github.com/the-kenny/egg2nix/archive/${version}.tar.gz"; + sha256 = "0adal428v4i7h9lzs7sfq75q2mxhsbf1qqwzrsjv8j41paars20y"; + }; + + name = "egg2nix-${version}"; + buildInputs = with chickenEggs; [ + matchable http-client + ]; + + meta = { + description = "Generate nix-expression from CHICKEN scheme eggs"; + homepage = https://github.com/the-kenny/egg2nix; + license = stdenv.lib.licenses.bsd3; + platforms = stdenv.lib.platforms.unix; + maintainers = [ stdenv.lib.maintainers.the-kenny ]; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/chicken/4/eggDerivation.nix b/nixpkgs/pkgs/development/compilers/chicken/4/eggDerivation.nix new file mode 100644 index 000000000000..4dc7ebe66717 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/chicken/4/eggDerivation.nix @@ -0,0 +1,44 @@ +{ stdenv, chicken, makeWrapper }: +{ name, src +, buildInputs ? [] +, chickenInstallFlags ? [] +, cscOptions ? [] +, ...} @ args: + +let + libPath = "${chicken}/var/lib/chicken/${toString chicken.binaryVersion}/"; + overrides = import ./overrides.nix; + baseName = (builtins.parseDrvName name).name; + override = if builtins.hasAttr baseName overrides + then + builtins.getAttr baseName overrides + else + {}; +in +stdenv.mkDerivation ({ + name = "chicken-${name}"; + propagatedBuildInputs = buildInputs; + buildInputs = [ makeWrapper chicken ]; + + CSC_OPTIONS = stdenv.lib.concatStringsSep " " cscOptions; + + CHICKEN_REPOSITORY = libPath; + CHICKEN_INSTALL_PREFIX = "$out"; + + installPhase = '' + runHook preInstall + + chicken-install -p $out ${stdenv.lib.concatStringsSep " " chickenInstallFlags} + + for f in $out/bin/* + do + wrapProgram $f \ + --set CHICKEN_REPOSITORY $CHICKEN_REPOSITORY \ + --prefix CHICKEN_REPOSITORY_EXTRA : "$out/lib/chicken/${toString chicken.binaryVersion}/:$CHICKEN_REPOSITORY_EXTRA" \ + --prefix CHICKEN_INCLUDE_PATH \; "$CHICKEN_INCLUDE_PATH;$out/share/" \ + --prefix PATH : "$out/bin:${chicken}/bin:$CHICKEN_REPOSITORY_EXTRA:$CHICKEN_REPOSITORY" + done + + runHook postInstall + ''; +} // (builtins.removeAttrs args ["name" "buildInputs"]) // override) diff --git a/nixpkgs/pkgs/development/compilers/chicken/4/eggs.nix b/nixpkgs/pkgs/development/compilers/chicken/4/eggs.nix new file mode 100644 index 000000000000..1f786f127c91 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/chicken/4/eggs.nix @@ -0,0 +1,296 @@ +{ pkgs }: +rec { + inherit (pkgs) eggDerivation fetchegg; + + base64 = eggDerivation { + name = "base64-3.3.1"; + + src = fetchegg { + name = "base64"; + version = "3.3.1"; + sha256 = "0wmldiwwg1jpcn07wb906nc53si5j7sa83wgyq643xzqcx4v4x1d"; + }; + + buildInputs = [ + + ]; + }; + + blob-utils = eggDerivation { + name = "blob-utils-1.0.3"; + + src = fetchegg { + name = "blob-utils"; + version = "1.0.3"; + sha256 = "17vdn02fnxnjx5ixgqimln93lqvzyq4y9w02fw7xnbdcjzqm0xml"; + }; + + buildInputs = [ + setup-helper + string-utils + ]; + }; + + check-errors = eggDerivation { + name = "check-errors-1.13.0"; + + src = fetchegg { + name = "check-errors"; + version = "1.13.0"; + sha256 = "12a0sn82n98jybh72zb39fdddmr5k4785xglxb16750fhy8rmjwi"; + }; + + buildInputs = [ + setup-helper + ]; + }; + + defstruct = eggDerivation { + name = "defstruct-1.6"; + + src = fetchegg { + name = "defstruct"; + version = "1.6"; + sha256 = "0lsgl32nmb5hxqiii4r3292cx5vqh50kp6v062nfiyid9lhrj0li"; + }; + + buildInputs = [ + + ]; + }; + + http-client = eggDerivation { + name = "http-client-0.7.1"; + + src = fetchegg { + name = "http-client"; + version = "0.7.1"; + sha256 = "1s03zgmb7kb99ld0f2ylqgicrab9qgza53fkgsqvg7bh5njmzhxr"; + }; + + buildInputs = [ + intarweb + uri-common + message-digest + md5 + string-utils + sendfile + ]; + }; + + intarweb = eggDerivation { + name = "intarweb-1.3"; + + src = fetchegg { + name = "intarweb"; + version = "1.3"; + sha256 = "0izlby78c25py29bdcbc0vapb6h7xgchqrzi6i51d0rb3mnwy88h"; + }; + + buildInputs = [ + defstruct + uri-common + base64 + ]; + }; + + lookup-table = eggDerivation { + name = "lookup-table-1.13.5"; + + src = fetchegg { + name = "lookup-table"; + version = "1.13.5"; + sha256 = "1nzly6rhynawlvzlyilk8z8cxz57cf9n5iv20glkhh28pz2izmrb"; + }; + + buildInputs = [ + setup-helper + check-errors + miscmacros + record-variants + synch + ]; + }; + + matchable = eggDerivation { + name = "matchable-3.3"; + + src = fetchegg { + name = "matchable"; + version = "3.3"; + sha256 = "07y3lpzgm4djiwi9y2adc796f9kwkmdr28fkfkw65syahdax8990"; + }; + + buildInputs = [ + + ]; + }; + + md5 = eggDerivation { + name = "md5-3.1.0"; + + src = fetchegg { + name = "md5"; + version = "3.1.0"; + sha256 = "0bka43nx8x9b0b079qpvml2fl20km19ny0qjmhwzlh6rwmzazj2a"; + }; + + buildInputs = [ + message-digest + ]; + }; + + message-digest = eggDerivation { + name = "message-digest-3.1.0"; + + src = fetchegg { + name = "message-digest"; + version = "3.1.0"; + sha256 = "1w6bax19dwgih78vcimiws0rja7qsd8hmbm6qqg2hf9cw3vab21s"; + }; + + buildInputs = [ + setup-helper + miscmacros + check-errors + variable-item + blob-utils + string-utils + ]; + }; + + miscmacros = eggDerivation { + name = "miscmacros-2.96"; + + src = fetchegg { + name = "miscmacros"; + version = "2.96"; + sha256 = "1ajdgjrni10i2hmhcp4rawnxajjxry3kmq1krdmah4sf0kjrgajc"; + }; + + buildInputs = [ + + ]; + }; + + record-variants = eggDerivation { + name = "record-variants-0.5.1"; + + src = fetchegg { + name = "record-variants"; + version = "0.5.1"; + sha256 = "15wgysxkm8m4hx9nhhw9akchzipdnqc7yj3qd3zn0z7sxg4sld1h"; + }; + + buildInputs = [ + + ]; + }; + + sendfile = eggDerivation { + name = "sendfile-1.7.29"; + + src = fetchegg { + name = "sendfile"; + version = "1.7.29"; + sha256 = "1dc02cbkx5kixhbqjy26g6gs680vy7krc9qis1p1v4aa0b2lgj7k"; + }; + + buildInputs = [ + + ]; + }; + + setup-helper = eggDerivation { + name = "setup-helper-1.5.4"; + + src = fetchegg { + name = "setup-helper"; + version = "1.5.4"; + sha256 = "1k644y0md2isdcvazqfm4nyc8rh3dby6b0j3r4na4w8ryspqp6gj"; + }; + + buildInputs = [ + + ]; + }; + + string-utils = eggDerivation { + name = "string-utils-1.2.4"; + + src = fetchegg { + name = "string-utils"; + version = "1.2.4"; + sha256 = "07alvghg0dahilrm4jg44bndl0x69sv1zbna9l20cbdvi35i0jp1"; + }; + + buildInputs = [ + setup-helper + miscmacros + lookup-table + check-errors + ]; + }; + + synch = eggDerivation { + name = "synch-2.1.2"; + + src = fetchegg { + name = "synch"; + version = "2.1.2"; + sha256 = "1m9mnbq0m5jsxmd1a3rqpwpxj0l1b7vn1fknvxycc047pmlcyl00"; + }; + + buildInputs = [ + setup-helper + check-errors + ]; + }; + + uri-common = eggDerivation { + name = "uri-common-1.4"; + + src = fetchegg { + name = "uri-common"; + version = "1.4"; + sha256 = "01ds1gixcn4rz657x3hr4rhw2496hsjff42ninw0k39l8i1cbh7c"; + }; + + buildInputs = [ + uri-generic + defstruct + matchable + ]; + }; + + uri-generic = eggDerivation { + name = "uri-generic-2.41"; + + src = fetchegg { + name = "uri-generic"; + version = "2.41"; + sha256 = "1r5jbzjllbnmhm5n0m3fcx0g6dc2c2jzp1dcndkfmxz0cl99zxac"; + }; + + buildInputs = [ + matchable + defstruct + ]; + }; + + variable-item = eggDerivation { + name = "variable-item-1.3.1"; + + src = fetchegg { + name = "variable-item"; + version = "1.3.1"; + sha256 = "19b3mhb8kr892sz9yyzq79l0vv28dgilw9cf415kj6aq16yp4d5n"; + }; + + buildInputs = [ + setup-helper + check-errors + ]; + }; +} + diff --git a/nixpkgs/pkgs/development/compilers/chicken/4/eggs.scm b/nixpkgs/pkgs/development/compilers/chicken/4/eggs.scm new file mode 100644 index 000000000000..d847ae9e29b9 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/chicken/4/eggs.scm @@ -0,0 +1,5 @@ +;; Eggs used by egg2nix +http-client +intarweb +matchable +uri-common diff --git a/nixpkgs/pkgs/development/compilers/chicken/4/fetchegg/builder.sh b/nixpkgs/pkgs/development/compilers/chicken/4/fetchegg/builder.sh new file mode 100644 index 000000000000..204661063090 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/chicken/4/fetchegg/builder.sh @@ -0,0 +1,9 @@ +source $stdenv/setup + +header "exporting egg ${eggName} (version $version) into $out" + +mkdir -p $out +chicken-install -r "${eggName}:${version}" +cp -r ${eggName}/* $out/ + +stopNest diff --git a/nixpkgs/pkgs/development/compilers/chicken/4/fetchegg/default.nix b/nixpkgs/pkgs/development/compilers/chicken/4/fetchegg/default.nix new file mode 100644 index 000000000000..d4d33a5593c3 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/chicken/4/fetchegg/default.nix @@ -0,0 +1,25 @@ +# Fetches a chicken egg from henrietta using `chicken-install -r' +# See: http://wiki.call-cc.org/chicken-projects/egg-index-4.html + +{ stdenvNoCC, chicken }: +{ name, version, md5 ? "", sha256 ? "" }: + +if md5 != "" then + throw "fetchegg does not support md5 anymore, please use sha256" +else +stdenvNoCC.mkDerivation { + name = "chicken-${name}-export-${version}"; + builder = ./builder.sh; + nativeBuildInputs = [ chicken ]; + + outputHashAlgo = "sha256"; + outputHashMode = "recursive"; + outputHash = sha256; + + inherit version; + + eggName = name; + + impureEnvVars = stdenvNoCC.lib.fetchers.proxyImpureEnvVars; +} + diff --git a/nixpkgs/pkgs/development/compilers/chicken/4/overrides.nix b/nixpkgs/pkgs/development/compilers/chicken/4/overrides.nix new file mode 100644 index 000000000000..9fdda9b6d9fe --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/chicken/4/overrides.nix @@ -0,0 +1,10 @@ +{ + setup-helper = { + preBuild = '' + substituteInPlace setup-helper.setup \ + --replace "(chicken-home)" \"$out/share/\" + + cat setup-helper.setup + ''; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/chicken/4/setup-hook.sh b/nixpkgs/pkgs/development/compilers/chicken/4/setup-hook.sh new file mode 100644 index 000000000000..b0d9b53b5378 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/chicken/4/setup-hook.sh @@ -0,0 +1,7 @@ +addChickenRepositoryPath() { + addToSearchPathWithCustomDelimiter : CHICKEN_REPOSITORY_EXTRA "$1/lib/chicken/8/" + # addToSearchPathWithCustomDelimiter \; CHICKEN_INCLUDE_PATH "$1/share/" + export CHICKEN_INCLUDE_PATH="$1/share;$CHICKEN_INCLUDE_PATH" +} + +addEnvHooks "$targetOffset" addChickenRepositoryPath diff --git a/nixpkgs/pkgs/development/compilers/chicken/5/chicken.nix b/nixpkgs/pkgs/development/compilers/chicken/5/chicken.nix new file mode 100644 index 000000000000..ff0faf408394 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/chicken/5/chicken.nix @@ -0,0 +1,62 @@ +{ stdenv, fetchurl, makeWrapper, bootstrap-chicken ? null }: + +let + version = "5.0.0"; + platform = with stdenv; + if isDarwin then "macosx" + else if isCygwin then "cygwin" + else if (isFreeBSD || isOpenBSD) then "bsd" + else if isSunOS then "solaris" + else "linux"; # Should be a sane default + lib = stdenv.lib; +in +stdenv.mkDerivation { + name = "chicken-${version}"; + + binaryVersion = 9; + + src = fetchurl { + url = "https://code.call-cc.org/releases/${version}/chicken-${version}.tar.gz"; + sha256 = "15b5yrzfa8aimzba79x7v6y282f898rxqxfxrr446sjx9jwlpfd8"; + }; + + setupHook = lib.ifEnable (bootstrap-chicken != null) ./setup-hook.sh; + + buildFlags = "PLATFORM=${platform} PREFIX=$(out) VARDIR=$(out)/var/lib"; + installFlags = "PLATFORM=${platform} PREFIX=$(out) VARDIR=$(out)/var/lib"; + + buildInputs = [ + makeWrapper + ] ++ (lib.ifEnable (bootstrap-chicken != null) [ + bootstrap-chicken + ]); + + postInstall = '' + for f in $out/bin/* + do + wrapProgram $f \ + --prefix PATH : ${stdenv.cc}/bin + done + + mv $out/var/lib/chicken $out/lib + rmdir $out/var/lib + rmdir $out/var + ''; + + # TODO: Assert csi -R files -p '(pathname-file (repository-path))' == binaryVersion + + meta = { + homepage = http://www.call-cc.org/; + license = stdenv.lib.licenses.bsd3; + maintainers = with stdenv.lib.maintainers; [ the-kenny ]; + platforms = stdenv.lib.platforms.linux; # Maybe other non-darwin Unix + description = "A portable compiler for the Scheme programming language"; + longDescription = '' + CHICKEN is a compiler for the Scheme programming language. + CHICKEN produces portable and efficient C, supports almost all + of the R5RS Scheme language standard, and includes many + enhancements and extensions. CHICKEN runs on Linux, macOS, + Windows, and many Unix flavours. + ''; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/chicken/5/default.nix b/nixpkgs/pkgs/development/compilers/chicken/5/default.nix new file mode 100644 index 000000000000..8d29c7c9a2b5 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/chicken/5/default.nix @@ -0,0 +1,21 @@ +{ newScope } : +let + callPackage = newScope self; + + self = { + pkgs = self; + + fetchegg = callPackage ./fetchegg { }; + + eggDerivation = callPackage ./eggDerivation.nix { }; + + chicken = callPackage ./chicken.nix { + bootstrap-chicken = self.chicken.override { bootstrap-chicken = null; }; + }; + + chickenEggs = callPackage ./eggs.nix { }; + + egg2nix = callPackage ./egg2nix.nix { }; + }; + +in self diff --git a/nixpkgs/pkgs/development/compilers/chicken/5/egg2nix.nix b/nixpkgs/pkgs/development/compilers/chicken/5/egg2nix.nix new file mode 100644 index 000000000000..21e12849b3ad --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/chicken/5/egg2nix.nix @@ -0,0 +1,29 @@ +{ stdenv, eggDerivation, fetchFromGitHub, chickenEggs }: + +# Note: This mostly reimplements the default.nix already contained in +# the tarball. Is there a nicer way than duplicating code? + +let + version = "c5-git"; +in +eggDerivation { + src = fetchFromGitHub { + owner = "corngood"; + repo = "egg2nix"; + rev = "chicken-5"; + sha256 = "1vfnhbcnyakywgjafhs0k5kpsdnrinzvdjxpz3fkwas1jsvxq3d1"; + }; + + name = "egg2nix-${version}"; + buildInputs = with chickenEggs; [ + args matchable + ]; + + meta = { + description = "Generate nix-expression from CHICKEN scheme eggs"; + homepage = https://github.com/the-kenny/egg2nix; + license = stdenv.lib.licenses.bsd3; + platforms = stdenv.lib.platforms.unix; + maintainers = [ stdenv.lib.maintainers.the-kenny ]; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/chicken/5/eggDerivation.nix b/nixpkgs/pkgs/development/compilers/chicken/5/eggDerivation.nix new file mode 100644 index 000000000000..3dc1c4afce98 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/chicken/5/eggDerivation.nix @@ -0,0 +1,41 @@ +{ stdenv, chicken, makeWrapper }: +{ name, src +, buildInputs ? [] +, chickenInstallFlags ? [] +, cscOptions ? [] +, ...} @ args: + +let + overrides = import ./overrides.nix; + baseName = (builtins.parseDrvName name).name; + override = if builtins.hasAttr baseName overrides + then + builtins.getAttr baseName overrides + else + {}; +in +stdenv.mkDerivation ({ + name = "chicken-${name}"; + propagatedBuildInputs = buildInputs; + buildInputs = [ makeWrapper chicken ]; + + CSC_OPTIONS = stdenv.lib.concatStringsSep " " cscOptions; + + installPhase = '' + runHook preInstall + + export CHICKEN_INSTALL_PREFIX=$out + export CHICKEN_INSTALL_REPOSITORY=$out/lib/chicken/${toString chicken.binaryVersion} + chicken-install ${stdenv.lib.concatStringsSep " " chickenInstallFlags} + + for f in $out/bin/* + do + wrapProgram $f \ + --prefix CHICKEN_REPOSITORY_PATH : "$out/lib/chicken/${toString chicken.binaryVersion}/:$CHICKEN_REPOSITORY_PATH" \ + --prefix CHICKEN_INCLUDE_PATH : "$CHICKEN_INCLUDE_PATH:$out/share/" \ + --prefix PATH : "$out/bin:${chicken}/bin:$CHICKEN_REPOSITORY_PATH" + done + + runHook postInstall + ''; +} // (builtins.removeAttrs args ["name" "buildInputs"]) // override) diff --git a/nixpkgs/pkgs/development/compilers/chicken/5/eggs.nix b/nixpkgs/pkgs/development/compilers/chicken/5/eggs.nix new file mode 100644 index 000000000000..04f7551f32d9 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/chicken/5/eggs.nix @@ -0,0 +1,91 @@ +{ pkgs, stdenv }: +rec { + inherit (pkgs) eggDerivation fetchegg; + + args = eggDerivation { + name = "args-1.6.0"; + + src = fetchegg { + name = "args"; + version = "1.6.0"; + sha256 = "1y9sznh4kxqxvhd8k44bjx0s7xspp52sx4bn8i8i0f8lwch6r2g4"; + }; + + buildInputs = [ + srfi-1 + srfi-13 + srfi-37 + ]; + }; + + matchable = eggDerivation { + name = "matchable-1.0"; + + src = fetchegg { + name = "matchable"; + version = "1.0"; + sha256 = "01vy2ppq3sq0wirvsvl3dh0bwa5jqs1i6rdjdd7pnwj4nncxd1ga"; + }; + + buildInputs = [ + + ]; + }; + + srfi-1 = eggDerivation { + name = "srfi-1-0.5"; + + src = fetchegg { + name = "srfi-1"; + version = "0.5"; + sha256 = "0gh1h406xbxwm5gvc5znc93nxp9xjbhyqf7zzga08k5y6igxrlvk"; + }; + + buildInputs = [ + + ]; + }; + + srfi-13 = eggDerivation { + name = "srfi-13-0.2"; + + src = fetchegg { + name = "srfi-13"; + version = "0.2"; + sha256 = "0jazbdnn9bjm7wwxqq7xzqxc9zfvaapq565rf1czj6ayl96yvk3n"; + }; + + buildInputs = [ + srfi-14 + ]; + }; + + srfi-14 = eggDerivation { + name = "srfi-14-0.2"; + + src = fetchegg { + name = "srfi-14"; + version = "0.2"; + sha256 = "13nm4nn1d52nkvhjizy26z3s6q41x1ml4zm847xzf86x1zwvymni"; + }; + + buildInputs = [ + + ]; + }; + + srfi-37 = eggDerivation { + name = "srfi-37-1.4"; + + src = fetchegg { + name = "srfi-37"; + version = "1.4"; + sha256 = "17f593497n70gldkj6iab6ilgryiqar051v6azn1szhnm1lk7dwd"; + }; + + buildInputs = [ + + ]; + }; +} + diff --git a/nixpkgs/pkgs/development/compilers/chicken/5/eggs.scm b/nixpkgs/pkgs/development/compilers/chicken/5/eggs.scm new file mode 100644 index 000000000000..b743d6e3229d --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/chicken/5/eggs.scm @@ -0,0 +1,3 @@ +;; Eggs used by egg2nix +args +matchable diff --git a/nixpkgs/pkgs/development/compilers/chicken/5/fetchegg/builder.sh b/nixpkgs/pkgs/development/compilers/chicken/5/fetchegg/builder.sh new file mode 100644 index 000000000000..d9adf510f22d --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/chicken/5/fetchegg/builder.sh @@ -0,0 +1,10 @@ +source $stdenv/setup + +header "exporting egg ${eggName} (version $version) into $out" + +mkdir -p $out +CHICKEN_EGG_CACHE=. chicken-install -r "${eggName}:${version}" +rm ${eggName}/{STATUS,TIMESTAMP} +cp -r ${eggName}/* $out/ + +stopNest diff --git a/nixpkgs/pkgs/development/compilers/chicken/5/fetchegg/default.nix b/nixpkgs/pkgs/development/compilers/chicken/5/fetchegg/default.nix new file mode 100644 index 000000000000..24bfbd7a30f4 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/chicken/5/fetchegg/default.nix @@ -0,0 +1,25 @@ +# Fetches a chicken egg from henrietta using `chicken-install -r' +# See: http://wiki.call-cc.org/chicken-projects/egg-index-5.html + +{ stdenvNoCC, chicken }: +{ name, version, md5 ? "", sha256 ? "" }: + +if md5 != "" then + throw "fetchegg does not support md5 anymore, please use sha256" +else +stdenvNoCC.mkDerivation { + name = "chicken-${name}-export"; + builder = ./builder.sh; + nativeBuildInputs = [ chicken ]; + + outputHashAlgo = "sha256"; + outputHashMode = "recursive"; + outputHash = sha256; + + inherit version; + + eggName = name; + + impureEnvVars = stdenvNoCC.lib.fetchers.proxyImpureEnvVars; +} + diff --git a/nixpkgs/pkgs/development/compilers/chicken/5/overrides.nix b/nixpkgs/pkgs/development/compilers/chicken/5/overrides.nix new file mode 100644 index 000000000000..2c63c0851048 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/chicken/5/overrides.nix @@ -0,0 +1,2 @@ +{ +} diff --git a/nixpkgs/pkgs/development/compilers/chicken/5/setup-hook.sh b/nixpkgs/pkgs/development/compilers/chicken/5/setup-hook.sh new file mode 100644 index 000000000000..2447aeb0ceae --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/chicken/5/setup-hook.sh @@ -0,0 +1,6 @@ +addChickenRepositoryPath() { + addToSearchPathWithCustomDelimiter : CHICKEN_REPOSITORY_PATH "$1/lib/chicken/9/" + addToSearchPathWithCustomDelimiter : CHICKEN_INCLUDE_PATH "$1/share/" +} + +addEnvHooks "$targetOffset" addChickenRepositoryPath diff --git a/nixpkgs/pkgs/development/compilers/clasp/default.nix b/nixpkgs/pkgs/development/compilers/clasp/default.nix new file mode 100644 index 000000000000..a1e29951ddb5 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/clasp/default.nix @@ -0,0 +1,131 @@ +{ stdenv, fetchFromGitHub, fetchFromGitLab +, llvmPackages +, cmake, boehmgc, gmp, zlib, ncurses, boost, libelf +, python, git, sbcl +, wafHook +}: +let + sicl = fetchFromGitHub { + owner = "Bike"; + repo = "SICL"; + rev = "78052fb5f02a3814eb7295f3dcac09f21f98702b"; + sha256 = "0wnmp40310ls6q9gkr5ysfkj2qirq26ljjicnkqifc53mm0ghz4i"; + }; + cst = fetchFromGitHub { + owner = "robert-strandh"; + repo = "Concrete-Syntax-Tree"; + rev = "8d8c5abf8f1690cb2b765241d81c2eb86d60d77e"; + sha256 = "1rs8a5nbfffdyli126sccd0z1a8h5axp222b4pgwvgfxsb9w7g3s"; + }; + c2mop = fetchFromGitHub { + owner = "pcostanza"; + repo = "closer-mop"; + rev = "d4d1c7aa6aba9b4ac8b7bb78ff4902a52126633f"; + sha256 = "1amcv0f3vbsq0aqhai7ki5bi367giway1pbfxyc47r7q3hq5hw3c"; + }; + acclimation = fetchFromGitHub { + owner = "robert-strandh"; + repo = "Acclimation"; + rev = "dd15c86b0866fc5d8b474be0da15c58a3c04c45c"; + sha256 = "0ql224qs3zgflvdhfbca621v3byhhqfb71kzy70bslyczxv1bsh2"; + }; + eclector = fetchFromGitHub { + owner = "robert-strandh"; + repo = "Eclector"; + rev = "287ce817c0478668bd389051d2cc6b26ddc62ec9"; + sha256 = "0v7mgkq49ddyx5vvsradcp772y5l7cv9xrll3280hyginpm8w6q3"; + }; + alexandria = fetchFromGitHub { + owner = "clasp-developers"; + repo = "alexandria"; + rev = "e5c54bc30b0887c237bde2827036d17315f88737"; + sha256 = "14h7a9fwimiw9gqxjm2h47d95bfhrm7b81f6si7x8vy18d78fn4g"; + }; + mps = fetchFromGitHub { + owner = "Ravenbrook"; + repo = "mps"; + rev = "b8a05a3846430bc36c8200f24d248c8293801503"; + sha256 = "1q2xqdw832jrp0w9yhgr8xihria01j4z132ac16lr9ssqznkprv6"; + }; + asdf = fetchFromGitLab { + domain = "gitlab.common-lisp.net"; + owner = "asdf"; + repo = "asdf"; + rev = "3.3.1.2"; + sha256 = "0ljr2vc0cb2wrijcyjmp9hcaj2bdhh05ci3zf4f43hdq6i2fgg6g"; + }; +in +stdenv.mkDerivation rec { + name = "${pname}-${version}"; + pname = "clasp"; + version = "0.8.99.20181128"; + + src = fetchFromGitHub { + owner = "drmeister"; + repo = "clasp"; + rev = "2f2b52ccb750048460562b5987a7eaf7a1aa4445"; + sha256 = "0ra55vdnk59lygwzlxr5cg16vb9c45fmg59wahaxclwm461w7fwz"; + fetchSubmodules = true; + }; + + nativeBuildInputs = [ cmake python git sbcl wafHook ] ++ + (with llvmPackages; [ llvm clang ]); + + buildInputs = with llvmPackages; + ( + builtins.map (x: stdenv.lib.overrideDerivation x + (x: {NIX_CFLAGS_COMPILE= (x.NIX_CFLAGS_COMPILE or "") + " -frtti"; })) + [ llvm clang clang-unwrapped clang ]) ++ + [ + gmp zlib ncurses + boost boehmgc libelf + (boost.override {enableStatic = true; enableShared = false;}) + (stdenv.lib.overrideDerivation boehmgc + (x: {configureFlags = (x.configureFlags or []) ++ ["--enable-static"];})) + ]; + + NIX_CXXSTDLIB_COMPILE = " -frtti "; + + postPatch = '' + echo " + PREFIX = '$out' + " | sed -e 's/^ *//' > wscript.config + + mkdir -p src/lisp/kernel/contrib/sicl + mkdir -p src/lisp/kernel/contrib/Concrete-Syntax-Tree + mkdir -p src/lisp/kernel/contrib/closer-mop + mkdir -p src/lisp/kernel/contrib/Acclimation + mkdir -p src/lisp/kernel/contrib/Eclector + mkdir -p src/lisp/kernel/contrib/alexandria + mkdir -p src/mps + mkdir -p src/lisp/modules/asdf + + cp -rfT "${sicl}" src/lisp/kernel/contrib/sicl + cp -rfT "${cst}" src/lisp/kernel/contrib/Concrete-Syntax-Tree + cp -rfT "${c2mop}" src/lisp/kernel/contrib/closer-mop + cp -rfT "${acclimation}" src/lisp/kernel/contrib/Acclimation + cp -rfT "${eclector}" src/lisp/kernel/contrib/Eclector + cp -rfT "${alexandria}" src/lisp/kernel/contrib/alexandria + cp -rfT "${mps}" src/mps + cp -rfT "${asdf}" src/lisp/modules/asdf + + chmod -R u+rwX src + ( cd src/lisp/modules/asdf; make ) + ''; + + buildTargets = "build_cboehm"; + installTargets = "install_cboehm"; + + CLASP_SRC_DONTTOUCH = "true"; + + meta = { + inherit version; + description = ''A Common Lisp implementation based on LLVM with C++ integration''; + license = stdenv.lib.licenses.lgpl21Plus ; + maintainers = [stdenv.lib.maintainers.raskin]; + platforms = stdenv.lib.platforms.linux; + # Large, long to build, a private build of clang is needed, a prerelease. + hydraPlatforms = []; + homepage = "https://github.com/drmeister/clasp"; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/clean/chroot-build-support-do-not-rebuild-equal-timestamps.patch b/nixpkgs/pkgs/development/compilers/clean/chroot-build-support-do-not-rebuild-equal-timestamps.patch new file mode 100644 index 000000000000..3e0fbe6b996d --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/clean/chroot-build-support-do-not-rebuild-equal-timestamps.patch @@ -0,0 +1,17 @@ +The clean command line compiler clm checks modules for freshness by comparing timestamps. +However, in chroot builds all files installed have the same timestamp. This leads to clm +trying to rebuild the library modules distributed with the Clean install every time a user +compiles any file. This patch changes the freshness check to use less than instead of less +than or equal to in order to avoid this. + +--- clean-upstream/src/tools/clm/clm.c 2010-12-10 06:12:17.000000000 -0430 ++++ clean/src/tools/clm/clm.c 2010-12-25 10:29:09.840675925 -0430 +@@ -250,7 +250,7 @@ + || (t1.dwHighDateTime==t2.dwHighDateTime && (unsigned)(t1.dwLowDateTime)<=(unsigned)(t2.dwLowDateTime))) + #else + typedef unsigned long FileTime; +-# define FILE_TIME_LE(t1,t2) (t1<=t2) ++# define FILE_TIME_LE(t1,t2) (t1<t2) + #endif + + typedef struct project_node { diff --git a/nixpkgs/pkgs/development/compilers/clean/default.nix b/nixpkgs/pkgs/development/compilers/clean/default.nix new file mode 100644 index 000000000000..91c163fd343a --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/clean/default.nix @@ -0,0 +1,52 @@ +{ stdenv, fetchurl }: + +stdenv.mkDerivation rec { + name = "clean-3.0"; + + src = + if stdenv.hostPlatform.system == "i686-linux" then (fetchurl { + url = "https://ftp.cs.ru.nl/Clean/Clean30/linux/clean3.0_32_boot.tar.gz"; + sha256 = "0cjxv3vqrg6pz3aicwfdz1zyhk0q650464j3qyl0wzaikh750010"; + }) + else if stdenv.hostPlatform.system == "x86_64-linux" then (fetchurl { + url = "https://ftp.cs.ru.nl/Clean/Clean30/linux/clean3.0_64_boot.tar.gz"; + sha256 = "06k283y9adbi28f78k3m5ssg6py73qqkz3sm8dgxc89drv4krl2i"; + }) + else throw "Architecture not supported"; + + hardeningDisable = [ "format" "pic" ]; + + # clm uses timestamps of dcl, icl, abc and o files to decide what must be rebuild + # and for chroot builds all of the library files will have equal timestamps. This + # makes clm try to rebuild the library modules (and fail due to absence of write permission + # on the Nix store) every time any file is compiled. + patches = [ ./chroot-build-support-do-not-rebuild-equal-timestamps.patch ]; + + preBuild = '' + substituteInPlace Makefile --replace 'INSTALL_DIR = $(CURRENTDIR)' 'INSTALL_DIR = '$out + + substituteInPlace src/tools/clm/clm.c --replace '/usr/bin/gcc' $(type -p gcc) + substituteInPlace src/tools/clm/clm.c --replace '/usr/bin/as' $(type -p as) + + cd src + ''; + + postBuild = '' + cd .. + ''; + + meta = { + description = "General purpose, state-of-the-art, pure and lazy functional programming language"; + longDescription = '' + Clean is a general purpose, state-of-the-art, pure and lazy functional + programming language designed for making real-world applications. Some + of its most notable language features are uniqueness typing, dynamic typing, + and generic functions. + ''; + + homepage = http://wiki.clean.cs.ru.nl/Clean; + license = stdenv.lib.licenses.lgpl21; + maintainers = [ stdenv.lib.maintainers.kkallio ]; + platforms = [ "i686-linux" "x86_64-linux" ]; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/closure/default.nix b/nixpkgs/pkgs/development/compilers/closure/default.nix new file mode 100644 index 000000000000..e9e973618257 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/closure/default.nix @@ -0,0 +1,30 @@ +{ stdenv, fetchurl, jre, makeWrapper }: + +stdenv.mkDerivation rec { + name = "closure-compiler-${version}"; + version = "20190215"; + + src = fetchurl { + url = "https://dl.google.com/closure-compiler/compiler-${version}.tar.gz"; + sha256 = "16rpl7x90ganpxlz6v9292cwx7dnkhklqx1nn161yj7ypf9bzd4k"; + }; + + sourceRoot = "."; + + nativeBuildInputs = [ makeWrapper ]; + buildInputs = [ jre ]; + + installPhase = '' + mkdir -p $out/share/java $out/bin + cp closure-compiler-v${version}.jar $out/share/java + makeWrapper ${jre}/bin/java $out/bin/closure-compiler \ + --add-flags "-jar $out/share/java/closure-compiler-v${version}.jar" + ''; + + meta = with stdenv.lib; { + description = "A tool for making JavaScript download and run faster"; + homepage = https://developers.google.com/closure/compiler/; + license = licenses.asl20; + platforms = platforms.all; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/cmdstan/default.nix b/nixpkgs/pkgs/development/compilers/cmdstan/default.nix new file mode 100644 index 000000000000..dab724ea607c --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/cmdstan/default.nix @@ -0,0 +1,42 @@ +{ stdenv, fetchurl, python, runtimeShell }: + +stdenv.mkDerivation rec { + name = "cmdstan-2.17.1"; + + src = fetchurl { + url = "https://github.com/stan-dev/cmdstan/releases/download/v2.17.1/cmdstan-2.17.1.tar.gz"; + sha256 = "1vq1cnrkvrvbfl40j6ajc60jdrjcxag1fi6kff5pqmadfdz9564j"; + }; + + buildFlags = "build"; + enableParallelBuilding = true; + + doCheck = true; + checkInputs = [ python ]; + checkPhase = "python ./runCmdStanTests.py src/test/interface"; # see #5368 + + installPhase = '' + mkdir -p $out/opt $out/bin + cp -r . $out/opt/cmdstan + ln -s $out/opt/cmdstan/bin/stanc $out/bin/stanc + ln -s $out/opt/cmdstan/bin/stansummary $out/bin/stansummary + cat > $out/bin/stan <<EOF + #!${runtimeShell} + make -C $out/opt/cmdstan "\$(realpath "\$1")" + EOF + chmod a+x $out/bin/stan + ''; + + meta = { + description = "Command-line interface to Stan"; + longDescription = '' + Stan is a probabilistic programming language implementing full Bayesian + statistical inference with MCMC sampling (NUTS, HMC), approximate Bayesian + inference with Variational inference (ADVI) and penalized maximum + likelihood estimation with Optimization (L-BFGS). + ''; + homepage = https://mc-stan.org/interfaces/cmdstan.html; + license = stdenv.lib.licenses.bsd3; + platforms = stdenv.lib.platforms.all; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/cmucl/binary.nix b/nixpkgs/pkgs/development/compilers/cmucl/binary.nix new file mode 100644 index 000000000000..9e3184c42eb2 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/cmucl/binary.nix @@ -0,0 +1,43 @@ +{stdenv, fetchurl}: + +let + inherit (stdenv.hostPlatform) system; + version = "21b"; + downloadUrl = arch: + "http://common-lisp.net/project/cmucl/downloads/release/" + + "${version}/cmucl-${version}-${arch}.tar.bz2"; + fetchDist = {arch, sha256}: fetchurl { + url = downloadUrl arch; + inherit sha256; + }; + dist = + if system == "i686-linux" then fetchDist { + arch = "x86-linux"; + sha256 = "13k3b5ygnbsq6n2i3r5i4ljw3r1qlskn2p5f4x9hrx6vfvbb3k7a"; + } + else throw "Unsupported platform for cmucl."; +in + +stdenv.mkDerivation { + name = "cmucl-binary-${version}"; + + buildCommand = '' + mkdir -p $out + tar -C $out -xjf ${dist} + patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \ + $out/bin/lisp + ''; + + meta = { + description = "The CMU implementation of Common Lisp"; + longDescription = '' + CMUCL is a free implementation of the Common Lisp programming language + which runs on most major Unix platforms. It mainly conforms to the + ANSI Common Lisp standard. + ''; + license = stdenv.lib.licenses.free; # public domain + homepage = http://www.cons.org/cmucl/; + maintainers = [stdenv.lib.maintainers.tohl]; + platforms = stdenv.lib.platforms.linux; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/colm/default.nix b/nixpkgs/pkgs/development/compilers/colm/default.nix new file mode 100644 index 000000000000..61b24a851941 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/colm/default.nix @@ -0,0 +1,28 @@ +{ stdenv, fetchurl, makeWrapper, gcc, asciidoc }: + +stdenv.mkDerivation rec { + name = "colm-${version}"; + version = "0.13.0.6"; + + src = fetchurl { + url = "https://www.colm.net/files/colm/${name}.tar.gz"; + sha256 = "0jd3qmqdm8yszy0yysbp3syk7pcbxvwzv9mibdwz7v9bv1nrai26"; + }; + + nativeBuildInputs = [ makeWrapper asciidoc ]; + + doCheck = true; + + postInstall = '' + wrapProgram $out/bin/colm \ + --prefix PATH ":" ${gcc}/bin + ''; + + meta = with stdenv.lib; { + description = "A programming language for the analysis and transformation of computer languages"; + homepage = http://www.colm.net/open-source/colm; + license = licenses.gpl2; + platforms = platforms.unix; + maintainers = with maintainers; [ pSub ]; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/compcert/default.nix b/nixpkgs/pkgs/development/compilers/compcert/default.nix new file mode 100644 index 000000000000..4538d3031489 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/compcert/default.nix @@ -0,0 +1,73 @@ +{ stdenv, lib, fetchFromGitHub, fetchpatch, makeWrapper +, coq, ocamlPackages, coq2html +, tools ? stdenv.cc +}: + +assert lib.versionAtLeast ocamlPackages.ocaml.version "4.02"; +assert lib.versionAtLeast coq.coq-version "8.6.1"; + +let + ocaml-pkgs = with ocamlPackages; [ ocaml findlib menhir ]; + ccomp-platform = if stdenv.isDarwin then "x86_64-macosx" else "x86_64-linux"; +in +stdenv.mkDerivation rec { + name = "compcert-${version}"; + version = "3.5"; + + src = fetchFromGitHub { + owner = "AbsInt"; + repo = "CompCert"; + rev = "v${version}"; + sha256 = "1g8067a5x3vd0l47d04gjvy5yx49nghh55am5d1fbrjirfsnsz8j"; + }; + + nativeBuildInputs = [ makeWrapper ]; + buildInputs = ocaml-pkgs ++ [ coq coq2html ]; + enableParallelBuilding = true; + + patchPhase = '' + substituteInPlace ./configure \ + --replace '{toolprefix}gcc' '{toolprefix}cc' + ''; + + configurePhase = '' + ./configure -clightgen \ + -prefix $out \ + -toolprefix ${tools}/bin/ \ + ${ccomp-platform} + ''; + + installTargets = "documentation install"; + postInstall = '' + # move man into place + mkdir -p $man/share + mv $out/share/man/ $man/share/ + + # move docs into place + mkdir -p $doc/share/doc/compcert + mv doc/html $doc/share/doc/compcert/ + + # install compcert lib files; remove copy from $out, too + mkdir -p $lib/lib/coq/${coq.coq-version}/user-contrib/compcert/ + mv backend cfrontend common cparser driver flocq x86 x86_64 lib \ + $lib/lib/coq/${coq.coq-version}/user-contrib/compcert/ + rm -rf $out/lib/compcert/coq + + # wrap ccomp to undefine _FORTIFY_SOURCE; ccomp invokes cc1 which sets + # _FORTIFY_SOURCE=2 by default, but undefines __GNUC__ (as it should), + # which causes a warning in libc. this suppresses it. + for x in ccomp clightgen; do + wrapProgram $out/bin/$x --add-flags "-U_FORTIFY_SOURCE" + done + ''; + + outputs = [ "out" "lib" "doc" "man" ]; + + meta = with stdenv.lib; { + description = "Formally verified C compiler"; + homepage = "http://compcert.inria.fr"; + license = licenses.inria-compcert; + platforms = [ "x86_64-linux" "x86_64-darwin" ]; + maintainers = with maintainers; [ thoughtpolice jwiegley vbgl ]; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/coreclr/default.nix b/nixpkgs/pkgs/development/compilers/coreclr/default.nix new file mode 100644 index 000000000000..8be482e2150f --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/coreclr/default.nix @@ -0,0 +1,101 @@ +{ config, stdenv +, fetchFromGitHub +, fetchpatch +, which +, cmake +, clang +, llvmPackages +, libunwind +, gettext +, openssl +, python2 +, icu +, lttng-ust +, liburcu +, libuuid +, libkrb5 +, debug ? config.coreclr.debug or false +}: + +stdenv.mkDerivation rec { + name = "coreclr-${version}"; + version = "2.0.7"; + + src = fetchFromGitHub { + owner = "dotnet"; + repo = "coreclr"; + rev = "v${version}"; + sha256 = "0pzkrfgqywhpijbx7j1v4lxa6270h6whymb64jdkp7yj56ipqh2n"; + }; + + patches = [ + (fetchpatch { + # glibc 2.26 + url = https://github.com/dotnet/coreclr/commit/a8f83b615708c529b112898e7d2fbc3f618b26ee.patch; + sha256 = "047ph5gip4z2h7liwdxsmpnlaq0sd3hliaw4nyqjp647m80g3ffq"; + }) + (fetchpatch { + # clang 5 + url = https://github.com/dotnet/coreclr/commit/9b22e1a767dee38f351001c5601f56d78766a43e.patch; + sha256 = "1w1lxw5ryvhq8m5m0kv880c4bh6y9xdgypkr76sqbh3v568yghzg"; + }) + ]; + + nativeBuildInputs = [ + which + cmake + clang + ]; + + buildInputs = [ + llvmPackages.llvm + llvmPackages.lldb + libunwind + gettext + openssl + python2 + icu + lttng-ust + liburcu + libuuid + libkrb5 + ]; + + configurePhase = '' + # override to avoid cmake running + patchShebangs . + ''; + + BuildArch = if stdenv.is64bit then "x64" else "x86"; + BuildType = if debug then "Debug" else "Release"; + + hardeningDisable = [ + "strictoverflow" + "format" + ]; + + buildPhase = '' + runHook preBuild + # disable -Werror which can potentially breaks with every compiler upgrade + ./build.sh $BuildArch $BuildType cmakeargs "-DCLR_CMAKE_WARNINGS_ARE_ERRORS=OFF" + runHook postBuild + ''; + + installPhase = '' + runHook preInstall + mkdir -p $out/share/dotnet $out/bin + cp -r bin/Product/Linux.$BuildArch.$BuildType/* $out/share/dotnet + for cmd in coreconsole corerun createdump crossgen ilasm ildasm mcs superpmi; do + ln -s $out/share/dotnet/$cmd $out/bin/$cmd + done + runHook postInstall + ''; + + meta = with stdenv.lib; { + homepage = https://github.com/dotnet/core/; + description = ".NET is a general purpose development platform"; + platforms = [ "x86_64-linux" ]; + maintainers = with maintainers; [ kuznero ]; + license = licenses.mit; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/crystal/default.nix b/nixpkgs/pkgs/development/compilers/crystal/default.nix new file mode 100644 index 000000000000..3c6f3693401d --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/crystal/default.nix @@ -0,0 +1,167 @@ +{ stdenv, lib, fetchFromGitHub, fetchurl, makeWrapper +, gmp, openssl, readline, tzdata, libxml2, libyaml +, boehmgc, libatomic_ops, pcre, libevent, libiconv, llvm, clang, which, zlib }: + +# We need multiple binaries as a given binary isn't always able to build +# (even slightly) older or newer version. +# - 0.26.1 can build 0.25.x and 0.26.x but not 0.27.x +# - 0.27.2 can build 0.27.x but not 0.25.x and 0.26.x +# +# We need to keep around at least the latest version released with a stable +# NixOS + +let + archs = { + "x86_64-linux" = "linux-x86_64"; + "i686-linux" = "linux-i686"; + "x86_64-darwin" = "darwin-x86_64"; + }; + + arch = archs."${stdenv.system}" or (throw "system ${stdenv.system} not supported"); + + checkInputs = [ gmp openssl readline libxml2 libyaml tzdata ]; + + genericBinary = { version, sha256s, rel ? 1 }: + stdenv.mkDerivation rec { + name = "crystal-binary-${version}"; + + src = fetchurl { + url = "https://github.com/crystal-lang/crystal/releases/download/${version}/crystal-${version}-${toString rel}-${arch}.tar.gz"; + sha256 = sha256s."${stdenv.system}"; + }; + + buildCommand = '' + mkdir -p $out + tar --strip-components=1 -C $out -xf ${src} + ''; + }; + + generic = { version, sha256, binary, doCheck ? true }: + stdenv.mkDerivation rec { + inherit doCheck; + name = "crystal-${version}"; + + src = fetchFromGitHub { + owner = "crystal-lang"; + repo = "crystal"; + rev = version; + inherit sha256; + }; + + postPatch = '' + ln -s spec/compiler spec/std + substituteInPlace spec/std/process_spec.cr \ + --replace /bin/ /run/current-system/sw/bin/ + ''; + + buildInputs = [ + boehmgc libatomic_ops pcre libevent + llvm zlib openssl + ] ++ stdenv.lib.optionals stdenv.isDarwin [ + libiconv + ]; + + nativeBuildInputs = [ binary makeWrapper which ]; + + makeFlags = [ + "CRYSTAL_CONFIG_VERSION=${version}" + ]; + + buildFlags = [ + "all" "docs" + ]; + + FLAGS = [ + "--release" + "--no-debug" + "--single-module" # needed for deterministic builds + ]; + + # We *have* to add `which` to the PATH or crystal is unable to build stuff + # later if which is not available. + installPhase = '' + runHook preInstall + + install -Dm755 .build/crystal $out/bin/crystal + wrapProgram $out/bin/crystal \ + --suffix PATH : ${lib.makeBinPath [ clang which ]} \ + --suffix CRYSTAL_PATH : lib:$out/lib/crystal \ + --suffix LIBRARY_PATH : ${lib.makeLibraryPath buildInputs} + install -dm755 $out/lib/crystal + cp -r src/* $out/lib/crystal/ + + install -dm755 $out/share/doc/crystal/api + cp -r docs/* $out/share/doc/crystal/api/ + cp -r samples $out/share/doc/crystal/ + + install -Dm644 etc/completion.bash $out/share/bash-completion/completions/crystal + install -Dm644 etc/completion.zsh $out/share/zsh/site-functions/_crystal + + install -Dm644 man/crystal.1 $out/share/man/man1/crystal.1 + + install -Dm644 -t $out/share/licenses/crystal LICENSE README.md + + runHook postInstall + ''; + + enableParallelBuilding = true; + + dontStrip = true; + + checkTarget = "spec"; + + preCheck = '' + export LIBRARY_PATH=${lib.makeLibraryPath checkInputs}:$LIBRARY_PATH + ''; + + meta = with lib; { + description = "A compiled language with Ruby like syntax and type inference"; + homepage = https://crystal-lang.org/; + license = licenses.asl20; + maintainers = with maintainers; [ manveru david50407 peterhoeg ]; + platforms = builtins.attrNames archs; + }; + }; + +in rec { + binaryCrystal_0_26 = genericBinary { + version = "0.26.1"; + sha256s = { + "x86_64-linux" = "1xban102yiiwmlklxvn3xp3q546bp8hlxxpakayajkhhnpl6yv45"; + "i686-linux" = "1igspf1lrv7wpmz0pfrkbx8m1ykvnv4zhic53cav4nicppm2v0ic"; + "x86_64-darwin" = "0hzc65ccajr0yhmvi5vbdgbzbp1gbjy56da24ds3zwwkam1ddk0k"; + }; + }; + + binaryCrystal_0_27 = genericBinary { + version = "0.27.2"; + sha256s = { + "x86_64-linux" = "05l5x7kx2acgnv42fj3rr17z73ix06zvi05h7d7vf3kw0izxrasm"; + "i686-linux" = "1iwizkvn6pglc0azkyfhlmk9ap793krdgcnbihd1kvrvs4cz0mm9"; + "x86_64-darwin" = "14c69ac2dmfwmb5q56ps3xyxxb0mrbc91ahk9h07c8fiqfii3k9g"; + }; + }; + + crystal_0_25 = generic { + version = "0.25.1"; + sha256 = "15xmbkalsdk9qpc6wfpkly3sifgw6a4ai5jzlv78dh3jp7glmgyl"; + doCheck = false; + binary = binaryCrystal_0_26; + }; + + crystal_0_26 = generic { + version = "0.26.1"; + sha256 = "0jwxrqm99zcjj82gyl6bzvnfj79nwzqf8sa1q3f66q9p50v44f84"; + doCheck = false; # about 20 tests out of more than 14000 are failing + binary = binaryCrystal_0_26; + }; + + crystal_0_27 = generic { + version = "0.27.2"; + sha256 = "0vxqnpqi85yh0167nrkbksxsni476iwbh6y3znbvbjbbfhsi3nsj"; + doCheck = false; # about 20 tests out of more than 15000 are failing + binary = binaryCrystal_0_27; + }; + + crystal = crystal_0_27; +} diff --git a/nixpkgs/pkgs/development/compilers/cudatoolkit/default.nix b/nixpkgs/pkgs/development/compilers/cudatoolkit/default.nix new file mode 100644 index 000000000000..e2c3c8fe587b --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/cudatoolkit/default.nix @@ -0,0 +1,298 @@ +{ lib, stdenv, makeWrapper, fetchurl, requireFile, perl, ncurses5, expat, python27, zlib +, gcc48, gcc49, gcc5, gcc6, gcc7 +, xorg, gtk2, gdk_pixbuf, glib, fontconfig, freetype, unixODBC, alsaLib, glibc +}: + +let + + common = + args@{ gcc, version, sha256 + , url ? "" + , name ? "" + , developerProgram ? false + , python ? python27 + , runPatches ? [] + }: + + stdenv.mkDerivation rec { + name = "cudatoolkit-${version}"; + inherit version runPatches; + + dontPatchELF = true; + dontStrip = true; + + src = + if developerProgram then + requireFile { + message = '' + This nix expression requires that ${args.name} is already part of the store. + Register yourself to NVIDIA Accelerated Computing Developer Program, retrieve the CUDA toolkit + at https://developer.nvidia.com/cuda-toolkit, and run the following command in the download directory: + nix-prefetch-url file://\$PWD/${args.name} + ''; + inherit (args) name sha256; + } + else + fetchurl { + inherit (args) url sha256; + }; + + outputs = [ "out" "lib" "doc" ]; + + nativeBuildInputs = [ perl makeWrapper ]; + buildInputs = [ gdk_pixbuf ]; # To get $GDK_PIXBUF_MODULE_FILE via setup-hook + runtimeDependencies = [ + ncurses5 expat python zlib glibc + xorg.libX11 xorg.libXext xorg.libXrender xorg.libXt xorg.libXtst xorg.libXi xorg.libXext + gtk2 glib fontconfig freetype unixODBC alsaLib + ]; + + rpath = "${stdenv.lib.makeLibraryPath runtimeDependencies}:${stdenv.cc.cc.lib}/lib64"; + + unpackPhase = '' + sh $src --keep --noexec + + cd pkg/run_files + sh cuda-linux*.run --keep --noexec + sh cuda-samples*.run --keep --noexec + mv pkg ../../$(basename $src) + cd ../.. + rm -rf pkg + + for patch in $runPatches; do + sh $patch --keep --noexec + mv pkg $(basename $patch) + done + ''; + + installPhase = '' + runHook preInstall + mkdir $out + cd $(basename $src) + export PERL5LIB=. + perl ./install-linux.pl --prefix="$out" + cd .. + for patch in $runPatches; do + cd $(basename $patch) + perl ./install_patch.pl --silent --accept-eula --installdir="$out" + cd .. + done + + rm $out/tools/CUDA_Occupancy_Calculator.xls # FIXME: why? + + # let's remove the 32-bit libraries, they confuse the lib64->lib mover + rm -rf $out/lib + + # Remove some cruft. + ${lib.optionalString (lib.versionAtLeast version "7.0") "rm $out/bin/uninstall*"} + + # Fixup path to samples (needed for cuda 6.5 or else nsight will not find them) + if [ -d "$out"/cuda-samples ]; then + mv "$out"/cuda-samples "$out"/samples + fi + + # Change the #error on GCC > 4.9 to a #warning. + sed -i $out/include/host_config.h -e 's/#error\(.*unsupported GNU version\)/#warning\1/' + + # Fix builds with newer glibc version + sed -i "1 i#define _BITS_FLOATN_H" "$out/include/host_defines.h" + + # Ensure that cmake can find CUDA. + mkdir -p $out/nix-support + echo "cmakeFlags+=' -DCUDA_TOOLKIT_ROOT_DIR=$out'" >> $out/nix-support/setup-hook + + # Move some libraries to the lib output so that programs that + # depend on them don't pull in this entire monstrosity. + mkdir -p $lib/lib + mv -v $out/lib64/libcudart* $lib/lib/ + + # Remove OpenCL libraries as they are provided by ocl-icd and driver. + rm -f $out/lib64/libOpenCL* + + # Set compiler for NVCC. + wrapProgram $out/bin/nvcc \ + --prefix PATH : ${gcc}/bin + + # nvprof do not find any program to profile if LD_LIBRARY_PATH is not set + wrapProgram $out/bin/nvprof \ + --prefix LD_LIBRARY_PATH : $out/lib + '' + lib.optionalString (lib.versionOlder version "8.0") '' + # Hack to fix building against recent Glibc/GCC. + echo "NIX_CFLAGS_COMPILE+=' -D_FORCE_INLINES'" >> $out/nix-support/setup-hook + '' + '' + runHook postInstall + ''; + + postInstall = '' + for b in nvvp nsight; do + wrapProgram "$out/bin/$b" \ + --set GDK_PIXBUF_MODULE_FILE "$GDK_PIXBUF_MODULE_FILE" + done + ''; + + preFixup = '' + while IFS= read -r -d ''$'\0' i; do + if ! isELF "$i"; then continue; fi + echo "patching $i..." + if [[ ! $i =~ \.so ]]; then + patchelf \ + --set-interpreter "''$(cat $NIX_CC/nix-support/dynamic-linker)" $i + fi + if [[ $i =~ libcudart ]]; then + rpath2= + else + rpath2=$rpath:$lib/lib:$out/jre/lib/amd64/jli:$out/lib:$out/lib64:$out/nvvm/lib:$out/nvvm/lib64 + fi + patchelf --set-rpath $rpath2 --force-rpath $i + done < <(find $out $lib $doc -type f -print0) + ''; + + # cuda-gdb doesn't run correctly when not using sandboxing, so + # temporarily disabling the install check. This should be set to true + # when we figure out how to get `cuda-gdb --version` to run correctly + # when not using sandboxing. + doInstallCheck = false; + postInstallCheck = let + in '' + # Smoke test binaries + pushd $out/bin + for f in *; do + case $f in + crt) continue;; + nvcc.profile) continue;; + nsight_ee_plugins_manage.sh) continue;; + uninstall_cuda_toolkit_6.5.pl) continue;; + computeprof|nvvp|nsight) continue;; # GUIs don't feature "--version" + *) echo "Executing '$f --version':"; ./$f --version;; + esac + done + popd + ''; + passthru = { + cc = gcc; + majorVersion = + let versionParts = lib.splitString "." version; + in "${lib.elemAt versionParts 0}.${lib.elemAt versionParts 1}"; + }; + + meta = with stdenv.lib; { + description = "A compiler for NVIDIA GPUs, math libraries, and tools"; + homepage = "https://developer.nvidia.com/cuda-toolkit"; + platforms = [ "x86_64-linux" ]; + license = licenses.unfree; + }; + }; + +in rec { + cudatoolkit_6 = common { + version = "6.0.37"; + url = "http://developer.download.nvidia.com/compute/cuda/6_0/rel/installers/cuda_6.0.37_linux_64.run"; + sha256 = "991e436c7a6c94ec67cf44204d136adfef87baa3ded270544fa211179779bc40"; + gcc = gcc48; + }; + + cudatoolkit_6_5 = common { + version = "6.5.19"; + url = "http://developer.download.nvidia.com/compute/cuda/6_5/rel/installers/cuda_6.5.19_linux_64.run"; + sha256 = "1x9zdmk8z784d3d35vr2ak1l4h5v4jfjhpxfi9fl9dvjkcavqyaj"; + gcc = gcc48; + }; + + cudatoolkit_7 = common { + version = "7.0.28"; + url = "http://developer.download.nvidia.com/compute/cuda/7_0/Prod/local_installers/cuda_7.0.28_linux.run"; + sha256 = "1km5hpiimx11jcazg0h3mjzk220klwahs2vfqhjavpds5ff2wafi"; + gcc = gcc49; + }; + + cudatoolkit_7_5 = common { + version = "7.5.18"; + url = "http://developer.download.nvidia.com/compute/cuda/7.5/Prod/local_installers/cuda_7.5.18_linux.run"; + sha256 = "1v2ylzp34ijyhcxyh5p6i0cwawwbbdhni2l5l4qm21s1cx9ish88"; + gcc = gcc49; + }; + + cudatoolkit_8 = common { + version = "8.0.61.2"; + url = "https://developer.nvidia.com/compute/cuda/8.0/Prod2/local_installers/cuda_8.0.61_375.26_linux-run"; + sha256 = "1i4xrsqbad283qffvysn88w2pmxzxbbby41lw0j1113z771akv4w"; + runPatches = [ + (fetchurl { + url = "https://developer.nvidia.com/compute/cuda/8.0/Prod2/patches/2/cuda_8.0.61.2_linux-run"; + sha256 = "1iaz5rrsnsb1p99qiqvxn6j3ksc7ry8xlr397kqcjzxqbljbqn9d"; + }) + ]; + gcc = gcc5; + }; + + cudatoolkit_9_0 = common { + version = "9.0.176.1"; + url = "https://developer.nvidia.com/compute/cuda/9.0/Prod/local_installers/cuda_9.0.176_384.81_linux-run"; + sha256 = "0308rmmychxfa4inb1ird9bpgfppgr9yrfg1qp0val5azqik91ln"; + runPatches = [ + (fetchurl { + url = "https://developer.nvidia.com/compute/cuda/9.0/Prod/patches/1/cuda_9.0.176.1_linux-run"; + sha256 = "1vbqg97pq9z9c8nqvckiwmq3ljm88m7gaizikzxbvz01izh67gx4"; + }) + (fetchurl { + url = "https://developer.nvidia.com/compute/cuda/9.0/Prod/patches/2/cuda_9.0.176.2_linux-run"; + sha256 = "1sz5dijbx9yf7drfipdxav5a5g6sxy4w6vi9xav0lb6m2xnmyd7c"; + }) + (fetchurl { + url = "https://developer.nvidia.com/compute/cuda/9.0/Prod/patches/3/cuda_9.0.176.3_linux-run"; + sha256 = "1jm83bxpscpjhzs5q3qijdgjm0r8qrdlgkj7y08fq8c0v8q2r7j2"; + }) + (fetchurl { + url = "https://developer.nvidia.com/compute/cuda/9.0/Prod/patches/4/cuda_9.0.176.4_linux-run"; + sha256 = "0pymg3mymsa2n48y0njz3spzlkm15lvjzw8fms1q83zslz4x0lwk"; + }) + ]; + gcc = gcc6; + }; + + cudatoolkit_9_1 = common { + version = "9.1.85.3"; + url = "https://developer.nvidia.com/compute/cuda/9.1/Prod/local_installers/cuda_9.1.85_387.26_linux"; + sha256 = "0lz9bwhck1ax4xf1fyb5nicb7l1kssslj518z64iirpy2qmwg5l4"; + runPatches = [ + (fetchurl { + url = "https://developer.nvidia.com/compute/cuda/9.1/Prod/patches/1/cuda_9.1.85.1_linux"; + sha256 = "1f53ij5nb7g0vb5pcpaqvkaj1x4mfq3l0mhkfnqbk8sfrvby775g"; + }) + (fetchurl { + url = "https://developer.nvidia.com/compute/cuda/9.1/Prod/patches/2/cuda_9.1.85.2_linux"; + sha256 = "16g0w09h3bqmas4hy1m0y6j5ffyharslw52fn25gql57bfihg7ym"; + }) + (fetchurl { + url = "https://developer.nvidia.com/compute/cuda/9.1/Prod/patches/3/cuda_9.1.85.3_linux"; + sha256 = "12mcv6f8z33z8y41ja8bv5p5iqhv2vx91mv3b5z6fcj7iqv98422"; + }) + ]; + gcc = gcc6; + }; + + cudatoolkit_9_2 = common { + version = "9.2.148.1"; + url = "https://developer.nvidia.com/compute/cuda/9.2/Prod2/local_installers/cuda_9.2.148_396.37_linux"; + sha256 = "04c6v9b50l4awsf9w9zj5vnxvmc0hk0ypcfjksbh4vnzrz14wigm"; + runPatches = [ + (fetchurl { + url = "https://developer.nvidia.com/compute/cuda/9.2/Prod2/patches/1/cuda_9.2.148.1_linux"; + sha256 = "1kx6l4yzsamk6q1f4vllcpywhbfr2j5wfl4h5zx8v6dgfpsjm2lw"; + }) + ]; + gcc = gcc7; + }; + + cudatoolkit_9 = cudatoolkit_9_2; + + cudatoolkit_10_0 = common { + version = "10.0.130"; + url = "https://developer.nvidia.com/compute/cuda/10.0/Prod/local_installers/cuda_10.0.130_410.48_linux"; + sha256 = "16p3bv1lwmyqpxil8r951h385sy9asc578afrc7lssa68c71ydcj"; + + gcc = gcc7; + }; + + cudatoolkit_10 = cudatoolkit_10_0; +} diff --git a/nixpkgs/pkgs/development/compilers/dale/default.nix b/nixpkgs/pkgs/development/compilers/dale/default.nix new file mode 100644 index 000000000000..8bae6e2363f6 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/dale/default.nix @@ -0,0 +1,48 @@ +{ stdenv +, fetchFromGitHub +, cmake +, pkgconfig +, libffi +, llvm_35 +, doCheck ? false +, perl +}: + +let version = "20170519"; + +in stdenv.mkDerivation { + name = "dale-${version}"; + + src = fetchFromGitHub { + owner = "tomhrr"; + repo = "dale"; + rev = "39e16d8e89fa070de65a673d4462e783d530f95a"; + sha256 = "0dc5cjahv7lzlp92hidlh83rwgrpgb6xz2pnba2pm5xrv2pnsskl"; + }; + + nativeBuildInputs = [ pkgconfig ]; + buildInputs = [ cmake libffi llvm_35 ] + ++ stdenv.lib.optional doCheck perl; + + patches = [ ./link-llvm.patch ]; + + inherit doCheck; + + checkTarget = "tests"; + + enableParallelBuilding = true; + + meta = with stdenv.lib; { + description = "Lisp-flavoured C"; + longDescription = '' + Dale is a system (no GC) programming language that uses + S-expressions for syntax and supports syntactic macros. + ''; + homepage = https://github.com/tomhrr/dale; + license = licenses.bsd3; + maintainers = with maintainers; [ amiloradovsky ]; + platforms = with platforms; [ "i686-linux" "x86_64-linux" ]; + # failed on Darwin: linker couldn't find the FFI lib + # failed on AArch64: because LLVM 3.5 is failed there + }; +} diff --git a/nixpkgs/pkgs/development/compilers/dale/link-llvm.patch b/nixpkgs/pkgs/development/compilers/dale/link-llvm.patch new file mode 100644 index 000000000000..3facec91874f --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/dale/link-llvm.patch @@ -0,0 +1,10 @@ +--- dale-39e16d8e89fa070de65a673d4462e783d530f95a-src.org/CMakeLists.txt 2017-06-22 08:01:05.839531242 +0100 ++++ dale-39e16d8e89fa070de65a673d4462e783d530f95a-src/CMakeLists.txt 2017-06-22 07:59:11.777566801 +0100 +@@ -78,6 +78,7 @@ + execute_process (COMMAND ${LLVM_CONFIG} --libs + OUTPUT_VARIABLE LLVM_LIBS + OUTPUT_STRIP_TRAILING_WHITESPACE) ++STRING(REGEX REPLACE " " ";" LLVM_LIBS "${LLVM_LIBS}") + if (${D_LLVM_VERSION_MINOR} GREATER 4) + execute_process (COMMAND ${LLVM_CONFIG} --system-libs + OUTPUT_VARIABLE LLVM_SYSTEM_LIBS diff --git a/nixpkgs/pkgs/development/compilers/dev86/default.nix b/nixpkgs/pkgs/development/compilers/dev86/default.nix new file mode 100644 index 000000000000..514075651e15 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/dev86/default.nix @@ -0,0 +1,21 @@ +{ stdenv, fetchurl }: + +stdenv.mkDerivation rec { + name = "dev86-${version}"; + version = "0.16.21"; + + src = fetchurl { + url = "http://v3.sk/~lkundrak/dev86/Dev86src-${version}.tar.gz"; + sha256 = "154dyr2ph4n0kwi8yx0n78j128kw29rk9r9f7s2gddzrdl712jr3"; + }; + + hardeningDisable = [ "format" ]; + + makeFlags = "PREFIX=$(out)"; + + meta = { + description = "Linux 8086 development environment"; + homepage = http://v3.sk/~lkundrak/dev86/; + platforms = stdenv.lib.platforms.linux; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/dmd/default.nix b/nixpkgs/pkgs/development/compilers/dmd/default.nix new file mode 100644 index 000000000000..b15e1a9aa309 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/dmd/default.nix @@ -0,0 +1,157 @@ +{ stdenv, lib, fetchFromGitHub, fetchpatch +, makeWrapper, unzip, which, writeTextFile +, curl, tzdata, gdb, darwin, git +, callPackage, targetPackages, ldc +, version ? "2.085.1" +, dmdSha256 ? "0ccidfcawrcwdpfjwjiln5xwr4ffp8i2hwx52p8zn3xmc5yxm660" +, druntimeSha256 ? "109f2glsqrlshk06761xlw4r5v22mivp873cq9g5gcax3g00k617" +, phobosSha256 ? "0giispqqx8j8xg6c0hm7nx77bcahiwic8rvf12sws3sv5pizv8pr" +}: + +let + + dmdConfFile = writeTextFile { + name = "dmd.conf"; + text = (lib.generators.toINI {} { + "Environment" = { + DFLAGS = ''-I@out@/include/dmd -L-L@out@/lib -fPIC ${stdenv.lib.optionalString (!targetPackages.stdenv.cc.isClang) "-L--export-dynamic"}''; + }; + }); + }; + +in + +stdenv.mkDerivation rec { + name = "dmd-${version}"; + inherit version; + + enableParallelBuilding = true; + + srcs = [ + (fetchFromGitHub { + owner = "dlang"; + repo = "dmd"; + rev = "v${version}"; + sha256 = dmdSha256; + name = "dmd"; + }) + (fetchFromGitHub { + owner = "dlang"; + repo = "druntime"; + rev = "v${version}"; + sha256 = druntimeSha256; + name = "druntime"; + }) + (fetchFromGitHub { + owner = "dlang"; + repo = "phobos"; + rev = "v${version}"; + sha256 = phobosSha256; + name = "phobos"; + }) + ]; + + patchFlags = [ "--directory=dmd" "-p1" ]; + + sourceRoot = "."; + + # https://issues.dlang.org/show_bug.cgi?id=19553 + hardeningDisable = [ "fortify" ]; + + postUnpack = '' + patchShebangs . + ''; + + postPatch = stdenv.lib.optionalString stdenv.hostPlatform.isLinux '' + substituteInPlace phobos/std/socket.d --replace "assert(ih.addrList[0] == 0x7F_00_00_01);" "" + '' + + + stdenv.lib.optionalString stdenv.hostPlatform.isDarwin '' + substituteInPlace phobos/std/socket.d --replace "foreach (name; names)" "names = []; foreach (name; names)" + ''; + + nativeBuildInputs = [ ldc makeWrapper unzip which gdb git ] + + ++ stdenv.lib.optional stdenv.hostPlatform.isDarwin (with darwin.apple_sdk.frameworks; [ + Foundation + ]); + + buildInputs = [ curl tzdata ]; + + bits = builtins.toString stdenv.hostPlatform.parsed.cpu.bits; + osname = if stdenv.hostPlatform.isDarwin then + "osx" + else + stdenv.hostPlatform.parsed.kernel.name; + top = "$(echo $NIX_BUILD_TOP)"; + pathToDmd = "${top}/dmd/generated/${osname}/release/${bits}/dmd"; + + # Buid and install are based on http://wiki.dlang.org/Building_DMD + buildPhase = '' + cd dmd + make -j$NIX_BUILD_CORES -f posix.mak INSTALL_DIR=$out BUILD=release ENABLE_RELEASE=1 PIC=1 HOST_DMD=ldmd2 + cd ../druntime + make -j$NIX_BUILD_CORES -f posix.mak BUILD=release ENABLE_RELEASE=1 PIC=1 INSTALL_DIR=$out DMD=${pathToDmd} + cd ../phobos + echo ${tzdata}/share/zoneinfo/ > TZDatabaseDirFile + echo ${curl.out}/lib/libcurl${stdenv.hostPlatform.extensions.sharedLibrary} > LibcurlPathFile + make -j$NIX_BUILD_CORES -f posix.mak BUILD=release ENABLE_RELEASE=1 PIC=1 INSTALL_DIR=$out DMD=${pathToDmd} DFLAGS="-version=TZDatabaseDir -version=LibcurlPath -J$(pwd)" + cd .. + ''; + + doCheck = true; + + checkPhase = '' + cd dmd + # https://github.com/NixOS/nixpkgs/pull/55998#issuecomment-465871846 + #make -j$NIX_BUILD_CORES -C test -f Makefile PIC=1 CC=$CXX DMD=${pathToDmd} BUILD=release SHELL=$SHELL + cd ../druntime + make -j$NIX_BUILD_CORES -f posix.mak unittest PIC=1 DMD=${pathToDmd} BUILD=release + cd ../phobos + make -j$NIX_BUILD_CORES -f posix.mak unittest BUILD=release ENABLE_RELEASE=1 PIC=1 DMD=${pathToDmd} DFLAGS="-version=TZDatabaseDir -version=LibcurlPath -J$(pwd)" + cd .. + ''; + + dontStrip = true; + + installPhase = '' + cd dmd + mkdir $out + mkdir $out/bin + cp ${pathToDmd} $out/bin + + mkdir -p $out/share/man/man1 + mkdir -p $out/share/man/man5 + cp -r docs/man/man1/* $out/share/man/man1/ + cp -r docs/man/man5/* $out/share/man/man5/ + + cd ../druntime + mkdir $out/include + mkdir $out/include/dmd + cp -r import/* $out/include/dmd + + cd ../phobos + mkdir $out/lib + cp generated/${osname}/release/${bits}/libphobos2.* $out/lib + + cp -r std $out/include/dmd + cp -r etc $out/include/dmd + + wrapProgram $out/bin/dmd \ + --prefix PATH ":" "${targetPackages.stdenv.cc}/bin" \ + --set-default CC "${targetPackages.stdenv.cc}/bin/cc" + + substitute ${dmdConfFile} "$out/bin/dmd.conf" --subst-var out + ''; + + meta = with stdenv.lib; { + description = "Official reference compiler for the D language"; + homepage = http://dlang.org/; + # Everything is now Boost licensed, even the backend. + # https://github.com/dlang/dmd/pull/6680 + license = licenses.boost; + maintainers = with maintainers; [ ThomasMader ]; + platforms = [ "x86_64-linux" "i686-linux" "x86_64-darwin" ]; + }; +} + diff --git a/nixpkgs/pkgs/development/compilers/dotnet/sdk/default.nix b/nixpkgs/pkgs/development/compilers/dotnet/sdk/default.nix new file mode 100644 index 000000000000..4e8ab34b1011 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/dotnet/sdk/default.nix @@ -0,0 +1,58 @@ +{ stdenv +, fetchurl +, libunwind +, openssl +, icu +, libuuid +, zlib +, curl +}: + +let + rpath = stdenv.lib.makeLibraryPath [ stdenv.cc.cc libunwind libuuid icu openssl zlib curl ]; +in + stdenv.mkDerivation rec { + version = "2.2.103"; + netCoreVersion = "2.2.1"; + name = "dotnet-sdk-${version}"; + + src = fetchurl { + url = "https://dotnetcli.azureedge.net/dotnet/Sdk/${version}/dotnet-sdk-${version}-linux-x64.tar.gz"; + # use sha512 from the download page + sha512 = "777AC6DCD0200BA447392E451A1779F0FBFA548BD620A7BBA3EEBDF35892236C3F10B19FF81D4F64B5BC134923CB47F9CC45EE6B004140E1249582249944DB69"; + }; + + unpackPhase = '' + mkdir src + cd src + tar xvzf $src + ''; + + buildPhase = '' + runHook preBuild + patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" ./dotnet + patchelf --set-rpath "${rpath}" ./dotnet + find -type f -name "*.so" -exec patchelf --set-rpath "${rpath}" {} \; + echo -n "dotnet-sdk version: " + ./dotnet --version + runHook postBuild + ''; + + dontPatchELF = true; + + installPhase = '' + runHook preInstall + mkdir -p $out/bin + cp -r ./ $out + ln -s $out/dotnet $out/bin/dotnet + runHook postInstall + ''; + + meta = with stdenv.lib; { + homepage = https://dotnet.github.io/; + description = ".NET Core SDK ${version} with .NET Core ${netCoreVersion}"; + platforms = [ "x86_64-linux" ]; + maintainers = with maintainers; [ kuznero ]; + license = licenses.mit; + }; + } diff --git a/nixpkgs/pkgs/development/compilers/dtc/default.nix b/nixpkgs/pkgs/development/compilers/dtc/default.nix new file mode 100644 index 000000000000..ea305cc5c84c --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/dtc/default.nix @@ -0,0 +1,29 @@ +{ stdenv, fetchgit, flex, bison, pkgconfig, python2, swig, which }: + +stdenv.mkDerivation rec { + pname = "dtc"; + version = "1.5.0"; + + src = fetchgit { + url = "https://git.kernel.org/pub/scm/utils/dtc/dtc.git"; + rev = "refs/tags/v${version}"; + sha256 = "075gj8bbahfdb8dlif3d2dpzjrkyf3bwbcmx96zpwhlgs0da8jxh"; + }; + + nativeBuildInputs = [ flex bison pkgconfig swig which ]; + buildInputs = [ python2 ]; + + postPatch = '' + patchShebangs pylibfdt/ + ''; + + installFlags = [ "INSTALL=install" "PREFIX=$(out)" "SETUP_PREFIX=$(out)" ]; + + meta = with stdenv.lib; { + description = "Device Tree Compiler"; + homepage = https://git.kernel.org/cgit/utils/dtc/dtc.git; + license = licenses.gpl2; # dtc itself is GPLv2, libfdt is dual GPL/BSD + maintainers = [ maintainers.dezgeg ]; + platforms = platforms.unix; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/ecl/16.1.2.nix b/nixpkgs/pkgs/development/compilers/ecl/16.1.2.nix new file mode 100644 index 000000000000..c27f2a226705 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/ecl/16.1.2.nix @@ -0,0 +1,83 @@ +{ stdenv, fetchurl, fetchpatch +, libtool, autoconf, automake +, gmp, mpfr, libffi, makeWrapper +, noUnicode ? false +, gcc +, threadSupport ? false +, useBoehmgc ? true, boehmgc +}: + +assert useBoehmgc -> boehmgc != null; + +let + s = # Generated upstream information + rec { + baseName="ecl"; + version="16.1.2"; + name="${baseName}-${version}"; + url="https://common-lisp.net/project/ecl/static/files/release/ecl-16.1.2.tgz"; + sha256="16ab8qs3awvdxy8xs8jy82v8r04x4wr70l9l2j45vgag18d2nj1d"; + }; + buildInputs = [ + libtool autoconf automake makeWrapper + ]; + propagatedBuildInputs = [ + libffi gmp mpfr gcc + ] ++ stdenv.lib.optionals useBoehmgc [ + # replaces ecl's own gc which other packages can depend on, thus propagated + boehmgc + ]; +in +stdenv.mkDerivation { + inherit (s) name version; + inherit buildInputs propagatedBuildInputs; + + src = fetchurl { + inherit (s) url sha256; + }; + + configureFlags = [ + (if threadSupport then "--enable-threads" else "--disable-threads") + "--with-gmp-prefix=${gmp.dev}" + "--with-libffi-prefix=${libffi.dev}" + ] + ++ + (stdenv.lib.optional (! noUnicode) + "--enable-unicode") + ; + + patches = [ + (fetchpatch { + # Avoid infinite loop, see https://gitlab.com/embeddable-common-lisp/ecl/issues/43 (fixed upstream) + name = "avoid-infinite-loop.patch"; + url = "https://gitlab.com/embeddable-common-lisp/ecl/commit/caba1989f40ef917e7486f41b9cd5c7e3c5c2d79.patch"; + sha256 = "07vw91psbc9gdn8grql46ra8lq3bgkzg5v480chnbryna4sv6lbb"; + }) + (fetchpatch { + # Fix getcwd with long pathnames + # Rebased version of + # https://gitlab.com/embeddable-common-lisp/ecl/commit/ac5f011f57a85a38627af154bc3ee7580e7fecd4.patch + name = "getcwd.patch"; + url = "https://git.sagemath.org/sage.git/plain/build/pkgs/ecl/patches/16.1.2-getcwd.patch?id=07d6c37d18811e2b377a9689790a7c5e24da16ba"; + sha256 = "1fbi8gn7rv8nqff5mpaijsrch3k3z7qc5cn4h1vl8qrr8xwqlqhb"; + }) + ]; + + hardeningDisable = [ "format" ]; + + postInstall = '' + sed -e 's/@[-a-zA-Z_]*@//g' -i $out/bin/ecl-config + wrapProgram "$out/bin/ecl" \ + --prefix PATH ':' "${gcc}/bin" \ + --prefix NIX_LDFLAGS ' ' "-L${gmp.lib or gmp.out or gmp}/lib" \ + --prefix NIX_LDFLAGS ' ' "-L${libffi.lib or libffi.out or libffi}/lib" + ''; + + meta = { + inherit (s) version; + description = "Lisp implementation aiming to be small, fast and easy to embed"; + license = stdenv.lib.licenses.mit ; + maintainers = [stdenv.lib.maintainers.raskin]; + platforms = stdenv.lib.platforms.linux; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/ecl/default.nix b/nixpkgs/pkgs/development/compilers/ecl/default.nix new file mode 100644 index 000000000000..33ed690772ea --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/ecl/default.nix @@ -0,0 +1,66 @@ +{stdenv, fetchurl +, libtool, autoconf, automake +, gmp, mpfr, libffi, makeWrapper +, noUnicode ? false +, gcc +, threadSupport ? true +, useBoehmgc ? false, boehmgc +}: +let + s = # Generated upstream information + rec { + baseName="ecl"; + version="16.1.3"; + name="${baseName}-${version}"; + hash="0m0j24w5d5a9dwwqyrg0d35c0nys16ijb4r0nyk87yp82v38b9bn"; + url="https://common-lisp.net/project/ecl/static/files/release/ecl-16.1.3.tgz"; + sha256="0m0j24w5d5a9dwwqyrg0d35c0nys16ijb4r0nyk87yp82v38b9bn"; + }; + buildInputs = [ + libtool autoconf automake makeWrapper + ]; + propagatedBuildInputs = [ + libffi gmp mpfr gcc + # replaces ecl's own gc which other packages can depend on, thus propagated + ] ++ stdenv.lib.optionals useBoehmgc [ + # replaces ecl's own gc which other packages can depend on, thus propagated + boehmgc + ]; +in +stdenv.mkDerivation { + inherit (s) name version; + inherit buildInputs propagatedBuildInputs; + + src = fetchurl { + inherit (s) url sha256; + }; + + configureFlags = [ + (if threadSupport then "--enable-threads" else "--disable-threads") + "--with-gmp-prefix=${gmp.dev}" + "--with-libffi-prefix=${libffi.dev}" + ] + ++ + (stdenv.lib.optional (! noUnicode) + "--enable-unicode") + ; + + hardeningDisable = [ "format" ]; + + postInstall = '' + sed -e 's/@[-a-zA-Z_]*@//g' -i $out/bin/ecl-config + wrapProgram "$out/bin/ecl" \ + --prefix PATH ':' "${gcc}/bin" \ + --prefix NIX_LDFLAGS ' ' "-L${gmp.lib or gmp.out or gmp}/lib" \ + --prefix NIX_LDFLAGS ' ' "-L${libffi.lib or libffi.out or libffi}/lib" + ''; + + meta = { + inherit (s) version; + description = "Lisp implementation aiming to be small, fast and easy to embed"; + homepage = https://common-lisp.net/project/ecl/; + license = stdenv.lib.licenses.mit ; + maintainers = [stdenv.lib.maintainers.raskin]; + platforms = stdenv.lib.platforms.linux; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/ecl/default.upstream b/nixpkgs/pkgs/development/compilers/ecl/default.upstream new file mode 100644 index 000000000000..eeb82cbfcab1 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/ecl/default.upstream @@ -0,0 +1,2 @@ +url https://common-lisp.net/project/ecl/ +version_link '[.]tgz$' diff --git a/nixpkgs/pkgs/development/compilers/edk2/default.nix b/nixpkgs/pkgs/development/compilers/edk2/default.nix new file mode 100644 index 000000000000..809fc6a4cf1a --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/edk2/default.nix @@ -0,0 +1,95 @@ +{ stdenv, fetchFromGitHub, fetchpatch, libuuid, python2, iasl }: + +let + pythonEnv = python2.withPackages(ps: [ps.tkinter]); + +targetArch = if stdenv.isi686 then + "IA32" +else if stdenv.isx86_64 then + "X64" +else if stdenv.isAarch64 then + "AARCH64" +else + throw "Unsupported architecture"; + +edk2 = stdenv.mkDerivation { + name = "edk2-2017-12-05"; + + src = fetchFromGitHub { + owner = "tianocore"; + repo = "edk2"; + rev = "f71a70e7a4c93a6143d7bad8ab0220a947679697"; + sha256 = "0k48xfwxcgcim1bhkggc19hilvsxsf5axvvcpmld0ng1fcfg0cr6"; + }; + + patches = [ + (fetchpatch { + name = "short-circuit-the-transfer-of-an-empty-S3_CONTEXT.patch"; + url = "https://github.com/tianocore/edk2/commit/9e2a8e928995c3b1bb664b73fd59785055c6b5f6.diff"; + sha256 = "0x24npijhgpjpsn3n74wayf8qcbaj97vi4z2iyf4almavqq8qaz4"; + }) + ]; + + buildInputs = [ libuuid pythonEnv ]; + + makeFlags = "-C BaseTools"; + + hardeningDisable = [ "format" "fortify" ]; + + installPhase = '' + mkdir -vp $out + mv -v BaseTools $out + mv -v EdkCompatibilityPkg $out + mv -v edksetup.sh $out + ''; + + enableParallelBuilding = true; + + meta = { + description = "Intel EFI development kit"; + homepage = https://sourceforge.net/projects/edk2/; + license = stdenv.lib.licenses.bsd2; + branch = "UDK2017"; + platforms = ["x86_64-linux" "i686-linux" "aarch64-linux"]; + }; + + passthru = { + setup = projectDscPath: attrs: { + buildInputs = [ pythonEnv ] ++ + stdenv.lib.optionals (attrs ? buildInputs) attrs.buildInputs; + + configurePhase = '' + mkdir -v Conf + + cp ${edk2}/BaseTools/Conf/target.template Conf/target.txt + sed -i Conf/target.txt \ + -e 's|Nt32Pkg/Nt32Pkg.dsc|${projectDscPath}|' \ + -e 's|MYTOOLS|GCC49|' \ + -e 's|IA32|${targetArch}|' \ + -e 's|DEBUG|RELEASE|'\ + + cp ${edk2}/BaseTools/Conf/tools_def.template Conf/tools_def.txt + sed -i Conf/tools_def.txt \ + -e 's|DEFINE GCC48_IA32_PREFIX = /usr/bin/|DEFINE GCC48_IA32_PREFIX = ""|' \ + -e 's|DEFINE GCC48_X64_PREFIX = /usr/bin/|DEFINE GCC48_X64_PREFIX = ""|' \ + -e 's|DEFINE UNIX_IASL_BIN = /usr/bin/iasl|DEFINE UNIX_IASL_BIN = ${iasl}/bin/iasl|' + + export WORKSPACE="$PWD" + export EFI_SOURCE="$PWD/EdkCompatibilityPkg" + ln -sv ${edk2}/BaseTools BaseTools + ln -sv ${edk2}/EdkCompatibilityPkg EdkCompatibilityPkg + . ${edk2}/edksetup.sh BaseTools + ''; + + buildPhase = " + build + "; + + installPhase = "mv -v Build/*/* $out"; + } // (removeAttrs attrs [ "buildInputs" ] ); + }; +}; + +in + +edk2 diff --git a/nixpkgs/pkgs/development/compilers/eli/default.nix b/nixpkgs/pkgs/development/compilers/eli/default.nix new file mode 100644 index 000000000000..4635c6d0a4e8 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/eli/default.nix @@ -0,0 +1,91 @@ +{ stdenv +, fetchurl +, symlinkJoin +, makeWrapper +, tcl +, fontconfig +, tk +, ncurses +, xorg +, file +}: + +let + # eli derives the location of the include folder from the location of the lib folder + tk_combined = symlinkJoin { + name = "tk_combined"; + paths = [ + tk + tk.dev + ]; + }; + curses_combined = symlinkJoin { + name = "curses_combined"; + paths = [ + ncurses + ncurses.dev + ]; + }; +in +stdenv.mkDerivation rec { + name = "eli-${version}"; + version = "4.8.1"; + + src = fetchurl { + url = "mirror://sourceforge/project/eli-project/Eli/Eli%20${version}/${name}.tar.bz2"; + sha256="1vran8583hbwrr5dciji4zkhz3f88w4mn8n9sdpr6zw0plpf1whj"; + }; + + buildInputs = [ + ncurses + fontconfig + ] ++ (with xorg; [ + libX11.dev + libXt.dev + libXaw.dev + libXext.dev + ]); + + nativeBuildInputs = [ + file + makeWrapper + ]; + + # skip interactive browser check + buildFlags = "nobrowsers"; + + + preConfigure='' + configureFlagsArray=( + --with-tcltk="${tcl} ${tk_combined}" + --with-curses="${curses_combined}" + ) + export ODIN_LOCALIPC=1 + ''; + + postInstall = '' + wrapProgram "$out/bin/eli" \ + --set ODIN_LOCALIPC 1 + ''; + + # Test if eli starts + doInstallCheck = true; + installCheckPhase = '' + export HOME="$TMP/home" + mkdir -p "$HOME" + $out/bin/eli "!ls" + ''; + + meta = { + description = "Translator Construction Made Easy"; + longDescription = '' + Eli is a programming environment that supports all phases of translator + construction with extensive libraries implementing common tasks, yet handling + arbitrary special cases. Output is the C subset of C++. + ''; + homepage = http://eli-project.sourceforge.net/; + license = stdenv.lib.licenses.gpl2; + maintainers = with stdenv.lib.maintainers; [ timokau ]; + platforms = stdenv.lib.platforms.linux; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/elm/README.md b/nixpkgs/pkgs/development/compilers/elm/README.md new file mode 100644 index 000000000000..f0254d0f9547 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/elm/README.md @@ -0,0 +1,24 @@ +# To update Elm: + +Modify revision in ./update.sh and run it + +# Notes about the build process: + +The elm binary embeds a piece of pre-compiled elm code, used by 'elm +reactor'. This means that the build process for 'elm' effectively +executes 'elm make'. that in turn expects to retrieve the elm +dependencies of that code (elm/core, etc.) from +package.elm-lang.org, as well as a cached bit of metadata +(versions.dat). + +The makeDotElm function lets us retrieve these dependencies in the +standard nix way. we have to copy them in (rather than symlink) and +make them writable because the elm compiler writes other .dat files +alongside the source code. versions.dat was produced during an +impure build of this same code; the build complains that it can't +update this cache, but continues past that warning. + +Finally, we set ELM_HOME to point to these pre-fetched artifacts so +that the default of ~/.elm isn't used. + +More: https://blog.hercules-ci.com/elm/2019/01/03/elm2nix-0.1/ diff --git a/nixpkgs/pkgs/development/compilers/elm/default.nix b/nixpkgs/pkgs/development/compilers/elm/default.nix new file mode 100644 index 000000000000..f14bce5d96b3 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/elm/default.nix @@ -0,0 +1,47 @@ +{ lib, stdenv, buildEnv +, haskell, nodejs +, fetchurl, fetchpatch, makeWrapper, git }: + +let + fetchElmDeps = import ./fetchElmDeps.nix { inherit stdenv lib fetchurl; }; + hsPkgs = haskell.packages.ghc864.override { + overrides = self: super: with haskell.lib; + let elmPkgs = { + elm = overrideCabal (self.callPackage ./packages/elm.nix { }) (drv: { + # sadly with parallelism most of the time breaks compilation + enableParallelBuilding = false; + preConfigure = self.fetchElmDeps { + elmPackages = (import ./packages/elm-srcs.nix); + versionsDat = ./versions.dat; + }; + patches = [ + (fetchpatch { + url = "https://github.com/elm/compiler/pull/1886/commits/39d86a735e28da514be185d4c3256142c37c2a8a.patch"; + sha256 = "0nni5qx1523rjz1ja42z6z9pijxvi3fgbw1dhq5qi11mh1nb9ay7"; + }) + ]; + buildTools = drv.buildTools or [] ++ [ makeWrapper ]; + jailbreak = true; + postInstall = '' + wrapProgram $out/bin/elm \ + --prefix PATH ':' ${lib.makeBinPath [ nodejs ]} + ''; + }); + + /* + The elm-format expression is updated via a script in the https://github.com/avh4/elm-format repo: + `pacakge/nix/build.sh` + */ + elm-format = justStaticExecutables (doJailbreak (self.callPackage ./packages/elm-format.nix {})); + + inherit fetchElmDeps; + elmVersion = elmPkgs.elm.version; + }; + in elmPkgs // { + inherit elmPkgs; + + # Needed for elm-format + indents = self.callPackage ./packages/indents.nix {}; + }; + }; +in hsPkgs.elmPkgs diff --git a/nixpkgs/pkgs/development/compilers/elm/fetchElmDeps.nix b/nixpkgs/pkgs/development/compilers/elm/fetchElmDeps.nix new file mode 100644 index 000000000000..3da2445e0c52 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/elm/fetchElmDeps.nix @@ -0,0 +1,11 @@ +{stdenv, lib, fetchurl}: + +{elmPackages, versionsDat}: + +let + makeDotElm = import ./makeDotElm.nix {inherit stdenv lib fetchurl versionsDat;}; + +in +'' + export ELM_HOME=`pwd`/.elm +'' + (makeDotElm "0.19.0" elmPackages) diff --git a/nixpkgs/pkgs/development/compilers/elm/makeDotElm.nix b/nixpkgs/pkgs/development/compilers/elm/makeDotElm.nix new file mode 100644 index 000000000000..1bc8e61d27ca --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/elm/makeDotElm.nix @@ -0,0 +1,30 @@ +{stdenv, lib, fetchurl, versionsDat}: + +ver: deps: + let cmds = lib.mapAttrsToList (name: info: let + pkg = stdenv.mkDerivation { + name = lib.replaceChars ["/"] ["-"] name + "-${info.version}"; + + src = fetchurl { + url = "https://github.com/${name}/archive/${info.version}.tar.gz"; + meta.homepage = "https://github.com/${name}/"; + inherit (info) sha256; + }; + + phases = [ "unpackPhase" "installPhase" ]; + + installPhase = '' + mkdir -p $out + cp -r * $out + ''; + + }; + in '' + mkdir -p .elm/${ver}/package/${name} + cp -R ${pkg} .elm/${ver}/package/${name}/${info.version} + '') deps; + in (lib.concatStrings cmds) + '' + mkdir -p .elm/${ver}/package; + cp ${versionsDat} .elm/${ver}/package/versions.dat; + chmod -R +w .elm + '' diff --git a/nixpkgs/pkgs/development/compilers/elm/packages/elm-format.nix b/nixpkgs/pkgs/development/compilers/elm/packages/elm-format.nix new file mode 100644 index 000000000000..aaae9fa4ba9c --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/elm/packages/elm-format.nix @@ -0,0 +1,36 @@ +{ mkDerivation, fetchgit, ansi-terminal, ansi-wl-pprint, base, binary +, bytestring, Cabal, cmark, containers, directory, filepath, free +, HUnit, indents, json, mtl, optparse-applicative, parsec, process +, QuickCheck, quickcheck-io, split, stdenv, tasty, tasty-golden +, tasty-hunit, tasty-quickcheck, text +}: +mkDerivation { + pname = "elm-format"; + version = "0.8.1"; + src = fetchgit { + url = "https://github.com/avh4/elm-format"; + sha256 = "0p1dy1m6illsl7i04zsv5jqw7i4znv7pfpdfm53zy0k7mq0fk09j"; + rev = "89694e858664329e3cbdaeb71b15c4456fd739ff"; + }; + postPatch = '' + sed -i "s|desc <-.*||" ./Setup.hs + sed -i "s|gitDescribe = .*|gitDescribe = \\\\\"0.8.1\\\\\"\"|" ./Setup.hs + ''; + isLibrary = true; + isExecutable = true; + setupHaskellDepends = [ base Cabal directory filepath process ]; + libraryHaskellDepends = [ + ansi-terminal ansi-wl-pprint base binary bytestring containers + directory filepath free indents json mtl optparse-applicative + parsec process split text + ]; + executableHaskellDepends = [ base ]; + testHaskellDepends = [ + base cmark containers HUnit mtl parsec QuickCheck quickcheck-io + split tasty tasty-golden tasty-hunit tasty-quickcheck text + ]; + doHaddock = false; + homepage = "https://elm-lang.org"; + description = "A source code formatter for Elm"; + license = stdenv.lib.licenses.bsd3; +} diff --git a/nixpkgs/pkgs/development/compilers/elm/packages/elm-srcs.nix b/nixpkgs/pkgs/development/compilers/elm/packages/elm-srcs.nix new file mode 100644 index 000000000000..e1f941626dd7 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/elm/packages/elm-srcs.nix @@ -0,0 +1,62 @@ +{ + + "elm-explorations/markdown" = { + sha256 = "0k3110ixa4wwf3vkkdplagwah9ypr965qxr1y147rnsc1xsxmr6y"; + version = "1.0.0"; + }; + + "elm/json" = { + sha256 = "1g0hafkqf2q633r7ir9wxpb1lnlzskhpsyi0h5bkzj0gl072zfnb"; + version = "1.0.0"; + }; + + "elm/html" = { + sha256 = "1n3gpzmpqqdsldys4ipgyl1zacn0kbpc3g4v3hdpiyfjlgh8bf3k"; + version = "1.0.0"; + }; + + "elm/svg" = { + sha256 = "08x0v8p9wm699jjmsnbq69pxv3jh60j4f6fg7y6hyr7xxj85y390"; + version = "1.0.0"; + }; + + "elm/project-metadata-utils" = { + sha256 = "1d4rd4grrnbdvj9gf00h7dr6hbkjzawgkzpizfrkp1z1pyr3mvq9"; + version = "1.0.0"; + }; + + "elm/browser" = { + sha256 = "1apmvyax93nvmagwj00y16zx10kfv640cxpi64xgqbgy7d2wphy4"; + version = "1.0.0"; + }; + + "elm/core" = { + sha256 = "10kr86h4v5h4p0586q406a5wbl8xvr1jyrf6097zp2wb8sv21ylw"; + version = "1.0.0"; + }; + + "elm/http" = { + sha256 = "1igmm89ialzrjib1j8xagkxalq1x2gj4l0hfxcd66mpwmvg7psl8"; + version = "1.0.0"; + }; + + "elm/parser" = { + sha256 = "0k4zlq30lrvawqvzwbvsl0hrmwf9s832mb41z7fdspm4549dj7wc"; + version = "1.0.0"; + }; + + "elm/url" = { + sha256 = "0av8x5syid40sgpl5vd7pry2rq0q4pga28b4yykn9gd9v12rs3l4"; + version = "1.0.0"; + }; + + "elm/time" = { + sha256 = "0vch7i86vn0x8b850w1p69vplll1bnbkp8s383z7pinyg94cm2z1"; + version = "1.0.0"; + }; + + "elm/virtual-dom" = { + sha256 = "0hm8g92h7z39km325dlnhk8n00nlyjkqp3r3jppr37k2k13md6aq"; + version = "1.0.0"; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/elm/packages/elm.nix b/nixpkgs/pkgs/development/compilers/elm/packages/elm.nix new file mode 100644 index 000000000000..4edd9bebbc6b --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/elm/packages/elm.nix @@ -0,0 +1,31 @@ +{ mkDerivation, ansi-terminal, ansi-wl-pprint, base, binary +, bytestring, containers, directory, edit-distance, fetchgit +, file-embed, filepath, ghc-prim, haskeline, HTTP, http-client +, http-client-tls, http-types, language-glsl, logict, mtl, network +, parsec, process, raw-strings-qq, scientific, SHA, snap-core +, snap-server, stdenv, template-haskell, text, time +, unordered-containers, utf8-string, vector, zip-archive +}: +mkDerivation { + pname = "elm"; + version = "0.19.0"; + src = fetchgit { + url = "https://github.com/elm/compiler"; + sha256 = "13jks6c6i80z71mjjfg46ri570g5ini0k3xw3857v6z66zcl56x4"; + rev = "d5cbc41aac23da463236bbc250933d037da4055a"; + fetchSubmodules = true; + }; + isLibrary = false; + isExecutable = true; + executableHaskellDepends = [ + ansi-terminal ansi-wl-pprint base binary bytestring containers + directory edit-distance file-embed filepath ghc-prim haskeline HTTP + http-client http-client-tls http-types language-glsl logict mtl + network parsec process raw-strings-qq scientific SHA snap-core + snap-server template-haskell text time unordered-containers + utf8-string vector zip-archive + ]; + homepage = "https://elm-lang.org"; + description = "The `elm` command line interface"; + license = stdenv.lib.licenses.bsd3; +} diff --git a/nixpkgs/pkgs/development/compilers/elm/packages/indents.nix b/nixpkgs/pkgs/development/compilers/elm/packages/indents.nix new file mode 100644 index 000000000000..6bf7fa7890e8 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/elm/packages/indents.nix @@ -0,0 +1,11 @@ +{ mkDerivation, base, concatenative, mtl, parsec, stdenv }: +mkDerivation { + pname = "indents"; + version = "0.3.3"; + sha256 = "b61f51ac894609cb5571cc3ded12db5de97185a8de236c69ec24c87457109f9a"; + libraryHaskellDepends = [ base concatenative mtl parsec ]; + doCheck = false; + homepage = "http://patch-tag.com/r/salazar/indents"; + description = "indentation sensitive parser-combinators for parsec"; + license = stdenv.lib.licenses.bsd3; +} diff --git a/nixpkgs/pkgs/development/compilers/elm/update.sh b/nixpkgs/pkgs/development/compilers/elm/update.sh new file mode 100755 index 000000000000..920b95e5ad95 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/elm/update.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env nix-shell +#!nix-shell -p cabal2nix elm2nix -i bash ../../.. + +cabal2nix https://github.com/elm/compiler --revision d5cbc41aac23da463236bbc250933d037da4055a > packages/elm.nix +elm2nix snapshot > versions.dat +pushd "$(nix-build -A elmPackages.elm.src --no-out-link ../../../..)/ui/browser" + elm2nix convert > $OLDPWD/packages/elm-srcs.nix +popd diff --git a/nixpkgs/pkgs/development/compilers/elm/versions.dat b/nixpkgs/pkgs/development/compilers/elm/versions.dat new file mode 100644 index 000000000000..9dcfd8a2808f --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/elm/versions.dat Binary files differdiff --git a/nixpkgs/pkgs/development/compilers/emscripten/default.nix b/nixpkgs/pkgs/development/compilers/emscripten/default.nix new file mode 100644 index 000000000000..d0af770a2a49 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/emscripten/default.nix @@ -0,0 +1,70 @@ +{ emscriptenVersion, stdenv, fetchFromGitHub, emscriptenfastcomp, python, nodejs, closurecompiler +, jre, binaryen, enableWasm ? true , cmake +}: + +let + rev = emscriptenVersion; + appdir = "share/emscripten"; + binaryenVersioned = binaryen.override { emscriptenRev = rev; }; +in + +stdenv.mkDerivation { + name = "emscripten-${rev}"; + + src = fetchFromGitHub { + owner = "emscripten-core"; + repo = "emscripten"; + sha256 = "1j3f0hpy05qskaiyv75l7wv4n0nzxhrh9b296zchx3f6f9h2rghq"; + inherit rev; + }; + + buildInputs = [ nodejs cmake python ]; + + buildCommand = '' + mkdir -p $out/${appdir} + cp -r $src/* $out/${appdir} + chmod -R +w $out/${appdir} + grep -rl '^#!/usr.*python' $out/${appdir} | xargs sed -i -s 's@^#!/usr.*python.*@#!${python}/bin/python@' + sed -i -e "s,EM_CONFIG = '~/.emscripten',EM_CONFIG = '$out/${appdir}/config'," $out/${appdir}/tools/shared.py + sed -i -e 's,^.*did not see a source tree above the LLVM.*$, return True,' $out/${appdir}/tools/shared.py + sed -i -e 's,def check_sanity(force=False):,def check_sanity(force=False):\n return,' $out/${appdir}/tools/shared.py + # fixes cmake support + sed -i -e "s/print \('emcc (Emscript.*\)/sys.stderr.write(\1); sys.stderr.flush()/g" $out/${appdir}/emcc.py + mkdir $out/bin + ln -s $out/${appdir}/{em++,em-config,emar,embuilder.py,emcc,emcmake,emconfigure,emlink.py,emmake,emranlib,emrun,emscons} $out/bin + + echo "EMSCRIPTEN_ROOT = '$out/${appdir}'" > $out/${appdir}/config + echo "LLVM_ROOT = '${emscriptenfastcomp}/bin'" >> $out/${appdir}/config + echo "PYTHON = '${python}/bin/python'" >> $out/${appdir}/config + echo "NODE_JS = '${nodejs}/bin/node'" >> $out/${appdir}/config + echo "JS_ENGINES = [NODE_JS]" >> $out/${appdir}/config + echo "COMPILER_ENGINE = NODE_JS" >> $out/${appdir}/config + echo "CLOSURE_COMPILER = '${closurecompiler}/share/java/closure-compiler-v${closurecompiler.version}.jar'" >> $out/${appdir}/config + echo "JAVA = '${jre}/bin/java'" >> $out/${appdir}/config + # to make the test(s) below work + echo "SPIDERMONKEY_ENGINE = []" >> $out/${appdir}/config + '' + + stdenv.lib.optionalString enableWasm '' + echo "BINARYEN_ROOT = '${binaryenVersioned}'" >> $out/share/emscripten/config + '' + + + '' + echo "--------------- running test -----------------" + # quick hack to get the test working + HOME=$TMPDIR + cp $out/${appdir}/config $HOME/.emscripten + export PATH=$PATH:$out/bin + + #export EMCC_DEBUG=2 + ${python}/bin/python $src/tests/runner.py test_hello_world + echo "--------------- /running test -----------------" + ''; + + meta = with stdenv.lib; { + homepage = https://github.com/emscripten-core/emscripten; + description = "An LLVM-to-JavaScript Compiler"; + platforms = platforms.all; + maintainers = with maintainers; [ qknight matthewbauer ]; + license = licenses.ncsa; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/emscripten/fastcomp/default.nix b/nixpkgs/pkgs/development/compilers/emscripten/fastcomp/default.nix new file mode 100644 index 000000000000..57496d288605 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/emscripten/fastcomp/default.nix @@ -0,0 +1,28 @@ +{ newScope, stdenv, binutils, wrapCCWith, symlinkJoin }: +let + callPackage = newScope (self // {inherit stdenv;}); + + self = { + emscriptenfastcomp-unwrapped = callPackage ./emscripten-fastcomp.nix {}; + emscriptenfastcomp-wrapped = wrapCCWith { + cc = self.emscriptenfastcomp-unwrapped; + # Never want Apple's cctools for WASM target + bintools = binutils; + libc = stdenv.cc.libc; + extraBuildCommands = '' + # hardening flags break WASM support + cat > $out/nix-support/add-hardening.sh + ''; + }; + emscriptenfastcomp = symlinkJoin { + name = "emscriptenfastcomp-${stdenv.lib.getVersion self.emscriptenfastcomp-unwrapped}"; + paths = [ self.emscriptenfastcomp-wrapped self.emscriptenfastcomp-unwrapped ]; + preferLocalBuild = false; + allowSubstitutes = true; + postBuild = '' + # replace unwrapped clang-3.9 binary by wrapper + ln -sf $out/bin/clang $out/bin/clang-[0-9]* + ''; + }; + }; +in self diff --git a/nixpkgs/pkgs/development/compilers/emscripten/fastcomp/emscripten-fastcomp.nix b/nixpkgs/pkgs/development/compilers/emscripten/fastcomp/emscripten-fastcomp.nix new file mode 100644 index 000000000000..91a42f53d282 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/emscripten/fastcomp/emscripten-fastcomp.nix @@ -0,0 +1,55 @@ +{ emscriptenVersion, stdenv, fetchFromGitHub, cmake, python, gtest, ... }: + +let + rev = emscriptenVersion; + gcc = if stdenv.cc.isGNU then stdenv.cc.cc else stdenv.cc.cc.gcc; +in +stdenv.mkDerivation rec { + name = "emscripten-fastcomp-${rev}"; + + src = fetchFromGitHub { + owner = "emscripten-core"; + repo = "emscripten-fastcomp"; + sha256 = "0bd0l5k2fa4k0nax2cpxi003pqffqivx4z4m2j5xdha1a12sid8i"; + inherit rev; + }; + + srcFL = fetchFromGitHub { + owner = "emscripten-core"; + repo = "emscripten-fastcomp-clang"; + sha256 = "1iw2qplhp489qzw0rma73sab7asnm27g4m95sr36c6kq9cq6agri"; + inherit rev; + }; + + nativeBuildInputs = [ cmake python gtest ]; + preConfigure = '' + cp -Lr ${srcFL} tools/clang + chmod +w -R tools/clang + ''; + cmakeFlags = [ + "-DCMAKE_BUILD_TYPE=Release" + "-DLLVM_TARGETS_TO_BUILD='X86;JSBackend'" + "-DLLVM_INCLUDE_EXAMPLES=OFF" + "-DLLVM_INCLUDE_TESTS=ON" + #"-DLLVM_CONFIG=${llvm}/bin/llvm-config" + "-DLLVM_BUILD_TESTS=ON" + "-DCLANG_INCLUDE_TESTS=ON" + ] ++ (stdenv.lib.optional stdenv.isLinux + # necessary for clang to find crtend.o + "-DGCC_INSTALL_PREFIX=${gcc}" + ); + enableParallelBuilding = true; + + passthru = { + isClang = true; + inherit gcc; + }; + + meta = with stdenv.lib; { + homepage = https://github.com/emscripten-core/emscripten-fastcomp; + description = "Emscripten LLVM"; + platforms = platforms.all; + maintainers = with maintainers; [ qknight matthewbauer ]; + license = stdenv.lib.licenses.ncsa; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/eql/default.nix b/nixpkgs/pkgs/development/compilers/eql/default.nix new file mode 100644 index 000000000000..1128fbe64ec3 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/eql/default.nix @@ -0,0 +1,60 @@ +{ stdenv, fetchgit, qt4, ecl, xorgserver, xkbcomp, xkeyboard_config }: + +stdenv.mkDerivation rec { + version = src.rev; + name = "eql-git-${version}"; + src = fetchgit { + rev = "9097bf98446ee33c07bb155d800395775ce0d9b2"; + url = "https://gitlab.com/eql/eql.git"; + sha256 = "17h23qr7fyr9hvjgiq0yhacmjs43x06vh8978aq42ymcgipxdcww"; + }; + + buildInputs = [ ecl qt4 xorgserver xkbcomp xkeyboard_config ]; + + NIX_CFLAGS_COMPILE = [ "-fPIC" ]; + + postPatch = '' + sed -re 's@[(]in-home "gui/.command-history"[)]@(concatenate '"'"'string (ext:getenv "HOME") "/.eql-gui-command-history")@' -i gui/gui.lisp + ''; + + buildPhase = '' + cd src + ecl -shell make-eql-lib.lisp + qmake eql_lib.pro + make + cd .. + + cd src + qmake eql_exe.pro + make + cd .. + cd src + ''; + + installPhase = '' + cd .. + mkdir -p $out/bin $out/lib/eql/ $out/include $out/include/gen $out/lib + cp -r . $out/lib/eql/build-dir + ln -s $out/lib/eql/build-dir/eql $out/bin + ln -s $out/lib/eql/build-dir/src/*.h $out/include + ln -s $out/lib/eql/build-dir/src/gen/*.h $out/include/gen + ln -s $out/lib/eql/build-dir/libeql*.so* $out/lib + ''; + + meta = with stdenv.lib; { + description = "Embedded Qt Lisp (ECL+Qt)"; + maintainers = with maintainers; [ raskin ]; + platforms = platforms.linux; + license = licenses.mit; + }; + + passthru = { + updateInfo = { + downloadPage = "http://password-taxi.at/EQL"; + method = "fetchgit"; + rev = src.rev; + url = src.url; + hash = src.sha256; + }; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/factor-lang/default.nix b/nixpkgs/pkgs/development/compilers/factor-lang/default.nix new file mode 100644 index 000000000000..65fb8a9c82dd --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/factor-lang/default.nix @@ -0,0 +1,107 @@ +{ stdenv, fetchurl, glib, glibc, git, + rlwrap, curl, pkgconfig, perl, makeWrapper, tzdata, ncurses, + pango, cairo, gtk2, gdk_pixbuf, gtkglext, + mesa, xorg, openssl, unzip }: + +let + inherit (stdenv.lib) optional; + +in stdenv.mkDerivation rec { + name = "factor-lang-${version}"; + version = "0.98"; + rev = "7999e72aecc3c5bc4019d43dc4697f49678cc3b4"; + + src = fetchurl { + url = http://downloads.factorcode.org/releases/0.98/factor-src-0.98.zip; + sha256 = "01ip9mbnar4sv60d2wcwfz62qaamdvbykxw3gbhzqa25z36vi3ri"; + }; + + patches = [ + ./staging-command-line-0.98-pre.patch + ./workdir-0.98-pre.patch + ./fuel-dir.patch + ]; + + buildInputs = with xorg; [ git rlwrap curl pkgconfig perl makeWrapper + libX11 pango cairo gtk2 gdk_pixbuf gtkglext + mesa libXmu libXt libICE libSM openssl unzip ]; + + buildPhase = '' + sed -ie '4i GIT_LABEL = heads/master-${rev}' GNUmakefile + make linux-x86-64 + # De-memoize xdg-* functions, otherwise they break the image. + sed -ie 's/^MEMO:/:/' basis/xdg/xdg.factor + ''; + + installPhase = '' + mkdir -p $out/bin $out/lib/factor + # The released image has library path info embedded, so we + # first have to recreate the boot image with Nix paths, and + # then use it to build the Nix release image. + cp boot.unix-x86.64.image $out/lib/factor/factor.image + + cp -r basis core extra $out/lib/factor + + # Factor uses XDG_CACHE_HOME for cache during compilation. + # We can't have that. So set it to $TMPDIR/.cache + export XDG_CACHE_HOME=$TMPDIR/.cache && mkdir -p $XDG_CACHE_HOME + + # There is no ld.so.cache in NixOS so we construct one + # out of known libraries. The side effect is that find-lib + # will work only on the known libraries. There does not seem + # to be a generic solution here. + find $(echo ${stdenv.lib.makeLibraryPath (with xorg; [ + glib libX11 pango cairo gtk2 gdk_pixbuf gtkglext + mesa libXmu libXt libICE libSM ])} | sed -e 's#:# #g') -name \*.so.\* > $TMPDIR/so.lst + + (echo $(cat $TMPDIR/so.lst | wc -l) "libs found in cache \`/etc/ld.so.cache'"; + for l in $(<$TMPDIR/so.lst); + do + echo " $(basename $l) (libc6,x86-64) => $l"; + done)> $out/lib/factor/ld.so.cache + + sed -ie "s#/sbin/ldconfig -p#cat $out/lib/factor/ld.so.cache#g" \ + $out/lib/factor/basis/alien/libraries/finder/linux/linux.factor + + sed -ie 's#/usr/share/zoneinfo/#${tzdata}/share/zoneinfo/#g' \ + $out/lib/factor/extra/tzinfo/tzinfo.factor + + sed -ie 's#/usr/share/terminfo#${ncurses.out}/share/terminfo#g' \ + $out/lib/factor/extra/terminfo/terminfo.factor + + cp ./factor $out/bin + wrapProgram $out/bin/factor --prefix LD_LIBRARY_PATH : \ + "${stdenv.lib.makeLibraryPath (with xorg; [ glib + libX11 pango cairo gtk2 gdk_pixbuf gtkglext + mesa libXmu libXt libICE libSM openssl])}" + + sed -ie 's#/bin/.factor-wrapped#/lib/factor/factor#g' $out/bin/factor + mv $out/bin/.factor-wrapped $out/lib/factor/factor + + # build full factor image from boot image + (cd $out/bin && ./factor -script -e='"unix-x86.64" USING: system bootstrap.image memory ; make-image save 0 exit' ) + + # make a new bootstrap image + (cd $out/bin && ./factor -script -e='"unix-x86.64" USING: system tools.deploy.backend ; make-boot-image 0 exit' ) + + # rebuild final full factor image to include all patched sources + (cd $out/lib/factor && ./factor -i=boot.unix-x86.64.image) + + # install fuel mode for emacs + mkdir -p $out/share/emacs/site-lisp + # update default paths in factor-listener.el for fuel mode + substituteInPlace misc/fuel/fuel-listener.el \ + --subst-var-by fuel_factor_root_dir $out/lib/factor \ + --subst-var-by fuel_listener_factor_binary $out/bin/factor + cp misc/fuel/*.el $out/share/emacs/site-lisp/ + ''; + + meta = with stdenv.lib; { + homepage = http://factorcode.org; + license = licenses.bsd2; + description = "A concatenative, stack-based programming language"; + + maintainers = [ maintainers.vrthra maintainers.spacefrogg ]; + platforms = [ "x86_64-linux" ]; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/factor-lang/fuel-dir.patch b/nixpkgs/pkgs/development/compilers/factor-lang/fuel-dir.patch new file mode 100644 index 000000000000..8f45b0372469 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/factor-lang/fuel-dir.patch @@ -0,0 +1,20 @@ +diff --git a/misc/fuel/fuel-listener.el b/misc/fuel/fuel-listener.el +index 2d1b182a75..bf2e573425 100644 +--- a/misc/fuel/fuel-listener.el ++++ b/misc/fuel/fuel-listener.el +@@ -30,13 +30,13 @@ + "Interacting with a Factor listener inside Emacs." + :group 'fuel) + +-(defcustom fuel-factor-root-dir nil ++(defcustom fuel-factor-root-dir "@fuel_factor_root_dir@" + "Full path to the factor root directory when starting a listener." + :type 'directory + :group 'fuel-listener) + + ;;; Is factor.com still valid on Windows...? +-(defcustom fuel-listener-factor-binary nil ++(defcustom fuel-listener-factor-binary "@fuel_listener_factor_binary@" + "Full path to the factor executable to use when starting a listener." + :type '(file :must-match t) + :group 'fuel-listener) diff --git a/nixpkgs/pkgs/development/compilers/factor-lang/staging-command-line-0.98-pre.patch b/nixpkgs/pkgs/development/compilers/factor-lang/staging-command-line-0.98-pre.patch new file mode 100644 index 000000000000..57fc657ddcf3 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/factor-lang/staging-command-line-0.98-pre.patch @@ -0,0 +1,13 @@ +diff --git a/basis/tools/deploy/backend/backend.factor b/basis/tools/deploy/backend/backend.factor +index ec86089dbe..b146168ec9 100644 +--- a/basis/tools/deploy/backend/backend.factor ++++ b/basis/tools/deploy/backend/backend.factor +@@ -69,7 +69,7 @@ ERROR: can't-deploy-library-file library ; + [ staging-image-name "-output-image=" prepend , ] + [ " " join "-include=" prepend , ] bi + ] [ +- input-image-name "-i=" prepend , ++ input-image-name resource-path "-i=" prepend , + "-resource-path=" "" resource-path append , + "-run=tools.deploy.restage" , + ] bi diff --git a/nixpkgs/pkgs/development/compilers/factor-lang/workdir-0.98-pre.patch b/nixpkgs/pkgs/development/compilers/factor-lang/workdir-0.98-pre.patch new file mode 100644 index 000000000000..f1498743dd67 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/factor-lang/workdir-0.98-pre.patch @@ -0,0 +1,24 @@ +diff --git a/core/io/pathnames/pathnames.factor b/core/io/pathnames/pathnames.factor +index 2d382e49d1..d4d9228d6c 100644 +--- a/core/io/pathnames/pathnames.factor ++++ b/core/io/pathnames/pathnames.factor +@@ -144,7 +144,10 @@ GENERIC: vocab-path ( path -- newpath ) + GENERIC: absolute-path ( path -- path' ) + + M: string absolute-path +- "resource:" ?head [ ++ "resource:work" ?head [ ++ trim-head-separators "/var/lib/factor" prepend-path ++ absolute-path ] ++ [ "resource:" ?head [ + trim-head-separators resource-path + absolute-path + ] [ +@@ -158,6 +161,7 @@ M: string absolute-path + ] [ + current-directory get prepend-path + ] if ] if ++ ] if + ] if ; + + M: object normalize-path ( path -- path' ) diff --git a/nixpkgs/pkgs/development/compilers/fasm/bin.nix b/nixpkgs/pkgs/development/compilers/fasm/bin.nix new file mode 100644 index 000000000000..7b23d4f6bcc1 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/fasm/bin.nix @@ -0,0 +1,24 @@ +{ stdenvNoCC, lib, fetchurl }: + +stdenvNoCC.mkDerivation rec { + name = "fasm-bin-${version}"; + + version = "1.73.11"; + + src = fetchurl { + url = "https://flatassembler.net/fasm-${version}.tgz"; + sha256 = "1zhbs72qc8bw5158zh6mvzznfamcx5a1bsmbmq9ci0d7wb58sxmg"; + }; + + installPhase = '' + install -D fasm${lib.optionalString stdenvNoCC.isx86_64 ".x64"} $out/bin/fasm + ''; + + meta = with lib; { + description = "x86(-64) macro assembler to binary, MZ, PE, COFF, and ELF"; + homepage = https://flatassembler.net/download.php; + license = licenses.bsd2; + maintainers = with maintainers; [ orivej ]; + platforms = [ "i686-linux" "x86_64-linux" ]; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/fasm/default.nix b/nixpkgs/pkgs/development/compilers/fasm/default.nix new file mode 100644 index 000000000000..47b90469234f --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/fasm/default.nix @@ -0,0 +1,28 @@ +{ stdenv, lib, fasm-bin, isx86_64 }: + +stdenv.mkDerivation rec { + inherit (fasm-bin) version src meta; + + name = "fasm-${version}"; + + nativeBuildInputs = [ fasm-bin ]; + + buildPhase = '' + fasm source/Linux${lib.optionalString isx86_64 "/x64"}/fasm.asm fasm + for tool in listing prepsrc symbols; do + fasm tools/libc/$tool.asm + cc -o tools/libc/fasm-$tool tools/libc/$tool.o + done + ''; + + outputs = [ "out" "doc" ]; + + installPhase = '' + install -Dt $out/bin fasm tools/libc/fasm-* + + docs=$doc/share/doc/fasm + mkdir -p $docs + cp -r examples/ *.txt tools/fas.txt $docs + cp tools/readme.txt $docs/tools.txt + ''; +} diff --git a/nixpkgs/pkgs/development/compilers/fpc/binary-builder.sh b/nixpkgs/pkgs/development/compilers/fpc/binary-builder.sh new file mode 100755 index 000000000000..4308c1ed211a --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/fpc/binary-builder.sh @@ -0,0 +1,14 @@ +source $stdenv/setup + +tar xf $src +cd */ +tarballdir=$(pwd) +for i in *.tar; do tar xvf $i; done +echo "Deploying binaries.." +mkdir $out +cd $out +for i in $tarballdir/*.gz; do tar xvf $i; done +echo 'Creating ppc* symlink..' +for i in $out/lib/fpc/*/ppc*; do + ln -fs $i $out/bin/$(basename $i) +done diff --git a/nixpkgs/pkgs/development/compilers/fpc/binary.nix b/nixpkgs/pkgs/development/compilers/fpc/binary.nix new file mode 100644 index 000000000000..cf13ab6f5954 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/fpc/binary.nix @@ -0,0 +1,24 @@ +{ stdenv, fetchurl }: + +stdenv.mkDerivation { + name = "fpc-2.6.0-binary"; + + src = + if stdenv.hostPlatform.system == "i686-linux" then + fetchurl { + url = "mirror://sourceforge/project/freepascal/Linux/2.6.0/fpc-2.6.0.i386-linux.tar"; + sha256 = "08yklvrfxvk59bxsd4rh1i6s3cjn0q06dzjs94h9fbq3n1qd5zdf"; + } + else if stdenv.hostPlatform.system == "x86_64-linux" then + fetchurl { + url = "mirror://sourceforge/project/freepascal/Linux/2.6.0/fpc-2.6.0.x86_64-linux.tar"; + sha256 = "0k9vi75k39y735fng4jc2vppdywp82j4qhzn7x4r6qjkad64d8lx"; + } + else throw "Not supported on ${stdenv.hostPlatform.system}."; + + builder = ./binary-builder.sh; + + meta = { + description = "Free Pascal Compiler from a binary distribution"; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/fpc/default.nix b/nixpkgs/pkgs/development/compilers/fpc/default.nix new file mode 100644 index 000000000000..b516019ffc9a --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/fpc/default.nix @@ -0,0 +1,46 @@ +{ stdenv, fetchurl, gawk }: + +let startFPC = import ./binary.nix { inherit stdenv fetchurl; }; in + +stdenv.mkDerivation rec { + version = "3.0.0"; + name = "fpc-${version}"; + + src = fetchurl { + url = "mirror://sourceforge/freepascal/fpcbuild-${version}.tar.gz"; + sha256 = "1v40bjp0kvsi8y0mndqvvhnsqjfssl2w6wpfww51j4rxblfkp4fm"; + }; + + buildInputs = [ startFPC gawk ]; + + preConfigure = + if stdenv.hostPlatform.system == "i686-linux" || stdenv.hostPlatform.system == "x86_64-linux" then '' + sed -e "s@'/lib/ld-linux[^']*'@'''@" -i fpcsrc/compiler/systems/t_linux.pas + sed -e "s@'/lib64/ld-linux[^']*'@'''@" -i fpcsrc/compiler/systems/t_linux.pas + '' else ""; + + makeFlags = "NOGDB=1 FPC=${startFPC}/bin/fpc"; + + installFlags = "INSTALL_PREFIX=\${out}"; + + postInstall = '' + for i in $out/lib/fpc/*/ppc*; do + ln -fs $i $out/bin/$(basename $i) + done + mkdir -p $out/lib/fpc/etc/ + $out/lib/fpc/*/samplecfg $out/lib/fpc/${version} $out/lib/fpc/etc/ + ''; + + passthru = { + bootstrap = startFPC; + }; + + meta = with stdenv.lib; { + description = "Free Pascal Compiler from a source distribution"; + homepage = https://www.freepascal.org; + maintainers = [ maintainers.raskin ]; + license = with licenses; [ gpl2 lgpl2 ]; + platforms = platforms.linux; + inherit version; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/fpc/default.upstream b/nixpkgs/pkgs/development/compilers/fpc/default.upstream new file mode 100644 index 000000000000..9f16c1b645cd --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/fpc/default.upstream @@ -0,0 +1,6 @@ +url https://sourceforge.net/projects/freepascal/files/Source/ +SF_version_dir +version_link 'fpcbuild-[0-9.]+[.]tar[.]gz/download$' +SF_redirect +version '.*-([0-9.]+)[.]tar[.]gz' '\1' +do_overwrite () { do_overwrite_just_version; } diff --git a/nixpkgs/pkgs/development/compilers/fpc/lazarus.nix b/nixpkgs/pkgs/development/compilers/fpc/lazarus.nix new file mode 100644 index 000000000000..74ca246deb09 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/fpc/lazarus.nix @@ -0,0 +1,48 @@ +{ stdenv, fetchurl, makeWrapper +, fpc, gtk2, glib, pango, atk, gdk_pixbuf +, libXi, xorgproto, libX11, libXext +}: +stdenv.mkDerivation rec { + name = "lazarus-${version}"; + version = "1.8.4"; + + src = fetchurl { + url = "mirror://sourceforge/lazarus/Lazarus%20Zip%20_%20GZip/Lazarus%20${version}/lazarus-${version}.tar.gz"; + sha256 = "1s8hdip973fc1lynklddl0mvg2jd2lzkfk8hzb8jlchs6jn0362s"; + }; + + buildInputs = [ + fpc gtk2 glib libXi xorgproto + libX11 libXext pango atk + stdenv.cc makeWrapper gdk_pixbuf + ]; + + makeFlags = [ + "FPC=fpc" + "PP=fpc" + "REQUIRE_PACKAGES+=tachartlazaruspkg" + "bigide" + ]; + + preBuild = '' + export makeFlags="$makeFlags LAZARUS_INSTALL_DIR=$out/share/lazarus/ INSTALL_PREFIX=$out/" + export NIX_LDFLAGS="$NIX_LDFLAGS -L${stdenv.cc.cc.lib}/lib -lXi -lX11 -lglib-2.0 -lgtk-x11-2.0 -lgdk-x11-2.0 -lc -lXext -lpango-1.0 -latk-1.0 -lgdk_pixbuf-2.0 -lcairo -lgcc_s" + export LCL_PLATFORM=gtk2 + mkdir -p $out/share "$out/lazarus" + tar xf ${fpc.src} --strip-components=1 -C $out/share -m + sed -e 's@/usr/fpcsrc@'"$out/share/fpcsrc@" -i ide/include/unix/lazbaseconf.inc + ''; + + postInstall = '' + wrapProgram $out/bin/startlazarus --prefix NIX_LDFLAGS ' ' "'$NIX_LDFLAGS'" \ + --prefix LCL_PLATFORM ' ' "'$LCL_PLATFORM'" + ''; + + meta = with stdenv.lib; { + description = "Lazarus graphical IDE for FreePascal language"; + homepage = http://www.lazarus.freepascal.org; + license = licenses.gpl2Plus ; + platforms = platforms.linux; + maintainers = [ maintainers.raskin ]; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/fsharp/default.nix b/nixpkgs/pkgs/development/compilers/fsharp/default.nix new file mode 100644 index 000000000000..2de487cc9c8b --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/fsharp/default.nix @@ -0,0 +1,48 @@ +# Temporarily avoid dependency on dotnetbuildhelpers to avoid rebuilding many times while working on it + +{ stdenv, fetchurl, mono, pkgconfig, dotnetbuildhelpers, autoconf, automake, which }: + +stdenv.mkDerivation rec { + name = "fsharp-${version}"; + version = "4.0.1.1"; + + src = fetchurl { + url = "https://github.com/fsharp/fsharp/archive/${version}.tar.gz"; + sha256 = "0mvmvwwpl4zq0yvgzdizww8l9azvlrc82xm32nz1fi1nw8x5qfqk"; + }; + + nativeBuildInputs = [ pkgconfig ]; + buildInputs = [ mono dotnetbuildhelpers autoconf automake which ]; + + configurePhase = '' + sed -i '988d' src/FSharpSource.targets + substituteInPlace ./autogen.sh --replace "/usr/bin/env sh" "${stdenv.shell}" + ./autogen.sh --prefix $out + ''; + + # Make sure the executables use the right mono binary, + # and set up some symlinks for backwards compatibility. + postInstall = '' + substituteInPlace $out/bin/fsharpc --replace " mono " " ${mono}/bin/mono " + substituteInPlace $out/bin/fsharpi --replace " mono " " ${mono}/bin/mono " + substituteInPlace $out/bin/fsharpiAnyCpu --replace " mono " " ${mono}/bin/mono " + ln -s $out/bin/fsharpc $out/bin/fsc + ln -s $out/bin/fsharpi $out/bin/fsi + for dll in "$out/lib/mono/4.5"/FSharp*.dll + do + create-pkg-config-for-dll.sh "$out/lib/pkgconfig" "$dll" + done + ''; + + # To fix this error when running: + # The file "/nix/store/path/whatever.exe" is an not a valid CIL image + dontStrip = true; + + meta = { + description = "A functional CLI language"; + homepage = https://fsharp.org/; + license = stdenv.lib.licenses.asl20; + maintainers = with stdenv.lib.maintainers; [ thoughtpolice raskin ]; + platforms = with stdenv.lib.platforms; unix; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/fsharp41/default.nix b/nixpkgs/pkgs/development/compilers/fsharp41/default.nix new file mode 100644 index 000000000000..e0094c73098f --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/fsharp41/default.nix @@ -0,0 +1,87 @@ +# Temporaririly avoid dependency on dotnetbuildhelpers to avoid rebuilding many times while working on it + +{ stdenv, fetchurl, pkgconfig, autoconf, automake, which, mono, dotnetbuildhelpers, dotnetPackages }: + +stdenv.mkDerivation rec { + name = "fsharp-${version}"; + version = "4.1.7"; + + src = fetchurl { + url = "https://github.com/fsharp/fsharp/archive/${version}.tar.gz"; + sha256 = "0rfkrk4mzi4w54mfqilvng9ar5swhmnwhsyjc54rx3fd0np3jiyl"; + }; + + nativeBuildInputs = [ pkgconfig ]; + buildInputs = [ + autoconf + automake + which + mono + dotnetbuildhelpers + dotnetPackages.FsCheck262 + dotnetPackages.FSharpCompilerTools + dotnetPackages.FSharpCore + dotnetPackages.FSharpData225 + dotnetPackages.FsLexYacc704 + dotnetPackages.MicrosoftDiaSymReader + dotnetPackages.MicrosoftDiaSymReaderPortablePdb + dotnetPackages.NUnit350 + dotnetPackages.SystemCollectionsImmutable131 + dotnetPackages.SystemReflectionMetadata + dotnetPackages.SystemValueTuple + ]; + + configurePhase = '' + substituteInPlace ./autogen.sh --replace "/usr/bin/env sh" "${stdenv.shell}" + ./autogen.sh --prefix $out + ''; + + preBuild = '' + substituteInPlace Makefile --replace "MONO_ENV_OPTIONS=\$(monoopts) mono .nuget/NuGet.exe restore packages.config -PackagesDirectory packages -ConfigFile .nuget/NuGet.Config" "true" + substituteInPlace src/fsharp/Fsc-proto/Fsc-proto.fsproj --replace "<FSharpCoreOptSigFiles Include=\"\$(FSharpCoreLkgPath)\\FSharp.Core.dll\" />" "" + substituteInPlace src/fsharp/Fsc-proto/Fsc-proto.fsproj --replace "<FSharpCoreOptSigFiles Include=\"\$(FSharpCoreLkgPath)\\FSharp.Core.optdata\" />" "" + substituteInPlace src/fsharp/Fsc-proto/Fsc-proto.fsproj --replace "<FSharpCoreOptSigFiles Include=\"\$(FSharpCoreLkgPath)\\FSharp.Core.sigdata\" />" "" + substituteInPlace src/fsharp/Fsc-proto/Fsc-proto.fsproj --replace "<FSharpCoreOptSigFiles Include=\"\$(FSharpCoreLkgPath)\\FSharp.Core.xml\" />" "" + + rm -rf packages + mkdir packages + + ln -s ${dotnetPackages.FsCheck262}/lib/dotnet/FsCheck packages/FsCheck.2.6.2 + ln -s ${dotnetPackages.FSharpCompilerTools}/lib/dotnet/FSharp.Compiler.Tools packages/FSharp.Compiler.Tools.4.1.4 + ln -s ${dotnetPackages.FSharpCore}/lib/dotnet/FSharp.Core/ packages/FSharp.Core.4.0.0.1 + ln -s ${dotnetPackages.FSharpData225}/lib/dotnet/FSharp.Data/ packages/FSharp.Data.2.2.5 + ln -s ${dotnetPackages.FsLexYacc704}/lib/dotnet/FsLexYacc/ packages/FsLexYacc.7.0.4 + ln -s ${dotnetPackages.MicrosoftDiaSymReader}/lib/dotnet/Microsoft.DiaSymReader/ packages/Microsoft.DiaSymReader.1.1.0 + ln -s ${dotnetPackages.MicrosoftDiaSymReaderPortablePdb}/lib/dotnet/Microsoft.DiaSymReader.PortablePdb/ packages/Microsoft.DiaSymReader.PortablePdb.1.2.0 + ln -s ${dotnetPackages.NUnit350}/lib/dotnet/NUnit/ packages/NUnit.3.5.0 + ln -s ${dotnetPackages.SystemCollectionsImmutable131}/lib/dotnet/System.Collections.Immutable/ packages/System.Collections.Immutable.1.3.1 + ln -s ${dotnetPackages.SystemReflectionMetadata}/lib/dotnet/System.Reflection.Metadata/ packages/System.Reflection.Metadata.1.4.2 + ln -s ${dotnetPackages.SystemValueTuple}/lib/dotnet/System.ValueTuple/ packages/System.ValueTuple.4.3.0 + ''; + + # Make sure the executables use the right mono binary, + # and set up some symlinks for backwards compatibility. + postInstall = '' + substituteInPlace $out/bin/fsharpc --replace " mono " " ${mono}/bin/mono " + substituteInPlace $out/bin/fsharpi --replace " mono " " ${mono}/bin/mono " + substituteInPlace $out/bin/fsharpiAnyCpu --replace " mono " " ${mono}/bin/mono " + ln -s $out/bin/fsharpc $out/bin/fsc + ln -s $out/bin/fsharpi $out/bin/fsi + for dll in "$out/lib/mono/fsharp"/FSharp*.dll + do + create-pkg-config-for-dll.sh "$out/lib/pkgconfig" "$dll" + done + ''; + + # To fix this error when running: + # The file "/nix/store/path/whatever.exe" is an not a valid CIL image + dontStrip = true; + + meta = { + description = "A functional CLI language"; + homepage = https://fsharp.org/; + license = stdenv.lib.licenses.asl20; + maintainers = with stdenv.lib.maintainers; [ thoughtpolice raskin ]; + platforms = with stdenv.lib.platforms; unix; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/fstar/default.nix b/nixpkgs/pkgs/development/compilers/fstar/default.nix new file mode 100644 index 000000000000..94836e84fd68 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/fstar/default.nix @@ -0,0 +1,45 @@ +{ stdenv, fetchFromGitHub, z3, ocamlPackages, makeWrapper }: + +stdenv.mkDerivation rec { + name = "fstar-${version}"; + version = "0.9.6.0"; + + src = fetchFromGitHub { + owner = "FStarLang"; + repo = "FStar"; + rev = "v${version}"; + sha256 = "0wix7l229afkn6c6sk4nwkfq0nznsiqdkds4ixi2yyf72immwmmb"; + }; + + nativeBuildInputs = [ makeWrapper ]; + + buildInputs = with ocamlPackages; [ + z3 ocaml findlib batteries menhir stdint + zarith camlp4 yojson pprint + ulex ocaml-migrate-parsetree process ppx_deriving ppx_deriving_yojson ocamlbuild + ]; + + makeFlags = [ "PREFIX=$(out)" ]; + + preBuild = '' + patchShebangs src/tools + patchShebangs bin + ''; + buildFlags = "-C src/ocaml-output"; + + preInstall = '' + mkdir -p $out/lib/ocaml/${ocamlPackages.ocaml.version}/site-lib/fstarlib + ''; + installFlags = "-C src/ocaml-output"; + postInstall = '' + wrapProgram $out/bin/fstar.exe --prefix PATH ":" "${z3}/bin" + ''; + + meta = with stdenv.lib; { + description = "ML-like functional programming language aimed at program verification"; + homepage = https://www.fstar-lang.org; + license = licenses.asl20; + platforms = with platforms; darwin ++ linux; + maintainers = with maintainers; [ gebner ]; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/gambit/bootstrap.nix b/nixpkgs/pkgs/development/compilers/gambit/bootstrap.nix new file mode 100644 index 000000000000..65cd67f527d4 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/gambit/bootstrap.nix @@ -0,0 +1,40 @@ +{ stdenv, fetchurl, autoconf, ... }: + +stdenv.mkDerivation rec { + name = "gambit-bootstrap-${version}"; + version = "4.9.3"; + + src = fetchurl { + url = "http://www.iro.umontreal.ca/~gambit/download/gambit/v4.9/source/gambit-v4_9_3.tgz"; + sha256 = "1p6172vhcrlpjgia6hsks1w4fl8rdyjf9xjh14wxfkv7dnx8a5hk"; + }; + + buildInputs = [ autoconf ]; + + configurePhase = '' + ./configure --prefix=$out + ''; + + buildPhase = '' + # Copy the (configured) sources now, not later, so we don't have to filter out + # all the intermediate build products. + mkdir -p $out ; cp -rp . $out/ + + # build the gsc-boot* compiler + make bootstrap + ''; + + installPhase = '' + cp -fa ./ $out/ + ''; + + forceShare = [ "info" ]; + + meta = { + description = "Optimizing Scheme to C compiler, bootstrap step"; + homepage = "http://gambitscheme.org"; + license = stdenv.lib.licenses.lgpl2; + platforms = stdenv.lib.platforms.unix; + maintainers = with stdenv.lib.maintainers; [ thoughtpolice raskin fare ]; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/gambit/build.nix b/nixpkgs/pkgs/development/compilers/gambit/build.nix new file mode 100644 index 000000000000..65d16c48a616 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/gambit/build.nix @@ -0,0 +1,70 @@ +{ stdenv, git, openssl, autoconf, pkgs, makeStaticLibraries, version, src }: + +stdenv.mkDerivation rec { + name = "gambit-${version}"; + inherit src; + + bootstrap = import ./bootstrap.nix ( pkgs ); + + # Use makeStaticLibraries to enable creation of statically linked binaries + buildInputs = [ git autoconf bootstrap openssl (makeStaticLibraries openssl)]; + + configurePhase = '' + options=( + --prefix=$out + --enable-single-host + --enable-c-opt=-O2 + --enable-gcc-opts + --enable-shared + --enable-absolute-shared-libs # Yes, NixOS will want an absolute path, and fix it. + --enable-poll + --enable-openssl + --enable-default-runtime-options="f8,-8,t8" # Default to UTF-8 for source and all I/O + #--enable-debug # Nope: enables plenty of good stuff, but also the costly console.log + + #--enable-multiple-versions # Nope, NixOS already does version multiplexing + #--enable-guide + #--enable-track-scheme + #--enable-high-res-timing + #--enable-max-processors=4 + #--enable-multiple-vms + #--enable-dynamic-tls + #--enable-multiple-vms + #--enable-multiple-threaded-vms ## when SMP branch is merged in + #--enable-thread-system=posix ## default when --enable-multiple-vms is on. + #--enable-profile + #--enable-coverage + #--enable-inline-jumps + #--enable-char-size=1" ; default is 4 + ) + ./configure ''${options[@]} + ''; + + buildPhase = '' + # Make bootstrap compiler, from release bootstrap + mkdir -p boot && + cp -rp ${bootstrap}/. boot/. && + chmod -R u+w boot && + cd boot && + cp ../gsc/makefile.in ../gsc/*.scm gsc && # */ + ./configure && + for i in lib gsi gsc ; do (cd $i ; make ) ; done && + cd .. && + cp boot/gsc/gsc gsc-boot && + + # Now use the bootstrap compiler to build the real thing! + make -j2 from-scratch + ''; + + doCheck = true; + + meta = { + description = "Optimizing Scheme to C compiler"; + homepage = "http://gambitscheme.org"; + license = stdenv.lib.licenses.lgpl2; + # NB regarding platforms: only actually tested on Linux, *should* work everywhere, + # but *might* need adaptation e.g. on macOS. + platforms = stdenv.lib.platforms.unix; + maintainers = with stdenv.lib.maintainers; [ thoughtpolice raskin fare ]; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/gambit/default.nix b/nixpkgs/pkgs/development/compilers/gambit/default.nix new file mode 100644 index 000000000000..303f6a30aadb --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/gambit/default.nix @@ -0,0 +1,10 @@ +{ stdenv, callPackage, fetchurl }: + +callPackage ./build.nix { + version = "4.9.3"; + src = fetchurl { + url = "http://www.iro.umontreal.ca/~gambit/download/gambit/v4.9/source/gambit-v4_9_3.tgz"; + sha256 = "1p6172vhcrlpjgia6hsks1w4fl8rdyjf9xjh14wxfkv7dnx8a5hk"; + }; + inherit stdenv; +} diff --git a/nixpkgs/pkgs/development/compilers/gambit/unstable.nix b/nixpkgs/pkgs/development/compilers/gambit/unstable.nix new file mode 100644 index 000000000000..5788f0df1da9 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/gambit/unstable.nix @@ -0,0 +1,13 @@ +{ stdenv, callPackage, fetchFromGitHub }: + +callPackage ./build.nix { + version = "unstable-2019-02-05"; +# git-version = "4.9.3"; + src = fetchFromGitHub { + owner = "feeley"; + repo = "gambit"; + rev = "baf7de67f6d800821412fe83a8d9e9e09faeb490"; + sha256 = "0ygm5y8fvq6dbb8mwq52v8rc8pdnwm4qpmxlnx5m9hzzbm1kzxxv"; + }; + inherit stdenv; +} diff --git a/nixpkgs/pkgs/development/compilers/gcc-arm-embedded/6/default.nix b/nixpkgs/pkgs/development/compilers/gcc-arm-embedded/6/default.nix new file mode 100644 index 000000000000..9e5a172eed84 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/gcc-arm-embedded/6/default.nix @@ -0,0 +1,47 @@ +{ stdenv, fetchurl, ncurses5, python27 }: + +stdenv.mkDerivation rec { + name = "gcc-arm-embedded-${version}"; + version = "6-2017-q2-update"; + subdir = "6-2017q2"; + + src = + if stdenv.isLinux then + fetchurl { + url = "https://developer.arm.com/-/media/Files/downloads/gnu-rm/${subdir}/gcc-arm-none-eabi-${version}-linux.tar.bz2"; + sha256="1hvwi02mx34al525sngnl0cm7dkmzxfkb1brq9kvbv28wcplp3p6"; + } + else if stdenv.isDarwin then + fetchurl { + url = "https://developer.arm.com/-/media/Files/downloads/gnu-rm/${subdir}/gcc-arm-none-eabi-${version}-mac.tar.bz2"; + sha256="0019ylpq4inq7p5gydpmc9m8ni72fz2csrjlqmgx1698998q0c3x"; + } + else throw "unsupported platform"; + + phases = [ "unpackPhase" "installPhase" "fixupPhase" ]; + + installPhase = '' + mkdir -p $out + cp -r * $out + ln -s $out/share/doc/gcc-arm-none-eabi/man $out/man + ''; + + dontPatchELF = true; + dontStrip = true; + + preFixup = '' + find $out -type f | while read f; do + patchelf $f > /dev/null 2>&1 || continue + patchelf --set-interpreter $(cat ${stdenv.cc}/nix-support/dynamic-linker) "$f" || true + patchelf --set-rpath ${stdenv.lib.makeLibraryPath [ "$out" stdenv.cc.cc ncurses5 python27 ]} "$f" || true + done + ''; + + meta = { + description = "Pre-built GNU toolchain from ARM Cortex-M & Cortex-R processors (Cortex-M0/M0+/M3/M4/M7, Cortex-R4/R5/R7/R8)"; + homepage = https://developer.arm.com/open-source/gnu-toolchain/gnu-rm; + license = with stdenv.lib.licenses; [ bsd2 gpl2 gpl3 lgpl21 lgpl3 mit ]; + maintainers = with stdenv.lib.maintainers; [ vinymeuh ]; + platforms = with stdenv.lib.platforms; linux ++ darwin; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/gcc-arm-embedded/7/default.nix b/nixpkgs/pkgs/development/compilers/gcc-arm-embedded/7/default.nix new file mode 100644 index 000000000000..80e042b5c2e9 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/gcc-arm-embedded/7/default.nix @@ -0,0 +1,49 @@ +{ stdenv, lib, fetchurl, ncurses5, python27 }: + +with lib; + +stdenv.mkDerivation rec { + name = "gcc-arm-embedded-${version}"; + version = "7-2018-q2-update"; + subdir = "7-2018q2"; + + src = + if stdenv.isLinux then + fetchurl { + url = "https://developer.arm.com/-/media/Files/downloads/gnu-rm/${subdir}/gcc-arm-none-eabi-${version}-linux.tar.bz2"; + sha256="0sgysp3hfpgrkcbfiwkp0a7ymqs02khfbrjabm52b5z61sgi05xv"; + } + else if stdenv.isDarwin then + fetchurl { + url = "https://developer.arm.com/-/media/Files/downloads/gnu-rm/${subdir}/gcc-arm-none-eabi-${version}-mac.tar.bz2"; + sha256="0nc7m0mpa39qyhfyydxkkyqm7spfc27xf6ygi2vd2aym4r9azi61"; + } + else throw "unsupported platform"; + + phases = [ "unpackPhase" "installPhase" "fixupPhase" ]; + + installPhase = '' + mkdir -p $out + cp -r * $out + ln -s $out/share/doc/gcc-arm-none-eabi/man $out/man + ''; + + dontPatchELF = true; + dontStrip = true; + + preFixup = '' + find $out -type f | while read f; do + patchelf $f > /dev/null 2>&1 || continue + patchelf --set-interpreter $(cat ${stdenv.cc}/nix-support/dynamic-linker) "$f" || true + patchelf --set-rpath ${stdenv.lib.makeLibraryPath [ "$out" stdenv.cc.cc ncurses5 python27 ]} "$f" || true + done + ''; + + meta = { + description = "Pre-built GNU toolchain from ARM Cortex-M & Cortex-R processors (Cortex-M0/M0+/M3/M4/M7, Cortex-R4/R5/R7/R8)"; + homepage = https://developer.arm.com/open-source/gnu-toolchain/gnu-rm; + license = with licenses; [ bsd2 gpl2 gpl3 lgpl21 lgpl3 mit ]; + maintainers = with maintainers; [ prusnak ]; + platforms = platforms.linux; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/gcc-arm-embedded/8/default.nix b/nixpkgs/pkgs/development/compilers/gcc-arm-embedded/8/default.nix new file mode 100644 index 000000000000..ee57dcc8c144 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/gcc-arm-embedded/8/default.nix @@ -0,0 +1,49 @@ +{ stdenv, lib, fetchurl, ncurses5, python27 }: + +with lib; + +stdenv.mkDerivation rec { + name = "gcc-arm-embedded-${version}"; + version = "8-2018-q4-major"; + subdir = "8-2018q4"; + + src = + if stdenv.isLinux then + fetchurl { + url = "https://developer.arm.com/-/media/Files/downloads/gnu-rm/${subdir}/gcc-arm-none-eabi-${version}-linux.tar.bz2"; + sha256="fb31fbdfe08406ece43eef5df623c0b2deb8b53e405e2c878300f7a1f303ee52"; + } + else if stdenv.isDarwin then + fetchurl { + url = "https://developer.arm.com/-/media/Files/downloads/gnu-rm/${subdir}/gcc-arm-none-eabi-${version}-mac.tar.bz2"; + sha256="0q44r57fizpk1z3ngcjwal3rxgsnzjyfknpgwlwzmw5r9p98wlhb"; + } + else throw "unsupported platform"; + + phases = [ "unpackPhase" "installPhase" "fixupPhase" ]; + + installPhase = '' + mkdir -p $out + cp -r * $out + ln -s $out/share/doc/gcc-arm-none-eabi/man $out/man + ''; + + dontPatchELF = true; + dontStrip = true; + + preFixup = '' + find $out -type f | while read f; do + patchelf $f > /dev/null 2>&1 || continue + patchelf --set-interpreter $(cat ${stdenv.cc}/nix-support/dynamic-linker) "$f" || true + patchelf --set-rpath ${stdenv.lib.makeLibraryPath [ "$out" stdenv.cc.cc ncurses5 python27 ]} "$f" || true + done + ''; + + meta = { + description = "Pre-built GNU toolchain from ARM Cortex-M & Cortex-R processors (Cortex-M0/M0+/M3/M4/M7, Cortex-R4/R5/R7/R8)"; + homepage = https://developer.arm.com/open-source/gnu-toolchain/gnu-rm; + license = with licenses; [ bsd2 gpl2 gpl3 lgpl21 lgpl3 mit ]; + maintainers = with maintainers; [ prusnak ]; + platforms = platforms.linux; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/gcc-arm-embedded/default.nix b/nixpkgs/pkgs/development/compilers/gcc-arm-embedded/default.nix new file mode 100644 index 000000000000..350eed2fedd0 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/gcc-arm-embedded/default.nix @@ -0,0 +1,51 @@ +{ stdenv, bzip2, patchelf, glibc, gcc, fetchurl, version, releaseType, sha256, ncurses +, dirName ? null, subdirName ? null }: +with stdenv.lib; +let + versionParts = splitString "-" version; # 4.7 2013q3 20130916 + majorVersion = elemAt versionParts 0; # 4.7 + yearQuarter = elemAt versionParts 1; # 2013q3 + underscoreVersion = replaceChars ["."] ["_"] version; # 4_7-2013q3-20130916 + yearQuarterParts = splitString "q" yearQuarter; # 2013 3 + year = elemAt yearQuarterParts 0; # 2013 + quarter = elemAt yearQuarterParts 1; # 3 + dirName_ = if dirName != null then dirName else majorVersion; + subdirName_ = if subdirName != null then subdirName + else "${majorVersion}-${year}-q${quarter}-${releaseType}"; # 4.7-2013-q3-update +in +stdenv.mkDerivation { + name = "gcc-arm-embedded-${version}"; + + src = fetchurl { + url = "https://launchpad.net/gcc-arm-embedded/${dirName_}/${subdirName_}/+download/gcc-arm-none-eabi-${underscoreVersion}-linux.tar.bz2"; + sha256 = sha256; + }; + + nativeBuildInputs = [ bzip2 patchelf ]; + + dontPatchELF = true; + + phases = "unpackPhase patchPhase installPhase"; + + installPhase = '' + mkdir -pv $out + cp -r ./* $out + ln -s $out/share/doc/gcc-arm-none-eabi/man $out/man + + for f in $(find $out); do + if [ -f "$f" ] && patchelf "$f" 2> /dev/null; then + patchelf --set-interpreter ${getLib glibc}/lib/ld-linux.so.2 \ + --set-rpath ${stdenv.lib.makeLibraryPath [ "$out" gcc ncurses ]} \ + "$f" || true + fi + done + ''; + + meta = with stdenv.lib; { + description = "Pre-built GNU toolchain from ARM Cortex-M & Cortex-R processors (Cortex-M0/M0+/M3/M4, Cortex-R4/R5/R7)"; + homepage = https://launchpad.net/gcc-arm-embedded; + license = with licenses; [ bsd2 gpl2 gpl3 lgpl21 lgpl3 mit ]; + maintainers = [ maintainers.rasendubi ]; + platforms = platforms.linux; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/gcc/4.8/default.nix b/nixpkgs/pkgs/development/compilers/gcc/4.8/default.nix new file mode 100644 index 000000000000..b9a24183cde2 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/gcc/4.8/default.nix @@ -0,0 +1,430 @@ +{ stdenv, targetPackages, fetchurl, fetchpatch, noSysDirs +, langC ? true, langCC ? true, langFortran ? false +, langObjC ? stdenv.targetPlatform.isDarwin +, langObjCpp ? stdenv.targetPlatform.isDarwin +, langJava ? false +, langGo ? false +, profiledCompiler ? false +, staticCompiler ? false +, enableShared ? true +, texinfo ? null +, perl ? null # optional, for texi2pod (then pod2man); required for Java +, gmp, mpfr, libmpc, gettext, which +, libelf # optional, for link-time optimizations (LTO) +, cloog ? null, isl ? null # optional, for the Graphite optimization framework. +, zlib ? null, boehmgc ? null +, zip ? null, unzip ? null, pkgconfig ? null +, gtk2 ? null, libart_lgpl ? null +, libX11 ? null, libXt ? null, libSM ? null, libICE ? null, libXtst ? null +, libXrender ? null, xorgproto ? null +, libXrandr ? null, libXi ? null +, x11Support ? langJava +, enableMultilib ? false +, enablePlugin ? stdenv.hostPlatform == stdenv.buildPlatform # Whether to support user-supplied plug-ins +, name ? "gcc" +, libcCross ? null +, crossStageStatic ? false +, # Strip kills static libs of other archs (hence no cross) + stripped ? stdenv.hostPlatform == stdenv.buildPlatform + && stdenv.targetPlatform == stdenv.hostPlatform +, gnused ? null +, buildPackages +}: + +assert langJava -> zip != null && unzip != null + && zlib != null && boehmgc != null + && perl != null; # for `--enable-java-home' + +# We enable the isl cloog backend. +assert cloog != null -> isl != null; + +# LTO needs libelf and zlib. +assert libelf != null -> zlib != null; + +# Make sure we get GNU sed. +assert stdenv.hostPlatform.isDarwin -> gnused != null; + +# The go frontend is written in c++ +assert langGo -> langCC; + +with stdenv.lib; +with builtins; + +let version = "4.8.5"; + + inherit (stdenv) buildPlatform hostPlatform targetPlatform; + + patches = [ ../parallel-bconfig.patch ] + ++ optional (targetPlatform != hostPlatform) ../libstdc++-target.patch + ++ optional noSysDirs ../no-sys-dirs.patch + ++ optional langFortran ../gfortran-driving.patch + ++ optional hostPlatform.isDarwin ../gfortran-darwin-NXConstStr.patch + ++ [(fetchpatch { + name = "libc_name_p.diff"; # needed to build with gcc6 + url = "https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff_plain;h=ec1cc0263f1"; + sha256 = "01jd7pdarh54ki498g6sz64ijl9a1l5f9v8q2696aaxalvh2vwzl"; + excludes = [ "gcc/cp/ChangeLog" ]; + })] + ++ [ # glibc-2.26 + ../struct-ucontext-4.8.patch + ../sigsegv-not-declared.patch + ../res_state-not-declared.patch + ]; + + javaEcj = fetchurl { + # The `$(top_srcdir)/ecj.jar' file is automatically picked up at + # `configure' time. + + # XXX: Eventually we might want to take it from upstream. + url = "ftp://sourceware.org/pub/java/ecj-4.3.jar"; + sha256 = "0jz7hvc0s6iydmhgh5h2m15yza7p2rlss2vkif30vm9y77m97qcx"; + }; + + # Antlr (optional) allows the Java `gjdoc' tool to be built. We want a + # binary distribution here to allow the whole chain to be bootstrapped. + javaAntlr = fetchurl { + url = https://www.antlr.org/download/antlr-4.4-complete.jar; + sha256 = "02lda2imivsvsis8rnzmbrbp8rh1kb8vmq4i67pqhkwz7lf8y6dz"; + }; + + xlibs = [ + libX11 libXt libSM libICE libXtst libXrender libXrandr libXi + xorgproto + ]; + + javaAwtGtk = langJava && x11Support; + + /* Cross-gcc settings (build == host != target) */ + crossMingw = targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt"; + crossDarwin = targetPlatform != hostPlatform && targetPlatform.libc == "libSystem"; + crossConfigureFlags = + # Ensure that -print-prog-name is able to find the correct programs. + [ "--with-as=${targetPackages.stdenv.cc.bintools}/bin/${targetPlatform.config}-as" + "--with-ld=${targetPackages.stdenv.cc.bintools}/bin/${targetPlatform.config}-ld" ] ++ + (if crossMingw && crossStageStatic then [ + "--with-headers=${libcCross}/include" + "--with-gcc" + "--with-gnu-as" + "--with-gnu-ld" + "--with-gnu-ld" + "--disable-shared" + "--disable-nls" + "--disable-debug" + "--enable-sjlj-exceptions" + "--enable-threads=win32" + "--disable-win32-registry" + "--disable-libmpx" # requires libc + ] else if crossStageStatic then [ + "--disable-libssp" + "--disable-nls" + "--without-headers" + "--disable-threads" + "--disable-libgomp" + "--disable-libquadmath" + "--disable-shared" + "--disable-libatomic" # requires libc + "--disable-decimal-float" # requires libc + "--disable-libmpx" # requires libc + ] else [ + (if crossDarwin then "--with-sysroot=${getLib libcCross}/share/sysroot" + else "--with-headers=${getDev libcCross}${libcCross.incdir or "/include"}") + "--enable-__cxa_atexit" + "--enable-long-long" + ] ++ + (if crossMingw then [ + "--enable-threads=win32" + "--enable-sjlj-exceptions" + "--enable-hash-synchronization" + "--enable-libssp" + "--disable-nls" + "--with-dwarf2" + # To keep ABI compatibility with upstream mingw-w64 + "--enable-fully-dynamic-string" + ] else + optionals (targetPlatform.libc == "uclibc" || targetPlatform.libc == "musl") [ + # In uclibc cases, libgomp needs an additional '-ldl' + # and as I don't know how to pass it, I disable libgomp. + "--disable-libgomp" + ] + ++ optional (targetPlatform.libc == "newlib") "--with-newlib" + ++ optional (targetPlatform.libc == "avrlibc") "--with-avrlibc" + ++ [ + "--enable-threads=${if targetPlatform.isUnix then "posix" + else if targetPlatform.isWindows then "win32" + else "single"}" + "--enable-nls" + "--disable-decimal-float" # No final libdecnumber (it may work only in 386) + ])); + stageNameAddon = if crossStageStatic then "-stage-static" else "-stage-final"; + crossNameAddon = if targetPlatform != hostPlatform then "${targetPlatform.config}${stageNameAddon}-" else ""; + + bootstrap = targetPlatform == hostPlatform; + +in + +# We need all these X libraries when building AWT with GTK+. +assert x11Support -> (filter (x: x == null) ([ gtk2 libart_lgpl ] ++ xlibs)) == []; + +stdenv.mkDerivation ({ + name = crossNameAddon + "${name}${if stripped then "" else "-debug"}-${version}"; + + builder = ../builder.sh; + + src = fetchurl { + url = "mirror://gnu/gcc/gcc-${version}/gcc-${version}.tar.bz2"; + sha256 = "08yggr18v373a1ihj0rg2vd6psnic42b518xcgp3r9k81xz1xyr2"; + }; + + inherit patches; + + hardeningDisable = [ "format" "pie" ]; + + outputs = [ "out" "lib" "man" "info" ]; + setOutputFlags = false; + NIX_NO_SELF_RPATH = true; + + libc_dev = stdenv.cc.libc_dev; + + postPatch = + if targetPlatform != hostPlatform || stdenv.cc.libc != null then + # On NixOS, use the right path to the dynamic linker instead of + # `/lib/ld*.so'. + let + libc = if libcCross != null then libcCross else stdenv.cc.libc; + in + '' echo "fixing the \`GLIBC_DYNAMIC_LINKER' and \`UCLIBC_DYNAMIC_LINKER' macros..." + for header in "gcc/config/"*-gnu.h "gcc/config/"*"/"*.h + do + grep -q LIBC_DYNAMIC_LINKER "$header" || continue + echo " fixing \`$header'..." + sed -i "$header" \ + -e 's|define[[:blank:]]*\([UCG]\+\)LIBC_DYNAMIC_LINKER\([0-9]*\)[[:blank:]]"\([^\"]\+\)"$|define \1LIBC_DYNAMIC_LINKER\2 "${libc.out}\3"|g' + done + '' + else null; + + inherit noSysDirs staticCompiler langJava crossStageStatic + libcCross crossMingw; + + depsBuildBuild = [ buildPackages.stdenv.cc ]; + nativeBuildInputs = [ texinfo which gettext ] + ++ (optional (perl != null) perl) + ++ (optional javaAwtGtk pkgconfig); + + # For building runtime libs + depsBuildTarget = + if hostPlatform == buildPlatform then [ + targetPackages.stdenv.cc.bintools # newly-built gcc will be used + ] else assert targetPlatform == hostPlatform; [ # build != host == target + stdenv.cc + ]; + + buildInputs = [ + gmp mpfr libmpc libelf + targetPackages.stdenv.cc.bintools # For linking code at run-time + ] ++ (optional (cloog != null) cloog) + ++ (optional (isl != null) isl) + ++ (optional (zlib != null) zlib) + ++ (optionals langJava [ boehmgc zip unzip ]) + ++ (optionals javaAwtGtk ([ gtk2 libart_lgpl ] ++ xlibs)) + # The builder relies on GNU sed (for instance, Darwin's `sed' fails with + # "-i may not be used with stdin"), and `stdenvNative' doesn't provide it. + ++ (optional hostPlatform.isDarwin gnused) + ; + + preConfigure = stdenv.lib.optionalString (hostPlatform.isSunOS && hostPlatform.is64bit) '' + export NIX_LDFLAGS=`echo $NIX_LDFLAGS | sed -e s~$prefix/lib~$prefix/lib/amd64~g` + export LDFLAGS_FOR_TARGET="-Wl,-rpath,$prefix/lib/amd64 $LDFLAGS_FOR_TARGET" + export CXXFLAGS_FOR_TARGET="-Wl,-rpath,$prefix/lib/amd64 $CXXFLAGS_FOR_TARGET" + export CFLAGS_FOR_TARGET="-Wl,-rpath,$prefix/lib/amd64 $CFLAGS_FOR_TARGET" + ''; + + dontDisableStatic = true; + + # TODO(@Ericson2314): Always pass "--target" and always prefix. + configurePlatforms = [ "build" "host" ] ++ stdenv.lib.optional (targetPlatform != hostPlatform) "target"; + + configureFlags = + # Basic dependencies + [ + "--with-gmp-include=${gmp.dev}/include" + "--with-gmp-lib=${gmp.out}/lib" + "--with-mpfr-include=${mpfr.dev}/include" + "--with-mpfr-lib=${mpfr.out}/lib" + "--with-mpc=${libmpc}" + ] ++ + optional (libelf != null) "--with-libelf=${libelf}" ++ + optional (!(crossMingw && crossStageStatic)) + "--with-native-system-header-dir=${getDev stdenv.cc.libc}/include" ++ + + # Basic configuration + [ + "--enable-lto" + "--disable-libstdcxx-pch" + "--without-included-gettext" + "--with-system-zlib" + "--enable-static" + "--enable-languages=${ + concatStrings (intersperse "," + ( optional langC "c" + ++ optional langCC "c++" + ++ optional langFortran "fortran" + ++ optional langJava "java" + ++ optional langGo "go" + ++ optional langObjC "objc" + ++ optional langObjCpp "obj-c++" + ++ optionals crossDarwin [ "objc" "obj-c++" ] + ) + ) + }" + ] ++ + + (if (enableMultilib || targetPlatform.isAvr) + then ["--enable-multilib" "--disable-libquadmath"] + else ["--disable-multilib"]) ++ + optional (!enableShared) "--disable-shared" ++ + (if enablePlugin + then ["--enable-plugin"] + else ["--disable-plugin"]) ++ + + # Optional features + optional (isl != null) "--with-isl=${isl}" ++ + optionals (cloog != null) [ + "--with-cloog=${cloog}" + "--disable-cloog-version-check" + "--enable-cloog-backend=isl" + ] ++ + + # Java options + optionals langJava [ + "--with-ecj-jar=${javaEcj}" + + # Follow Sun's layout for the convenience of IcedTea/OpenJDK. See + # <http://mail.openjdk.java.net/pipermail/distro-pkg-dev/2010-April/008888.html>. + "--enable-java-home" + "--with-java-home=\${prefix}/lib/jvm/jre" + ] ++ + optional javaAwtGtk "--enable-java-awt=gtk" ++ + optional (langJava && javaAntlr != null) "--with-antlr-jar=${javaAntlr}" ++ + + (import ../common/platform-flags.nix { inherit (stdenv) lib targetPlatform; }) ++ + optional (targetPlatform != hostPlatform) crossConfigureFlags ++ + optional (!bootstrap) "--disable-bootstrap" ++ + + # Platform-specific flags + optional (targetPlatform == hostPlatform && targetPlatform.isx86_32) "--with-arch=${stdenv.hostPlatform.parsed.cpu.name}" ++ + optionals hostPlatform.isSunOS [ + "--enable-long-long" "--enable-libssp" "--enable-threads=posix" "--disable-nls" "--enable-__cxa_atexit" + # On Illumos/Solaris GNU as is preferred + "--with-gnu-as" "--without-gnu-ld" + ] + ; + + targetConfig = if targetPlatform != hostPlatform then targetPlatform.config else null; + + buildFlags = optional + (bootstrap && hostPlatform == buildPlatform) + (if profiledCompiler then "profiledbootstrap" else "bootstrap"); + + dontStrip = !stripped; + + doCheck = false; # requires a lot of tools, causes a dependency cycle for stdenv + + installTargets = + if stripped + then "install-strip" + else "install"; + + # https://gcc.gnu.org/install/specific.html#x86-64-x-solaris210 + ${if hostPlatform.system == "x86_64-solaris" then "CC" else null} = "gcc -m64"; + + # Setting $CPATH and $LIBRARY_PATH to make sure both `gcc' and `xgcc' find the + # library headers and binaries, regarless of the language being compiled. + # + # Note: When building the Java AWT GTK+ peer, the build system doesn't honor + # `--with-gmp' et al., e.g., when building + # `libjava/classpath/native/jni/java-math/gnu_java_math_GMP.c', so we just add + # them to $CPATH and $LIBRARY_PATH in this case. + # + # Likewise, the LTO code doesn't find zlib. + # + # Cross-compiling, we need gcc not to read ./specs in order to build the g++ + # compiler (after the specs for the cross-gcc are created). Having + # LIBRARY_PATH= makes gcc read the specs from ., and the build breaks. + + CPATH = optionals (targetPlatform == hostPlatform) (makeSearchPathOutput "dev" "include" ([] + ++ optional (zlib != null) zlib + ++ optional langJava boehmgc + ++ optionals javaAwtGtk xlibs + ++ optionals javaAwtGtk [ gmp mpfr ] + )); + + LIBRARY_PATH = optionals (targetPlatform == hostPlatform) (makeLibraryPath ([] + ++ optional (zlib != null) zlib + ++ optional langJava boehmgc + ++ optionals javaAwtGtk xlibs + ++ optionals javaAwtGtk [ gmp mpfr ] + )); + + EXTRA_TARGET_FLAGS = optionals + (targetPlatform != hostPlatform && libcCross != null) + ([ + "-idirafter ${getDev libcCross}${libcCross.incdir or "/include"}" + ] ++ optionals (! crossStageStatic) [ + "-B${libcCross.out}${libcCross.libdir or "/lib"}" + ]); + + EXTRA_TARGET_LDFLAGS = optionals + (targetPlatform != hostPlatform && libcCross != null) + ([ + "-Wl,-L${libcCross.out}${libcCross.libdir or "/lib"}" + ] ++ (if crossStageStatic then [ + "-B${libcCross.out}${libcCross.libdir or "/lib"}" + ] else [ + "-Wl,-rpath,${libcCross.out}${libcCross.libdir or "/lib"}" + "-Wl,-rpath-link,${libcCross.out}${libcCross.libdir or "/lib"}" + ])); + + passthru = { + inherit langC langCC langObjC langObjCpp langFortran langGo version; + isGNU = true; + hardeningUnsupportedFlags = [ "stackprotector" ]; + }; + + enableParallelBuilding = true; + inherit enableMultilib; + + inherit (stdenv) is64bit; + + meta = { + homepage = https://gcc.gnu.org/; + license = stdenv.lib.licenses.gpl3Plus; # runtime support libraries are typically LGPLv3+ + description = "GNU Compiler Collection, version ${version}" + + (if stripped then "" else " (with debugging info)"); + + longDescription = '' + The GNU Compiler Collection includes compiler front ends for C, C++, + Objective-C, Fortran, OpenMP for C/C++/Fortran, Java, and Ada, as well + as libraries for these languages (libstdc++, libgcj, libgomp,...). + + GCC development is a part of the GNU Project, aiming to improve the + compiler used in the GNU system including the GNU/Linux variant. + ''; + + maintainers = with stdenv.lib.maintainers; [ peti ]; + + platforms = + stdenv.lib.platforms.linux ++ + stdenv.lib.platforms.freebsd ++ + stdenv.lib.platforms.illumos ++ + stdenv.lib.platforms.darwin; + }; +} + +// optionalAttrs (targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt" && crossStageStatic) { + makeFlags = [ "all-gcc" "all-target-libgcc" ]; + installTargets = "install-gcc install-target-libgcc"; +} + +// optionalAttrs (enableMultilib) { dontMoveLib64 = true; } +) diff --git a/nixpkgs/pkgs/development/compilers/gcc/4.9/default.nix b/nixpkgs/pkgs/development/compilers/gcc/4.9/default.nix new file mode 100644 index 000000000000..36ad5b46b791 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/gcc/4.9/default.nix @@ -0,0 +1,448 @@ +{ stdenv, targetPackages, fetchurl, fetchpatch, noSysDirs +, langC ? true, langCC ? true, langFortran ? false +, langObjC ? stdenv.targetPlatform.isDarwin +, langObjCpp ? stdenv.targetPlatform.isDarwin +, langJava ? false +, langGo ? false +, profiledCompiler ? false +, staticCompiler ? false +, enableShared ? true +, texinfo ? null +, perl ? null # optional, for texi2pod (then pod2man); required for Java +, gmp, mpfr, libmpc, gettext, which +, libelf # optional, for link-time optimizations (LTO) +, cloog ? null, isl ? null # optional, for the Graphite optimization framework. +, zlib ? null, boehmgc ? null +, zip ? null, unzip ? null, pkgconfig ? null +, gtk2 ? null, libart_lgpl ? null +, libX11 ? null, libXt ? null, libSM ? null, libICE ? null, libXtst ? null +, libXrender ? null, xorgproto ? null +, libXrandr ? null, libXi ? null +, x11Support ? langJava +, enableMultilib ? false +, enablePlugin ? stdenv.hostPlatform == stdenv.buildPlatform # Whether to support user-supplied plug-ins +, name ? "gcc" +, libcCross ? null +, crossStageStatic ? false +, # Strip kills static libs of other archs (hence no cross) + stripped ? stdenv.hostPlatform == stdenv.buildPlatform + && stdenv.targetPlatform == stdenv.hostPlatform +, gnused ? null +, buildPackages +}: + +assert langJava -> zip != null && unzip != null + && zlib != null && boehmgc != null + && perl != null; # for `--enable-java-home' + +# We enable the isl cloog backend. +assert cloog != null -> isl != null; + +# LTO needs libelf and zlib. +assert libelf != null -> zlib != null; + +# Make sure we get GNU sed. +assert stdenv.hostPlatform.isDarwin -> gnused != null; + +# The go frontend is written in c++ +assert langGo -> langCC; + +with stdenv.lib; +with builtins; + +let version = "4.9.4"; + + inherit (stdenv) buildPlatform hostPlatform targetPlatform; + + patches = + [ ../use-source-date-epoch.patch ../parallel-bconfig.patch ./parallel-strsignal.patch ] + ++ optional (targetPlatform != hostPlatform) ../libstdc++-target.patch + ++ optional noSysDirs ../no-sys-dirs.patch + ++ optional langFortran ../gfortran-driving.patch + ++ [ ../struct-ucontext.patch ../struct-sigaltstack-4.9.patch ] # glibc-2.26 + # Retpoline patches pulled from the branch hjl/indirect/gcc-4_9-branch (by H.J. Lu, the author of GCC upstream retpoline commits) + ++ builtins.map ({commit, sha256}: fetchpatch {url = "https://github.com/hjl-tools/gcc/commit/${commit}.patch"; inherit sha256;}) + [{ commit = "e623d21608e96ecd6b65f0d06312117d20488a38"; sha256 = "1ix8i4d2r3ygbv7npmsdj790rhxqrnfwcqzv48b090r9c3ij8ay3"; } + { commit = "2015a09e332309f12de1dadfe179afa6a29368b8"; sha256 = "0xcfs0cbb63llj2gbcdrvxim79ax4k4aswn0a3yjavxsj71s1n91"; } + { commit = "6b11591f4494f705e8746e7d58b7f423191f4e92"; sha256 = "0aydyhsm2ig0khgbp27am7vq7liyqrq6kfhfi2ki0ij0ab1hfbga"; } + { commit = "203c7d9c3e9cb0f88816b481ef8e7e87b3ecc373"; sha256 = "0wqn16y7wy5kg8ngfcni5qdwfphl01axczibbk49bxclwnzvldqa"; } + { commit = "f039c6f284b2c9ce97c8353d6034978795c4872e"; sha256 = "13fkgdb17lpyxfksz1zanxhgpsm0jrss9w61nbl7an4im22hz7ci"; } + { commit = "ed42606bdab1c5d9e5ad828cd6fe1a0557f193b7"; sha256 = "0gdnn8v3p03imj3qga2mzdhpgbmjcklkxdl97jvz5xia2ikzknxm"; } + { commit = "5278e062ef292fd2fbf987d25389785f4c5c0f99"; sha256 = "0j81x758wf8v7j4rx5wc1cy7yhkvhlhv3wmnarwakxiwsspq0vrs"; } + { commit = "76f1ffbbb6cd9f6ecde6c82cd16e20a27242e890"; sha256 = "1py56y6gp7fjf4f8bbsfwh5bs1gnmlqda1ycsmnwlzfm0cshdp0c"; } + { commit = "4ca48b2b688b135c0390f54ea9077ef10aedd52c"; sha256 = "15r019pzr3k0lpgyvdc92c8fayw8b5lrzncna4bqmamcsdz7vsaw"; } + { commit = "98c7bf9ddc80db965d69d61521b1c7a1cec32d9a"; sha256 = "1d7pfdv1q23nf0wadw7jbp6d6r7pnzjpbyxgbdfv7j1vr9l1bp60"; } + { commit = "3dc76b53ad896494ca62550a7a752fecbca3f7a2"; sha256 = "0jvdzfpvfdmklfcjwqblwq1i22iqis7ljpvm7adra5d7zf2xk7xz"; } + { commit = "1e961ed49b18e176c7457f53df2433421387c23b"; sha256 = "04dnqqs4qsvz4g8cq6db5id41kzys7hzhcaycwmc9rpqygs2ajwz"; } + { commit = "e137c72d099f9b3b47f4cc718aa11eab14df1a9c"; sha256 = "1ms0dmz74yf6kwgjfs4d2fhj8y6mcp2n184r3jk44wx2xc24vgb2"; }]; + + javaEcj = fetchurl { + # The `$(top_srcdir)/ecj.jar' file is automatically picked up at + # `configure' time. + + # XXX: Eventually we might want to take it from upstream. + url = "ftp://sourceware.org/pub/java/ecj-4.3.jar"; + sha256 = "0jz7hvc0s6iydmhgh5h2m15yza7p2rlss2vkif30vm9y77m97qcx"; + }; + + # Antlr (optional) allows the Java `gjdoc' tool to be built. We want a + # binary distribution here to allow the whole chain to be bootstrapped. + javaAntlr = fetchurl { + url = https://www.antlr.org/download/antlr-4.4-complete.jar; + sha256 = "02lda2imivsvsis8rnzmbrbp8rh1kb8vmq4i67pqhkwz7lf8y6dz"; + }; + + xlibs = [ + libX11 libXt libSM libICE libXtst libXrender libXrandr libXi + xorgproto + ]; + + javaAwtGtk = langJava && x11Support; + + /* Cross-gcc settings (build == host != target) */ + crossMingw = targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt"; + crossDarwin = targetPlatform != hostPlatform && targetPlatform.libc == "libSystem"; + crossConfigureFlags = + # Ensure that -print-prog-name is able to find the correct programs. + [ "--with-as=${targetPackages.stdenv.cc.bintools}/bin/${targetPlatform.config}-as" + "--with-ld=${targetPackages.stdenv.cc.bintools}/bin/${targetPlatform.config}-ld" ] ++ + (if crossMingw && crossStageStatic then [ + "--with-headers=${libcCross}/include" + "--with-gcc" + "--with-gnu-as" + "--with-gnu-ld" + "--with-gnu-ld" + "--disable-shared" + "--disable-nls" + "--disable-debug" + "--enable-sjlj-exceptions" + "--enable-threads=win32" + "--disable-win32-registry" + "--disable-libmpx" # requires libc + ] else if crossStageStatic then [ + "--disable-libssp" + "--disable-nls" + "--without-headers" + "--disable-threads" + "--disable-libgomp" + "--disable-libquadmath" + "--disable-shared" + "--disable-libatomic" # requires libc + "--disable-decimal-float" # requires libc + "--disable-libmpx" # requires libc + ] else [ + (if crossDarwin then "--with-sysroot=${getLib libcCross}/share/sysroot" + else "--with-headers=${getDev libcCross}${libcCross.incdir or "/include"}") + "--enable-__cxa_atexit" + "--enable-long-long" + ] ++ + (if crossMingw then [ + "--enable-threads=win32" + "--enable-sjlj-exceptions" + "--enable-hash-synchronization" + "--enable-libssp" + "--disable-nls" + "--with-dwarf2" + # To keep ABI compatibility with upstream mingw-w64 + "--enable-fully-dynamic-string" + ] else + optionals (targetPlatform.libc == "uclibc" || targetPlatform.libc == "musl") [ + # libsanitizer requires netrom/netrom.h which is not + # available in uclibc. + "--disable-libsanitizer" + # In uclibc cases, libgomp needs an additional '-ldl' + # and as I don't know how to pass it, I disable libgomp. + "--disable-libgomp" + ] + ++ optional (targetPlatform.libc == "newlib") "--with-newlib" + ++ optional (targetPlatform.libc == "avrlibc") "--with-avrlibc" + ++ [ + "--enable-threads=${if targetPlatform.isUnix then "posix" + else if targetPlatform.isWindows then "win32" + else "single"}" + "--enable-nls" + "--disable-decimal-float" # No final libdecnumber (it may work only in 386) + ])); + stageNameAddon = if crossStageStatic then "-stage-static" else "-stage-final"; + crossNameAddon = if targetPlatform != hostPlatform then "${targetPlatform.config}${stageNameAddon}-" else ""; + + bootstrap = targetPlatform == hostPlatform; + +in + +# We need all these X libraries when building AWT with GTK+. +assert x11Support -> (filter (x: x == null) ([ gtk2 libart_lgpl ] ++ xlibs)) == []; + +stdenv.mkDerivation ({ + name = crossNameAddon + "${name}${if stripped then "" else "-debug"}-${version}"; + + builder = ../builder.sh; + + src = fetchurl { + url = "mirror://gnu/gcc/gcc-${version}/gcc-${version}.tar.bz2"; + sha256 = "14l06m7nvcvb0igkbip58x59w3nq6315k6jcz3wr9ch1rn9d44bc"; + }; + + inherit patches; + + hardeningDisable = [ "format" "pie" ]; + + outputs = if langJava || langGo then ["out" "man" "info"] + else [ "out" "lib" "man" "info" ]; + setOutputFlags = false; + NIX_NO_SELF_RPATH = true; + + libc_dev = stdenv.cc.libc_dev; + + postPatch = + if targetPlatform != hostPlatform || stdenv.cc.libc != null then + # On NixOS, use the right path to the dynamic linker instead of + # `/lib/ld*.so'. + let + libc = if libcCross != null then libcCross else stdenv.cc.libc; + in + '' echo "fixing the \`GLIBC_DYNAMIC_LINKER' and \`UCLIBC_DYNAMIC_LINKER' macros..." + for header in "gcc/config/"*-gnu.h "gcc/config/"*"/"*.h + do + grep -q LIBC_DYNAMIC_LINKER "$header" || continue + echo " fixing \`$header'..." + sed -i "$header" \ + -e 's|define[[:blank:]]*\([UCG]\+\)LIBC_DYNAMIC_LINKER\([0-9]*\)[[:blank:]]"\([^\"]\+\)"$|define \1LIBC_DYNAMIC_LINKER\2 "${libc.out}\3"|g' + done + '' + else null; + + inherit noSysDirs staticCompiler langJava crossStageStatic + libcCross crossMingw; + + depsBuildBuild = [ buildPackages.stdenv.cc ]; + nativeBuildInputs = [ texinfo which gettext ] + ++ (optional (perl != null) perl) + ++ (optional javaAwtGtk pkgconfig); + + # For building runtime libs + depsBuildTarget = + if hostPlatform == buildPlatform then [ + targetPackages.stdenv.cc.bintools # newly-built gcc will be used + ] else assert targetPlatform == hostPlatform; [ # build != host == target + stdenv.cc + ]; + + buildInputs = [ + gmp mpfr libmpc libelf + targetPackages.stdenv.cc.bintools # For linking code at run-time + ] ++ (optional (cloog != null) cloog) + ++ (optional (isl != null) isl) + ++ (optional (zlib != null) zlib) + ++ (optionals langJava [ boehmgc zip unzip ]) + ++ (optionals javaAwtGtk ([ gtk2 libart_lgpl ] ++ xlibs)) + # The builder relies on GNU sed (for instance, Darwin's `sed' fails with + # "-i may not be used with stdin"), and `stdenvNative' doesn't provide it. + ++ (optional hostPlatform.isDarwin gnused) + ; + + preConfigure = stdenv.lib.optionalString (hostPlatform.isSunOS && hostPlatform.is64bit) '' + sed -i -e "s/-lrt//g" libstdc++-v3/configure + export NIX_LDFLAGS=`echo $NIX_LDFLAGS | sed -e s~$prefix/lib~$prefix/lib/amd64~g` + export LDFLAGS_FOR_TARGET="-Wl,-rpath,$prefix/lib/amd64 $LDFLAGS_FOR_TARGET" + export CXXFLAGS_FOR_TARGET="-Wl,-rpath,$prefix/lib/amd64 $CXXFLAGS_FOR_TARGET" + export CFLAGS_FOR_TARGET="-Wl,-rpath,$prefix/lib/amd64 $CFLAGS_FOR_TARGET" + '' + + stdenv.lib.optionalString (langJava || langGo) '' + export lib=$out; + ''; + + dontDisableStatic = true; + + # TODO(@Ericson2314): Always pass "--target" and always prefix. + configurePlatforms = [ "build" "host" ] ++ stdenv.lib.optional (targetPlatform != hostPlatform) "target"; + + configureFlags = + # Basic dependencies + [ + "--with-gmp-include=${gmp.dev}/include" + "--with-gmp-lib=${gmp.out}/lib" + "--with-mpfr-include=${mpfr.dev}/include" + "--with-mpfr-lib=${mpfr.out}/lib" + "--with-mpc=${libmpc}" + ] ++ + optional (libelf != null) "--with-libelf=${libelf}" ++ + optional (!(crossMingw && crossStageStatic)) + "--with-native-system-header-dir=${getDev stdenv.cc.libc}/include" ++ + + # Basic configuration + [ + "--enable-lto" + "--disable-libstdcxx-pch" + "--without-included-gettext" + "--with-system-zlib" + "--enable-static" + "--enable-languages=${ + concatStrings (intersperse "," + ( optional langC "c" + ++ optional langCC "c++" + ++ optional langFortran "fortran" + ++ optional langJava "java" + ++ optional langGo "go" + ++ optional langObjC "objc" + ++ optional langObjCpp "obj-c++" + ++ optionals crossDarwin [ "objc" "obj-c++" ] + ) + ) + }" + ] ++ + + (if (enableMultilib || targetPlatform.isAvr) + then ["--enable-multilib" "--disable-libquadmath"] + else ["--disable-multilib"]) ++ + optional (!enableShared) "--disable-shared" ++ + (if enablePlugin + then ["--enable-plugin"] + else ["--disable-plugin"]) ++ + + # Optional features + optional (isl != null) "--with-isl=${isl}" ++ + optionals (cloog != null) [ + "--with-cloog=${cloog}" + "--disable-cloog-version-check" + "--enable-cloog-backend=isl" + ] ++ + + # Java options + optionals langJava [ + "--with-ecj-jar=${javaEcj}" + + # Follow Sun's layout for the convenience of IcedTea/OpenJDK. See + # <http://mail.openjdk.java.net/pipermail/distro-pkg-dev/2010-April/008888.html>. + "--enable-java-home" + "--with-java-home=\${prefix}/lib/jvm/jre" + ] ++ + optional javaAwtGtk "--enable-java-awt=gtk" ++ + optional (langJava && javaAntlr != null) "--with-antlr-jar=${javaAntlr}" ++ + + (import ../common/platform-flags.nix { inherit (stdenv) lib targetPlatform; }) ++ + optional (targetPlatform != hostPlatform) crossConfigureFlags ++ + optional (!bootstrap) "--disable-bootstrap" ++ + + # Platform-specific flags + optional (targetPlatform == hostPlatform && targetPlatform.isx86_32) "--with-arch=${stdenv.hostPlatform.parsed.cpu.name}" ++ + optionals hostPlatform.isSunOS [ + "--enable-long-long" "--enable-libssp" "--enable-threads=posix" "--disable-nls" "--enable-__cxa_atexit" + # On Illumos/Solaris GNU as is preferred + "--with-gnu-as" "--without-gnu-ld" + ] + ; + + targetConfig = if targetPlatform != hostPlatform then targetPlatform.config else null; + + buildFlags = optional + (bootstrap && hostPlatform == buildPlatform) + (if profiledCompiler then "profiledbootstrap" else "bootstrap"); + + dontStrip = !stripped; + + doCheck = false; # requires a lot of tools, causes a dependency cycle for stdenv + + installTargets = + if stripped + then "install-strip" + else "install"; + + # https://gcc.gnu.org/install/specific.html#x86-64-x-solaris210 + ${if hostPlatform.system == "x86_64-solaris" then "CC" else null} = "gcc -m64"; + + # Setting $CPATH and $LIBRARY_PATH to make sure both `gcc' and `xgcc' find the + # library headers and binaries, regarless of the language being compiled. + # + # Note: When building the Java AWT GTK+ peer, the build system doesn't honor + # `--with-gmp' et al., e.g., when building + # `libjava/classpath/native/jni/java-math/gnu_java_math_GMP.c', so we just add + # them to $CPATH and $LIBRARY_PATH in this case. + # + # Likewise, the LTO code doesn't find zlib. + # + # Cross-compiling, we need gcc not to read ./specs in order to build the g++ + # compiler (after the specs for the cross-gcc are created). Having + # LIBRARY_PATH= makes gcc read the specs from ., and the build breaks. + + CPATH = optionals (targetPlatform == hostPlatform) (makeSearchPathOutput "dev" "include" ([] + ++ optional (zlib != null) zlib + ++ optional langJava boehmgc + ++ optionals javaAwtGtk xlibs + ++ optionals javaAwtGtk [ gmp mpfr ] + )); + + LIBRARY_PATH = optionals (targetPlatform == hostPlatform) (makeLibraryPath ([] + ++ optional (zlib != null) zlib + ++ optional langJava boehmgc + ++ optionals javaAwtGtk xlibs + ++ optionals javaAwtGtk [ gmp mpfr ] + )); + + EXTRA_TARGET_FLAGS = optionals + (targetPlatform != hostPlatform && libcCross != null) + ([ + "-idirafter ${getDev libcCross}${libcCross.incdir or "/include"}" + ] ++ optionals (! crossStageStatic) [ + "-B${libcCross.out}${libcCross.libdir or "/lib"}" + ]); + + EXTRA_TARGET_LDFLAGS = optionals + (targetPlatform != hostPlatform && libcCross != null) + ([ + "-Wl,-L${libcCross.out}${libcCross.libdir or "/lib"}" + ] ++ (if crossStageStatic then [ + "-B${libcCross.out}${libcCross.libdir or "/lib"}" + ] else [ + "-Wl,-rpath,${libcCross.out}${libcCross.libdir or "/lib"}" + "-Wl,-rpath-link,${libcCross.out}${libcCross.libdir or "/lib"}" + ])); + + passthru = { + inherit langC langCC langObjC langObjCpp langFortran langGo version; + isGNU = true; + }; + + enableParallelBuilding = true; + inherit enableMultilib; + + inherit (stdenv) is64bit; + + meta = { + homepage = https://gcc.gnu.org/; + license = stdenv.lib.licenses.gpl3Plus; # runtime support libraries are typically LGPLv3+ + description = "GNU Compiler Collection, version ${version}" + + (if stripped then "" else " (with debugging info)"); + + longDescription = '' + The GNU Compiler Collection includes compiler front ends for C, C++, + Objective-C, Fortran, OpenMP for C/C++/Fortran, Java, and Ada, as well + as libraries for these languages (libstdc++, libgcj, libgomp,...). + + GCC development is a part of the GNU Project, aiming to improve the + compiler used in the GNU system including the GNU/Linux variant. + ''; + + maintainers = with stdenv.lib.maintainers; [ peti ]; + + platforms = + stdenv.lib.platforms.linux ++ + stdenv.lib.platforms.freebsd ++ + stdenv.lib.platforms.illumos ++ + stdenv.lib.platforms.darwin; + }; +} + +// optionalAttrs (targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt" && crossStageStatic) { + makeFlags = [ "all-gcc" "all-target-libgcc" ]; + installTargets = "install-gcc install-target-libgcc"; +} + +// optionalAttrs (enableMultilib) { dontMoveLib64 = true; } + +// optionalAttrs (langJava) { + postFixup = '' + target="$(echo "$out/libexec/gcc"/*/*/ecj*)" + patchelf --set-rpath "$(patchelf --print-rpath "$target"):$out/lib" "$target" + '';} +) diff --git a/nixpkgs/pkgs/development/compilers/gcc/4.9/parallel-strsignal.patch b/nixpkgs/pkgs/development/compilers/gcc/4.9/parallel-strsignal.patch new file mode 100644 index 000000000000..4c98ca273a54 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/gcc/4.9/parallel-strsignal.patch @@ -0,0 +1,61 @@ +gcc/Makefile.in: fix parallel building failure + +The gcc-ar.o, gcc-nm.o, gcc-ranlib.o and errors.o included +config.h which was a generated file. But no explicity rule +to clarify the dependency. There was potential building +failure while parallel make. + +For gcc-ar.o, gcc-nm.o and gcc-ranlib.o, they were compiled from one C +source file gcc-ar.c, we add them to ALL_HOST_BACKEND_OBJS, so the +'$(ALL_HOST_OBJS) : | $(generated_files)' rule could work for these +objects. + +For errors.o, it is part of gengtype, and the gengtype generator program +is special: Two versions are built. One is for the build machine, and one +is for the host. We refered what gengtype-parse.o did (which also is part +of gengtype). + +[GCC #61899] +https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61899 + +Upstream-Status: Send to gcc-patches@gcc.gnu.org mailing list + +Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com> +--- + gcc/Makefile.in | 7 ++++++- + 1 file changed, 6 insertions(+), 1 deletion(-) + +diff --git a/gcc/Makefile.in b/gcc/Makefile.in +index 6475cba..56e50bb 100644 +--- a/gcc/Makefile.in ++++ b/gcc/Makefile.in +@@ -1481,13 +1481,16 @@ OBJS-libcommon-target = $(common_out_object_file) prefix.o params.o \ + opts.o opts-common.o options.o vec.o hooks.o common/common-targhooks.o \ + hash-table.o file-find.o + ++# Objects compiled from one C source file gcc-ar.c ++OBJS-gcc-ar = gcc-ar.o gcc-nm.o gcc-ranlib.o ++ + # This lists all host objects for the front ends. + ALL_HOST_FRONTEND_OBJS = $(foreach v,$(CONFIG_LANGUAGES),$($(v)_OBJS)) + + ALL_HOST_BACKEND_OBJS = $(GCC_OBJS) $(OBJS) $(OBJS-libcommon) \ + $(OBJS-libcommon-target) @TREEBROWSER@ main.o c-family/cppspec.o \ + $(COLLECT2_OBJS) $(EXTRA_GCC_OBJS) $(GCOV_OBJS) $(GCOV_DUMP_OBJS) \ +- lto-wrapper.o ++ lto-wrapper.o $(OBJS-gcc-ar) + + # This lists all host object files, whether they are included in this + # compilation or not. +@@ -2437,6 +2440,8 @@ gengtype-parse.o: $(CONFIG_H) + CFLAGS-build/gengtype-parse.o += -DGENERATOR_FILE + build/gengtype-parse.o: $(BCONFIG_H) + ++errors.o : $(CONFIG_H) ++ + gengtype-state.o build/gengtype-state.o: gengtype-state.c $(SYSTEM_H) \ + gengtype.h errors.h double-int.h version.h $(HASHTAB_H) $(OBSTACK_H) \ + $(XREGEX_H) +-- +1.8.1.2 + diff --git a/nixpkgs/pkgs/development/compilers/gcc/5/default.nix b/nixpkgs/pkgs/development/compilers/gcc/5/default.nix new file mode 100644 index 000000000000..2d7ac9497bbb --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/gcc/5/default.nix @@ -0,0 +1,447 @@ +{ stdenv, targetPackages, fetchurl, fetchpatch, noSysDirs +, langC ? true, langCC ? true, langFortran ? false +, langObjC ? stdenv.targetPlatform.isDarwin +, langObjCpp ? stdenv.targetPlatform.isDarwin +, langJava ? false +, langGo ? false +, profiledCompiler ? false +, staticCompiler ? false +, enableShared ? true +, texinfo ? null +, perl ? null # optional, for texi2pod (then pod2man); required for Java +, gmp, mpfr, libmpc, gettext, which +, libelf # optional, for link-time optimizations (LTO) +, isl ? null # optional, for the Graphite optimization framework. +, zlib ? null, boehmgc ? null +, zip ? null, unzip ? null, pkgconfig ? null +, gtk2 ? null, libart_lgpl ? null +, libX11 ? null, libXt ? null, libSM ? null, libICE ? null, libXtst ? null +, libXrender ? null, xorgproto ? null +, libXrandr ? null, libXi ? null +, x11Support ? langJava +, enableMultilib ? false +, enablePlugin ? stdenv.hostPlatform == stdenv.buildPlatform # Whether to support user-supplied plug-ins +, name ? "gcc" +, libcCross ? null +, crossStageStatic ? false +, # Strip kills static libs of other archs (hence no cross) + stripped ? stdenv.hostPlatform == stdenv.buildPlatform + && stdenv.targetPlatform == stdenv.hostPlatform +, gnused ? null +, cloog # unused; just for compat with gcc4, as we override the parameter on some places +, buildPackages +}: + +assert langJava -> zip != null && unzip != null + && zlib != null && boehmgc != null + && perl != null; # for `--enable-java-home' + +# LTO needs libelf and zlib. +assert libelf != null -> zlib != null; + +# Make sure we get GNU sed. +assert stdenv.hostPlatform.isDarwin -> gnused != null; + +# The go frontend is written in c++ +assert langGo -> langCC; + +with stdenv.lib; +with builtins; + +let version = "5.5.0"; + + inherit (stdenv) buildPlatform hostPlatform targetPlatform; + + patches = + [ ../use-source-date-epoch.patch ] + ++ optional (targetPlatform != hostPlatform) ../libstdc++-target.patch + ++ optional noSysDirs ../no-sys-dirs.patch + ++ optional langFortran ../gfortran-driving.patch + ++ optional (targetPlatform.libc == "musl") ../libgomp-dont-force-initial-exec.patch + ++ optional stdenv.hostPlatform.isMusl (fetchpatch { + url = https://raw.githubusercontent.com/richfelker/musl-cross-make/e84b1bd1fc12a3def33111ca6df522cd6e5ec361/patches/gcc-5.3.0/0001-musl.diff; + sha256 = "0pppbf8myi2kjhm3z3479ihn1cm60kycfv60gj8yy1bs0pl1qcfm"; + }); + + javaEcj = fetchurl { + # The `$(top_srcdir)/ecj.jar' file is automatically picked up at + # `configure' time. + + # XXX: Eventually we might want to take it from upstream. + url = "ftp://sourceware.org/pub/java/ecj-4.3.jar"; + sha256 = "0jz7hvc0s6iydmhgh5h2m15yza7p2rlss2vkif30vm9y77m97qcx"; + }; + + # Antlr (optional) allows the Java `gjdoc' tool to be built. We want a + # binary distribution here to allow the whole chain to be bootstrapped. + javaAntlr = fetchurl { + url = https://www.antlr.org/download/antlr-4.4-complete.jar; + sha256 = "02lda2imivsvsis8rnzmbrbp8rh1kb8vmq4i67pqhkwz7lf8y6dz"; + }; + + xlibs = [ + libX11 libXt libSM libICE libXtst libXrender libXrandr libXi + xorgproto + ]; + + javaAwtGtk = langJava && x11Support; + + /* Cross-gcc settings (build == host != target) */ + crossMingw = targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt"; + crossDarwin = targetPlatform != hostPlatform && targetPlatform.libc == "libSystem"; + crossConfigureFlags = + # Ensure that -print-prog-name is able to find the correct programs. + [ "--with-as=${targetPackages.stdenv.cc.bintools}/bin/${targetPlatform.config}-as" + "--with-ld=${targetPackages.stdenv.cc.bintools}/bin/${targetPlatform.config}-ld" ] ++ + (if crossMingw && crossStageStatic then [ + "--with-headers=${libcCross}/include" + "--with-gcc" + "--with-gnu-as" + "--with-gnu-ld" + "--with-gnu-ld" + "--disable-shared" + "--disable-nls" + "--disable-debug" + "--enable-sjlj-exceptions" + "--enable-threads=win32" + "--disable-win32-registry" + "--disable-libmpx" # requires libc + ] else if crossStageStatic then [ + "--disable-libssp" + "--disable-nls" + "--without-headers" + "--disable-threads" + "--disable-libgomp" + "--disable-libquadmath" + "--disable-shared" + "--disable-libatomic" # requires libc + "--disable-decimal-float" # requires libc + "--disable-libmpx" # requires libc + ] else [ + (if crossDarwin then "--with-sysroot=${getLib libcCross}/share/sysroot" + else "--with-headers=${getDev libcCross}${libcCross.incdir or "/include"}") + "--enable-__cxa_atexit" + "--enable-long-long" + ] ++ + (if crossMingw then [ + "--enable-threads=win32" + "--enable-sjlj-exceptions" + "--enable-hash-synchronization" + "--enable-libssp" + "--disable-nls" + "--with-dwarf2" + # To keep ABI compatibility with upstream mingw-w64 + "--enable-fully-dynamic-string" + ] else + optionals (targetPlatform.libc == "uclibc" || targetPlatform.libc == "musl") [ + # libsanitizer requires netrom/netrom.h which is not + # available in uclibc. + "--disable-libsanitizer" + # In uclibc cases, libgomp needs an additional '-ldl' + # and as I don't know how to pass it, I disable libgomp. + "--disable-libgomp" + ] + ++ optional (targetPlatform.libc == "newlib") "--with-newlib" + ++ optional (targetPlatform.libc == "avrlibc") "--with-avrlibc" + ++ [ + "--enable-threads=${if targetPlatform.isUnix then "posix" + else if targetPlatform.isWindows then "win32" + else "single"}" + "--enable-nls" + "--disable-decimal-float" # No final libdecnumber (it may work only in 386) + ])); + stageNameAddon = if crossStageStatic then "-stage-static" else "-stage-final"; + crossNameAddon = if targetPlatform != hostPlatform then "${targetPlatform.config}${stageNameAddon}-" else ""; + + bootstrap = targetPlatform == hostPlatform; + +in + +# We need all these X libraries when building AWT with GTK+. +assert x11Support -> (filter (x: x == null) ([ gtk2 libart_lgpl ] ++ xlibs)) == []; + +stdenv.mkDerivation ({ + name = crossNameAddon + "${name}${if stripped then "" else "-debug"}-${version}"; + + builder = ../builder.sh; + + src = fetchurl { + url = "mirror://gnu/gcc/gcc-${version}/gcc-${version}.tar.xz"; + sha256 = "11zd1hgzkli3b2v70qsm2hyqppngd4616qc96lmm9zl2kl9yl32k"; + }; + + inherit patches; + + outputs = [ "out" "lib" "man" "info" ]; + setOutputFlags = false; + NIX_NO_SELF_RPATH = true; + + libc_dev = stdenv.cc.libc_dev; + + hardeningDisable = [ "format" "pie" ]; + + # This should kill all the stdinc frameworks that gcc and friends like to + # insert into default search paths. + prePatch = stdenv.lib.optionalString hostPlatform.isDarwin '' + substituteInPlace gcc/config/darwin-c.c \ + --replace 'if (stdinc)' 'if (0)' + + substituteInPlace libgcc/config/t-slibgcc-darwin \ + --replace "-install_name @shlib_slibdir@/\$(SHLIB_INSTALL_NAME)" "-install_name $lib/lib/\$(SHLIB_INSTALL_NAME)" + + substituteInPlace libgfortran/configure \ + --replace "-install_name \\\$rpath/\\\$soname" "-install_name $lib/lib/\\\$soname" + ''; + + postPatch = + if targetPlatform != hostPlatform || stdenv.cc.libc != null then + # On NixOS, use the right path to the dynamic linker instead of + # `/lib/ld*.so'. + let + libc = if libcCross != null then libcCross else stdenv.cc.libc; + in + ( + '' echo "fixing the \`GLIBC_DYNAMIC_LINKER', \`UCLIBC_DYNAMIC_LINKER', and \`MUSL_DYNAMIC_LINKER' macros..." + for header in "gcc/config/"*-gnu.h "gcc/config/"*"/"*.h + do + grep -q _DYNAMIC_LINKER "$header" || continue + echo " fixing \`$header'..." + sed -i "$header" \ + -e 's|define[[:blank:]]*\([UCG]\+\)LIBC_DYNAMIC_LINKER\([0-9]*\)[[:blank:]]"\([^\"]\+\)"$|define \1LIBC_DYNAMIC_LINKER\2 "${libc.out}\3"|g' \ + -e 's|define[[:blank:]]*MUSL_DYNAMIC_LINKER\([0-9]*\)[[:blank:]]"\([^\"]\+\)"$|define MUSL_DYNAMIC_LINKER\1 "${libc.out}\2"|g' + done + '' + + stdenv.lib.optionalString (targetPlatform.libc == "musl") + '' + sed -i gcc/config/linux.h -e '1i#undef LOCAL_INCLUDE_DIR' + '' + ) + else null; + + inherit noSysDirs staticCompiler langJava crossStageStatic + libcCross crossMingw; + + depsBuildBuild = [ buildPackages.stdenv.cc ]; + nativeBuildInputs = [ texinfo which gettext ] + ++ (optional (perl != null) perl) + ++ (optional javaAwtGtk pkgconfig); + + # For building runtime libs + depsBuildTarget = + if hostPlatform == buildPlatform then [ + targetPackages.stdenv.cc.bintools # newly-built gcc will be used + ] else assert targetPlatform == hostPlatform; [ # build != host == target + stdenv.cc + ]; + + buildInputs = [ + gmp mpfr libmpc libelf + targetPackages.stdenv.cc.bintools # For linking code at run-time + ] ++ (optional (isl != null) isl) + ++ (optional (zlib != null) zlib) + ++ (optionals langJava [ boehmgc zip unzip ]) + ++ (optionals javaAwtGtk ([ gtk2 libart_lgpl ] ++ xlibs)) + + # The builder relies on GNU sed (for instance, Darwin's `sed' fails with + # "-i may not be used with stdin"), and `stdenvNative' doesn't provide it. + ++ (optional hostPlatform.isDarwin gnused) + ; + + NIX_LDFLAGS = stdenv.lib.optionalString hostPlatform.isSunOS "-lm -ldl"; + + preConfigure = stdenv.lib.optionalString (hostPlatform.isSunOS && hostPlatform.is64bit) '' + export NIX_LDFLAGS=`echo $NIX_LDFLAGS | sed -e s~$prefix/lib~$prefix/lib/amd64~g` + export LDFLAGS_FOR_TARGET="-Wl,-rpath,$prefix/lib/amd64 $LDFLAGS_FOR_TARGET" + export CXXFLAGS_FOR_TARGET="-Wl,-rpath,$prefix/lib/amd64 $CXXFLAGS_FOR_TARGET" + export CFLAGS_FOR_TARGET="-Wl,-rpath,$prefix/lib/amd64 $CFLAGS_FOR_TARGET" + ''; + + dontDisableStatic = true; + + # TODO(@Ericson2314): Always pass "--target" and always prefix. + configurePlatforms = [ "build" "host" ] ++ stdenv.lib.optional (targetPlatform != hostPlatform) "target"; + + configureFlags = + # Basic dependencies + [ + "--with-gmp-include=${gmp.dev}/include" + "--with-gmp-lib=${gmp.out}/lib" + "--with-mpfr-include=${mpfr.dev}/include" + "--with-mpfr-lib=${mpfr.out}/lib" + "--with-mpc=${libmpc}" + ] ++ + optional (libelf != null) "--with-libelf=${libelf}" ++ + optional (!(crossMingw && crossStageStatic)) + "--with-native-system-header-dir=${getDev stdenv.cc.libc}/include" ++ + + # Basic configuration + [ + "--enable-lto" + "--disable-libstdcxx-pch" + "--without-included-gettext" + "--with-system-zlib" + "--enable-static" + "--enable-languages=${ + concatStrings (intersperse "," + ( optional langC "c" + ++ optional langCC "c++" + ++ optional langFortran "fortran" + ++ optional langJava "java" + ++ optional langGo "go" + ++ optional langObjC "objc" + ++ optional langObjCpp "obj-c++" + ++ optionals crossDarwin [ "objc" "obj-c++" ] + ) + ) + }" + ] ++ + + (if (enableMultilib || targetPlatform.isAvr) + then ["--enable-multilib" "--disable-libquadmath"] + else ["--disable-multilib"]) ++ + optional (!enableShared) "--disable-shared" ++ + (if enablePlugin + then ["--enable-plugin"] + else ["--disable-plugin"]) ++ + + # Optional features + optional (isl != null) "--with-isl=${isl}" ++ + + # Java options + optionals langJava [ + "--with-ecj-jar=${javaEcj}" + + # Follow Sun's layout for the convenience of IcedTea/OpenJDK. See + # <http://mail.openjdk.java.net/pipermail/distro-pkg-dev/2010-April/008888.html>. + "--enable-java-home" + "--with-java-home=\${prefix}/lib/jvm/jre" + ] ++ + optional javaAwtGtk "--enable-java-awt=gtk" ++ + optional (langJava && javaAntlr != null) "--with-antlr-jar=${javaAntlr}" ++ + + (import ../common/platform-flags.nix { inherit (stdenv) lib targetPlatform; }) ++ + optional (targetPlatform != hostPlatform) crossConfigureFlags ++ + optional (!bootstrap) "--disable-bootstrap" ++ + + # Platform-specific flags + optional (targetPlatform == hostPlatform && targetPlatform.isx86_32) "--with-arch=${stdenv.hostPlatform.parsed.cpu.name}" ++ + optionals hostPlatform.isSunOS [ + "--enable-long-long" "--enable-libssp" "--enable-threads=posix" "--disable-nls" "--enable-__cxa_atexit" + # On Illumos/Solaris GNU as is preferred + "--with-gnu-as" "--without-gnu-ld" + ] + ++ optionals (targetPlatform == hostPlatform && targetPlatform.libc == "musl") [ + "--disable-libsanitizer" + "--disable-symvers" + "libat_cv_have_ifunc=no" + "--disable-gnu-indirect-function" + ] + ; + + targetConfig = if targetPlatform != hostPlatform then targetPlatform.config else null; + + buildFlags = optional + (bootstrap && hostPlatform == buildPlatform) + (if profiledCompiler then "profiledbootstrap" else "bootstrap"); + + dontStrip = !stripped; + + doCheck = false; # requires a lot of tools, causes a dependency cycle for stdenv + + installTargets = + if stripped + then "install-strip" + else "install"; + + # https://gcc.gnu.org/install/specific.html#x86-64-x-solaris210 + ${if hostPlatform.system == "x86_64-solaris" then "CC" else null} = "gcc -m64"; + + # Setting $CPATH and $LIBRARY_PATH to make sure both `gcc' and `xgcc' find the + # library headers and binaries, regarless of the language being compiled. + # + # Note: When building the Java AWT GTK+ peer, the build system doesn't honor + # `--with-gmp' et al., e.g., when building + # `libjava/classpath/native/jni/java-math/gnu_java_math_GMP.c', so we just add + # them to $CPATH and $LIBRARY_PATH in this case. + # + # Likewise, the LTO code doesn't find zlib. + # + # Cross-compiling, we need gcc not to read ./specs in order to build the g++ + # compiler (after the specs for the cross-gcc are created). Having + # LIBRARY_PATH= makes gcc read the specs from ., and the build breaks. + + CPATH = optionals (targetPlatform == hostPlatform) (makeSearchPathOutput "dev" "include" ([] + ++ optional (zlib != null) zlib + ++ optional langJava boehmgc + ++ optionals javaAwtGtk xlibs + ++ optionals javaAwtGtk [ gmp mpfr ] + )); + + LIBRARY_PATH = optionals (targetPlatform == hostPlatform) (makeLibraryPath ([] + ++ optional (zlib != null) zlib + ++ optional langJava boehmgc + ++ optionals javaAwtGtk xlibs + ++ optionals javaAwtGtk [ gmp mpfr ] + )); + + EXTRA_TARGET_FLAGS = optionals + (targetPlatform != hostPlatform && libcCross != null) + ([ + "-idirafter ${getDev libcCross}${libcCross.incdir or "/include"}" + ] ++ optionals (! crossStageStatic) [ + "-B${libcCross.out}${libcCross.libdir or "/lib"}" + ]); + + EXTRA_TARGET_LDFLAGS = optionals + (targetPlatform != hostPlatform && libcCross != null) + ([ + "-Wl,-L${libcCross.out}${libcCross.libdir or "/lib"}" + ] ++ (if crossStageStatic then [ + "-B${libcCross.out}${libcCross.libdir or "/lib"}" + ] else [ + "-Wl,-rpath,${libcCross.out}${libcCross.libdir or "/lib"}" + "-Wl,-rpath-link,${libcCross.out}${libcCross.libdir or "/lib"}" + ])); + + passthru = { + inherit langC langCC langObjC langObjCpp langFortran langGo version; + isGNU = true; + }; + + enableParallelBuilding = true; + inherit enableMultilib; + + inherit (stdenv) is64bit; + + meta = { + homepage = https://gcc.gnu.org/; + license = stdenv.lib.licenses.gpl3Plus; # runtime support libraries are typically LGPLv3+ + description = "GNU Compiler Collection, version ${version}" + + (if stripped then "" else " (with debugging info)"); + + longDescription = '' + The GNU Compiler Collection includes compiler front ends for C, C++, + Objective-C, Fortran, OpenMP for C/C++/Fortran, Java, and Ada, as well + as libraries for these languages (libstdc++, libgcj, libgomp,...). + + GCC development is a part of the GNU Project, aiming to improve the + compiler used in the GNU system including the GNU/Linux variant. + ''; + + maintainers = with stdenv.lib.maintainers; [ peti ]; + + platforms = + stdenv.lib.platforms.linux ++ + stdenv.lib.platforms.freebsd ++ + stdenv.lib.platforms.illumos ++ + stdenv.lib.platforms.darwin; + }; +} + +// optionalAttrs (targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt" && crossStageStatic) { + makeFlags = [ "all-gcc" "all-target-libgcc" ]; + installTargets = "install-gcc install-target-libgcc"; +} + +// optionalAttrs (enableMultilib) { dontMoveLib64 = true; } +) diff --git a/nixpkgs/pkgs/development/compilers/gcc/6/default.nix b/nixpkgs/pkgs/development/compilers/gcc/6/default.nix new file mode 100644 index 000000000000..7644f4d3f623 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/gcc/6/default.nix @@ -0,0 +1,460 @@ +{ stdenv, targetPackages, fetchurl, noSysDirs +, langC ? true, langCC ? true, langFortran ? false +, langObjC ? stdenv.targetPlatform.isDarwin +, langObjCpp ? stdenv.targetPlatform.isDarwin +, langJava ? false +, langGo ? false +, profiledCompiler ? false +, staticCompiler ? false +, enableShared ? true +, texinfo ? null +, perl ? null # optional, for texi2pod (then pod2man); required for Java +, gmp, mpfr, libmpc, gettext, which +, libelf # optional, for link-time optimizations (LTO) +, isl ? null # optional, for the Graphite optimization framework. +, zlib ? null, boehmgc ? null +, zip ? null, unzip ? null, pkgconfig ? null +, gtk2 ? null, libart_lgpl ? null +, libX11 ? null, libXt ? null, libSM ? null, libICE ? null, libXtst ? null +, libXrender ? null, xorgproto ? null +, libXrandr ? null, libXi ? null +, x11Support ? langJava +, enableMultilib ? false +, enablePlugin ? stdenv.hostPlatform == stdenv.buildPlatform # Whether to support user-supplied plug-ins +, name ? "gcc" +, libcCross ? null +, crossStageStatic ? false +, # Strip kills static libs of other archs (hence no cross) + stripped ? stdenv.hostPlatform == stdenv.buildPlatform + && stdenv.targetPlatform == stdenv.hostPlatform +, gnused ? null +, cloog # unused; just for compat with gcc4, as we override the parameter on some places +, buildPackages +}: + +assert langJava -> zip != null && unzip != null + && zlib != null && boehmgc != null + && perl != null; # for `--enable-java-home' + +# LTO needs libelf and zlib. +assert libelf != null -> zlib != null; + +# Make sure we get GNU sed. +assert stdenv.hostPlatform.isDarwin -> gnused != null; + +# The go frontend is written in c++ +assert langGo -> langCC; + +with stdenv.lib; +with builtins; + +let version = "6.5.0"; + + inherit (stdenv) buildPlatform hostPlatform targetPlatform; + + patches = + [ ../use-source-date-epoch.patch ] + ++ optional (targetPlatform != hostPlatform) ../libstdc++-target.patch + ++ optional noSysDirs ../no-sys-dirs.patch + ++ optional langFortran ../gfortran-driving.patch + ++ optional (targetPlatform.libc == "musl") ../libgomp-dont-force-initial-exec.patch + ; + + javaEcj = fetchurl { + # The `$(top_srcdir)/ecj.jar' file is automatically picked up at + # `configure' time. + + # XXX: Eventually we might want to take it from upstream. + url = "ftp://sourceware.org/pub/java/ecj-4.3.jar"; + sha256 = "0jz7hvc0s6iydmhgh5h2m15yza7p2rlss2vkif30vm9y77m97qcx"; + }; + + # Antlr (optional) allows the Java `gjdoc' tool to be built. We want a + # binary distribution here to allow the whole chain to be bootstrapped. + javaAntlr = fetchurl { + url = https://www.antlr.org/download/antlr-4.4-complete.jar; + sha256 = "02lda2imivsvsis8rnzmbrbp8rh1kb8vmq4i67pqhkwz7lf8y6dz"; + }; + + xlibs = [ + libX11 libXt libSM libICE libXtst libXrender libXrandr libXi + xorgproto + ]; + + javaAwtGtk = langJava && x11Support; + + /* Cross-gcc settings (build == host != target) */ + crossMingw = targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt"; + crossDarwin = targetPlatform != hostPlatform && targetPlatform.libc == "libSystem"; + crossConfigureFlags = + # Ensure that -print-prog-name is able to find the correct programs. + [ "--with-as=${targetPackages.stdenv.cc.bintools}/bin/${targetPlatform.config}-as" + "--with-ld=${targetPackages.stdenv.cc.bintools}/bin/${targetPlatform.config}-ld" ] ++ + (if crossMingw && crossStageStatic then [ + "--with-headers=${libcCross}/include" + "--with-gcc" + "--with-gnu-as" + "--with-gnu-ld" + "--with-gnu-ld" + "--disable-shared" + "--disable-nls" + "--disable-debug" + "--enable-sjlj-exceptions" + "--enable-threads=win32" + "--disable-win32-registry" + "--disable-libmpx" # requires libc + ] else if crossStageStatic then [ + "--disable-libssp" + "--disable-nls" + "--without-headers" + "--disable-threads" + "--disable-libgomp" + "--disable-libquadmath" + "--disable-shared" + "--disable-libatomic" # requires libc + "--disable-decimal-float" # requires libc + "--disable-libmpx" # requires libc + ] else [ + (if crossDarwin then "--with-sysroot=${getLib libcCross}/share/sysroot" + else "--with-headers=${getDev libcCross}${libcCross.incdir or "/include"}") + "--enable-__cxa_atexit" + "--enable-long-long" + ] ++ + (if crossMingw then [ + "--enable-threads=win32" + "--enable-sjlj-exceptions" + "--enable-hash-synchronization" + "--enable-libssp" + "--disable-nls" + "--with-dwarf2" + # To keep ABI compatibility with upstream mingw-w64 + "--enable-fully-dynamic-string" + ] else + optionals (targetPlatform.libc == "uclibc" || targetPlatform.libc == "musl") [ + # libsanitizer requires netrom/netrom.h which is not + # available in uclibc. + "--disable-libsanitizer" + # In uclibc cases, libgomp needs an additional '-ldl' + # and as I don't know how to pass it, I disable libgomp. + "--disable-libgomp" + # musl at least, disable: https://git.buildroot.net/buildroot/commit/?id=873d4019f7fb00f6a80592224236b3ba7d657865 + "--disable-libmpx" + ] + ++ optional (targetPlatform.libc == "newlib") "--with-newlib" + ++ optional (targetPlatform.libc == "avrlibc") "--with-avrlibc" + ++ [ + "--enable-threads=${if targetPlatform.isUnix then "posix" + else if targetPlatform.isWindows then "win32" + else "single"}" + "--enable-nls" + "--disable-decimal-float" # No final libdecnumber (it may work only in 386) + ])); + stageNameAddon = if crossStageStatic then "-stage-static" else "-stage-final"; + crossNameAddon = if targetPlatform != hostPlatform then "${targetPlatform.config}${stageNameAddon}-" else ""; + + bootstrap = targetPlatform == hostPlatform; + +in + +# We need all these X libraries when building AWT with GTK+. +assert x11Support -> (filter (x: x == null) ([ gtk2 libart_lgpl ] ++ xlibs)) == []; + +stdenv.mkDerivation ({ + name = crossNameAddon + "${name}${if stripped then "" else "-debug"}-${version}"; + + builder = ../builder.sh; + + src = fetchurl { + url = "mirror://gnu/gcc/gcc-${version}/gcc-${version}.tar.xz"; + sha256 = "0i89fksfp6wr1xg9l8296aslcymv2idn60ip31wr9s4pwin7kwby"; + }; + + inherit patches; + + outputs = if langJava || langGo then ["out" "man" "info"] + else [ "out" "lib" "man" "info" ]; + setOutputFlags = false; + NIX_NO_SELF_RPATH = true; + + libc_dev = stdenv.cc.libc_dev; + + hardeningDisable = [ "format" "pie" ]; + + prePatch = + (stdenv.lib.optionalString (langJava || langGo) '' + export lib=$out + '') + + # This should kill all the stdinc frameworks that gcc and friends like to + # insert into default search paths. + + stdenv.lib.optionalString hostPlatform.isDarwin '' + substituteInPlace gcc/config/darwin-c.c \ + --replace 'if (stdinc)' 'if (0)' + + substituteInPlace libgcc/config/t-slibgcc-darwin \ + --replace "-install_name @shlib_slibdir@/\$(SHLIB_INSTALL_NAME)" "-install_name $lib/lib/\$(SHLIB_INSTALL_NAME)" + + substituteInPlace libgfortran/configure \ + --replace "-install_name \\\$rpath/\\\$soname" "-install_name $lib/lib/\\\$soname" + ''; + + postPatch = + if targetPlatform != hostPlatform || stdenv.cc.libc != null then + # On NixOS, use the right path to the dynamic linker instead of + # `/lib/ld*.so'. + let + libc = if libcCross != null then libcCross else stdenv.cc.libc; + in + ( + '' echo "fixing the \`GLIBC_DYNAMIC_LINKER', \`UCLIBC_DYNAMIC_LINKER', and \`MUSL_DYNAMIC_LINKER' macros..." + for header in "gcc/config/"*-gnu.h "gcc/config/"*"/"*.h + do + grep -q _DYNAMIC_LINKER "$header" || continue + echo " fixing \`$header'..." + sed -i "$header" \ + -e 's|define[[:blank:]]*\([UCG]\+\)LIBC_DYNAMIC_LINKER\([0-9]*\)[[:blank:]]"\([^\"]\+\)"$|define \1LIBC_DYNAMIC_LINKER\2 "${libc.out}\3"|g' \ + -e 's|define[[:blank:]]*MUSL_DYNAMIC_LINKER\([0-9]*\)[[:blank:]]"\([^\"]\+\)"$|define MUSL_DYNAMIC_LINKER\1 "${libc.out}\2"|g' + done + '' + + stdenv.lib.optionalString (targetPlatform.libc == "musl") + '' + sed -i gcc/config/linux.h -e '1i#undef LOCAL_INCLUDE_DIR' + '' + ) + else null; + + inherit noSysDirs staticCompiler langJava crossStageStatic + libcCross crossMingw; + + depsBuildBuild = [ buildPackages.stdenv.cc ]; + nativeBuildInputs = [ texinfo which gettext ] + ++ (optional (perl != null) perl) + ++ (optional javaAwtGtk pkgconfig); + + # For building runtime libs + depsBuildTarget = + if hostPlatform == buildPlatform then [ + targetPackages.stdenv.cc.bintools # newly-built gcc will be used + ] else assert targetPlatform == hostPlatform; [ # build != host == target + stdenv.cc + ]; + + buildInputs = [ + gmp mpfr libmpc libelf + targetPackages.stdenv.cc.bintools # For linking code at run-time + ] ++ (optional (isl != null) isl) + ++ (optional (zlib != null) zlib) + ++ (optionals langJava [ boehmgc zip unzip ]) + ++ (optionals javaAwtGtk ([ gtk2 libart_lgpl ] ++ xlibs)) + # The builder relies on GNU sed (for instance, Darwin's `sed' fails with + # "-i may not be used with stdin"), and `stdenvNative' doesn't provide it. + ++ (optional hostPlatform.isDarwin gnused) + ; + + NIX_LDFLAGS = stdenv.lib.optionalString hostPlatform.isSunOS "-lm -ldl"; + + preConfigure = stdenv.lib.optionalString (hostPlatform.isSunOS && hostPlatform.is64bit) '' + export NIX_LDFLAGS=`echo $NIX_LDFLAGS | sed -e s~$prefix/lib~$prefix/lib/amd64~g` + export LDFLAGS_FOR_TARGET="-Wl,-rpath,$prefix/lib/amd64 $LDFLAGS_FOR_TARGET" + export CXXFLAGS_FOR_TARGET="-Wl,-rpath,$prefix/lib/amd64 $CXXFLAGS_FOR_TARGET" + export CFLAGS_FOR_TARGET="-Wl,-rpath,$prefix/lib/amd64 $CFLAGS_FOR_TARGET" + '' + + stdenv.lib.optionalString (langJava || langGo) '' + export lib=$out; + ''; + + dontDisableStatic = true; + + # TODO(@Ericson2314): Always pass "--target" and always prefix. + configurePlatforms = [ "build" "host" ] ++ stdenv.lib.optional (targetPlatform != hostPlatform) "target"; + + configureFlags = + # Basic dependencies + [ + "--with-gmp-include=${gmp.dev}/include" + "--with-gmp-lib=${gmp.out}/lib" + "--with-mpfr-include=${mpfr.dev}/include" + "--with-mpfr-lib=${mpfr.out}/lib" + "--with-mpc=${libmpc}" + ] ++ + optional (libelf != null) "--with-libelf=${libelf}" ++ + optional (!(crossMingw && crossStageStatic)) + "--with-native-system-header-dir=${getDev stdenv.cc.libc}/include" ++ + + # Basic configuration + [ + "--enable-lto" + "--disable-libstdcxx-pch" + "--without-included-gettext" + "--with-system-zlib" + "--enable-static" + "--enable-languages=${ + concatStrings (intersperse "," + ( optional langC "c" + ++ optional langCC "c++" + ++ optional langFortran "fortran" + ++ optional langJava "java" + ++ optional langGo "go" + ++ optional langObjC "objc" + ++ optional langObjCpp "obj-c++" + ++ optionals crossDarwin [ "objc" "obj-c++" ] + ) + ) + }" + ] ++ + + (if (enableMultilib || targetPlatform.isAvr) + then ["--enable-multilib" "--disable-libquadmath"] + else ["--disable-multilib"]) ++ + optional (!enableShared) "--disable-shared" ++ + (if enablePlugin + then ["--enable-plugin"] + else ["--disable-plugin"]) ++ + + # Optional features + optional (isl != null) "--with-isl=${isl}" ++ + + # Java options + optionals langJava [ + "--with-ecj-jar=${javaEcj}" + + # Follow Sun's layout for the convenience of IcedTea/OpenJDK. See + # <http://mail.openjdk.java.net/pipermail/distro-pkg-dev/2010-April/008888.html>. + "--enable-java-home" + "--with-java-home=\${prefix}/lib/jvm/jre" + ] ++ + optional javaAwtGtk "--enable-java-awt=gtk" ++ + optional (langJava && javaAntlr != null) "--with-antlr-jar=${javaAntlr}" ++ + + (import ../common/platform-flags.nix { inherit (stdenv) lib targetPlatform; }) ++ + optional (targetPlatform != hostPlatform) crossConfigureFlags ++ + optional (!bootstrap) "--disable-bootstrap" ++ + + # Platform-specific flags + optional (targetPlatform == hostPlatform && targetPlatform.isx86_32) "--with-arch=${stdenv.hostPlatform.parsed.cpu.name}" ++ + optionals hostPlatform.isSunOS [ + "--enable-long-long" "--enable-libssp" "--enable-threads=posix" "--disable-nls" "--enable-__cxa_atexit" + # On Illumos/Solaris GNU as is preferred + "--with-gnu-as" "--without-gnu-ld" + ] + ++ optionals (targetPlatform == hostPlatform && targetPlatform.libc == "musl") [ + "--disable-libsanitizer" + "--disable-symvers" + "libat_cv_have_ifunc=no" + "--disable-gnu-indirect-function" + ] + ; + + targetConfig = if targetPlatform != hostPlatform then targetPlatform.config else null; + + buildFlags = optional + (bootstrap && hostPlatform == buildPlatform) + (if profiledCompiler then "profiledbootstrap" else "bootstrap"); + + dontStrip = !stripped; + + doCheck = false; # requires a lot of tools, causes a dependency cycle for stdenv + + installTargets = + if stripped + then "install-strip" + else "install"; + + # https://gcc.gnu.org/install/specific.html#x86-64-x-solaris210 + ${if hostPlatform.system == "x86_64-solaris" then "CC" else null} = "gcc -m64"; + + # Setting $CPATH and $LIBRARY_PATH to make sure both `gcc' and `xgcc' find the + # library headers and binaries, regarless of the language being compiled. + # + # Note: When building the Java AWT GTK+ peer, the build system doesn't honor + # `--with-gmp' et al., e.g., when building + # `libjava/classpath/native/jni/java-math/gnu_java_math_GMP.c', so we just add + # them to $CPATH and $LIBRARY_PATH in this case. + # + # Likewise, the LTO code doesn't find zlib. + # + # Cross-compiling, we need gcc not to read ./specs in order to build the g++ + # compiler (after the specs for the cross-gcc are created). Having + # LIBRARY_PATH= makes gcc read the specs from ., and the build breaks. + + CPATH = optionals (targetPlatform == hostPlatform) (makeSearchPathOutput "dev" "include" ([] + ++ optional (zlib != null) zlib + ++ optional langJava boehmgc + ++ optionals javaAwtGtk xlibs + ++ optionals javaAwtGtk [ gmp mpfr ] + )); + + LIBRARY_PATH = optionals (targetPlatform == hostPlatform) (makeLibraryPath ([] + ++ optional (zlib != null) zlib + ++ optional langJava boehmgc + ++ optionals javaAwtGtk xlibs + ++ optionals javaAwtGtk [ gmp mpfr ] + )); + + EXTRA_TARGET_FLAGS = optionals + (targetPlatform != hostPlatform && libcCross != null) + ([ + "-idirafter ${getDev libcCross}${libcCross.incdir or "/include"}" + ] ++ optionals (! crossStageStatic) [ + "-B${libcCross.out}${libcCross.libdir or "/lib"}" + ]); + + EXTRA_TARGET_LDFLAGS = optionals + (targetPlatform != hostPlatform && libcCross != null) + ([ + "-Wl,-L${libcCross.out}${libcCross.libdir or "/lib"}" + ] ++ (if crossStageStatic then [ + "-B${libcCross.out}${libcCross.libdir or "/lib"}" + ] else [ + "-Wl,-rpath,${libcCross.out}${libcCross.libdir or "/lib"}" + "-Wl,-rpath-link,${libcCross.out}${libcCross.libdir or "/lib"}" + ])); + + passthru = { + inherit langC langCC langObjC langObjCpp langFortran langGo version; + isGNU = true; + }; + + enableParallelBuilding = true; + inherit enableMultilib; + + inherit (stdenv) is64bit; + + meta = { + homepage = https://gcc.gnu.org/; + license = stdenv.lib.licenses.gpl3Plus; # runtime support libraries are typically LGPLv3+ + description = "GNU Compiler Collection, version ${version}" + + (if stripped then "" else " (with debugging info)"); + + longDescription = '' + The GNU Compiler Collection includes compiler front ends for C, C++, + Objective-C, Fortran, OpenMP for C/C++/Fortran, Java, and Ada, as well + as libraries for these languages (libstdc++, libgcj, libgomp,...). + + GCC development is a part of the GNU Project, aiming to improve the + compiler used in the GNU system including the GNU/Linux variant. + ''; + + maintainers = with stdenv.lib.maintainers; [ peti ]; + + platforms = + stdenv.lib.platforms.linux ++ + stdenv.lib.platforms.freebsd ++ + stdenv.lib.platforms.illumos ++ + stdenv.lib.platforms.darwin; + }; +} + +// optionalAttrs (targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt" && crossStageStatic) { + makeFlags = [ "all-gcc" "all-target-libgcc" ]; + installTargets = "install-gcc install-target-libgcc"; +} + +// optionalAttrs (enableMultilib) { dontMoveLib64 = true; } + +// optionalAttrs (langJava && !stdenv.hostPlatform.isDarwin) { + postFixup = '' + target="$(echo "$out/libexec/gcc"/*/*/ecj*)" + patchelf --set-rpath "$(patchelf --print-rpath "$target"):$out/lib" "$target" + '';} +) diff --git a/nixpkgs/pkgs/development/compilers/gcc/6/fix-objdump-check.patch b/nixpkgs/pkgs/development/compilers/gcc/6/fix-objdump-check.patch new file mode 100644 index 000000000000..f9adbe9eb1ca --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/gcc/6/fix-objdump-check.patch @@ -0,0 +1,43 @@ +commit 4c38abe0967bad78dd6baa61c86923e4d4b346d3 +Author: Ben Gamari <ben@smart-cactus.org> +Date: Sun Nov 5 13:14:19 2017 -0500 + + Fix it + +diff --git a/config/gcc-plugin.m4 b/config/gcc-plugin.m4 +index dd06a58..f4435b8 100644 +--- a/config/gcc-plugin.m4 ++++ b/config/gcc-plugin.m4 +@@ -13,6 +13,32 @@ dnl the same distribution terms as the rest of that program. + # Sets the shell variables enable_plugin and pluginlibs. + AC_DEFUN([GCC_ENABLE_PLUGINS], + [# Check for plugin support ++ ++ # Figure out what objdump we will be using. ++ AS_VAR_SET_IF(gcc_cv_objdump,, [ ++ if test -f $gcc_cv_binutils_srcdir/configure.ac \ ++ && test -f ../binutils/Makefile \ ++ && test x$build = x$host; then ++ # Single tree build which includes binutils. ++ gcc_cv_objdump=../binutils/objdump$build_exeext ++ elif test -x objdump$build_exeext; then ++ gcc_cv_objdump=./objdump$build_exeext ++ elif ( set dummy $OBJDUMP_FOR_TARGET; test -x $[2] ); then ++ gcc_cv_objdump="$OBJDUMP_FOR_TARGET" ++ else ++ AC_PATH_PROG(gcc_cv_objdump, $OBJDUMP_FOR_TARGET) ++ fi]) ++ ++ AC_MSG_CHECKING(what objdump to use) ++ if test "$gcc_cv_objdump" = ../binutils/objdump$build_exeext; then ++ # Single tree build which includes binutils. ++ AC_MSG_RESULT(newly built objdump) ++ elif test x$gcc_cv_objdump = x; then ++ AC_MSG_RESULT(not found) ++ else ++ AC_MSG_RESULT($gcc_cv_objdump) ++ fi ++ + AC_ARG_ENABLE(plugin, + [AS_HELP_STRING([--enable-plugin], [enable plugin support])], + enable_plugin=$enableval, diff --git a/nixpkgs/pkgs/development/compilers/gcc/7/default.nix b/nixpkgs/pkgs/development/compilers/gcc/7/default.nix new file mode 100644 index 000000000000..68c05d289784 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/gcc/7/default.nix @@ -0,0 +1,404 @@ +{ stdenv, targetPackages, fetchurl, fetchpatch, noSysDirs +, langC ? true, langCC ? true, langFortran ? false +, langObjC ? stdenv.targetPlatform.isDarwin +, langObjCpp ? stdenv.targetPlatform.isDarwin +, langGo ? false +, profiledCompiler ? false +, staticCompiler ? false +, enableShared ? true +, texinfo ? null +, perl ? null # optional, for texi2pod (then pod2man) +, gmp, mpfr, libmpc, gettext, which +, libelf # optional, for link-time optimizations (LTO) +, isl ? null # optional, for the Graphite optimization framework. +, zlib ? null +, enableMultilib ? false +, enablePlugin ? stdenv.hostPlatform == stdenv.buildPlatform # Whether to support user-supplied plug-ins +, name ? "gcc" +, libcCross ? null +, crossStageStatic ? false +, # Strip kills static libs of other archs (hence no cross) + stripped ? stdenv.hostPlatform == stdenv.buildPlatform + && stdenv.targetPlatform == stdenv.hostPlatform +, gnused ? null +, cloog # unused; just for compat with gcc4, as we override the parameter on some places +, buildPackages +}: + +# LTO needs libelf and zlib. +assert libelf != null -> zlib != null; + +# Make sure we get GNU sed. +assert stdenv.hostPlatform.isDarwin -> gnused != null; + +# The go frontend is written in c++ +assert langGo -> langCC; + +with stdenv.lib; +with builtins; + +let version = "7.4.0"; + + inherit (stdenv) buildPlatform hostPlatform targetPlatform; + + patches = + [ # https://gcc.gnu.org/ml/gcc-patches/2018-02/msg00633.html + ./riscv-pthread-reentrant.patch + # https://gcc.gnu.org/ml/gcc-patches/2018-03/msg00297.html + ./riscv-no-relax.patch + ] + ++ optional (targetPlatform != hostPlatform) ../libstdc++-target.patch + ++ optionals targetPlatform.isNetBSD [ + ../libstdc++-netbsd-ctypes.patch + ] + ++ optional noSysDirs ../no-sys-dirs.patch + ++ optional (hostPlatform != buildPlatform) (fetchpatch { # XXX: Refine when this should be applied + url = "https://git.busybox.net/buildroot/plain/package/gcc/7.1.0/0900-remove-selftests.patch?id=11271540bfe6adafbc133caf6b5b902a816f5f02"; + sha256 = "0mrvxsdwip2p3l17dscpc1x8vhdsciqw1z5q9i6p5g9yg1cqnmgs"; + }) + ++ optional langFortran ../gfortran-driving.patch + ++ optional (targetPlatform.libc == "musl" && targetPlatform.isPower) ../ppc-musl.patch + ++ optional (targetPlatform.libc == "musl") ../libgomp-dont-force-initial-exec.patch; + + /* Cross-gcc settings (build == host != target) */ + crossMingw = targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt"; + crossDarwin = targetPlatform != hostPlatform && targetPlatform.libc == "libSystem"; + crossConfigureFlags = + # Ensure that -print-prog-name is able to find the correct programs. + [ "--with-as=${targetPackages.stdenv.cc.bintools}/bin/${targetPlatform.config}-as" + "--with-ld=${targetPackages.stdenv.cc.bintools}/bin/${targetPlatform.config}-ld" ] ++ + (if crossMingw && crossStageStatic then [ + "--with-headers=${getDev libcCross}${libcCross.incdir or "/include"}" + "--with-gcc" + "--with-gnu-as" + "--with-gnu-ld" + "--with-gnu-ld" + "--disable-shared" + "--disable-nls" + "--disable-debug" + "--enable-sjlj-exceptions" + "--enable-threads=win32" + "--disable-win32-registry" + "--disable-libmpx" # requires libc + ] else if crossStageStatic then [ + "--disable-libssp" + "--disable-nls" + "--without-headers" + "--disable-threads" + "--disable-libgomp" + "--disable-libquadmath" + "--disable-shared" + "--disable-libatomic" # requires libc + "--disable-decimal-float" # requires libc + "--disable-libmpx" # requires libc + ] else [ + (if crossDarwin then "--with-sysroot=${getLib libcCross}/share/sysroot" + else "--with-headers=${getDev libcCross}${libcCross.incdir or "/include"}") + "--enable-__cxa_atexit" + "--enable-long-long" + ] ++ + (if crossMingw then [ + "--enable-threads=win32" + "--enable-sjlj-exceptions" + "--enable-hash-synchronization" + "--enable-libssp" + "--disable-nls" + "--with-dwarf2" + # To keep ABI compatibility with upstream mingw-w64 + "--enable-fully-dynamic-string" + ] else + optionals (targetPlatform.libc == "uclibc" || targetPlatform.libc == "musl") [ + # libsanitizer requires netrom/netrom.h which is not + # available in uclibc. + "--disable-libsanitizer" + # In uclibc cases, libgomp needs an additional '-ldl' + # and as I don't know how to pass it, I disable libgomp. + "--disable-libgomp" + # musl at least, disable: https://git.buildroot.net/buildroot/commit/?id=873d4019f7fb00f6a80592224236b3ba7d657865 + "--disable-libmpx" + ] + ++ optional (targetPlatform.libc == "newlib") "--with-newlib" + ++ optional (targetPlatform.libc == "avrlibc") "--with-avrlibc" + ++ [ + "--enable-threads=${if targetPlatform.isUnix then "posix" + else if targetPlatform.isWindows then "win32" + else "single"}" + "--enable-nls" + # No final libdecnumber (it may work only in 386) + "--disable-decimal-float" + ])); + stageNameAddon = if crossStageStatic then "-stage-static" else "-stage-final"; + crossNameAddon = if targetPlatform != hostPlatform then "${targetPlatform.config}${stageNameAddon}-" else ""; + + bootstrap = targetPlatform == hostPlatform; + +in + +stdenv.mkDerivation ({ + name = crossNameAddon + "${name}${if stripped then "" else "-debug"}-${version}"; + + builder = ../builder.sh; + + src = fetchurl { + url = "mirror://gcc/releases/gcc-${version}/gcc-${version}.tar.xz"; + sha256 = "0lgy170b0pp60j9cczqkmaqyjjb584vfamj4c30swd7k0j6y5pgd"; + }; + + inherit patches; + + outputs = [ "out" "lib" "man" "info" ]; + setOutputFlags = false; + NIX_NO_SELF_RPATH = true; + + libc_dev = stdenv.cc.libc_dev; + + hardeningDisable = [ "format" "pie" ]; + + # This should kill all the stdinc frameworks that gcc and friends like to + # insert into default search paths. + prePatch = stdenv.lib.optionalString hostPlatform.isDarwin '' + substituteInPlace gcc/config/darwin-c.c \ + --replace 'if (stdinc)' 'if (0)' + + substituteInPlace libgcc/config/t-slibgcc-darwin \ + --replace "-install_name @shlib_slibdir@/\$(SHLIB_INSTALL_NAME)" "-install_name $lib/lib/\$(SHLIB_INSTALL_NAME)" + + substituteInPlace libgfortran/configure \ + --replace "-install_name \\\$rpath/\\\$soname" "-install_name $lib/lib/\\\$soname" + ''; + + postPatch = '' + configureScripts=$(find . -name configure) + for configureScript in $configureScripts; do + patchShebangs $configureScript + done + '' + ( + if targetPlatform != hostPlatform || stdenv.cc.libc != null then + # On NixOS, use the right path to the dynamic linker instead of + # `/lib/ld*.so'. + let + libc = if libcCross != null then libcCross else stdenv.cc.libc; + in + ( + '' echo "fixing the \`GLIBC_DYNAMIC_LINKER', \`UCLIBC_DYNAMIC_LINKER', and \`MUSL_DYNAMIC_LINKER' macros..." + for header in "gcc/config/"*-gnu.h "gcc/config/"*"/"*.h + do + grep -q _DYNAMIC_LINKER "$header" || continue + echo " fixing \`$header'..." + sed -i "$header" \ + -e 's|define[[:blank:]]*\([UCG]\+\)LIBC_DYNAMIC_LINKER\([0-9]*\)[[:blank:]]"\([^\"]\+\)"$|define \1LIBC_DYNAMIC_LINKER\2 "${libc.out}\3"|g' \ + -e 's|define[[:blank:]]*MUSL_DYNAMIC_LINKER\([0-9]*\)[[:blank:]]"\([^\"]\+\)"$|define MUSL_DYNAMIC_LINKER\1 "${libc.out}\2"|g' + done + '' + + stdenv.lib.optionalString (targetPlatform.libc == "musl") + '' + sed -i gcc/config/linux.h -e '1i#undef LOCAL_INCLUDE_DIR' + '' + ) + else "") + + stdenv.lib.optionalString targetPlatform.isAvr '' + makeFlagsArray+=( + 'LIMITS_H_TEST=false' + ) + ''; + + inherit noSysDirs staticCompiler crossStageStatic + libcCross crossMingw; + + depsBuildBuild = [ buildPackages.stdenv.cc ]; + nativeBuildInputs = [ texinfo which gettext ] + ++ (optional (perl != null) perl); + + # For building runtime libs + depsBuildTarget = + if hostPlatform == buildPlatform then [ + targetPackages.stdenv.cc.bintools # newly-built gcc will be used + ] else assert targetPlatform == hostPlatform; [ # build != host == target + stdenv.cc + ]; + + buildInputs = [ + gmp mpfr libmpc libelf + targetPackages.stdenv.cc.bintools # For linking code at run-time + ] ++ (optional (isl != null) isl) + ++ (optional (zlib != null) zlib) + # The builder relies on GNU sed (for instance, Darwin's `sed' fails with + # "-i may not be used with stdin"), and `stdenvNative' doesn't provide it. + ++ (optional hostPlatform.isDarwin gnused) + ; + + NIX_CFLAGS_COMPILE = stdenv.lib.optionalString (stdenv.cc.isClang && langFortran) "-Wno-unused-command-line-argument"; + NIX_LDFLAGS = stdenv.lib.optionalString hostPlatform.isSunOS "-lm -ldl"; + + preConfigure = stdenv.lib.optionalString (hostPlatform.isSunOS && hostPlatform.is64bit) '' + export NIX_LDFLAGS=`echo $NIX_LDFLAGS | sed -e s~$prefix/lib~$prefix/lib/amd64~g` + export LDFLAGS_FOR_TARGET="-Wl,-rpath,$prefix/lib/amd64 $LDFLAGS_FOR_TARGET" + export CXXFLAGS_FOR_TARGET="-Wl,-rpath,$prefix/lib/amd64 $CXXFLAGS_FOR_TARGET" + export CFLAGS_FOR_TARGET="-Wl,-rpath,$prefix/lib/amd64 $CFLAGS_FOR_TARGET" + ''; + + dontDisableStatic = true; + + # TODO(@Ericson2314): Always pass "--target" and always prefix. + configurePlatforms = [ "build" "host" ] ++ stdenv.lib.optional (targetPlatform != hostPlatform) "target"; + + configureFlags = + # Basic dependencies + [ + "--with-gmp-include=${gmp.dev}/include" + "--with-gmp-lib=${gmp.out}/lib" + "--with-mpfr-include=${mpfr.dev}/include" + "--with-mpfr-lib=${mpfr.out}/lib" + "--with-mpc=${libmpc}" + ] ++ + optional (libelf != null) "--with-libelf=${libelf}" ++ + optional (!(crossMingw && crossStageStatic)) + "--with-native-system-header-dir=${getDev stdenv.cc.libc}/include" ++ + + # Basic configuration + [ + "--enable-lto" + "--disable-libstdcxx-pch" + "--without-included-gettext" + "--with-system-zlib" + "--enable-static" + "--enable-languages=${ + concatStrings (intersperse "," + ( optional langC "c" + ++ optional langCC "c++" + ++ optional langFortran "fortran" + ++ optional langGo "go" + ++ optional langObjC "objc" + ++ optional langObjCpp "obj-c++" + ++ optionals crossDarwin [ "objc" "obj-c++" ] + ) + ) + }" + ] ++ + + (if (enableMultilib || targetPlatform.isAvr) + then ["--enable-multilib" "--disable-libquadmath"] + else ["--disable-multilib"]) ++ + optional (!enableShared) "--disable-shared" ++ + (if enablePlugin + then ["--enable-plugin"] + else ["--disable-plugin"]) ++ + + # Optional features + optional (isl != null) "--with-isl=${isl}" ++ + + (import ../common/platform-flags.nix { inherit (stdenv) lib targetPlatform; }) ++ + optional (targetPlatform != hostPlatform) crossConfigureFlags ++ + optional (!bootstrap) "--disable-bootstrap" ++ + + # Platform-specific flags + optional (targetPlatform == hostPlatform && targetPlatform.isx86_32) "--with-arch=${stdenv.hostPlatform.parsed.cpu.name}" ++ + optionals hostPlatform.isSunOS [ + "--enable-long-long" "--enable-libssp" "--enable-threads=posix" "--disable-nls" "--enable-__cxa_atexit" + # On Illumos/Solaris GNU as is preferred + "--with-gnu-as" "--without-gnu-ld" + ] + ++ optionals (targetPlatform == hostPlatform && targetPlatform.libc == "musl") [ + "--disable-libsanitizer" + "--disable-symvers" + "libat_cv_have_ifunc=no" + "--disable-gnu-indirect-function" + ] + ++ optional (targetPlatform.isAarch64) "--enable-fix-cortex-a53-843419" + ++ optional targetPlatform.isNetBSD "--disable-libcilkrts" + ; + + targetConfig = if targetPlatform != hostPlatform then targetPlatform.config else null; + + buildFlags = optional + (bootstrap && hostPlatform == buildPlatform) + (if profiledCompiler then "profiledbootstrap" else "bootstrap"); + + dontStrip = !stripped; + + doCheck = false; # requires a lot of tools, causes a dependency cycle for stdenv + + installTargets = + if stripped + then "install-strip" + else "install"; + + # https://gcc.gnu.org/install/specific.html#x86-64-x-solaris210 + ${if hostPlatform.system == "x86_64-solaris" then "CC" else null} = "gcc -m64"; + + # Setting $CPATH and $LIBRARY_PATH to make sure both `gcc' and `xgcc' find the + # library headers and binaries, regarless of the language being compiled. + # + # Likewise, the LTO code doesn't find zlib. + # + # Cross-compiling, we need gcc not to read ./specs in order to build the g++ + # compiler (after the specs for the cross-gcc are created). Having + # LIBRARY_PATH= makes gcc read the specs from ., and the build breaks. + + CPATH = optionals (targetPlatform == hostPlatform) (makeSearchPathOutput "dev" "include" ([] + ++ optional (zlib != null) zlib + )); + + LIBRARY_PATH = optionals (targetPlatform == hostPlatform) (makeLibraryPath (optional (zlib != null) zlib)); + + EXTRA_TARGET_FLAGS = optionals + (targetPlatform != hostPlatform && libcCross != null) + ([ + "-idirafter ${getDev libcCross}${libcCross.incdir or "/include"}" + ] ++ optionals (! crossStageStatic) [ + "-B${libcCross.out}${libcCross.libdir or "/lib"}" + ]); + + EXTRA_TARGET_LDFLAGS = optionals + (targetPlatform != hostPlatform && libcCross != null) + ([ + "-Wl,-L${libcCross.out}${libcCross.libdir or "/lib"}" + ] ++ (if crossStageStatic then [ + "-B${libcCross.out}${libcCross.libdir or "/lib"}" + ] else [ + "-Wl,-rpath,${libcCross.out}${libcCross.libdir or "/lib"}" + "-Wl,-rpath-link,${libcCross.out}${libcCross.libdir or "/lib"}" + ])); + + passthru = { + inherit langC langCC langObjC langObjCpp langFortran langGo version; + isGNU = true; + }; + + enableParallelBuilding = true; + inherit enableMultilib; + + inherit (stdenv) is64bit; + + meta = { + homepage = https://gcc.gnu.org/; + license = stdenv.lib.licenses.gpl3Plus; # runtime support libraries are typically LGPLv3+ + description = "GNU Compiler Collection, version ${version}" + + (if stripped then "" else " (with debugging info)"); + + longDescription = '' + The GNU Compiler Collection includes compiler front ends for C, C++, + Objective-C, Fortran, OpenMP for C/C++/Fortran, and Ada, as well as + libraries for these languages (libstdc++, libgomp,...). + + GCC development is a part of the GNU Project, aiming to improve the + compiler used in the GNU system including the GNU/Linux variant. + ''; + + maintainers = with stdenv.lib.maintainers; [ ]; + + platforms = + stdenv.lib.platforms.linux ++ + stdenv.lib.platforms.freebsd ++ + stdenv.lib.platforms.illumos ++ + stdenv.lib.platforms.darwin; + }; +} + +// optionalAttrs (targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt" && crossStageStatic) { + makeFlags = [ "all-gcc" "all-target-libgcc" ]; + installTargets = "install-gcc install-target-libgcc"; +} + +// optionalAttrs (enableMultilib) { dontMoveLib64 = true; } +) diff --git a/nixpkgs/pkgs/development/compilers/gcc/7/riscv-no-relax.patch b/nixpkgs/pkgs/development/compilers/gcc/7/riscv-no-relax.patch new file mode 100644 index 000000000000..93d9cd1d60f5 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/gcc/7/riscv-no-relax.patch @@ -0,0 +1,109 @@ +commit e7c570f37384d824cb9725f237920e9691e57269 +gpg: Signature made Tue 06 Mar 2018 04:52:46 PM PST +gpg: using RSA key 00CE76D1834960DFCE886DF8EF4CA1502CCBAB41 +gpg: issuer "palmer@dabbelt.com" +gpg: Good signature from "Palmer Dabbelt <palmer@dabbelt.com>" [ultimate] +gpg: aka "Palmer Dabbelt <palmer@sifive.com>" [ultimate] +Author: Palmer Dabbelt <palmer@sifive.com> +Date: Thu Mar 1 12:01:06 2018 -0800 + + RISC-V: Add and document the "-mno-relax" option + + RISC-V relies on aggressive linker relaxation to get good code size. As + a result no text symbol addresses can be known until link time, which + means that alignment must be handled during the link. This alignment + pass is essentially just another linker relaxation, so this has the + unfortunate side effect that linker relaxation is required for + correctness on many RISC-V targets. + + The RISC-V assembler has supported an ".option norelax" for a long time + because there are situations in which linker relaxation is a bad idea -- + the canonical example is when trying to materialize the initial value of + the global pointer into a register, which would otherwise be relaxed to + a NOP. We've been relying on users who want to disable relaxation for + an entire link to pass "-Wl,--no-relax", but that still relies on the + linker relaxing R_RISCV_ALIGN to handle alignment despite it not being + strictly necessary. + + This patch adds a GCC option, "-mno-relax", that disable linker + relaxation by adding ".option norelax" to the top of every generated + assembly file. The assembler is smart enough to handle alignment at + assemble time for files that have never emitted a relaxable relocation, + so this is sufficient to really disable all relaxations in the linker, + which results in significantly faster link times for large objects. + + This also has the side effect of allowing toolchains that don't support + linker relaxation (LLVM and the Linux module loader) to function + correctly. Toolchains that don't support linker relaxation should + default to "-mno-relax" and error when presented with any R_RISCV_ALIGN + relocation as those need to be handled for correctness. + + gcc/ChangeLog + + 2018-03-01 Palmer Dabbelt <palmer@sifive.com> + + * config/riscv/riscv.opt (mrelax): New option. + * config/riscv/riscv.c (riscv_file_start): Emit ".option + "norelax" when riscv_mrelax is disabled. + * doc/invoke.texi (RISC-V): Document "-mrelax" and "-mno-relax". + +diff --git a/gcc/config/riscv/riscv.c b/gcc/config/riscv/riscv.c +index c38f6c394d54..3e81874de232 100644 +--- a/gcc/config/riscv/riscv.c ++++ b/gcc/config/riscv/riscv.c +@@ -3979,6 +3979,11 @@ riscv_file_start (void) + + /* Instruct GAS to generate position-[in]dependent code. */ + fprintf (asm_out_file, "\t.option %spic\n", (flag_pic ? "" : "no")); ++ ++ /* If the user specifies "-mno-relax" on the command line then disable linker ++ relaxation in the assembler. */ ++ if (! riscv_mrelax) ++ fprintf (asm_out_file, "\t.option norelax\n"); + } + + /* Implement TARGET_ASM_OUTPUT_MI_THUNK. Generate rtl rather than asm text +diff --git a/gcc/config/riscv/riscv.opt b/gcc/config/riscv/riscv.opt +index 581a26bb5c1e..b37ac75d9bb4 100644 +--- a/gcc/config/riscv/riscv.opt ++++ b/gcc/config/riscv/riscv.opt +@@ -106,6 +106,11 @@ mexplicit-relocs + Target Report Mask(EXPLICIT_RELOCS) + Use %reloc() operators, rather than assembly macros, to load addresses. + ++mrelax ++Target Bool Var(riscv_mrelax) Init(1) ++Take advantage of linker relaxations to reduce the number of instructions ++required to materialize symbol addresses. ++ + Mask(64BIT) + + Mask(MUL) +diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi +index 8d366c626bae..deb48af2ecad 100644 +--- a/gcc/doc/invoke.texi ++++ b/gcc/doc/invoke.texi +@@ -1042,7 +1042,8 @@ See RS/6000 and PowerPC Options. + -msave-restore -mno-save-restore @gol + -mstrict-align -mno-strict-align @gol + -mcmodel=medlow -mcmodel=medany @gol +--mexplicit-relocs -mno-explicit-relocs @gol} ++-mexplicit-relocs -mno-explicit-relocs @gol ++-mrelax -mno-relax @gol} + + @emph{RL78 Options} + @gccoptlist{-msim -mmul=none -mmul=g13 -mmul=g14 -mallregs @gol +@@ -23102,6 +23103,12 @@ Use or do not use assembler relocation operators when dealing with symbolic + addresses. The alternative is to use assembler macros instead, which may + limit optimization. + ++@item -mrelax ++@itemx -mno-relax ++Take advantage of linker relaxations to reduce the number of instructions ++required to materialize symbol addresses. The default is to take advantage of ++linker relaxations. ++ + @end table + + @node RL78 Options + diff --git a/nixpkgs/pkgs/development/compilers/gcc/7/riscv-pthread-reentrant.patch b/nixpkgs/pkgs/development/compilers/gcc/7/riscv-pthread-reentrant.patch new file mode 100644 index 000000000000..c7527ffb2b16 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/gcc/7/riscv-pthread-reentrant.patch @@ -0,0 +1,13 @@ +Index: gcc/config/riscv/linux.h +=================================================================== +--- a/gcc/config/riscv/linux.h (revision 257620) ++++ b/gcc/config/riscv/linux.h (revision 257621) +@@ -47,6 +47,8 @@ + + #define ICACHE_FLUSH_FUNC "__riscv_flush_icache" + ++#define CPP_SPEC "%{pthread:-D_REENTRANT}" ++ + #define LINK_SPEC "\ + -melf" XLEN_SPEC "lriscv \ + %{shared} \ diff --git a/nixpkgs/pkgs/development/compilers/gcc/8/default.nix b/nixpkgs/pkgs/development/compilers/gcc/8/default.nix new file mode 100644 index 000000000000..f5572c077f31 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/gcc/8/default.nix @@ -0,0 +1,385 @@ +{ stdenv, targetPackages, fetchurl, noSysDirs +, langC ? true, langCC ? true, langFortran ? false +, langObjC ? stdenv.targetPlatform.isDarwin +, langObjCpp ? stdenv.targetPlatform.isDarwin +, langGo ? false +, profiledCompiler ? false +, staticCompiler ? false +, enableShared ? true +, texinfo ? null +, perl ? null # optional, for texi2pod (then pod2man) +, gmp, mpfr, libmpc, gettext, which +, libelf # optional, for link-time optimizations (LTO) +, isl ? null # optional, for the Graphite optimization framework. +, zlib ? null +, enableMultilib ? false +, enablePlugin ? stdenv.hostPlatform == stdenv.buildPlatform # Whether to support user-supplied plug-ins +, name ? "gcc" +, libcCross ? null +, crossStageStatic ? false +, # Strip kills static libs of other archs (hence no cross) + stripped ? stdenv.hostPlatform == stdenv.buildPlatform + && stdenv.targetPlatform == stdenv.hostPlatform +, gnused ? null +, cloog # unused; just for compat with gcc4, as we override the parameter on some places +, buildPackages +}: + +# LTO needs libelf and zlib. +assert libelf != null -> zlib != null; + +# Make sure we get GNU sed. +assert stdenv.hostPlatform.isDarwin -> gnused != null; + +# The go frontend is written in c++ +assert langGo -> langCC; + +with stdenv.lib; +with builtins; + +let version = "8.3.0"; + + inherit (stdenv) buildPlatform hostPlatform targetPlatform; + + patches = + optional (targetPlatform != hostPlatform) ../libstdc++-target.patch + ++ optional noSysDirs ../no-sys-dirs.patch + /* ++ optional (hostPlatform != buildPlatform) (fetchpatch { # XXX: Refine when this should be applied + url = "https://git.busybox.net/buildroot/plain/package/gcc/${version}/0900-remove-selftests.patch?id=11271540bfe6adafbc133caf6b5b902a816f5f02"; + sha256 = ""; # TODO: uncomment and check hash when available. + }) */ + ++ optional langFortran ../gfortran-driving.patch + ++ optional (targetPlatform.libc == "musl" && targetPlatform.isPower) ../ppc-musl.patch + ++ optional (targetPlatform.libc == "musl") ../libgomp-dont-force-initial-exec.patch; + + /* Cross-gcc settings (build == host != target) */ + crossMingw = targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt"; + crossDarwin = targetPlatform != hostPlatform && targetPlatform.libc == "libSystem"; + crossConfigureFlags = + # Ensure that -print-prog-name is able to find the correct programs. + [ "--with-as=${targetPackages.stdenv.cc.bintools}/bin/${targetPlatform.config}-as" + "--with-ld=${targetPackages.stdenv.cc.bintools}/bin/${targetPlatform.config}-ld" ] ++ + (if crossMingw && crossStageStatic then [ + "--with-headers=${libcCross}/include" + "--with-gcc" + "--with-gnu-as" + "--with-gnu-ld" + "--with-gnu-ld" + "--disable-shared" + "--disable-nls" + "--disable-debug" + "--enable-sjlj-exceptions" + "--enable-threads=win32" + "--disable-win32-registry" + "--disable-libmpx" # requires libc + ] else if crossStageStatic then [ + "--disable-libssp" + "--disable-nls" + "--without-headers" + "--disable-threads" + "--disable-libgomp" + "--disable-libquadmath" + "--disable-shared" + "--disable-libatomic" # requires libc + "--disable-decimal-float" # requires libc + "--disable-libmpx" # requires libc + ] else [ + (if crossDarwin then "--with-sysroot=${getLib libcCross}/share/sysroot" + else "--with-headers=${getDev libcCross}${libcCross.incdir or "/include"}") + "--enable-__cxa_atexit" + "--enable-long-long" + ] ++ + (if crossMingw then [ + "--enable-threads=win32" + "--enable-sjlj-exceptions" + "--enable-hash-synchronization" + "--enable-libssp" + "--disable-nls" + "--with-dwarf2" + # To keep ABI compatibility with upstream mingw-w64 + "--enable-fully-dynamic-string" + ] else + optionals (targetPlatform.libc == "uclibc" || targetPlatform.libc == "musl") [ + # libsanitizer requires netrom/netrom.h which is not + # available in uclibc. + "--disable-libsanitizer" + # In uclibc cases, libgomp needs an additional '-ldl' + # and as I don't know how to pass it, I disable libgomp. + "--disable-libgomp" + # musl at least, disable: https://git.buildroot.net/buildroot/commit/?id=873d4019f7fb00f6a80592224236b3ba7d657865 + "--disable-libmpx" + ] + ++ optional (targetPlatform.libc == "newlib") "--with-newlib" + ++ optional (targetPlatform.libc == "avrlibc") "--with-avrlibc" + ++ [ + "--enable-threads=${if targetPlatform.isUnix then "posix" + else if targetPlatform.isWindows then "win32" + else "single"}" + "--enable-nls" + "--disable-decimal-float" # No final libdecnumber (it may work only in 386) + ])); + stageNameAddon = if crossStageStatic then "-stage-static" else "-stage-final"; + crossNameAddon = if targetPlatform != hostPlatform then "-${targetPlatform.config}" + stageNameAddon else ""; + + bootstrap = targetPlatform == hostPlatform; + +in + +stdenv.mkDerivation ({ + name = "${name}${if stripped then "" else "-debug"}-${version}" + crossNameAddon; + + builder = ../builder.sh; + + src = fetchurl { + url = "mirror://gcc/releases/gcc-${version}/gcc-${version}.tar.xz"; + sha256 = "0b3xv411xhlnjmin2979nxcbnidgvzqdf4nbhix99x60dkzavfk4"; + }; + + inherit patches; + + outputs = [ "out" "lib" "man" "info" ]; + setOutputFlags = false; + NIX_NO_SELF_RPATH = true; + + libc_dev = stdenv.cc.libc_dev; + + hardeningDisable = [ "format" "pie" ]; + + # This should kill all the stdinc frameworks that gcc and friends like to + # insert into default search paths. + prePatch = stdenv.lib.optionalString hostPlatform.isDarwin '' + substituteInPlace gcc/config/darwin-c.c \ + --replace 'if (stdinc)' 'if (0)' + + substituteInPlace libgcc/config/t-slibgcc-darwin \ + --replace "-install_name @shlib_slibdir@/\$(SHLIB_INSTALL_NAME)" "-install_name $lib/lib/\$(SHLIB_INSTALL_NAME)" + + substituteInPlace libgfortran/configure \ + --replace "-install_name \\\$rpath/\\\$soname" "-install_name $lib/lib/\\\$soname" + ''; + + postPatch = '' + configureScripts=$(find . -name configure) + for configureScript in $configureScripts; do + patchShebangs $configureScript + done + '' + ( + if targetPlatform != hostPlatform || stdenv.cc.libc != null then + # On NixOS, use the right path to the dynamic linker instead of + # `/lib/ld*.so'. + let + libc = if libcCross != null then libcCross else stdenv.cc.libc; + in + ( + '' echo "fixing the \`GLIBC_DYNAMIC_LINKER', \`UCLIBC_DYNAMIC_LINKER', and \`MUSL_DYNAMIC_LINKER' macros..." + for header in "gcc/config/"*-gnu.h "gcc/config/"*"/"*.h + do + grep -q _DYNAMIC_LINKER "$header" || continue + echo " fixing \`$header'..." + sed -i "$header" \ + -e 's|define[[:blank:]]*\([UCG]\+\)LIBC_DYNAMIC_LINKER\([0-9]*\)[[:blank:]]"\([^\"]\+\)"$|define \1LIBC_DYNAMIC_LINKER\2 "${libc.out}\3"|g' \ + -e 's|define[[:blank:]]*MUSL_DYNAMIC_LINKER\([0-9]*\)[[:blank:]]"\([^\"]\+\)"$|define MUSL_DYNAMIC_LINKER\1 "${libc.out}\2"|g' + done + '' + + stdenv.lib.optionalString (targetPlatform.libc == "musl") + '' + sed -i gcc/config/linux.h -e '1i#undef LOCAL_INCLUDE_DIR' + '' + ) + else ""); + + inherit noSysDirs staticCompiler crossStageStatic + libcCross crossMingw; + + depsBuildBuild = [ buildPackages.stdenv.cc ]; + nativeBuildInputs = [ texinfo which gettext ] + ++ (optional (perl != null) perl); + + # For building runtime libs + depsBuildTarget = + if hostPlatform == buildPlatform then [ + targetPackages.stdenv.cc.bintools # newly-built gcc will be used + ] else assert targetPlatform == hostPlatform; [ # build != host == target + stdenv.cc + ]; + + buildInputs = [ + gmp mpfr libmpc libelf + targetPackages.stdenv.cc.bintools # For linking code at run-time + ] ++ (optional (isl != null) isl) + ++ (optional (zlib != null) zlib) + # The builder relies on GNU sed (for instance, Darwin's `sed' fails with + # "-i may not be used with stdin"), and `stdenvNative' doesn't provide it. + ++ (optional hostPlatform.isDarwin gnused) + ; + + NIX_LDFLAGS = stdenv.lib.optionalString hostPlatform.isSunOS "-lm -ldl"; + + preConfigure = stdenv.lib.optionalString (hostPlatform.isSunOS && hostPlatform.is64bit) '' + export NIX_LDFLAGS=`echo $NIX_LDFLAGS | sed -e s~$prefix/lib~$prefix/lib/amd64~g` + export LDFLAGS_FOR_TARGET="-Wl,-rpath,$prefix/lib/amd64 $LDFLAGS_FOR_TARGET" + export CXXFLAGS_FOR_TARGET="-Wl,-rpath,$prefix/lib/amd64 $CXXFLAGS_FOR_TARGET" + export CFLAGS_FOR_TARGET="-Wl,-rpath,$prefix/lib/amd64 $CFLAGS_FOR_TARGET" + ''; + + dontDisableStatic = true; + + # TODO(@Ericson2314): Always pass "--target" and always prefix. + configurePlatforms = [ "build" "host" ] ++ stdenv.lib.optional (targetPlatform != hostPlatform) "target"; + + configureFlags = + # Basic dependencies + [ + "--with-gmp-include=${gmp.dev}/include" + "--with-gmp-lib=${gmp.out}/lib" + "--with-mpfr-include=${mpfr.dev}/include" + "--with-mpfr-lib=${mpfr.out}/lib" + "--with-mpc=${libmpc}" + ] ++ + optional (libelf != null) "--with-libelf=${libelf}" ++ + optional (!(crossMingw && crossStageStatic)) + "--with-native-system-header-dir=${getDev stdenv.cc.libc}/include" ++ + + # Basic configuration + [ + "--enable-lto" + "--disable-libstdcxx-pch" + "--without-included-gettext" + "--with-system-zlib" + "--enable-static" + "--enable-languages=${ + concatStrings (intersperse "," + ( optional langC "c" + ++ optional langCC "c++" + ++ optional langFortran "fortran" + ++ optional langGo "go" + ++ optional langObjC "objc" + ++ optional langObjCpp "obj-c++" + ++ optionals crossDarwin [ "objc" "obj-c++" ] + ) + ) + }" + ] ++ + + (if (enableMultilib || targetPlatform.isAvr) + then ["--enable-multilib" "--disable-libquadmath"] + else ["--disable-multilib"]) ++ + optional (!enableShared) "--disable-shared" ++ + (if enablePlugin + then ["--enable-plugin"] + else ["--disable-plugin"]) ++ + + # Optional features + optional (isl != null) "--with-isl=${isl}" ++ + + (import ../common/platform-flags.nix { inherit (stdenv) lib targetPlatform; }) ++ + optional (targetPlatform != hostPlatform) crossConfigureFlags ++ + optional (!bootstrap) "--disable-bootstrap" ++ + + # Platform-specific flags + optional (targetPlatform == hostPlatform && targetPlatform.isx86_32) "--with-arch=${stdenv.hostPlatform.parsed.cpu.name}" ++ + optionals hostPlatform.isSunOS [ + "--enable-long-long" "--enable-libssp" "--enable-threads=posix" "--disable-nls" "--enable-__cxa_atexit" + # On Illumos/Solaris GNU as is preferred + "--with-gnu-as" "--without-gnu-ld" + ] + ++ optionals (targetPlatform == hostPlatform && targetPlatform.libc == "musl") [ + "--disable-libsanitizer" + "--disable-symvers" + "libat_cv_have_ifunc=no" + "--disable-gnu-indirect-function" + ] + ; + + targetConfig = if targetPlatform != hostPlatform then targetPlatform.config else null; + + buildFlags = optional + (bootstrap && hostPlatform == buildPlatform) + (if profiledCompiler then "profiledbootstrap" else "bootstrap"); + + dontStrip = !stripped; + + installTargets = + if stripped + then "install-strip" + else "install"; + + # https://gcc.gnu.org/install/specific.html#x86-64-x-solaris210 + ${if hostPlatform.system == "x86_64-solaris" then "CC" else null} = "gcc -m64"; + + # Setting $CPATH and $LIBRARY_PATH to make sure both `gcc' and `xgcc' find the + # library headers and binaries, regarless of the language being compiled. + # + # Likewise, the LTO code doesn't find zlib. + # + # Cross-compiling, we need gcc not to read ./specs in order to build the g++ + # compiler (after the specs for the cross-gcc are created). Having + # LIBRARY_PATH= makes gcc read the specs from ., and the build breaks. + + CPATH = optionals (targetPlatform == hostPlatform) (makeSearchPathOutput "dev" "include" ([] + ++ optional (zlib != null) zlib + )); + + LIBRARY_PATH = optionals (targetPlatform == hostPlatform) (makeLibraryPath (optional (zlib != null) zlib)); + + EXTRA_TARGET_FLAGS = optionals + (targetPlatform != hostPlatform && libcCross != null) + ([ + "-idirafter ${getDev libcCross}${libcCross.incdir or "/include"}" + ] ++ optionals (! crossStageStatic) [ + "-B${libcCross.out}${libcCross.libdir or "/lib"}" + ]); + + EXTRA_TARGET_LDFLAGS = optionals + (targetPlatform != hostPlatform && libcCross != null) + ([ + "-Wl,-L${libcCross.out}${libcCross.libdir or "/lib"}" + ] ++ (if crossStageStatic then [ + "-B${libcCross.out}${libcCross.libdir or "/lib"}" + ] else [ + "-Wl,-rpath,${libcCross.out}${libcCross.libdir or "/lib"}" + "-Wl,-rpath-link,${libcCross.out}${libcCross.libdir or "/lib"}" + ])); + + passthru = { + inherit langC langCC langObjC langObjCpp langFortran langGo version; + isGNU = true; + }; + + enableParallelBuilding = true; + inherit enableMultilib; + + inherit (stdenv) is64bit; + + meta = { + homepage = https://gcc.gnu.org/; + license = stdenv.lib.licenses.gpl3Plus; # runtime support libraries are typically LGPLv3+ + description = "GNU Compiler Collection, version ${version}" + + (if stripped then "" else " (with debugging info)"); + + longDescription = '' + The GNU Compiler Collection includes compiler front ends for C, C++, + Objective-C, Fortran, OpenMP for C/C++/Fortran, and Ada, as well as + libraries for these languages (libstdc++, libgomp,...). + + GCC development is a part of the GNU Project, aiming to improve the + compiler used in the GNU system including the GNU/Linux variant. + ''; + + maintainers = with stdenv.lib.maintainers; [ synthetica ]; + + platforms = + stdenv.lib.platforms.linux ++ + stdenv.lib.platforms.freebsd ++ + stdenv.lib.platforms.illumos ++ + stdenv.lib.platforms.darwin; + }; +} + +// optionalAttrs (targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt" && crossStageStatic) { + makeFlags = [ "all-gcc" "all-target-libgcc" ]; + installTargets = "install-gcc install-target-libgcc"; +} + +// optionalAttrs (enableMultilib) { dontMoveLib64 = true; } +) diff --git a/nixpkgs/pkgs/development/compilers/gcc/builder.sh b/nixpkgs/pkgs/development/compilers/gcc/builder.sh new file mode 100644 index 000000000000..07a003691d6b --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/gcc/builder.sh @@ -0,0 +1,289 @@ +source $stdenv/setup + + +oldOpts="$(shopt -po nounset)" || true +set -euo pipefail + + +export NIX_FIXINC_DUMMY="$NIX_BUILD_TOP/dummy" +mkdir "$NIX_FIXINC_DUMMY" + + +if test "$staticCompiler" = "1"; then + EXTRA_LDFLAGS="-static" +else + EXTRA_LDFLAGS="-Wl,-rpath,${!outputLib}/lib" +fi + + +# GCC interprets empty paths as ".", which we don't want. +if test -z "${CPATH-}"; then unset CPATH; fi +if test -z "${LIBRARY_PATH-}"; then unset LIBRARY_PATH; fi +echo "\$CPATH is \`${CPATH-}'" +echo "\$LIBRARY_PATH is \`${LIBRARY_PATH-}'" + +if test "$noSysDirs" = "1"; then + + declare \ + EXTRA_BUILD_FLAGS EXTRA_FLAGS EXTRA_TARGET_FLAGS \ + EXTRA_BUILD_LDFLAGS EXTRA_TARGET_LDFLAGS + + # Extract flags from Bintools Wrappers + for pre in 'BUILD_' ''; do + curBintools="NIX_${pre}BINTOOLS" + + declare -a extraLDFlags=() + if [[ -e "${!curBintools}/nix-support/orig-libc" ]]; then + # Figure out what extra flags when linking to pass to the gcc + # compilers being generated to make sure that they use our libc. + extraLDFlags=($(< "${!curBintools}/nix-support/libc-ldflags") $(< "${!curBintools}/nix-support/libc-ldflags-before" || true)) + + # The path to the Libc binaries such as `crti.o'. + libc_libdir="$(< "${!curBintools}/nix-support/orig-libc")/lib" + else + # Hack: support impure environments. + extraLDFlags=("-L/usr/lib64" "-L/usr/lib") + libc_libdir="/usr/lib" + fi + extraLDFlags=("-L$libc_libdir" "-rpath" "$libc_libdir" + "${extraLDFlags[@]}") + for i in "${extraLDFlags[@]}"; do + declare EXTRA_${pre}LDFLAGS+=" -Wl,$i" + done + done + + # Extract flags from CC Wrappers + for pre in 'BUILD_' ''; do + curCC="NIX_${pre}CC" + curFIXINC="NIX_${pre}FIXINC_DUMMY" + + declare -a extraFlags=() + if [[ -e "${!curCC}/nix-support/orig-libc" ]]; then + # Figure out what extra compiling flags to pass to the gcc compilers + # being generated to make sure that they use our libc. + extraFlags=($(< "${!curCC}/nix-support/libc-cflags")) + + # The path to the Libc headers + libc_devdir="$(< "${!curCC}/nix-support/orig-libc-dev")" + + # Use *real* header files, otherwise a limits.h is generated that + # does not include Libc's limits.h (notably missing SSIZE_MAX, + # which breaks the build). + declare NIX_${pre}FIXINC_DUMMY="$libc_devdir/include" + else + # Hack: support impure environments. + extraFlags=("-isystem" "/usr/include") + declare NIX_${pre}FIXINC_DUMMY=/usr/include + fi + + extraFlags=("-I${!curFIXINC}" "${extraFlags[@]}") + + # BOOT_CFLAGS defaults to `-g -O2'; since we override it below, make + # sure to explictly add them so that files compiled with the bootstrap + # compiler are optimized and (optionally) contain debugging information + # (info "(gccinstall) Building"). + if test -n "${dontStrip-}"; then + extraFlags=("-O2" "-g" "${extraFlags[@]}") + else + # Don't pass `-g' at all; this saves space while building. + extraFlags=("-O2" "${extraFlags[@]}") + fi + + declare EXTRA_${pre}FLAGS="${extraFlags[*]}" + done + + if test -z "${targetConfig-}"; then + # host = target, so the flags are the same + EXTRA_TARGET_FLAGS="$EXTRA_FLAGS" + EXTRA_TARGET_LDFLAGS="$EXTRA_LDFLAGS" + fi + + # CFLAGS_FOR_TARGET are needed for the libstdc++ configure script to find + # the startfiles. + # FLAGS_FOR_TARGET are needed for the target libraries to receive the -Bxxx + # for the startfiles. + makeFlagsArray+=( + "BUILD_SYSTEM_HEADER_DIR=$NIX_BUILD_FIXINC_DUMMY" + "SYSTEM_HEADER_DIR=$NIX_BUILD_FIXINC_DUMMY" + "NATIVE_SYSTEM_HEADER_DIR=$NIX_FIXINC_DUMMY" + + "LDFLAGS_FOR_BUILD=$EXTRA_BUILD_LDFLAGS" + #"LDFLAGS=$EXTRA_LDFLAGS" + "LDFLAGS_FOR_TARGET=$EXTRA_TARGET_LDFLAGS" + + "CFLAGS_FOR_BUILD=$EXTRA_BUILD_FLAGS $EXTRA_BUILD_LDFLAGS" + "CXXFLAGS_FOR_BUILD=$EXTRA_BUILD_FLAGS $EXTRA_BUILD_LDFLAGS" + "FLAGS_FOR_BUILD=$EXTRA_BUILD_FLAGS $EXTRA_BUILD_LDFLAGS" + + # It seems there is a bug in GCC 5 + #"CFLAGS=$EXTRA_FLAGS $EXTRA_LDFLAGS" + #"CXXFLAGS=$EXTRA_FLAGS $EXTRA_LDFLAGS" + + "CFLAGS_FOR_TARGET=$EXTRA_TARGET_FLAGS $EXTRA_TARGET_LDFLAGS" + "CXXFLAGS_FOR_TARGET=$EXTRA_TARGET_FLAGS $EXTRA_TARGET_LDFLAGS" + "FLAGS_FOR_TARGET=$EXTRA_TARGET_FLAGS $EXTRA_TARGET_LDFLAGS" + ) + + if test -z "${targetConfig-}"; then + makeFlagsArray+=( + "BOOT_CFLAGS=$EXTRA_FLAGS $EXTRA_LDFLAGS" + "BOOT_LDFLAGS=$EXTRA_TARGET_FLAGS $EXTRA_TARGET_LDFLAGS" + ) + fi + + if test "$crossStageStatic" == 1; then + # We don't want the gcc build to assume there will be a libc providing + # limits.h in this stagae + makeFlagsArray+=( + 'LIMITS_H_TEST=false' + ) + else + makeFlagsArray+=( + 'LIMITS_H_TEST=true' + ) + fi +fi + +if test -n "${targetConfig-}"; then + # The host strip will destroy some important details of the objects + dontStrip=1 +fi + +eval "$oldOpts" + +providedPreConfigure="$preConfigure"; +preConfigure() { + if test -n "$newlibSrc"; then + tar xvf "$newlibSrc" -C .. + ln -s ../newlib-*/newlib newlib + # Patch to get armvt5el working: + sed -i -e 's/ arm)/ arm*)/' newlib/configure.host + fi + + # Bug - they packaged zlib + if test -d "zlib"; then + # This breaks the build without-headers, which should build only + # the target libgcc as target libraries. + # See 'configure:5370' + rm -Rf zlib + fi + + if test -f "$NIX_CC/nix-support/orig-libc"; then + # Patch the configure script so it finds glibc headers. It's + # important for example in order not to get libssp built, + # because its functionality is in glibc already. + sed -i \ + -e "s,glibc_header_dir=/usr/include,glibc_header_dir=$libc_dev/include", \ + gcc/configure + fi + + if test -n "$crossMingw" -a -n "$crossStageStatic"; then + mkdir -p ../mingw + # --with-build-sysroot expects that: + cp -R $libcCross/include ../mingw + configureFlags="$configureFlags --with-build-sysroot=`pwd`/.." + fi + + # Eval the preConfigure script from nix expression. + eval "$providedPreConfigure" + + # Perform the build in a different directory. + mkdir ../build + cd ../build + configureScript=../$sourceRoot/configure +} + + +postConfigure() { + # Don't store the configure flags in the resulting executables. + sed -e '/TOPLEVEL_CONFIGURE_ARGUMENTS=/d' -i Makefile +} + + +preInstall() { + # Make ‘lib64’ symlinks to ‘lib’. + if [ -n "$is64bit" -a -z "$enableMultilib" ]; then + mkdir -p "$out/lib" + ln -s lib "$out/lib64" + mkdir -p "$lib/lib" + ln -s lib "$lib/lib64" + fi +} + + +postInstall() { + # Move runtime libraries to $lib. + moveToOutput "lib/lib*.so*" "$lib" + moveToOutput "lib/lib*.la" "$lib" + moveToOutput "lib/lib*.dylib" "$lib" + moveToOutput "share/gcc-*/python" "$lib" + + for i in "$lib"/lib/*.{la,py}; do + substituteInPlace "$i" --replace "$out" "$lib" + done + + if [ -n "$enableMultilib" ]; then + moveToOutput "lib64/lib*.so*" "$lib" + moveToOutput "lib64/lib*.la" "$lib" + moveToOutput "lib64/lib*.dylib" "$lib" + + for i in "$lib"/lib64/*.{la,py}; do + substituteInPlace "$i" --replace "$out" "$lib" + done + fi + + # Remove `fixincl' to prevent a retained dependency on the + # previous gcc. + rm -rf $out/libexec/gcc/*/*/install-tools + rm -rf $out/lib/gcc/*/*/install-tools + + # More dependencies with the previous gcc or some libs (gccbug stores the build command line) + rm -rf $out/bin/gccbug + + if type "patchelf"; then + # Take out the bootstrap-tools from the rpath, as it's not needed at all having $out + for i in $(find "$out"/libexec/gcc/*/*/* -type f -a \! -name '*.la'); do + PREV_RPATH=`patchelf --print-rpath "$i"` + NEW_RPATH=`echo "$PREV_RPATH" | sed 's,:[^:]*bootstrap-tools/lib,,g'` + patchelf --set-rpath "$NEW_RPATH" "$i" && echo OK + done + + # For some reason the libs retain RPATH to $out + for i in "$lib"/lib/{libtsan,libasan,libubsan}.so.*.*.*; do + PREV_RPATH=`patchelf --print-rpath "$i"` + NEW_RPATH=`echo "$PREV_RPATH" | sed "s,:${out}[^:]*,,g"` + patchelf --set-rpath "$NEW_RPATH" "$i" && echo OK + done + fi + + if type "install_name_tool"; then + for i in "$lib"/lib/*.*.dylib; do + install_name_tool -id "$i" "$i" || true + for old_path in $(otool -L "$i" | grep "$out" | awk '{print $1}'); do + new_path=`echo "$old_path" | sed "s,$out,$lib,"` + install_name_tool -change "$old_path" "$new_path" "$i" || true + done + done + fi + + # Get rid of some "fixed" header files + rm -rfv $out/lib/gcc/*/*/include-fixed/{root,linux} + + # Replace hard links for i686-pc-linux-gnu-gcc etc. with symlinks. + for i in $out/bin/*-gcc*; do + if cmp -s $out/bin/gcc $i; then + ln -sfn gcc $i + fi + done + + for i in $out/bin/c++ $out/bin/*-c++* $out/bin/*-g++*; do + if cmp -s $out/bin/g++ $i; then + ln -sfn g++ $i + fi + done + + # Two identical man pages are shipped (moving and compressing is done later) + ln -sf gcc.1 "$out"/share/man/man1/g++.1 +} + +genericBuild diff --git a/nixpkgs/pkgs/development/compilers/gcc/common/platform-flags.nix b/nixpkgs/pkgs/development/compilers/gcc/common/platform-flags.nix new file mode 100644 index 000000000000..f3cdce411939 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/gcc/common/platform-flags.nix @@ -0,0 +1,16 @@ +{ lib, targetPlatform }: + +let + p = targetPlatform.platform.gcc or {} + // targetPlatform.parsed.abi; +in lib.concatLists [ + (lib.optional (!targetPlatform.isx86_64 && p ? arch) "--with-arch=${p.arch}") # --with-arch= is unknown flag on x86_64 + (lib.optional (p ? cpu) "--with-cpu=${p.cpu}") + (lib.optional (p ? abi) "--with-abi=${p.abi}") + (lib.optional (p ? fpu) "--with-fpu=${p.fpu}") + (lib.optional (p ? float) "--with-float=${p.float}") + (lib.optional (p ? mode) "--with-mode=${p.mode}") + (lib.optional + (let tp = targetPlatform; in tp.isPower && tp.libc == "glibc" && tp.is64bit && tp.isLittleEndian) + "--with-long-double-128") +] diff --git a/nixpkgs/pkgs/development/compilers/gcc/gfortran-darwin-NXConstStr.patch b/nixpkgs/pkgs/development/compilers/gcc/gfortran-darwin-NXConstStr.patch new file mode 100644 index 000000000000..a7e158ca364b --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/gcc/gfortran-darwin-NXConstStr.patch @@ -0,0 +1,27 @@ +From 82f81877458ea372176eabb5de36329431dce99b Mon Sep 17 00:00:00 2001 +From: Iain Sandoe <iain@codesourcery.com> +Date: Sat, 21 Dec 2013 00:30:18 +0000 +Subject: [PATCH] don't try to mark local symbols as no-dead-strip + +--- + gcc/config/darwin.c | 5 +++++ + 1 file changed, 5 insertions(+) + +diff --git a/gcc/config/darwin.c b/gcc/config/darwin.c +index 40804b8..0080299 100644 +--- a/gcc/config/darwin.c ++++ b/gcc/config/darwin.c +@@ -1259,6 +1259,11 @@ darwin_encode_section_info (tree decl, rtx rtl, int first ATTRIBUTE_UNUSED) + void + darwin_mark_decl_preserved (const char *name) + { ++ /* Actually we shouldn't mark any local symbol this way, but for now ++ this only happens with ObjC meta-data. */ ++ if (darwin_label_is_anonymous_local_objc_name (name)) ++ return; ++ + fprintf (asm_out_file, "\t.no_dead_strip "); + assemble_name (asm_out_file, name); + fputc ('\n', asm_out_file); +-- +2.2.1 diff --git a/nixpkgs/pkgs/development/compilers/gcc/gfortran-driving.patch b/nixpkgs/pkgs/development/compilers/gcc/gfortran-driving.patch new file mode 100644 index 000000000000..70708886b405 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/gcc/gfortran-driving.patch @@ -0,0 +1,20 @@ +This patch fixes interaction with Libtool. +See <http://thread.gmane.org/gmane.comp.gcc.patches/258777>, for details. + +--- a/gcc/fortran/gfortranspec.c ++++ b/gcc/fortran/gfortranspec.c +@@ -461,8 +461,15 @@ For more information about these matters, see the file named COPYING\n\n")); + { + fprintf (stderr, _("Driving:")); + for (i = 0; i < g77_newargc; i++) ++ { ++ if (g77_new_decoded_options[i].opt_index == OPT_l) ++ /* Make sure no white space is inserted after `-l'. */ ++ fprintf (stderr, " -l%s", ++ g77_new_decoded_options[i].canonical_option[1]); ++ else + fprintf (stderr, " %s", + g77_new_decoded_options[i].orig_option_with_args_text); ++ } + fprintf (stderr, "\n"); + } diff --git a/nixpkgs/pkgs/development/compilers/gcc/libgomp-dont-force-initial-exec.patch b/nixpkgs/pkgs/development/compilers/gcc/libgomp-dont-force-initial-exec.patch new file mode 100644 index 000000000000..afd1f7456d32 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/gcc/libgomp-dont-force-initial-exec.patch @@ -0,0 +1,40 @@ +From 01c433f4788441c0963005b9d3fad5b2865e6651 Mon Sep 17 00:00:00 2001 +From: Will Dietz <w@wdtz.org> +Date: Mon, 24 Sep 2018 19:57:50 -0500 +Subject: [PATCH] libgomp/configure.tgt: don't force initial-exec tls-model + +--- + libgomp/configure.tgt | 17 ----------------- + 1 file changed, 17 deletions(-) + +diff --git a/libgomp/configure.tgt b/libgomp/configure.tgt +index 74d95a570c7..b608c55f0c1 100644 +--- a/libgomp/configure.tgt ++++ b/libgomp/configure.tgt +@@ -10,23 +10,6 @@ + # XCFLAGS Add extra compile flags to use. + # XLDFLAGS Add extra link flags to use. + +-# Optimize TLS usage by avoiding the overhead of dynamic allocation. +-if test $gcc_cv_have_tls = yes ; then +- case "${target}" in +- +- *-*-k*bsd*-gnu*) +- ;; +- +- *-*-linux* | *-*-gnu*) +- XCFLAGS="${XCFLAGS} -ftls-model=initial-exec" +- ;; +- +- *-*-rtems*) +- XCFLAGS="${XCFLAGS} -ftls-model=local-exec" +- ;; +- esac +-fi +- + # Since we require POSIX threads, assume a POSIX system by default. + config_path="posix" + +-- +2.19.0 + diff --git a/nixpkgs/pkgs/development/compilers/gcc/libstdc++-hook.sh b/nixpkgs/pkgs/development/compilers/gcc/libstdc++-hook.sh new file mode 100644 index 000000000000..19db70597ce5 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/gcc/libstdc++-hook.sh @@ -0,0 +1,4 @@ +# See pkgs/build-support/setup-hooks/role.bash +getHostRole + +export NIX_${role_pre}CXXSTDLIB_COMPILE+=" -isystem $(echo -n @gcc@/include/c++/*) -isystem $(echo -n @gcc@/include/c++/*)/$(@gcc@/bin/gcc -dumpmachine)" diff --git a/nixpkgs/pkgs/development/compilers/gcc/libstdc++-netbsd-ctypes.patch b/nixpkgs/pkgs/development/compilers/gcc/libstdc++-netbsd-ctypes.patch new file mode 100644 index 000000000000..28fff80b786d --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/gcc/libstdc++-netbsd-ctypes.patch @@ -0,0 +1,141 @@ +diff --git a/libstdc++-v3/config/os/bsd/netbsd/ctype_base.h b/libstdc++-v3/config/os/bsd/netbsd/ctype_base.h +index ff3ec893974..21eccf9fde1 100644 +--- a/libstdc++-v3/config/os/bsd/netbsd/ctype_base.h ++++ b/libstdc++-v3/config/os/bsd/netbsd/ctype_base.h +@@ -38,40 +38,46 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION + /// @brief Base class for ctype. + struct ctype_base + { +- // Non-standard typedefs. +- typedef const unsigned char* __to_type; + + // NB: Offsets into ctype<char>::_M_table force a particular size + // on the mask type. Because of this, we don't use an enum. +- typedef unsigned char mask; + + #ifndef _CTYPE_U +- static const mask upper = _U; +- static const mask lower = _L; +- static const mask alpha = _U | _L; +- static const mask digit = _N; +- static const mask xdigit = _N | _X; +- static const mask space = _S; +- static const mask print = _P | _U | _L | _N | _B; +- static const mask graph = _P | _U | _L | _N; +- static const mask cntrl = _C; +- static const mask punct = _P; +- static const mask alnum = _U | _L | _N; ++ // Non-standard typedefs. ++ typedef const unsigned char* __to_type; ++ ++ typedef unsigned char mask; ++ ++ static const mask upper = _U; ++ static const mask lower = _L; ++ static const mask alpha = _U | _L; ++ static const mask digit = _N; ++ static const mask xdigit = _N | _X; ++ static const mask space = _S; ++ static const mask print = _P | _U | _L | _N | _B; ++ static const mask graph = _P | _U | _L | _N; ++ static const mask cntrl = _C; ++ static const mask punct = _P; ++ static const mask alnum = _U | _L | _N; + #else +- static const mask upper = _CTYPE_U; +- static const mask lower = _CTYPE_L; +- static const mask alpha = _CTYPE_U | _CTYPE_L; +- static const mask digit = _CTYPE_N; +- static const mask xdigit = _CTYPE_N | _CTYPE_X; +- static const mask space = _CTYPE_S; +- static const mask print = _CTYPE_P | _CTYPE_U | _CTYPE_L | _CTYPE_N | _CTYPE_B; +- static const mask graph = _CTYPE_P | _CTYPE_U | _CTYPE_L | _CTYPE_N; +- static const mask cntrl = _CTYPE_C; +- static const mask punct = _CTYPE_P; +- static const mask alnum = _CTYPE_U | _CTYPE_L | _CTYPE_N; ++ typedef const unsigned short* __to_type; ++ ++ typedef unsigned short mask; ++ ++ static const mask upper = _CTYPE_U; ++ static const mask lower = _CTYPE_L; ++ static const mask alpha = _CTYPE_A; ++ static const mask digit = _CTYPE_D; ++ static const mask xdigit = _CTYPE_X; ++ static const mask space = _CTYPE_S; ++ static const mask print = _CTYPE_R; ++ static const mask graph = _CTYPE_G; ++ static const mask cntrl = _CTYPE_C; ++ static const mask punct = _CTYPE_P; ++ static const mask alnum = _CTYPE_A | _CTYPE_D; + #endif + #if __cplusplus >= 201103L +- static const mask blank = space; ++ static const mask blank = space; + #endif + }; + +diff --git a/libstdc++-v3/config/os/bsd/netbsd/ctype_configure_char.cc b/libstdc++-v3/config/os/bsd/netbsd/ctype_configure_char.cc +index ed3b7cd0d6a..33358e8f5d8 100644 +--- a/libstdc++-v3/config/os/bsd/netbsd/ctype_configure_char.cc ++++ b/libstdc++-v3/config/os/bsd/netbsd/ctype_configure_char.cc +@@ -38,11 +38,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION + + // Information as gleaned from /usr/include/ctype.h + +- extern "C" const u_int8_t _C_ctype_[]; +- + const ctype_base::mask* + ctype<char>::classic_table() throw() +- { return _C_ctype_ + 1; } ++ { return _C_ctype_tab_ + 1; } + + ctype<char>::ctype(__c_locale, const mask* __table, bool __del, + size_t __refs) +@@ -69,14 +67,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION + + char + ctype<char>::do_toupper(char __c) const +- { return ::toupper((int) __c); } ++ { return ::toupper((int)(unsigned char) __c); } + + const char* + ctype<char>::do_toupper(char* __low, const char* __high) const + { + while (__low < __high) + { +- *__low = ::toupper((int) *__low); ++ *__low = ::toupper((int)(unsigned char) *__low); + ++__low; + } + return __high; +@@ -84,14 +82,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION + + char + ctype<char>::do_tolower(char __c) const +- { return ::tolower((int) __c); } ++ { return ::tolower((int)(unsigned char) __c); } + + const char* + ctype<char>::do_tolower(char* __low, const char* __high) const + { + while (__low < __high) + { +- *__low = ::tolower((int) *__low); ++ *__low = ::tolower((int)(unsigned char) *__low); + ++__low; + } + return __high; +diff --git a/libstdc++-v3/config/os/bsd/netbsd/ctype_inline.h b/libstdc++-v3/config/os/bsd/netbsd/ctype_inline.h +index ace1120fba2..3234ce17c70 100644 +--- a/libstdc++-v3/config/os/bsd/netbsd/ctype_inline.h ++++ b/libstdc++-v3/config/os/bsd/netbsd/ctype_inline.h +@@ -48,7 +48,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION + is(const char* __low, const char* __high, mask* __vec) const + { + while (__low < __high) +- *__vec++ = _M_table[*__low++]; ++ *__vec++ = _M_table[(unsigned char)*__low++]; + return __high; + } + diff --git a/nixpkgs/pkgs/development/compilers/gcc/libstdc++-target.patch b/nixpkgs/pkgs/development/compilers/gcc/libstdc++-target.patch new file mode 100644 index 000000000000..fb622b395806 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/gcc/libstdc++-target.patch @@ -0,0 +1,32 @@ +Patch to make the target libraries 'configure' scripts find the proper CPP. +I noticed that building the mingw32 cross compiler. +Looking at the build script for mingw in archlinux, I think that only nixos +needs this patch. I don't know why. +diff --git a/Makefile.in b/Makefile.in +index 93f66b6..d691917 100644 +--- a/Makefile.in ++++ b/Makefile.in +@@ -266,6 +266,7 @@ BASE_TARGET_EXPORTS = \ + AR="$(AR_FOR_TARGET)"; export AR; \ + AS="$(COMPILER_AS_FOR_TARGET)"; export AS; \ + CC="$(CC_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS"; export CC; \ ++ CPP="$(CC_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS -E"; export CC; \ + CFLAGS="$(CFLAGS_FOR_TARGET)"; export CFLAGS; \ + CONFIG_SHELL="$(SHELL)"; export CONFIG_SHELL; \ + CPPFLAGS="$(CPPFLAGS_FOR_TARGET)"; export CPPFLAGS; \ +@@ -291,11 +292,13 @@ BASE_TARGET_EXPORTS = \ + RAW_CXX_TARGET_EXPORTS = \ + $(BASE_TARGET_EXPORTS) \ + CXX_FOR_TARGET="$(RAW_CXX_FOR_TARGET)"; export CXX_FOR_TARGET; \ +- CXX="$(RAW_CXX_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS"; export CXX; ++ CXX="$(RAW_CXX_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS"; export CXX; \ ++ CXXCPP="$(RAW_CXX_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS -E"; export CXX; + + NORMAL_TARGET_EXPORTS = \ + $(BASE_TARGET_EXPORTS) \ +- CXX="$(CXX_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS"; export CXX; ++ CXX="$(CXX_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS"; export CXX; \ ++ CXXCPP="$(CXX_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS -E"; export CXX; + + # Where to find GMP + HOST_GMPLIBS = @gmplibs@ diff --git a/nixpkgs/pkgs/development/compilers/gcc/no-sys-dirs.patch b/nixpkgs/pkgs/development/compilers/gcc/no-sys-dirs.patch new file mode 100644 index 000000000000..36df51904acf --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/gcc/no-sys-dirs.patch @@ -0,0 +1,28 @@ +diff -ru -x '*~' gcc-4.8.3-orig/gcc/cppdefault.c gcc-4.8.3/gcc/cppdefault.c +--- gcc-4.8.3-orig/gcc/cppdefault.c 2013-01-10 21:38:27.000000000 +0100 ++++ gcc-4.8.3/gcc/cppdefault.c 2014-08-18 16:20:32.893944536 +0200 +@@ -35,6 +35,8 @@ + # undef CROSS_INCLUDE_DIR + #endif + ++#undef LOCAL_INCLUDE_DIR ++ + const struct default_include cpp_include_defaults[] + #ifdef INCLUDE_DEFAULTS + = INCLUDE_DEFAULTS; +diff -ru -x '*~' gcc-4.8.3-orig/gcc/gcc.c gcc-4.8.3/gcc/gcc.c +--- gcc-4.8.3-orig/gcc/gcc.c 2014-03-23 12:30:57.000000000 +0100 ++++ gcc-4.8.3/gcc/gcc.c 2014-08-18 13:19:32.689201690 +0200 +@@ -1162,10 +1162,10 @@ + /* Default prefixes to attach to command names. */ + + #ifndef STANDARD_STARTFILE_PREFIX_1 +-#define STANDARD_STARTFILE_PREFIX_1 "/lib/" ++#define STANDARD_STARTFILE_PREFIX_1 "" + #endif + #ifndef STANDARD_STARTFILE_PREFIX_2 +-#define STANDARD_STARTFILE_PREFIX_2 "/usr/lib/" ++#define STANDARD_STARTFILE_PREFIX_2 "" + #endif + + #ifdef CROSS_DIRECTORY_STRUCTURE /* Don't use these prefixes for a cross compiler. */ diff --git a/nixpkgs/pkgs/development/compilers/gcc/parallel-bconfig.patch b/nixpkgs/pkgs/development/compilers/gcc/parallel-bconfig.patch new file mode 100644 index 000000000000..bc56ac698f5a --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/gcc/parallel-bconfig.patch @@ -0,0 +1,32 @@ +Hacky work-around for highly parallel builds. +http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57125 + +diff --git a/gcc/Makefile.in b/gcc/Makefile.in +index aad927c..182f666 100644 +--- a/gcc/Makefile.in ++++ b/gcc/Makefile.in +@@ -3908,21 +3908,21 @@ build/gengtype-lex.o: $(BCONFIG_H) + + gengtype-parse.o build/gengtype-parse.o : gengtype-parse.c gengtype.h \ + $(SYSTEM_H) +-gengtype-parse.o: $(CONFIG_H) ++gengtype-parse.o: $(CONFIG_H) $(BCONFIG_H) + CFLAGS-gengtype-parse.o += -DGENERATOR_FILE + build/gengtype-parse.o: $(BCONFIG_H) + + gengtype-state.o build/gengtype-state.o: gengtype-state.c $(SYSTEM_H) \ + gengtype.h errors.h double-int.h version.h $(HASHTAB_H) $(OBSTACK_H) \ + $(XREGEX_H) +-gengtype-state.o: $(CONFIG_H) ++gengtype-state.o: $(CONFIG_H) $(BCONFIG_H) + CFLAGS-gengtype-state.o += -DGENERATOR_FILE + build/gengtype-state.o: $(BCONFIG_H) + + gengtype.o build/gengtype.o : gengtype.c $(SYSTEM_H) gengtype.h \ + rtl.def insn-notes.def errors.h double-int.h version.h $(HASHTAB_H) \ + $(OBSTACK_H) $(XREGEX_H) +-gengtype.o: $(CONFIG_H) ++gengtype.o: $(CONFIG_H) $(BCONFIG_H) + CFLAGS-gengtype.o += -DGENERATOR_FILE + build/gengtype.o: $(BCONFIG_H) + diff --git a/nixpkgs/pkgs/development/compilers/gcc/ppc-musl.patch b/nixpkgs/pkgs/development/compilers/gcc/ppc-musl.patch new file mode 100644 index 000000000000..bc90888a3797 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/gcc/ppc-musl.patch @@ -0,0 +1,18 @@ +diff --git a/gcc/config/rs6000/sysv4.h b/gcc/config/rs6000/sysv4.h +index cbee89140dd..e1f26b0a096 100644 +--- a/gcc/config/rs6000/sysv4.h ++++ b/gcc/config/rs6000/sysv4.h +@@ -996,13 +996,7 @@ ncrtn.o%s" + { GPLUSPLUS_BACKWARD_INCLUDE_DIR, "G++", 1, 1, \ + GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 0 }, + +-#ifdef LOCAL_INCLUDE_DIR +-#define INCLUDE_DEFAULTS_MUSL_LOCAL \ +- { LOCAL_INCLUDE_DIR, 0, 0, 1, 1, 2 }, \ +- { LOCAL_INCLUDE_DIR, 0, 0, 1, 1, 0 }, +-#else + #define INCLUDE_DEFAULTS_MUSL_LOCAL +-#endif + + #ifdef PREFIX_INCLUDE_DIR + #define INCLUDE_DEFAULTS_MUSL_PREFIX \ diff --git a/nixpkgs/pkgs/development/compilers/gcc/res_state-not-declared.patch b/nixpkgs/pkgs/development/compilers/gcc/res_state-not-declared.patch new file mode 100644 index 000000000000..e970487786d0 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/gcc/res_state-not-declared.patch @@ -0,0 +1,13 @@ +diff --git a/libsanitizer/tsan/tsan_platform_linux.cc b/libsanitizer/tsan/tsan_platform_linux.cc +index fe69430..49f5270 100644 +--- a/libsanitizer/tsan/tsan_platform_linux.cc ++++ b/libsanitizer/tsan/tsan_platform_linux.cc +@@ -351,7 +351,7 @@ bool IsGlobalVar(uptr addr) { + // closes within glibc. The code is a pure hack. + int ExtractResolvFDs(void *state, int *fds, int nfd) { + int cnt = 0; +- __res_state *statp = (__res_state*)state; ++ struct __res_state *statp = (struct __res_state*)state; + for (int i = 0; i < MAXNS && cnt < nfd; i++) { + if (statp->_u._ext.nsaddrs[i] && statp->_u._ext.nssocks[i] != -1) + fds[cnt++] = statp->_u._ext.nssocks[i]; diff --git a/nixpkgs/pkgs/development/compilers/gcc/sigsegv-not-declared.patch b/nixpkgs/pkgs/development/compilers/gcc/sigsegv-not-declared.patch new file mode 100644 index 000000000000..f9cfaec82026 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/gcc/sigsegv-not-declared.patch @@ -0,0 +1,13 @@ +error: 'SIGSEGV' was not declared in this scope +diff --git a/libsanitizer/asan/asan_linux.cc b/libsanitizer/asan/asan_linux.cc +index 0692eb1..472f734 100644 +--- a/libsanitizer/asan/asan_linux.cc ++++ b/libsanitizer/asan/asan_linux.cc +@@ -26,6 +26,7 @@ + #include <sys/types.h> + #include <fcntl.h> + #include <pthread.h> ++#include <signal.h> + #include <stdio.h> + #include <unistd.h> + #include <unwind.h> diff --git a/nixpkgs/pkgs/development/compilers/gcc/snapshot/default.nix b/nixpkgs/pkgs/development/compilers/gcc/snapshot/default.nix new file mode 100644 index 000000000000..a07f6f1feb2f --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/gcc/snapshot/default.nix @@ -0,0 +1,352 @@ +{ stdenv, targetPackages, fetchurl, noSysDirs +, langC ? true, langCC ? true, langFortran ? false +, langObjC ? stdenv.targetPlatform.isDarwin +, langObjCpp ? stdenv.targetPlatform.isDarwin +, langGo ? false +, profiledCompiler ? false +, staticCompiler ? false +, enableShared ? true +, texinfo ? null +, perl ? null # optional, for texi2pod (then pod2man) +, gmp, mpfr, libmpc, gettext, which +, libelf # optional, for link-time optimizations (LTO) +, isl ? null # optional, for the Graphite optimization framework. +, zlib ? null +, enableMultilib ? false +, enablePlugin ? stdenv.hostPlatform == stdenv.buildPlatform # Whether to support user-supplied plug-ins +, name ? "gcc" +, libcCross ? null +, crossStageStatic ? false +, # Strip kills static libs of other archs (hence no cross) + stripped ? stdenv.hostPlatform == stdenv.buildPlatform + && stdenv.targetPlatform == stdenv.hostPlatform +, gnused ? null +, cloog # unused; just for compat with gcc4, as we override the parameter on some places +, flex ? null +, buildPackages +}: + +# LTO needs libelf and zlib. +assert libelf != null -> zlib != null; + +# Make sure we get GNU sed. +assert stdenv.hostPlatform.isDarwin -> gnused != null; + +# The go frontend is written in c++ +assert langGo -> langCC; + +with stdenv.lib; +with builtins; + +let version = "7-20170409"; + + inherit (stdenv) buildPlatform hostPlatform targetPlatform; + + patches = + [ ] + ++ optional (targetPlatform != hostPlatform) ../libstdc++-target.patch + ++ optional noSysDirs ../no-sys-dirs.patch + ++ optional langFortran ../gfortran-driving.patch; + + /* Cross-gcc settings (build == host != target) */ + crossMingw = targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt"; + crossDarwin = targetPlatform != hostPlatform && targetPlatform.libc == "libSystem"; + crossConfigureFlags = + # Ensure that -print-prog-name is able to find the correct programs. + [ "--with-as=${targetPackages.stdenv.cc.bintools}/bin/${targetPlatform.config}-as" + "--with-ld=${targetPackages.stdenv.cc.bintools}/bin/${targetPlatform.config}-ld" ] ++ + (if crossMingw && crossStageStatic then [ + "--with-headers=${libcCross}/include" + "--with-gcc" + "--with-gnu-as" + "--with-gnu-ld" + "--with-gnu-ld" + "--disable-shared" + "--disable-nls" + "--disable-debug" + "--enable-sjlj-exceptions" + "--enable-threads=win32" + "--disable-win32-registry" + "--disable-libmpx" # requires libc + ] else if crossStageStatic then [ + "--disable-libssp" + "--disable-nls" + "--without-headers" + "--disable-threads" + "--disable-libgomp" + "--disable-libquadmath" + "--disable-shared" + "--disable-libatomic" # requires libc + "--disable-decimal-float" # requires libc + "--disable-libmpx" # requires libc + ] else [ + (if crossDarwin then "--with-sysroot=${getLib libcCross}/share/sysroot" + else "--with-headers=${getDev libcCross}/include") + "--enable-__cxa_atexit" + "--enable-long-long" + ] ++ + (if crossMingw then [ + "--enable-threads=win32" + "--enable-sjlj-exceptions" + "--enable-hash-synchronization" + "--enable-libssp" + "--disable-nls" + "--with-dwarf2" + # To keep ABI compatibility with upstream mingw-w64 + "--enable-fully-dynamic-string" + ] else + optionals (targetPlatform.libc == "uclibc") [ + # libsanitizer requires netrom/netrom.h which is not + # available in uclibc. + "--disable-libsanitizer" + # In uclibc cases, libgomp needs an additional '-ldl' + # and as I don't know how to pass it, I disable libgomp. + "--disable-libgomp" + ] + ++ optional (targetPlatform.libc == "newlib") "--with-newlib" + ++ optional (targetPlatform.libc == "avrlibc") "--with-avrlibc" + ++ [ + "--enable-threads=${if targetPlatform.isUnix then "posix" + else if targetPlatform.isWindows then "win32" + else "single"}" + "--enable-nls" + "--disable-decimal-float" # No final libdecnumber (it may work only in 386) + ])); + stageNameAddon = if crossStageStatic then "-stage-static" else "-stage-final"; + crossNameAddon = if targetPlatform != hostPlatform then "-${targetPlatform.config}" + stageNameAddon else ""; + + bootstrap = targetPlatform == hostPlatform; + +in + +stdenv.mkDerivation ({ + name = "${name}${if stripped then "" else "-debug"}-${version}" + crossNameAddon; + + builder = ../builder.sh; + + src = fetchurl { + url = "mirror://gcc/snapshots/${version}/gcc-${version}.tar.bz2"; + sha256 = "19197rw1xrpkb8h10lfgn6zj7yj52x95hdmr0x5lg8i4v3i23b67"; + }; + + inherit patches; + + outputs = [ "out" "lib" "man" "info" ]; + setOutputFlags = false; + NIX_NO_SELF_RPATH = true; + + libc_dev = stdenv.cc.libc_dev; + + hardeningDisable = [ "format" "pie" ]; + + postPatch = + if targetPlatform != hostPlatform || stdenv.cc.libc != null then + # On NixOS, use the right path to the dynamic linker instead of + # `/lib/ld*.so'. + let + libc = if libcCross != null then libcCross else stdenv.cc.libc; + in + '' echo "fixing the \`GLIBC_DYNAMIC_LINKER' and \`UCLIBC_DYNAMIC_LINKER' macros..." + for header in "gcc/config/"*-gnu.h "gcc/config/"*"/"*.h + do + grep -q LIBC_DYNAMIC_LINKER "$header" || continue + echo " fixing \`$header'..." + sed -i "$header" \ + -e 's|define[[:blank:]]*\([UCG]\+\)LIBC_DYNAMIC_LINKER\([0-9]*\)[[:blank:]]"\([^\"]\+\)"$|define \1LIBC_DYNAMIC_LINKER\2 "${libc.out}\3"|g' + done + '' + else null; + + inherit noSysDirs staticCompiler crossStageStatic + libcCross crossMingw; + + depsBuildBuild = [ buildPackages.stdenv.cc ]; + nativeBuildInputs = [ texinfo which gettext ] + ++ (optional (perl != null) perl); + + # For building runtime libs + depsBuildTarget = + if hostPlatform == buildPlatform then [ + targetPackages.stdenv.cc.bintools # newly-built gcc will be used + ] else assert targetPlatform == hostPlatform; [ # build != host == target + stdenv.cc + ]; + + buildInputs = [ + gmp mpfr libmpc libelf flex + targetPackages.stdenv.cc.bintools # For linking code at run-time + ] ++ (optional (isl != null) isl) + ++ (optional (zlib != null) zlib) + # The builder relies on GNU sed (for instance, Darwin's `sed' fails with + # "-i may not be used with stdin"), and `stdenvNative' doesn't provide it. + ++ (optional hostPlatform.isDarwin gnused) + ; + + NIX_LDFLAGS = stdenv.lib.optionalString hostPlatform.isSunOS "-lm -ldl"; + + preConfigure = stdenv.lib.optionalString (hostPlatform.isSunOS && hostPlatform.is64bit) '' + export NIX_LDFLAGS=`echo $NIX_LDFLAGS | sed -e s~$prefix/lib~$prefix/lib/amd64~g` + export LDFLAGS_FOR_TARGET="-Wl,-rpath,$prefix/lib/amd64 $LDFLAGS_FOR_TARGET" + export CXXFLAGS_FOR_TARGET="-Wl,-rpath,$prefix/lib/amd64 $CXXFLAGS_FOR_TARGET" + export CFLAGS_FOR_TARGET="-Wl,-rpath,$prefix/lib/amd64 $CFLAGS_FOR_TARGET" + ''; + + dontDisableStatic = true; + + # TODO(@Ericson2314): Always pass "--target" and always prefix. + configurePlatforms = [ "build" "host" ] ++ stdenv.lib.optional (targetPlatform != hostPlatform) "target"; + + configureFlags = + # Basic dependencies + [ + "--with-gmp-include=${gmp.dev}/include" + "--with-gmp-lib=${gmp.out}/lib" + "--with-mpfr-include=${mpfr.dev}/include" + "--with-mpfr-lib=${mpfr.out}/lib" + "--with-mpc=${libmpc}" + ] ++ + optional (libelf != null) "--with-libelf=${libelf}" ++ + optional (!(crossMingw && crossStageStatic)) + "--with-native-system-header-dir=${getDev stdenv.cc.libc}/include" ++ + + # Basic configuration + [ + "--enable-lto" + "--disable-libstdcxx-pch" + "--without-included-gettext" + "--with-system-zlib" + "--enable-static" + "--enable-languages=${ + concatStrings (intersperse "," + ( optional langC "c" + ++ optional langCC "c++" + ++ optional langFortran "fortran" + ++ optional langGo "go" + ++ optional langObjC "objc" + ++ optional langObjCpp "obj-c++" + ++ optionals crossDarwin [ "objc" "obj-c++" ] + ) + ) + }" + ] ++ + + (if enableMultilib + then ["--enable-multilib" "--disable-libquadmath"] + else ["--disable-multilib"]) ++ + optional (!enableShared) "--disable-shared" ++ + (if enablePlugin + then ["--enable-plugin"] + else ["--disable-plugin"]) ++ + + # Optional features + optional (isl != null) "--with-isl=${isl}" ++ + + + (import ../common/platform-flags.nix { inherit (stdenv) lib targetPlatform; }) ++ + optional (targetPlatform != hostPlatform) crossConfigureFlags ++ + optional (!bootstrap) "--disable-bootstrap" ++ + + # Platform-specific flags + optional (targetPlatform == hostPlatform && targetPlatform.isi686) "--with-arch=i686" ++ + optionals hostPlatform.isSunOS [ + "--enable-long-long" "--enable-libssp" "--enable-threads=posix" "--disable-nls" "--enable-__cxa_atexit" + # On Illumos/Solaris GNU as is preferred + "--with-gnu-as" "--without-gnu-ld" + ] + ; + + targetConfig = if targetPlatform != hostPlatform then targetPlatform.config else null; + + buildFlags = if bootstrap then + (if profiledCompiler then "profiledbootstrap" else "bootstrap") + else ""; + + dontStrip = !stripped; + NIX_STRIP_DEBUG = !stripped; + + installTargets = + if stripped + then "install-strip" + else "install"; + + # https://gcc.gnu.org/install/specific.html#x86-64-x-solaris210 + ${if hostPlatform.system == "x86_64-solaris" then "CC" else null} = "gcc -m64"; + + # Setting $CPATH and $LIBRARY_PATH to make sure both `gcc' and `xgcc' find the + # library headers and binaries, regarless of the language being compiled. + # + # Likewise, the LTO code doesn't find zlib. + # + # Cross-compiling, we need gcc not to read ./specs in order to build the g++ + # compiler (after the specs for the cross-gcc are created). Having + # LIBRARY_PATH= makes gcc read the specs from ., and the build breaks. + + CPATH = optionals (targetPlatform == hostPlatform) (makeSearchPathOutput "dev" "include" ([] + ++ optional (zlib != null) zlib + )); + + LIBRARY_PATH = optionals (targetPlatform == hostPlatform) (makeLibraryPath (optional (zlib != null) zlib)); + + EXTRA_TARGET_FLAGS = optionals + (targetPlatform != hostPlatform && libcCross != null) + ([ + "-idirafter ${getDev libcCross}${libcCross.incdir or "/include"}" + ] ++ optionals (! crossStageStatic) [ + "-B${libcCross.out}${libcCross.libdir or "/lib"}" + ]); + + EXTRA_TARGET_LDFLAGS = optionals + (targetPlatform != hostPlatform && libcCross != null) + ([ + "-Wl,-L${libcCross.out}${libcCross.libdir or "/lib"}" + ] ++ (if crossStageStatic then [ + "-B${libcCross.out}${libcCross.libdir or "/lib"}" + ] else [ + "-Wl,-rpath,${libcCross.out}${libcCross.libdir or "/lib"}" + "-Wl,-rpath-link,${libcCross.out}${libcCross.libdir or "/lib"}" + ])); + + passthru = { + inherit langC langCC langObjC langObjCpp langFortran langGo version; + isGNU = true; + }; + + enableParallelBuilding = true; + inherit enableMultilib; + + inherit (stdenv) is64bit; + + meta = { + homepage = https://gcc.gnu.org/; + license = stdenv.lib.licenses.gpl3Plus; # runtime support libraries are typically LGPLv3+ + description = "GNU Compiler Collection, version ${version}" + + (if stripped then "" else " (with debugging info)"); + + longDescription = '' + The GNU Compiler Collection includes compiler front ends for C, C++, + Objective-C, Fortran, OpenMP for C/C++/Fortran, and Ada, as well as + libraries for these languages (libstdc++, libgomp,...). + + GCC development is a part of the GNU Project, aiming to improve the + compiler used in the GNU system including the GNU/Linux variant. + ''; + + maintainers = with stdenv.lib.maintainers; [ ]; + + platforms = + stdenv.lib.platforms.linux ++ + stdenv.lib.platforms.freebsd ++ + stdenv.lib.platforms.illumos ++ + stdenv.lib.platforms.darwin; + + broken = true; + }; +} + +// optionalAttrs (targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt" && crossStageStatic) { + makeFlags = [ "all-gcc" "all-target-libgcc" ]; + installTargets = "install-gcc install-target-libgcc"; +} + +// optionalAttrs (enableMultilib) { dontMoveLib64 = true; } +) diff --git a/nixpkgs/pkgs/development/compilers/gcc/struct-sigaltstack-4.9.patch b/nixpkgs/pkgs/development/compilers/gcc/struct-sigaltstack-4.9.patch new file mode 100644 index 000000000000..fc126b4813d6 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/gcc/struct-sigaltstack-4.9.patch @@ -0,0 +1,78 @@ +hand-resolved trivial conflicts for 4.9 from the upstream patch +72edc2c02f8b4768ad660f46a1c7e2400c0a8e06 +diff --git a/libsanitizer/sanitizer_common/sanitizer_linux.cc b/libsanitizer/sanitizer_common/sanitizer_linux.cc +index 69c9c10..8e53673 100644 +--- a/libsanitizer/sanitizer_common/sanitizer_linux.cc ++++ b/libsanitizer/sanitizer_common/sanitizer_linux.cc +@@ -599,8 +599,7 @@ uptr internal_prctl(int option, uptr arg2, uptr arg3, uptr arg4, uptr arg5) { + return internal_syscall(__NR_prctl, option, arg2, arg3, arg4, arg5); + } + +-uptr internal_sigaltstack(const struct sigaltstack *ss, +- struct sigaltstack *oss) { ++uptr internal_sigaltstack(const void *ss, void *oss) { + return internal_syscall(__NR_sigaltstack, (uptr)ss, (uptr)oss); + } + +diff --git a/libsanitizer/sanitizer_common/sanitizer_linux.h b/libsanitizer/sanitizer_common/sanitizer_linux.h +index 6422df1..8e111d1 100644 +--- a/libsanitizer/sanitizer_common/sanitizer_linux.h ++++ b/libsanitizer/sanitizer_common/sanitizer_linux.h +@@ -18,7 +18,6 @@ + #include "sanitizer_platform_limits_posix.h" + + struct link_map; // Opaque type returned by dlopen(). +-struct sigaltstack; + + namespace __sanitizer { + // Dirent structure for getdents(). Note that this structure is different from +@@ -28,8 +27,7 @@ struct linux_dirent; + // Syscall wrappers. + uptr internal_getdents(fd_t fd, struct linux_dirent *dirp, unsigned int count); + uptr internal_prctl(int option, uptr arg2, uptr arg3, uptr arg4, uptr arg5); +-uptr internal_sigaltstack(const struct sigaltstack* ss, +- struct sigaltstack* oss); ++uptr internal_sigaltstack(const void* ss, void* oss); + uptr internal_sigaction(int signum, const __sanitizer_kernel_sigaction_t *act, + __sanitizer_kernel_sigaction_t *oldact); + uptr internal_sigprocmask(int how, __sanitizer_kernel_sigset_t *set, +diff --git a/libsanitizer/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc b/libsanitizer/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc +index 891386dc..234e8c6 100644 +--- a/libsanitizer/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc ++++ b/libsanitizer/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc +@@ -273,7 +273,7 @@ static int TracerThread(void* argument) { + + // Alternate stack for signal handling. + InternalScopedBuffer<char> handler_stack_memory(kHandlerStackSize); +- struct sigaltstack handler_stack; ++ stack_t handler_stack; + internal_memset(&handler_stack, 0, sizeof(handler_stack)); + handler_stack.ss_sp = handler_stack_memory.data(); + handler_stack.ss_size = kHandlerStackSize; +diff --git a/libsanitizer/tsan/tsan_platform_linux.cc b/libsanitizer/tsan/tsan_platform_linux.cc +index 2ed5718..6f972ab 100644 +--- a/libsanitizer/tsan/tsan_platform_linux.cc ++++ b/libsanitizer/tsan/tsan_platform_linux.cc +@@ -287,7 +287,7 @@ void InitializePlatform() { + int ExtractResolvFDs(void *state, int *fds, int nfd) { + #if SANITIZER_LINUX && !SANITIZER_ANDROID + int cnt = 0; +- __res_state *statp = (__res_state*)state; ++ struct __res_state *statp = (struct __res_state*)state; + for (int i = 0; i < MAXNS && cnt < nfd; i++) { + if (statp->_u._ext.nsaddrs[i] && statp->_u._ext.nssocks[i] != -1) + fds[cnt++] = statp->_u._ext.nssocks[i]; + +error: 'SIGSEGV' was not declared in this scope +diff --git a/libsanitizer/asan/asan_linux.cc b/libsanitizer/asan/asan_linux.cc +index 0692eb1..472f734 100644 +--- a/libsanitizer/asan/asan_linux.cc ++++ b/libsanitizer/asan/asan_linux.cc +@@ -26,6 +26,7 @@ + #include <sys/types.h> + #include <fcntl.h> + #include <pthread.h> ++#include <signal.h> + #include <stdio.h> + #include <unistd.h> + #include <unwind.h> diff --git a/nixpkgs/pkgs/development/compilers/gcc/struct-sigaltstack.patch b/nixpkgs/pkgs/development/compilers/gcc/struct-sigaltstack.patch new file mode 100644 index 000000000000..6e1ddb252c24 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/gcc/struct-sigaltstack.patch @@ -0,0 +1,87 @@ +From 72edc2c02f8b4768ad660f46a1c7e2400c0a8e06 Mon Sep 17 00:00:00 2001 +From: jakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4> +Date: Mon, 17 Jul 2017 19:41:08 +0000 +Subject: [PATCH] Backported from mainline 2017-07-14 Jakub + Jelinek <jakub@redhat.com> + + PR sanitizer/81066 + * sanitizer_common/sanitizer_linux.h: Cherry-pick upstream r307969. + * sanitizer_common/sanitizer_linux.cc: Likewise. + * sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc: Likewise. + * tsan/tsan_platform_linux.cc: Likewise. + + +git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-7-branch@250287 138bc75d-0d04-0410-961f-82ee72b054a4 +--- + libsanitizer/ChangeLog (REMOVED) | 11 +++++++++++ + libsanitizer/sanitizer_common/sanitizer_linux.cc | 3 +-- + libsanitizer/sanitizer_common/sanitizer_linux.h | 4 +--- + .../sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc | 2 +- + libsanitizer/tsan/tsan_platform_linux.cc | 2 +- + 5 files changed, 15 insertions(+), 7 deletions(-) + +diff --git a/libsanitizer/sanitizer_common/sanitizer_linux.cc b/libsanitizer/sanitizer_common/sanitizer_linux.cc +index 806fcd5..5b6f186 100644 +--- a/libsanitizer/sanitizer_common/sanitizer_linux.cc ++++ b/libsanitizer/sanitizer_common/sanitizer_linux.cc +@@ -605,8 +605,7 @@ uptr internal_prctl(int option, uptr arg2, uptr arg3, uptr arg4, uptr arg5) { + } + #endif + +-uptr internal_sigaltstack(const struct sigaltstack *ss, +- struct sigaltstack *oss) { ++uptr internal_sigaltstack(const void *ss, void *oss) { + return internal_syscall(SYSCALL(sigaltstack), (uptr)ss, (uptr)oss); + } + +diff --git a/libsanitizer/sanitizer_common/sanitizer_linux.h b/libsanitizer/sanitizer_common/sanitizer_linux.h +index 895bfc1..a42df57 100644 +--- a/libsanitizer/sanitizer_common/sanitizer_linux.h ++++ b/libsanitizer/sanitizer_common/sanitizer_linux.h +@@ -19,7 +19,6 @@ + #include "sanitizer_platform_limits_posix.h" + + struct link_map; // Opaque type returned by dlopen(). +-struct sigaltstack; + + namespace __sanitizer { + // Dirent structure for getdents(). Note that this structure is different from +@@ -28,8 +27,7 @@ struct linux_dirent; + + // Syscall wrappers. + uptr internal_getdents(fd_t fd, struct linux_dirent *dirp, unsigned int count); +-uptr internal_sigaltstack(const struct sigaltstack* ss, +- struct sigaltstack* oss); ++uptr internal_sigaltstack(const void* ss, void* oss); + uptr internal_sigprocmask(int how, __sanitizer_sigset_t *set, + __sanitizer_sigset_t *oldset); + +diff --git a/libsanitizer/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc b/libsanitizer/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc +index 891386dc..234e8c6 100644 +--- a/libsanitizer/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc ++++ b/libsanitizer/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc +@@ -273,7 +273,7 @@ static int TracerThread(void* argument) { + + // Alternate stack for signal handling. + InternalScopedBuffer<char> handler_stack_memory(kHandlerStackSize); +- struct sigaltstack handler_stack; ++ stack_t handler_stack; + internal_memset(&handler_stack, 0, sizeof(handler_stack)); + handler_stack.ss_sp = handler_stack_memory.data(); + handler_stack.ss_size = kHandlerStackSize; +diff --git a/libsanitizer/tsan/tsan_platform_linux.cc b/libsanitizer/tsan/tsan_platform_linux.cc +index 2ed5718..6f972ab 100644 +--- a/libsanitizer/tsan/tsan_platform_linux.cc ++++ b/libsanitizer/tsan/tsan_platform_linux.cc +@@ -287,7 +287,7 @@ void InitializePlatform() { + int ExtractResolvFDs(void *state, int *fds, int nfd) { + #if SANITIZER_LINUX && !SANITIZER_ANDROID + int cnt = 0; +- __res_state *statp = (__res_state*)state; ++ struct __res_state *statp = (struct __res_state*)state; + for (int i = 0; i < MAXNS && cnt < nfd; i++) { + if (statp->_u._ext.nsaddrs[i] && statp->_u._ext.nssocks[i] != -1) + fds[cnt++] = statp->_u._ext.nssocks[i]; +-- +2.9.3 + diff --git a/nixpkgs/pkgs/development/compilers/gcc/struct-ucontext-4.5.patch b/nixpkgs/pkgs/development/compilers/gcc/struct-ucontext-4.5.patch new file mode 100644 index 000000000000..a84e9ffe2681 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/gcc/struct-ucontext-4.5.patch @@ -0,0 +1,107 @@ +Trivally backported the upstream commit +b685411208e0aaa79190d54faf945763514706b8 +(different directory, some files not present, etc.) +We only really use x86* from those, probably, so I didn't bother much. +diff --git a/gcc/config/alpha/linux-unwind.h b/gcc/config/alpha/linux-unwind.h +index bdbba4a..e84812e 100644 +--- a/gcc/config/alpha/linux-unwind.h ++++ b/gcc/config/alpha/linux-unwind.h +@@ -51,7 +51,7 @@ alpha_fallback_frame_state (struct _Unwind_Context *context, + { + struct rt_sigframe { + siginfo_t info; +- struct ucontext uc; ++ ucontext_t uc; + } *rt_ = context->cfa; + sc = &rt_->uc.uc_mcontext; + } +diff --git a/gcc/config/bfin/linux-unwind.h b/gcc/config/bfin/linux-unwind.h +index 77b7c23..8bf5e82 100644 +--- a/gcc/config/bfin/linux-unwind.h ++++ b/gcc/config/bfin/linux-unwind.h +@@ -52,7 +52,7 @@ bfin_fallback_frame_state (struct _Unwind_Context *context, + void *puc; + char retcode[8]; + siginfo_t info; +- struct ucontext uc; ++ ucontext_t uc; + } *rt_ = context->cfa; + + /* The void * cast is necessary to avoid an aliasing warning. +diff --git a/gcc/config/i386/linux-unwind.h b/gcc/config/i386/linux-unwind.h +index 540a0a2..29efbe3 100644 +--- a/gcc/config/i386/linux-unwind.h ++++ b/gcc/config/i386/linux-unwind.h +@@ -58,7 +58,7 @@ x86_64_fallback_frame_state (struct _Unwind_Context *context, + if (*(unsigned char *)(pc+0) == 0x48 + && *(unsigned long long *)(pc+1) == RT_SIGRETURN_SYSCALL) + { +- struct ucontext *uc_ = context->cfa; ++ ucontext_t *uc_ = context->cfa; + /* The void * cast is necessary to avoid an aliasing warning. + The aliasing warning is correct, but should not be a problem + because it does not alias anything. */ +@@ -138,7 +138,7 @@ x86_fallback_frame_state (struct _Unwind_Context *context, + siginfo_t *pinfo; + void *puc; + siginfo_t info; +- struct ucontext uc; ++ ucontext_t uc; + } *rt_ = context->cfa; + /* The void * cast is necessary to avoid an aliasing warning. + The aliasing warning is correct, but should not be a problem +diff --git a/gcc/config/m68k/linux-unwind.h b/gcc/config/m68k/linux-unwind.h +index 75b7cf7..f964e24 100644 +--- a/gcc/config/m68k/linux-unwind.h ++++ b/gcc/config/m68k/linux-unwind.h +@@ -33,7 +33,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see + /* <sys/ucontext.h> is unfortunately broken right now. */ + struct uw_ucontext { + unsigned long uc_flags; +- struct ucontext *uc_link; ++ ucontext_t *uc_link; + stack_t uc_stack; + mcontext_t uc_mcontext; + unsigned long uc_filler[80]; +diff --git a/gcc/config/pa/linux-unwind.h b/gcc/config/pa/linux-unwind.h +index 9a2657f..e47493d 100644 +--- a/gcc/config/pa/linux-unwind.h ++++ b/gcc/config/pa/linux-unwind.h +@@ -80,7 +80,7 @@ pa32_fallback_frame_state (struct _Unwind_Context *context, + struct sigcontext *sc; + struct rt_sigframe { + siginfo_t info; +- struct ucontext uc; ++ ucontext_t uc; + } *frame; + + /* rt_sigreturn trampoline: +diff --git a/gcc/config/sh/linux-unwind.h b/gcc/config/sh/linux-unwind.h +index e389cac..0bf43ba 100644 +--- a/gcc/config/sh/linux-unwind.h ++++ b/gcc/config/sh/linux-unwind.h +@@ -180,7 +180,7 @@ sh_fallback_frame_state (struct _Unwind_Context *context, + { + struct rt_sigframe { + siginfo_t info; +- struct ucontext uc; ++ ucontext_t uc; + } *rt_ = context->cfa; + /* The void * cast is necessary to avoid an aliasing warning. + The aliasing warning is correct, but should not be a problem +diff --git a/gcc/config/xtensa/linux-unwind.h b/gcc/config/xtensa/linux-unwind.h +index 9872492..586a9d4 100644 +--- a/gcc/config/xtensa/linux-unwind.h ++++ b/gcc/config/xtensa/linux-unwind.h +@@ -67,7 +67,7 @@ xtensa_fallback_frame_state (struct _Unwind_Context *context, + + struct rt_sigframe { + siginfo_t info; +- struct ucontext uc; ++ ucontext_t uc; + } *rt_; + + /* movi a2, __NR_rt_sigreturn; syscall */ +-- +2.9.3 + diff --git a/nixpkgs/pkgs/development/compilers/gcc/struct-ucontext-4.8.patch b/nixpkgs/pkgs/development/compilers/gcc/struct-ucontext-4.8.patch new file mode 100644 index 000000000000..630ef6586e45 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/gcc/struct-ucontext-4.8.patch @@ -0,0 +1,177 @@ +From b685411208e0aaa79190d54faf945763514706b8 Mon Sep 17 00:00:00 2001 +From: jsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4> +Date: Tue, 4 Jul 2017 10:23:57 +0000 +Subject: [PATCH] Use ucontext_t not struct ucontext in linux-unwind.h files. + +Current glibc no longer gives the ucontext_t type the tag struct +ucontext, to conform with POSIX namespace rules. This requires +various linux-unwind.h files in libgcc, that were previously using +struct ucontext, to be fixed to use ucontext_t instead. This is +similar to the removal of the struct siginfo tag from siginfo_t some +years ago. + +This patch changes those files to use ucontext_t instead. As the +standard name that should be unconditionally safe, so this is not +restricted to architectures supported by glibc, or conditioned on the +glibc version. + +Tested compilation together with current glibc with glibc's +build-many-glibcs.py. + + * config/aarch64/linux-unwind.h (aarch64_fallback_frame_state), + config/alpha/linux-unwind.h (alpha_fallback_frame_state), + config/bfin/linux-unwind.h (bfin_fallback_frame_state), + config/i386/linux-unwind.h (x86_64_fallback_frame_state, + x86_fallback_frame_state), config/m68k/linux-unwind.h (struct + uw_ucontext), config/nios2/linux-unwind.h (struct nios2_ucontext), + config/pa/linux-unwind.h (pa32_fallback_frame_state), + config/sh/linux-unwind.h (sh_fallback_frame_state), + config/tilepro/linux-unwind.h (tile_fallback_frame_state), + config/xtensa/linux-unwind.h (xtensa_fallback_frame_state): Use + ucontext_t instead of struct ucontext. + + +git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-6-branch@249957 138bc75d-0d04-0410-961f-82ee72b054a4 +--- + libgcc/ChangeLog (REMOVED) | 14 ++++++++++++++ + libgcc/config/aarch64/linux-unwind.h | 2 +- + libgcc/config/alpha/linux-unwind.h | 2 +- + libgcc/config/bfin/linux-unwind.h | 2 +- + libgcc/config/i386/linux-unwind.h | 4 ++-- + libgcc/config/m68k/linux-unwind.h | 2 +- + libgcc/config/nios2/linux-unwind.h | 2 +- + libgcc/config/pa/linux-unwind.h | 2 +- + libgcc/config/sh/linux-unwind.h | 2 +- + libgcc/config/tilepro/linux-unwind.h | 2 +- + libgcc/config/xtensa/linux-unwind.h | 2 +- + 11 files changed, 25 insertions(+), 11 deletions(-) + +diff --git a/libgcc/config/aarch64/linux-unwind.h b/libgcc/config/aarch64/linux-unwind.h +index 4512efb..06de45a 100644 +--- a/libgcc/config/aarch64/linux-unwind.h ++++ b/libgcc/config/aarch64/linux-unwind.h +@@ -52,7 +52,7 @@ aarch64_fallback_frame_state (struct _Unwind_Context *context, + struct rt_sigframe + { + siginfo_t info; +- struct ucontext uc; ++ ucontext_t uc; + }; + + struct rt_sigframe *rt_; +diff --git a/libgcc/config/alpha/linux-unwind.h b/libgcc/config/alpha/linux-unwind.h +index bdbba4a..e84812e 100644 +--- a/libgcc/config/alpha/linux-unwind.h ++++ b/libgcc/config/alpha/linux-unwind.h +@@ -51,7 +51,7 @@ alpha_fallback_frame_state (struct _Unwind_Context *context, + { + struct rt_sigframe { + siginfo_t info; +- struct ucontext uc; ++ ucontext_t uc; + } *rt_ = context->cfa; + sc = &rt_->uc.uc_mcontext; + } +diff --git a/libgcc/config/bfin/linux-unwind.h b/libgcc/config/bfin/linux-unwind.h +index 77b7c23..8bf5e82 100644 +--- a/libgcc/config/bfin/linux-unwind.h ++++ b/libgcc/config/bfin/linux-unwind.h +@@ -52,7 +52,7 @@ bfin_fallback_frame_state (struct _Unwind_Context *context, + void *puc; + char retcode[8]; + siginfo_t info; +- struct ucontext uc; ++ ucontext_t uc; + } *rt_ = context->cfa; + + /* The void * cast is necessary to avoid an aliasing warning. +diff --git a/libgcc/config/i386/linux-unwind.h b/libgcc/config/i386/linux-unwind.h +index 540a0a2..29efbe3 100644 +--- a/libgcc/config/i386/linux-unwind.h ++++ b/libgcc/config/i386/linux-unwind.h +@@ -58,7 +58,7 @@ x86_64_fallback_frame_state (struct _Unwind_Context *context, + if (*(unsigned char *)(pc+0) == 0x48 + && *(unsigned long long *)(pc+1) == RT_SIGRETURN_SYSCALL) + { +- struct ucontext *uc_ = context->cfa; ++ ucontext_t *uc_ = context->cfa; + /* The void * cast is necessary to avoid an aliasing warning. + The aliasing warning is correct, but should not be a problem + because it does not alias anything. */ +@@ -138,7 +138,7 @@ x86_fallback_frame_state (struct _Unwind_Context *context, + siginfo_t *pinfo; + void *puc; + siginfo_t info; +- struct ucontext uc; ++ ucontext_t uc; + } *rt_ = context->cfa; + /* The void * cast is necessary to avoid an aliasing warning. + The aliasing warning is correct, but should not be a problem +diff --git a/libgcc/config/m68k/linux-unwind.h b/libgcc/config/m68k/linux-unwind.h +index 75b7cf7..f964e24 100644 +--- a/libgcc/config/m68k/linux-unwind.h ++++ b/libgcc/config/m68k/linux-unwind.h +@@ -33,7 +33,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see + /* <sys/ucontext.h> is unfortunately broken right now. */ + struct uw_ucontext { + unsigned long uc_flags; +- struct ucontext *uc_link; ++ ucontext_t *uc_link; + stack_t uc_stack; + mcontext_t uc_mcontext; + unsigned long uc_filler[80]; +diff --git a/libgcc/config/pa/linux-unwind.h b/libgcc/config/pa/linux-unwind.h +index 9a2657f..e47493d 100644 +--- a/libgcc/config/pa/linux-unwind.h ++++ b/libgcc/config/pa/linux-unwind.h +@@ -80,7 +80,7 @@ pa32_fallback_frame_state (struct _Unwind_Context *context, + struct sigcontext *sc; + struct rt_sigframe { + siginfo_t info; +- struct ucontext uc; ++ ucontext_t uc; + } *frame; + + /* rt_sigreturn trampoline: +diff --git a/libgcc/config/sh/linux-unwind.h b/libgcc/config/sh/linux-unwind.h +index e389cac..0bf43ba 100644 +--- a/libgcc/config/sh/linux-unwind.h ++++ b/libgcc/config/sh/linux-unwind.h +@@ -180,7 +180,7 @@ sh_fallback_frame_state (struct _Unwind_Context *context, + { + struct rt_sigframe { + siginfo_t info; +- struct ucontext uc; ++ ucontext_t uc; + } *rt_ = context->cfa; + /* The void * cast is necessary to avoid an aliasing warning. + The aliasing warning is correct, but should not be a problem +diff --git a/libgcc/config/tilepro/linux-unwind.h b/libgcc/config/tilepro/linux-unwind.h +index 796e976..75f8890 100644 +--- a/libgcc/config/tilepro/linux-unwind.h ++++ b/libgcc/config/tilepro/linux-unwind.h +@@ -61,7 +61,7 @@ tile_fallback_frame_state (struct _Unwind_Context *context, + struct rt_sigframe { + unsigned char save_area[C_ABI_SAVE_AREA_SIZE]; + siginfo_t info; +- struct ucontext uc; ++ ucontext_t uc; + } *rt_; + + /* Return if this is not a signal handler. */ +diff --git a/libgcc/config/xtensa/linux-unwind.h b/libgcc/config/xtensa/linux-unwind.h +index 9872492..586a9d4 100644 +--- a/libgcc/config/xtensa/linux-unwind.h ++++ b/libgcc/config/xtensa/linux-unwind.h +@@ -67,7 +67,7 @@ xtensa_fallback_frame_state (struct _Unwind_Context *context, + + struct rt_sigframe { + siginfo_t info; +- struct ucontext uc; ++ ucontext_t uc; + } *rt_; + + /* movi a2, __NR_rt_sigreturn; syscall */ +-- +2.9.3 + diff --git a/nixpkgs/pkgs/development/compilers/gcc/struct-ucontext-libjava.patch b/nixpkgs/pkgs/development/compilers/gcc/struct-ucontext-libjava.patch new file mode 100644 index 000000000000..3892a56954e0 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/gcc/struct-ucontext-libjava.patch @@ -0,0 +1,33 @@ +--- a/libjava/include/x86_64-signal.h ++++ a/libjava/include/x86_64-signal.h +@@ -28,7 +28,7 @@ + #define HANDLE_DIVIDE_OVERFLOW \ + do \ + { \ +- struct ucontext *_uc = (struct ucontext *)_p; \ ++ ucontext_t *_uc = (ucontext_t *)_p; \ + gregset_t &_gregs = _uc->uc_mcontext.gregs; \ + unsigned char *_rip = (unsigned char *)_gregs[REG_RIP]; \ + \ +--- a/libjava/include/i386-signal.h ++++ a/libjava/include/i386-signal.h +@@ -29,7 +29,7 @@ + #define HANDLE_DIVIDE_OVERFLOW \ + do \ + { \ +- struct ucontext *_uc = (struct ucontext *)_p; \ ++ ucontext_t *_uc = (ucontext_t *)_p; \ + gregset_t &_gregs = _uc->uc_mcontext.gregs; \ + unsigned char *_eip = (unsigned char *)_gregs[REG_EIP]; \ + \ +--- a/libjava/include/s390-signal.h ++++ a/libjava/include/s390-signal.h +@@ -51,7 +51,7 @@ + struct \ + { \ + unsigned long int uc_flags; \ +- struct ucontext *uc_link; \ ++ ucontext_t *uc_link; \ + stack_t uc_stack; \ + mcontext_t uc_mcontext; \ + unsigned long sigmask[2]; \ diff --git a/nixpkgs/pkgs/development/compilers/gcc/struct-ucontext.patch b/nixpkgs/pkgs/development/compilers/gcc/struct-ucontext.patch new file mode 100644 index 000000000000..c7fb6d1f71cf --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/gcc/struct-ucontext.patch @@ -0,0 +1,190 @@ +From b685411208e0aaa79190d54faf945763514706b8 Mon Sep 17 00:00:00 2001 +From: jsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4> +Date: Tue, 4 Jul 2017 10:23:57 +0000 +Subject: [PATCH] Use ucontext_t not struct ucontext in linux-unwind.h files. + +Current glibc no longer gives the ucontext_t type the tag struct +ucontext, to conform with POSIX namespace rules. This requires +various linux-unwind.h files in libgcc, that were previously using +struct ucontext, to be fixed to use ucontext_t instead. This is +similar to the removal of the struct siginfo tag from siginfo_t some +years ago. + +This patch changes those files to use ucontext_t instead. As the +standard name that should be unconditionally safe, so this is not +restricted to architectures supported by glibc, or conditioned on the +glibc version. + +Tested compilation together with current glibc with glibc's +build-many-glibcs.py. + + * config/aarch64/linux-unwind.h (aarch64_fallback_frame_state), + config/alpha/linux-unwind.h (alpha_fallback_frame_state), + config/bfin/linux-unwind.h (bfin_fallback_frame_state), + config/i386/linux-unwind.h (x86_64_fallback_frame_state, + x86_fallback_frame_state), config/m68k/linux-unwind.h (struct + uw_ucontext), config/nios2/linux-unwind.h (struct nios2_ucontext), + config/pa/linux-unwind.h (pa32_fallback_frame_state), + config/sh/linux-unwind.h (sh_fallback_frame_state), + config/tilepro/linux-unwind.h (tile_fallback_frame_state), + config/xtensa/linux-unwind.h (xtensa_fallback_frame_state): Use + ucontext_t instead of struct ucontext. + + +git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-6-branch@249957 138bc75d-0d04-0410-961f-82ee72b054a4 +--- + libgcc/ChangeLog (REMOVED) | 14 ++++++++++++++ + libgcc/config/aarch64/linux-unwind.h | 2 +- + libgcc/config/alpha/linux-unwind.h | 2 +- + libgcc/config/bfin/linux-unwind.h | 2 +- + libgcc/config/i386/linux-unwind.h | 4 ++-- + libgcc/config/m68k/linux-unwind.h | 2 +- + libgcc/config/nios2/linux-unwind.h | 2 +- + libgcc/config/pa/linux-unwind.h | 2 +- + libgcc/config/sh/linux-unwind.h | 2 +- + libgcc/config/tilepro/linux-unwind.h | 2 +- + libgcc/config/xtensa/linux-unwind.h | 2 +- + 11 files changed, 25 insertions(+), 11 deletions(-) + +diff --git a/libgcc/config/aarch64/linux-unwind.h b/libgcc/config/aarch64/linux-unwind.h +index 4512efb..06de45a 100644 +--- a/libgcc/config/aarch64/linux-unwind.h ++++ b/libgcc/config/aarch64/linux-unwind.h +@@ -52,7 +52,7 @@ aarch64_fallback_frame_state (struct _Unwind_Context *context, + struct rt_sigframe + { + siginfo_t info; +- struct ucontext uc; ++ ucontext_t uc; + }; + + struct rt_sigframe *rt_; +diff --git a/libgcc/config/alpha/linux-unwind.h b/libgcc/config/alpha/linux-unwind.h +index bdbba4a..e84812e 100644 +--- a/libgcc/config/alpha/linux-unwind.h ++++ b/libgcc/config/alpha/linux-unwind.h +@@ -51,7 +51,7 @@ alpha_fallback_frame_state (struct _Unwind_Context *context, + { + struct rt_sigframe { + siginfo_t info; +- struct ucontext uc; ++ ucontext_t uc; + } *rt_ = context->cfa; + sc = &rt_->uc.uc_mcontext; + } +diff --git a/libgcc/config/bfin/linux-unwind.h b/libgcc/config/bfin/linux-unwind.h +index 77b7c23..8bf5e82 100644 +--- a/libgcc/config/bfin/linux-unwind.h ++++ b/libgcc/config/bfin/linux-unwind.h +@@ -52,7 +52,7 @@ bfin_fallback_frame_state (struct _Unwind_Context *context, + void *puc; + char retcode[8]; + siginfo_t info; +- struct ucontext uc; ++ ucontext_t uc; + } *rt_ = context->cfa; + + /* The void * cast is necessary to avoid an aliasing warning. +diff --git a/libgcc/config/i386/linux-unwind.h b/libgcc/config/i386/linux-unwind.h +index 540a0a2..29efbe3 100644 +--- a/libgcc/config/i386/linux-unwind.h ++++ b/libgcc/config/i386/linux-unwind.h +@@ -58,7 +58,7 @@ x86_64_fallback_frame_state (struct _Unwind_Context *context, + if (*(unsigned char *)(pc+0) == 0x48 + && *(unsigned long long *)(pc+1) == RT_SIGRETURN_SYSCALL) + { +- struct ucontext *uc_ = context->cfa; ++ ucontext_t *uc_ = context->cfa; + /* The void * cast is necessary to avoid an aliasing warning. + The aliasing warning is correct, but should not be a problem + because it does not alias anything. */ +@@ -138,7 +138,7 @@ x86_fallback_frame_state (struct _Unwind_Context *context, + siginfo_t *pinfo; + void *puc; + siginfo_t info; +- struct ucontext uc; ++ ucontext_t uc; + } *rt_ = context->cfa; + /* The void * cast is necessary to avoid an aliasing warning. + The aliasing warning is correct, but should not be a problem +diff --git a/libgcc/config/m68k/linux-unwind.h b/libgcc/config/m68k/linux-unwind.h +index 75b7cf7..f964e24 100644 +--- a/libgcc/config/m68k/linux-unwind.h ++++ b/libgcc/config/m68k/linux-unwind.h +@@ -33,7 +33,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see + /* <sys/ucontext.h> is unfortunately broken right now. */ + struct uw_ucontext { + unsigned long uc_flags; +- struct ucontext *uc_link; ++ ucontext_t *uc_link; + stack_t uc_stack; + mcontext_t uc_mcontext; + unsigned long uc_filler[80]; +diff --git a/libgcc/config/nios2/linux-unwind.h b/libgcc/config/nios2/linux-unwind.h +index 2304142..30f25ea 100644 +--- a/libgcc/config/nios2/linux-unwind.h ++++ b/libgcc/config/nios2/linux-unwind.h +@@ -38,7 +38,7 @@ struct nios2_mcontext { + + struct nios2_ucontext { + unsigned long uc_flags; +- struct ucontext *uc_link; ++ ucontext_t *uc_link; + stack_t uc_stack; + struct nios2_mcontext uc_mcontext; + sigset_t uc_sigmask; /* mask last for extensibility */ +diff --git a/libgcc/config/pa/linux-unwind.h b/libgcc/config/pa/linux-unwind.h +index 9a2657f..e47493d 100644 +--- a/libgcc/config/pa/linux-unwind.h ++++ b/libgcc/config/pa/linux-unwind.h +@@ -80,7 +80,7 @@ pa32_fallback_frame_state (struct _Unwind_Context *context, + struct sigcontext *sc; + struct rt_sigframe { + siginfo_t info; +- struct ucontext uc; ++ ucontext_t uc; + } *frame; + + /* rt_sigreturn trampoline: +diff --git a/libgcc/config/sh/linux-unwind.h b/libgcc/config/sh/linux-unwind.h +index e389cac..0bf43ba 100644 +--- a/libgcc/config/sh/linux-unwind.h ++++ b/libgcc/config/sh/linux-unwind.h +@@ -180,7 +180,7 @@ sh_fallback_frame_state (struct _Unwind_Context *context, + { + struct rt_sigframe { + siginfo_t info; +- struct ucontext uc; ++ ucontext_t uc; + } *rt_ = context->cfa; + /* The void * cast is necessary to avoid an aliasing warning. + The aliasing warning is correct, but should not be a problem +diff --git a/libgcc/config/tilepro/linux-unwind.h b/libgcc/config/tilepro/linux-unwind.h +index 796e976..75f8890 100644 +--- a/libgcc/config/tilepro/linux-unwind.h ++++ b/libgcc/config/tilepro/linux-unwind.h +@@ -61,7 +61,7 @@ tile_fallback_frame_state (struct _Unwind_Context *context, + struct rt_sigframe { + unsigned char save_area[C_ABI_SAVE_AREA_SIZE]; + siginfo_t info; +- struct ucontext uc; ++ ucontext_t uc; + } *rt_; + + /* Return if this is not a signal handler. */ +diff --git a/libgcc/config/xtensa/linux-unwind.h b/libgcc/config/xtensa/linux-unwind.h +index 9872492..586a9d4 100644 +--- a/libgcc/config/xtensa/linux-unwind.h ++++ b/libgcc/config/xtensa/linux-unwind.h +@@ -67,7 +67,7 @@ xtensa_fallback_frame_state (struct _Unwind_Context *context, + + struct rt_sigframe { + siginfo_t info; +- struct ucontext uc; ++ ucontext_t uc; + } *rt_; + + /* movi a2, __NR_rt_sigreturn; syscall */ +-- +2.9.3 + diff --git a/nixpkgs/pkgs/development/compilers/gcc/use-source-date-epoch.patch b/nixpkgs/pkgs/development/compilers/gcc/use-source-date-epoch.patch new file mode 100644 index 000000000000..65a5ab028c1c --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/gcc/use-source-date-epoch.patch @@ -0,0 +1,52 @@ +https://gcc.gnu.org/ml/gcc-patches/2015-06/msg02210.html + +diff --git a/libcpp/macro.c b/libcpp/macro.c +index 1e0a0b5..a52e3cb 100644 +--- a/libcpp/macro.c ++++ b/libcpp/macro.c +@@ -349,14 +349,38 @@ _cpp_builtin_macro_text (cpp_reader *pfile, cpp_hashnode *node) + slow on some systems. */ + time_t tt; + struct tm *tb = NULL; ++ char *source_date_epoch; + +- /* (time_t) -1 is a legitimate value for "number of seconds +- since the Epoch", so we have to do a little dance to +- distinguish that from a genuine error. */ +- errno = 0; +- tt = time(NULL); +- if (tt != (time_t)-1 || errno == 0) +- tb = localtime (&tt); ++ /* Allow the date and time to be set externally by an exported ++ environment variable to enable reproducible builds. */ ++ source_date_epoch = getenv ("SOURCE_DATE_EPOCH"); ++ if (source_date_epoch) ++ { ++ errno = 0; ++ tt = (time_t) strtol (source_date_epoch, NULL, 10); ++ if (errno == 0) ++ { ++ tb = gmtime (&tt); ++ if (tb == NULL) ++ cpp_error (pfile, CPP_DL_ERROR, ++ "SOURCE_DATE_EPOCH=\"%s\" is not a valid date", ++ source_date_epoch); ++ } ++ else ++ cpp_error (pfile, CPP_DL_ERROR, ++ "SOURCE_DATE_EPOCH=\"%s\" is not a valid number", ++ source_date_epoch); ++ } ++ else ++ { ++ /* (time_t) -1 is a legitimate value for "number of seconds ++ since the Epoch", so we have to do a little dance to ++ distinguish that from a genuine error. */ ++ errno = 0; ++ tt = time(NULL); ++ if (tt != (time_t)-1 || errno == 0) ++ tb = localtime (&tt); ++ } + + if (tb) + { diff --git a/nixpkgs/pkgs/development/compilers/gcl/2.6.13-pre.nix b/nixpkgs/pkgs/development/compilers/gcl/2.6.13-pre.nix new file mode 100644 index 000000000000..16450cf24ab4 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/gcl/2.6.13-pre.nix @@ -0,0 +1,51 @@ +{ stdenv, fetchgit, mpfr, m4, binutils, emacs, zlib, which +, texinfo, libX11, xorgproto, libXi, gmp, readline, strace +, libXext, libXt, libXaw, libXmu } : + +assert stdenv ? cc ; +assert stdenv.cc.isGNU ; +assert stdenv.cc ? libc ; +assert stdenv.cc.libc != null ; + +stdenv.mkDerivation rec { + name = "gcl-${version}"; + version = "2.6.13pre50"; + + src = fetchgit { + sha256 = "0vpxb6z5g9fjavrgx8gz8fsjvskfz64f63qibh5s00fvvndlwi88"; + url = "https://git.savannah.gnu.org/r/gcl.git"; + rev = "refs/tags/Version_2_6_13pre50"; + }; + + postPatch = '' + sed -e 's/<= obj-date/<= (if (= 0 obj-date) 1 obj-date)/' -i lsp/make.lisp + '' + # https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=902475 + + '' + substituteInPlace h/elf64_i386_reloc.h \ + --replace 'case R_X86_64_PC32:' 'case R_X86_64_PC32: case R_X86_64_PLT32:' + ''; + + sourceRoot = "gcl/gcl"; + + patches = []; + + buildInputs = [ + mpfr m4 binutils emacs gmp + libX11 xorgproto libXi + libXext libXt libXaw libXmu + zlib which texinfo readline strace + ]; + + configureFlags = [ + "--enable-ansi" + ]; + + hardeningDisable = [ "pic" "bindnow" ]; + + meta = { + description = "GNU Common Lisp compiler working via GCC"; + maintainers = [ stdenv.lib.maintainers.raskin ]; + platforms = stdenv.lib.platforms.linux; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/gcl/default.nix b/nixpkgs/pkgs/development/compilers/gcl/default.nix new file mode 100644 index 000000000000..50d397d2cd47 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/gcl/default.nix @@ -0,0 +1,51 @@ +{ stdenv, fetchurl, mpfr, m4, binutils, emacs, zlib, which +, texinfo, libX11, xorgproto, libXi, gmp +, libXext, libXt, libXaw, libXmu } : + +assert stdenv ? cc ; +assert stdenv.cc.isGNU ; +assert stdenv.cc ? libc ; +assert stdenv.cc.libc != null ; + +stdenv.mkDerivation rec { + name = "gcl-${version}"; + version = "2.6.12"; + + src = fetchurl { + sha256 = "1s4hs2qbjqmn9h88l4xvsifq5c3dlc5s74lyb61rdi5grhdlkf4f"; + url = "http://gnu.spinellicreations.com/gcl/${name}.tar.gz"; + }; + + patches = [(fetchurl { + url = https://gitweb.gentoo.org/repo/gentoo.git/plain/dev-lisp/gcl/files/gcl-2.6.12-gcc5.patch; + sha256 = "00jbsn0qp8ki2w7dx8caha7g2hr9076xa6bg48j3qqqncff93zdh"; + })]; + + # https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=902475 + postPatch = '' + substituteInPlace h/elf64_i386_reloc.h \ + --replace 'case R_X86_64_PC32:' 'case R_X86_64_PC32: case R_X86_64_PLT32:' + ''; + + buildInputs = [ + mpfr m4 binutils emacs gmp + libX11 xorgproto libXi + libXext libXt libXaw libXmu + zlib which texinfo + ]; + + configureFlags = [ + "--enable-ansi" + ]; + + hardeningDisable = [ "pic" "bindnow" ]; + + NIX_CFLAGS_COMPILE = "-fgnu89-inline"; + + meta = with stdenv.lib; { + description = "GNU Common Lisp compiler working via GCC"; + maintainers = [ maintainers.raskin ]; + license = licenses.gpl2; + platforms = platforms.linux; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/gerbil/build.nix b/nixpkgs/pkgs/development/compilers/gerbil/build.nix new file mode 100644 index 000000000000..b20d6f9c47ef --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/gerbil/build.nix @@ -0,0 +1,92 @@ +{ stdenv, makeStaticLibraries, + coreutils, rsync, bash, + openssl, zlib, sqlite, libxml2, libyaml, mysql, lmdb, leveldb, postgresql, + version, git-version, gambit, src }: + +# TODO: distinct packages for gerbil-release and gerbil-devel +# TODO: make static compilation work + +stdenv.mkDerivation rec { + name = "gerbil-${version}"; + inherit src; + + # Use makeStaticLibraries to enable creation of statically linked binaries + buildInputs_libraries = [ openssl zlib sqlite libxml2 libyaml mysql.connector-c lmdb leveldb postgresql ]; + buildInputs_staticLibraries = map makeStaticLibraries buildInputs_libraries; + + buildInputs = [ gambit rsync bash ] + ++ buildInputs_libraries ++ buildInputs_staticLibraries; + + NIX_CFLAGS_COMPILE = [ "-I${mysql.connector-c}/include/mysql" "-L${mysql.connector-c}/lib/mysql" ]; + + postPatch = '' + echo '(define (gerbil-version-string) "v${git-version}")' > src/gerbil/runtime/gx-version.scm + + patchShebangs . + + grep -Fl '#!/usr/bin/env' `find . -type f -executable` | while read f ; do + substituteInPlace "$f" --replace '#!/usr/bin/env' '#!${coreutils}/bin/env' + done + grep -Fl '"gsc"' `find . -type f -name '*.s*'` | while read f ; do + substituteInPlace "$f" --replace '"gsc"' '"${gambit}/bin/gsc"' + done + substituteInPlace "etc/gerbil.el" --replace '"gxc"' "\"$out/bin/gxc\"" + + cat > etc/gerbil_static_libraries.sh <<EOF +#OPENSSL_LIBCRYPTO=${makeStaticLibraries openssl}/lib/libcrypto.a # MISSING! +#OPENSSL_LIBSSL=${makeStaticLibraries openssl}/lib/libssl.a # MISSING! +ZLIB=${makeStaticLibraries zlib}/lib/libz.a +# SQLITE=${makeStaticLibraries sqlite}/lib/sqlite.a # MISSING! +# LIBXML2=${makeStaticLibraries libxml2}/lib/libxml2.a # MISSING! +# YAML=${makeStaticLibraries libyaml}/lib/libyaml.a # MISSING! +MYSQL=${makeStaticLibraries mysql.connector-c}/lib/mariadb/libmariadb.a +# LMDB=${makeStaticLibraries lmdb}/lib/mysql/libmysqlclient_r.a # MISSING! +LEVELDB=${makeStaticLibraries lmdb}/lib/libleveldb.a +EOF + ''; + + buildPhase = '' + runHook preBuild + + # Enable all optional libraries + substituteInPlace "src/std/build-features.ss" --replace '#f' '#t' + + # gxprof testing uses $HOME/.cache/gerbil/gxc + export HOME=$$PWD + + # Build, replacing make by build.sh + ( cd src && sh build.sh ) + + runHook postBuild + ''; + + installPhase = '' + runHook preInstall + mkdir -p $out/ + cp -fa bin lib etc doc $out/ + + cat > $out/bin/gxi <<EOF +#!${bash}/bin/bash -e +export GERBIL_HOME=$out +case "\$1" in -:*) GSIOPTIONS=\$1 ; shift ;; esac +if [[ \$# = 0 ]] ; then + exec ${gambit}/bin/gsi \$GSIOPTIONS \$GERBIL_HOME/lib/gxi-init \$GERBIL_HOME/lib/gxi-interactive - ; +else + exec ${gambit}/bin/gsi \$GSIOPTIONS \$GERBIL_HOME/lib/gxi-init "\$@" +fi +EOF + runHook postInstall + ''; + + dontStrip = true; + + meta = { + description = "Gerbil Scheme"; + homepage = "https://github.com/vyzo/gerbil"; + license = stdenv.lib.licenses.lgpl2; + # NB regarding platforms: only actually tested on Linux, *should* work everywhere, + # but *might* need adaptation e.g. on macOS. Please report success and/or failure to fare. + platforms = stdenv.lib.platforms.unix; + maintainers = with stdenv.lib.maintainers; [ fare ]; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/gerbil/default.nix b/nixpkgs/pkgs/development/compilers/gerbil/default.nix new file mode 100644 index 000000000000..8c6b1a87cd37 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/gerbil/default.nix @@ -0,0 +1,14 @@ +{ stdenv, callPackage, fetchFromGitHub, gambit }: + +callPackage ./build.nix rec { + version = "0.15.1"; + git-version = "0.15.1"; + inherit gambit; + src = fetchFromGitHub { + owner = "vyzo"; + repo = "gerbil"; + rev = "v${version}"; + sha256 = "0qpqms66hz41wwhxb1z0fnzj96ivkm7qi9h9d7lhlr3fsxm1kp1n"; + }; + inherit stdenv; +} diff --git a/nixpkgs/pkgs/development/compilers/gerbil/unstable.nix b/nixpkgs/pkgs/development/compilers/gerbil/unstable.nix new file mode 100644 index 000000000000..6e60ea6fea49 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/gerbil/unstable.nix @@ -0,0 +1,14 @@ +{ stdenv, callPackage, fetchFromGitHub, gambit-unstable }: + +callPackage ./build.nix { + version = "unstable-2019-02-09"; + git-version = "0.16-DEV-15-gafc20fc2"; + gambit = gambit-unstable; + src = fetchFromGitHub { + owner = "vyzo"; + repo = "gerbil"; + rev = "afc20fc21030e8445b46b8267cc4c52cfd662aad"; + sha256 = "02v16zya9zryjs4wallibp1kvnpba60aw15y4k7zhddc71qjfbhw"; + }; + inherit stdenv; +} diff --git a/nixpkgs/pkgs/development/compilers/gforth/default.nix b/nixpkgs/pkgs/development/compilers/gforth/default.nix new file mode 100644 index 000000000000..675522d54ead --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/gforth/default.nix @@ -0,0 +1,29 @@ +{ stdenv, fetchurl, m4 }: + +let + version = "0.7.3"; +in +stdenv.mkDerivation { + name = "gforth-${version}"; + src = fetchurl { + url = "https://ftp.gnu.org/gnu/gforth/gforth-${version}.tar.gz"; + sha256 = "1c1bahc9ypmca8rv2dijiqbangm1d9av286904yw48ph7ciz4qig"; + }; + + buildInputs = [ m4 ]; + + configureFlags = stdenv.lib.optional stdenv.isDarwin [ "--build=x86_64-apple-darwin" ]; + + postInstall = '' + mkdir -p $out/share/emacs/site-lisp + cp gforth.el $out/share/emacs/site-lisp/ + ''; + + meta = { + description = "The Forth implementation of the GNU project"; + homepage = https://www.gnu.org/software/gforth/; + license = stdenv.lib.licenses.gpl3; + platforms = stdenv.lib.platforms.all; + maintainers = with stdenv.lib.maintainers; [ the-kenny ]; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/ghc/8.2.2-binary.nix b/nixpkgs/pkgs/development/compilers/ghc/8.2.2-binary.nix new file mode 100644 index 000000000000..9fe3a7d9dba3 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/ghc/8.2.2-binary.nix @@ -0,0 +1,188 @@ +{ stdenv, substituteAll +, fetchurl, perl, gcc, llvm_39 +, ncurses5, gmp, glibc, libiconv +}: + +# Prebuilt only does native +assert stdenv.targetPlatform == stdenv.hostPlatform; + +let + libPath = stdenv.lib.makeLibraryPath ([ + ncurses5 gmp + ] ++ stdenv.lib.optional (stdenv.hostPlatform.isDarwin) libiconv); + + libEnvVar = stdenv.lib.optionalString stdenv.hostPlatform.isDarwin "DY" + + "LD_LIBRARY_PATH"; + + glibcDynLinker = assert stdenv.isLinux; + if stdenv.hostPlatform.libc == "glibc" then + # Could be stdenv.cc.bintools.dynamicLinker, keeping as-is to avoid rebuild. + ''"$(cat $NIX_CC/nix-support/dynamic-linker)"'' + else + "${stdenv.lib.getLib glibc}/lib/ld-linux*"; + +in + +stdenv.mkDerivation rec { + version = "8.2.2"; + + name = "ghc-${version}-binary"; + + src = fetchurl ({ + "i686-linux" = { + url = "http://haskell.org/ghc/dist/${version}/ghc-${version}-i386-deb8-linux.tar.xz"; + sha256 = "08w2ik55dp3n95qikmrflc91lsiq01xp53ki3jlhnbj8fqnxfrwy"; + }; + "x86_64-linux" = { + url = "http://haskell.org/ghc/dist/${version}/ghc-${version}-x86_64-deb8-linux.tar.xz"; + sha256 = "0ahv26304pqi3dm7i78si4pxwvg5f5dc2jwsfgvcrhcx5g30bqj8"; + }; + "armv7l-linux" = { + url = "http://haskell.org/ghc/dist/${version}/ghc-${version}-armv7-deb8-linux.tar.xz"; + sha256 = "1jmv8qmnh5bn324fivbwdcaj55kvw7cb2zq9pafmlmv3qwwx7s46"; + }; + "aarch64-linux" = { + url = "http://haskell.org/ghc/dist/${version}/ghc-${version}-aarch64-deb8-linux.tar.xz"; + sha256 = "1k2amylcp1ad67c75h1pqf7czf9m0zj1i7hdc45ghjklnfq9hrk7"; + }; + "x86_64-darwin" = { + url = "http://haskell.org/ghc/dist/${version}/ghc-${version}-x86_64-apple-darwin.tar.xz"; + sha256 = "09swx71gh5habzbx55shz2xykgr96xkcy09nzinnm4z0yxicy3zr"; + }; + }.${stdenv.hostPlatform.system} + or (throw "cannot bootstrap GHC on this platform")); + + nativeBuildInputs = [ perl ]; + buildInputs = stdenv.lib.optionals (stdenv.targetPlatform.isAarch32 || stdenv.targetPlatform.isAarch64) [ llvm_39 ]; + + # Cannot patchelf beforehand due to relative RPATHs that anticipate + # the final install location/ + ${libEnvVar} = libPath; + + postUnpack = + # GHC has dtrace probes, which causes ld to try to open /usr/lib/libdtrace.dylib + # during linking + stdenv.lib.optionalString stdenv.isDarwin '' + export NIX_LDFLAGS+=" -no_dtrace_dof" + # not enough room in the object files for the full path to libiconv :( + for exe in $(find . -type f -executable); do + isScript $exe && continue + ln -fs ${libiconv}/lib/libiconv.dylib $(dirname $exe)/libiconv.dylib + install_name_tool -change /usr/lib/libiconv.2.dylib @executable_path/libiconv.dylib -change /usr/local/lib/gcc/6/libgcc_s.1.dylib ${gcc.cc.lib}/lib/libgcc_s.1.dylib $exe + done + '' + + + # Some scripts used during the build need to have their shebangs patched + '' + patchShebangs ghc-${version}/utils/ + patchShebangs ghc-${version}/configure + '' + + + # Strip is harmful, see also below. It's important that this happens + # first. The GHC Cabal build system makes use of strip by default and + # has hardcoded paths to /usr/bin/strip in many places. We replace + # those below, making them point to our dummy script. + '' + mkdir "$TMP/bin" + for i in strip; do + echo '#! ${stdenv.shell}' > "$TMP/bin/$i" + chmod +x "$TMP/bin/$i" + done + PATH="$TMP/bin:$PATH" + '' + + # We have to patch the GMP paths for the integer-gmp package. + '' + find . -name integer-gmp.buildinfo \ + -exec sed -i "s@extra-lib-dirs: @extra-lib-dirs: ${gmp.out}/lib@" {} \; + '' + stdenv.lib.optionalString stdenv.isDarwin '' + find . -name base.buildinfo \ + -exec sed -i "s@extra-lib-dirs: @extra-lib-dirs: ${libiconv}/lib@" {} \; + '' + + # Rename needed libraries and binaries, fix interpreter + stdenv.lib.optionalString stdenv.isLinux '' + find . -type f -perm -0100 -exec patchelf \ + --replace-needed libncurses${stdenv.lib.optionalString stdenv.is64bit "w"}.so.5 libncurses.so \ + --replace-needed libtinfo.so libtinfo.so.5 \ + --interpreter ${glibcDynLinker} {} \; + + sed -i "s|/usr/bin/perl|perl\x00 |" ghc-${version}/ghc/stage2/build/tmp/ghc-stage2 + sed -i "s|/usr/bin/gcc|gcc\x00 |" ghc-${version}/ghc/stage2/build/tmp/ghc-stage2 + '' + + # We're kludging a glibc bindist into working with non-glibc... + # Here we patch up the use of `__strdup` (part of glibc binary ABI) + # to instead use `strdup` since musl doesn't provide __strdup + # (`__strdup` is defined to be an alias of `strdup` anyway[1]). + # [1] http://refspecs.linuxbase.org/LSB_4.0.0/LSB-Core-generic/LSB-Core-generic/baselib---strdup-1.html + # Use objcopy magic to make the change: + stdenv.lib.optionalString stdenv.hostPlatform.isMusl '' + find ./ghc-${version}/rts -name "libHSrts*.a" -exec ''${OBJCOPY:-objcopy} --redefine-sym __strdup=strdup {} \; + ''; + + configurePlatforms = [ ]; + configureFlags = + let + gcc-clang-wrapper = substituteAll { + inherit (stdenv) shell; + isExecutable = true; + src = ./gcc-clang-wrapper.sh; + }; + in + [ "--with-gmp-libraries=${stdenv.lib.getLib gmp}/lib" + "--with-gmp-includes=${stdenv.lib.getDev gmp}/include" + ] ++ stdenv.lib.optional stdenv.isDarwin "--with-gcc=${gcc-clang-wrapper}" + ++ stdenv.lib.optional stdenv.hostPlatform.isMusl "--disable-ld-override"; + + # Stripping combined with patchelf breaks the executables (they die + # with a segfault or the kernel even refuses the execve). (NIXPKGS-85) + dontStrip = true; + + # No building is necessary, but calling make without flags ironically + # calls install-strip ... + dontBuild = true; + + # On Linux, use patchelf to modify the executables so that they can + # find editline/gmp. + preFixup = stdenv.lib.optionalString stdenv.isLinux '' + for p in $(find "$out" -type f -executable); do + if isELF "$p"; then + echo "Patchelfing $p" + patchelf --set-rpath "${libPath}:$(patchelf --print-rpath $p)" $p + fi + done + '' + stdenv.lib.optionalString stdenv.isDarwin '' + # not enough room in the object files for the full path to libiconv :( + for exe in $(find "$out" -type f -executable); do + isScript $exe && continue + ln -fs ${libiconv}/lib/libiconv.dylib $(dirname $exe)/libiconv.dylib + install_name_tool -change /usr/lib/libiconv.2.dylib @executable_path/libiconv.dylib -change /usr/local/lib/gcc/6/libgcc_s.1.dylib ${gcc.cc.lib}/lib/libgcc_s.1.dylib $exe + done + + for file in $(find "$out" -name setup-config); do + substituteInPlace $file --replace /usr/bin/ranlib "$(type -P ranlib)" + done + ''; + + doInstallCheck = true; + installCheckPhase = '' + unset ${libEnvVar} + # Sanity check, can ghc create executables? + cd $TMP + mkdir test-ghc; cd test-ghc + cat > main.hs << EOF + {-# LANGUAGE TemplateHaskell #-} + module Main where + main = putStrLn \$([|"yes"|]) + EOF + $out/bin/ghc --make main.hs || exit 1 + echo compilation ok + [ $(./main) == "yes" ] + ''; + + passthru = { + targetPrefix = ""; + enableShared = true; + }; + + meta.license = stdenv.lib.licenses.bsd3; + meta.platforms = ["x86_64-linux" "i686-linux" "x86_64-darwin" "armv7l-linux" "aarch64-linux"]; +} diff --git a/nixpkgs/pkgs/development/compilers/ghc/8.2.2.nix b/nixpkgs/pkgs/development/compilers/ghc/8.2.2.nix new file mode 100644 index 000000000000..a88cf9c01165 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/ghc/8.2.2.nix @@ -0,0 +1,271 @@ +{ stdenv, pkgsBuildTarget, targetPackages + +# build-tools +, bootPkgs +, autoconf, autoreconfHook, automake, coreutils, fetchurl, fetchpatch, perl, python3, sphinx +, runCommand + +, libiconv ? null, ncurses + +, useLLVM ? !stdenv.targetPlatform.isx86 || (stdenv.targetPlatform.isMusl && stdenv.hostPlatform != stdenv.targetPlatform) +, # LLVM is conceptually a run-time-only depedendency, but for + # non-x86, we need LLVM to bootstrap later stages, so it becomes a + # build-time dependency too. + buildLlvmPackages, llvmPackages + +, # If enabled, GHC will be built with the GPL-free but slower integer-simple + # library instead of the faster but GPLed integer-gmp library. + enableIntegerSimple ? !(stdenv.lib.any (stdenv.lib.meta.platformMatch stdenv.hostPlatform) gmp.meta.platforms), gmp + +, # If enabled, use -fPIC when compiling static libs. + enableRelocatedStaticLibs ? stdenv.targetPlatform != stdenv.hostPlatform + +, # Whether to build dynamic libs for the standard library (on the target + # platform). Static libs are always built. + enableShared ? !stdenv.targetPlatform.useiOSPrebuilt + +, # What flavour to build. An empty string indicates no + # specific flavour and falls back to ghc default values. + ghcFlavour ? stdenv.lib.optionalString (stdenv.targetPlatform != stdenv.hostPlatform) "perf-cross" +, # Whether to backport https://phabricator.haskell.org/D4388 for + # deterministic profiling symbol names, at the cost of a slightly + # non-standard GHC API + deterministicProfiling ? false +}: + +assert !enableIntegerSimple -> gmp != null; + +let + inherit (stdenv) buildPlatform hostPlatform targetPlatform; + + inherit (bootPkgs) ghc; + + # TODO(@Ericson2314) Make unconditional + targetPrefix = stdenv.lib.optionalString + (targetPlatform != hostPlatform) + "${targetPlatform.config}-"; + + buildMK = '' + BuildFlavour = ${ghcFlavour} + ifneq \"\$(BuildFlavour)\" \"\" + include mk/flavours/\$(BuildFlavour).mk + endif + DYNAMIC_GHC_PROGRAMS = ${if enableShared then "YES" else "NO"} + INTEGER_LIBRARY = ${if enableIntegerSimple then "integer-simple" else "integer-gmp"} + '' + stdenv.lib.optionalString (targetPlatform != hostPlatform) '' + Stage1Only = ${if targetPlatform.system == hostPlatform.system then "NO" else "YES"} + CrossCompilePrefix = ${targetPrefix} + HADDOCK_DOCS = NO + BUILD_SPHINX_HTML = NO + BUILD_SPHINX_PDF = NO + '' + stdenv.lib.optionalString enableRelocatedStaticLibs '' + GhcLibHcOpts += -fPIC + GhcRtsHcOpts += -fPIC + '' + stdenv.lib.optionalString targetPlatform.useAndroidPrebuilt '' + EXTRA_CC_OPTS += -std=gnu99 + ''; + + # Splicer will pull out correct variations + libDeps = platform: [ ncurses ] + ++ stdenv.lib.optional (!enableIntegerSimple) gmp + ++ stdenv.lib.optional (platform.libc != "glibc") libiconv; + + toolsForTarget = [ + pkgsBuildTarget.targetPackages.stdenv.cc + ] ++ stdenv.lib.optional useLLVM buildLlvmPackages.llvm; + + targetCC = builtins.head toolsForTarget; + +in +stdenv.mkDerivation (rec { + version = "8.2.2"; + name = "${targetPrefix}ghc-${version}"; + + src = fetchurl { + url = "https://downloads.haskell.org/~ghc/${version}/ghc-${version}-src.tar.xz"; + sha256 = "1z05vkpaj54xdypmaml50hgsdpw29dhbs2r7magx0cm199iw73mv"; + }; + + enableParallelBuilding = true; + + outputs = [ "out" "doc" ]; + + patches = [ + (fetchpatch { # Fix STRIP to be substituted from configure + url = "https://git.haskell.org/ghc.git/commitdiff_plain/2fc8ce5f0c8c81771c26266ac0b150ca9b75c5f3"; + sha256 = "03253ci40np1v6k0wmi4aypj3nmj3rdyvb1k6rwqipb30nfc719f"; + }) + (import ./abi-depends-determinism.nix { inherit fetchpatch runCommand; }) + ] ++ stdenv.lib.optionals (hostPlatform != targetPlatform) [ + # Cherry-pick a few commits from newer hsc2hs so that proper binary is + # installed -- stage 2 normally but stage 1 with cross. + # + # TODO make unconditional next mass rebuild. + (fetchpatch { + url = "https://git.haskell.org/hsc2hs.git/patch/ecdac062b5cf1d284906487849c56f4e149b3c8e"; + sha256 = "1gagswi26j50z44sdx0mk1sb3wr0nrqyaph9j724zp6iwqslxyzm"; + extraPrefix = "utils/hsc2hs/"; + stripLen = 1; + }) + (fetchpatch { + url = "https://git.haskell.org/hsc2hs.git/patch/598303cbffcd230635fbce28ce4105d177fdf76a"; + sha256 = "0hqcg434qbh1bz1pk85cap2q4v9i8bs6x65yzq4spz6xk3zq6af7"; + extraPrefix = "utils/hsc2hs/"; + stripLen = 1; + }) + (fetchpatch { + url = "https://git.haskell.org/hsc2hs.git/patch/9483ad10064fbbb97ab525280623826b1ef63959"; + sha256 = "1cpfdhfc0cz9xkjzkcgwx4fbyj96dkmd04wpwi1vji7fahw8kmf3"; + extraPrefix = "utils/hsc2hs/"; + stripLen = 1; + }) + (fetchpatch { + url = "https://git.haskell.org/hsc2hs.git/patch/738f3666c878ee9e79c3d5e819ef8b3460288edf"; + sha256 = "0plzsbfaq6vb1023lsarrjglwgr9chld4q3m99rcfzx0yx5mibp3"; + extraPrefix = "utils/hsc2hs/"; + stripLen = 1; + }) + ] ++ stdenv.lib.optionals (hostPlatform != targetPlatform && targetPlatform.system == hostPlatform.system) [ + (fetchpatch { + url = "https://raw.githubusercontent.com/gentoo/gentoo/08a41d2dff99645af6ac5a7bb4774f5f193b6f20/dev-lang/ghc/files/ghc-8.2.1_rc1-unphased-cross.patch"; + sha256 = "1hxj80bjx0x3w0f35cj3k2wipppr1ald03jwfy5q0xlxygdha17w"; + }) + (fetchpatch { + url = "https://raw.githubusercontent.com/gentoo/gentoo/08a41d2dff99645af6ac5a7bb4774f5f193b6f20/dev-lang/ghc/files/ghc-8.2.1_rc1-staged-cross.patch"; + sha256 = "12xsln3zyfpvml8bwdpbc003h6zl1qh2qcq1rhdrw02n45dz8lvc"; + }) + (fetchpatch { + url = "https://raw.githubusercontent.com/gentoo/gentoo/08a41d2dff99645af6ac5a7bb4774f5f193b6f20/dev-lang/ghc/files/ghc-8.2.1_rc1-ghci-cross.patch"; + sha256 = "03dcqf5af3vjhrky3f2z26j4d9h8qd9nkv76xp0l97h4cqk7vfqb"; + }) + (fetchpatch { + url = "https://raw.githubusercontent.com/gentoo/gentoo/08a41d2dff99645af6ac5a7bb4774f5f193b6f20/dev-lang/ghc/files/ghc-8.2.1_rc1-stage2-cross.patch"; + sha256 = "0pi2m85wjxaaablq6n4q5vyn9qxvry5d7nmja4b28i68yb4ly9g1"; + }) + (fetchpatch { + url = "https://raw.githubusercontent.com/gentoo/gentoo/08a41d2dff99645af6ac5a7bb4774f5f193b6f20/dev-lang/ghc/files/ghc-8.2.1_rc1-hp2ps-cross.patch"; + sha256 = "1fszfavf1cvrf02x500mi7jykcpvpl2i7i4qzr2qz9sbmyq063f0"; + }) + ] ++ stdenv.lib.optional deterministicProfiling + (fetchpatch { # Backport of https://phabricator.haskell.org/D4388 for more determinism + url = "https://github.com/shlevy/ghc/commit/fec1b8d3555c447c0d8da0e96b659be67c8bb4bc.patch"; + sha256 = "1lyysz6hfd1njcigpm8xppbnkadqfs0kvrp7s8vqgb38pjswj5hg"; + }) + ++ stdenv.lib.optional stdenv.isDarwin ./backport-dylib-command-size-limit.patch; + + postPatch = "patchShebangs ."; + + # GHC is a bit confused on its cross terminology. + preConfigure = '' + for env in $(env | grep '^TARGET_' | sed -E 's|\+?=.*||'); do + export "''${env#TARGET_}=''${!env}" + done + # GHC is a bit confused on its cross terminology, as these would normally be + # the *host* tools. + export CC="${targetCC}/bin/${targetCC.targetPrefix}cc" + export CXX="${targetCC}/bin/${targetCC.targetPrefix}cxx" + # Use gold to work around https://sourceware.org/bugzilla/show_bug.cgi?id=16177 + export LD="${targetCC.bintools}/bin/${targetCC.bintools.targetPrefix}ld${stdenv.lib.optionalString targetPlatform.isAarch32 ".gold"}" + export AS="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}as" + export AR="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}ar" + export NM="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}nm" + export RANLIB="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}ranlib" + export READELF="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}readelf" + export STRIP="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}strip" + + echo -n "${buildMK}" > mk/build.mk + sed -i -e 's|-isysroot /Developer/SDKs/MacOSX10.5.sdk||' configure + '' + stdenv.lib.optionalString (!stdenv.isDarwin) '' + export NIX_LDFLAGS+=" -rpath $out/lib/ghc-${version}" + '' + stdenv.lib.optionalString stdenv.isDarwin '' + export NIX_LDFLAGS+=" -no_dtrace_dof" + ''; + + # TODO(@Ericson2314): Always pass "--target" and always prefix. + configurePlatforms = [ "build" "host" ] + ++ stdenv.lib.optional (targetPlatform != hostPlatform) "target"; + # `--with` flags for libraries needed for RTS linker + configureFlags = [ + "--datadir=$doc/share/doc/ghc" + ] ++ stdenv.lib.optional (targetPlatform == hostPlatform) [ + "--with-curses-includes=${ncurses.dev}/include" "--with-curses-libraries=${ncurses.out}/lib" + ] ++ stdenv.lib.optional (targetPlatform == hostPlatform && !enableIntegerSimple) [ + "--with-gmp-includes=${targetPackages.gmp.dev}/include" "--with-gmp-libraries=${targetPackages.gmp.out}/lib" + ] ++ stdenv.lib.optional (targetPlatform == hostPlatform && hostPlatform.libc != "glibc") [ + "--with-iconv-includes=${libiconv}/include" "--with-iconv-libraries=${libiconv}/lib" + ] ++ stdenv.lib.optionals (targetPlatform != hostPlatform) [ + "--enable-bootstrap-with-devel-snapshot" + ] ++ stdenv.lib.optionals (targetPlatform.isAarch32) [ + "CFLAGS=-fuse-ld=gold" + "CONF_GCC_LINKER_OPTS_STAGE1=-fuse-ld=gold" + "CONF_GCC_LINKER_OPTS_STAGE2=-fuse-ld=gold" + ] ++ stdenv.lib.optionals (targetPlatform.isDarwin && targetPlatform.isAarch64) [ + # fix for iOS: https://www.reddit.com/r/haskell/comments/4ttdz1/building_an_osxi386_to_iosarm64_cross_compiler/d5qvd67/ + "--disable-large-address-space" + ]; + + # Don’t add -liconv to LDFLAGS automatically so that GHC will add it itself. + dontAddExtraLibs = true; + + # Make sure we never relax`$PATH` and hooks support for compatability. + strictDeps = true; + + nativeBuildInputs = [ + autoconf autoreconfHook automake perl python3 sphinx + ghc bootPkgs.alex bootPkgs.happy bootPkgs.hscolour + ]; + + # For building runtime libs + depsBuildTarget = toolsForTarget; + + buildInputs = [ perl ] ++ (libDeps hostPlatform); + + propagatedBuildInputs = [ targetPackages.stdenv.cc ] + ++ stdenv.lib.optional useLLVM llvmPackages.llvm; + + depsTargetTarget = map stdenv.lib.getDev (libDeps targetPlatform); + depsTargetTargetPropagated = map (stdenv.lib.getOutput "out") (libDeps targetPlatform); + + # required, because otherwise all symbols from HSffi.o are stripped, and + # that in turn causes GHCi to abort + stripDebugFlags = [ "-S" ] ++ stdenv.lib.optional (!targetPlatform.isDarwin) "--keep-file-symbols"; + + checkTarget = "test"; + doCheck = false; # fails with "testsuite/tests: No such file or directory. Stop." + + hardeningDisable = [ "format" ] ++ stdenv.lib.optional stdenv.targetPlatform.isMusl "pie"; + + postInstall = '' + # Install the bash completion file. + install -D -m 444 utils/completion/ghc.bash $out/share/bash-completion/completions/${targetPrefix}ghc + + # Patch scripts to include "readelf" and "cat" in $PATH. + for i in "$out/bin/"*; do + test ! -h $i || continue + egrep --quiet '^#!' <(head -n 1 $i) || continue + sed -i -e '2i export PATH="$PATH:${stdenv.lib.makeBinPath [ targetPackages.stdenv.cc.bintools coreutils ]}"' $i + done + ''; + + passthru = { + inherit bootPkgs targetPrefix; + + inherit llvmPackages; + inherit enableShared; + + # Our Cabal compiler name + haskellCompilerName = "ghc-8.2.2"; + }; + + meta = { + homepage = http://haskell.org/ghc; + description = "The Glasgow Haskell Compiler"; + maintainers = with stdenv.lib.maintainers; [ marcweber andres peti ]; + inherit (ghc.meta) license platforms; + }; + +} // stdenv.lib.optionalAttrs targetPlatform.useAndroidPrebuilt { + dontStrip = true; + dontPatchELF = true; + noAuditTmpdir = true; +}) diff --git a/nixpkgs/pkgs/development/compilers/ghc/8.4.4.nix b/nixpkgs/pkgs/development/compilers/ghc/8.4.4.nix new file mode 100644 index 000000000000..da72c351ec66 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/ghc/8.4.4.nix @@ -0,0 +1,247 @@ +{ stdenv, pkgsBuildTarget, targetPackages + +# build-tools +, bootPkgs +, autoconf, automake, coreutils, fetchurl, fetchpatch, perl, python3, m4, sphinx + +, libiconv ? null, ncurses + +, useLLVM ? !stdenv.targetPlatform.isx86 || (stdenv.targetPlatform.isMusl && stdenv.hostPlatform != stdenv.targetPlatform) +, # LLVM is conceptually a run-time-only depedendency, but for + # non-x86, we need LLVM to bootstrap later stages, so it becomes a + # build-time dependency too. + buildLlvmPackages, llvmPackages + +, # If enabled, GHC will be built with the GPL-free but slower integer-simple + # library instead of the faster but GPLed integer-gmp library. + enableIntegerSimple ? !(stdenv.lib.any (stdenv.lib.meta.platformMatch stdenv.hostPlatform) gmp.meta.platforms), gmp + +, # If enabled, use -fPIC when compiling static libs. + enableRelocatedStaticLibs ? stdenv.targetPlatform != stdenv.hostPlatform + +, # Whether to build dynamic libs for the standard library (on the target + # platform). Static libs are always built. + enableShared ? !stdenv.targetPlatform.isWindows && !stdenv.targetPlatform.useiOSPrebuilt + +, # Whetherto build terminfo. + enableTerminfo ? !stdenv.targetPlatform.isWindows + +, # What flavour to build. An empty string indicates no + # specific flavour and falls back to ghc default values. + ghcFlavour ? stdenv.lib.optionalString (stdenv.targetPlatform != stdenv.hostPlatform) "perf-cross" +, # Whether to backport https://phabricator.haskell.org/D4388 for + # deterministic profiling symbol names, at the cost of a slightly + # non-standard GHC API + deterministicProfiling ? false +}: + +assert !enableIntegerSimple -> gmp != null; + +let + inherit (stdenv) buildPlatform hostPlatform targetPlatform; + + inherit (bootPkgs) ghc; + + # TODO(@Ericson2314) Make unconditional + targetPrefix = stdenv.lib.optionalString + (targetPlatform != hostPlatform) + "${targetPlatform.config}-"; + + buildMK = '' + BuildFlavour = ${ghcFlavour} + ifneq \"\$(BuildFlavour)\" \"\" + include mk/flavours/\$(BuildFlavour).mk + endif + DYNAMIC_GHC_PROGRAMS = ${if enableShared then "YES" else "NO"} + INTEGER_LIBRARY = ${if enableIntegerSimple then "integer-simple" else "integer-gmp"} + '' + stdenv.lib.optionalString (targetPlatform != hostPlatform) '' + Stage1Only = ${if targetPlatform.system == hostPlatform.system then "NO" else "YES"} + CrossCompilePrefix = ${targetPrefix} + HADDOCK_DOCS = NO + BUILD_SPHINX_HTML = NO + BUILD_SPHINX_PDF = NO + '' + stdenv.lib.optionalString enableRelocatedStaticLibs '' + GhcLibHcOpts += -fPIC + GhcRtsHcOpts += -fPIC + '' + stdenv.lib.optionalString targetPlatform.useAndroidPrebuilt '' + EXTRA_CC_OPTS += -std=gnu99 + ''; + + # Splicer will pull out correct variations + libDeps = platform: stdenv.lib.optional enableTerminfo [ ncurses ] + ++ stdenv.lib.optional (!enableIntegerSimple) gmp + ++ stdenv.lib.optional (platform.libc != "glibc" && !targetPlatform.isWindows) libiconv; + + toolsForTarget = [ + pkgsBuildTarget.targetPackages.stdenv.cc + ] ++ stdenv.lib.optional useLLVM buildLlvmPackages.llvm; + + targetCC = builtins.head toolsForTarget; + +in +stdenv.mkDerivation (rec { + version = "8.4.4"; + name = "${targetPrefix}ghc-${version}"; + + src = fetchurl { + url = "https://downloads.haskell.org/~ghc/${version}/ghc-${version}-src.tar.xz"; + sha256 = "1ch4j2asg7pr52ai1hwzykxyj553wndg7wq93i47ql4fllspf48i"; + }; + + enableParallelBuilding = true; + + outputs = [ "out" "doc" ]; + + patches = [(fetchpatch { + url = "https://git.haskell.org/hsc2hs.git/patch/738f3666c878ee9e79c3d5e819ef8b3460288edf"; + sha256 = "0plzsbfaq6vb1023lsarrjglwgr9chld4q3m99rcfzx0yx5mibp3"; + extraPrefix = "utils/hsc2hs/"; + stripLen = 1; + }) (fetchpatch rec { # https://phabricator.haskell.org/D5123 + url = "http://tarballs.nixos.org/sha256/${sha256}"; + name = "D5123.diff"; + sha256 = "0nhqwdamf2y4gbwqxcgjxs0kqx23w9gv5kj0zv6450dq19rji82n"; + })] ++ stdenv.lib.optional deterministicProfiling + (fetchpatch rec { + url = "http://tarballs.nixos.org/sha256/${sha256}"; + name = "D4388.diff"; + sha256 = "0w6sdcvnqjlnlzpvnzw20b80v150ijjyjvs9548ildc1928j0w7s"; + }) + ++ stdenv.lib.optional stdenv.isDarwin ./backport-dylib-command-size-limit.patch + ++ stdenv.lib.optional (targetPlatform.isAarch32 || targetPlatform.isAarch64) (fetchpatch { + url = "https://git.haskell.org/ghc.git/patch/d8495549ba9d194815c2d0eaee6797fc7c00756a"; + sha256 = "1yjcma507c609bcim4rnxq0gaj2dg4d001jklmbpbqpzqzxkn5sz"; + }); + + postPatch = "patchShebangs ."; + + # GHC is a bit confused on its cross terminology. + preConfigure = '' + for env in $(env | grep '^TARGET_' | sed -E 's|\+?=.*||'); do + export "''${env#TARGET_}=''${!env}" + done + # GHC is a bit confused on its cross terminology, as these would normally be + # the *host* tools. + export CC="${targetCC}/bin/${targetCC.targetPrefix}cc" + export CXX="${targetCC}/bin/${targetCC.targetPrefix}cxx" + # Use gold to work around https://sourceware.org/bugzilla/show_bug.cgi?id=16177 + export LD="${targetCC.bintools}/bin/${targetCC.bintools.targetPrefix}ld${stdenv.lib.optionalString targetPlatform.isAarch32 ".gold"}" + export AS="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}as" + export AR="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}ar" + export NM="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}nm" + export RANLIB="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}ranlib" + export READELF="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}readelf" + export STRIP="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}strip" + + echo -n "${buildMK}" > mk/build.mk + sed -i -e 's|-isysroot /Developer/SDKs/MacOSX10.5.sdk||' configure + '' + stdenv.lib.optionalString (!stdenv.isDarwin) '' + export NIX_LDFLAGS+=" -rpath $out/lib/ghc-${version}" + '' + stdenv.lib.optionalString stdenv.isDarwin '' + export NIX_LDFLAGS+=" -no_dtrace_dof" + '' + stdenv.lib.optionalString targetPlatform.useAndroidPrebuilt '' + sed -i -e '5i ,("armv7a-unknown-linux-androideabi", ("e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64", "cortex-a8", ""))' llvm-targets + '' + stdenv.lib.optionalString targetPlatform.isMusl '' + echo "patching llvm-targets for musl targets..." + echo "Cloning these existing '*-linux-gnu*' targets:" + grep linux-gnu llvm-targets | sed 's/^/ /' + echo "(go go gadget sed)" + sed -i 's,\(^.*linux-\)gnu\(.*\)$,\0\n\1musl\2,' llvm-targets + echo "llvm-targets now contains these '*-linux-musl*' targets:" + grep linux-musl llvm-targets | sed 's/^/ /' + + echo "And now patching to preserve '-musleabi' as done with '-gnueabi'" + # (aclocal.m4 is actual source, but patch configure as well since we don't re-gen) + for x in configure aclocal.m4; do + substituteInPlace $x \ + --replace '*-android*|*-gnueabi*)' \ + '*-android*|*-gnueabi*|*-musleabi*)' + done + ''; + + # TODO(@Ericson2314): Always pass "--target" and always prefix. + configurePlatforms = [ "build" "host" ] + ++ stdenv.lib.optional (targetPlatform != hostPlatform) "target"; + # `--with` flags for libraries needed for RTS linker + configureFlags = [ + "--datadir=$doc/share/doc/ghc" + "--with-curses-includes=${ncurses.dev}/include" "--with-curses-libraries=${ncurses.out}/lib" + ] ++ stdenv.lib.optional (targetPlatform == hostPlatform && !enableIntegerSimple) [ + "--with-gmp-includes=${targetPackages.gmp.dev}/include" "--with-gmp-libraries=${targetPackages.gmp.out}/lib" + ] ++ stdenv.lib.optional (targetPlatform == hostPlatform && hostPlatform.libc != "glibc" && !targetPlatform.isWindows) [ + "--with-iconv-includes=${libiconv}/include" "--with-iconv-libraries=${libiconv}/lib" + ] ++ stdenv.lib.optionals (targetPlatform != hostPlatform) [ + "--enable-bootstrap-with-devel-snapshot" + ] ++ stdenv.lib.optionals (targetPlatform.isAarch32) [ + "CFLAGS=-fuse-ld=gold" + "CONF_GCC_LINKER_OPTS_STAGE1=-fuse-ld=gold" + "CONF_GCC_LINKER_OPTS_STAGE2=-fuse-ld=gold" + ] ++ stdenv.lib.optionals (targetPlatform.isDarwin && targetPlatform.isAarch64) [ + # fix for iOS: https://www.reddit.com/r/haskell/comments/4ttdz1/building_an_osxi386_to_iosarm64_cross_compiler/d5qvd67/ + "--disable-large-address-space" + ]; + + # Make sure we never relax`$PATH` and hooks support for compatability. + strictDeps = true; + + # Don’t add -liconv to LDFLAGS automatically so that GHC will add it itself. + dontAddExtraLibs = true; + + nativeBuildInputs = [ + perl autoconf automake m4 python3 sphinx + ghc bootPkgs.alex bootPkgs.happy bootPkgs.hscolour + ]; + + # For building runtime libs + depsBuildTarget = toolsForTarget; + + buildInputs = [ perl ] ++ (libDeps hostPlatform); + + propagatedBuildInputs = [ targetPackages.stdenv.cc ] + ++ stdenv.lib.optional useLLVM llvmPackages.llvm; + + depsTargetTarget = map stdenv.lib.getDev (libDeps targetPlatform); + depsTargetTargetPropagated = map (stdenv.lib.getOutput "out") (libDeps targetPlatform); + + # required, because otherwise all symbols from HSffi.o are stripped, and + # that in turn causes GHCi to abort + stripDebugFlags = [ "-S" ] ++ stdenv.lib.optional (!targetPlatform.isDarwin) "--keep-file-symbols"; + + checkTarget = "test"; + + hardeningDisable = [ "format" ] ++ stdenv.lib.optional stdenv.targetPlatform.isMusl "pie"; + + postInstall = '' + # Install the bash completion file. + install -D -m 444 utils/completion/ghc.bash $out/share/bash-completion/completions/${targetPrefix}ghc + + # Patch scripts to include "readelf" and "cat" in $PATH. + for i in "$out/bin/"*; do + test ! -h $i || continue + egrep --quiet '^#!' <(head -n 1 $i) || continue + sed -i -e '2i export PATH="$PATH:${stdenv.lib.makeBinPath [ targetPackages.stdenv.cc.bintools coreutils ]}"' $i + done + ''; + + passthru = { + inherit bootPkgs targetPrefix; + + inherit llvmPackages; + inherit enableShared; + + # Our Cabal compiler name + haskellCompilerName = "ghc-8.4.4"; + }; + + meta = { + homepage = http://haskell.org/ghc; + description = "The Glasgow Haskell Compiler"; + maintainers = with stdenv.lib.maintainers; [ marcweber andres peti ]; + inherit (ghc.meta) license platforms; + }; + +} // stdenv.lib.optionalAttrs targetPlatform.useAndroidPrebuilt { + dontStrip = true; + dontPatchELF = true; + noAuditTmpdir = true; +}) diff --git a/nixpkgs/pkgs/development/compilers/ghc/8.6.3-binary.nix b/nixpkgs/pkgs/development/compilers/ghc/8.6.3-binary.nix new file mode 100644 index 000000000000..7e845da5b648 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/ghc/8.6.3-binary.nix @@ -0,0 +1,173 @@ +{ stdenv +, fetchurl, perl, gcc, llvm_39 +, ncurses5, gmp, glibc, libiconv +}: + +# Prebuilt only does native +assert stdenv.targetPlatform == stdenv.hostPlatform; + +let + libPath = stdenv.lib.makeLibraryPath ([ + ncurses5 gmp + ] ++ stdenv.lib.optional (stdenv.hostPlatform.isDarwin) libiconv); + + libEnvVar = stdenv.lib.optionalString stdenv.hostPlatform.isDarwin "DY" + + "LD_LIBRARY_PATH"; + + glibcDynLinker = assert stdenv.isLinux; + if stdenv.hostPlatform.libc == "glibc" then + # Could be stdenv.cc.bintools.dynamicLinker, keeping as-is to avoid rebuild. + ''"$(cat $NIX_CC/nix-support/dynamic-linker)"'' + else + "${stdenv.lib.getLib glibc}/lib/ld-linux*"; + +in + +stdenv.mkDerivation rec { + version = "8.6.3"; + + name = "ghc-${version}-binary"; + + src = fetchurl ({ + "i686-linux" = { + url = "http://haskell.org/ghc/dist/${version}/ghc-${version}-i386-deb8-linux.tar.xz"; + sha256 = "0bw8a7fxcbskf93rb4m542ff66vrmx5i5kj77qx37cbhijx70w5m"; + }; + "x86_64-linux" = { + url = "http://haskell.org/ghc/dist/${version}/ghc-${version}-x86_64-deb8-linux.tar.xz"; + sha256 = "1m9gaga2pzi2cx5gvasg0rx1dlvr68gmi20l67652kag6xjsa719"; + }; + "x86_64-darwin" = { + url = "http://haskell.org/ghc/dist/${version}/ghc-${version}-x86_64-apple-darwin.tar.xz"; + sha256 = "1hbzk57v45176kxcx848p5jn5p1xbp2129ramkbzsk6plyhnkl3r"; + }; + }.${stdenv.hostPlatform.system} + or (throw "cannot bootstrap GHC on this platform")); + + nativeBuildInputs = [ perl ]; + buildInputs = stdenv.lib.optionals (stdenv.targetPlatform.isAarch32 || stdenv.targetPlatform.isAarch64) [ llvm_39 ]; + + # Cannot patchelf beforehand due to relative RPATHs that anticipate + # the final install location/ + ${libEnvVar} = libPath; + + postUnpack = + # GHC has dtrace probes, which causes ld to try to open /usr/lib/libdtrace.dylib + # during linking + stdenv.lib.optionalString stdenv.isDarwin '' + export NIX_LDFLAGS+=" -no_dtrace_dof" + # not enough room in the object files for the full path to libiconv :( + for exe in $(find . -type f -executable); do + isScript $exe && continue + ln -fs ${libiconv}/lib/libiconv.dylib $(dirname $exe)/libiconv.dylib + install_name_tool -change /usr/lib/libiconv.2.dylib @executable_path/libiconv.dylib -change /usr/local/lib/gcc/6/libgcc_s.1.dylib ${gcc.cc.lib}/lib/libgcc_s.1.dylib $exe + done + '' + + + # Some scripts used during the build need to have their shebangs patched + '' + patchShebangs ghc-${version}/utils/ + patchShebangs ghc-${version}/configure + '' + + + # Strip is harmful, see also below. It's important that this happens + # first. The GHC Cabal build system makes use of strip by default and + # has hardcoded paths to /usr/bin/strip in many places. We replace + # those below, making them point to our dummy script. + '' + mkdir "$TMP/bin" + for i in strip; do + echo '#! ${stdenv.shell}' > "$TMP/bin/$i" + chmod +x "$TMP/bin/$i" + done + PATH="$TMP/bin:$PATH" + '' + + # We have to patch the GMP paths for the integer-gmp package. + '' + find . -name integer-gmp.buildinfo \ + -exec sed -i "s@extra-lib-dirs: @extra-lib-dirs: ${gmp.out}/lib@" {} \; + '' + stdenv.lib.optionalString stdenv.isDarwin '' + find . -name base.buildinfo \ + -exec sed -i "s@extra-lib-dirs: @extra-lib-dirs: ${libiconv}/lib@" {} \; + '' + + # Rename needed libraries and binaries, fix interpreter + stdenv.lib.optionalString stdenv.isLinux '' + find . -type f -perm -0100 -exec patchelf \ + --replace-needed libncurses${stdenv.lib.optionalString stdenv.is64bit "w"}.so.5 libncurses.so \ + --replace-needed libtinfo.so libtinfo.so.5 \ + --interpreter ${glibcDynLinker} {} \; + + sed -i "s|/usr/bin/perl|perl\x00 |" ghc-${version}/ghc/stage2/build/tmp/ghc-stage2 + sed -i "s|/usr/bin/gcc|gcc\x00 |" ghc-${version}/ghc/stage2/build/tmp/ghc-stage2 + '' + + # We're kludging a glibc bindist into working with non-glibc... + # Here we patch up the use of `__strdup` (part of glibc binary ABI) + # to instead use `strdup` since musl doesn't provide __strdup + # (`__strdup` is defined to be an alias of `strdup` anyway[1]). + # [1] http://refspecs.linuxbase.org/LSB_4.0.0/LSB-Core-generic/LSB-Core-generic/baselib---strdup-1.html + # Use objcopy magic to make the change: + stdenv.lib.optionalString stdenv.hostPlatform.isMusl '' + find ./ghc-${version}/rts -name "libHSrts*.a" -exec ''${OBJCOPY:-objcopy} --redefine-sym __strdup=strdup {} \; + ''; + + configurePlatforms = [ ]; + configureFlags = [ + "--with-gmp-libraries=${stdenv.lib.getLib gmp}/lib" + "--with-gmp-includes=${stdenv.lib.getDev gmp}/include" + ] ++ stdenv.lib.optional stdenv.isDarwin "--with-gcc=${./gcc-clang-wrapper.sh}" + ++ stdenv.lib.optional stdenv.hostPlatform.isMusl "--disable-ld-override"; + + # Stripping combined with patchelf breaks the executables (they die + # with a segfault or the kernel even refuses the execve). (NIXPKGS-85) + dontStrip = true; + + # No building is necessary, but calling make without flags ironically + # calls install-strip ... + dontBuild = true; + + # On Linux, use patchelf to modify the executables so that they can + # find editline/gmp. + preFixup = stdenv.lib.optionalString stdenv.isLinux '' + for p in $(find "$out" -type f -executable); do + if isELF "$p"; then + echo "Patchelfing $p" + patchelf --set-rpath "${libPath}:$(patchelf --print-rpath $p)" $p + fi + done + '' + stdenv.lib.optionalString stdenv.isDarwin '' + # not enough room in the object files for the full path to libiconv :( + for exe in $(find "$out" -type f -executable); do + isScript $exe && continue + ln -fs ${libiconv}/lib/libiconv.dylib $(dirname $exe)/libiconv.dylib + install_name_tool -change /usr/lib/libiconv.2.dylib @executable_path/libiconv.dylib -change /usr/local/lib/gcc/6/libgcc_s.1.dylib ${gcc.cc.lib}/lib/libgcc_s.1.dylib $exe + done + + for file in $(find "$out" -name setup-config); do + substituteInPlace $file --replace /usr/bin/ranlib "$(type -P ranlib)" + done + ''; + + doInstallCheck = true; + installCheckPhase = '' + unset ${libEnvVar} + # Sanity check, can ghc create executables? + cd $TMP + mkdir test-ghc; cd test-ghc + cat > main.hs << EOF + {-# LANGUAGE TemplateHaskell #-} + module Main where + main = putStrLn \$([|"yes"|]) + EOF + $out/bin/ghc --make main.hs || exit 1 + echo compilation ok + [ $(./main) == "yes" ] + ''; + + passthru = { + targetPrefix = ""; + enableShared = true; + }; + + meta.license = stdenv.lib.licenses.bsd3; + meta.platforms = ["x86_64-linux" "i686-linux" "x86_64-darwin"]; +} diff --git a/nixpkgs/pkgs/development/compilers/ghc/8.6.4.nix b/nixpkgs/pkgs/development/compilers/ghc/8.6.4.nix new file mode 100644 index 000000000000..640709aba1b8 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/ghc/8.6.4.nix @@ -0,0 +1,245 @@ +{ stdenv, pkgsBuildTarget, targetPackages + +# build-tools +, bootPkgs +, autoconf, automake, coreutils, fetchurl, fetchpatch, perl, python3, m4, sphinx + +, libiconv ? null, ncurses + +, # GHC can be built with system libffi or a bundled one. + libffi ? null + +, useLLVM ? !stdenv.targetPlatform.isx86 || (stdenv.targetPlatform.isMusl && stdenv.hostPlatform != stdenv.targetPlatform) +, # LLVM is conceptually a run-time-only depedendency, but for + # non-x86, we need LLVM to bootstrap later stages, so it becomes a + # build-time dependency too. + buildLlvmPackages, llvmPackages + +, # If enabled, GHC will be built with the GPL-free but slower integer-simple + # library instead of the faster but GPLed integer-gmp library. + enableIntegerSimple ? !(stdenv.lib.any (stdenv.lib.meta.platformMatch stdenv.hostPlatform) gmp.meta.platforms), gmp + +, # If enabled, use -fPIC when compiling static libs. + enableRelocatedStaticLibs ? stdenv.targetPlatform != stdenv.hostPlatform + +, # Whether to build dynamic libs for the standard library (on the target + # platform). Static libs are always built. + enableShared ? !stdenv.targetPlatform.isWindows && !stdenv.targetPlatform.useiOSPrebuilt + +, # Whetherto build terminfo. + enableTerminfo ? !stdenv.targetPlatform.isWindows + +, # What flavour to build. An empty string indicates no + # specific flavour and falls back to ghc default values. + ghcFlavour ? stdenv.lib.optionalString (stdenv.targetPlatform != stdenv.hostPlatform) "perf-cross" + +, # Whether to disable the large address space allocator + # necessary fix for iOS: https://www.reddit.com/r/haskell/comments/4ttdz1/building_an_osxi386_to_iosarm64_cross_compiler/d5qvd67/ + disableLargeAddressSpace ? stdenv.targetPlatform.isDarwin && stdenv.targetPlatform.isAarch64 +}: + +assert !enableIntegerSimple -> gmp != null; + +let + inherit (stdenv) buildPlatform hostPlatform targetPlatform; + + inherit (bootPkgs) ghc; + + # TODO(@Ericson2314) Make unconditional + targetPrefix = stdenv.lib.optionalString + (targetPlatform != hostPlatform) + "${targetPlatform.config}-"; + + buildMK = '' + BuildFlavour = ${ghcFlavour} + ifneq \"\$(BuildFlavour)\" \"\" + include mk/flavours/\$(BuildFlavour).mk + endif + DYNAMIC_GHC_PROGRAMS = ${if enableShared then "YES" else "NO"} + INTEGER_LIBRARY = ${if enableIntegerSimple then "integer-simple" else "integer-gmp"} + '' + stdenv.lib.optionalString (targetPlatform != hostPlatform) '' + Stage1Only = ${if targetPlatform.system == hostPlatform.system then "NO" else "YES"} + CrossCompilePrefix = ${targetPrefix} + HADDOCK_DOCS = NO + BUILD_SPHINX_HTML = NO + BUILD_SPHINX_PDF = NO + '' + stdenv.lib.optionalString enableRelocatedStaticLibs '' + GhcLibHcOpts += -fPIC + GhcRtsHcOpts += -fPIC + '' + stdenv.lib.optionalString targetPlatform.useAndroidPrebuilt '' + EXTRA_CC_OPTS += -std=gnu99 + ''; + + # Splicer will pull out correct variations + libDeps = platform: stdenv.lib.optional enableTerminfo [ ncurses ] + ++ [libffi] + ++ stdenv.lib.optional (!enableIntegerSimple) gmp + ++ stdenv.lib.optional (platform.libc != "glibc" && !targetPlatform.isWindows) libiconv; + + toolsForTarget = [ + pkgsBuildTarget.targetPackages.stdenv.cc + ] ++ stdenv.lib.optional useLLVM buildLlvmPackages.llvm; + + targetCC = builtins.head toolsForTarget; + +in +stdenv.mkDerivation (rec { + version = "8.6.4"; + name = "${targetPrefix}ghc-${version}"; + + src = fetchurl { + url = "https://downloads.haskell.org/~ghc/${version}/ghc-${version}-src.tar.xz"; + sha256 = "0fihs1sr0hpk67dn9cmrsav13kkcp9hz8ggdqcrs80rj8vj0fpav"; + }; + + enableParallelBuilding = true; + + outputs = [ "out" "doc" ]; + + patches = [ + (fetchpatch rec { # https://phabricator.haskell.org/D5123 + url = "http://tarballs.nixos.org/sha256/${sha256}"; + name = "D5123.diff"; + sha256 = "0nhqwdamf2y4gbwqxcgjxs0kqx23w9gv5kj0zv6450dq19rji82n"; + }) + (fetchpatch rec { # https://github.com/haskell/haddock/issues/900 + url = "https://patch-diff.githubusercontent.com/raw/haskell/haddock/pull/983.diff"; + name = "loadpluginsinmodules.diff"; + sha256 = "0bvvv0zsfq2581zsir97zfkggc1kkircbbajc2fz3b169ycpbha1"; + extraPrefix = "utils/haddock/"; + stripLen = 1; + }) + ]; + + postPatch = "patchShebangs ."; + + # GHC is a bit confused on its cross terminology. + preConfigure = '' + for env in $(env | grep '^TARGET_' | sed -E 's|\+?=.*||'); do + export "''${env#TARGET_}=''${!env}" + done + # GHC is a bit confused on its cross terminology, as these would normally be + # the *host* tools. + export CC="${targetCC}/bin/${targetCC.targetPrefix}cc" + export CXX="${targetCC}/bin/${targetCC.targetPrefix}cxx" + # Use gold to work around https://sourceware.org/bugzilla/show_bug.cgi?id=16177 + export LD="${targetCC.bintools}/bin/${targetCC.bintools.targetPrefix}ld${stdenv.lib.optionalString targetPlatform.isAarch32 ".gold"}" + export AS="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}as" + export AR="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}ar" + export NM="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}nm" + export RANLIB="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}ranlib" + export READELF="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}readelf" + export STRIP="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}strip" + + echo -n "${buildMK}" > mk/build.mk + sed -i -e 's|-isysroot /Developer/SDKs/MacOSX10.5.sdk||' configure + '' + stdenv.lib.optionalString (!stdenv.isDarwin) '' + export NIX_LDFLAGS+=" -rpath $out/lib/ghc-${version}" + '' + stdenv.lib.optionalString stdenv.isDarwin '' + export NIX_LDFLAGS+=" -no_dtrace_dof" + '' + stdenv.lib.optionalString targetPlatform.useAndroidPrebuilt '' + sed -i -e '5i ,("armv7a-unknown-linux-androideabi", ("e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64", "cortex-a8", ""))' llvm-targets + '' + stdenv.lib.optionalString targetPlatform.isMusl '' + echo "patching llvm-targets for musl targets..." + echo "Cloning these existing '*-linux-gnu*' targets:" + grep linux-gnu llvm-targets | sed 's/^/ /' + echo "(go go gadget sed)" + sed -i 's,\(^.*linux-\)gnu\(.*\)$,\0\n\1musl\2,' llvm-targets + echo "llvm-targets now contains these '*-linux-musl*' targets:" + grep linux-musl llvm-targets | sed 's/^/ /' + + echo "And now patching to preserve '-musleabi' as done with '-gnueabi'" + # (aclocal.m4 is actual source, but patch configure as well since we don't re-gen) + for x in configure aclocal.m4; do + substituteInPlace $x \ + --replace '*-android*|*-gnueabi*)' \ + '*-android*|*-gnueabi*|*-musleabi*)' + done + ''; + + # TODO(@Ericson2314): Always pass "--target" and always prefix. + configurePlatforms = [ "build" "host" ] + ++ stdenv.lib.optional (targetPlatform != hostPlatform) "target"; + # `--with` flags for libraries needed for RTS linker + configureFlags = [ + "--datadir=$doc/share/doc/ghc" + "--with-curses-includes=${ncurses.dev}/include" "--with-curses-libraries=${ncurses.out}/lib" + ] ++ stdenv.lib.optionals (libffi != null) ["--with-system-libffi" "--with-ffi-includes=${targetPackages.libffi.dev}/include" "--with-ffi-libraries=${targetPackages.libffi.out}/lib" + ] ++ stdenv.lib.optional (targetPlatform == hostPlatform && !enableIntegerSimple) [ + "--with-gmp-includes=${targetPackages.gmp.dev}/include" "--with-gmp-libraries=${targetPackages.gmp.out}/lib" + ] ++ stdenv.lib.optional (targetPlatform == hostPlatform && hostPlatform.libc != "glibc" && !targetPlatform.isWindows) [ + "--with-iconv-includes=${libiconv}/include" "--with-iconv-libraries=${libiconv}/lib" + ] ++ stdenv.lib.optionals (targetPlatform != hostPlatform) [ + "--enable-bootstrap-with-devel-snapshot" + ] ++ stdenv.lib.optionals (targetPlatform.isAarch32) [ + "CFLAGS=-fuse-ld=gold" + "CONF_GCC_LINKER_OPTS_STAGE1=-fuse-ld=gold" + "CONF_GCC_LINKER_OPTS_STAGE2=-fuse-ld=gold" + ] ++ stdenv.lib.optionals (disableLargeAddressSpace) [ + "--disable-large-address-space" + ]; + + # Make sure we never relax`$PATH` and hooks support for compatability. + strictDeps = true; + + # Don’t add -liconv to LDFLAGS automatically so that GHC will add it itself. + dontAddExtraLibs = true; + + nativeBuildInputs = [ + perl autoconf automake m4 python3 sphinx + ghc bootPkgs.alex bootPkgs.happy bootPkgs.hscolour + ]; + + # For building runtime libs + depsBuildTarget = toolsForTarget; + + buildInputs = [ perl ] ++ (libDeps hostPlatform); + + propagatedBuildInputs = [ targetPackages.stdenv.cc ] + ++ stdenv.lib.optional useLLVM llvmPackages.llvm; + + depsTargetTarget = map stdenv.lib.getDev (libDeps targetPlatform); + depsTargetTargetPropagated = map (stdenv.lib.getOutput "out") (libDeps targetPlatform); + + # required, because otherwise all symbols from HSffi.o are stripped, and + # that in turn causes GHCi to abort + stripDebugFlags = [ "-S" ] ++ stdenv.lib.optional (!targetPlatform.isDarwin) "--keep-file-symbols"; + + checkTarget = "test"; + + hardeningDisable = [ "format" ] ++ stdenv.lib.optional stdenv.targetPlatform.isMusl "pie"; + + postInstall = '' + # Install the bash completion file. + install -D -m 444 utils/completion/ghc.bash $out/share/bash-completion/completions/${targetPrefix}ghc + + # Patch scripts to include "readelf" and "cat" in $PATH. + for i in "$out/bin/"*; do + test ! -h $i || continue + egrep --quiet '^#!' <(head -n 1 $i) || continue + sed -i -e '2i export PATH="$PATH:${stdenv.lib.makeBinPath [ targetPackages.stdenv.cc.bintools coreutils ]}"' $i + done + ''; + + passthru = { + inherit bootPkgs targetPrefix; + + inherit llvmPackages; + inherit enableShared; + + # Our Cabal compiler name + haskellCompilerName = "ghc-8.6.4"; + }; + + meta = { + homepage = http://haskell.org/ghc; + description = "The Glasgow Haskell Compiler"; + maintainers = with stdenv.lib.maintainers; [ marcweber andres peti ]; + inherit (ghc.meta) license platforms; + }; + +} // stdenv.lib.optionalAttrs targetPlatform.useAndroidPrebuilt { + dontStrip = true; + dontPatchELF = true; + noAuditTmpdir = true; +}) diff --git a/nixpkgs/pkgs/development/compilers/ghc/8.6.5.nix b/nixpkgs/pkgs/development/compilers/ghc/8.6.5.nix new file mode 100644 index 000000000000..e891ff42ff60 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/ghc/8.6.5.nix @@ -0,0 +1,245 @@ +{ stdenv, pkgsBuildTarget, targetPackages + +# build-tools +, bootPkgs +, autoconf, automake, coreutils, fetchurl, fetchpatch, perl, python3, m4, sphinx + +, libiconv ? null, ncurses + +, # GHC can be built with system libffi or a bundled one. + libffi ? null + +, useLLVM ? !stdenv.targetPlatform.isx86 || (stdenv.targetPlatform.isMusl && stdenv.hostPlatform != stdenv.targetPlatform) +, # LLVM is conceptually a run-time-only depedendency, but for + # non-x86, we need LLVM to bootstrap later stages, so it becomes a + # build-time dependency too. + buildLlvmPackages, llvmPackages + +, # If enabled, GHC will be built with the GPL-free but slower integer-simple + # library instead of the faster but GPLed integer-gmp library. + enableIntegerSimple ? !(stdenv.lib.any (stdenv.lib.meta.platformMatch stdenv.hostPlatform) gmp.meta.platforms), gmp + +, # If enabled, use -fPIC when compiling static libs. + enableRelocatedStaticLibs ? stdenv.targetPlatform != stdenv.hostPlatform + +, # Whether to build dynamic libs for the standard library (on the target + # platform). Static libs are always built. + enableShared ? !stdenv.targetPlatform.isWindows && !stdenv.targetPlatform.useiOSPrebuilt + +, # Whetherto build terminfo. + enableTerminfo ? !stdenv.targetPlatform.isWindows + +, # What flavour to build. An empty string indicates no + # specific flavour and falls back to ghc default values. + ghcFlavour ? stdenv.lib.optionalString (stdenv.targetPlatform != stdenv.hostPlatform) "perf-cross" + +, # Whether to disable the large address space allocator + # necessary fix for iOS: https://www.reddit.com/r/haskell/comments/4ttdz1/building_an_osxi386_to_iosarm64_cross_compiler/d5qvd67/ + disableLargeAddressSpace ? stdenv.targetPlatform.isDarwin && stdenv.targetPlatform.isAarch64 +}: + +assert !enableIntegerSimple -> gmp != null; + +let + inherit (stdenv) buildPlatform hostPlatform targetPlatform; + + inherit (bootPkgs) ghc; + + # TODO(@Ericson2314) Make unconditional + targetPrefix = stdenv.lib.optionalString + (targetPlatform != hostPlatform) + "${targetPlatform.config}-"; + + buildMK = '' + BuildFlavour = ${ghcFlavour} + ifneq \"\$(BuildFlavour)\" \"\" + include mk/flavours/\$(BuildFlavour).mk + endif + DYNAMIC_GHC_PROGRAMS = ${if enableShared then "YES" else "NO"} + INTEGER_LIBRARY = ${if enableIntegerSimple then "integer-simple" else "integer-gmp"} + '' + stdenv.lib.optionalString (targetPlatform != hostPlatform) '' + Stage1Only = ${if targetPlatform.system == hostPlatform.system then "NO" else "YES"} + CrossCompilePrefix = ${targetPrefix} + HADDOCK_DOCS = NO + BUILD_SPHINX_HTML = NO + BUILD_SPHINX_PDF = NO + '' + stdenv.lib.optionalString enableRelocatedStaticLibs '' + GhcLibHcOpts += -fPIC + GhcRtsHcOpts += -fPIC + '' + stdenv.lib.optionalString targetPlatform.useAndroidPrebuilt '' + EXTRA_CC_OPTS += -std=gnu99 + ''; + + # Splicer will pull out correct variations + libDeps = platform: stdenv.lib.optional enableTerminfo [ ncurses ] + ++ [libffi] + ++ stdenv.lib.optional (!enableIntegerSimple) gmp + ++ stdenv.lib.optional (platform.libc != "glibc" && !targetPlatform.isWindows) libiconv; + + toolsForTarget = [ + pkgsBuildTarget.targetPackages.stdenv.cc + ] ++ stdenv.lib.optional useLLVM buildLlvmPackages.llvm; + + targetCC = builtins.head toolsForTarget; + +in +stdenv.mkDerivation (rec { + version = "8.6.5"; + name = "${targetPrefix}ghc-${version}"; + + src = fetchurl { + url = "https://downloads.haskell.org/~ghc/${version}/ghc-${version}-src.tar.xz"; + sha256 = "0qg3zsmbk4rkwkc3jpas3zs74qaxmw4sp4v1mhsbj0a0dzls2jjd"; + }; + + enableParallelBuilding = true; + + outputs = [ "out" "doc" ]; + + patches = [ + (fetchpatch rec { # https://phabricator.haskell.org/D5123 + url = "http://tarballs.nixos.org/sha256/${sha256}"; + name = "D5123.diff"; + sha256 = "0nhqwdamf2y4gbwqxcgjxs0kqx23w9gv5kj0zv6450dq19rji82n"; + }) + (fetchpatch rec { # https://github.com/haskell/haddock/issues/900 + url = "https://patch-diff.githubusercontent.com/raw/haskell/haddock/pull/983.diff"; + name = "loadpluginsinmodules.diff"; + sha256 = "0bvvv0zsfq2581zsir97zfkggc1kkircbbajc2fz3b169ycpbha1"; + extraPrefix = "utils/haddock/"; + stripLen = 1; + }) + ]; + + postPatch = "patchShebangs ."; + + # GHC is a bit confused on its cross terminology. + preConfigure = '' + for env in $(env | grep '^TARGET_' | sed -E 's|\+?=.*||'); do + export "''${env#TARGET_}=''${!env}" + done + # GHC is a bit confused on its cross terminology, as these would normally be + # the *host* tools. + export CC="${targetCC}/bin/${targetCC.targetPrefix}cc" + export CXX="${targetCC}/bin/${targetCC.targetPrefix}cxx" + # Use gold to work around https://sourceware.org/bugzilla/show_bug.cgi?id=16177 + export LD="${targetCC.bintools}/bin/${targetCC.bintools.targetPrefix}ld${stdenv.lib.optionalString targetPlatform.isAarch32 ".gold"}" + export AS="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}as" + export AR="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}ar" + export NM="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}nm" + export RANLIB="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}ranlib" + export READELF="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}readelf" + export STRIP="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}strip" + + echo -n "${buildMK}" > mk/build.mk + sed -i -e 's|-isysroot /Developer/SDKs/MacOSX10.5.sdk||' configure + '' + stdenv.lib.optionalString (!stdenv.isDarwin) '' + export NIX_LDFLAGS+=" -rpath $out/lib/ghc-${version}" + '' + stdenv.lib.optionalString stdenv.isDarwin '' + export NIX_LDFLAGS+=" -no_dtrace_dof" + '' + stdenv.lib.optionalString targetPlatform.useAndroidPrebuilt '' + sed -i -e '5i ,("armv7a-unknown-linux-androideabi", ("e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64", "cortex-a8", ""))' llvm-targets + '' + stdenv.lib.optionalString targetPlatform.isMusl '' + echo "patching llvm-targets for musl targets..." + echo "Cloning these existing '*-linux-gnu*' targets:" + grep linux-gnu llvm-targets | sed 's/^/ /' + echo "(go go gadget sed)" + sed -i 's,\(^.*linux-\)gnu\(.*\)$,\0\n\1musl\2,' llvm-targets + echo "llvm-targets now contains these '*-linux-musl*' targets:" + grep linux-musl llvm-targets | sed 's/^/ /' + + echo "And now patching to preserve '-musleabi' as done with '-gnueabi'" + # (aclocal.m4 is actual source, but patch configure as well since we don't re-gen) + for x in configure aclocal.m4; do + substituteInPlace $x \ + --replace '*-android*|*-gnueabi*)' \ + '*-android*|*-gnueabi*|*-musleabi*)' + done + ''; + + # TODO(@Ericson2314): Always pass "--target" and always prefix. + configurePlatforms = [ "build" "host" ] + ++ stdenv.lib.optional (targetPlatform != hostPlatform) "target"; + # `--with` flags for libraries needed for RTS linker + configureFlags = [ + "--datadir=$doc/share/doc/ghc" + "--with-curses-includes=${ncurses.dev}/include" "--with-curses-libraries=${ncurses.out}/lib" + ] ++ stdenv.lib.optionals (libffi != null) ["--with-system-libffi" "--with-ffi-includes=${targetPackages.libffi.dev}/include" "--with-ffi-libraries=${targetPackages.libffi.out}/lib" + ] ++ stdenv.lib.optional (targetPlatform == hostPlatform && !enableIntegerSimple) [ + "--with-gmp-includes=${targetPackages.gmp.dev}/include" "--with-gmp-libraries=${targetPackages.gmp.out}/lib" + ] ++ stdenv.lib.optional (targetPlatform == hostPlatform && hostPlatform.libc != "glibc" && !targetPlatform.isWindows) [ + "--with-iconv-includes=${libiconv}/include" "--with-iconv-libraries=${libiconv}/lib" + ] ++ stdenv.lib.optionals (targetPlatform != hostPlatform) [ + "--enable-bootstrap-with-devel-snapshot" + ] ++ stdenv.lib.optionals (targetPlatform.isAarch32) [ + "CFLAGS=-fuse-ld=gold" + "CONF_GCC_LINKER_OPTS_STAGE1=-fuse-ld=gold" + "CONF_GCC_LINKER_OPTS_STAGE2=-fuse-ld=gold" + ] ++ stdenv.lib.optionals (disableLargeAddressSpace) [ + "--disable-large-address-space" + ]; + + # Make sure we never relax`$PATH` and hooks support for compatability. + strictDeps = true; + + # Don’t add -liconv to LDFLAGS automatically so that GHC will add it itself. + dontAddExtraLibs = true; + + nativeBuildInputs = [ + perl autoconf automake m4 python3 sphinx + ghc bootPkgs.alex bootPkgs.happy bootPkgs.hscolour + ]; + + # For building runtime libs + depsBuildTarget = toolsForTarget; + + buildInputs = [ perl ] ++ (libDeps hostPlatform); + + propagatedBuildInputs = [ targetPackages.stdenv.cc ] + ++ stdenv.lib.optional useLLVM llvmPackages.llvm; + + depsTargetTarget = map stdenv.lib.getDev (libDeps targetPlatform); + depsTargetTargetPropagated = map (stdenv.lib.getOutput "out") (libDeps targetPlatform); + + # required, because otherwise all symbols from HSffi.o are stripped, and + # that in turn causes GHCi to abort + stripDebugFlags = [ "-S" ] ++ stdenv.lib.optional (!targetPlatform.isDarwin) "--keep-file-symbols"; + + checkTarget = "test"; + + hardeningDisable = [ "format" ] ++ stdenv.lib.optional stdenv.targetPlatform.isMusl "pie"; + + postInstall = '' + # Install the bash completion file. + install -D -m 444 utils/completion/ghc.bash $out/share/bash-completion/completions/${targetPrefix}ghc + + # Patch scripts to include "readelf" and "cat" in $PATH. + for i in "$out/bin/"*; do + test ! -h $i || continue + egrep --quiet '^#!' <(head -n 1 $i) || continue + sed -i -e '2i export PATH="$PATH:${stdenv.lib.makeBinPath [ targetPackages.stdenv.cc.bintools coreutils ]}"' $i + done + ''; + + passthru = { + inherit bootPkgs targetPrefix; + + inherit llvmPackages; + inherit enableShared; + + # Our Cabal compiler name + haskellCompilerName = "ghc-${version}"; + }; + + meta = { + homepage = http://haskell.org/ghc; + description = "The Glasgow Haskell Compiler"; + maintainers = with stdenv.lib.maintainers; [ marcweber andres peti ]; + inherit (ghc.meta) license platforms; + }; + +} // stdenv.lib.optionalAttrs targetPlatform.useAndroidPrebuilt { + dontStrip = true; + dontPatchELF = true; + noAuditTmpdir = true; +}) diff --git a/nixpkgs/pkgs/development/compilers/ghc/8.8.1.nix b/nixpkgs/pkgs/development/compilers/ghc/8.8.1.nix new file mode 100644 index 000000000000..9772d045b765 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/ghc/8.8.1.nix @@ -0,0 +1,230 @@ +{ stdenv, pkgsBuildTarget, targetPackages + +# build-tools +, bootPkgs +, autoconf, automake, coreutils, fetchurl, fetchpatch, perl, python3, m4, sphinx + +, libiconv ? null, ncurses + +, # GHC can be built with system libffi or a bundled one. + libffi ? null + +, useLLVM ? !stdenv.targetPlatform.isx86 || (stdenv.targetPlatform.isMusl && stdenv.hostPlatform != stdenv.targetPlatform) +, # LLVM is conceptually a run-time-only depedendency, but for + # non-x86, we need LLVM to bootstrap later stages, so it becomes a + # build-time dependency too. + buildLlvmPackages, llvmPackages + +, # If enabled, GHC will be built with the GPL-free but slower integer-simple + # library instead of the faster but GPLed integer-gmp library. + enableIntegerSimple ? !(stdenv.lib.any (stdenv.lib.meta.platformMatch stdenv.hostPlatform) gmp.meta.platforms), gmp + +, # If enabled, use -fPIC when compiling static libs. + enableRelocatedStaticLibs ? stdenv.targetPlatform != stdenv.hostPlatform + +, # Whether to build dynamic libs for the standard library (on the target + # platform). Static libs are always built. + enableShared ? !stdenv.targetPlatform.isWindows && !stdenv.targetPlatform.useiOSPrebuilt + +, # Whetherto build terminfo. + enableTerminfo ? !stdenv.targetPlatform.isWindows + +, # What flavour to build. An empty string indicates no + # specific flavour and falls back to ghc default values. + ghcFlavour ? stdenv.lib.optionalString (stdenv.targetPlatform != stdenv.hostPlatform) "perf-cross" + +, # Whether to disable the large address space allocator + # necessary fix for iOS: https://www.reddit.com/r/haskell/comments/4ttdz1/building_an_osxi386_to_iosarm64_cross_compiler/d5qvd67/ + disableLargeAddressSpace ? stdenv.targetPlatform.isDarwin && stdenv.targetPlatform.isAarch64 +}: + +assert !enableIntegerSimple -> gmp != null; + +let + inherit (stdenv) buildPlatform hostPlatform targetPlatform; + + inherit (bootPkgs) ghc; + + # TODO(@Ericson2314) Make unconditional + targetPrefix = stdenv.lib.optionalString + (targetPlatform != hostPlatform) + "${targetPlatform.config}-"; + + buildMK = '' + BuildFlavour = ${ghcFlavour} + ifneq \"\$(BuildFlavour)\" \"\" + include mk/flavours/\$(BuildFlavour).mk + endif + DYNAMIC_GHC_PROGRAMS = ${if enableShared then "YES" else "NO"} + INTEGER_LIBRARY = ${if enableIntegerSimple then "integer-simple" else "integer-gmp"} + '' + stdenv.lib.optionalString (targetPlatform != hostPlatform) '' + Stage1Only = ${if targetPlatform.system == hostPlatform.system then "NO" else "YES"} + CrossCompilePrefix = ${targetPrefix} + HADDOCK_DOCS = NO + BUILD_SPHINX_HTML = NO + BUILD_SPHINX_PDF = NO + '' + stdenv.lib.optionalString enableRelocatedStaticLibs '' + GhcLibHcOpts += -fPIC + GhcRtsHcOpts += -fPIC + '' + stdenv.lib.optionalString targetPlatform.useAndroidPrebuilt '' + EXTRA_CC_OPTS += -std=gnu99 + ''; + + # Splicer will pull out correct variations + libDeps = platform: stdenv.lib.optional enableTerminfo [ ncurses ] + ++ [libffi] + ++ stdenv.lib.optional (!enableIntegerSimple) gmp + ++ stdenv.lib.optional (platform.libc != "glibc" && !targetPlatform.isWindows) libiconv; + + toolsForTarget = [ + pkgsBuildTarget.targetPackages.stdenv.cc + ] ++ stdenv.lib.optional useLLVM buildLlvmPackages.llvm; + + targetCC = builtins.head toolsForTarget; + +in +stdenv.mkDerivation (rec { + version = "8.8.0.20190424"; + name = "${targetPrefix}ghc-${version}"; + + src = fetchurl { + url = "https://downloads.haskell.org/~ghc/8.8.1-alpha1/ghc-${version}-src.tar.xz"; + sha256 = "1lwzy4q9hhaayamr1ij3lk8l7zdwfqza5b2racylp7xn2y9wanl9"; + }; + + enableParallelBuilding = true; + + outputs = [ "out" "doc" ]; + + postPatch = "patchShebangs ."; + + # GHC is a bit confused on its cross terminology. + preConfigure = '' + for env in $(env | grep '^TARGET_' | sed -E 's|\+?=.*||'); do + export "''${env#TARGET_}=''${!env}" + done + # GHC is a bit confused on its cross terminology, as these would normally be + # the *host* tools. + export CC="${targetCC}/bin/${targetCC.targetPrefix}cc" + export CXX="${targetCC}/bin/${targetCC.targetPrefix}cxx" + # Use gold to work around https://sourceware.org/bugzilla/show_bug.cgi?id=16177 + export LD="${targetCC.bintools}/bin/${targetCC.bintools.targetPrefix}ld${stdenv.lib.optionalString targetPlatform.isAarch32 ".gold"}" + export AS="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}as" + export AR="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}ar" + export NM="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}nm" + export RANLIB="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}ranlib" + export READELF="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}readelf" + export STRIP="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}strip" + + echo -n "${buildMK}" > mk/build.mk + sed -i -e 's|-isysroot /Developer/SDKs/MacOSX10.5.sdk||' configure + '' + stdenv.lib.optionalString (!stdenv.isDarwin) '' + export NIX_LDFLAGS+=" -rpath $out/lib/ghc-${version}" + '' + stdenv.lib.optionalString stdenv.isDarwin '' + export NIX_LDFLAGS+=" -no_dtrace_dof" + '' + stdenv.lib.optionalString targetPlatform.useAndroidPrebuilt '' + sed -i -e '5i ,("armv7a-unknown-linux-androideabi", ("e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64", "cortex-a8", ""))' llvm-targets + '' + stdenv.lib.optionalString targetPlatform.isMusl '' + echo "patching llvm-targets for musl targets..." + echo "Cloning these existing '*-linux-gnu*' targets:" + grep linux-gnu llvm-targets | sed 's/^/ /' + echo "(go go gadget sed)" + sed -i 's,\(^.*linux-\)gnu\(.*\)$,\0\n\1musl\2,' llvm-targets + echo "llvm-targets now contains these '*-linux-musl*' targets:" + grep linux-musl llvm-targets | sed 's/^/ /' + + echo "And now patching to preserve '-musleabi' as done with '-gnueabi'" + # (aclocal.m4 is actual source, but patch configure as well since we don't re-gen) + for x in configure aclocal.m4; do + substituteInPlace $x \ + --replace '*-android*|*-gnueabi*)' \ + '*-android*|*-gnueabi*|*-musleabi*)' + done + ''; + + # TODO(@Ericson2314): Always pass "--target" and always prefix. + configurePlatforms = [ "build" "host" ] + ++ stdenv.lib.optional (targetPlatform != hostPlatform) "target"; + # `--with` flags for libraries needed for RTS linker + configureFlags = [ + "--datadir=$doc/share/doc/ghc" + "--with-curses-includes=${ncurses.dev}/include" "--with-curses-libraries=${ncurses.out}/lib" + ] ++ stdenv.lib.optionals (libffi != null) ["--with-system-libffi" "--with-ffi-includes=${targetPackages.libffi.dev}/include" "--with-ffi-libraries=${targetPackages.libffi.out}/lib" + ] ++ stdenv.lib.optional (targetPlatform == hostPlatform && !enableIntegerSimple) [ + "--with-gmp-includes=${targetPackages.gmp.dev}/include" "--with-gmp-libraries=${targetPackages.gmp.out}/lib" + ] ++ stdenv.lib.optional (targetPlatform == hostPlatform && hostPlatform.libc != "glibc" && !targetPlatform.isWindows) [ + "--with-iconv-includes=${libiconv}/include" "--with-iconv-libraries=${libiconv}/lib" + ] ++ stdenv.lib.optionals (targetPlatform != hostPlatform) [ + "--enable-bootstrap-with-devel-snapshot" + ] ++ stdenv.lib.optionals (targetPlatform.isAarch32) [ + "CFLAGS=-fuse-ld=gold" + "CONF_GCC_LINKER_OPTS_STAGE1=-fuse-ld=gold" + "CONF_GCC_LINKER_OPTS_STAGE2=-fuse-ld=gold" + ] ++ stdenv.lib.optionals (disableLargeAddressSpace) [ + "--disable-large-address-space" + ]; + + # Make sure we never relax`$PATH` and hooks support for compatability. + strictDeps = true; + + # Don’t add -liconv to LDFLAGS automatically so that GHC will add it itself. + dontAddExtraLibs = true; + + nativeBuildInputs = [ + perl autoconf automake m4 python3 sphinx + ghc bootPkgs.alex bootPkgs.happy bootPkgs.hscolour + ]; + + # For building runtime libs + depsBuildTarget = toolsForTarget; + + buildInputs = [ perl ] ++ (libDeps hostPlatform); + + propagatedBuildInputs = [ targetPackages.stdenv.cc ] + ++ stdenv.lib.optional useLLVM llvmPackages.llvm; + + depsTargetTarget = map stdenv.lib.getDev (libDeps targetPlatform); + depsTargetTargetPropagated = map (stdenv.lib.getOutput "out") (libDeps targetPlatform); + + # required, because otherwise all symbols from HSffi.o are stripped, and + # that in turn causes GHCi to abort + stripDebugFlags = [ "-S" ] ++ stdenv.lib.optional (!targetPlatform.isDarwin) "--keep-file-symbols"; + + checkTarget = "test"; + + hardeningDisable = [ "format" ] ++ stdenv.lib.optional stdenv.targetPlatform.isMusl "pie"; + + postInstall = '' + # Install the bash completion file. + install -D -m 444 utils/completion/ghc.bash $out/share/bash-completion/completions/${targetPrefix}ghc + + # Patch scripts to include "readelf" and "cat" in $PATH. + for i in "$out/bin/"*; do + test ! -h $i || continue + egrep --quiet '^#!' <(head -n 1 $i) || continue + sed -i -e '2i export PATH="$PATH:${stdenv.lib.makeBinPath [ targetPackages.stdenv.cc.bintools coreutils ]}"' $i + done + ''; + + passthru = { + inherit bootPkgs targetPrefix; + + inherit llvmPackages; + inherit enableShared; + + # Our Cabal compiler name + haskellCompilerName = "ghc-${version}"; + }; + + meta = { + homepage = http://haskell.org/ghc; + description = "The Glasgow Haskell Compiler"; + maintainers = with stdenv.lib.maintainers; [ marcweber andres peti ]; + inherit (ghc.meta) license platforms; + }; + +} // stdenv.lib.optionalAttrs targetPlatform.useAndroidPrebuilt { + dontStrip = true; + dontPatchELF = true; + noAuditTmpdir = true; +}) diff --git a/nixpkgs/pkgs/development/compilers/ghc/abi-depends-determinism.nix b/nixpkgs/pkgs/development/compilers/ghc/abi-depends-determinism.nix new file mode 100644 index 000000000000..bc803b74617f --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/ghc/abi-depends-determinism.nix @@ -0,0 +1,12 @@ +# https://phabricator.haskell.org/D4159 to fix non-determinism in +# cached abi-depends fields in package databases, modified to only +# contain hunks that exist in distribution tarballs. +{ fetchpatch, runCommand }: let + base = fetchpatch rec { # Non-determinism in cached abi-depends fields + # Originally https://phabricator-files.haskell.org/file/data/4pqrbo5b62sifktfbrls/PHID-FILE-4g4zjiqlfxmmlaos7lz7/D4159.diff + url = "http://tarballs.nixos.org/sha256/${sha256}"; + name = "D4159.diff"; + sha256 = "0b8a08sisf1swmarm6nh9rgw7cpzi2rwdzvrd6ny49c7wk0f7x4b"; + }; +in runCommand base.name {} + "sed -n '/utils\\/ghc-pkg/,$p' ${base} >$out" diff --git a/nixpkgs/pkgs/development/compilers/ghc/backport-dylib-command-size-limit.patch b/nixpkgs/pkgs/development/compilers/ghc/backport-dylib-command-size-limit.patch new file mode 100644 index 000000000000..d0d94717d9c4 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/ghc/backport-dylib-command-size-limit.patch @@ -0,0 +1,24 @@ +diff --git a/compiler/main/DriverPipeline.hs b/compiler/main/DriverPipeline.hs +index acd0d61..3e83c15 100644 +--- a/compiler/main/DriverPipeline.hs ++++ b/compiler/main/DriverPipeline.hs +@@ -1916,6 +1916,7 @@ linkBinary' staticLink dflags o_files dep_packages = do + ++ pkg_framework_opts + ++ debug_opts + ++ thread_opts ++ ++ (if (platformOS platform `elem` [OSDarwin]) then [ "-Wl,-dead_strip_dylibs" ] else []) + )) + + exeFileName :: Bool -> DynFlags -> FilePath +diff --git a/compiler/main/SysTools.hs b/compiler/main/SysTools.hs +index 1ab5b13..2ebbf51 100644 +--- a/compiler/main/SysTools.hs ++++ b/compiler/main/SysTools.hs +@@ -1737,6 +1737,7 @@ linkDynLib dflags0 o_files dep_packages + ++ map Option pkg_lib_path_opts + ++ map Option pkg_link_opts + ++ map Option pkg_framework_opts ++ ++ [ Option "-Wl,-dead_strip_dylibs" ] + ) + OSiOS -> throwGhcExceptionIO (ProgramError "dynamic libraries are not supported on iOS target") + _ -> do diff --git a/nixpkgs/pkgs/development/compilers/ghc/gcc-clang-wrapper.sh b/nixpkgs/pkgs/development/compilers/ghc/gcc-clang-wrapper.sh new file mode 100755 index 000000000000..45af982c2973 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/ghc/gcc-clang-wrapper.sh @@ -0,0 +1,46 @@ +#!@shell@ + +inPreprocessorMode () { + hasE=0 + hasU=0 + hasT=0 + for arg in "$@" + do + if [ 'x-E' = "x$arg" ]; then hasE=1; fi + if [ 'x-undef' = "x$arg" ]; then hasU=1; fi + if [ 'x-traditional' = "x$arg" ]; then hasT=1; fi + done + [ "$hasE$hasU$hasT" = '111' ] +} + +extraClangArgs="-Wno-invalid-pp-token -Wno-unicode -Wno-trigraphs" + +adjustPreprocessorLanguage () { + newArgs='' + while [ $# -gt 0 ] + do + newArgs="$newArgs $1" + if [ "$1" = '-x' ] + then + shift + if [ $# -gt 0 ] + then + if [ "$1" = 'c' ] + then + newArgs="$newArgs assembler-with-cpp" + else + newArgs="$newArgs $1" + fi + fi + fi + shift + done + echo $newArgs +} + +if inPreprocessorMode "$@" +then + exec clang $extraClangArgs `adjustPreprocessorLanguage "$@"` +else + exec clang $extraClangArgs "${@/-nodefaultlibs/}" +fi diff --git a/nixpkgs/pkgs/development/compilers/ghc/head.nix b/nixpkgs/pkgs/development/compilers/ghc/head.nix new file mode 100644 index 000000000000..88b273500dc0 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/ghc/head.nix @@ -0,0 +1,228 @@ +{ stdenv, pkgsBuildTarget, targetPackages + +# build-tools +, bootPkgs +, autoconf, automake, coreutils, fetchgit, fetchurl, fetchpatch, perl, python3, m4, sphinx + +, libiconv ? null, ncurses + +, useLLVM ? !stdenv.targetPlatform.isx86 || (stdenv.targetPlatform.isMusl && stdenv.hostPlatform != stdenv.targetPlatform) +, # LLVM is conceptually a run-time-only depedendency, but for + # non-x86, we need LLVM to bootstrap later stages, so it becomes a + # build-time dependency too. + buildLlvmPackages, llvmPackages + +, # If enabled, GHC will be built with the GPL-free but slower integer-simple + # library instead of the faster but GPLed integer-gmp library. + enableIntegerSimple ? !(stdenv.lib.any (stdenv.lib.meta.platformMatch stdenv.hostPlatform) gmp.meta.platforms), gmp + +, # If enabled, use -fPIC when compiling static libs. + enableRelocatedStaticLibs ? stdenv.targetPlatform != stdenv.hostPlatform + +, # Whether to build dynamic libs for the standard library (on the target + # platform). Static libs are always built. + enableShared ? !stdenv.targetPlatform.isWindows && !stdenv.targetPlatform.useiOSPrebuilt + +, # Whetherto build terminfo. + enableTerminfo ? !stdenv.targetPlatform.isWindows + +, version ? "8.7.20190115" +, # What flavour to build. An empty string indicates no + # specific flavour and falls back to ghc default values. + ghcFlavour ? stdenv.lib.optionalString (stdenv.targetPlatform != stdenv.hostPlatform) "perf-cross" + +, # Whether to disable the large address space allocator + # necessary fix for iOS: https://www.reddit.com/r/haskell/comments/4ttdz1/building_an_osxi386_to_iosarm64_cross_compiler/d5qvd67/ + disableLargeAddressSpace ? stdenv.targetPlatform.isDarwin && stdenv.targetPlatform.isAarch64 +}: + +assert !enableIntegerSimple -> gmp != null; + +let + inherit (stdenv) buildPlatform hostPlatform targetPlatform; + + inherit (bootPkgs) ghc; + + # TODO(@Ericson2314) Make unconditional + targetPrefix = stdenv.lib.optionalString + (targetPlatform != hostPlatform) + "${targetPlatform.config}-"; + + buildMK = '' + BuildFlavour = ${ghcFlavour} + ifneq \"\$(BuildFlavour)\" \"\" + include mk/flavours/\$(BuildFlavour).mk + endif + DYNAMIC_GHC_PROGRAMS = ${if enableShared then "YES" else "NO"} + INTEGER_LIBRARY = ${if enableIntegerSimple then "integer-simple" else "integer-gmp"} + '' + stdenv.lib.optionalString (targetPlatform != hostPlatform) '' + Stage1Only = ${if targetPlatform.system == hostPlatform.system then "NO" else "YES"} + CrossCompilePrefix = ${targetPrefix} + HADDOCK_DOCS = NO + BUILD_SPHINX_HTML = NO + BUILD_SPHINX_PDF = NO + '' + stdenv.lib.optionalString enableRelocatedStaticLibs '' + GhcLibHcOpts += -fPIC + GhcRtsHcOpts += -fPIC + '' + stdenv.lib.optionalString targetPlatform.useAndroidPrebuilt '' + EXTRA_CC_OPTS += -std=gnu99 + ''; + + # Splicer will pull out correct variations + libDeps = platform: stdenv.lib.optional enableTerminfo [ ncurses ] + ++ stdenv.lib.optional (!enableIntegerSimple) gmp + ++ stdenv.lib.optional (platform.libc != "glibc" && !targetPlatform.isWindows) libiconv; + + toolsForTarget = [ + pkgsBuildTarget.targetPackages.stdenv.cc + ] ++ stdenv.lib.optional useLLVM buildLlvmPackages.llvm; + + targetCC = builtins.head toolsForTarget; + +in +stdenv.mkDerivation (rec { + inherit version; + inherit (src) rev; + name = "${targetPrefix}ghc-${version}"; + + src = fetchgit { + url = "https://gitlab.haskell.org/ghc/ghc.git/"; + rev = "c9756dbf1ee58b117ea5c4ded45dea88030efd65"; + sha256 = "0ja3ivyz4jrqkw6z1mdgsczxaqkjy5vw0nyyqlqr0bqxiw9p8834"; + }; + + enableParallelBuilding = true; + + outputs = [ "out" "doc" ]; + + postPatch = "patchShebangs ."; + + # GHC is a bit confused on its cross terminology. + preConfigure = '' + for env in $(env | grep '^TARGET_' | sed -E 's|\+?=.*||'); do + export "''${env#TARGET_}=''${!env}" + done + # GHC is a bit confused on its cross terminology, as these would normally be + # the *host* tools. + export CC="${targetCC}/bin/${targetCC.targetPrefix}cc" + export CXX="${targetCC}/bin/${targetCC.targetPrefix}cxx" + # Use gold to work around https://sourceware.org/bugzilla/show_bug.cgi?id=16177 + export LD="${targetCC.bintools}/bin/${targetCC.bintools.targetPrefix}ld${stdenv.lib.optionalString targetPlatform.isAarch32 ".gold"}" + export AS="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}as" + export AR="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}ar" + export NM="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}nm" + export RANLIB="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}ranlib" + export READELF="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}readelf" + export STRIP="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}strip" + + echo -n "${buildMK}" > mk/build.mk + echo ${version} >VERSION + echo ${src.rev} >GIT_COMMIT_ID + ./boot + sed -i -e 's|-isysroot /Developer/SDKs/MacOSX10.5.sdk||' configure + '' + stdenv.lib.optionalString (!stdenv.isDarwin) '' + export NIX_LDFLAGS+=" -rpath $out/lib/ghc-${version}" + '' + stdenv.lib.optionalString stdenv.isDarwin '' + export NIX_LDFLAGS+=" -no_dtrace_dof" + '' + stdenv.lib.optionalString targetPlatform.useAndroidPrebuilt '' + sed -i -e '5i ,("armv7a-unknown-linux-androideabi", ("e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64", "cortex-a8", ""))' llvm-targets + '' + stdenv.lib.optionalString targetPlatform.isMusl '' + echo "patching llvm-targets for musl targets..." + echo "Cloning these existing '*-linux-gnu*' targets:" + grep linux-gnu llvm-targets | sed 's/^/ /' + echo "(go go gadget sed)" + sed -i 's,\(^.*linux-\)gnu\(.*\)$,\0\n\1musl\2,' llvm-targets + echo "llvm-targets now contains these '*-linux-musl*' targets:" + grep linux-musl llvm-targets | sed 's/^/ /' + + echo "And now patching to preserve '-musleabi' as done with '-gnueabi'" + # (aclocal.m4 is actual source, but patch configure as well since we don't re-gen) + for x in configure aclocal.m4; do + substituteInPlace $x \ + --replace '*-android*|*-gnueabi*)' \ + '*-android*|*-gnueabi*|*-musleabi*)' + done + ''; + + # TODO(@Ericson2314): Always pass "--target" and always prefix. + configurePlatforms = [ "build" "host" ] + ++ stdenv.lib.optional (targetPlatform != hostPlatform) "target"; + # `--with` flags for libraries needed for RTS linker + configureFlags = [ + "--datadir=$doc/share/doc/ghc" + "--with-curses-includes=${ncurses.dev}/include" "--with-curses-libraries=${ncurses.out}/lib" + ] ++ stdenv.lib.optional (targetPlatform == hostPlatform && !enableIntegerSimple) [ + "--with-gmp-includes=${targetPackages.gmp.dev}/include" "--with-gmp-libraries=${targetPackages.gmp.out}/lib" + ] ++ stdenv.lib.optional (targetPlatform == hostPlatform && hostPlatform.libc != "glibc" && !targetPlatform.isWindows) [ + "--with-iconv-includes=${libiconv}/include" "--with-iconv-libraries=${libiconv}/lib" + ] ++ stdenv.lib.optionals (targetPlatform != hostPlatform) [ + "--enable-bootstrap-with-devel-snapshot" + ] ++ stdenv.lib.optionals (targetPlatform.isAarch32) [ + "CFLAGS=-fuse-ld=gold" + "CONF_GCC_LINKER_OPTS_STAGE1=-fuse-ld=gold" + "CONF_GCC_LINKER_OPTS_STAGE2=-fuse-ld=gold" + ] ++ stdenv.lib.optionals (disableLargeAddressSpace) [ + "--disable-large-address-space" + ]; + + # Make sure we never relax`$PATH` and hooks support for compatability. + strictDeps = true; + + nativeBuildInputs = [ + perl autoconf automake m4 python3 sphinx + bootPkgs.ghc bootPkgs.alex bootPkgs.happy bootPkgs.hscolour + ]; + + # For building runtime libs + depsBuildTarget = toolsForTarget; + + buildInputs = [ perl ] ++ (libDeps hostPlatform); + + propagatedBuildInputs = [ targetPackages.stdenv.cc ] + ++ stdenv.lib.optional useLLVM llvmPackages.llvm; + + depsTargetTarget = map stdenv.lib.getDev (libDeps targetPlatform); + depsTargetTargetPropagated = map (stdenv.lib.getOutput "out") (libDeps targetPlatform); + + # required, because otherwise all symbols from HSffi.o are stripped, and + # that in turn causes GHCi to abort + stripDebugFlags = [ "-S" ] ++ stdenv.lib.optional (!targetPlatform.isDarwin) "--keep-file-symbols"; + + checkTarget = "test"; + + hardeningDisable = [ "format" ] ++ stdenv.lib.optional stdenv.targetPlatform.isMusl "pie"; + + postInstall = '' + # Install the bash completion file. + install -D -m 444 utils/completion/ghc.bash $out/share/bash-completion/completions/${targetPrefix}ghc + + # Patch scripts to include "readelf" and "cat" in $PATH. + for i in "$out/bin/"*; do + test ! -h $i || continue + egrep --quiet '^#!' <(head -n 1 $i) || continue + sed -i -e '2i export PATH="$PATH:${stdenv.lib.makeBinPath [ targetPackages.stdenv.cc.bintools coreutils ]}"' $i + done + ''; + + passthru = { + inherit bootPkgs targetPrefix; + + inherit llvmPackages; + inherit enableShared; + + # Our Cabal compiler name + haskellCompilerName = "ghc-8.7"; + }; + + meta = { + homepage = http://haskell.org/ghc; + description = "The Glasgow Haskell Compiler"; + maintainers = with stdenv.lib.maintainers; [ marcweber andres peti ]; + inherit (bootPkgs.ghc.meta) license platforms; + }; + +} // stdenv.lib.optionalAttrs targetPlatform.useAndroidPrebuilt { + dontStrip = true; + dontPatchELF = true; + noAuditTmpdir = true; +}) diff --git a/nixpkgs/pkgs/development/compilers/ghcjs-ng/8.4/dep-overrides.nix b/nixpkgs/pkgs/development/compilers/ghcjs-ng/8.4/dep-overrides.nix new file mode 100644 index 000000000000..efba0dc8634f --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/ghcjs-ng/8.4/dep-overrides.nix @@ -0,0 +1,9 @@ +{ haskellLib }: + +let inherit (haskellLib) dontCheck doJailbreak; +in self: super: { + haddock-library-ghcjs = doJailbreak (dontCheck super.haddock-library-ghcjs); + haddock-api-ghcjs = doJailbreak super.haddock-api-ghcjs; + + template-haskell-ghcjs = doJailbreak super.template-haskell-ghcjs; +} diff --git a/nixpkgs/pkgs/development/compilers/ghcjs-ng/8.4/git.json b/nixpkgs/pkgs/development/compilers/ghcjs-ng/8.4/git.json new file mode 100644 index 000000000000..cfa6cf1d7d26 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/ghcjs-ng/8.4/git.json @@ -0,0 +1,6 @@ +{ + "url": "https://github.com/ghcjs/ghcjs", + "rev": "81bf5f31dabaa711aab234cb119eb9c998ccb129", + "sha256": "1bgnc71kjqicqv2xq8p70nck600yi2p7g4k9r1jclv21ib7i5hmx", + "fetchSubmodules": true +} diff --git a/nixpkgs/pkgs/development/compilers/ghcjs-ng/8.4/stage0.nix b/nixpkgs/pkgs/development/compilers/ghcjs-ng/8.4/stage0.nix new file mode 100644 index 000000000000..3b89db144979 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/ghcjs-ng/8.4/stage0.nix @@ -0,0 +1,176 @@ +{ callPackage, configuredSrc }: + +{ + + ghcjs = callPackage + ({ mkDerivation, aeson, array, attoparsec, base, base16-bytestring + , base64-bytestring, binary, bytestring, Cabal, containers + , cryptohash, data-default, deepseq, directory, executable-path + , filepath, ghc-api-ghcjs, ghc-boot, ghc-paths, ghci-ghcjs + , ghcjs-th, haddock-api-ghcjs, hashable, haskell-src-exts + , haskell-src-meta, http-types, HUnit, lens, lifted-base, mtl + , network, optparse-applicative, parallel, parsec, process, random + , regex-posix, safe, shelly, split, stdenv, stringsearch, syb + , system-fileio, system-filepath, tar, template-haskell + , template-haskell-ghcjs, terminfo, test-framework + , test-framework-hunit, text, time, transformers + , transformers-compat, unix, unix-compat, unordered-containers + , vector, wai, wai-app-static, wai-extra, wai-websockets, warp + , webdriver, websockets, wl-pprint-text, yaml + }: + mkDerivation { + pname = "ghcjs"; + version = "8.4.0.1"; + src = configuredSrc + /.; + isLibrary = true; + isExecutable = true; + enableSeparateDataOutput = true; + setupHaskellDepends = [ + base Cabal containers directory filepath process template-haskell + transformers + ]; + libraryHaskellDepends = [ + aeson array attoparsec base base16-bytestring base64-bytestring + binary bytestring Cabal containers cryptohash data-default deepseq + directory filepath ghc-api-ghcjs ghc-boot ghc-paths ghci-ghcjs + ghcjs-th hashable haskell-src-exts haskell-src-meta lens mtl + optparse-applicative parallel parsec process regex-posix safe split + stringsearch syb template-haskell template-haskell-ghcjs text time + transformers unordered-containers vector wl-pprint-text yaml + ]; + executableHaskellDepends = [ + aeson base binary bytestring Cabal containers directory + executable-path filepath ghc-api-ghcjs ghc-boot haddock-api-ghcjs + lens mtl optparse-applicative process shelly system-fileio + system-filepath tar terminfo text time transformers + transformers-compat unix unix-compat unordered-containers vector + yaml + ]; + testHaskellDepends = [ + aeson base bytestring data-default deepseq directory http-types + HUnit lens lifted-base network optparse-applicative process random + shelly system-fileio system-filepath test-framework + test-framework-hunit text time transformers unordered-containers + wai wai-app-static wai-extra wai-websockets warp webdriver + websockets yaml + ]; + description = "Haskell to JavaScript compiler"; + license = stdenv.lib.licenses.mit; + }) {}; + + ghc-api-ghcjs = callPackage + ({ mkDerivation, array, base, binary, bytestring, containers + , deepseq, directory, filepath, ghc-boot, ghc-boot-th, ghci-ghcjs + , hpc, process, stdenv, template-haskell-ghcjs, terminfo, time + , transformers, unix + }: + mkDerivation { + pname = "ghc-api-ghcjs"; + version = "8.4.0"; + src = configuredSrc + /lib/ghc-api-ghcjs; + libraryHaskellDepends = [ + array base binary bytestring containers deepseq directory filepath + ghc-boot ghc-boot-th ghci-ghcjs hpc process template-haskell-ghcjs + terminfo time transformers unix + ]; + homepage = "http://www.haskell.org/ghc/"; + description = "The GHC API (customized for GHCJS)"; + license = stdenv.lib.licenses.bsd3; + }) {}; + + ghci-ghcjs = callPackage + ({ mkDerivation, array, base, binary, bytestring, containers + , deepseq, filepath, ghc-boot, ghc-boot-th, stdenv + , template-haskell-ghcjs, transformers, unix + }: + mkDerivation { + pname = "ghci-ghcjs"; + version = "8.4.0"; + src = configuredSrc + /lib/ghci-ghcjs; + libraryHaskellDepends = [ + array base binary bytestring containers deepseq filepath ghc-boot + ghc-boot-th template-haskell-ghcjs transformers unix + ]; + description = "The library supporting GHC's interactive interpreter (customized for GHCJS)"; + license = stdenv.lib.licenses.bsd3; + }) {}; + + ghcjs-th = callPackage + ({ mkDerivation, base, binary, bytestring, containers, ghc-prim + , ghci-ghcjs, stdenv, template-haskell-ghcjs + }: + mkDerivation { + pname = "ghcjs-th"; + version = "0.1.0.0"; + src = configuredSrc + /lib/ghcjs-th; + libraryHaskellDepends = [ + base binary bytestring containers ghc-prim ghci-ghcjs + template-haskell-ghcjs + ]; + homepage = "https://github.com/ghcjs"; + license = stdenv.lib.licenses.mit; + }) {}; + + haddock-api-ghcjs = callPackage + ({ mkDerivation, array, base, bytestring, Cabal, containers, deepseq + , directory, filepath, ghc-api-ghcjs, ghc-boot, ghc-paths + , haddock-library-ghcjs, hspec, hspec-discover, QuickCheck, stdenv + , transformers, xhtml + }: + mkDerivation { + pname = "haddock-api-ghcjs"; + version = "2.20.0"; + src = configuredSrc + /lib/haddock-api-ghcjs; + enableSeparateDataOutput = true; + libraryHaskellDepends = [ + array base bytestring Cabal containers deepseq directory filepath + ghc-api-ghcjs ghc-boot ghc-paths haddock-library-ghcjs transformers + xhtml + ]; + testHaskellDepends = [ + array base bytestring Cabal containers deepseq directory filepath + ghc-api-ghcjs ghc-boot ghc-paths haddock-library-ghcjs hspec + QuickCheck transformers xhtml + ]; + testToolDepends = [ hspec-discover ]; + homepage = "http://www.haskell.org/haddock/"; + description = "A documentation-generation tool for Haskell libraries"; + license = stdenv.lib.licenses.bsd3; + }) {}; + + haddock-library-ghcjs = callPackage + ({ mkDerivation, base, base-compat, bytestring, containers, deepseq + , directory, filepath, haddock-library, hspec, hspec-discover + , optparse-applicative, QuickCheck, stdenv, transformers, tree-diff + }: + mkDerivation { + pname = "haddock-library-ghcjs"; + version = "1.6.0"; + src = configuredSrc + /lib/haddock-library-ghcjs; + libraryHaskellDepends = [ + base bytestring containers deepseq transformers + ]; + testHaskellDepends = [ + base base-compat bytestring containers deepseq directory filepath + haddock-library hspec optparse-applicative QuickCheck transformers + tree-diff + ]; + testToolDepends = [ hspec-discover ]; + doHaddock = false; + homepage = "http://www.haskell.org/haddock/"; + description = "Library exposing some functionality of Haddock"; + license = stdenv.lib.licenses.bsd3; + }) {}; + + template-haskell-ghcjs = callPackage + ({ mkDerivation, base, ghc-boot-th, pretty, stdenv }: + mkDerivation { + pname = "template-haskell-ghcjs"; + version = "2.13.0.0"; + src = configuredSrc + /lib/template-haskell-ghcjs; + libraryHaskellDepends = [ base ghc-boot-th pretty ]; + description = "Support library for Template Haskell (customized for GHCJS)"; + license = stdenv.lib.licenses.bsd3; + }) {}; + +} diff --git a/nixpkgs/pkgs/development/compilers/ghcjs-ng/8.6/dep-overrides.nix b/nixpkgs/pkgs/development/compilers/ghcjs-ng/8.6/dep-overrides.nix new file mode 100644 index 000000000000..8681aceacd7f --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/ghcjs-ng/8.6/dep-overrides.nix @@ -0,0 +1,7 @@ +{ haskellLib }: + +let inherit (haskellLib) dontCheck doJailbreak dontHaddock; +in self: super: { + haddock-library-ghcjs = doJailbreak super.haddock-library-ghcjs; + haddock-api-ghcjs = doJailbreak (dontHaddock super.haddock-api-ghcjs); +} diff --git a/nixpkgs/pkgs/development/compilers/ghcjs-ng/8.6/git.json b/nixpkgs/pkgs/development/compilers/ghcjs-ng/8.6/git.json new file mode 100644 index 000000000000..37861b96e7aa --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/ghcjs-ng/8.6/git.json @@ -0,0 +1,6 @@ +{ + "url": "https://github.com/ghcjs/ghcjs", + "rev": "75c61af32d73def4409d1fe7b64659c1d28cd075", + "sha256": "18pixn6xdz6qp941yhxfnmwi463jnpskmg473lv07vvgy4hpgjhj", + "fetchSubmodules": true +} diff --git a/nixpkgs/pkgs/development/compilers/ghcjs-ng/8.6/stage0.nix b/nixpkgs/pkgs/development/compilers/ghcjs-ng/8.6/stage0.nix new file mode 100644 index 000000000000..a89ab15c55fd --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/ghcjs-ng/8.6/stage0.nix @@ -0,0 +1,176 @@ +{ callPackage, configuredSrc }: + +{ + + ghcjs = callPackage + ({ mkDerivation, aeson, array, attoparsec, base, base16-bytestring + , base64-bytestring, binary, bytestring, Cabal, containers + , cryptohash, data-default, deepseq, directory, executable-path + , filepath, ghc-api-ghcjs, ghc-boot, ghc-paths, ghci-ghcjs + , ghcjs-th, haddock-api-ghcjs, hashable, haskell-src-exts + , haskell-src-meta, http-types, HUnit, lens, lifted-base, mtl + , network, optparse-applicative, parallel, parsec, process, random + , regex-posix, safe, shelly, split, stdenv, stringsearch, syb + , system-fileio, system-filepath, tar, template-haskell + , template-haskell-ghcjs, terminfo, test-framework + , test-framework-hunit, text, time, transformers + , transformers-compat, unix, unix-compat, unordered-containers + , vector, wai, wai-app-static, wai-extra, wai-websockets, warp + , webdriver, websockets, wl-pprint-text, yaml + }: + mkDerivation { + pname = "ghcjs"; + version = "8.6.0.1"; + src = configuredSrc + /.; + isLibrary = true; + isExecutable = true; + enableSeparateDataOutput = true; + setupHaskellDepends = [ + base Cabal containers directory filepath process template-haskell + transformers + ]; + libraryHaskellDepends = [ + aeson array attoparsec base base16-bytestring base64-bytestring + binary bytestring Cabal containers cryptohash data-default deepseq + directory filepath ghc-api-ghcjs ghc-boot ghc-paths ghci-ghcjs + ghcjs-th hashable haskell-src-exts haskell-src-meta lens mtl + optparse-applicative parallel parsec process regex-posix safe split + stringsearch syb template-haskell template-haskell-ghcjs text time + transformers unordered-containers vector wl-pprint-text yaml + ]; + executableHaskellDepends = [ + aeson base binary bytestring Cabal containers directory + executable-path filepath ghc-api-ghcjs ghc-boot haddock-api-ghcjs + lens mtl optparse-applicative process shelly system-fileio + system-filepath tar terminfo text time transformers + transformers-compat unix unix-compat unordered-containers vector + yaml + ]; + testHaskellDepends = [ + aeson base bytestring data-default deepseq directory http-types + HUnit lens lifted-base network optparse-applicative process random + shelly system-fileio system-filepath test-framework + test-framework-hunit text time transformers unordered-containers + wai wai-app-static wai-extra wai-websockets warp webdriver + websockets yaml + ]; + description = "Haskell to JavaScript compiler"; + license = stdenv.lib.licenses.mit; + }) {}; + + ghc-api-ghcjs = callPackage + ({ mkDerivation, array, base, binary, bytestring, containers + , deepseq, directory, filepath, ghc-boot, ghc-boot-th, ghc-heap + , ghci-ghcjs, hpc, process, stdenv, template-haskell-ghcjs + , terminfo, time, transformers, unix + }: + mkDerivation { + pname = "ghc-api-ghcjs"; + version = "8.6.2"; + src = configuredSrc + /lib/ghc-api-ghcjs; + libraryHaskellDepends = [ + array base binary bytestring containers deepseq directory filepath + ghc-boot ghc-boot-th ghc-heap ghci-ghcjs hpc process + template-haskell-ghcjs terminfo time transformers unix + ]; + homepage = "http://www.haskell.org/ghc/"; + description = "The GHC API (customized for GHCJS)"; + license = stdenv.lib.licenses.bsd3; + }) {}; + + ghci-ghcjs = callPackage + ({ mkDerivation, array, base, binary, bytestring, containers + , deepseq, filepath, ghc-boot, ghc-boot-th, ghc-heap, stdenv + , template-haskell-ghcjs, transformers, unix + }: + mkDerivation { + pname = "ghci-ghcjs"; + version = "8.6.1"; + src = configuredSrc + /lib/ghci-ghcjs; + libraryHaskellDepends = [ + array base binary bytestring containers deepseq filepath ghc-boot + ghc-boot-th ghc-heap template-haskell-ghcjs transformers unix + ]; + description = "The library supporting GHC's interactive interpreter (customized for GHCJS)"; + license = stdenv.lib.licenses.bsd3; + }) {}; + + ghcjs-th = callPackage + ({ mkDerivation, base, binary, bytestring, containers, ghc-prim + , ghci-ghcjs, stdenv, template-haskell-ghcjs + }: + mkDerivation { + pname = "ghcjs-th"; + version = "0.1.0.0"; + src = configuredSrc + /lib/ghcjs-th; + libraryHaskellDepends = [ + base binary bytestring containers ghc-prim ghci-ghcjs + template-haskell-ghcjs + ]; + homepage = "https://github.com/ghcjs"; + license = stdenv.lib.licenses.mit; + }) {}; + + haddock-api-ghcjs = callPackage + ({ mkDerivation, array, base, bytestring, Cabal, containers, deepseq + , directory, filepath, ghc-api-ghcjs, ghc-boot, ghc-paths + , haddock-library-ghcjs, hspec, hspec-discover, QuickCheck, stdenv + , transformers, xhtml + }: + mkDerivation { + pname = "haddock-api-ghcjs"; + version = "2.20.0"; + src = configuredSrc + /lib/haddock-api-ghcjs; + enableSeparateDataOutput = true; + libraryHaskellDepends = [ + array base bytestring Cabal containers deepseq directory filepath + ghc-api-ghcjs ghc-boot ghc-paths haddock-library-ghcjs transformers + xhtml + ]; + testHaskellDepends = [ + array base bytestring Cabal containers deepseq directory filepath + ghc-api-ghcjs ghc-boot ghc-paths haddock-library-ghcjs hspec + QuickCheck transformers xhtml + ]; + testToolDepends = [ hspec-discover ]; + homepage = "http://www.haskell.org/haddock/"; + description = "A documentation-generation tool for Haskell libraries"; + license = stdenv.lib.licenses.bsd3; + }) {}; + + haddock-library-ghcjs = callPackage + ({ mkDerivation, base, base-compat, bytestring, containers, deepseq + , directory, filepath, haddock-library, hspec, hspec-discover + , optparse-applicative, parsec, QuickCheck, stdenv, text + , transformers, tree-diff + }: + mkDerivation { + pname = "haddock-library-ghcjs"; + version = "1.6.0"; + src = configuredSrc + /lib/haddock-library-ghcjs; + libraryHaskellDepends = [ + base bytestring containers parsec text transformers + ]; + testHaskellDepends = [ + base base-compat bytestring containers deepseq directory filepath + haddock-library hspec optparse-applicative parsec QuickCheck text + transformers tree-diff + ]; + testToolDepends = [ hspec-discover ]; + homepage = "http://www.haskell.org/haddock/"; + description = "Library exposing some functionality of Haddock"; + license = stdenv.lib.licenses.bsd3; + }) {}; + + template-haskell-ghcjs = callPackage + ({ mkDerivation, base, ghc-boot-th, pretty, stdenv }: + mkDerivation { + pname = "template-haskell-ghcjs"; + version = "2.14.0.0"; + src = configuredSrc + /lib/template-haskell-ghcjs; + libraryHaskellDepends = [ base ghc-boot-th pretty ]; + description = "Support library for Template Haskell (customized for GHCJS)"; + license = stdenv.lib.licenses.bsd3; + }) {}; + +} diff --git a/nixpkgs/pkgs/development/compilers/ghcjs-ng/README.md b/nixpkgs/pkgs/development/compilers/ghcjs-ng/README.md new file mode 100644 index 000000000000..99ad980c965e --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/ghcjs-ng/README.md @@ -0,0 +1,21 @@ +New build system for GHCJS 8.2 +--- + +`ghcjs-8.2` reworked the build system, and now comes with its own +small package set of dependencies. This involves autogenerating +several sources and cabal files, based on a GHC +checkout. `callCabal2nix` is off limits, since we don't like "import +from derivation" in nixpkgs. So there is a derivation that builds the +nix expression that should be checked in whenever GHCJS is updated. + +Updating +--- + +``` +$ nix-prefetch-git https://github.com/ghcjs/ghcjs --rev refs/heads/ghc-8.4 \ + | jq '{ url, rev, fetchSubmodules, sha256 }' \ + > 8.4/git.json +$ cat $(nix-build ../../../.. -A haskell.compiler.ghcjs82.genStage0 --no-out-link) > 8.4/stage0.nix +$ cabal2nix --compiler ghcjs git://github.com/ghcjs/ghcjs-base > ghcjs-base.nix +``` + diff --git a/nixpkgs/pkgs/development/compilers/ghcjs-ng/common-overrides.nix b/nixpkgs/pkgs/development/compilers/ghcjs-ng/common-overrides.nix new file mode 100644 index 000000000000..52f3ad497ad6 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/ghcjs-ng/common-overrides.nix @@ -0,0 +1,9 @@ +{ haskellLib, alex, happy }: + +let inherit (haskellLib) addBuildTools appendConfigureFlag dontHaddock doJailbreak; +in self: super: { + ghc-api-ghcjs = addBuildTools super.ghc-api-ghcjs [alex happy]; + ghcjs = dontHaddock (appendConfigureFlag (doJailbreak super.ghcjs) "-fno-wrapper-install"); + haddock-library-ghcjs = dontHaddock super.haddock-library-ghcjs; + system-fileio = doJailbreak super.system-fileio; +} diff --git a/nixpkgs/pkgs/development/compilers/ghcjs-ng/configured-ghcjs-src.nix b/nixpkgs/pkgs/development/compilers/ghcjs-ng/configured-ghcjs-src.nix new file mode 100644 index 000000000000..56b69ea267f9 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/ghcjs-ng/configured-ghcjs-src.nix @@ -0,0 +1,51 @@ +{ perl +, autoconf +, automake +, python3 +, gcc +, cabal-install +, runCommand +, lib +, stdenv + +, ghc +, happy +, alex + +, ghcjsSrc +}: + +runCommand "configured-ghcjs-src" { + buildInputs = [ + perl + autoconf + automake + python3 + ghc + happy + alex + cabal-install + ] ++ lib.optionals stdenv.isDarwin [ + gcc # https://github.com/ghcjs/ghcjs/issues/663 + ]; + inherit ghcjsSrc; +} '' + export HOME=$(pwd) + mkdir $HOME/.cabal + touch $HOME/.cabal/config + cp -r "$ghcjsSrc" "$out" + chmod -R +w "$out" + cd "$out" + + # TODO: Find a better way to avoid impure version numbers + sed -i 's/RELEASE=NO/RELEASE=YES/' ghc/configure.ac + + # TODO: How to actually fix this? + # Seems to work fine and produce the right files. + touch ghc/includes/ghcautoconf.h + mkdir -p ghc/compiler/vectorise + mkdir -p ghc/utils/haddock/haddock-library/vendor + + patchShebangs . + ./utils/makePackages.sh copy +'' diff --git a/nixpkgs/pkgs/development/compilers/ghcjs-ng/default.nix b/nixpkgs/pkgs/development/compilers/ghcjs-ng/default.nix new file mode 100644 index 000000000000..068d7b578dfe --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/ghcjs-ng/default.nix @@ -0,0 +1,109 @@ +{ stdenv +, callPackage +, fetchgit +, ghcjsSrcJson ? null +, ghcjsSrc ? fetchgit (builtins.fromJSON (builtins.readFile ghcjsSrcJson)) +, bootPkgs +, stage0 +, haskellLib +, cabal-install +, nodejs +, makeWrapper +, xorg +, gmp +, pkgconfig +, gcc +, lib +, nodePackages +, ghcjsDepOverrides ? (_:_:{}) +, haskell +}: + +let + passthru = { + configuredSrc = callPackage ./configured-ghcjs-src.nix { + inherit ghcjsSrc; + inherit (bootPkgs) ghc alex happy; + }; + genStage0 = callPackage ./mk-stage0.nix { inherit (passthru) configuredSrc; }; + bootPkgs = bootPkgs.extend (lib.foldr lib.composeExtensions (_:_:{}) [ + (self: _: import stage0 { + inherit (passthru) configuredSrc; + inherit (self) callPackage; + }) + + (callPackage ./common-overrides.nix { + inherit haskellLib; + inherit (bootPkgs) alex happy; + }) + ghcjsDepOverrides + ]); + + targetPrefix = ""; + inherit bootGhcjs; + inherit (bootGhcjs) version; + ghcVersion = bootPkgs.ghc.version; + isGhcjs = true; + + enableShared = true; + + socket-io = nodePackages."socket.io"; + + # Relics of the old GHCJS build system + stage1Packages = []; + mkStage2 = { callPackage }: { + # https://github.com/ghcjs/ghcjs-base/issues/110 + # https://github.com/ghcjs/ghcjs-base/pull/111 + ghcjs-base = haskell.lib.dontCheck (haskell.lib.doJailbreak (callPackage ./ghcjs-base.nix {})); + }; + + haskellCompilerName = "ghcjs-${bootGhcjs.version}"; + }; + + bootGhcjs = haskellLib.justStaticExecutables passthru.bootPkgs.ghcjs; + libexec = "${bootGhcjs}/libexec/${builtins.replaceStrings ["darwin" "i686"] ["osx" "i386"] stdenv.buildPlatform.system}-${passthru.bootPkgs.ghc.name}/${bootGhcjs.name}"; + +in stdenv.mkDerivation { + name = bootGhcjs.name; + src = passthru.configuredSrc; + nativeBuildInputs = [ + bootGhcjs + passthru.bootPkgs.ghc + cabal-install + nodejs + makeWrapper + xorg.lndir + gmp + pkgconfig + ] ++ lib.optionals stdenv.isDarwin [ + gcc # https://github.com/ghcjs/ghcjs/issues/663 + ]; + dontConfigure = true; + dontInstall = true; + buildPhase = '' + export HOME=$TMP + mkdir $HOME/.cabal + touch $HOME/.cabal/config + cd lib/boot + + mkdir -p $out/bin + mkdir -p $out/lib/${bootGhcjs.name} + lndir ${libexec} $out/bin + + wrapProgram $out/bin/ghcjs --add-flags "-B$out/lib/${bootGhcjs.name}" + wrapProgram $out/bin/haddock-ghcjs --add-flags "-B$out/lib/${bootGhcjs.name}" + wrapProgram $out/bin/ghcjs-pkg --add-flags "--global-package-db=$out/lib/${bootGhcjs.name}/package.conf.d" + + env PATH=$out/bin:$PATH $out/bin/ghcjs-boot -j1 --with-ghcjs-bin $out/bin + ''; + + # We hard code -j1 as a temporary workaround for + # https://github.com/ghcjs/ghcjs/issues/654 + # enableParallelBuilding = true; + + inherit passthru; + + meta.platforms = passthru.bootPkgs.ghc.meta.platforms; + meta.maintainers = [lib.maintainers.elvishjerricco]; + meta.hydraPlatforms = []; + } diff --git a/nixpkgs/pkgs/development/compilers/ghcjs-ng/ghcjs-base.nix b/nixpkgs/pkgs/development/compilers/ghcjs-ng/ghcjs-base.nix new file mode 100644 index 000000000000..7c10ce6572f8 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/ghcjs-ng/ghcjs-base.nix @@ -0,0 +1,29 @@ +{ mkDerivation, aeson, array, attoparsec, base, binary, bytestring +, containers, deepseq, directory, dlist, fetchgit, ghc-prim +, ghcjs-prim, hashable, HUnit, integer-gmp, primitive, QuickCheck +, quickcheck-unicode, random, scientific, stdenv, test-framework +, test-framework-hunit, test-framework-quickcheck2, text, time +, transformers, unordered-containers, vector +}: +mkDerivation { + pname = "ghcjs-base"; + version = "0.2.0.0"; + src = fetchgit { + url = "git://github.com/ghcjs/ghcjs-base"; + sha256 = "0qr05m0djll3x38dhl85pl798arsndmwfhil8yklhb70lxrbvfrs"; + rev = "01014ade3f8f5ae677df192d7c2a208bd795b96c"; + }; + libraryHaskellDepends = [ + aeson attoparsec base binary bytestring containers deepseq dlist + ghc-prim ghcjs-prim hashable integer-gmp primitive scientific text + time transformers unordered-containers vector + ]; + testHaskellDepends = [ + array base bytestring deepseq directory ghc-prim ghcjs-prim HUnit + primitive QuickCheck quickcheck-unicode random test-framework + test-framework-hunit test-framework-quickcheck2 text + ]; + homepage = "https://github.com/ghcjs/ghcjs-base"; + description = "base library for GHCJS"; + license = stdenv.lib.licenses.mit; +} diff --git a/nixpkgs/pkgs/development/compilers/ghcjs-ng/mk-stage0.nix b/nixpkgs/pkgs/development/compilers/ghcjs-ng/mk-stage0.nix new file mode 100644 index 000000000000..f45ebb4511d6 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/ghcjs-ng/mk-stage0.nix @@ -0,0 +1,25 @@ +{ configuredSrc +, runCommand +, cabal2nix +, yq +}: + +runCommand "stage0.nix" { + buildInputs = [cabal2nix yq]; +} '' + ( + printf '{ callPackage, configuredSrc }:\n\n{\n\n' + yq '.packages | .[]' ${configuredSrc}/stack.yaml -r | sed 's|^\.$|./.|' | sed 's|^\.||' | while read f; do + printf ' %s = callPackage\n' \ + "$(find ${configuredSrc}/$f -name "*.cabal" -maxdepth 1 \ + | xargs basename \ + | sed 's/.cabal$//')" + printf '(%s) {};' \ + "$(cabal2nix ${configuredSrc}/$f \ + | sed 's|${configuredSrc}/|configuredSrc + |g')" \ + | sed 's/^/ /' + printf '\n\n' + done + printf '}\n' + ) > $out +'' diff --git a/nixpkgs/pkgs/development/compilers/ghcjs/base.nix b/nixpkgs/pkgs/development/compilers/ghcjs/base.nix new file mode 100644 index 000000000000..93e6a47934fc --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/ghcjs/base.nix @@ -0,0 +1,161 @@ +{ mkDerivation +, lib +, broken ? false +, test-framework +, test-framework-hunit +, data-default +, ghc-paths +, haskell-src-exts +, haskell-src-meta +, optparse-applicative +, system-fileio +, system-filepath +, text-binary +, unordered-containers +, cabal-install +, wl-pprint-text +, base16-bytestring +, executable-path +, transformers-compat +, haddock-api +, regex-posix + +, bootPkgs, gmp + +, runCommand +, nodejs, stdenv, filepath, HTTP, HUnit, mtl, network, QuickCheck, random, stm +, time +, zlib, aeson, attoparsec, bzlib, hashable +, lens +, parallel, safe, shelly, split, stringsearch, syb +, tar, terminfo +, vector, yaml, fetchgit, fetchFromGitHub +, alex, happy, git, gnumake, autoconf, patch +, automake, libtool +, cryptohash +, haddock, hspec, xhtml, pkgs +, coreutils +, libiconv + +, version +, ghcjsSrc +, ghcjsBootSrc +, ghcjsBoot ? import ./ghcjs-boot.nix { + inherit runCommand; + src = ghcjsBootSrc; + } +, shims + +# This is the list of the Stage 1 packages that are built into a booted ghcjs installation +# It can be generated with the command: +# nix-shell -p haskell.packages.ghcjs.ghc --command "ghcjs-pkg list | sed -n 's/^ \(.*\)-\([0-9.]*\)$/\1_\2/ p' | sed 's/\./_/g' | sed 's/^\([^_]*\)\(.*\)$/ \"\1\"/'" +, stage1Packages + +, stage2 ? import ./stage2.nix + +, patches + +# used for resolving compiler plugins +, ghcLibdir ? null +}: +let + inherit (bootPkgs) ghc; + +in mkDerivation (rec { + pname = "ghcjs"; + inherit version; + src = ghcjsSrc; + isLibrary = true; + isExecutable = true; + jailbreak = true; + doHaddock = false; + doCheck = false; + buildDepends = [ + filepath HTTP mtl network random stm time zlib aeson attoparsec + bzlib data-default ghc-paths hashable haskell-src-exts haskell-src-meta + lens optparse-applicative parallel safe shelly split + stringsearch syb system-fileio system-filepath tar terminfo text-binary + unordered-containers vector wl-pprint-text yaml + alex happy git gnumake autoconf automake libtool patch gmp + base16-bytestring cryptohash executable-path haddock-api + transformers-compat QuickCheck haddock hspec xhtml + regex-posix libiconv + ]; + buildTools = [ nodejs git ]; + testDepends = [ + HUnit test-framework test-framework-hunit + ]; + inherit patches; + postPatch = '' + substituteInPlace Setup.hs \ + --replace "/usr/bin/env" "${coreutils}/bin/env" + + substituteInPlace src/Compiler/Info.hs \ + --replace "@PREFIX@" "$out" \ + --replace "@VERSION@" "${version}" + + substituteInPlace src-bin/Boot.hs \ + --replace "@PREFIX@" "$out" \ + --replace "@CC@" "${stdenv.cc}/bin/cc" + ''; + preBuild = '' + export HOME="$TMP" + + local topDir=$out/lib/ghcjs-${version} + mkdir -p $topDir + + cp -r ${ghcjsBoot} $topDir/ghcjs-boot + chmod -R u+w $topDir/ghcjs-boot + + cp -r ${shims} $topDir/shims + chmod -R u+w $topDir/shims + + # Make the patches be relative their corresponding package's directory. + # See: https://github.com/ghcjs/ghcjs-boot/pull/12 + for patch in "$topDir/ghcjs-boot/patches/"*.patch; do + echo "fixing patch: $patch" + sed -i -e 's@ \(a\|b\)/boot/[^/]\+@ \1@g' $patch + done + ''; + # We build with --quick so we can build stage 2 packages separately. + # This is necessary due to: https://github.com/haskell/cabal/commit/af19fb2c2d231d8deff1cb24164a2bf7efb8905a + # Cabal otherwise fails to build: http://hydra.nixos.org/build/31824079/nixlog/1/raw + postInstall = '' + PATH=$out/bin:$PATH LD_LIBRARY_PATH=${gmp.out}/lib:${stdenv.cc}/lib64:$LD_LIBRARY_PATH \ + env -u GHC_PACKAGE_PATH $out/bin/ghcjs-boot \ + --dev \ + --quick \ + --with-cabal ${cabal-install}/bin/cabal \ + --with-gmp-includes ${gmp.dev}/include \ + --with-gmp-libraries ${gmp.out}/lib + '' + lib.optionalString (ghcLibdir != null) '' + printf '%s' '${ghcLibdir}' > "$out/lib/ghcjs-${version}/ghc_libdir" + ''; + passthru = { + inherit bootPkgs; + ghcVersion = ghc.version; + isCross = true; + isGhcjs = true; + inherit nodejs ghcjsBoot; + socket-io = pkgs.nodePackages."socket.io"; + haskellCompilerName = "ghcjs-${version}"; + + # let us assume ghcjs is never actually cross compiled + targetPrefix = ""; + + enableShared = true; + + inherit stage1Packages; + mkStage2 = stage2 { + inherit ghcjsBoot; + }; + }; + + homepage = https://github.com/ghcjs/ghcjs; + description = "A Haskell to JavaScript compiler that uses the GHC API"; + license = stdenv.lib.licenses.bsd3; + platforms = ghc.meta.platforms; + maintainers = with stdenv.lib.maintainers; [ jwiegley cstrahan dmjio elvishjerricco ]; + hydraPlatforms = if broken then [] else ghc.meta.platforms; + inherit broken; +}) diff --git a/nixpkgs/pkgs/development/compilers/ghcjs/gen-stage2.rb b/nixpkgs/pkgs/development/compilers/ghcjs/gen-stage2.rb new file mode 100755 index 000000000000..709e635db55c --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/ghcjs/gen-stage2.rb @@ -0,0 +1,54 @@ +#!/usr/bin/env ruby + +require 'pathname' + +# from boot.yaml in ghcjs/ghcjs +stage2_packages = [ + "boot/async", + "boot/aeson", + "boot/attoparsec", + "boot/case-insensitive", + "boot/dlist", + "boot/extensible-exceptions", + "boot/hashable", + "boot/mtl", + "boot/old-time", + "boot/parallel", + "boot/scientific", + "boot/stm", + "boot/syb", + "boot/text", + "boot/unordered-containers", + "boot/vector", + "ghcjs/ghcjs-base", + # not listed under stage2, but needed when "quick booting". + "boot/cabal/Cabal" +] + +nixpkgs = File.expand_path("../../../../..", __FILE__) +boot = ARGV[0] || `nix-build #{nixpkgs} -A haskell.packages.ghcjs.ghc.ghcjsBoot`.chomp + +out = "".dup +out << "{ ghcjsBoot }: { callPackage }:\n" +out << "\n" +out << "{\n" + +stage2_packages.each do |package| + name = Pathname.new(package).basename + nix = `cabal2nix file://#{boot}/#{package} --jailbreak` + nix.sub!(/src =.*?$/, "src = \"${ghcjsBoot}/#{package}\";") + nix.sub!(" doCheck = false;\n", "") + nix.sub!("libraryHaskellDepends", "doCheck = false;\n libraryHaskellDepends") + # cabal2nix somehow generates the deps for 'text' as if it had selected flag + # 'integer-simple' (despite not passing the flag within the generated + # expression). We want integer-gmp instead. + nix.gsub!(/integer-simple/, "integer-gmp") + nix = nix.split("\n").join("\n ") + + out << " #{name} = callPackage\n" + out << " (#{nix}) {};\n" +end + +out << "}" + +puts out diff --git a/nixpkgs/pkgs/development/compilers/ghcjs/ghcjs-boot.nix b/nixpkgs/pkgs/development/compilers/ghcjs/ghcjs-boot.nix new file mode 100644 index 000000000000..c00e13a92404 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/ghcjs/ghcjs-boot.nix @@ -0,0 +1,25 @@ +{ runCommand, src }: + +# we remove the patches so ghcjs-boot doesn't try to apply them again. +runCommand "${src.name}-patched" {} '' + cp -r ${src} $out + chmod -R +w $out + + # Make the patches be relative their corresponding package's directory. + # See: https://github.com/ghcjs/ghcjs-boot/pull/12 + for patch in $out/patches/*.patch; do + echo ">> fixing patch: $patch" + sed -i -e 's@ \(a\|b\)/boot/[^/]\+@ \1@g' $patch + done + + for package in $(cd $out/boot; echo *); do + patch=$out/patches/$package.patch + if [[ -e $patch ]]; then + echo ">> patching package: $package" + pushd $out/boot/$package + patch -p1 < $patch + rm $patch + popd + fi + done +'' diff --git a/nixpkgs/pkgs/development/compilers/glslang/default.nix b/nixpkgs/pkgs/development/compilers/glslang/default.nix new file mode 100644 index 000000000000..784d66a0f242 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/glslang/default.nix @@ -0,0 +1,37 @@ +{ stdenv, fetchFromGitHub, fetchpatch, cmake, bison, jq, python, spirv-tools, spirv-headers }: +stdenv.mkDerivation rec { + name = "glslang-${version}"; + version = "7.11.3113"; + + src = fetchFromGitHub { + owner = "KhronosGroup"; + repo = "glslang"; + rev = "${version}"; + sha256 = "1kzv2b4q1fddxd7c0hc754nd6rw6y9vijb9fsi13xzzq9dficgb6"; + }; + + nativeBuildInputs = [ cmake python bison jq ]; + enableParallelBuilding = true; + + postPatch = '' + cp --no-preserve=mode -r "${spirv-tools.src}" External/spirv-tools + ln -s "${spirv-headers.src}" External/spirv-tools/external/spirv-headers + ''; + + preConfigure = '' + HEADERS_COMMIT=$(jq -r < known_good.json '.commits|map(select(.name=="spirv-tools/external/spirv-headers"))[0].commit') + TOOLS_COMMIT=$(jq -r < known_good.json '.commits|map(select(.name=="spirv-tools"))[0].commit') + if [ "$HEADERS_COMMIT" != "${spirv-headers.src.rev}" ] || [ "$TOOLS_COMMIT" != "${spirv-tools.src.rev}" ]; then + echo "ERROR: spirv-tools commits do not match expected versions: expected tools at $TOOLS_COMMIT, headers at $HEADERS_COMMIT"; + exit 1; + fi + ''; + + meta = with stdenv.lib; { + inherit (src.meta) homepage; + description = "Khronos reference front-end for GLSL and ESSL"; + license = licenses.asl20; + platforms = platforms.linux; + maintainers = [ maintainers.ralith ]; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/gnu-cobol/default.nix b/nixpkgs/pkgs/development/compilers/gnu-cobol/default.nix new file mode 100644 index 000000000000..ae27964ae8f0 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/gnu-cobol/default.nix @@ -0,0 +1,40 @@ +{ stdenv, fetchurl, gcc, makeWrapper +, db, gmp, ncurses }: + +let + version = "2.2"; + lib = stdenv.lib; +in +stdenv.mkDerivation rec { + name = "gnu-cobol-${version}"; + inherit version; + + src = fetchurl { + url = "https://sourceforge.com/projects/open-cobol/files/gnu-cobol/${version}/gnucobol-${version}.tar.gz"; + sha256 = "1jrjmdx0swssjh388pp08awhiisbrs2i7gx4lcm4p1k5rpg3hn4j"; + }; + + nativeBuildInputs = [ makeWrapper ]; + + buildInputs = [ db gmp ncurses ]; + + cflags = stdenv.lib.concatMapStringsSep " " (p: "-L" + (lib.getLib p) + "/lib ") buildInputs; + ldflags = stdenv.lib.concatMapStringsSep " " (p: "-I" + (lib.getDev p) + "/include ") buildInputs; + + cobolCCFlags = "-I$out/include ${ldflags} -L$out/lib ${cflags}"; + + postInstall = with stdenv.lib; '' + wrapProgram "$out/bin/cobc" \ + --set COB_CC "${gcc}/bin/gcc" \ + --prefix COB_LDFLAGS " " "${cobolCCFlags}" \ + --prefix COB_CFLAGS " " "${cobolCCFlags}" + ''; + + meta = with stdenv.lib; { + description = "An open-source COBOL compiler"; + homepage = https://sourceforge.net/projects/open-cobol/; + license = licenses.gpl3; + maintainers = with maintainers; [ ericsagnes the-kenny ]; + platforms = with platforms; linux ++ darwin; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/gnu-smalltalk/default.nix b/nixpkgs/pkgs/development/compilers/gnu-smalltalk/default.nix new file mode 100644 index 000000000000..41c325c2b1ad --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/gnu-smalltalk/default.nix @@ -0,0 +1,60 @@ +{ config, stdenv, fetchurl, pkgconfig, libtool +, zip, libffi, libsigsegv, readline, gmp +, gnutls, gnome2, cairo, SDL, sqlite +, emacsSupport ? config.emacsSupport or false, emacs ? null }: + +assert emacsSupport -> (emacs != null); + +let # The gnu-smalltalk project has a dependency to the libsigsegv library. + # The project ships with sources for this library, but deprecated this option. + # Using the vanilla libsigsegv library results in error: "cannot relocate [...]" + # Adding --enable-static=libsigsegv to the gnu-smalltalk configuration flags + # does not help, the error still occurs. The only solution is to build a + # shared version of libsigsegv. + libsigsegv-shared = stdenv.lib.overrideDerivation libsigsegv (oldAttrs: { + configureFlags = [ "--enable-shared" ]; + }); + +in stdenv.mkDerivation rec { + + version = "3.2.5"; + name = "gnu-smalltalk-${version}"; + + src = fetchurl { + url = "mirror://gnu/smalltalk/smalltalk-${version}.tar.xz"; + sha256 = "1k2ssrapfzhngc7bg1zrnd9n2vyxp9c9m70byvsma6wapbvib6l1"; + }; + + # The dependencies and their justification are explained at + # http://smalltalk.gnu.org/download + nativeBuildInputs = [ pkgconfig ]; + buildInputs = [ + libtool zip libffi libsigsegv-shared readline gmp gnutls gnome2.gtk + cairo SDL sqlite + ] + ++ stdenv.lib.optional emacsSupport emacs; + + configureFlags = stdenv.lib.optional (!emacsSupport) "--without-emacs"; + + hardeningDisable = [ "format" ]; + + installFlags = stdenv.lib.optional emacsSupport "lispdir=$(out)/share/emacs/site-lisp"; + + # For some reason the tests fail if executated with nix-build, but pass if + # executed within nix-shell --pure. + doCheck = false; + + meta = with stdenv.lib; { + description = "A free implementation of the Smalltalk-80 language"; + longDescription = '' + GNU Smalltalk is a free implementation of the Smalltalk-80 language. It + runs on most POSIX compatible operating systems (including GNU/Linux, of + course), as well as under Windows. Smalltalk is a dynamic object-oriented + language, well-versed to scripting tasks. + ''; + homepage = http://smalltalk.gnu.org/; + license = with licenses; [ gpl2 lgpl2 ]; + platforms = platforms.linux; + maintainers = with maintainers; [ skeidel ]; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/go/1.10.nix b/nixpkgs/pkgs/development/compilers/go/1.10.nix new file mode 100644 index 000000000000..5dce1529a8b8 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/go/1.10.nix @@ -0,0 +1,191 @@ +{ stdenv, fetchFromGitHub, tzdata, iana-etc, go_bootstrap, runCommand, writeScriptBin +, perl, which, pkgconfig, patch, procps, pcre, cacert, llvm, Security, Foundation +, fetchpatch +}: + +let + + inherit (stdenv.lib) optionals optionalString; + + clangHack = writeScriptBin "clang" '' + #!${stdenv.shell} + exec ${stdenv.cc}/bin/clang "$@" 2> >(sed '/ld: warning:.*ignoring unexpected dylib file/ d' 1>&2) + ''; + + goBootstrap = runCommand "go-bootstrap" {} '' + mkdir $out + cp -rf ${go_bootstrap}/* $out/ + chmod -R u+w $out + find $out -name "*.c" -delete + cp -rf $out/bin/* $out/share/go/bin/ + ''; + +in + +stdenv.mkDerivation rec { + name = "go-${version}"; + version = "1.10.8"; + + src = fetchFromGitHub { + owner = "golang"; + repo = "go"; + rev = "go${version}"; + sha256 = "1yynv105wh8pwiq61v4yg5i50k13g3x634x60mhxhv4gj9cq06cx"; + }; + + GOCACHE = "off"; + + # perl is used for testing go vet + nativeBuildInputs = [ perl which pkgconfig patch procps ]; + buildInputs = [ cacert pcre ] + ++ optionals stdenv.isLinux [ stdenv.cc.libc.out ] + ++ optionals (stdenv.hostPlatform.libc == "glibc") [ stdenv.cc.libc.static ]; + propagatedBuildInputs = optionals stdenv.isDarwin [ Security Foundation ]; + + hardeningDisable = [ "all" ]; + + prePatch = '' + patchShebangs ./ # replace /bin/bash + + # This source produces shell script at run time, + # and thus it is not corrected by patchShebangs. + substituteInPlace misc/cgo/testcarchive/carchive_test.go \ + --replace '#!/usr/bin/env bash' '#!${stdenv.shell}' + + # Disabling the 'os/http/net' tests (they want files not available in + # chroot builds) + rm src/net/{listen,parse}_test.go + rm src/syscall/exec_linux_test.go + + # !!! substituteInPlace does not seems to be effective. + # The os test wants to read files in an existing path. Just don't let it be /usr/bin. + sed -i 's,/usr/bin,'"`pwd`", src/os/os_test.go + sed -i 's,/bin/pwd,'"`type -P pwd`", src/os/os_test.go + # Disable the unix socket test + sed -i '/TestShutdownUnix/areturn' src/net/net_test.go + # Disable the hostname test + sed -i '/TestHostname/areturn' src/os/os_test.go + # ParseInLocation fails the test + sed -i '/TestParseInSydney/areturn' src/time/format_test.go + # Remove the api check as it never worked + sed -i '/src\/cmd\/api\/run.go/ireturn nil' src/cmd/dist/test.go + # Remove the coverage test as we have removed this utility + sed -i '/TestCoverageWithCgo/areturn' src/cmd/go/go_test.go + # Remove the timezone naming test + sed -i '/TestLoadFixed/areturn' src/time/time_test.go + # Remove disable setgid test + sed -i '/TestRespectSetgidDir/areturn' src/cmd/go/internal/work/build_test.go + # Remove cert tests that conflict with NixOS's cert resolution + sed -i '/TestEnvVars/areturn' src/crypto/x509/root_unix_test.go + # TestWritevError hangs sometimes + sed -i '/TestWritevError/areturn' src/net/writev_test.go + # TestVariousDeadlines fails sometimes + sed -i '/TestVariousDeadlines/areturn' src/net/timeout_test.go + + sed -i 's,/etc/protocols,${iana-etc}/etc/protocols,' src/net/lookup_unix.go + sed -i 's,/etc/services,${iana-etc}/etc/services,' src/net/port_unix.go + + # Disable cgo lookup tests not works, they depend on resolver + rm src/net/cgo_unix_test.go + + '' + optionalString stdenv.isLinux '' + sed -i 's,/usr/share/zoneinfo/,${tzdata}/share/zoneinfo/,' src/time/zoneinfo_unix.go + '' + optionalString stdenv.isAarch32 '' + sed -i '/TestCurrent/areturn' src/os/user/user_test.go + echo '#!${stdenv.shell}' > misc/cgo/testplugin/test.bash + '' + optionalString stdenv.isDarwin '' + substituteInPlace src/race.bash --replace \ + "sysctl machdep.cpu.extfeatures | grep -qv EM64T" true + sed -i 's,strings.Contains(.*sysctl.*,true {,' src/cmd/dist/util.go + sed -i 's,"/etc","'"$TMPDIR"'",' src/os/os_test.go + sed -i 's,/_go_os_test,'"$TMPDIR"'/_go_os_test,' src/os/path_test.go + + sed -i '/TestChdirAndGetwd/areturn' src/os/os_test.go + sed -i '/TestCredentialNoSetGroups/areturn' src/os/exec/exec_posix_test.go + sed -i '/TestCurrent/areturn' src/os/user/user_test.go + sed -i '/TestNohup/areturn' src/os/signal/signal_test.go + sed -i '/TestRead0/areturn' src/os/os_test.go + sed -i '/TestSystemRoots/areturn' src/crypto/x509/root_darwin_test.go + + sed -i '/TestGoInstallRebuildsStalePackagesInOtherGOPATH/areturn' src/cmd/go/go_test.go + sed -i '/TestBuildDashIInstallsDependencies/areturn' src/cmd/go/go_test.go + + sed -i '/TestDisasmExtld/areturn' src/cmd/objdump/objdump_test.go + + sed -i 's/unrecognized/unknown/' src/cmd/link/internal/ld/lib.go + + touch $TMPDIR/group $TMPDIR/hosts $TMPDIR/passwd + ''; + + patches = [ + ./remove-tools-1.9.patch + ./ssl-cert-file-1.9.patch + ./remove-test-pie.patch + ./creds-test.patch + ./go-1.9-skip-flaky-19608.patch + ./go-1.9-skip-flaky-20072.patch + (fetchpatch { + name = "missing_cpuHog_in_pprof_output.diff"; + url = "https://github.com/golang/go/commit/33110e2c.diff"; + sha256 = "04vh9lflbpz9xjvymyzhd91gkxiiwwz4lhglzl3r8z0lk45p96qn"; + }) + ]; + + postPatch = optionalString stdenv.isDarwin '' + echo "substitute hardcoded dsymutil with ${llvm}/bin/llvm-dsymutil" + substituteInPlace "src/cmd/link/internal/ld/lib.go" --replace dsymutil ${llvm}/bin/llvm-dsymutil + ''; + + GOOS = if stdenv.isDarwin then "darwin" else "linux"; + GOARCH = if stdenv.isDarwin then "amd64" + else if stdenv.hostPlatform.system == "i686-linux" then "386" + else if stdenv.hostPlatform.system == "x86_64-linux" then "amd64" + else if stdenv.isAarch32 then "arm" + else if stdenv.isAarch64 then "arm64" + else throw "Unsupported system"; + GOARM = optionalString (stdenv.hostPlatform.system == "armv5tel-linux") "5"; + GO386 = 387; # from Arch: don't assume sse2 on i686 + CGO_ENABLED = 1; + GOROOT_BOOTSTRAP = "${goBootstrap}/share/go"; + # Hopefully avoids test timeouts on Hydra + GO_TEST_TIMEOUT_SCALE = 3; + + # The go build actually checks for CC=*/clang and does something different, so we don't + # just want the generic `cc` here. + CC = if stdenv.isDarwin then "clang" else "cc"; + + configurePhase = '' + mkdir -p $out/share/go/bin + export GOROOT=$out/share/go + export GOBIN=$GOROOT/bin + export PATH=$GOBIN:$PATH + ulimit -a + ''; + + postConfigure = optionalString stdenv.isDarwin '' + export PATH=${clangHack}/bin:$PATH + ''; + + installPhase = '' + cp -r . $GOROOT + ( cd $GOROOT/src && ./all.bash ) + ''; + + preFixup = '' + rm -r $out/share/go/pkg/bootstrap + ln -s $out/share/go/bin $out/bin + ''; + + setupHook = ./setup-hook.sh; + + disallowedReferences = [ go_bootstrap ]; + + meta = with stdenv.lib; { + branch = "1.10"; + homepage = http://golang.org/; + description = "The Go Programming language"; + license = licenses.bsd3; + maintainers = with maintainers; [ cstrahan orivej velovix mic92 ]; + platforms = platforms.linux ++ platforms.darwin; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/go/1.11.nix b/nixpkgs/pkgs/development/compilers/go/1.11.nix new file mode 100644 index 000000000000..1e3a63983f4a --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/go/1.11.nix @@ -0,0 +1,237 @@ +{ stdenv, fetchurl, tzdata, iana-etc, go_bootstrap, runCommand, writeScriptBin +, perl, which, pkgconfig, patch, procps, pcre, cacert, llvm, Security, Foundation +, mailcap, runtimeShell +, buildPackages, pkgsTargetTarget +}: + +let + + inherit (stdenv.lib) optionals optionalString; + + goBootstrap = runCommand "go-bootstrap" {} '' + mkdir $out + cp -rf ${buildPackages.go_bootstrap}/* $out/ + chmod -R u+w $out + find $out -name "*.c" -delete + cp -rf $out/bin/* $out/share/go/bin/ + ''; + + goarch = platform: { + "i686" = "386"; + "x86_64" = "amd64"; + "aarch64" = "arm64"; + "arm" = "arm"; + "armv5tel" = "arm"; + "armv6l" = "arm"; + "armv7l" = "arm"; + }.${platform.parsed.cpu.name} or (throw "Unsupported system"); + +in + +stdenv.mkDerivation rec { + name = "go-${version}"; + version = "1.11.6"; + + src = fetchurl { + url = "https://dl.google.com/go/go${version}.src.tar.gz"; + sha256 = "0cz1sdhxf9283p1p4jxb020pym0ncd0qlfh36r3hkv6bbm1a2vd9"; + }; + + # perl is used for testing go vet + nativeBuildInputs = [ perl which pkgconfig patch procps ]; + buildInputs = [ cacert pcre ] + ++ optionals stdenv.isLinux [ stdenv.cc.libc.out ] + ++ optionals (stdenv.hostPlatform.libc == "glibc") [ stdenv.cc.libc.static ]; + + + propagatedBuildInputs = optionals stdenv.isDarwin [ Security Foundation ]; + + hardeningDisable = [ "all" ]; + + prePatch = '' + patchShebangs ./ # replace /bin/bash + + # This source produces shell script at run time, + # and thus it is not corrected by patchShebangs. + substituteInPlace misc/cgo/testcarchive/carchive_test.go \ + --replace '#!/usr/bin/env bash' '#!${runtimeShell}' + + # Patch the mimetype database location which is missing on NixOS. + substituteInPlace src/mime/type_unix.go \ + --replace '/etc/mime.types' '${mailcap}/etc/mime.types' + + # Disabling the 'os/http/net' tests (they want files not available in + # chroot builds) + rm src/net/{listen,parse}_test.go + rm src/syscall/exec_linux_test.go + + # !!! substituteInPlace does not seems to be effective. + # The os test wants to read files in an existing path. Just don't let it be /usr/bin. + sed -i 's,/usr/bin,'"`pwd`", src/os/os_test.go + sed -i 's,/bin/pwd,'"`type -P pwd`", src/os/os_test.go + # Disable the unix socket test + sed -i '/TestShutdownUnix/areturn' src/net/net_test.go + # Disable the hostname test + sed -i '/TestHostname/areturn' src/os/os_test.go + # ParseInLocation fails the test + sed -i '/TestParseInSydney/areturn' src/time/format_test.go + # Remove the api check as it never worked + sed -i '/src\/cmd\/api\/run.go/ireturn nil' src/cmd/dist/test.go + # Remove the coverage test as we have removed this utility + sed -i '/TestCoverageWithCgo/areturn' src/cmd/go/go_test.go + # Remove the timezone naming test + sed -i '/TestLoadFixed/areturn' src/time/time_test.go + # Remove disable setgid test + sed -i '/TestRespectSetgidDir/areturn' src/cmd/go/internal/work/build_test.go + # Remove cert tests that conflict with NixOS's cert resolution + sed -i '/TestEnvVars/areturn' src/crypto/x509/root_unix_test.go + # TestWritevError hangs sometimes + sed -i '/TestWritevError/areturn' src/net/writev_test.go + # TestVariousDeadlines fails sometimes + sed -i '/TestVariousDeadlines/areturn' src/net/timeout_test.go + + sed -i 's,/etc/protocols,${iana-etc}/etc/protocols,' src/net/lookup_unix.go + sed -i 's,/etc/services,${iana-etc}/etc/services,' src/net/port_unix.go + + # Disable cgo lookup tests not works, they depend on resolver + rm src/net/cgo_unix_test.go + + '' + optionalString stdenv.isLinux '' + sed -i 's,/usr/share/zoneinfo/,${tzdata}/share/zoneinfo/,' src/time/zoneinfo_unix.go + '' + optionalString stdenv.isAarch32 '' + echo '#!${runtimeShell}' > misc/cgo/testplugin/test.bash + '' + optionalString stdenv.isDarwin '' + substituteInPlace src/race.bash --replace \ + "sysctl machdep.cpu.extfeatures | grep -qv EM64T" true + sed -i 's,strings.Contains(.*sysctl.*,true {,' src/cmd/dist/util.go + sed -i 's,"/etc","'"$TMPDIR"'",' src/os/os_test.go + sed -i 's,/_go_os_test,'"$TMPDIR"'/_go_os_test,' src/os/path_test.go + + sed -i '/TestChdirAndGetwd/areturn' src/os/os_test.go + sed -i '/TestCredentialNoSetGroups/areturn' src/os/exec/exec_posix_test.go + sed -i '/TestRead0/areturn' src/os/os_test.go + sed -i '/TestSystemRoots/areturn' src/crypto/x509/root_darwin_test.go + + sed -i '/TestGoInstallRebuildsStalePackagesInOtherGOPATH/areturn' src/cmd/go/go_test.go + sed -i '/TestBuildDashIInstallsDependencies/areturn' src/cmd/go/go_test.go + + sed -i '/TestDisasmExtld/areturn' src/cmd/objdump/objdump_test.go + + sed -i 's/unrecognized/unknown/' src/cmd/link/internal/ld/lib.go + + touch $TMPDIR/group $TMPDIR/hosts $TMPDIR/passwd + ''; + + patches = [ + ./remove-tools-1.11.patch + ./ssl-cert-file-1.12.1.patch + ./remove-test-pie.patch + ./creds-test.patch + ./go-1.9-skip-flaky-19608.patch + ./go-1.9-skip-flaky-20072.patch + ./remove-fhs-test-references.patch + ./skip-external-network-tests.patch + ./skip-nohup-tests.patch + # breaks under load: https://github.com/golang/go/issues/25628 + ./skip-test-extra-files-on-386.patch + ]; + + postPatch = optionalString stdenv.isDarwin '' + echo "substitute hardcoded dsymutil with ${llvm}/bin/llvm-dsymutil" + substituteInPlace "src/cmd/link/internal/ld/lib.go" --replace dsymutil ${llvm}/bin/llvm-dsymutil + ''; + + GOOS = stdenv.targetPlatform.parsed.kernel.name; + GOARCH = goarch stdenv.targetPlatform; + # GOHOSTOS/GOHOSTARCH must match the building system, not the host system. + # Go will nevertheless build a for host system that we will copy over in + # the install phase. + GOHOSTOS = stdenv.buildPlatform.parsed.kernel.name; + GOHOSTARCH = goarch stdenv.buildPlatform; + + # {CC,CXX}_FOR_TARGET must be only set for cross compilation case as go expect those + # to be different from CC/CXX + CC_FOR_TARGET = if (stdenv.buildPlatform != stdenv.targetPlatform) then + "${pkgsTargetTarget.stdenv.cc}/bin/${pkgsTargetTarget.stdenv.cc.targetPrefix}cc" + else + null; + CXX_FOR_TARGET = if (stdenv.buildPlatform != stdenv.targetPlatform) then + "${pkgsTargetTarget.stdenv.cc}/bin/${pkgsTargetTarget.stdenv.cc.targetPrefix}c++" + else + null; + + GOARM = toString (stdenv.lib.intersectLists [(stdenv.hostPlatform.parsed.cpu.version or "")] ["5" "6" "7"]); + GO386 = 387; # from Arch: don't assume sse2 on i686 + CGO_ENABLED = 1; + # Hopefully avoids test timeouts on Hydra + GO_TEST_TIMEOUT_SCALE = 3; + + # Indicate that we are running on build infrastructure + # Some tests assume things like home directories and users exists + GO_BUILDER_NAME = "nix"; + + GOROOT_BOOTSTRAP="${goBootstrap}/share/go"; + + postConfigure = '' + export GOCACHE=$TMPDIR/go-cache + # this is compiled into the binary + export GOROOT_FINAL=$out/share/go + + export PATH=$(pwd)/bin:$PATH + + # Independent from host/target, CC should produce code for the building system. + export CC=${buildPackages.stdenv.cc}/bin/cc + ulimit -a + ''; + + postBuild = '' + (cd src && ./make.bash) + ''; + + doCheck = stdenv.hostPlatform == stdenv.targetPlatform; + + checkPhase = '' + runHook preCheck + (cd src && ./run.bash --no-rebuild) + runHook postCheck + ''; + + preInstall = '' + rm -r pkg/{bootstrap,obj} + # Contains the wrong perl shebang when cross compiling, + # since it is not used for anything we can deleted as well. + rm src/regexp/syntax/make_perl_groups.pl + '' + (if (stdenv.buildPlatform != stdenv.hostPlatform) then '' + mv bin/*_*/* bin + rmdir bin/*_* + ${optionalString (!(GOHOSTARCH == GOARCH && GOOS == GOHOSTOS)) '' + rm -rf pkg/${GOHOSTOS}_${GOHOSTARCH} pkg/tool/${GOHOSTOS}_${GOHOSTARCH} + ''} + '' else if (stdenv.hostPlatform != stdenv.targetPlatform) then '' + rm -rf bin/*_* + ${optionalString (!(GOHOSTARCH == GOARCH && GOOS == GOHOSTOS)) '' + rm -rf pkg/${GOOS}_${GOARCH} pkg/tool/${GOOS}_${GOARCH} + ''} + '' else ""); + + installPhase = '' + runHook preInstall + mkdir -p $GOROOT_FINAL + cp -a bin pkg src lib misc api doc $GOROOT_FINAL + ln -s $GOROOT_FINAL/bin $out/bin + runHook postInstall + ''; + + setupHook = ./setup-hook.sh; + + disallowedReferences = [ goBootstrap ]; + + meta = with stdenv.lib; { + branch = "1.11"; + homepage = http://golang.org/; + description = "The Go Programming language"; + license = licenses.bsd3; + maintainers = with maintainers; [ cstrahan orivej velovix mic92 ]; + platforms = platforms.linux ++ platforms.darwin; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/go/1.12.nix b/nixpkgs/pkgs/development/compilers/go/1.12.nix new file mode 100644 index 000000000000..44304006f6b4 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/go/1.12.nix @@ -0,0 +1,242 @@ +{ stdenv, fetchurl, tzdata, iana-etc, go_bootstrap, runCommand, writeScriptBin +, perl, which, pkgconfig, patch, procps, pcre, cacert, llvm, Security, Foundation +, mailcap, runtimeShell +, buildPackages, pkgsTargetTarget +}: + +let + + inherit (stdenv.lib) optionals optionalString; + + goBootstrap = runCommand "go-bootstrap" {} '' + mkdir $out + cp -rf ${buildPackages.go_bootstrap}/* $out/ + chmod -R u+w $out + find $out -name "*.c" -delete + cp -rf $out/bin/* $out/share/go/bin/ + ''; + + goarch = platform: { + "i686" = "386"; + "x86_64" = "amd64"; + "aarch64" = "arm64"; + "arm" = "arm"; + "armv5tel" = "arm"; + "armv6l" = "arm"; + "armv7l" = "arm"; + }.${platform.parsed.cpu.name} or (throw "Unsupported system"); + +in + +stdenv.mkDerivation rec { + name = "go-${version}"; + version = "1.12.1"; + + src = fetchurl { + url = "https://dl.google.com/go/go${version}.src.tar.gz"; + sha256 = "12l12mmgqvy3nbscy7sz83qj4m6iz5a322aq9sk45f7l9ml2gq8b"; + }; + + # perl is used for testing go vet + nativeBuildInputs = [ perl which pkgconfig patch procps ]; + buildInputs = [ cacert pcre ] + ++ optionals stdenv.isLinux [ stdenv.cc.libc.out ] + ++ optionals (stdenv.hostPlatform.libc == "glibc") [ stdenv.cc.libc.static ]; + + + propagatedBuildInputs = optionals stdenv.isDarwin [ Security Foundation ]; + + hardeningDisable = [ "all" ]; + + prePatch = '' + patchShebangs ./ # replace /bin/bash + + # This source produces shell script at run time, + # and thus it is not corrected by patchShebangs. + substituteInPlace misc/cgo/testcarchive/carchive_test.go \ + --replace '#!/usr/bin/env bash' '#!${runtimeShell}' + + # Patch the mimetype database location which is missing on NixOS. + substituteInPlace src/mime/type_unix.go \ + --replace '/etc/mime.types' '${mailcap}/etc/mime.types' + + # Disabling the 'os/http/net' tests (they want files not available in + # chroot builds) + rm src/net/{listen,parse}_test.go + rm src/syscall/exec_linux_test.go + + # !!! substituteInPlace does not seems to be effective. + # The os test wants to read files in an existing path. Just don't let it be /usr/bin. + sed -i 's,/usr/bin,'"`pwd`", src/os/os_test.go + sed -i 's,/bin/pwd,'"`type -P pwd`", src/os/os_test.go + # Disable the unix socket test + sed -i '/TestShutdownUnix/areturn' src/net/net_test.go + # Disable the hostname test + sed -i '/TestHostname/areturn' src/os/os_test.go + # ParseInLocation fails the test + sed -i '/TestParseInSydney/areturn' src/time/format_test.go + # Remove the api check as it never worked + sed -i '/src\/cmd\/api\/run.go/ireturn nil' src/cmd/dist/test.go + # Remove the coverage test as we have removed this utility + sed -i '/TestCoverageWithCgo/areturn' src/cmd/go/go_test.go + # Remove the timezone naming test + sed -i '/TestLoadFixed/areturn' src/time/time_test.go + # Remove disable setgid test + sed -i '/TestRespectSetgidDir/areturn' src/cmd/go/internal/work/build_test.go + # Remove cert tests that conflict with NixOS's cert resolution + sed -i '/TestEnvVars/areturn' src/crypto/x509/root_unix_test.go + # TestWritevError hangs sometimes + sed -i '/TestWritevError/areturn' src/net/writev_test.go + # TestVariousDeadlines fails sometimes + sed -i '/TestVariousDeadlines/areturn' src/net/timeout_test.go + + sed -i 's,/etc/protocols,${iana-etc}/etc/protocols,' src/net/lookup_unix.go + sed -i 's,/etc/services,${iana-etc}/etc/services,' src/net/port_unix.go + + # Disable cgo lookup tests not works, they depend on resolver + rm src/net/cgo_unix_test.go + + '' + optionalString stdenv.isLinux '' + sed -i 's,/usr/share/zoneinfo/,${tzdata}/share/zoneinfo/,' src/time/zoneinfo_unix.go + '' + optionalString stdenv.isAarch32 '' + echo '#!${runtimeShell}' > misc/cgo/testplugin/test.bash + '' + optionalString stdenv.isDarwin '' + substituteInPlace src/race.bash --replace \ + "sysctl machdep.cpu.extfeatures | grep -qv EM64T" true + sed -i 's,strings.Contains(.*sysctl.*,true {,' src/cmd/dist/util.go + sed -i 's,"/etc","'"$TMPDIR"'",' src/os/os_test.go + sed -i 's,/_go_os_test,'"$TMPDIR"'/_go_os_test,' src/os/path_test.go + + sed -i '/TestChdirAndGetwd/areturn' src/os/os_test.go + sed -i '/TestCredentialNoSetGroups/areturn' src/os/exec/exec_posix_test.go + sed -i '/TestRead0/areturn' src/os/os_test.go + sed -i '/TestSystemRoots/areturn' src/crypto/x509/root_darwin_test.go + + sed -i '/TestGoInstallRebuildsStalePackagesInOtherGOPATH/areturn' src/cmd/go/go_test.go + sed -i '/TestBuildDashIInstallsDependencies/areturn' src/cmd/go/go_test.go + + sed -i '/TestDisasmExtld/areturn' src/cmd/objdump/objdump_test.go + + sed -i 's/unrecognized/unknown/' src/cmd/link/internal/ld/lib.go + + # TestCurrent fails because Current is not implemented on Darwin + sed -i 's/TestCurrent/testCurrent/g' src/os/user/user_test.go + sed -i 's/TestLookup/testLookup/g' src/os/user/user_test.go + + touch $TMPDIR/group $TMPDIR/hosts $TMPDIR/passwd + ''; + + patches = [ + ./remove-tools-1.11.patch + ./ssl-cert-file-1.12.1.patch + ./remove-test-pie.patch + ./creds-test.patch + ./go-1.9-skip-flaky-19608.patch + ./go-1.9-skip-flaky-20072.patch + ./skip-external-network-tests.patch + ./skip-nohup-tests.patch + # breaks under load: https://github.com/golang/go/issues/25628 + ./skip-test-extra-files-on-386.patch + ]; + + postPatch = '' + find . -name '*.orig' -exec rm {} ';' + '' + optionalString stdenv.isDarwin '' + echo "substitute hardcoded dsymutil with ${llvm}/bin/llvm-dsymutil" + substituteInPlace "src/cmd/link/internal/ld/lib.go" --replace dsymutil ${llvm}/bin/llvm-dsymutil + ''; + + GOOS = stdenv.targetPlatform.parsed.kernel.name; + GOARCH = goarch stdenv.targetPlatform; + # GOHOSTOS/GOHOSTARCH must match the building system, not the host system. + # Go will nevertheless build a for host system that we will copy over in + # the install phase. + GOHOSTOS = stdenv.buildPlatform.parsed.kernel.name; + GOHOSTARCH = goarch stdenv.buildPlatform; + + # {CC,CXX}_FOR_TARGET must be only set for cross compilation case as go expect those + # to be different from CC/CXX + CC_FOR_TARGET = if (stdenv.buildPlatform != stdenv.targetPlatform) then + "${pkgsTargetTarget.stdenv.cc}/bin/${pkgsTargetTarget.stdenv.cc.targetPrefix}cc" + else + null; + CXX_FOR_TARGET = if (stdenv.buildPlatform != stdenv.targetPlatform) then + "${pkgsTargetTarget.stdenv.cc}/bin/${pkgsTargetTarget.stdenv.cc.targetPrefix}c++" + else + null; + + GOARM = toString (stdenv.lib.intersectLists [(stdenv.hostPlatform.parsed.cpu.version or "")] ["5" "6" "7"]); + GO386 = 387; # from Arch: don't assume sse2 on i686 + CGO_ENABLED = 1; + # Hopefully avoids test timeouts on Hydra + GO_TEST_TIMEOUT_SCALE = 3; + + # Indicate that we are running on build infrastructure + # Some tests assume things like home directories and users exists + GO_BUILDER_NAME = "nix"; + + GOROOT_BOOTSTRAP="${goBootstrap}/share/go"; + + postConfigure = '' + export GOCACHE=$TMPDIR/go-cache + # this is compiled into the binary + export GOROOT_FINAL=$out/share/go + + export PATH=$(pwd)/bin:$PATH + + # Independent from host/target, CC should produce code for the building system. + export CC=${buildPackages.stdenv.cc}/bin/cc + ulimit -a + ''; + + postBuild = '' + (cd src && ./make.bash) + ''; + + doCheck = stdenv.hostPlatform == stdenv.targetPlatform; + + checkPhase = '' + runHook preCheck + (cd src && HOME=$TMPDIR GOCACHE=$TMPDIR/go-cache ./run.bash --no-rebuild) + runHook postCheck + ''; + + preInstall = '' + rm -r pkg/{bootstrap,obj} + # Contains the wrong perl shebang when cross compiling, + # since it is not used for anything we can deleted as well. + rm src/regexp/syntax/make_perl_groups.pl + '' + (if (stdenv.buildPlatform != stdenv.hostPlatform) then '' + mv bin/*_*/* bin + rmdir bin/*_* + ${optionalString (!(GOHOSTARCH == GOARCH && GOOS == GOHOSTOS)) '' + rm -rf pkg/${GOHOSTOS}_${GOHOSTARCH} pkg/tool/${GOHOSTOS}_${GOHOSTARCH} + ''} + '' else if (stdenv.hostPlatform != stdenv.targetPlatform) then '' + rm -rf bin/*_* + ${optionalString (!(GOHOSTARCH == GOARCH && GOOS == GOHOSTOS)) '' + rm -rf pkg/${GOOS}_${GOARCH} pkg/tool/${GOOS}_${GOARCH} + ''} + '' else ""); + + installPhase = '' + runHook preInstall + mkdir -p $GOROOT_FINAL + cp -a bin pkg src lib misc api doc $GOROOT_FINAL + ln -s $GOROOT_FINAL/bin $out/bin + runHook postInstall + ''; + + setupHook = ./setup-hook.sh; + + disallowedReferences = [ goBootstrap ]; + + meta = with stdenv.lib; { + branch = "1.12"; + homepage = http://golang.org/; + description = "The Go Programming language"; + license = licenses.bsd3; + maintainers = with maintainers; [ cstrahan orivej velovix mic92 ]; + platforms = platforms.linux ++ platforms.darwin; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/go/1.4.nix b/nixpkgs/pkgs/development/compilers/go/1.4.nix new file mode 100644 index 000000000000..95312f9e1ead --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/go/1.4.nix @@ -0,0 +1,162 @@ +{ stdenv, lib, fetchurl, fetchpatch, tzdata, iana-etc, libcCross +, pkgconfig +, pcre +, Security }: + +let + libc = if stdenv ? "cross" then libcCross else stdenv.cc.libc; +in + +stdenv.mkDerivation rec { + name = "go-${version}"; + version = "1.4-bootstrap-20161024"; + revision = "79d85a4965ea7c46db483314c3981751909d7883"; + + src = fetchurl { + url = "https://github.com/golang/go/archive/${revision}.tar.gz"; + sha256 = "1ljbllwjysya323xxm9s792z8y9jdw19n8sj3mlc8picjclrx5xf"; + }; + + nativeBuildInputs = [ pkgconfig ]; + buildInputs = [ pcre ]; + propagatedBuildInputs = lib.optional stdenv.isDarwin Security; + + hardeningDisable = [ "all" ]; + + # The tests try to do stuff with 127.0.0.1 and localhost + __darwinAllowLocalNetworking = true; + + # I'm not sure what go wants from its 'src', but the go installation manual + # describes an installation keeping the src. + preUnpack = '' + mkdir -p $out/share + cd $out/share + ''; + + prePatch = '' + # Ensure that the source directory is named go + cd .. + if [ ! -d go ]; then + mv * go + fi + + cd go + patchShebangs ./ # replace /bin/bash + + # Disabling the 'os/http/net' tests (they want files not available in + # chroot builds) + rm src/net/{multicast_test.go,parse_test.go,port_test.go} + # !!! substituteInPlace does not seems to be effective. + # The os test wants to read files in an existing path. Just don't let it be /usr/bin. + sed -i 's,/usr/bin,'"`pwd`", src/os/os_test.go + sed -i 's,/bin/pwd,'"`type -P pwd`", src/os/os_test.go + # Disable the unix socket test + sed -i '/TestShutdownUnix/areturn' src/net/net_test.go + # Disable network timeout test + sed -i '/TestDialTimeout/areturn' src/net/dial_test.go + # Disable the hostname test + sed -i '/TestHostname/areturn' src/os/os_test.go + # ParseInLocation fails the test + sed -i '/TestParseInSydney/areturn' src/time/format_test.go + + sed -i 's,/etc/protocols,${iana-etc}/etc/protocols,' src/net/lookup_unix.go + '' + lib.optionalString stdenv.isLinux '' + sed -i 's,/usr/share/zoneinfo/,${tzdata}/share/zoneinfo/,' src/time/zoneinfo_unix.go + + # Find the loader dynamically + LOADER="$(find ${lib.getLib libc}/lib -name ld-linux\* | head -n 1)" + + # Replace references to the loader + find src/cmd -name asm.c -exec sed -i "s,/lib/ld-linux.*\.so\.[0-9],$LOADER," {} \; + '' + lib.optionalString stdenv.isDarwin '' + sed -i 's,"/etc","'"$TMPDIR"'",' src/os/os_test.go + sed -i 's,/_go_os_test,'"$TMPDIR"'/_go_os_test,' src/os/path_test.go + sed -i '/TestCgoLookupIP/areturn' src/net/cgo_unix_test.go + sed -i '/TestChdirAndGetwd/areturn' src/os/os_test.go + sed -i '/TestDialDualStackLocalhost/areturn' src/net/dial_test.go + sed -i '/TestRead0/areturn' src/os/os_test.go + sed -i '/TestSystemRoots/areturn' src/crypto/x509/root_darwin_test.go + + # fails when running inside tmux + sed -i '/TestNohup/areturn' src/os/signal/signal_test.go + + # unix socket tests fail on darwin + sed -i '/TestConnAndListener/areturn' src/net/conn_test.go + sed -i '/TestPacketConn/areturn' src/net/conn_test.go + sed -i '/TestPacketConn/areturn' src/net/packetconn_test.go + sed -i '/TestConnAndPacketConn/areturn' src/net/packetconn_test.go + sed -i '/TestUnixListenerSpecificMethods/areturn' src/net/packetconn_test.go + sed -i '/TestUnixConnSpecificMethods/areturn' src/net/packetconn_test.go + sed -i '/TestUnixListenerSpecificMethods/areturn' src/net/protoconn_test.go + sed -i '/TestUnixConnSpecificMethods/areturn' src/net/protoconn_test.go + sed -i '/TestStreamConnServer/areturn' src/net/server_test.go + sed -i '/TestReadUnixgramWithUnnamedSocket/areturn' src/net/unix_test.go + sed -i '/TestReadUnixgramWithZeroBytesBuffer/areturn' src/net/unix_test.go + sed -i '/TestUnixgramWrite/areturn' src/net/unix_test.go + sed -i '/TestUnixConnLocalAndRemoteNames/areturn' src/net/unix_test.go + sed -i '/TestUnixgramConnLocalAndRemoteNames/areturn' src/net/unix_test.go + sed -i '/TestWithSimulated/areturn' src/log/syslog/syslog_test.go + sed -i '/TestFlap/areturn' src/log/syslog/syslog_test.go + sed -i '/TestNew/areturn' src/log/syslog/syslog_test.go + sed -i '/TestNewLogger/areturn' src/log/syslog/syslog_test.go + sed -i '/TestDial/areturn' src/log/syslog/syslog_test.go + sed -i '/TestWrite/areturn' src/log/syslog/syslog_test.go + sed -i '/TestConcurrentWrite/areturn' src/log/syslog/syslog_test.go + sed -i '/TestConcurrentReconnect/areturn' src/log/syslog/syslog_test.go + + # remove IP resolving tests, on darwin they can find fe80::1%lo while expecting ::1 + sed -i '/TestResolveIPAddr/areturn' src/net/ipraw_test.go + sed -i '/TestResolveTCPAddr/areturn' src/net/tcp_test.go + sed -i '/TestResolveUDPAddr/areturn' src/net/udp_test.go + + sed -i '/TestCgoExternalThreadSIGPROF/areturn' src/runtime/crash_cgo_test.go + + touch $TMPDIR/group $TMPDIR/hosts $TMPDIR/passwd + ''; + + patches = [ + ./remove-tools-1.4.patch + ./creds-test-1.4.patch + + # This test checks for the wrong thing with recent tzdata. It's been fixed in master but the patch + # actually works on old versions too. + (fetchpatch { + url = "https://github.com/golang/go/commit/91563ced5897faf729a34be7081568efcfedda31.patch"; + sha256 = "1ny5l3f8a9dpjjrnjnsplb66308a0x13sa0wwr4j6yrkc8j4qxqi"; + }) + ]; + + GOOS = if stdenv.isDarwin then "darwin" else "linux"; + GOARCH = if stdenv.isDarwin then "amd64" + else if stdenv.hostPlatform.system == "i686-linux" then "386" + else if stdenv.hostPlatform.system == "x86_64-linux" then "amd64" + else if stdenv.isAarch32 then "arm" + else throw "Unsupported system"; + GOARM = stdenv.lib.optionalString (stdenv.hostPlatform.system == "armv5tel-linux") "5"; + GO386 = 387; # from Arch: don't assume sse2 on i686 + CGO_ENABLED = 0; + + # The go build actually checks for CC=*/clang and does something different, so we don't + # just want the generic `cc` here. + CC = if stdenv.isDarwin then "clang" else "cc"; + + installPhase = '' + mkdir -p "$out/bin" + export GOROOT="$(pwd)/" + export GOBIN="$out/bin" + export PATH="$GOBIN:$PATH" + cd ./src + ./all.bash + ''; + + setupHook = ./setup-hook.sh; + + meta = with stdenv.lib; { + branch = "1.4"; + homepage = http://golang.org/; + description = "The Go Programming language"; + license = licenses.bsd3; + maintainers = with maintainers; [ cstrahan ]; + platforms = platforms.linux ++ platforms.darwin; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/go/creds-test-1.4.patch b/nixpkgs/pkgs/development/compilers/go/creds-test-1.4.patch new file mode 100644 index 000000000000..98cec532dcca --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/go/creds-test-1.4.patch @@ -0,0 +1,17 @@ +diff --git a/go-go1.4.3/src/syscall/creds_test.go b/go-go1.4.3/src/syscall/creds_test.go +index b1894c6..b2d6b4e 100644 +--- a/src/syscall/creds_test.go ++++ b/src/syscall/creds_test.go +@@ -56,9 +56,10 @@ func TestSCMCredentials(t *testing.T) { + ucred.Gid = 0 + oob := syscall.UnixCredentials(&ucred) + _, _, err := cli.(*net.UnixConn).WriteMsgUnix(nil, oob, nil) +- if err.(*net.OpError).Err != syscall.EPERM { +- t.Fatalf("WriteMsgUnix failed with %v, want EPERM", err) ++ if err.(*net.OpError).Err != syscall.EPERM && err.(*net.OpError).Err != syscall.EINVAL { ++ t.Fatalf("WriteMsgUnix failed with %v, want EPERM or EINVAL", err) + } ++ + } + + ucred.Pid = int32(os.Getpid()) diff --git a/nixpkgs/pkgs/development/compilers/go/creds-test.patch b/nixpkgs/pkgs/development/compilers/go/creds-test.patch new file mode 100644 index 000000000000..6a18e6cc42e8 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/go/creds-test.patch @@ -0,0 +1,13 @@ +--- source.org/src/syscall/creds_test.go 1970-01-01 01:00:01.000000000 +0100 ++++ source/src/syscall/creds_test.go 2018-02-22 10:43:47.223615358 +0000 +@@ -76,8 +76,8 @@ + if sys, ok := err.(*os.SyscallError); ok { + err = sys.Err + } +- if err != syscall.EPERM { +- t.Fatalf("WriteMsgUnix failed with %v, want EPERM", err) ++ if err != syscall.EPERM && err != syscall.EINVAL { ++ t.Fatalf("WriteMsgUnix failed with %v, want EPERM or EINVAL", err) + } + } + diff --git a/nixpkgs/pkgs/development/compilers/go/go-1.9-skip-flaky-19608.patch b/nixpkgs/pkgs/development/compilers/go/go-1.9-skip-flaky-19608.patch new file mode 100644 index 000000000000..a4d9f0674791 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/go/go-1.9-skip-flaky-19608.patch @@ -0,0 +1,12 @@ +diff --git a/src/net/http/serve_test.go b/src/net/http/serve_test.go +index 7137599..43cca2e 100644 +--- a/src/net/http/serve_test.go ++++ b/src/net/http/serve_test.go +@@ -5361,6 +5361,7 @@ func testServerKeepAlivesEnabled(t *testing.T, h2 bool) { + // the server's doing its 1-byte background read between requests, + // waiting for the connection to maybe close. + func TestServerCancelsReadTimeoutWhenIdle(t *testing.T) { ++ testenv.SkipFlaky(t, 19608) + setParallel(t) + defer afterTest(t) + const timeout = 250 * time.Millisecond diff --git a/nixpkgs/pkgs/development/compilers/go/go-1.9-skip-flaky-20072.patch b/nixpkgs/pkgs/development/compilers/go/go-1.9-skip-flaky-20072.patch new file mode 100644 index 000000000000..13db40ababc3 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/go/go-1.9-skip-flaky-20072.patch @@ -0,0 +1,20 @@ +diff --git a/src/sync/waitgroup_test.go b/src/sync/waitgroup_test.go +index e3e3096..f80d1e2 100644 +--- a/src/sync/waitgroup_test.go ++++ b/src/sync/waitgroup_test.go +@@ -6,6 +6,7 @@ package sync_test + + import ( + "internal/race" ++ "internal/testenv" + "runtime" + . "sync" + "sync/atomic" +@@ -73,6 +74,7 @@ func TestWaitGroupMisuse2(t *testing.T) { + if runtime.NumCPU() <= 4 { + t.Skip("NumCPU<=4, skipping: this test requires parallelism") + } ++ testenv.SkipFlaky(t, 20072) + defer func() { + err := recover() + if err != "sync: negative WaitGroup counter" && diff --git a/nixpkgs/pkgs/development/compilers/go/remove-fhs-test-references.patch b/nixpkgs/pkgs/development/compilers/go/remove-fhs-test-references.patch new file mode 100644 index 000000000000..1ea7f85d5290 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/go/remove-fhs-test-references.patch @@ -0,0 +1,13 @@ +diff --git a/src/cmd/vendor/golang.org/x/sys/unix/syscall_unix_test.go b/src/cmd/vendor/golang.org/x/sys/unix/syscall_unix_test.go +index d694990..87fa259 100644 +--- a/src/cmd/vendor/golang.org/x/sys/unix/syscall_unix_test.go ++++ b/src/cmd/vendor/golang.org/x/sys/unix/syscall_unix_test.go +@@ -452,7 +452,7 @@ func TestGetwd(t *testing.T) { + defer fd.Close() + // These are chosen carefully not to be symlinks on a Mac + // (unlike, say, /var, /etc) +- dirs := []string{"/", "/usr/bin"} ++ dirs := []string{"/"} + switch runtime.GOOS { + case "android": + dirs = []string{"/", "/system/bin"} diff --git a/nixpkgs/pkgs/development/compilers/go/remove-test-pie.patch b/nixpkgs/pkgs/development/compilers/go/remove-test-pie.patch new file mode 100644 index 000000000000..fb8e116af76f --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/go/remove-test-pie.patch @@ -0,0 +1,24 @@ +--- source.org/src/cmd/dist/test.go 2018-02-22 10:40:40.089632339 +0000 ++++ source/src/cmd/dist/test.go 2018-02-22 10:56:53.075193788 +0000 +@@ -526,21 +526,6 @@ + }) + } + +- // Test internal linking of PIE binaries where it is supported. +- if goos == "linux" && goarch == "amd64" && !isAlpineLinux() { +- // Issue 18243: We don't have a way to set the default +- // dynamic linker used in internal linking mode. So +- // this test is skipped on Alpine. +- t.tests = append(t.tests, distTest{ +- name: "pie_internal", +- heading: "internal linking of -buildmode=pie", +- fn: func(dt *distTest) error { +- t.addCmd(dt, "src", t.goTest(), "reflect", "-buildmode=pie", "-ldflags=-linkmode=internal", t.timeout(60)) +- return nil +- }, +- }) +- } +- + // sync tests + t.tests = append(t.tests, distTest{ + name: "sync_cpu", diff --git a/nixpkgs/pkgs/development/compilers/go/remove-tools-1.11.patch b/nixpkgs/pkgs/development/compilers/go/remove-tools-1.11.patch new file mode 100644 index 000000000000..cff35999a832 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/go/remove-tools-1.11.patch @@ -0,0 +1,35 @@ +diff --git a/src/go/build/build.go b/src/go/build/build.go +index b68a712..b60bf19 100644 +--- a/src/go/build/build.go ++++ b/src/go/build/build.go +@@ -1708,7 +1708,7 @@ func init() { + } + + // ToolDir is the directory containing build tools. +-var ToolDir = getToolDir() ++var ToolDir = runtime.GOTOOLDIR() + + // IsLocalImport reports whether the import path is + // a local import path, like ".", "..", "./foo", or "../foo". +diff --git a/src/runtime/extern.go b/src/runtime/extern.go +index 7171b13..18a942c 100644 +--- a/src/runtime/extern.go ++++ b/src/runtime/extern.go +@@ -229,6 +229,17 @@ func GOROOT() string { + return sys.DefaultGoroot + } + ++// GOTOOLDIR returns the root of the Go tree. ++// It uses the GOTOOLDIR environment variable, if set, ++// or else the root used during the Go build. ++func GOTOOLDIR() string { ++ s := gogetenv("GOTOOLDIR") ++ if s != "" { ++ return s ++ } ++ return GOROOT() + "/pkg/tool/" + GOOS + "_" + GOARCH ++} ++ + // Version returns the Go tree's version string. + // It is either the commit hash and date at the time of the build or, + // when possible, a release tag like "go1.3". diff --git a/nixpkgs/pkgs/development/compilers/go/remove-tools-1.4.patch b/nixpkgs/pkgs/development/compilers/go/remove-tools-1.4.patch new file mode 100644 index 000000000000..807ab8e089c1 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/go/remove-tools-1.4.patch @@ -0,0 +1,81 @@ +diff --git a/misc/makerelease/makerelease.go b/misc/makerelease/makerelease.go +index 3b511b1..a46ebd8 100644 +--- a/misc/makerelease/makerelease.go ++++ b/misc/makerelease/makerelease.go +@@ -65,9 +65,6 @@ const ( + // These must be the command that cmd/go knows to install to $GOROOT/bin + // or $GOROOT/pkg/tool. + var toolPaths = []string{ +- "golang.org/x/tools/cmd/cover", +- "golang.org/x/tools/cmd/godoc", +- "golang.org/x/tools/cmd/vet", + } + + var preBuildCleanFiles = []string{ +diff --git a/src/cmd/dist/build.c b/src/cmd/dist/build.c +index b6c61b4..2006bc2 100644 +--- a/src/cmd/dist/build.c ++++ b/src/cmd/dist/build.c +@@ -210,7 +210,9 @@ init(void) + workdir = xworkdir(); + xatexit(rmworkdir); + +- bpathf(&b, "%s/pkg/tool/%s_%s", goroot, gohostos, gohostarch); ++ xgetenv(&b, "GOTOOLDIR"); ++ if (b.len == 0) ++ bpathf(&b, "%s/pkg/tool/%s_%s", goroot, gohostos, gohostarch); + tooldir = btake(&b); + + bfree(&b); +diff --git a/src/cmd/go/pkg.go b/src/cmd/go/pkg.go +index b71feb7..8468ea8 100644 +--- a/src/cmd/go/pkg.go ++++ b/src/cmd/go/pkg.go +@@ -401,9 +401,9 @@ var goTools = map[string]targetDir{ + "cmd/pack": toTool, + "cmd/pprof": toTool, + "cmd/yacc": toTool, +- "golang.org/x/tools/cmd/cover": toTool, +- "golang.org/x/tools/cmd/godoc": toBin, +- "golang.org/x/tools/cmd/vet": toTool, ++ "nixos.org/x/tools/cmd/cover": toTool, ++ "nixos.org/x/tools/cmd/godoc": toBin, ++ "nixos.org/x/tools/cmd/vet": toTool, + "code.google.com/p/go.tools/cmd/cover": stalePath, + "code.google.com/p/go.tools/cmd/godoc": stalePath, + "code.google.com/p/go.tools/cmd/vet": stalePath, +diff --git a/src/go/build/build.go b/src/go/build/build.go +index 311ecb0..f151d8f 100644 +--- a/src/go/build/build.go ++++ b/src/go/build/build.go +@@ -1367,7 +1367,7 @@ func init() { + } + + // ToolDir is the directory containing build tools. +-var ToolDir = filepath.Join(runtime.GOROOT(), "pkg/tool/"+runtime.GOOS+"_"+runtime.GOARCH) ++var ToolDir = runtime.GOTOOLDIR() + + // IsLocalImport reports whether the import path is + // a local import path, like ".", "..", "./foo", or "../foo". +diff --git a/src/runtime/extern.go b/src/runtime/extern.go +index 6cc5df8..9a9a964 100644 +--- a/src/runtime/extern.go ++++ b/src/runtime/extern.go +@@ -152,6 +152,17 @@ func GOROOT() string { + return defaultGoroot + } + ++// GOTOOLDIR returns the root of the Go tree. ++// It uses the GOTOOLDIR environment variable, if set, ++// or else the root used during the Go build. ++func GOTOOLDIR() string { ++ s := gogetenv("GOTOOLDIR") ++ if s != "" { ++ return s ++ } ++ return GOROOT() + "/pkg/tool/" + GOOS + "_" + GOARCH ++} ++ + // Version returns the Go tree's version string. + // It is either the commit hash and date at the time of the build or, + // when possible, a release tag like "go1.3". diff --git a/nixpkgs/pkgs/development/compilers/go/remove-tools-1.9.patch b/nixpkgs/pkgs/development/compilers/go/remove-tools-1.9.patch new file mode 100644 index 000000000000..e76ed61693a8 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/go/remove-tools-1.9.patch @@ -0,0 +1,35 @@ +diff --git a/src/go/build/build.go b/src/go/build/build.go +index d8163d0172..dd80a70473 100644 +--- a/src/go/build/build.go ++++ b/src/go/build/build.go +@@ -1592,7 +1592,7 @@ func init() { + } + + // ToolDir is the directory containing build tools. +-var ToolDir = filepath.Join(runtime.GOROOT(), "pkg/tool/"+runtime.GOOS+"_"+runtime.GOARCH) ++var ToolDir = runtime.GOTOOLDIR() + + // IsLocalImport reports whether the import path is + // a local import path, like ".", "..", "./foo", or "../foo". +diff --git a/src/runtime/extern.go b/src/runtime/extern.go +index 6e6c674d96..e9f62f96dc 100644 +--- a/src/runtime/extern.go ++++ b/src/runtime/extern.go +@@ -223,6 +223,17 @@ func GOROOT() string { + return sys.DefaultGoroot + } + ++// GOTOOLDIR returns the root of the Go tree. ++// It uses the GOTOOLDIR environment variable, if set, ++// or else the root used during the Go build. ++func GOTOOLDIR() string { ++ s := gogetenv("GOTOOLDIR") ++ if s != "" { ++ return s ++ } ++ return GOROOT() + "/pkg/tool/" + GOOS + "_" + GOARCH ++} ++ + // Version returns the Go tree's version string. + // It is either the commit hash and date at the time of the build or, + // when possible, a release tag like "go1.3". diff --git a/nixpkgs/pkgs/development/compilers/go/setup-hook.sh b/nixpkgs/pkgs/development/compilers/go/setup-hook.sh new file mode 100644 index 000000000000..7dce15eeb102 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/go/setup-hook.sh @@ -0,0 +1,5 @@ +addToGoPath() { + addToSearchPath GOPATH $1/share/go +} + +addEnvHooks "$targetOffset" addToGoPath diff --git a/nixpkgs/pkgs/development/compilers/go/skip-external-network-tests.patch b/nixpkgs/pkgs/development/compilers/go/skip-external-network-tests.patch new file mode 100644 index 000000000000..5791b213cb59 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/go/skip-external-network-tests.patch @@ -0,0 +1,26 @@ +diff --git a/src/cmd/go/go_test.go b/src/cmd/go/go_test.go +index 85cae90..94b4edd 100644 +--- a/src/cmd/go/go_test.go ++++ b/src/cmd/go/go_test.go +@@ -4946,6 +4946,8 @@ func TestBuildmodePIE(t *testing.T) { + } + + func TestExecBuildX(t *testing.T) { ++ t.Skipf("skipping, test requires networking") ++ + tooSlow(t) + if !canCgo { + t.Skip("skipping because cgo not enabled") +diff --git a/src/net/dial_test.go b/src/net/dial_test.go +index 00a84d1..27f9ec9 100644 +--- a/src/net/dial_test.go ++++ b/src/net/dial_test.go +@@ -968,6 +968,8 @@ func TestDialerControl(t *testing.T) { + // mustHaveExternalNetwork is like testenv.MustHaveExternalNetwork + // except that it won't skip testing on non-iOS builders. + func mustHaveExternalNetwork(t *testing.T) { ++ t.Skipf("Nix sandbox does not have networking") ++ + t.Helper() + ios := runtime.GOOS == "darwin" && (runtime.GOARCH == "arm" || runtime.GOARCH == "arm64") + if testenv.Builder() == "" || ios { diff --git a/nixpkgs/pkgs/development/compilers/go/skip-nohup-tests.patch b/nixpkgs/pkgs/development/compilers/go/skip-nohup-tests.patch new file mode 100644 index 000000000000..1da07407d049 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/go/skip-nohup-tests.patch @@ -0,0 +1,22 @@ +diff --git a/src/os/signal/signal_test.go b/src/os/signal/signal_test.go +index 3d79c7a..6e0f7b4 100644 +--- a/src/os/signal/signal_test.go ++++ b/src/os/signal/signal_test.go +@@ -217,6 +217,8 @@ var checkSighupIgnored = flag.Bool("check_sighup_ignored", false, "if true, Test + + // Test that Ignored(SIGHUP) correctly detects whether it is being run under nohup. + func TestDetectNohup(t *testing.T) { ++ t.Skip("Fails in nix build environment") ++ + if *checkSighupIgnored { + if !Ignored(syscall.SIGHUP) { + t.Fatal("SIGHUP is not ignored.") +@@ -306,6 +308,8 @@ func TestStop(t *testing.T) { + // Test that when run under nohup, an uncaught SIGHUP does not kill the program, + // but a + func TestNohup(t *testing.T) { ++ t.Skip("Fails in nix build environment") ++ + // Ugly: ask for SIGHUP so that child will not have no-hup set + // even if test is running under nohup environment. + // We have no intention of reading from c. diff --git a/nixpkgs/pkgs/development/compilers/go/skip-test-extra-files-on-386.patch b/nixpkgs/pkgs/development/compilers/go/skip-test-extra-files-on-386.patch new file mode 100644 index 000000000000..afe5aea3d916 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/go/skip-test-extra-files-on-386.patch @@ -0,0 +1,15 @@ +diff --git a/src/os/exec/exec_test.go b/src/os/exec/exec_test.go +index 558345ff63..22129bf022 100644 +--- a/src/os/exec/exec_test.go ++++ b/src/os/exec/exec_test.go +@@ -593,6 +593,10 @@ func TestExtraFiles(t *testing.T) { + t.Skipf("skipping test on %q", runtime.GOOS) + } + ++ if runtime.GOOS == "linux" && runtime.GOARCH == "386" { ++ t.Skipf("skipping test on %q %q", runtime.GOARCH, runtime.GOOS) ++ } ++ + // Ensure that file descriptors have not already been leaked into + // our environment. + if !testedAlreadyLeaked { diff --git a/nixpkgs/pkgs/development/compilers/go/ssl-cert-file-1.12.1.patch b/nixpkgs/pkgs/development/compilers/go/ssl-cert-file-1.12.1.patch new file mode 100644 index 000000000000..aa3116d76c12 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/go/ssl-cert-file-1.12.1.patch @@ -0,0 +1,59 @@ +diff -Naur a/src/crypto/x509/root_cgo_darwin.go b/src/crypto/x509/root_cgo_darwin.go +--- a/src/crypto/x509/root_cgo_darwin.go 2019-03-15 11:33:55.920232337 -0700 ++++ b/src/crypto/x509/root_cgo_darwin.go 2019-03-15 11:34:53.323180897 -0700 +@@ -270,11 +270,20 @@ + import "C" + import ( + "errors" ++ "io/ioutil" ++ "os" + "unsafe" + ) + + func loadSystemRoots() (*CertPool, error) { + roots := NewCertPool() ++ if file := os.Getenv("NIX_SSL_CERT_FILE"); file != "" { ++ data, err := ioutil.ReadFile(file) ++ if err == nil { ++ roots.AppendCertsFromPEM(data) ++ return roots, nil ++ } ++ } + + var data C.CFDataRef = 0 + var untrustedData C.CFDataRef = 0 +diff -Naur a/src/crypto/x509/root_darwin.go b/src/crypto/x509/root_darwin.go +--- a/src/crypto/x509/root_darwin.go 2019-03-15 11:33:55.920232337 -0700 ++++ b/src/crypto/x509/root_darwin.go 2019-03-15 11:36:21.205123541 -0700 +@@ -92,6 +92,14 @@ + verifyCh = make(chan rootCandidate) + ) + ++ if file := os.Getenv("NIX_SSL_CERT_FILE"); file != "" { ++ data, err := ioutil.ReadFile(file) ++ if err == nil { ++ roots.AppendCertsFromPEM(data) ++ return roots, nil ++ } ++ } ++ + // Using 4 goroutines to pipe into verify-cert seems to be + // about the best we can do. The verify-cert binary seems to + // just RPC to another server with coarse locking anyway, so +diff -Naur a/src/crypto/x509/root_unix.go b/src/crypto/x509/root_unix.go +--- a/src/crypto/x509/root_unix.go 2019-03-15 11:33:55.920232337 -0700 ++++ b/src/crypto/x509/root_unix.go 2019-03-15 11:37:15.737326340 -0700 +@@ -38,6 +38,13 @@ + + func loadSystemRoots() (*CertPool, error) { + roots := NewCertPool() ++ if file := os.Getenv("NIX_SSL_CERT_FILE"); file != "" { ++ data, err := ioutil.ReadFile(file) ++ if err == nil { ++ roots.AppendCertsFromPEM(data) ++ return roots, nil ++ } ++ } + + files := certFiles + if f := os.Getenv(certFileEnv); f != "" { diff --git a/nixpkgs/pkgs/development/compilers/go/ssl-cert-file-1.9.patch b/nixpkgs/pkgs/development/compilers/go/ssl-cert-file-1.9.patch new file mode 100644 index 000000000000..3f27bc138c10 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/go/ssl-cert-file-1.9.patch @@ -0,0 +1,80 @@ +diff --git a/src/crypto/x509/root_cgo_darwin.go b/src/crypto/x509/root_cgo_darwin.go +index 8e80533590..31c0c666ec 100644 +--- a/src/crypto/x509/root_cgo_darwin.go ++++ b/src/crypto/x509/root_cgo_darwin.go +@@ -201,11 +201,20 @@ int FetchPEMRoots(CFDataRef *pemRoots, CFDataRef *untrustedPemRoots) { + import "C" + import ( + "errors" ++ "io/ioutil" ++ "os" + "unsafe" + ) + + func loadSystemRoots() (*CertPool, error) { + roots := NewCertPool() ++ if file := os.Getenv("NIX_SSL_CERT_FILE"); file != "" { ++ data, err := ioutil.ReadFile(file) ++ if err == nil { ++ roots.AppendCertsFromPEM(data) ++ return roots, nil ++ } ++ } + + var data C.CFDataRef = nil + var untrustedData C.CFDataRef = nil +diff --git a/src/crypto/x509/root_darwin.go b/src/crypto/x509/root_darwin.go +index bc35a1cf21..21e52bec51 100644 +--- a/src/crypto/x509/root_darwin.go ++++ b/src/crypto/x509/root_darwin.go +@@ -81,18 +81,26 @@ func execSecurityRoots() (*CertPool, error) { + ) + } + +- cmd := exec.Command("/usr/bin/security", args...) +- data, err := cmd.Output() +- if err != nil { +- return nil, err +- } +- + var ( + mu sync.Mutex + roots = NewCertPool() + numVerified int // number of execs of 'security verify-cert', for debug stats + ) + ++ if file := os.Getenv("NIX_SSL_CERT_FILE"); file != "" { ++ data, err := ioutil.ReadFile(file) ++ if err == nil { ++ roots.AppendCertsFromPEM(data) ++ return roots, nil ++ } ++ } ++ ++ cmd := exec.Command("/usr/bin/security", args...) ++ data, err := cmd.Output() ++ if err != nil { ++ return nil, err ++ } ++ + blockCh := make(chan *pem.Block) + var wg sync.WaitGroup + +diff --git a/src/crypto/x509/root_unix.go b/src/crypto/x509/root_unix.go +index 65b5a5fdbc..c9c7ac6a74 100644 +--- a/src/crypto/x509/root_unix.go ++++ b/src/crypto/x509/root_unix.go +@@ -37,6 +37,13 @@ func (c *Certificate) systemVerify(opts *VerifyOptions) (chains [][]*Certificate + + func loadSystemRoots() (*CertPool, error) { + roots := NewCertPool() ++ if file := os.Getenv("NIX_SSL_CERT_FILE"); file != "" { ++ data, err := ioutil.ReadFile(file) ++ if err == nil { ++ roots.AppendCertsFromPEM(data) ++ return roots, nil ++ } ++ } + + files := certFiles + if f := os.Getenv(certFileEnv); f != "" { diff --git a/nixpkgs/pkgs/development/compilers/gprolog/default.nix b/nixpkgs/pkgs/development/compilers/gprolog/default.nix new file mode 100644 index 000000000000..b823bf9bdd44 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/gprolog/default.nix @@ -0,0 +1,68 @@ +{ stdenv, fetchurl }: + +stdenv.mkDerivation rec { + name = "gprolog-1.4.5"; + + src = fetchurl { + urls = [ + "mirror://gnu/gprolog/${name}.tar.gz" + "http://www.gprolog.org/${name}.tar.gz" + ]; + sha256 = "0z4cc42n3k6i35b8mr816iwsvrpxshw6d7dgz6s2h1hy0l7g1p5z"; + }; + + hardeningDisable = stdenv.lib.optional stdenv.isi686 "pic"; + + patchPhase = '' + sed -i -e "s|/tmp/make.log|$TMPDIR/make.log|g" src/Pl2Wam/check_boot + ''; + + preConfigure = '' + cd src + configureFlagsArray=( + "--with-install-dir=$out" + "--without-links-dir" + "--with-examples-dir=$out/share/${name}/examples" + "--with-doc-dir=$out/share/${name}/doc" + ) + ''; + + postInstall = '' + mv -v $out/[A-Z]* $out/gprolog.ico $out/share/${name}/ + ''; + + doCheck = true; + + meta = { + homepage = https://www.gnu.org/software/gprolog/; + description = "GNU Prolog, a free Prolog compiler with constraint solving over finite domains"; + license = stdenv.lib.licenses.lgpl3Plus; + + longDescription = '' + GNU Prolog is a free Prolog compiler with constraint solving + over finite domains developed by Daniel Diaz. + + GNU Prolog accepts Prolog+constraint programs and produces + native binaries (like gcc does from a C source). The obtained + executable is then stand-alone. The size of this executable can + be quite small since GNU Prolog can avoid to link the code of + most unused built-in predicates. The performances of GNU Prolog + are very encouraging (comparable to commercial systems). + + Beside the native-code compilation, GNU Prolog offers a + classical interactive interpreter (top-level) with a debugger. + + The Prolog part conforms to the ISO standard for Prolog with + many extensions very useful in practice (global variables, OS + interface, sockets,...). + + GNU Prolog also includes an efficient constraint solver over + Finite Domains (FD). This opens contraint logic programming to + the user combining the power of constraint programming to the + declarativity of logic programming. + ''; + + maintainers = [ stdenv.lib.maintainers.peti ]; + platforms = stdenv.lib.platforms.gnu ++ stdenv.lib.platforms.linux; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/graalvm/default.nix b/nixpkgs/pkgs/development/compilers/graalvm/default.nix new file mode 100644 index 000000000000..f051b24065a5 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/graalvm/default.nix @@ -0,0 +1,276 @@ +{ stdenv, lib, fetchFromGitHub, fetchurl, fetchzip, mercurial, python27, zlib, makeWrapper, oraclejdk8 }: + +let + # pre-download some cache entries ('mx' will not be able to download under nixbld1) + makeMxCache = list: + stdenv.mkDerivation { + name = "mx-cache"; + buildCommand = '' + mkdir $out + ${lib.concatMapStrings ({url, name, sha1}: '' + install -D ${fetchurl { inherit url sha1; }} $out/${name} + echo -n ${sha1} > $out/${name}.sha1 + '') list} + ''; + }; + + jvmci8-mxcache = [ + rec { sha1 = "66215826a684eb6866d4c14a5a4f9c344f1d1eef"; name = "JACOCOCORE_${sha1}/jacococore.jar"; url = mirror://maven/org/jacoco/org.jacoco.core/0.7.9/org.jacoco.core-0.7.9.jar; } + rec { sha1 = "a365ee459836b2aa18028929923923d15f0c3af9"; name = "JACOCOCORE_${sha1}/jacococore.sources.jar"; url = mirror://maven/org/jacoco/org.jacoco.core/0.7.9/org.jacoco.core-0.7.9-sources.jar; } + rec { sha1 = "8a7f78fdf2a4e58762890d8e896a9298c2980c10"; name = "JACOCOREPORT_${sha1}/jacocoreport.jar"; url = mirror://maven/org/jacoco/org.jacoco.report/0.7.9/org.jacoco.report-0.7.9.jar; } + rec { sha1 = "e6703ef288523a8e63fa756d8adeaa70858d41b0"; name = "JACOCOREPORT_${sha1}/jacocoreport.sources.jar"; url = mirror://maven/org/jacoco/org.jacoco.report/0.7.9/org.jacoco.report-0.7.9-sources.jar; } + rec { sha1 = "306816fb57cf94f108a43c95731b08934dcae15c"; name = "JOPTSIMPLE_4_6_${sha1}/joptsimple-4-6.jar"; url = mirror://maven/net/sf/jopt-simple/jopt-simple/4.6/jopt-simple-4.6.jar; } + rec { sha1 = "9cd14a61d7aa7d554f251ef285a6f2c65caf7b65"; name = "JOPTSIMPLE_4_6_${sha1}/joptsimple-4-6.sources.jar"; url = mirror://maven/net/sf/jopt-simple/jopt-simple/4.6/jopt-simple-4.6-sources.jar; } + rec { sha1 = "b852fb028de645ad2852bbe998e084d253f450a5"; name = "JMH_GENERATOR_ANNPROCESS_1_18_${sha1}/jmh-generator-annprocess-1-18.jar"; url = mirror://maven/org/openjdk/jmh/jmh-generator-annprocess/1.18/jmh-generator-annprocess-1.18.jar; } + rec { sha1 = "d455b0dc6108b5e6f1fb4f6cf1c7b4cbedbecc97"; name = "JMH_GENERATOR_ANNPROCESS_1_18_${sha1}/jmh-generator-annprocess-1-18.sources.jar"; url = mirror://maven/org/openjdk/jmh/jmh-generator-annprocess/1.18/jmh-generator-annprocess-1.18-sources.jar; } + rec { sha1 = "7aac374614a8a76cad16b91f1a4419d31a7dcda3"; name = "JMH_GENERATOR_ANNPROCESS_1_21_${sha1}/jmh-generator-annprocess-1-21.jar"; url = mirror://maven/org/openjdk/jmh/jmh-generator-annprocess/1.21/jmh-generator-annprocess-1.21.jar; } + rec { sha1 = "fb48e2a97df95f8b9dced54a1a37749d2a64d2ae"; name = "JMH_GENERATOR_ANNPROCESS_1_21_${sha1}/jmh-generator-annprocess-1-21.sources.jar"; url = mirror://maven/org/openjdk/jmh/jmh-generator-annprocess/1.21/jmh-generator-annprocess-1.21-sources.jar; } + rec { sha1 = "702b8525fcf81454235e5e2fa2a35f15ffc0ec7e"; name = "ASM_DEBUG_ALL_${sha1}/asm-debug-all.jar"; url = mirror://maven/org/ow2/asm/asm-debug-all/5.0.4/asm-debug-all-5.0.4.jar; } + rec { sha1 = "ec2544ab27e110d2d431bdad7d538ed509b21e62"; name = "COMMONS_MATH3_3_2_${sha1}/commons-math3-3-2.jar"; url = mirror://maven/org/apache/commons/commons-math3/3.2/commons-math3-3.2.jar; } + rec { sha1 = "cd098e055bf192a60c81d81893893e6e31a6482f"; name = "COMMONS_MATH3_3_2_${sha1}/commons-math3-3-2.sources.jar"; url = mirror://maven/org/apache/commons/commons-math3/3.2/commons-math3-3.2-sources.jar; } + rec { sha1 = "0174aa0077e9db596e53d7f9ec37556d9392d5a6"; name = "JMH_1_18_${sha1}/jmh-1-18.jar"; url = mirror://maven/org/openjdk/jmh/jmh-core/1.18/jmh-core-1.18.jar; } + rec { sha1 = "7ff1e1aafea436b6aa8b29a8b8f1c2d66be26f5b"; name = "JMH_1_18_${sha1}/jmh-1-18.sources.jar"; url = mirror://maven/org/openjdk/jmh/jmh-core/1.18/jmh-core-1.18-sources.jar; } + rec { sha1 = "442447101f63074c61063858033fbfde8a076873"; name = "JMH_1_21_${sha1}/jmh-1-21.jar"; url = mirror://maven/org/openjdk/jmh/jmh-core/1.21/jmh-core-1.21.jar; } + rec { sha1 = "a6fe84788bf8cf762b0e561bf48774c2ea74e370"; name = "JMH_1_21_${sha1}/jmh-1-21.sources.jar"; url = mirror://maven/org/openjdk/jmh/jmh-core/1.21/jmh-core-1.21-sources.jar; } + rec { sha1 = "2973d150c0dc1fefe998f834810d68f278ea58ec"; name = "JUNIT_${sha1}/junit.jar"; url = mirror://maven/junit/junit/4.12/junit-4.12.jar; } + rec { sha1 = "a6c32b40bf3d76eca54e3c601e5d1470c86fcdfa"; name = "JUNIT_${sha1}/junit.sources.jar"; url = mirror://maven/junit/junit/4.12/junit-4.12-sources.jar; } + rec { sha1 = "42a25dc3219429f0e5d060061f71acb49bf010a0"; name = "HAMCREST_${sha1}/hamcrest.jar"; url = mirror://maven/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar; } + rec { sha1 = "1dc37250fbc78e23a65a67fbbaf71d2e9cbc3c0b"; name = "HAMCREST_${sha1}/hamcrest.sources.jar"; url = mirror://maven/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3-sources.jar; } + rec { sha1 = "0d031013db9a80d6c88330c42c983fbfa7053193"; name = "jvmci/intel-hsdis-amd64-linux-${sha1}.so"; url = "https://lafo.ssw.uni-linz.ac.at/pub/hsdis/intel/hsdis-amd64-linux-${sha1}.so"; } + ]; + + graal-mxcache = jvmci8-mxcache ++ [ + rec { sha1 = "f2cfb09cee12469ff64f0d698b13de19903bb4f7"; name = "NanoHTTPD-WebSocket_${sha1}/nanohttpd-websocket.jar"; url = mirror://maven/org/nanohttpd/nanohttpd-websocket/2.3.1/nanohttpd-websocket-2.3.1.jar; } + rec { sha1 = "a8d54d1ca554a77f377eff6bf9e16ca8383c8f6c"; name = "NanoHTTPD_${sha1}/nanohttpd.jar"; url = mirror://maven/org/nanohttpd/nanohttpd/2.3.1/nanohttpd-2.3.1.jar; } + rec { sha1 = "30b13b7efc55b7feea667691509cf59902375001"; name = "ANTLR4_${sha1}/antlr4.jar"; url = mirror://maven/org/antlr/antlr4-runtime/4.7/antlr4-runtime-4.7.jar; } + rec { sha1 = "fdedd5f2522122102f0b3db85fe7aa563a009926"; name = "JLINE_${sha1}/jline.jar"; url = mirror://maven/jline/jline/2.14.5/jline-2.14.5.jar; } + rec { sha1 = "d0bdc21c5e6404726b102998e44c66a738897905"; name = "JAVA_ALLOCATION_INSTRUMENTER_${sha1}/java-allocation-instrumenter.jar"; url = mirror://maven/com/google/code/java-allocation-instrumenter/java-allocation-instrumenter/3.1.0/java-allocation-instrumenter-3.1.0.jar; } + rec { sha1 = "0da08b8cce7bbf903602a25a3a163ae252435795"; name = "ASM5_${sha1}/asm5.jar"; url = mirror://maven/org/ow2/asm/asm/5.0.4/asm-5.0.4.jar; } + rec { sha1 = "396ce0c07ba2b481f25a70195c7c94922f0d1b0b"; name = "ASM_TREE5_${sha1}/asm-tree5.jar"; url = mirror://maven/org/ow2/asm/asm-tree/5.0.4/asm-tree-5.0.4.jar; } + rec { sha1 = "280c265b789e041c02e5c97815793dfc283fb1e6"; name = "LIBFFI_${sha1}/libffi.tar.gz"; url = https://lafo.ssw.uni-linz.ac.at/pub/graal-external-deps/libffi-3.2.1.tar.gz; } + rec { sha1 = "8819cea8bfe22c9c63f55465e296b3855ea41786"; name = "TruffleJSON_${sha1}/trufflejson.jar"; url = https://lafo.ssw.uni-linz.ac.at/pub/graal-external-deps/trufflejson-20180130.jar; } + rec { sha1 = "9712a8124c40298015f04a74f61b3d81a51513af"; name = "CHECKSTYLE_8.8_${sha1}/checkstyle-8.8.jar"; url = https://lafo.ssw.uni-linz.ac.at/pub/graal-external-deps/checkstyle-8.8-all.jar; } + rec { sha1 = "a828a4f32caf9ac0b74f2548f87310959558c526"; name = "VISUALVM_COMMON_${sha1}/visualvm-common.tar.gz"; url = https://lafo.ssw.uni-linz.ac.at/pub/graal-external-deps/visualvm-612.tar.gz; } + rec { sha1 = "7ac829f0c9a37f5cc39afd2265588a365480720d"; name = "VISUALVM_PLATFORM_SPECIFIC_${sha1}/visualvm-platform-specific.tar.gz"; url = https://lafo.ssw.uni-linz.ac.at/pub/graal-external-deps/visualvm-612-linux-amd64.tar.gz; } + rec { sha1 = "e6e60889b7211a80b21052a249bd7e0f88f79fee"; name = "Java-WebSocket_${sha1}/java-websocket.jar"; url = mirror://maven/org/java-websocket/Java-WebSocket/1.3.9/Java-WebSocket-1.3.9.jar; } + ]; + + findbugs = fetchzip { + name = "findbugs-3.0.0"; + url = https://lafo.ssw.uni-linz.ac.at/pub/graal-external-deps/findbugs-3.0.0.zip; + sha256 = "0sf5f9h1s6fmhfigjy81i109j1ani5kzdr4njlpq0mnkkh9fpr7m"; + }; + +in rec { + + mx = stdenv.mkDerivation rec { + version = "5.192.0"; + pname = "mx"; + src = fetchFromGitHub { + owner = "graalvm"; + repo = "mx"; + rev = version; + sha256 = "04gdf1gzlc8a6li8lcnrs2j9zicj11fs1vqqf7cmhb4pm2h72hml"; + }; + nativeBuildInputs = [ makeWrapper ]; + buildPhase = '' + substituteInPlace mx --replace /bin/pwd pwd + + # forbid network access while simulate success for passing obligatory "VerifyLibraryURL" + substituteInPlace mx.py --replace \ + 'def download(path, urls, verbose=False, abortOnError=True, verifyOnly=False):' \ + 'def download(path, urls, verbose=False, abortOnError=True, verifyOnly=False): + print("FAKE download(path={} urls={} verbose={} abortOnError={} verifyOnly={})".format(path, urls, verbose, abortOnError, verifyOnly)) + return True' + + # avoid crash with 'ValueError: ZIP does not support timestamps before 1980' + substituteInPlace mx.py --replace \ + 'zipfile.ZipInfo(arcname, time.localtime(os.path.getmtime(join(root, f)))[:6])' \ + 'zipfile.ZipInfo(arcname, time.strptime ("1 Jan 1980", "%d %b %Y" )[:6])' + ''; + installPhase = '' + mkdir -p $out/bin + cp -dpR * $out/bin + wrapProgram $out/bin/mx \ + --prefix PATH : ${lib.makeBinPath [ python27 mercurial ]} \ + --set FINDBUGS_HOME ${findbugs} + ''; + meta = with stdenv.lib; { + homepage = https://github.com/graalvm/mx; + description = "Command-line tool used for the development of Graal projects"; + license = licenses.unfree; + platforms = python27.meta.platforms; + }; + }; + + # copy of pkgs.oraclejvm8 with JVMCI interface (TODO: it should work with pkgs.openjdk8 too) + jvmci8 = stdenv.mkDerivation rec { + version = "0.49"; + name = let + n = "jvmci${/*"8u191"*/ lib.removePrefix "oraclejdk-" oraclejdk8.name}-${version}"; + in if (lib.stringLength n) == (lib.stringLength oraclejdk8.name) then + n + else + throw "length of string `${n}' must be equal to the length of `${oraclejdk8.name}'"; + src = fetchFromGitHub { + owner = "graalvm"; + repo = "graal-jvmci-8"; + rev = "jvmci-${version}"; + sha256 = "1zgin0w1qa7wmfhcisx470fhnmddfxxp5nyyix31yaa7dznql82k"; + }; + buildInputs = [ mx mercurial ]; + postUnpack = '' + # a fake mercurial dir to prevent mx crash and supply the version to mx + ( cd $sourceRoot + hg init + hg add + hg commit -m 'dummy commit' + hg tag ${lib.escapeShellArg src.rev} + hg checkout ${lib.escapeShellArg src.rev} + ) + ''; + hardeningDisable = [ "fortify" ]; + NIX_CFLAGS_COMPILE = [ + "-Wno-error=format-overflow" # newly detected by gcc7 + "-Wno-error=nonnull" + ]; + buildPhase = '' + cp -dpR ${oraclejdk8} writable-copy-of-jdk + chmod +w -R writable-copy-of-jdk + + export MX_ALT_OUTPUT_ROOT=$NIX_BUILD_TOP/mxbuild + export MX_CACHE_DIR=${makeMxCache jvmci8-mxcache} + mx --java-home $(pwd)/writable-copy-of-jdk build + ''; + installPhase = '' + mv jdk1.8.0_*/linux-amd64/product $out + find $out -type f -exec sed -i "s#${oraclejdk8}#$out#g" {} \; + + install -v -m0555 -D $MX_CACHE_DIR/jvmci/*hsdis*.so $out/jre/lib/amd64/hsdis-amd64.so + ''; + dontFixup = true; # do not nuke path of ffmpeg etc + dontStrip = true; # why? see in oraclejdk derivation + inherit (oraclejdk8) meta; + }; + + graalvm8 = stdenv.mkDerivation rec { + version = "1.0.0-rc8"; + name = let + n = "graal-${version}"; + in if (lib.stringLength n) == (lib.stringLength jvmci8.name) then + n + else + throw "length of string `${n}' must be equal to the length of `${jvmci8.name}'"; + src = fetchFromGitHub { + owner = "oracle"; + repo = "graal"; + rev = "vm-${version}"; + sha256 = "1fada4awrr8bhw294xdiq4bagvgrlcr44mw6338gaal0ky3vkm0p"; + }; + buildInputs = [ mx zlib mercurial jvmci8 ]; + postUnpack = '' + # a fake mercurial dir to prevent mx crash and supply the version to mx + ( cd $sourceRoot + hg init + hg add + hg commit -m 'dummy commit' + hg tag ${lib.escapeShellArg src.rev} + hg checkout ${lib.escapeShellArg src.rev} + ) + ''; + postPatch = '' + substituteInPlace substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/headers/PosixDirectives.java \ + --replace '<zlib.h>' '<${zlib.dev}/include/zlib.h>' + substituteInPlace substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/image/CCLinkerInvocation.java \ + --replace 'cmd.add("-v");' 'cmd.add("-v"); cmd.add("-L${zlib}/lib");' + substituteInPlace substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/c/codegen/CCompilerInvoker.java \ + --replace 'command.add(Platform.includedIn(Platform.WINDOWS.class) ? "CL" : "gcc");' \ + 'command.add(Platform.includedIn(Platform.WINDOWS.class) ? "CL" : "${stdenv.cc}/bin/gcc");' + substituteInPlace substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/image/CCLinkerInvocation.java \ + --replace 'protected String compilerCommand = "cc";' 'protected String compilerCommand = "${stdenv.cc}/bin/cc";' + ''; + buildPhase = '' + # make a copy of jvmci8 + cp -dpR ${jvmci8} $out + chmod +w -R $out + find $out -type f -exec sed -i "s#${jvmci8}#$out#g" {} \; + + export MX_ALT_OUTPUT_ROOT=$NIX_BUILD_TOP/mxbuild + export MX_CACHE_DIR=${makeMxCache graal-mxcache} + + ( cd substratevm + + mkdir -p clibraries + mx --java-home $out build + + # bootstrap native-image (that was removed from mx build in https://github.com/oracle/graal/commit/140d7a7edf54ec5872a8ff45869cd1ae499efde4) + mx --java-home $out native-image -cp $MX_ALT_OUTPUT_ROOT/substratevm/dists/jdk1.8/svm-driver.jar com.oracle.svm.driver.NativeImage + ) + ( cd tools + mx --java-home $out build + ) + ''; + installPhase = '' + # add graal files modelling after directory structure of "graalvm-ce" binary distribution + mkdir -p $out/jre/tools/{profiler,chromeinspector,truffle/builder} $out/jre/lib/{graal,include,truffle/include} + cp -vpLR substratevm/svmbuild/native-image-root/lib/* $out/jre/lib/ || true # ignore "same file" error when dereferencing symlinks + cp -vp $MX_ALT_OUTPUT_ROOT/truffle/linux-amd64/truffle-nfi-native/bin/* $out/jre/lib/amd64/ + cp -vp $MX_ALT_OUTPUT_ROOT/compiler/dists/jdk1.8/graal-*processor*.jar $out/jre/lib/graal/ + cp -vp $MX_ALT_OUTPUT_ROOT/truffle/linux-amd64/truffle-nfi-native/include/* $out/jre/lib/include/ + cp -vp $MX_ALT_OUTPUT_ROOT/compiler/dists/jdk1.8/graal-management.jar $out/jre/lib/jvmci/ + cp -vdpR $out/jre/lib/svm/clibraries $out/jre/lib/svm/builder/ + cp -vpR $MX_ALT_OUTPUT_ROOT/truffle/dists/jdk1.8/* $out/jre/lib/truffle/ + cp -vp $MX_ALT_OUTPUT_ROOT/truffle/linux-amd64/truffle-nfi-native/include/* $out/jre/lib/truffle/include/ + cp -vpLR substratevm/svmbuild/native-image-root/tools/* $out/jre/tools/ + cp -vpR $MX_ALT_OUTPUT_ROOT/tools/dists/chromeinspector* $out/jre/tools/chromeinspector/ + cp -vpR $MX_ALT_OUTPUT_ROOT/tools/dists/truffle-profiler* $out/jre/tools/profiler/ + cp -vpR $MX_ALT_OUTPUT_ROOT/truffle/linux-amd64/truffle-nfi-native/* $out/jre/tools/truffle/ + cp -vp $MX_ALT_OUTPUT_ROOT/truffle/dists/jdk1.8/truffle-nfi.jar $out/jre/tools/truffle/builder/ + + echo "name=GraalVM ${version}" > $out/jre/lib/amd64/server/vm.properties + echo -n "graal" > $out/jre/lib/jvmci/compiler-name + echo -n "../truffle/truffle-api.jar:../truffle/truffle-nfi.jar" > $out/jre/lib/jvmci/parentClassLoader.classpath + + install -v -m0555 -D substratevm/com.oracle.svm.driver.nativeimage $out/jre/lib/svm/bin/native-image + ln -s ../lib/svm/bin/native-image $out/jre/bin/native-image + ln -s ../jre/bin/native-image $out/bin/native-image + + # BUG workaround http://mail.openjdk.java.net/pipermail/graal-dev/2017-December/005141.html + substituteInPlace $out/jre/lib/security/java.security \ + --replace file:/dev/random file:/dev/./urandom \ + --replace NativePRNGBlocking SHA1PRNG + ''; + dontFixup = true; # do not nuke path of ffmpeg etc + dontStrip = true; # why? see in oraclejdk derivation + doInstallCheck = true; + installCheckPhase = '' + echo ${lib.escapeShellArg '' + public class HelloWorld { + public static void main(String[] args) { + System.out.println("Hello World"); + } + } + ''} > HelloWorld.java + $out/bin/javac HelloWorld.java + + # run on JVM with Graal Compiler + $out/bin/java -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI -XX:+UseJVMCICompiler HelloWorld + $out/bin/java -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI -XX:+UseJVMCICompiler HelloWorld | fgrep 'Hello World' + + # Ahead-Of-Time compilation + $out/bin/native-image --no-server HelloWorld + ./helloworld + ./helloworld | fgrep 'Hello World' + ''; + + passthru.home = graalvm8; + + meta = with stdenv.lib; { + homepage = https://github.com/oracle/graal; + description = "High-Performance Polyglot VM"; + license = licenses.unfree; + maintainers = with maintainers; [ volth ]; + platforms = [ "x86_64-linux" ]; + }; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/gwt/2.4.0.nix b/nixpkgs/pkgs/development/compilers/gwt/2.4.0.nix new file mode 100644 index 000000000000..f15e1060203b --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/gwt/2.4.0.nix @@ -0,0 +1,25 @@ +{ stdenv, fetchurl, unzip }: + +stdenv.mkDerivation { + name = "gwt-java-2.4.0"; + + src = fetchurl { + url = "https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/google-web-toolkit/gwt-2.4.0.zip"; + sha256 = "1gvyg00vx7fdqgfl2w7nhql78clg3abs6fxxy7m03pprdm5qmm17"; + }; + + buildInputs = [ unzip ]; + + installPhase = '' + mkdir -p $out + unzip $src + mv gwt-2.4.0 $out/bin + ''; + + meta = { + homepage = http://www.gwtproject.org/; + description = "A development toolkit for building and optimizing complex browser-based applications"; + license = stdenv.lib.licenses.asl20; + platforms = stdenv.lib.platforms.unix; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/halide/default.nix b/nixpkgs/pkgs/development/compilers/halide/default.nix new file mode 100644 index 000000000000..1d3b13937fc0 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/halide/default.nix @@ -0,0 +1,64 @@ +{ llvmPackages, lib, fetchFromGitHub, cmake +, libpng, libjpeg, mesa_noglu, eigen, openblas +}: + +let + version = "2018_02_15"; + +in llvmPackages.stdenv.mkDerivation { + + name = "halide-${builtins.replaceStrings ["_"] ["."] version}"; + + src = fetchFromGitHub { + owner = "halide"; + repo = "Halide"; + rev = "release_${version}"; + sha256 = "14lmpbxydx7ii0pxds6rgq5vw4i6yfjsq0bai1l5wwpv1rnwmbxd"; + }; + + patches = [ ./nix.patch ]; + + # clang fails to compile intermediate code because + # of unused "--gcc-toolchain" option + postPatch = '' + sed -i "s/-Werror//" src/CMakeLists.txt + ''; + + cmakeFlags = [ "-DWARNINGS_AS_ERRORS=OFF" ]; + + # To handle the lack of 'local' RPATH; required, as they call one of + # their built binaries requiring their libs, in the build process. + preBuild = '' + export LD_LIBRARY_PATH="$(pwd)/lib:$LD_LIBRARY_PATH" + ''; + + enableParallelBuilding = true; + + # Note: only openblas and not atlas part of this Nix expression + # see pkgs/development/libraries/science/math/liblapack/3.5.0.nix + # to get a hint howto setup atlas instead of openblas + buildInputs = [ llvmPackages.llvm libpng libjpeg mesa_noglu eigen openblas ]; + + nativeBuildInputs = [ cmake ]; + + # No install target for cmake available. + # Calling install target in Makefile causes complete rebuild + # and the library rpath is broken, because libncursesw.so.6 is missing. + # Another way is using "make halide_archive", but the tarball is not easy + # to disassemble. + installPhase = '' + find + mkdir -p "$out/lib" "$out/bin" + cp bin/HalideTrace* "$out/bin" + cp lib/libHalide.so "$out/lib" + cp -r include "$out" + ''; + + meta = with lib; { + description = "C++ based language for image processing and computational photography"; + homepage = "https://halide-lang.org"; + license = licenses.mit; + platforms = platforms.linux; + maintainers = [ maintainers.ck3d ]; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/halide/nix.patch b/nixpkgs/pkgs/development/compilers/halide/nix.patch new file mode 100644 index 000000000000..2ab1e31adeb4 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/halide/nix.patch @@ -0,0 +1,55 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 40a685b7e..c452efd09 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -49,10 +49,10 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") + + set(LLVM_VERSION "${LLVM_VERSION_MAJOR}${LLVM_VERSION_MINOR}") + +-file(TO_NATIVE_PATH "${LLVM_TOOLS_BINARY_DIR}/llvm-as${CMAKE_EXECUTABLE_SUFFIX}" LLVM_AS) +-file(TO_NATIVE_PATH "${LLVM_TOOLS_BINARY_DIR}/llvm-nm${CMAKE_EXECUTABLE_SUFFIX}" LLVM_NM) +-file(TO_NATIVE_PATH "${LLVM_TOOLS_BINARY_DIR}/clang${CMAKE_EXECUTABLE_SUFFIX}" CLANG) +-file(TO_NATIVE_PATH "${LLVM_TOOLS_BINARY_DIR}/llvm-config${CMAKE_EXECUTABLE_SUFFIX}" LLVM_CONFIG) ++find_program(LLVM_AS llvm-as HINTS ${LLVM_TOOLS_BINARY_DIR}) ++find_program(LLVM_NM llvm-nm HINTS ${LLVM_TOOLS_BINARY_DIR}) ++find_program(CLANG clang HINTS ${LLVM_TOOLS_BINARY_DIR}) ++find_program(LLVM_CONFIG llvm-config HINTS ${LLVM_TOOLS_BINARY_DIR}) + + # LLVM doesn't appear to expose --system-libs via its CMake interface, + # so we must shell out to llvm-config to find this info +diff --git a/apps/linear_algebra/CMakeLists.txt b/apps/linear_algebra/CMakeLists.txt +index 132c80e6a..36ce865f2 100644 +--- a/apps/linear_algebra/CMakeLists.txt ++++ b/apps/linear_algebra/CMakeLists.txt +@@ -26,7 +26,7 @@ if (CBLAS_FOUND) + # Atlas requires also linking against its provided libcblas for cblas symbols + set(ATLAS_EXTRA_LIBS cblas) # XXX fragile + set(OpenBLAS_EXTRA_LIBS) +- set(BLAS_VENDORS OpenBLAS ATLAS) ++ set(BLAS_VENDORS OpenBLAS) + + # TODO + # there are more vendors we could add here that support the cblas interface +@@ -41,6 +41,7 @@ if (CBLAS_FOUND) + message(STATUS " ${BLAS_VENDOR}: Missing") + else() + message(STATUS " ${BLAS_VENDOR}: Found") ++ set(BLAS_LIBRARIES "${BLAS_LIBRARIES}" CACHE FILEPATH "BLAS library to use") + list(APPEND BLAS_VENDORS ${NAME}) + endif() + endforeach() +diff --git a/apps/linear_algebra/tests/CMakeLists.txt b/apps/linear_algebra/tests/CMakeLists.txt +index 4b95eb3bb..1daa97437 100644 +--- a/apps/linear_algebra/tests/CMakeLists.txt ++++ b/apps/linear_algebra/tests/CMakeLists.txt +@@ -19,6 +19,6 @@ target_compile_options(test_halide_blas PRIVATE -Wno-unused-variable) + target_link_libraries(test_halide_blas + PRIVATE + halide_blas +- cblas # XXX fragile ++ ${BLAS_LIBRARIES} + Halide + ) +-- +2.15.0 + diff --git a/nixpkgs/pkgs/development/compilers/haxe/default.nix b/nixpkgs/pkgs/development/compilers/haxe/default.nix new file mode 100644 index 000000000000..0a974fccc888 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/haxe/default.nix @@ -0,0 +1,100 @@ +{ stdenv, fetchgit, coreutils, ocaml, zlib, pcre, neko, camlp4 }: + +let + generic = { version, sha256, prePatch }: + stdenv.mkDerivation rec { + name = "haxe-${version}"; + + buildInputs = [ocaml zlib pcre neko camlp4]; + + src = fetchgit { + url = https://github.com/HaxeFoundation/haxe.git; + inherit sha256; + fetchSubmodules = true; + rev = "refs/tags/${version}"; + }; + + inherit prePatch; + + buildFlags = [ "all" "tools" ]; + + installPhase = '' + install -vd "$out/bin" "$out/lib/haxe/std" + cp -vr haxe haxelib std "$out/lib/haxe" + + # make wrappers which provide a temporary HAXELIB_PATH with symlinks to multiple repositories HAXELIB_PATH may point to + for name in haxe haxelib; do + cat > $out/bin/$name <<EOF + #!{bash}/bin/bash + + if [[ "\$HAXELIB_PATH" =~ : ]]; then + NEW_HAXELIB_PATH="\$(${coreutils}/bin/mktemp -d)" + + IFS=':' read -ra libs <<< "\$HAXELIB_PATH" + for libdir in "\''${libs[@]}"; do + for lib in "\$libdir"/*; do + if [ ! -e "\$NEW_HAXELIB_PATH/\$(${coreutils}/bin/basename "\$lib")" ]; then + ${coreutils}/bin/ln -s "--target-directory=\$NEW_HAXELIB_PATH" "\$lib" + fi + done + done + export HAXELIB_PATH="\$NEW_HAXELIB_PATH" + $out/lib/haxe/$name "\$@" + rm -rf "\$NEW_HAXELIB_PATH" + else + exec $out/lib/haxe/$name "\$@" + fi + EOF + chmod +x $out/bin/$name + done + ''; + + setupHook = ./setup-hook.sh; + + dontStrip = true; + + # While it might be a good idea to run the upstream test suite, let's at + # least make sure we can actually run the compiler. + doInstallCheck = true; + installCheckPhase = '' + # Get out of the source directory to make sure the stdlib from the + # sources doesn't interfere with the installed one. + mkdir installcheck + pushd installcheck > /dev/null + cat >> InstallCheck.hx <<EOF + class InstallCheck { + public static function main() trace("test"); + } + EOF + "$out/bin/haxe" -js installcheck.js -main InstallCheck + grep -q 'console\.log.*test' installcheck.js + popd > /dev/null + ''; + + meta = with stdenv.lib; { + description = "Programming language targeting JavaScript, Flash, NekoVM, PHP, C++"; + homepage = https://haxe.org; + license = with licenses; [ gpl2 bsd2 /*?*/ ]; # -> docs/license.txt + maintainers = [ maintainers.marcweber ]; + platforms = platforms.linux ++ platforms.darwin; + }; + }; +in { + # this old version is required to compile some libraries + haxe_3_2 = generic { + version = "3.2.1"; + sha256 = "1x9ay5a2llq46fww3k07jxx8h1vfpyxb522snc6702a050ki5vz3"; + prePatch = '' + sed -i -e 's|"/usr/lib/haxe/std/";|"'"$out/lib/haxe/std/"'";\n&|g' main.ml + sed -i -e 's|"neko"|"${neko}/bin/neko"|g' extra/haxelib_src/src/tools/haxelib/Main.hx + ''; + }; + haxe_3_4 = generic { + version = "3.4.6"; + sha256 = "1myc4b8fwp0f9vky17wv45n34a583f5sjvajsc93f5gm1wanp4if"; + prePatch = '' + sed -i -re 's!(let +prefix_path += +).*( +in)!\1"'"$out/"'"\2!' src/main.ml + sed -i -e 's|"neko"|"${neko}/bin/neko"|g' extra/haxelib_src/src/haxelib/client/Main.hx + ''; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/haxe/setup-hook.sh b/nixpkgs/pkgs/development/compilers/haxe/setup-hook.sh new file mode 100644 index 000000000000..e6496107a5ee --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/haxe/setup-hook.sh @@ -0,0 +1,7 @@ +addHaxeLibPath() { + if [ ! -d "$1/lib/haxe/std" ]; then + addToSearchPath HAXELIB_PATH "$1/lib/haxe" + fi +} + +addEnvHooks "$targetOffset" addHaxeLibPath diff --git a/nixpkgs/pkgs/development/compilers/hhvm/default.nix b/nixpkgs/pkgs/development/compilers/hhvm/default.nix new file mode 100644 index 000000000000..010dacd0c71a --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/hhvm/default.nix @@ -0,0 +1,68 @@ +{ stdenv, fetchgit, cmake, pkgconfig, boost, libunwind, libmemcached +, pcre, libevent, gd, curl, libxml2, icu, flex, bison, openssl, zlib, php +, expat, libcap, oniguruma, libdwarf, libmcrypt, tbb, gperftools, glog, libkrb5 +, bzip2, openldap, readline, libelf, uwimap, binutils, cyrus_sasl, pam, libpng +, libxslt, freetype, gdb, git, perl, mysql, gmp, libyaml, libedit +, libvpx, imagemagick, fribidi, gperf, which, ocamlPackages +}: + +stdenv.mkDerivation rec { + name = "hhvm-${version}"; + version = "3.23.2"; + + # use git version since we need submodules + src = fetchgit { + url = "https://github.com/facebook/hhvm.git"; + rev = "HHVM-${version}"; + sha256 = "1nic49j8nghx82lgvz0b95r78sqz46qaaqv4nx48p8yrj9ysnd7i"; + fetchSubmodules = true; + }; + + buildInputs = + [ cmake pkgconfig boost libunwind mysql.connector-c libmemcached pcre gdb git perl + libevent gd curl libxml2 icu flex bison openssl zlib php expat libcap + oniguruma libdwarf libmcrypt tbb gperftools bzip2 openldap readline + libelf uwimap binutils cyrus_sasl pam glog libpng libxslt libkrb5 + gmp libyaml libedit libvpx imagemagick fribidi gperf which + ocamlPackages.ocaml ocamlPackages.ocamlbuild + ]; + + patches = [ + ./flexible-array-members-gcc6.patch + ]; + + enableParallelBuilding = true; + dontUseCmakeBuildDir = true; + NIX_LDFLAGS = "-lpam -L${pam}/lib"; + + # work around broken build system + NIX_CFLAGS_COMPILE = "-I${freetype.dev}/include/freetype2"; + + # the cmake package does not handle absolute CMAKE_INSTALL_INCLUDEDIR correctly + # (setting it to an absolute path causes include files to go to $out/$out/include, + # because the absolute path is interpreted with root at $out). + cmakeFlags = "-DCMAKE_INSTALL_INCLUDEDIR=include"; + + prePatch = '' + substituteInPlace ./configure \ + --replace "/usr/bin/env bash" ${stdenv.shell} + substituteInPlace ./third-party/ocaml/CMakeLists.txt \ + --replace "/bin/bash" ${stdenv.shell} + perl -pi -e 's/([ \t(])(isnan|isinf)\(/$1std::$2(/g' \ + hphp/runtime/base/*.cpp \ + hphp/runtime/ext/std/*.cpp \ + hphp/runtime/ext_zend_compat/php-src/main/*.cpp \ + hphp/runtime/ext_zend_compat/php-src/main/*.h + sed '1i#include <functional>' -i third-party/mcrouter/src/mcrouter/lib/cycles/Cycles.h + patchShebangs . + ''; + + meta = { + description = "High-performance JIT compiler for PHP/Hack"; + homepage = "https://hhvm.com"; + license = "PHP/Zend"; + platforms = [ "x86_64-linux" ]; + maintainers = [ stdenv.lib.maintainers.thoughtpolice ]; + broken = true; # Since 2018-04-21, see https://hydra.nixos.org/build/73059373 + }; +} diff --git a/nixpkgs/pkgs/development/compilers/hhvm/flexible-array-members-gcc6.patch b/nixpkgs/pkgs/development/compilers/hhvm/flexible-array-members-gcc6.patch new file mode 100644 index 000000000000..61b6e5e8d8c3 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/hhvm/flexible-array-members-gcc6.patch @@ -0,0 +1,20 @@ +diff --git a/third-party/re2/src/re2/dfa.cc b/third-party/re2/src/re2/dfa.cc +index 483f678..3aa3610 100644 +--- a/third-party/re2/src/re2/dfa.cc ++++ b/third-party/re2/src/re2/dfa.cc +@@ -101,8 +101,13 @@ class DFA { + uint flag_; // Empty string bitfield flags in effect on the way + // into this state, along with kFlagMatch if this + // is a matching state. +- std::atomic<State*> next_[]; // Outgoing arrows from State, +- // one per input byte class ++// Work around the bug affecting flexible array members in GCC 6.1 and 6.2. ++// (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70932) ++#if !defined(__clang__) && defined(__GNUC__) && __GNUC__ == 6 && __GNUC_MINOR__ >= 1 ++ std::atomic<State*> next_[0]; // Outgoing arrows from State, one per input byte class ++#else ++ std::atomic<State*> next_[]; // Outgoing arrows from State, one per input byte class ++#endif + }; + + enum { diff --git a/nixpkgs/pkgs/development/compilers/hop/default.nix b/nixpkgs/pkgs/development/compilers/hop/default.nix new file mode 100644 index 000000000000..3db916e6003c --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/hop/default.nix @@ -0,0 +1,28 @@ +{ stdenv, fetchurl, bigloo }: + +stdenv.mkDerivation rec { + name = "hop-2.5.1"; + src = fetchurl { + url = "ftp://ftp-sop.inria.fr/indes/fp/Hop/${name}.tar.gz"; + sha256 = "1bvp7pc71bln5yvfj87s8750c6l53wjl6f8m12v62q9926adhwys"; + }; + + buildInputs = [ bigloo ]; + + preConfigure = '' + export NIX_LDFLAGS="$NIX_LDFLAGS -lbigloogc-4.1a"; + ''; + + configureFlags = [ + "--bigloo=${bigloo}/bin/bigloo" + "--bigloolibdir=${bigloo}/lib/bigloo/4.1a/" + ]; + + meta = with stdenv.lib; { + description = "A multi-tier programming language for the Web 2.0 and the so-called diffuse Web"; + homepage = http://hop.inria.fr/; + license = licenses.gpl2Plus; + platforms = platforms.linux; + maintainers = with maintainers; [ vbgl ]; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/iasl/default.nix b/nixpkgs/pkgs/development/compilers/iasl/default.nix new file mode 100644 index 000000000000..2b5891256043 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/iasl/default.nix @@ -0,0 +1,30 @@ +{stdenv, fetchurl, bison, flex}: + +stdenv.mkDerivation rec { + name = "iasl-${version}"; + version = "20181213"; + + src = fetchurl { + url = "https://acpica.org/sites/acpica/files/acpica-unix-${version}.tar.gz"; + sha256 = "1vgqlv9pvxc52faxixpgz7hi1awqmj88bw5vqn3bldf6fmkh147w"; + }; + + NIX_CFLAGS_COMPILE = "-O3"; + + buildFlags = "iasl"; + + buildInputs = [ bison flex ]; + + installPhase = + '' + install -d $out/bin + install generate/unix/bin*/iasl $out/bin + ''; + + meta = { + description = "Intel ACPI Compiler"; + homepage = http://www.acpica.org/; + license = stdenv.lib.licenses.iasl; + platforms = stdenv.lib.platforms.unix; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/icedtea-web/default.nix b/nixpkgs/pkgs/development/compilers/icedtea-web/default.nix new file mode 100644 index 000000000000..9390cbde6377 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/icedtea-web/default.nix @@ -0,0 +1,39 @@ +{ stdenv, fetchurl, jdk, gtk2, xulrunner, zip, pkgconfig, perl, npapi_sdk, bash, bc }: + +stdenv.mkDerivation rec { + name = "icedtea-web-${version}"; + + version = "1.7.1"; + + src = fetchurl { + url = "http://icedtea.wildebeest.org/download/source/${name}.tar.gz"; + sha256 = "1b9z0i9b1dsc2qpfdzbn2fi4vi3idrhm7ig45g1ny40ymvxcwwn9"; + }; + + nativeBuildInputs = [ pkgconfig bc perl ]; + buildInputs = [ gtk2 xulrunner zip npapi_sdk ]; + + preConfigure = '' + #patchShebangs javac.in + configureFlagsArray+=("BIN_BASH=${bash}/bin/bash") + ''; + + configureFlags = [ + "--with-jdk-home=${jdk.home}" + "--disable-docs" + ]; + + mozillaPlugin = "/lib"; + + meta = { + description = "Java web browser plugin and an implementation of Java Web Start"; + longDescription = '' + A Free Software web browser plugin running applets written in the Java + programming language and an implementation of Java Web Start, originally + based on the NetX project. + ''; + homepage = http://icedtea.classpath.org/wiki/IcedTea-Web; + maintainers = with stdenv.lib.maintainers; [ wizeman ]; + platforms = stdenv.lib.platforms.linux; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/inform7/default.nix b/nixpkgs/pkgs/development/compilers/inform7/default.nix new file mode 100644 index 000000000000..a6955c030519 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/inform7/default.nix @@ -0,0 +1,30 @@ +{ stdenv, fetchzip, coreutils, perl, gnutar, gzip }: +let + version = "6M62"; +in stdenv.mkDerivation { + name = "inform7-${version}"; + buildInputs = [ perl coreutils gnutar gzip ]; + src = fetchzip { + url = "http://inform7.com/download/content/6M62/I7_6M62_Linux_all.tar.gz"; + sha256 = "0bk0pfymvsn1g8ci0pfdw7dgrlzb232a8pc67y2xk6zgpf3m41vj"; + }; + preConfigure = "touch Makefile.PL"; + buildPhase = ""; + installPhase = '' + mkdir -p $out + pushd $src + ./install-inform7.sh --prefix $out + popd + + substituteInPlace "$out/bin/i7" \ + --replace "/usr/bin/perl" "${perl}/bin/perl" + ''; + + meta = with stdenv.lib; { + description = "A design system for interactive fiction."; + homepage = http://inform7.com/; + license = licenses.artistic2; + maintainers = with maintainers; [ mbbx6spp ]; + platforms = platforms.unix; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/intercal/default.nix b/nixpkgs/pkgs/development/compilers/intercal/default.nix new file mode 100644 index 000000000000..f601dc254a43 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/intercal/default.nix @@ -0,0 +1,42 @@ +{ stdenv, fetchurl +, pkgconfig +, bison, flex +, makeWrapper }: + +with stdenv.lib; +stdenv.mkDerivation rec { + + name = "intercal-${version}"; + version = "0.30"; + + src = fetchurl { + url = "http://catb.org/esr/intercal/${name}.tar.gz"; + sha256 = "058ppvvgz9r5603ia9jkknbrciypgg4hjbczrv9v1d9w3ak652xk"; + }; + + buildInputs = + [ pkgconfig bison flex makeWrapper ]; + + # Intercal invokes gcc, so we need an explicit PATH + postInstall = '' + wrapProgram $out/bin/ick --suffix PATH ':' ${stdenv.cc}/bin + ''; + + meta = { + description = "The original esoteric programming language"; + longDescription = '' + INTERCAL, an abbreviation for "Compiler Language With No + Pronounceable Acronym", is a famously esoterical programming + language. It was created in 1972, by Donald R. Woods and James + M. Lyon, with the unusual goal of creating a language with no + similarities whatsoever to any existing programming + languages. The language largely succeeds in this goal, apart + from its use of an assignment statement. + ''; + homepage = http://www.catb.org/~esr/intercal/; + license = licenses.gpl2Plus; + maintainers = [ maintainers.AndersonTorres ]; + platforms = platforms.linux; + }; +} +# TODO: investigate if LD_LIBRARY_PATH needs to be set diff --git a/nixpkgs/pkgs/development/compilers/ios-cross-compile/9.2.nix b/nixpkgs/pkgs/development/compilers/ios-cross-compile/9.2.nix new file mode 100644 index 000000000000..e64c0c912d94 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/ios-cross-compile/9.2.nix @@ -0,0 +1,65 @@ +{ stdenv, git, clang, + fetchFromGitHub, requireFile, + openssl, xz, gnutar, + automake, autoconf, libtool, clangStdenv } : + +clangStdenv.mkDerivation rec { + name = "ios-cross-compile-${version}"; + version = "9.2"; + sdk = "iPhoneOS9.2.sdk"; + cctools_port = fetchFromGitHub { + owner = "tpoechtrager"; + repo = "cctools-port"; + rev = "7d405492b09fa27546caaa989b8493829365deab"; + sha256 = "0nj1q5bqdx5jm68dispybxc7wnkb6p8p2igpnap9q6qyv2r9p07w"; + }; + ldid = fetchFromGitHub { + owner = "tpoechtrager"; + repo = "ldid"; + rev = "3064ed628108da4b9a52cfbe5d4c1a5817811400"; + sha256 = "1a6zaz8fgbi239l5zqx9xi3hsrv3jmfh8dkiy5gmnjs6v4gcf6sf"; + }; + src = requireFile rec { + name = "iPhoneOS9.2.sdk.tar.xz"; + sha256 = "1l2h3cic9psrq3nmfv9aaxkdk8y2pvr0iq6apj87mb3ms9a4cqrq"; + message = '' + You need to do the following steps to get a prepared + ios tarball. + + 1) Download an XCode dmg, specifically XCode_7.2.dmg + 2) Install darling-dmg, available via: nix-env -i darling-dmg + 3) Follow this shell history: + + $ cd ~/ + $ mkdir xcode + $ darling-dmg Xcode_7.2dmg xcode + $ cd xcode/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs + $ mktemp -d + /tmp/gar/tmp.4ZZ8kqyfqp/ + $ mkdir /tmp/gar/tmp.4ZZ8kqyfqp/iPhoneOS9.2.sdk + $ cp -r iPhoneOS.sdk/* /tmp/gar/tmp.4ZZ8kqyfqp/iPhoneOS9.2.sdk + $ cp -r ../../../../Toolchains/XcodeDefault.xctoolchain/usr/include/c++/* \ + /tmp/gar/tmp.4ZZ8kqyfqp/iPhoneOS9.2.sdk/usr/include/c++ + $ tar -cf - * | xz -9 -c - > iPhoneOS9.2.sdk.tar.xz + $ cd ~/ + $ fusermount -u xcode + + Then do: + + nix-prefetch-url file:///path/to/${name} + + and run this installation again. + ''; + }; + buildInputs = [ git xz gnutar openssl automake autoconf libtool clang ]; + alt_wrapper = ./alt_wrapper.c; + builder = ./9.2_builder.sh; + meta = { + description = + "Provides an iOS cross compiler from 7.1 up to iOS-${version} and ldid"; + platforms = stdenv.lib.platforms.linux; + hydraPlatforms = []; + maintainers = with stdenv.lib.maintainers; [ fxfactorial ]; + license = stdenv.lib.licenses.gpl2; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/ios-cross-compile/9.2_builder.sh b/nixpkgs/pkgs/development/compilers/ios-cross-compile/9.2_builder.sh new file mode 100644 index 000000000000..4604b1fdea72 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/ios-cross-compile/9.2_builder.sh @@ -0,0 +1,153 @@ +# -*- shell-script -*- +source $stdenv/setup + +function extract +{ + printf "extracting $(basename $1) ...\n" + local tarflags="xf" + + case "$1" in + *.tar.xz) + xz -dc $1 | tar "$tarflags" - ;; + *) + printf "Make sure you give a iPhoneOS9.2.sdk.tar.xz file \n" ;; + esac +} + +function verify_arch { + case "$1" in + # Our good arches. + armv7|arm64) ;; + *) + local + acc="armv7 | arm64" + error_message=$( + printf '%s is not an acceptable arch. Try one of %s' "$1" "$acc" + ) + printf "$error_message\n" + exit + esac +} + +function verify_sdk_version { + sdk_version=$(basename "$1" | grep -P -o "[0-9].[0-9]+") + case "$sdk_version" in + # Make sure the SDK is correct. + [5-9].[0-9]) ;; + *) + printf 'No iPhone SDK version in file name\n' + esac +} + +function do_build { + + if [ $# -lt 2 ]; then + printf "usage: $0 iPhoneOS.sdk.tar* <target cpu>\n" 1>&2 + printf "i.e. $0 /path/to/iPhoneOS.sdk.tar.xz armv7\n" 1>&2 + exit 1 + fi + + mkdir -p $out + + chmod -R 755 "$cctools_port" + + pushd "$cctools_port"/usage_examples/ios_toolchain &> /dev/null + + export LC_ALL=C + + local + triple='%s-apple-darwin11' + target_dir="$PWD/target" + sdk_dir="$target_dir/SDK" + platform="$(uname -s)" + # Will be mutated by verify_sdk_version + sdk_version= + + mkdir -p "$target_dir" + mkdir -p "$target_dir/bin" + mkdir -p "$sdk_dir" + + verify_arch "$2" + verify_sdk_version "$1" + + triple="$(printf "$triple" "$2")" + pushd "$sdk_dir" &>/dev/null + extract "$1" + + local sys_lib=$( + find $sdk_dir -name libSystem.dylib -o -name libSystem.tbd | head -n1 + ) + + if [ -z "$sys_lib" ]; then + printf "SDK should contain libSystem{.dylib,.tbd}\n" 1>&2 + exit 1 + fi + + local sys_root=$(readlink -f "$(dirname $sys_lib)/../..") + + local sdk_unboxed=$(basename $sys_root) + + mv -f "$sys_root"/* "$sdk_dir" || true + + popd &>/dev/null + + printf "\nbuilding wrapper\n" + + printf "int main(){return 0;}" | clang -xc -O2 -o "$target_dir"/bin/dsymutil - + + clang -O2 -std=c99 $alt_wrapper \ + -DTARGET_CPU=$(printf '"%s"' "$2") \ + -DNIX_APPLE_HDRS=$( + printf '"%s"' "-I$out/$sdk/usr/include" + ) \ + -DNIX_APPLE_FRAMEWORKS=$( + printf '"%s"' "$out/$sdk/System/Library/Frameworks" + ) \ + -DNIX_APPLE_PRIV_FRAMEWORKS=$( + printf '"%s"' "$out/$sdk/System/Library/PrivateFrameworks" + ) \ + -DOS_VER_MIN=$(printf '"%s"' "7.1") \ + -o "$target_dir/bin/$triple-clang" + + pushd "$target_dir"/bin &>/dev/null + + cp "$triple"-clang "$triple"-clang++ + + popd &>/dev/null + + printf "\nbuilding ldid\n" + + mkdir -p tmp + pushd tmp &>/dev/null + pushd "$ldid" &>/dev/null + + chmod -R 755 "$ldid" + + make INSTALLPREFIX="$target_dir" -j4 install + popd &>/dev/null + popd &>/dev/null + + printf "\nbuilding cctools / ld64\n" + + pushd ../../cctools &>/dev/null + git clean -fdx . &>/dev/null || true + ./autogen.sh + ./configure --target="$triple" --prefix="$target_dir" + make -j4 + make install &>/dev/null + + popd &>/dev/null + + local me=`whoami` + + for d in bin libexec SDK; do + chown -R $me:$me target/$d + cp -R target/$d $out + done + + # Crucial piece + rm -rf $out/$sdk + mv $out/SDK $out/$sdk +} + +do_build $src armv7 diff --git a/nixpkgs/pkgs/development/compilers/ios-cross-compile/alt_wrapper.c b/nixpkgs/pkgs/development/compilers/ios-cross-compile/alt_wrapper.c new file mode 100644 index 000000000000..928b64e6fd9d --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/ios-cross-compile/alt_wrapper.c @@ -0,0 +1,212 @@ +/* + This and the shell builder was originally written by + https://github.com/tpoechtrager but I had to modify both so that + they played nicely and were reproducible with nixpkgs. Much thanks + to MixRank for letting me work on this. + Edgar Aroutiounian <edgar.factorial@gmail.com> + */ + +#ifndef TARGET_CPU +#define TARGET_CPU "armv7" +#endif + +#ifndef OS_VER_MIN +#define OS_VER_MIN "4.2" +#endif + +#ifndef NIX_APPLE_HDRS +#define NIX_APPLE_HDRS "" +#endif + +#ifndef NIX_APPLE_FRAMEWORKS +#define NIX_APPLE_FRAMEWORKS "" +#endif + +#ifndef NIX_APPLE_PRIV_FRAMEWORKS +#define NIX_APPLE_PRIV_FRAMEWORKS "" +#endif + +#define _GNU_SOURCE + +#include <stdlib.h> +#include <string.h> +#include <stdio.h> +#include <stddef.h> +#include <unistd.h> +#include <limits.h> + +#ifdef __APPLE__ +#include <mach-o/dyld.h> +#endif + +#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) +#include <sys/sysctl.h> +#endif + +#ifdef __OpenBSD__ +#include <sys/types.h> +#include <sys/user.h> +#include <sys/stat.h> +#endif + +char *get_executable_path(char *epath, size_t buflen) +{ + char *p; +#ifdef __APPLE__ + unsigned int l = buflen; + if (_NSGetExecutablePath(epath, &l) != 0) return NULL; +#elif defined(__FreeBSD__) || defined(__DragonFly__) + int mib[4] = { CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1 }; + size_t l = buflen; + if (sysctl(mib, 4, epath, &l, NULL, 0) != 0) return NULL; +#elif defined(__OpenBSD__) + int mib[4]; + char **argv; + size_t len; + size_t l; + const char *comm; + int ok = 0; + mib[0] = CTL_KERN; + mib[1] = KERN_PROC_ARGS; + mib[2] = getpid(); + mib[3] = KERN_PROC_ARGV; + if (sysctl(mib, 4, NULL, &len, NULL, 0) < 0) + abort(); + if (!(argv = malloc(len))) + abort(); + if (sysctl(mib, 4, argv, &len, NULL, 0) < 0) + abort(); + comm = argv[0]; + if (*comm == '/' || *comm == '.') { + char *rpath; + if ((rpath = realpath(comm, NULL))) { + strlcpy(epath, rpath, buflen); + free(rpath); + ok = 1; + } + } else { + char *sp; + char *xpath = strdup(getenv("PATH")); + char *path = strtok_r(xpath, ":", &sp); + struct stat st; + if (!xpath) + abort(); + while (path) { + snprintf(epath, buflen, "%s/%s", path, comm); + if (!stat(epath, &st) && (st.st_mode & S_IXUSR)) { + ok = 1; + break; + } + path = strtok_r(NULL, ":", &sp); + } + free(xpath); + } + free(argv); + if (!ok) return NULL; + l = strlen(epath); +#else + ssize_t l = readlink("/proc/self/exe", epath, buflen); +#endif + if (l <= 0) return NULL; + epath[buflen - 1] = '\0'; + p = strrchr(epath, '/'); + if (p) *p = '\0'; + return epath; +} + +char *get_filename(char *str) +{ + char *p = strrchr(str, '/'); + return p ? &p[1] : str; +} + +void target_info(char *argv[], char **triple, char **compiler) +{ + char *p = get_filename(argv[0]); + char *x = strrchr(p, '-'); + if (!x) abort(); + *compiler = &x[1]; + *x = '\0'; + *triple = p; +} + +void env(char **p, const char *name, char *fallback) +{ + char *ev = getenv(name); + if (ev) { *p = ev; return; } + *p = fallback; +} + +int main(int argc, char *argv[]) +{ + char **args = alloca(sizeof(char*) * (argc + 17)); + int i, j; + + char execpath[PATH_MAX+1]; + char sdkpath[PATH_MAX+1]; + char codesign_allocate[64]; + char osvermin[64]; + + char *compiler, *target, *sdk, *cpu, *osmin; + + target_info(argv, &target, &compiler); + + if (!get_executable_path(execpath, sizeof(execpath))) abort(); + snprintf(sdkpath, sizeof(sdkpath), "%s/../SDK", execpath); + + snprintf(codesign_allocate, sizeof(codesign_allocate), + "%s-codesign_allocate", target); + + setenv("CODESIGN_ALLOCATE", codesign_allocate, 1); + setenv("IOS_FAKE_CODE_SIGN", "1", 1); + + env(&sdk, "IOS_SDK_SYSROOT", sdkpath); + env(&cpu, "IOS_TARGET_CPU", TARGET_CPU); + + env(&osmin, "IPHONEOS_DEPLOYMENT_TARGET", OS_VER_MIN); + unsetenv("IPHONEOS_DEPLOYMENT_TARGET"); + + snprintf(osvermin, sizeof(osvermin), "-miphoneos-version-min=%s", osmin); + + for (i = 1; i < argc; ++i) { + if (!strcmp(argv[i], "-arch")) { + cpu = NULL; + break; + } + } + + i = 0; + + args[i++] = compiler; + args[i++] = "-target"; + args[i++] = target; + args[i++] = "-isysroot"; + args[i++] = sdk; + args[i++] = NIX_APPLE_HDRS; + args[i++] = "-F"; + args[i++] = NIX_APPLE_FRAMEWORKS; + args[i++] = "-F"; + args[i++] = NIX_APPLE_PRIV_FRAMEWORKS; + + if (cpu) { + args[i++] = "-arch"; + args[i++] = cpu; + } + + args[i++] = osvermin; + args[i++] = "-mlinker-version=253.3"; + + for (j = 1; j < argc; ++i, ++j) args[i] = argv[j]; + + args[i] = NULL; + + setenv("COMPILER_PATH", execpath, 1); + /* int k; */ + /* for (k = 0; k < i; k++) */ + /* printf("Compiler option: %s\n", args[k]); */ + /* printf("End of Compiler args\n"); */ + execvp(compiler, args); + + fprintf(stderr, "cannot invoke compiler, this is a serious bug\n"); + return 1; +} diff --git a/nixpkgs/pkgs/development/compilers/ispc/default.nix b/nixpkgs/pkgs/development/compilers/ispc/default.nix new file mode 100644 index 000000000000..2657ee6633b7 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/ispc/default.nix @@ -0,0 +1,73 @@ +{stdenv, fetchFromGitHub, fetchpatch, which, m4, python, bison, flex, llvmPackages, +testedTargets ? ["sse2" "host"] # the default test target is sse4, but that is not supported by all Hydra agents +}: + +stdenv.mkDerivation rec { + version = "1.10.0"; + rev = "v${version}"; + + inherit testedTargets; + + name = "ispc-${version}"; + + src = fetchFromGitHub { + owner = "ispc"; + repo = "ispc"; + inherit rev; + sha256 = "1x07n2gaff3v32yvddrb659mx5gg12bnbsqbyfimp396wn04w60b"; + }; + + # there are missing dependencies in the Makefile, causing sporadic build failures + enableParallelBuilding = false; + + doCheck = true; + + buildInputs = with llvmPackages; [ + which + m4 + python + bison + flex + llvm + llvmPackages.clang-unwrapped # we need to link against libclang, so we need the unwrapped + ]; + + postPatch = "sed -i -e 's,/bin/,,g' -e 's/-lcurses/-lncurses/g' Makefile"; + + # TODO: this correctly catches errors early, but also some things that are just weird and don't seem to be real + # errors + #configurePhase = '' + # makeFlagsArray=( SHELL="${bash}/bin/bash -o pipefail" ) + #''; + + installPhase = '' + mkdir -p $out/bin + cp ispc $out/bin + ''; + + checkPhase = '' + export ISPC_HOME=$PWD + for target in $testedTargets + do + echo "Testing target $target" + echo "================================" + echo + PATH=${llvmPackages.clang}/bin:$PATH python run_tests.py -t $target --non-interactive --verbose --file=test_output.log + fgrep -q "No new fails" test_output.log || exit 1 + done + ''; + + makeFlags = [ + "CXX=${stdenv.cc}/bin/clang++" + "CLANG=${stdenv.cc}/bin/clang" + "CLANG_INCLUDE=${llvmPackages.clang-unwrapped}/include" + ]; + + meta = with stdenv.lib; { + homepage = https://ispc.github.io/ ; + description = "Intel 'Single Program, Multiple Data' Compiler, a vectorised language"; + license = licenses.bsd3; + platforms = ["x86_64-linux"]; # TODO: buildable on more platforms? + maintainers = [ maintainers.aristid ]; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/javacard-devkit/default.nix b/nixpkgs/pkgs/development/compilers/javacard-devkit/default.nix new file mode 100644 index 000000000000..06f321bc39c4 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/javacard-devkit/default.nix @@ -0,0 +1,70 @@ +{ stdenv, requireFile, unzip, makeWrapper, oraclejdk8, autoPatchelfHook +, pcsclite +}: + +stdenv.mkDerivation rec { + name = "${pname}-${version}"; + pname = "javacard-devkit"; + version = "2.2.2"; + uscoreVersion = builtins.replaceStrings ["."] ["_"] version; + + src = requireFile { + name = "java_card_kit-${uscoreVersion}-linux.zip"; + url = "http://www.oracle.com/technetwork/java/javasebusiness/downloads/" + + "java-archive-downloads-javame-419430.html#java_card_kit-2.2.2-oth-JPR"; + sha256 = "1rzkw8izqq73ifvyp937wnjjc40a40drc4zsm0l1s6jyv3d7agb2"; + }; + + nativeBuildInputs = [ unzip oraclejdk8 makeWrapper autoPatchelfHook ]; + buildInputs = [ pcsclite ]; + + zipPrefix = "java_card_kit-${uscoreVersion}"; + + sourceRoot = "."; + unpackCmd = '' + unzip -p "$curSrc" "$zipPrefix/$zipPrefix-rr-bin-linux-do.zip" | jar x + ''; + + installPhase = '' + mkdir -p "$out/share/$pname" + cp -rt "$out/share/$pname" api_export_files + cp -rt "$out" lib + + for i in bin/*; do + case "$i" in + *.so) install -vD "$i" "$out/libexec/$pname/$(basename "$i")";; + *) target="$out/bin/$(basename "$i")" + install -vD "$i" "$target" + sed -i -e 's|^$JAVA_HOME/bin/java|''${JAVA:-$JAVA_HOME/bin/java}|' "$target" + wrapProgram "$target" \ + --set JAVA_HOME "$JAVA_HOME" \ + --prefix CLASSPATH : "$out/share/$pname/api_export_files" + ;; + esac + done + + makeWrapper "$JAVA_HOME/bin/javac" "$out/bin/javacardc" \ + --prefix CLASSPATH : "$out/lib/api.jar" + ''; + + meta = { + description = "Official development kit by Oracle for programming for the Java Card platform"; + longDescription = '' + This Java Card SDK is the official SDK made available by Oracle for programming for the Java Card platform. + + Instructions for usage: + + First, compile your '.java' (NixOS-specific: you should not need to set the class path -- if you need, it's a bug): + javacardc -source 1.5 -target 1.5 [MyJavaFile].java + Then, test with 'jcwde' (NixOS-specific: you can change the java version used to run jcwde with eg. JAVA=jdb): + CLASSPATH=. jcwde [MyJcwdeConfig].app & sleep 1 && apdutool [MyApdus].apdu + Finally, convert the '.class' file into a '.cap': + converter -applet [AppletAID] [MyApplet] [myPackage] [PackageAID] [Version] + For more details, please refer to the documentation by Oracle + ''; + homepage = https://www.oracle.com/technetwork/java/embedded/javacard/overview/index.html; + license = stdenv.lib.licenses.unfree; + maintainers = [ stdenv.lib.maintainers.ekleog ]; + platforms = [ "i686-linux" "x86_64-linux" ]; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/jetbrains-jdk/default.nix b/nixpkgs/pkgs/development/compilers/jetbrains-jdk/default.nix new file mode 100644 index 000000000000..08e3ec4f445f --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/jetbrains-jdk/default.nix @@ -0,0 +1,67 @@ +{ stdenv, lib, fetchurl, file, glib, libxml2, libav_0_8, ffmpeg, libxslt +, libGL , xorg, alsaLib, fontconfig, freetype, pango, gtk2, cairo +, gdk_pixbuf, atk, zlib }: + +# TODO: Investigate building from source instead of patching binaries. +# TODO: Binary patching for not just x86_64-linux but also x86_64-darwin i686-linux + +let drv = stdenv.mkDerivation rec { + pname = "jetbrainsjdk"; + version = "164"; + name = pname + "-" + version; + + src = if stdenv.hostPlatform.system == "x86_64-linux" then + fetchurl { + url = "https://bintray.com/jetbrains/intellij-jdk/download_file?file_path=jbrsdk-11_0_2-linux-x64-b${version}.tar.gz"; + sha256 = "121yzgvkfx7lq0k9s8wjnhz09a564br5y7zlkxgh191sbm2i7zdi"; + } + else + throw "unsupported system: ${stdenv.hostPlatform.system}"; + + nativeBuildInputs = [ file ]; + + unpackCmd = "mkdir jdk; pushd jdk; tar -xzf $src; popd"; + + installPhase = '' + cd .. + + mv $sourceRoot $out + jrePath=$out/jre + ''; + + postFixup = '' + find $out -type f -perm -0100 \ + -exec patchelf --interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \ + --set-rpath "$rpath" {} \; + find $out -name "*.so" -exec patchelf --set-rpath "$rpath" {} \; + ''; + + rpath = lib.makeLibraryPath ([ + stdenv.cc.cc stdenv.cc.libc glib libxml2 libav_0_8 ffmpeg libxslt libGL + alsaLib fontconfig freetype pango gtk2 cairo gdk_pixbuf atk zlib + (placeholder "out") + ] ++ (with xorg; [ + libX11 libXext libXtst libXi libXp libXt libXrender libXxf86vm + ])) + ":${placeholder "out"}/lib/jli"; + + passthru.home = drv; + + meta = with stdenv.lib; { + description = "An OpenJDK fork to better support Jetbrains's products."; + longDescription = '' + JetBrains Runtime is a runtime environment for running IntelliJ Platform + based products on Windows, Mac OS X, and Linux. JetBrains Runtime is + based on OpenJDK project with some modifications. These modifications + include: Subpixel Anti-Aliasing, enhanced font rendering on Linux, HiDPI + support, ligatures, some fixes for native crashes not presented in + official build, and other small enhancements. + + JetBrains Runtime is not a certified build of OpenJDK. Please, use at + your own risk. + ''; + homepage = "https://bintray.com/jetbrains/intellij-jdk/"; + license = licenses.gpl2; + maintainers = with maintainers; [ edwtjo ]; + platforms = with platforms; [ "x86_64-linux" ]; + }; +}; in drv diff --git a/nixpkgs/pkgs/development/compilers/jikes/default.nix b/nixpkgs/pkgs/development/compilers/jikes/default.nix new file mode 100644 index 000000000000..1247f369c5c9 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/jikes/default.nix @@ -0,0 +1,14 @@ +{stdenv, fetchurl}: + +stdenv.mkDerivation { + name = "jikes-1.22"; + src = fetchurl { + url = mirror://sourceforge/jikes/jikes-1.22.tar.bz2; + sha256 = "1qqldrp74pzpy5ly421srqn30qppmm9cvjiqdngk8hf47dv2rc0c"; + }; + + meta = { + platforms = stdenv.lib.platforms.unix; + license = stdenv.lib.licenses.epl10; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/jsonnet/default.nix b/nixpkgs/pkgs/development/compilers/jsonnet/default.nix new file mode 100644 index 000000000000..6104ffc7aaa3 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/jsonnet/default.nix @@ -0,0 +1,35 @@ +{ stdenv, lib, fetchFromGitHub }: + +stdenv.mkDerivation rec { + name = "jsonnet-${version}"; + version = "0.12.1"; + + src = fetchFromGitHub { + rev = "v${version}"; + owner = "google"; + repo = "jsonnet"; + sha256 = "13a0sf1k8ivxhc28w0d0axzr0sj3jccl9sjq6l0dkyzrnmbxzmkb"; + }; + + enableParallelBuilding = true; + + makeFlags = [ + "jsonnet" + "libjsonnet.so" + ]; + + installPhase = '' + mkdir -p $out/bin $out/lib $out/include + cp jsonnet $out/bin/ + cp libjsonnet*.so $out/lib/ + cp -a include/*.h $out/include/ + ''; + + meta = { + description = "Purely-functional configuration language that helps you define JSON data"; + maintainers = with lib.maintainers; [ benley copumpkin ]; + license = lib.licenses.asl20; + homepage = https://github.com/google/jsonnet; + platforms = lib.platforms.unix; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/julia/0.7.nix b/nixpkgs/pkgs/development/compilers/julia/0.7.nix new file mode 100644 index 000000000000..e0992d800033 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/julia/0.7.nix @@ -0,0 +1,9 @@ +import ./shared.nix { + majorVersion = "0"; + minorVersion = "7"; + maintenanceVersion = "0"; + src_sha256 = "1j57569qm2ii8ddzsp08hds2navpk7acdz83kh27dvk44axhwj6f"; + + libuvVersion = "ed3700c849289ed01fe04273a7bf865340b2bd7e"; + libuvSha256 = "137w666zsjw1p0ma3lf94d75hr1q45sgkfmbizkyji2qm57cnxjs"; +} diff --git a/nixpkgs/pkgs/development/compilers/julia/0001.1-use-system-utf8proc.patch b/nixpkgs/pkgs/development/compilers/julia/0001.1-use-system-utf8proc.patch new file mode 100644 index 000000000000..be4391399f55 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/julia/0001.1-use-system-utf8proc.patch @@ -0,0 +1,29 @@ +From 54a66b5728ec98f44a1768f064509be4fd3f2ef6 Mon Sep 17 00:00:00 2001 +From: Thomas Tuegel <ttuegel@gmail.com> +Date: Sat, 10 Oct 2015 13:09:48 -0500 +Subject: [PATCH 1/3] use system utf8proc + +--- + src/flisp/Makefile | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/src/flisp/Makefile b/src/flisp/Makefile +index bec8624..5437b5c 100644 +--- a/src/flisp/Makefile ++++ b/src/flisp/Makefile +@@ -24,9 +24,9 @@ DOBJS = $(SRCS:%.c=$(BUILDDIR)/%.dbg.obj) + LLTDIR := ../support + LLT_release := $(BUILDDIR)/$(LLTDIR)/libsupport.a + LLT_debug := $(BUILDDIR)/$(LLTDIR)/libsupport-debug.a +-LIBFILES_release := $(LLT_release) $(LIBUV) $(LIBUTF8PROC) +-LIBFILES_debug := $(LLT_debug) $(LIBUV) $(LIBUTF8PROC) +-LIBS := ++LIBFILES_release := $(LLT_release) $(LIBUV) ++LIBFILES_debug := $(LLT_debug) $(LIBUV) ++LIBS := $(LIBUTF8PROC) + ifneq ($(OS),WINNT) + LIBS += -lpthread + endif +-- +2.5.2 + diff --git a/nixpkgs/pkgs/development/compilers/julia/1.0.nix b/nixpkgs/pkgs/development/compilers/julia/1.0.nix new file mode 100644 index 000000000000..a679eda33066 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/julia/1.0.nix @@ -0,0 +1,9 @@ +import ./shared.nix { + majorVersion = "1"; + minorVersion = "0"; + maintenanceVersion = "3"; + src_sha256 = "0666chsc19wx02k5m1yilf6wbc9bw27ay8p1d00jkh8m0jkrpf7l"; + + libuvVersion = "ed3700c849289ed01fe04273a7bf865340b2bd7e"; + libuvSha256 = "137w666zsjw1p0ma3lf94d75hr1q45sgkfmbizkyji2qm57cnxjs"; +} diff --git a/nixpkgs/pkgs/development/compilers/julia/1.1.nix b/nixpkgs/pkgs/development/compilers/julia/1.1.nix new file mode 100644 index 000000000000..a868f949d27c --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/julia/1.1.nix @@ -0,0 +1,9 @@ +import ./shared.nix { + majorVersion = "1"; + minorVersion = "1"; + maintenanceVersion = "0"; + src_sha256 = "08fyck4qcdv9nnrdqh1wb7lb8pkkikh67xx5lc872sjl9w3p0sak"; + + libuvVersion = "2348256acf5759a544e5ca7935f638d2bc091d60"; + libuvSha256 = "1363f4vqayfcv5zqg07qmzjff56yhad74k16c22ian45lram8mv8"; +} diff --git a/nixpkgs/pkgs/development/compilers/julia/allow_nix_mtime.patch b/nixpkgs/pkgs/development/compilers/julia/allow_nix_mtime.patch new file mode 100644 index 000000000000..e4a164cfa1ad --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/julia/allow_nix_mtime.patch @@ -0,0 +1,25 @@ +From f79775378a9eeec5b99f18cc95735b12d172aba3 Mon Sep 17 00:00:00 2001 +From: Tom McLaughlin <pyro777@gmail.com> +Date: Wed, 12 Dec 2018 13:01:32 -0800 +Subject: [PATCH] Patch to make work better with nix + +--- + base/loading.jl | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/base/loading.jl b/base/loading.jl +index 51201b98b6..b40c0690f6 100644 +--- a/base/loading.jl ++++ b/base/loading.jl +@@ -1384,7 +1384,7 @@ function stale_cachefile(modpath::String, cachefile::String) + # Issue #13606: compensate for Docker images rounding mtimes + # Issue #20837: compensate for GlusterFS truncating mtimes to microseconds + ftime = mtime(f) +- if ftime != ftime_req && ftime != floor(ftime_req) && ftime != trunc(ftime_req, digits=6) ++ if ftime != ftime_req && ftime != floor(ftime_req) && ftime != trunc(ftime_req, digits=6) && ftime != 1.0 + @debug "Rejecting stale cache file $cachefile (mtime $ftime_req) because file $f (mtime $ftime) has changed" + return true + end +-- +2.17.1 + diff --git a/nixpkgs/pkgs/development/compilers/julia/shared.nix b/nixpkgs/pkgs/development/compilers/julia/shared.nix new file mode 100644 index 000000000000..6706cf1e2bd4 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/julia/shared.nix @@ -0,0 +1,226 @@ +{ majorVersion +, minorVersion +, maintenanceVersion +, src_sha256 +# source deps +, libuvVersion +, libuvSha256 +}: +{ stdenv, fetchurl, fetchzip +# build tools +, gfortran, m4, makeWrapper, patchelf, perl, which, python2 +, llvm, cmake +# libjulia dependencies +, libunwind, readline, utf8proc, zlib +# standard library dependencies +, curl, fftwSinglePrec, fftw, gmp, libgit2, mpfr, openlibm, openspecfun, pcre2 +# linear algebra +, openblas, arpack +# Darwin frameworks +, CoreServices, ApplicationServices +}: + +with stdenv.lib; + +# All dependencies must use the same OpenBLAS. +let + arpack_ = arpack; +in +let + arpack = arpack_.override { inherit openblas; }; +in + +let + dsfmtVersion = "2.2.3"; + dsfmt = fetchurl { + url = "http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/SFMT/dSFMT-src-${dsfmtVersion}.tar.gz"; + sha256 = "03kaqbjbi6viz0n33dk5jlf6ayxqlsq4804n7kwkndiga9s4hd42"; + }; + + libuv = fetchurl { + url = "https://api.github.com/repos/JuliaLang/libuv/tarball/${libuvVersion}"; + sha256 = libuvSha256; + }; + + rmathVersion = "0.1"; + rmath-julia = fetchurl { + url = "https://api.github.com/repos/JuliaLang/Rmath-julia/tarball/v${rmathVersion}"; + sha256 = "1qyps217175qhid46l8f5i1v8i82slgp23ia63x2hzxwfmx8617p"; + }; + + virtualenvVersion = "15.0.0"; + virtualenv = fetchurl { + url = "mirror://pypi/v/virtualenv/virtualenv-${virtualenvVersion}.tar.gz"; + sha256 = "06fw4liazpx5vf3am45q2pdiwrv0id7ckv7n6zmpml29x6vkzmkh"; + }; + + libwhichVersion = "81e9723c0273d78493dc8c8ed570f68d9ce7e89e"; + libwhich = fetchurl { + url = "https://api.github.com/repos/vtjnash/libwhich/tarball/${libwhichVersion}"; + sha256 = "1p7zg31kpmpbmh1znrk1xrbd074agx13b9q4dcw8n2zrwwdlbz3b"; + }; + + llvmVersion = "6.0.0"; + llvm = fetchurl { + url = "http://releases.llvm.org/6.0.0/llvm-${llvmVersion}.src.tar.xz"; + sha256 = "0224xvfg6h40y5lrbnb9qaq3grmdc5rg00xq03s1wxjfbf8krx8z"; + }; + + suitesparseVersion = "4.4.5"; + suitesparse = fetchurl { + url = "http://faculty.cse.tamu.edu/davis/SuiteSparse/SuiteSparse-${suitesparseVersion}.tar.gz"; + sha256 = "1jcbxb8jx5wlcixzf6n5dca2rcfx6mlcms1k2rl5gp67ay3bix43"; + }; + version = "${majorVersion}.${minorVersion}.${maintenanceVersion}"; +in + +stdenv.mkDerivation rec { + pname = "julia"; + inherit version; + name = "${pname}-${version}"; + + src = fetchzip { + url = "https://github.com/JuliaLang/${pname}/releases/download/v${version}/${name}.tar.gz"; + sha256 = src_sha256; + }; + prePatch = '' + export PATH=$PATH:${cmake}/bin + mkdir deps/srccache + cp "${dsfmt}" "./deps/srccache/dsfmt-${dsfmtVersion}.tar.gz" + cp "${rmath-julia}" "./deps/srccache/Rmath-julia-${rmathVersion}.tar.gz" + cp "${libuv}" "./deps/srccache/libuv-${libuvVersion}.tar.gz" + cp "${virtualenv}" "./deps/srccache/virtualenv-${virtualenvVersion}.tar.gz" + cp "${libwhich}" "./deps/srccache/libwhich-${libwhichVersion}.tar.gz" + cp "${llvm}" "./deps/srccache/llvm-${llvmVersion}.src.tar.xz" + cp "${suitesparse}" "./deps/srccache/SuiteSparse-${suitesparseVersion}.tar.gz" + ''; + + patches = [ + ./0001.1-use-system-utf8proc.patch + + # Julia recompiles a precompiled file if the mtime stored *in* the + # .ji file differs from the mtime of the .ji file. This + # doesn't work in Nix because Nix changes the mtime of files in + # the Nix store to 1. So patch Julia to accept mtimes of 1. + ./allow_nix_mtime.patch + ]; + + postPatch = '' + patchShebangs . contrib + for i in backtrace cmdlineargs; do + mv test/$i.jl{,.off} + touch test/$i.jl + done + rm stdlib/Sockets/test/runtests.jl && touch stdlib/Sockets/test/runtests.jl + rm stdlib/Distributed/test/runtests.jl && touch stdlib/Distributed/test/runtests.jl + sed -e 's/Invalid Content-Type:/invalid Content-Type:/g' -i ./stdlib/LibGit2/test/libgit2.jl + sed -e 's/Failed to resolve /failed to resolve /g' -i ./stdlib/LibGit2/test/libgit2.jl + ''; + + buildInputs = [ + arpack fftw fftwSinglePrec gmp libgit2 libunwind mpfr + pcre2.dev openblas openlibm openspecfun readline utf8proc + zlib + ] + ++ stdenv.lib.optionals stdenv.isDarwin [CoreServices ApplicationServices] + ; + + nativeBuildInputs = [ curl gfortran m4 makeWrapper patchelf perl python2 which ]; + + makeFlags = + let + arch = head (splitString "-" stdenv.system); + march = { "x86_64" = stdenv.hostPlatform.platform.gcc.arch or "x86-64"; "i686" = "pentium4"; }."${arch}" + or (throw "unsupported architecture: ${arch}"); + # Julia requires Pentium 4 (SSE2) or better + cpuTarget = { "x86_64" = "x86-64"; "i686" = "pentium4"; }."${arch}" + or (throw "unsupported architecture: ${arch}"); + in [ + "ARCH=${arch}" + "MARCH=${march}" + "JULIA_CPU_TARGET=${cpuTarget}" + "PREFIX=$(out)" + "prefix=$(out)" + "SHELL=${stdenv.shell}" + + "USE_SYSTEM_BLAS=1" + "USE_BLAS64=${if openblas.blas64 then "1" else "0"}" + "LIBBLAS=-lopenblas" + "LIBBLASNAME=libopenblas" + + "USE_SYSTEM_LAPACK=1" + "LIBLAPACK=-lopenblas" + "LIBLAPACKNAME=libopenblas" + + "USE_SYSTEM_ARPACK=1" + "USE_SYSTEM_FFTW=1" + "USE_SYSTEM_GMP=1" + "USE_SYSTEM_LIBGIT2=1" + "USE_SYSTEM_LIBUNWIND=1" + + #"USE_SYSTEM_LLVM=1" + "LLVM_VER=6.0.0" + + "USE_SYSTEM_MPFR=1" + "USE_SYSTEM_OPENLIBM=1" + "USE_SYSTEM_OPENSPECFUN=1" + "USE_SYSTEM_PATCHELF=1" + "USE_SYSTEM_PCRE=1" + "PCRE_CONFIG=${pcre2.dev}/bin/pcre2-config" + "PCRE_INCL_PATH=${pcre2.dev}/include/pcre2.h" + "USE_SYSTEM_READLINE=1" + "USE_SYSTEM_UTF8PROC=1" + "USE_SYSTEM_ZLIB=1" + ]; + + NIX_CFLAGS_COMPILE = [ "-fPIC" ]; + + LD_LIBRARY_PATH = makeLibraryPath [ + arpack fftw fftwSinglePrec gmp libgit2 mpfr openblas openlibm + openspecfun pcre2 + ]; + + dontStrip = true; + dontPatchELF = true; + + enableParallelBuilding = true; + + doCheck = !stdenv.isDarwin; + checkTarget = "testall"; + # Julia's tests require read/write access to $HOME + preCheck = '' + export HOME="$NIX_BUILD_TOP" + ''; + + preBuild = '' + sed -e '/^install:/s@[^ ]*/doc/[^ ]*@@' -i Makefile + sed -e '/[$](DESTDIR)[$](docdir)/d' -i Makefile + export LD_LIBRARY_PATH=${LD_LIBRARY_PATH} + ''; + + postInstall = '' + # Symlink shared libraries from LD_LIBRARY_PATH into lib/julia, + # as using a wrapper with LD_LIBRARY_PATH causes segmentation + # faults when program returns an error: + # $ julia -e 'throw(Error())' + find $(echo $LD_LIBRARY_PATH | sed 's|:| |g') -maxdepth 1 -name '*.${if stdenv.isDarwin then "dylib" else "so"}*' | while read lib; do + if [[ ! -e $out/lib/julia/$(basename $lib) ]]; then + ln -sv $lib $out/lib/julia/$(basename $lib) + fi + done + ''; + + passthru = { + inherit majorVersion minorVersion maintenanceVersion; + site = "share/julia/site/v${majorVersion}.${minorVersion}"; + }; + + meta = { + description = "High-level performance-oriented dynamical language for technical computing"; + homepage = https://julialang.org/; + license = stdenv.lib.licenses.mit; + maintainers = with stdenv.lib.maintainers; [ raskin rob garrison ]; + platforms = [ "i686-linux" "x86_64-linux" "x86_64-darwin" ]; + broken = stdenv.isi686; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/jwasm/default.nix b/nixpkgs/pkgs/development/compilers/jwasm/default.nix new file mode 100644 index 000000000000..9800b33e7a9e --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/jwasm/default.nix @@ -0,0 +1,27 @@ +{ stdenv, fetchFromGitHub +, cmake }: + +with stdenv.lib; +stdenv.mkDerivation rec { + name = "jwasm-${version}"; + version = "git-2017-11-22"; + + src = fetchFromGitHub { + owner = "JWasm"; + repo = "JWasm"; + rev = "26f97c8b5c9d9341ec45538701116fa3649b7766"; + sha256 = "0m972pc8vk8s9yv1pi85fsjgm6hj24gab7nalw2q04l0359nqi7w"; + }; + + nativeBuildInputs = [ cmake ]; + + installPhase = "mkdir -p $out/bin ; cp jwasm $out/bin/"; + + meta = { + description = "A MASM-compatible x86 assembler"; + homepage = http://jwasm.github.io/; + license = licenses.gpl2Plus; + maintainers = with maintainers; [ AndersonTorres ]; + platforms = platforms.darwin ++ platforms.linux; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/kotlin/default.nix b/nixpkgs/pkgs/development/compilers/kotlin/default.nix new file mode 100644 index 000000000000..87c798c8d382 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/kotlin/default.nix @@ -0,0 +1,46 @@ +{ stdenv, fetchurl, makeWrapper, jre, unzip }: + +let + version = "1.3.31"; +in stdenv.mkDerivation rec { + inherit version; + name = "kotlin-${version}"; + + src = fetchurl { + url = "https://github.com/JetBrains/kotlin/releases/download/v${version}/kotlin-compiler-${version}.zip"; + sha256 = "0sldhjxh2ghzwkabgziyiq4609iws0vninr8zxclzbqmcgajawqh"; + }; + + propagatedBuildInputs = [ jre ] ; + buildInputs = [ makeWrapper unzip ] ; + + installPhase = '' + mkdir -p $out + rm "bin/"*.bat + mv * $out + + for p in $(ls $out/bin/) ; do + wrapProgram $out/bin/$p --prefix PATH ":" ${jre}/bin ; + done + + if [ -f $out/LICENSE ]; then + install -D $out/LICENSE $out/share/kotlin/LICENSE + rm $out/LICENSE + fi + ''; + + meta = { + description = "General purpose programming language"; + longDescription = '' + Kotlin is a statically typed language that targets the JVM and JavaScript. + It is a general-purpose language intended for industry use. + It is developed by a team at JetBrains although it is an OSS language + and has external contributors. + ''; + homepage = https://kotlinlang.org/; + license = stdenv.lib.licenses.asl20; + maintainers = with stdenv.lib.maintainers; + [ nequissimus ]; + platforms = stdenv.lib.platforms.all; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/ldc/default.nix b/nixpkgs/pkgs/development/compilers/ldc/default.nix new file mode 100644 index 000000000000..71473be580ea --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/ldc/default.nix @@ -0,0 +1,190 @@ +{ stdenv, fetchurl, cmake, ninja, llvm, llvm_8, curl, tzdata +, python, libconfig, lit, gdb, unzip, darwin, bash +, callPackage, makeWrapper, targetPackages +, bootstrapVersion ? false +, version ? "1.15.0" +, ldcSha256 ? "1qnfy2q8zkywvby7wa8jm20mlpghn28x6w357cpc8hi56g7y1q6p" +}: + +let + bootstrapLdc = if !bootstrapVersion then + # LDC 0.17.x is the last version which doesn't need a working D compiler to + # build so we use that version to bootstrap the actual build. + callPackage ./default.nix { + bootstrapVersion = true; + version = "0.17.6"; + ldcSha256 = "0qf5kbxddgmg3kqzi0kf4bgv8vdrnv16y07hcpm0cwv9mc3qr2w6"; + } + else + ""; + +in + +stdenv.mkDerivation rec { + name = "ldc-${version}"; + + enableParallelBuilding = true; + + src = fetchurl { + url = "https://github.com/ldc-developers/ldc/releases/download/v${version}/ldc-${version}-src.tar.gz"; + sha256 = ldcSha256; + }; + + # https://issues.dlang.org/show_bug.cgi?id=19553 + hardeningDisable = [ "fortify" ]; + + postUnpack = '' + patchShebangs . + '' + + + stdenv.lib.optionalString (!bootstrapVersion) '' + rm ldc-${version}-src/tests/d2/dmd-testsuite/fail_compilation/mixin_gc.d + rm ldc-${version}-src/tests/d2/dmd-testsuite/runnable/xtest46_gc.d + rm ldc-${version}-src/tests/d2/dmd-testsuite/runnable/testptrref_gc.d + '' + + + stdenv.lib.optionalString (!bootstrapVersion && stdenv.hostPlatform.isDarwin) '' + # https://github.com/NixOS/nixpkgs/issues/34817 + rm -r ldc-${version}-src/tests/plugins/addFuncEntryCall + '' + + + stdenv.lib.optionalString (!bootstrapVersion) '' + echo ${tzdata}/share/zoneinfo/ > ldc-${version}-src/TZDatabaseDirFile + + echo ${curl.out}/lib/libcurl${stdenv.hostPlatform.extensions.sharedLibrary} > ldc-${version}-src/LibcurlPathFile + ''; + + postPatch = '' + # Setting SHELL=$SHELL when dmd testsuite is run doesn't work on Linux somehow + substituteInPlace tests/d2/dmd-testsuite/Makefile --replace "SHELL=/bin/bash" "SHELL=${bash}/bin/bash" + '' + + + stdenv.lib.optionalString (!bootstrapVersion && stdenv.hostPlatform.isLinux) '' + substituteInPlace runtime/phobos/std/socket.d --replace "assert(ih.addrList[0] == 0x7F_00_00_01);" "" + '' + + + stdenv.lib.optionalString (!bootstrapVersion && stdenv.hostPlatform.isDarwin) '' + substituteInPlace runtime/phobos/std/socket.d --replace "foreach (name; names)" "names = []; foreach (name; names)" + '' + + + stdenv.lib.optionalString (bootstrapVersion && stdenv.hostPlatform.isDarwin) '' + # Was not able to compile on darwin due to "__inline_isnanl" + # being undefined. + # TODO Remove with version > 0.17.6 + substituteInPlace dmd2/root/port.c --replace __inline_isnanl __inline_isnan + ''; + + nativeBuildInputs = [ cmake ninja makeWrapper unzip ] + + ++ stdenv.lib.optional (!bootstrapVersion) [ + bootstrapLdc python lit + ] + + ++ stdenv.lib.optional (!bootstrapVersion && stdenv.hostPlatform.isDarwin) [ + # https://github.com/NixOS/nixpkgs/issues/57120 + # https://github.com/NixOS/nixpkgs/pull/59197#issuecomment-481972515 + llvm + ] + + ++ stdenv.lib.optional (!bootstrapVersion && !stdenv.hostPlatform.isDarwin) [ + llvm_8 + ] + + ++ stdenv.lib.optional (!bootstrapVersion && !stdenv.hostPlatform.isDarwin) [ + # https://github.com/NixOS/nixpkgs/pull/36378#issuecomment-385034818 + gdb + ] + + ++ stdenv.lib.optional (bootstrapVersion) [ + libconfig llvm + ] + + ++ stdenv.lib.optional stdenv.hostPlatform.isDarwin (with darwin.apple_sdk.frameworks; [ + Foundation + ]); + + + buildInputs = [ curl tzdata ]; + + cmakeFlagsString = stdenv.lib.optionalString (!bootstrapVersion) '' + "-DD_FLAGS=-d-version=TZDatabaseDir;-d-version=LibcurlPath;-J$PWD" + "-DCMAKE_BUILD_TYPE=Release" + ''; + + preConfigure = stdenv.lib.optionalString (!bootstrapVersion) '' + cmakeFlagsArray=( + ${cmakeFlagsString} + ) + ''; + + postConfigure = '' + export DMD=$PWD/bin/ldmd2 + ''; + + makeFlags = [ "DMD=$DMD" ]; + + fixNames = if stdenv.hostPlatform.isDarwin then '' + fixDarwinDylibNames() { + local flags=() + + for fn in "$@"; do + flags+=(-change "$(basename "$fn")" "$fn") + done + + for fn in "$@"; do + if [ -L "$fn" ]; then continue; fi + echo "$fn: fixing dylib" + install_name_tool -id "$fn" "''${flags[@]}" "$fn" + done + } + + fixDarwinDylibNames $(find "$(pwd)/lib" -name "*.dylib") + export DYLD_LIBRARY_PATH=$(pwd)/lib + '' + else + ""; + + # https://github.com/ldc-developers/ldc/issues/2497#issuecomment-459633746 + additionalExceptions = if stdenv.hostPlatform.isDarwin then + "|druntime-test-shared" + else + ""; + + doCheck = !bootstrapVersion; + + checkPhase = stdenv.lib.optionalString doCheck '' + # Build default lib test runners + ninja -j$NIX_BUILD_CORES all-test-runners + + ${fixNames} + + # Run dmd testsuite + export DMD_TESTSUITE_MAKE_ARGS="-j$NIX_BUILD_CORES DMD=$DMD CC=$CXX" + ctest -V -R "dmd-testsuite" + + # Build and run LDC D unittests. + ctest --output-on-failure -R "ldc2-unittest" + + # Run LIT testsuite. + ctest -V -R "lit-tests" + + # Run default lib unittests + ctest -j$NIX_BUILD_CORES --output-on-failure -E "ldc2-unittest|lit-tests|dmd-testsuite${additionalExceptions}" + ''; + + postInstall = '' + wrapProgram $out/bin/ldc2 \ + --prefix PATH ":" "${targetPackages.stdenv.cc}/bin" \ + --set-default CC "${targetPackages.stdenv.cc}/bin/cc" + ''; + + meta = with stdenv.lib; { + description = "The LLVM-based D compiler"; + homepage = https://github.com/ldc-developers/ldc; + # from https://github.com/ldc-developers/ldc/blob/master/LICENSE + license = with licenses; [ bsd3 boost mit ncsa gpl2Plus ]; + maintainers = with maintainers; [ ThomasMader ]; + platforms = [ "x86_64-linux" "i686-linux" "x86_64-darwin" ]; + }; +} + diff --git a/nixpkgs/pkgs/development/compilers/llvm/3.5/clang-purity.patch b/nixpkgs/pkgs/development/compilers/llvm/3.5/clang-purity.patch new file mode 100644 index 000000000000..dc3b54e304fc --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/3.5/clang-purity.patch @@ -0,0 +1,22 @@ +diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp +index 198e82e..810d006 100644 +--- a/lib/Driver/Tools.cpp ++++ b/lib/Driver/Tools.cpp +@@ -7355,17 +7355,6 @@ void gnutools::Link::ConstructJob(Compilation &C, const JobAction &JA, + CmdArgs.push_back("-shared"); + } + +- if (ToolChain.getArch() == llvm::Triple::arm || +- ToolChain.getArch() == llvm::Triple::armeb || +- ToolChain.getArch() == llvm::Triple::thumb || +- ToolChain.getArch() == llvm::Triple::thumbeb || +- (!Args.hasArg(options::OPT_static) && +- !Args.hasArg(options::OPT_shared))) { +- CmdArgs.push_back("-dynamic-linker"); +- CmdArgs.push_back(Args.MakeArgString( +- D.DyldPrefix + getLinuxDynamicLinker(Args, ToolChain))); +- } +- + CmdArgs.push_back("-o"); + CmdArgs.push_back(Output.getFilename()); + diff --git a/nixpkgs/pkgs/development/compilers/llvm/3.5/clang-separate-build.patch b/nixpkgs/pkgs/development/compilers/llvm/3.5/clang-separate-build.patch new file mode 100644 index 000000000000..5fb67f169f45 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/3.5/clang-separate-build.patch @@ -0,0 +1,8 @@ +diff -Naur clang-3.4-orig/tools/extra/CMakeLists.txt clang-3.4/tools/extra/CMakeLists.txt +--- clang-3.4-orig/tools/extra/CMakeLists.txt 2013-11-07 19:08:23.000000000 -0500 ++++ clang-3.4/tools/extra/CMakeLists.txt 2014-01-20 11:47:22.678435223 -0500 +@@ -1,3 +1,4 @@ ++include(CheckLibraryExists) + check_library_exists(edit el_init "" HAVE_LIBEDIT) + + add_subdirectory(clang-apply-replacements) diff --git a/nixpkgs/pkgs/development/compilers/llvm/3.5/clang.nix b/nixpkgs/pkgs/development/compilers/llvm/3.5/clang.nix new file mode 100644 index 000000000000..7e0163577baf --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/3.5/clang.nix @@ -0,0 +1,56 @@ +{ stdenv, fetch, cmake, libxml2, llvm, version, clang-tools-extra_src }: +let + gcc = if stdenv.cc.isGNU then stdenv.cc.cc else stdenv.cc.cc.gcc; +in stdenv.mkDerivation { + name = "clang-${version}"; + + unpackPhase = '' + unpackFile ${fetch "cfe" "0846h8vn3zlc00jkmvrmy88gc6ql6014c02l4jv78fpvfigmgssg"} + mv cfe-${version}.src clang + sourceRoot=$PWD/clang + unpackFile ${clang-tools-extra_src} + mv clang-tools-extra-* $sourceRoot/tools/extra + ''; + + buildInputs = [ cmake libxml2 llvm ]; + + cmakeFlags = [ + "-DCMAKE_CXX_FLAGS=-std=c++11" + ] ++ + # Maybe with compiler-rt this won't be needed? + (stdenv.lib.optional stdenv.isLinux "-DGCC_INSTALL_PREFIX=${gcc}") ++ + (stdenv.lib.optional (stdenv.cc.libc != null) "-DC_INCLUDE_DIRS=${stdenv.cc.libc}/include"); + + patches = [ ./clang-purity.patch ]; + + postPatch = '' + sed -i -e 's/Args.hasArg(options::OPT_nostdlibinc)/true/' lib/Driver/Tools.cpp + sed -i -e 's/DriverArgs.hasArg(options::OPT_nostdlibinc)/true/' lib/Driver/ToolChains.cpp + ''; + + # Clang expects to find LLVMgold in its own prefix + # Clang expects to find sanitizer libraries in its own prefix + postInstall = '' + if [ -e ${llvm}/lib/LLVMgold.so ]; then + ln -sv ${llvm}/lib/LLVMgold.so $out/lib + fi + + ln -sv ${llvm}/lib/clang/${version}/lib $out/lib/clang/${version}/ + ln -sv $out/bin/clang $out/bin/cpp + ''; + + enableParallelBuilding = true; + + passthru = { + isClang = true; + } // stdenv.lib.optionalAttrs stdenv.isLinux { + inherit gcc; + }; + + meta = { + description = "A c, c++, objective-c, and objective-c++ frontend for the llvm compiler"; + homepage = http://llvm.org/; + license = stdenv.lib.licenses.ncsa; + platforms = stdenv.lib.platforms.all; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/llvm/3.5/default.nix b/nixpkgs/pkgs/development/compilers/llvm/3.5/default.nix new file mode 100644 index 000000000000..b87fa747f145 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/3.5/default.nix @@ -0,0 +1,43 @@ +{ pkgs, newScope, stdenv, isl, fetchurl }: +let + callPackage = newScope (self // { inherit stdenv isl version fetch; }); + + version = "3.5.2"; + + fetch = fetch_v version; + fetch_v = ver: name: sha256: fetchurl { + url = "https://releases.llvm.org/${ver}/${name}-${ver}.src.tar.xz"; + inherit sha256; + }; + + compiler-rt_src = fetch "compiler-rt" "1hsdnzzdr5kglz6fnv3lcsjs222zjsy14y8ax9dy6zqysanplbal"; + clang-tools-extra_src = fetch "clang-tools-extra" "01607w6hdf1pjgaapn9fy6smk22i3d4ncqjlhk4xi55ifi6kf6pj"; + + self = { + llvm = callPackage ./llvm.nix rec { + version = "3.5.2"; + fetch = fetch_v version; + inherit compiler-rt_src; + }; + + clang = callPackage ./clang.nix rec { + version = "3.5.2"; + fetch = fetch_v version; + inherit clang-tools-extra_src; + }; + + lld = callPackage ./lld.nix {}; + + lldb = callPackage ./lldb.nix {}; + + polly = callPackage ./polly.nix {}; + + dragonegg = callPackage ./dragonegg.nix {}; + + libcxx = callPackage ./libc++ { stdenv = pkgs.clangStdenv; }; + + libcxxabi = callPackage ./libc++abi { stdenv = pkgs.clangStdenv; }; + + #openmp = callPackage ./openmp {}; + }; +in self diff --git a/nixpkgs/pkgs/development/compilers/llvm/3.5/dragonegg.nix b/nixpkgs/pkgs/development/compilers/llvm/3.5/dragonegg.nix new file mode 100644 index 000000000000..d54ffd96382d --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/3.5/dragonegg.nix @@ -0,0 +1,26 @@ +{stdenv, fetch, llvm, gmp, mpfr, libmpc, ncurses, zlib, version}: + +stdenv.mkDerivation rec { + name = "dragonegg-${version}"; + + src = fetch "dragonegg" "1va4wv2b1dj0dpzsksnpnd0jic52q7pqj79w3m9jwdb58h7104dw"; + + # The gcc the plugin will be built for (the same used building dragonegg) + GCC = "gcc"; + + buildInputs = [ llvm gmp mpfr libmpc ncurses zlib ]; + + installPhase = '' + mkdir -p $out/lib $out/share/doc/${name} + cp -d dragonegg.so $out/lib + cp README COPYING $out/share/doc/${name} + ''; + + meta = { + homepage = http://dragonegg.llvm.org/; + description = "gcc plugin that replaces gcc's optimizers and code generators by those in LLVM"; + license = stdenv.lib.licenses.gpl2Plus; + maintainers = with stdenv.lib.maintainers; [viric]; + platforms = with stdenv.lib.platforms; linux; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/llvm/3.5/fix-15974.patch b/nixpkgs/pkgs/development/compilers/llvm/3.5/fix-15974.patch new file mode 100644 index 000000000000..446004cd9988 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/3.5/fix-15974.patch @@ -0,0 +1,15 @@ +diff --git a/include/llvm/ADT/IntrusiveRefCntPtr.h b/include/llvm/ADT/IntrusiveRefCntPtr.h +index f9df378..9d860ec 100644 +--- a/include/llvm/ADT/IntrusiveRefCntPtr.h ++++ b/include/llvm/ADT/IntrusiveRefCntPtr.h +@@ -134,9 +134,9 @@ public: + //===----------------------------------------------------------------------===// + template <typename T> + class IntrusiveRefCntPtr { ++ public: + T* Obj; + +- public: + typedef T element_type; + + explicit IntrusiveRefCntPtr() : Obj(nullptr) {} diff --git a/nixpkgs/pkgs/development/compilers/llvm/3.5/libc++/darwin.patch b/nixpkgs/pkgs/development/compilers/llvm/3.5/libc++/darwin.patch new file mode 100644 index 000000000000..bf83f169cfc3 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/3.5/libc++/darwin.patch @@ -0,0 +1,30 @@ +diff -ru -x '*~' libcxx-3.4.2.src-orig/lib/CMakeLists.txt libcxx-3.4.2.src/lib/CMakeLists.txt +--- libcxx-3.4.2.src-orig/lib/CMakeLists.txt 2013-11-15 18:18:57.000000000 +0100 ++++ libcxx-3.4.2.src/lib/CMakeLists.txt 2014-09-24 14:04:01.000000000 +0200 +@@ -56,7 +56,7 @@ + "-compatibility_version 1" + "-current_version ${LIBCXX_VERSION}" + "-install_name /usr/lib/libc++.1.dylib" +- "-Wl,-reexport_library,/usr/lib/libc++abi.dylib" ++ "-Wl,-reexport_library,${LIBCXX_LIBCXXABI_LIB_PATH}/libc++abi.dylib" + "-Wl,-unexported_symbols_list,${CMAKE_CURRENT_SOURCE_DIR}/libc++unexp.exp" + "/usr/lib/libSystem.B.dylib") + else() +@@ -64,14 +64,14 @@ + list(FIND ${CMAKE_OSX_ARCHITECTURES} "armv7" OSX_HAS_ARMV7) + if (OSX_HAS_ARMV7) + set(OSX_RE_EXPORT_LINE +- "${CMAKE_OSX_SYSROOT}/usr/lib/libc++abi.dylib" ++ "${CMAKE_OSX_SYSROOT}${LIBCXX_LIBCXXABI_LIB_PATH}/libc++abi.dylib" + "-Wl,-reexported_symbols_list,${CMAKE_CURRENT_SOURCE_DIR}/libc++sjlj-abi.exp") + else() + set(OSX_RE_EXPORT_LINE +- "-Wl,-reexport_library,${CMAKE_OSX_SYSROOT}/usr/lib/libc++abi.dylib") ++ "-Wl,-reexport_library,${CMAKE_OSX_SYSROOT}${LIBCXX_LIBCXXABI_LIB_PATH}/libc++abi.dylib") + endif() + else() +- set (OSX_RE_EXPORT_LINE "/usr/lib/libc++abi.dylib -Wl,-reexported_symbols_list,${CMAKE_CURRENT_SOURCE_DIR}/libc++abi${LIBCXX_LIBCPPABI_VERSION}.exp") ++ set (OSX_RE_EXPORT_LINE "${LIBCXX_LIBCXXABI_LIB_PATH}/libc++abi.dylib -Wl,-reexported_symbols_list,${CMAKE_CURRENT_SOURCE_DIR}/libc++abi${LIBCXX_LIBCPPABI_VERSION}.exp") + endif() + + list(APPEND link_flags diff --git a/nixpkgs/pkgs/development/compilers/llvm/3.5/libc++/default.nix b/nixpkgs/pkgs/development/compilers/llvm/3.5/libc++/default.nix new file mode 100644 index 000000000000..6edd5e9798c7 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/3.5/libc++/default.nix @@ -0,0 +1,53 @@ +{ lib, stdenv, fetchurl, cmake, libcxxabi, fixDarwinDylibNames }: + +let version = "3.5.2"; in + +stdenv.mkDerivation rec { + name = "libc++-${version}"; + + src = fetchurl { + url = "http://llvm.org/releases/${version}/libcxx-${version}.src.tar.xz"; + sha256 = "0irnl54fwzh2hzn9x4jfvnfyq5kd0zn0iwbzdivgwhqzw6fjdwdv"; + }; + + # instead of allowing libc++ to link with /usr/lib/libc++abi.dylib, + # force it to link with our copy + preConfigure = stdenv.lib.optionalString stdenv.isDarwin '' + substituteInPlace lib/CMakeLists.txt \ + --replace 'OSX_RE_EXPORT_LINE "/usr/lib/libc++abi.dylib' \ + 'OSX_RE_EXPORT_LINE "${libcxxabi}/lib/libc++abi.dylib' \ + --replace '"''${CMAKE_OSX_SYSROOT}/usr/lib/libc++abi.dylib"' \ + '"${libcxxabi}/lib/libc++abi.dylib"' + ''; + + patches = [ + ./darwin.patch + # glibc 2.26 fix + ./xlocale-glibc-2.26.patch + ]; + + buildInputs = [ cmake libcxxabi ] ++ lib.optional stdenv.isDarwin fixDarwinDylibNames; + + cmakeFlags = [ + "-DLIBCXX_LIBCXXABI_INCLUDE_PATHS=${libcxxabi}/include" + "-DLIBCXX_LIBCXXABI_LIB_PATH=${libcxxabi}/lib" + "-DLIBCXX_LIBCPPABI_VERSION=2" + "-DLIBCXX_CXX_ABI=libcxxabi" + ]; + + enableParallelBuilding = true; + + linkCxxAbi = stdenv.isLinux; + + setupHooks = [ + ../../../../../build-support/setup-hooks/role.bash + ./setup-hook.sh + ]; + + meta = { + homepage = http://libcxx.llvm.org/; + description = "A new implementation of the C++ standard library, targeting C++11"; + license = with stdenv.lib.licenses; [ ncsa mit ]; + platforms = stdenv.lib.platforms.unix; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/llvm/3.5/libc++/setup-hook.sh b/nixpkgs/pkgs/development/compilers/llvm/3.5/libc++/setup-hook.sh new file mode 100644 index 000000000000..6611259165ae --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/3.5/libc++/setup-hook.sh @@ -0,0 +1,6 @@ +# See pkgs/build-support/setup-hooks/role.bash +getHostRole + +linkCxxAbi="@linkCxxAbi@" +export NIX_${role_pre}CXXSTDLIB_COMPILE+=" -isystem @out@/include/c++/v1" +export NIX_${role_pre}CXXSTDLIB_LINK=" -stdlib=libc++${linkCxxAbi:+" -lc++abi"}" diff --git a/nixpkgs/pkgs/development/compilers/llvm/3.5/libc++/xlocale-glibc-2.26.patch b/nixpkgs/pkgs/development/compilers/llvm/3.5/libc++/xlocale-glibc-2.26.patch new file mode 100644 index 000000000000..250bb49fc231 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/3.5/libc++/xlocale-glibc-2.26.patch @@ -0,0 +1,17 @@ +diff --git a/include/__locale b/include/__locale +index 3daa1f1..cb8e151 100644 +--- a/include/__locale ++++ b/include/__locale +@@ -29,10 +29,10 @@ + # if __ANDROID_API__ <= 20 + # include <support/android/locale_bionic.h> + # endif +-#elif (defined(__GLIBC__) || defined(__APPLE__) || defined(__FreeBSD__) \ ++#elif (defined(__APPLE__) || defined(__FreeBSD__) \ + || defined(__sun__) || defined(__EMSCRIPTEN__) || defined(__IBMCPP__)) + # include <xlocale.h> +-#endif // __GLIBC__ || __APPLE__ || __FreeBSD__ || __sun__ || __EMSCRIPTEN__ || __IBMCPP__ ++#endif // __APPLE__ || __FreeBSD__ || __sun__ || __EMSCRIPTEN__ || __IBMCPP__ + + #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) + #pragma GCC system_header diff --git a/nixpkgs/pkgs/development/compilers/llvm/3.5/libc++abi/default.nix b/nixpkgs/pkgs/development/compilers/llvm/3.5/libc++abi/default.nix new file mode 100644 index 000000000000..268f2702a234 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/3.5/libc++abi/default.nix @@ -0,0 +1,59 @@ +{ stdenv, cmake, fetchurl, libcxx, libunwind, llvm }: + +let + version = "3.5.2"; + cmakeLists = fetchurl { + name = "CMakeLists.txt"; + url = "http://llvm.org/svn/llvm-project/libcxxabi/trunk/CMakeLists.txt?p=217324"; + sha256 = "10idgcbs4pcx6mjsbq1vjm8hzqqdk2p7k86cw9f473jmfyfwgf5j"; + }; +in stdenv.mkDerivation { + name = "libc++abi-${version}"; + + src = fetchurl { + url = "http://llvm.org/releases/${version}/libcxxabi-${version}.src.tar.xz"; + sha256 = "1c6rv0zx0na1w4hdmdfq2f6nj7limb7d1krrknwajxxkcn4yws92"; + }; + + buildInputs = [ cmake ] ++ stdenv.lib.optional (!stdenv.isDarwin) libunwind; + + postUnpack = '' + unpackFile ${libcxx.src} + unpackFile ${llvm.src} + echo cp ${cmakeLists} libcxxabi-*/CMakeLists.txt + cp ${cmakeLists} libcxxabi-*/CMakeLists.txt + export NIX_CFLAGS_COMPILE+=" -I$PWD/include" + export cmakeFlags="-DLLVM_PATH=$PWD/$(ls -d llvm-*) -DLIBCXXABI_LIBCXX_INCLUDES=$PWD/$(ls -d libcxx-*)/include" + '' + stdenv.lib.optionalString stdenv.isDarwin '' + export TRIPLE=x86_64-apple-darwin + ''; + + installPhase = if stdenv.isDarwin + then '' + for file in lib/*; do + # this should be done in CMake, but having trouble figuring out + # the magic combination of necessary CMake variables + # if you fancy a try, take a look at + # http://www.cmake.org/Wiki/CMake_RPATH_handling + install_name_tool -id $out/$file $file + done + make install + install -d 755 $out/include + install -m 644 ../include/cxxabi.h $out/include + '' + else '' + install -d -m 755 $out/include $out/lib + install -m 644 lib/libc++abi.so.1.0 $out/lib + install -m 644 $src/include/cxxabi.h $out/include + ln -s libc++abi.so.1.0 $out/lib/libc++abi.so + ln -s libc++abi.so.1.0 $out/lib/libc++abi.so.1 + ''; + + meta = { + homepage = http://libcxxabi.llvm.org/; + description = "A new implementation of low level support for a standard C++ library"; + license = with stdenv.lib.licenses; [ ncsa mit ]; + maintainers = with stdenv.lib.maintainers; [ vlstill ]; + platforms = stdenv.lib.platforms.unix; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/llvm/3.5/lld.nix b/nixpkgs/pkgs/development/compilers/llvm/3.5/lld.nix new file mode 100644 index 000000000000..4a398bd96a05 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/3.5/lld.nix @@ -0,0 +1,29 @@ +{ stdenv, fetch, cmake, llvm, ncurses, zlib, python, version }: + +stdenv.mkDerivation { + name = "lld-${version}"; + + src = fetch "lld" "1hpqawg1sc8mdqxqaxqmlzbrn69w1pkj8rxhjgqgmwra6c0xky89"; + + preUnpack = '' + # !!! Hopefully won't be needed for 3.5 + unpackFile ${llvm.src} + export cmakeFlags="$cmakeFlags -DLLD_PATH_TO_LLVM_SOURCE="`ls -d $PWD/llvm-*` + ''; + + buildInputs = [ cmake ncurses zlib python ]; + + cmakeFlags = [ + "-DCMAKE_CXX_FLAGS=-std=c++11" + "-DLLD_PATH_TO_LLVM_BUILD=${llvm}" + ]; + + enableParallelBuilding = true; + + meta = { + description = "A set of modular code for creating linker tools"; + homepage = http://llvm.org/; + license = stdenv.lib.licenses.ncsa; + platforms = stdenv.lib.platforms.all; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/llvm/3.5/lldb.nix b/nixpkgs/pkgs/development/compilers/llvm/3.5/lldb.nix new file mode 100644 index 000000000000..a5161333b282 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/3.5/lldb.nix @@ -0,0 +1,44 @@ +{ stdenv +, fetch +, cmake +, zlib +, ncurses +, swig +, which +, libedit +, llvm +, clang +, python +, version +}: + +stdenv.mkDerivation { + name = "lldb-${version}"; + + src = fetch "lldb" "0ffi9jn4k3yd0hvxs1v4n710x8siq21lb49v3351d7j5qinrpgi7"; + + patchPhase = '' + sed -i 's|/usr/bin/env||' \ + scripts/Python/finish-swig-Python-LLDB.sh \ + scripts/Python/build-swig-Python.sh + ''; + + buildInputs = [ cmake python which swig ncurses zlib libedit ]; + + cmakeFlags = [ + "-DCMAKE_CXX_FLAGS=-std=c++11" + "-DLLDB_PATH_TO_LLVM_BUILD=${llvm}" + "-DLLDB_PATH_TO_CLANG_BUILD=${clang}" + "-DLLDB_DISABLE_LIBEDIT=1" # https://llvm.org/bugs/show_bug.cgi?id=28898 + ]; + + enableParallelBuilding = true; + + meta = { + description = "A next-generation high-performance debugger"; + homepage = http://llvm.org/; + license = stdenv.lib.licenses.ncsa; + platforms = stdenv.lib.platforms.all; + broken = true; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/llvm/3.5/llvm-separate-build.patch b/nixpkgs/pkgs/development/compilers/llvm/3.5/llvm-separate-build.patch new file mode 100644 index 000000000000..abfc11513cdc --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/3.5/llvm-separate-build.patch @@ -0,0 +1,12 @@ +diff -Naur llvm-3.4-orig/cmake/modules/TableGen.cmake llvm-3.4/cmake/modules/TableGen.cmake +--- llvm-3.4-orig/cmake/modules/TableGen.cmake 2013-10-06 21:00:07.000000000 -0400 ++++ llvm-3.4/cmake/modules/TableGen.cmake 2014-01-20 13:06:55.273022149 -0500 +@@ -78,8 +78,6 @@ + endif() + + macro(add_tablegen target project) +- set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${LLVM_TOOLS_BINARY_DIR}) +- + set(${target}_OLD_LLVM_LINK_COMPONENTS ${LLVM_LINK_COMPONENTS}) + set(LLVM_LINK_COMPONENTS ${LLVM_LINK_COMPONENTS} TableGen) + add_llvm_utility(${target} ${ARGN}) diff --git a/nixpkgs/pkgs/development/compilers/llvm/3.5/llvm.nix b/nixpkgs/pkgs/development/compilers/llvm/3.5/llvm.nix new file mode 100644 index 000000000000..2645469767ad --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/3.5/llvm.nix @@ -0,0 +1,98 @@ +{ stdenv +, fetch +, fetchpatch +, perl +, groff +, cmake +, python +, libffi +, libbfd +, libxml2 +, valgrind +, ncurses +, version +, zlib +, compiler-rt_src +, debugVersion ? false +, enableSharedLibraries ? !stdenv.isDarwin +}: + +let + src = fetch "llvm" "0xf5q17kkxsrm2gsi93h4pwlv663kji73r2g4asb97klsmb626a4"; +in stdenv.mkDerivation rec { + name = "llvm-${version}"; + + unpackPhase = '' + unpackFile ${src} + mv llvm-${version}.src llvm + sourceRoot=$PWD/llvm + unpackFile ${compiler-rt_src} + mv compiler-rt-* $sourceRoot/projects/compiler-rt + ''; + + buildInputs = [ perl groff cmake libxml2 python libffi ] ++ stdenv.lib.optional stdenv.isLinux valgrind; + + propagatedBuildInputs = [ ncurses zlib ]; + + prePatch = '' + substituteInPlace CMakeLists.txt \ + --replace 'set(CMAKE_INSTALL_NAME_DIR "@rpath")' "set(CMAKE_INSTALL_NAME_DIR "$out/lib")" \ + --replace 'set(CMAKE_INSTALL_RPATH "@executable_path/../lib")' "" + ''; + + postPatch = stdenv.lib.optionalString (stdenv ? glibc) '' + ( + cd projects/compiler-rt + patch -p1 < ${ + fetchpatch { + name = "sigaltstack.patch"; # for glibc-2.26 + url = https://github.com/llvm-mirror/compiler-rt/commit/8a5e425a68d.diff; + sha256 = "0h4y5vl74qaa7dl54b1fcyqalvlpd8zban2d1jxfkxpzyi7m8ifi"; + } + } + + sed -i "s,#include <pthread.h>,&\n#include <signal.h>,g" \ + lib/asan/asan_linux.cc + ) + ''; + + # hacky fix: created binaries need to be run before installation + preBuild = '' + mkdir -p $out/ + ln -sv $PWD/lib $out + ''; + + cmakeFlags = with stdenv; [ + "-DCMAKE_BUILD_TYPE=${if debugVersion then "Debug" else "Release"}" + "-DLLVM_BUILD_TESTS=ON" + "-DLLVM_ENABLE_FFI=ON" + "-DLLVM_REQUIRES_RTTI=1" + ] ++ stdenv.lib.optional enableSharedLibraries + "-DBUILD_SHARED_LIBS=ON" + ++ stdenv.lib.optional (!isDarwin) + "-DLLVM_BINUTILS_INCDIR=${libbfd.dev}/include" + ++ stdenv.lib.optionals ( isDarwin) [ + "-DCMAKE_CXX_FLAGS=-stdlib=libc++" + "-DCAN_TARGET_i386=false" + ]; + + patches = [ ./fix-15974.patch ] ++ + stdenv.lib.optionals (!stdenv.isDarwin) [../fix-llvm-config.patch ]; + + postBuild = '' + rm -fR $out + ''; + + enableParallelBuilding = true; + + passthru.src = src; + + meta = { + description = "Collection of modular and reusable compiler and toolchain technologies"; + homepage = http://llvm.org/; + license = stdenv.lib.licenses.ncsa; + maintainers = with stdenv.lib.maintainers; [ lovek323 raskin ]; + platforms = [ "i686-linux" "x86_64-linux" "x86_64-darwin" "armv7l-linux"]; + }; +} + diff --git a/nixpkgs/pkgs/development/compilers/llvm/3.5/polly-separate-build.patch b/nixpkgs/pkgs/development/compilers/llvm/3.5/polly-separate-build.patch new file mode 100644 index 000000000000..618dd4dc3b12 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/3.5/polly-separate-build.patch @@ -0,0 +1,12 @@ +diff -Naur polly-3.4-orig/CMakeLists.txt polly-3.4/CMakeLists.txt +--- polly-3.4-orig/CMakeLists.txt 2013-11-21 06:51:46.000000000 -0500 ++++ polly-3.4/CMakeLists.txt 2014-01-20 18:49:34.907919933 -0500 +@@ -53,7 +53,7 @@ + execute_process(COMMAND "${LLVM_INSTALL_ROOT}/bin/llvm-config" --cxxflags + OUTPUT_VARIABLE LLVM_CXX_FLAGS + OUTPUT_STRIP_TRAILING_WHITESPACE) +- set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} ${LLVM_CXX_FLAGS}) ++ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${LLVM_CXX_FLAGS}") + endif(NOT DEFINED LLVM_MAIN_SRC_DIR) + + set(POLLY_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) diff --git a/nixpkgs/pkgs/development/compilers/llvm/3.5/polly.nix b/nixpkgs/pkgs/development/compilers/llvm/3.5/polly.nix new file mode 100644 index 000000000000..bacf4d30556b --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/3.5/polly.nix @@ -0,0 +1,25 @@ +{ stdenv, fetch, cmake, isl, python, gmp, llvm, version }: + +stdenv.mkDerivation { + name = "polly-${version}"; + + src = fetch "polly" "1s6v54czmgq626an4yk2k34lrzkwmz1bjrbiafh7j23yc2w4nalx"; + + patches = [ ./polly-separate-build.patch ]; + + buildInputs = [ cmake isl python gmp ]; + + cmakeFlags = [ + "-DCMAKE_CXX_FLAGS=-std=c++11" + "-DLLVM_INSTALL_ROOT=${llvm}" + ]; + + enableParallelBuilding = true; + + meta = { + description = "A polyhedral optimizer for llvm"; + homepage = http://llvm.org/; + license = stdenv.lib.licenses.ncsa; + platforms = stdenv.lib.platforms.all; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/llvm/3.7/clang/default.nix b/nixpkgs/pkgs/development/compilers/llvm/3.7/clang/default.nix new file mode 100644 index 000000000000..4ccd00af6846 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/3.7/clang/default.nix @@ -0,0 +1,60 @@ +{ stdenv, fetch, cmake, libxml2, llvm, version, clang-tools-extra_src }: + +let + gcc = if stdenv.cc.isGNU then stdenv.cc.cc else stdenv.cc.cc.gcc; + self = stdenv.mkDerivation { + name = "clang-${version}"; + + unpackPhase = '' + unpackFile ${fetch "cfe" "0x065d0w9b51xvdjxwfzjxng0gzpbx45fgiaxpap45ragi61dqjn"} + mv cfe-${version}.src clang + sourceRoot=$PWD/clang + unpackFile ${clang-tools-extra_src} + mv clang-tools-extra-* $sourceRoot/tools/extra + ''; + + buildInputs = [ cmake libxml2 llvm ]; + + cmakeFlags = [ + "-DCMAKE_CXX_FLAGS=-std=c++11" + ] ++ + # Maybe with compiler-rt this won't be needed? + (stdenv.lib.optional stdenv.isLinux "-DGCC_INSTALL_PREFIX=${gcc}") ++ + (stdenv.lib.optional (stdenv.cc.libc != null) "-DC_INCLUDE_DIRS=${stdenv.cc.libc}/include"); + + patches = [ ./purity.patch ]; + + postPatch = '' + sed -i -e 's/Args.hasArg(options::OPT_nostdlibinc)/true/' lib/Driver/Tools.cpp + sed -i -e 's/DriverArgs.hasArg(options::OPT_nostdlibinc)/true/' lib/Driver/ToolChains.cpp + ''; + + # Clang expects to find LLVMgold in its own prefix + # Clang expects to find sanitizer libraries in its own prefix + postInstall = '' + if [ -e ${llvm}/lib/LLVMgold.so ]; then + ln -sv ${llvm}/lib/LLVMgold.so $out/lib + fi + + ln -sv ${llvm}/lib/clang/${version}/lib $out/lib/clang/${version}/ + ln -sv $out/bin/clang $out/bin/cpp + ''; + + enableParallelBuilding = true; + + 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; + }; + + meta = { + description = "A c, c++, objective-c, and objective-c++ frontend for the llvm compiler"; + homepage = http://llvm.org/; + license = stdenv.lib.licenses.ncsa; + platforms = stdenv.lib.platforms.all; + }; + }; +in self diff --git a/nixpkgs/pkgs/development/compilers/llvm/3.7/clang/purity.patch b/nixpkgs/pkgs/development/compilers/llvm/3.7/clang/purity.patch new file mode 100644 index 000000000000..ee73b26eb5ce --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/3.7/clang/purity.patch @@ -0,0 +1,17 @@ +--- a/lib/Driver/Tools.cpp 2015-07-31 00:47:41.000000000 +0200 ++++ b/lib/Driver/Tools.cpp 2015-09-11 21:30:50.057895565 +0200 +@@ -8150,15 +8150,6 @@ + CmdArgs.push_back("-shared"); + } + +- if (Arch == llvm::Triple::arm || Arch == llvm::Triple::armeb || +- Arch == llvm::Triple::thumb || Arch == llvm::Triple::thumbeb || +- (!Args.hasArg(options::OPT_static) && +- !Args.hasArg(options::OPT_shared))) { +- CmdArgs.push_back("-dynamic-linker"); +- CmdArgs.push_back(Args.MakeArgString( +- D.DyldPrefix + getLinuxDynamicLinker(Args, ToolChain))); +- } +- + CmdArgs.push_back("-o"); + CmdArgs.push_back(Output.getFilename()); diff --git a/nixpkgs/pkgs/development/compilers/llvm/3.7/default.nix b/nixpkgs/pkgs/development/compilers/llvm/3.7/default.nix new file mode 100644 index 000000000000..3c557711449f --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/3.7/default.nix @@ -0,0 +1,59 @@ +{ newScope, stdenv, libstdcxxHook, isl, fetchurl +, overrideCC, wrapCCWith +, buildLlvmTools # tools, but from the previous stage, for cross +, targetLlvmLibraries # libraries, but from the next stage, for cross +}: + +let + version = "3.7.1"; + + fetch = fetch_v version; + fetch_v = ver: name: sha256: fetchurl { + url = "https://releases.llvm.org/${ver}/${name}-${ver}.src.tar.xz"; + inherit sha256; + }; + + compiler-rt_src = fetch "compiler-rt" "10c1mz2q4bdq9bqfgr3dirc6hz1h3sq8573srd5q5lr7m7j6jiwx"; + clang-tools-extra_src = fetch "clang-tools-extra" "0sxw2l3q5msbrwxv1ck72arggdw6n5ysi929gi69ikniranfv4aa"; + + tools = stdenv.lib.makeExtensible (tools: let + callPackage = newScope (tools // { inherit stdenv isl version fetch; }); + in { + llvm = callPackage ./llvm.nix { + inherit compiler-rt_src; + inherit (targetLlvmLibraries) libcxxabi; + }; + + clang-unwrapped = callPackage ./clang { + inherit clang-tools-extra_src; + }; + + clang = if stdenv.cc.isGNU then tools.libstdcxxClang else tools.libcxxClang; + + libstdcxxClang = wrapCCWith { + cc = tools.clang-unwrapped; + extraPackages = [ libstdcxxHook ]; + }; + + libcxxClang = wrapCCWith { + cc = tools.clang-unwrapped; + extraPackages = [ targetLlvmLibraries.libcxx targetLlvmLibraries.libcxxabi ]; + }; + + lldb = callPackage ./lldb.nix {}; + }); + + libraries = stdenv.lib.makeExtensible (libraries: let + callPackage = newScope (libraries // buildLlvmTools // { inherit stdenv isl version fetch; }); + in { + + stdenv = overrideCC stdenv buildLlvmTools.clang; + + libcxxStdenv = overrideCC stdenv buildLlvmTools.libcxxClang; + + libcxx = callPackage ./libc++ {}; + + libcxxabi = callPackage ./libc++abi.nix {}; + }); + +in { inherit tools libraries; } // libraries // tools diff --git a/nixpkgs/pkgs/development/compilers/llvm/3.7/libc++/darwin.patch b/nixpkgs/pkgs/development/compilers/llvm/3.7/libc++/darwin.patch new file mode 100644 index 000000000000..bf83f169cfc3 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/3.7/libc++/darwin.patch @@ -0,0 +1,30 @@ +diff -ru -x '*~' libcxx-3.4.2.src-orig/lib/CMakeLists.txt libcxx-3.4.2.src/lib/CMakeLists.txt +--- libcxx-3.4.2.src-orig/lib/CMakeLists.txt 2013-11-15 18:18:57.000000000 +0100 ++++ libcxx-3.4.2.src/lib/CMakeLists.txt 2014-09-24 14:04:01.000000000 +0200 +@@ -56,7 +56,7 @@ + "-compatibility_version 1" + "-current_version ${LIBCXX_VERSION}" + "-install_name /usr/lib/libc++.1.dylib" +- "-Wl,-reexport_library,/usr/lib/libc++abi.dylib" ++ "-Wl,-reexport_library,${LIBCXX_LIBCXXABI_LIB_PATH}/libc++abi.dylib" + "-Wl,-unexported_symbols_list,${CMAKE_CURRENT_SOURCE_DIR}/libc++unexp.exp" + "/usr/lib/libSystem.B.dylib") + else() +@@ -64,14 +64,14 @@ + list(FIND ${CMAKE_OSX_ARCHITECTURES} "armv7" OSX_HAS_ARMV7) + if (OSX_HAS_ARMV7) + set(OSX_RE_EXPORT_LINE +- "${CMAKE_OSX_SYSROOT}/usr/lib/libc++abi.dylib" ++ "${CMAKE_OSX_SYSROOT}${LIBCXX_LIBCXXABI_LIB_PATH}/libc++abi.dylib" + "-Wl,-reexported_symbols_list,${CMAKE_CURRENT_SOURCE_DIR}/libc++sjlj-abi.exp") + else() + set(OSX_RE_EXPORT_LINE +- "-Wl,-reexport_library,${CMAKE_OSX_SYSROOT}/usr/lib/libc++abi.dylib") ++ "-Wl,-reexport_library,${CMAKE_OSX_SYSROOT}${LIBCXX_LIBCXXABI_LIB_PATH}/libc++abi.dylib") + endif() + else() +- set (OSX_RE_EXPORT_LINE "/usr/lib/libc++abi.dylib -Wl,-reexported_symbols_list,${CMAKE_CURRENT_SOURCE_DIR}/libc++abi${LIBCXX_LIBCPPABI_VERSION}.exp") ++ set (OSX_RE_EXPORT_LINE "${LIBCXX_LIBCXXABI_LIB_PATH}/libc++abi.dylib -Wl,-reexported_symbols_list,${CMAKE_CURRENT_SOURCE_DIR}/libc++abi${LIBCXX_LIBCPPABI_VERSION}.exp") + endif() + + list(APPEND link_flags diff --git a/nixpkgs/pkgs/development/compilers/llvm/3.7/libc++/default.nix b/nixpkgs/pkgs/development/compilers/llvm/3.7/libc++/default.nix new file mode 100644 index 000000000000..462e35a483f4 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/3.7/libc++/default.nix @@ -0,0 +1,47 @@ +{ lib, stdenv, fetch, cmake, libcxxabi, fixDarwinDylibNames, version }: + +stdenv.mkDerivation rec { + name = "libc++-${version}"; + + src = fetch "libcxx" "0i7iyzk024krda5spfpfi8jksh83yp3bxqkal0xp76ffi11bszrm"; + + postUnpack = '' + unpackFile ${libcxxabi.src} + ''; + + preConfigure = '' + # Get headers from the cxxabi source so we can see private headers not installed by the cxxabi package + cmakeFlagsArray=($cmakeFlagsArray -DLIBCXX_CXX_ABI_INCLUDE_PATHS="$NIX_BUILD_TOP/libcxxabi-${version}.src/include") + ''; + + patches = [ + ./darwin.patch + ./r242056.patch + # glibc 2.26 fix + ./xlocale-glibc-2.26.patch + ]; + + buildInputs = [ cmake libcxxabi ] ++ lib.optional stdenv.isDarwin fixDarwinDylibNames; + + cmakeFlags = [ + "-DLIBCXX_LIBCXXABI_LIB_PATH=${libcxxabi}/lib" + "-DLIBCXX_LIBCPPABI_VERSION=2" + "-DLIBCXX_CXX_ABI=libcxxabi" + ]; + + enableParallelBuilding = true; + + linkCxxAbi = stdenv.isLinux; + + setupHooks = [ + ../../../../../build-support/setup-hooks/role.bash + ./setup-hook.sh + ]; + + meta = { + homepage = http://libcxx.llvm.org/; + description = "A new implementation of the C++ standard library, targeting C++11"; + license = with stdenv.lib.licenses; [ ncsa mit ]; + platforms = stdenv.lib.platforms.unix; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/llvm/3.7/libc++/r242056.patch b/nixpkgs/pkgs/development/compilers/llvm/3.7/libc++/r242056.patch new file mode 100644 index 000000000000..96245e76653a --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/3.7/libc++/r242056.patch @@ -0,0 +1,16 @@ +--- a/include/string 2015/07/13 20:04:56 242056 ++++ b/include/string 2015/07/18 20:40:46 242623 +@@ -1936,7 +1936,12 @@ + template <class _CharT, class _Traits, class _Allocator> + inline _LIBCPP_INLINE_VISIBILITY + basic_string<_CharT, _Traits, _Allocator>::basic_string(const allocator_type& __a) +- : __r_(__a) ++#if _LIBCPP_STD_VER <= 14 ++ _NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value) ++#else ++ _NOEXCEPT ++#endif ++: __r_(__a) + { + #if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_c(this); diff --git a/nixpkgs/pkgs/development/compilers/llvm/3.7/libc++/setup-hook.sh b/nixpkgs/pkgs/development/compilers/llvm/3.7/libc++/setup-hook.sh new file mode 100644 index 000000000000..6611259165ae --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/3.7/libc++/setup-hook.sh @@ -0,0 +1,6 @@ +# See pkgs/build-support/setup-hooks/role.bash +getHostRole + +linkCxxAbi="@linkCxxAbi@" +export NIX_${role_pre}CXXSTDLIB_COMPILE+=" -isystem @out@/include/c++/v1" +export NIX_${role_pre}CXXSTDLIB_LINK=" -stdlib=libc++${linkCxxAbi:+" -lc++abi"}" diff --git a/nixpkgs/pkgs/development/compilers/llvm/3.7/libc++/xlocale-glibc-2.26.patch b/nixpkgs/pkgs/development/compilers/llvm/3.7/libc++/xlocale-glibc-2.26.patch new file mode 100644 index 000000000000..5ee8f6b82305 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/3.7/libc++/xlocale-glibc-2.26.patch @@ -0,0 +1,17 @@ +diff --git a/include/__locale b/include/__locale +index 1989558..1e42905 100644 +--- a/include/__locale ++++ b/include/__locale +@@ -34,10 +34,10 @@ + # include <support/solaris/xlocale.h> + #elif defined(_NEWLIB_VERSION) + # include <support/newlib/xlocale.h> +-#elif (defined(__GLIBC__) || defined(__APPLE__) || defined(__FreeBSD__) \ ++#elif (defined(__APPLE__) || defined(__FreeBSD__) \ + || defined(__EMSCRIPTEN__) || defined(__IBMCPP__)) + # include <xlocale.h> +-#endif // __GLIBC__ || __APPLE__ || __FreeBSD__ || __sun__ || __EMSCRIPTEN__ || __IBMCPP__ ++#endif // __APPLE__ || __FreeBSD__ || __sun__ || __EMSCRIPTEN__ || __IBMCPP__ + + #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) + #pragma GCC system_header diff --git a/nixpkgs/pkgs/development/compilers/llvm/3.7/libc++abi.nix b/nixpkgs/pkgs/development/compilers/llvm/3.7/libc++abi.nix new file mode 100644 index 000000000000..2c79d7b3b1b5 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/3.7/libc++abi.nix @@ -0,0 +1,61 @@ +{ stdenv, cmake, fetch, fetchpatch, libcxx, libunwind, llvm, version }: + +let + # Newer LLVMs (3.8 onwards) have changed how some basic C++ stuff works, which breaks builds of this older version + llvm38-and-above = fetchpatch { + url = "https://trac.macports.org/raw-attachment/ticket/50304/0005-string-Fix-exception-declaration.patch"; + sha256 = "1lm38n7s0l5dbl7kp4i49pvzxz1mcvlr2vgsnj47agnwhhm63jvr"; + }; +in stdenv.mkDerivation { + name = "libc++abi-${version}"; + + src = fetch "libcxxabi" "0ambfcmr2nh88hx000xb7yjm9lsqjjz49w5mlf6dlxzmj3nslzx4"; + + nativeBuildInputs = [ cmake ]; + buildInputs = stdenv.lib.optional (!stdenv.isDarwin && !stdenv.isFreeBSD) libunwind; + + postUnpack = '' + unpackFile ${libcxx.src} + unpackFile ${llvm.src} + export NIX_CFLAGS_COMPILE+=" -I$PWD/include" + export cmakeFlags="-DLLVM_PATH=$PWD/$(ls -d llvm-*) -DLIBCXXABI_LIBCXX_INCLUDES=$PWD/$(ls -d libcxx-*)/include" + '' + stdenv.lib.optionalString stdenv.isDarwin '' + export TRIPLE=x86_64-apple-darwin + ''; + + # I can't use patches directly because this is actually a patch for libc++'s source, which we manually extract + # into the libc++abi build environment above. + prePatch = ''( + cd ../libcxx-* + patch -p1 < ${llvm38-and-above} + )''; + + installPhase = if stdenv.isDarwin + then '' + for file in lib/*.dylib; do + # this should be done in CMake, but having trouble figuring out + # the magic combination of necessary CMake variables + # if you fancy a try, take a look at + # http://www.cmake.org/Wiki/CMake_RPATH_handling + install_name_tool -id $out/$file $file + done + make install + install -d 755 $out/include + install -m 644 ../include/*.h $out/include + '' + else '' + install -d -m 755 $out/include $out/lib + install -m 644 lib/libc++abi.so.1.0 $out/lib + install -m 644 ../include/cxxabi.h $out/include + ln -s libc++abi.so.1.0 $out/lib/libc++abi.so + ln -s libc++abi.so.1.0 $out/lib/libc++abi.so.1 + ''; + + meta = { + homepage = http://libcxxabi.llvm.org/; + description = "A new implementation of low level support for a standard C++ library"; + license = with stdenv.lib.licenses; [ ncsa mit ]; + maintainers = with stdenv.lib.maintainers; [ vlstill ]; + platforms = stdenv.lib.platforms.unix; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/llvm/3.7/lldb.nix b/nixpkgs/pkgs/development/compilers/llvm/3.7/lldb.nix new file mode 100644 index 000000000000..294410f99869 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/3.7/lldb.nix @@ -0,0 +1,49 @@ +{ stdenv +, fetch +, cmake +, zlib +, ncurses +, swig +, which +, libedit +, llvm +, clang-unwrapped +, python2 +, version +}: + +stdenv.mkDerivation { + name = "lldb-${version}"; + + src = fetch "lldb" "008fdbyza13ym3v0xpans4z4azw4y16hcbgrrnc4rx2mxwaw62ws"; + + patchPhase = '' + sed -i 's|/usr/bin/env||' \ + scripts/Python/finish-swig-Python-LLDB.sh \ + scripts/Python/build-swig-Python.sh + ''; + + buildInputs = [ cmake python2 which swig ncurses zlib libedit ]; + + preConfigure = '' + export CXXFLAGS="-pthread" + export LDFLAGS="-ldl" + ''; + + cmakeFlags = [ + "-DLLDB_PATH_TO_LLVM_BUILD=${llvm}" + "-DLLDB_PATH_TO_CLANG_BUILD=${clang-unwrapped}" + "-DPYTHON_VERSION_MAJOR=2" + "-DPYTHON_VERSION_MINOR=7" + "-DLLDB_DISABLE_LIBEDIT=1" # https://llvm.org/bugs/show_bug.cgi?id=28898 + ]; + + enableParallelBuilding = true; + + meta = { + description = "A next-generation high-performance debugger"; + homepage = http://llvm.org/; + license = stdenv.lib.licenses.ncsa; + platforms = stdenv.lib.platforms.all; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/llvm/3.7/llvm.nix b/nixpkgs/pkgs/development/compilers/llvm/3.7/llvm.nix new file mode 100644 index 000000000000..a6fd18f94d68 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/3.7/llvm.nix @@ -0,0 +1,105 @@ +{ stdenv +, fetch +, fetchpatch +, perl +, groff +, cmake +, python2 +, libffi +, libbfd +, libxml2 +, ncurses +, version +, zlib +, compiler-rt_src +, libcxxabi +, debugVersion ? false +, enableSharedLibraries ? !stdenv.isDarwin +}: + +let + src = fetch "llvm" "1masakdp9g2dan1yrazg7md5am2vacbkb3nahb3dchpc1knr8xxy"; +in stdenv.mkDerivation rec { + name = "llvm-${version}"; + + unpackPhase = '' + unpackFile ${src} + mv llvm-${version}.src llvm + sourceRoot=$PWD/llvm + unpackFile ${compiler-rt_src} + mv compiler-rt-* $sourceRoot/projects/compiler-rt + ''; + + buildInputs = [ perl groff cmake libxml2 python2 libffi ] + ++ stdenv.lib.optional stdenv.isDarwin libcxxabi; + + propagatedBuildInputs = [ ncurses zlib ]; + + # The goal here is to disable LLVM bindings (currently go and ocaml) regardless + # of whether the impure CMake search sheananigans find the compilers in global + # paths. This mostly exists because sandbox builds don't work very well on Darwin + # and sometimes you get weird behavior if CMake finds go in your system path. + # This would be far prettier if there were a CMake option to just disable bindings + # but from what I can tell, there isn't such a thing. The file in question only + # contains `if(WIN32)` conditions to check whether to disable bindings, so making + # those always succeed has the net effect of disabling all bindings. + prePatch = '' + substituteInPlace cmake/config-ix.cmake --replace "if(WIN32)" "if(1)" + '' + + stdenv.lib.optionalString (stdenv ? glibc) '' + ( + cd projects/compiler-rt + patch -p1 < ${ + fetchpatch { + name = "sigaltstack.patch"; # for glibc-2.26 + url = https://github.com/llvm-mirror/compiler-rt/commit/8a5e425a68d.diff; + sha256 = "0h4y5vl74qaa7dl54b1fcyqalvlpd8zban2d1jxfkxpzyi7m8ifi"; + } + } + ) + ''; + + # hacky fix: created binaries need to be run before installation + preBuild = '' + mkdir -p $out/ + ln -sv $PWD/lib $out + ''; + + patches = stdenv.lib.optionals (!stdenv.isDarwin) [ + # llvm-config --libfiles returns (non-existing) static libs + ../fix-llvm-config.patch + ]; + + cmakeFlags = with stdenv; [ + "-DCMAKE_BUILD_TYPE=${if debugVersion then "Debug" else "Release"}" + "-DLLVM_INSTALL_UTILS=ON" # Needed by rustc + "-DLLVM_BUILD_TESTS=ON" + "-DLLVM_ENABLE_FFI=ON" + "-DLLVM_ENABLE_RTTI=ON" + ] ++ stdenv.lib.optional enableSharedLibraries + "-DBUILD_SHARED_LIBS=ON" + ++ stdenv.lib.optional (!isDarwin) + "-DLLVM_BINUTILS_INCDIR=${libbfd.dev}/include" + ++ stdenv.lib.optionals ( isDarwin) [ + "-DLLVM_ENABLE_LIBCXX=ON" + "-DCAN_TARGET_i386=false" + ]; + + NIX_LDFLAGS = "-lpthread"; # no idea what's the problem + + postBuild = '' + rm -fR $out + ''; + + enableParallelBuilding = true; + + passthru.src = src; + + meta = { + description = "Collection of modular and reusable compiler and toolchain technologies"; + homepage = http://llvm.org/; + license = stdenv.lib.licenses.ncsa; + maintainers = with stdenv.lib.maintainers; [ lovek323 raskin ]; + platforms = stdenv.lib.platforms.all; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/llvm/3.8/D17533-1.patch b/nixpkgs/pkgs/development/compilers/llvm/3.8/D17533-1.patch new file mode 100644 index 000000000000..79ca953d6e5b --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/3.8/D17533-1.patch @@ -0,0 +1,60 @@ +commit eb92f5a745014532b83abfba04602fce87ca8393 +Author: Chuang-Yu Cheng <cycheng@multicorewareinc.com> +Date: Fri Apr 8 12:04:32 2016 +0000 + + CXX_FAST_TLS calling convention: performance improvement for PPC64 + + This is the same change on PPC64 as r255821 on AArch64. I have even borrowed + his commit message. + + The access function has a short entry and a short exit, the initialization + block is only run the first time. To improve the performance, we want to + have a short frame at the entry and exit. + + We explicitly handle most of the CSRs via copies. Only the CSRs that are not + handled via copies will be in CSR_SaveList. + + Frame lowering and prologue/epilogue insertion will generate a short frame + in the entry and exit according to CSR_SaveList. The majority of the CSRs will + be handled by register allcoator. Register allocator will try to spill and + reload them in the initialization block. + + We add CSRsViaCopy, it will be explicitly handled during lowering. + + 1> we first set FunctionLoweringInfo->SplitCSR if conditions are met (the target + supports it for the given machine function and the function has only return + exits). We also call TLI->initializeSplitCSR to perform initialization. + 2> we call TLI->insertCopiesSplitCSR to insert copies from CSRsViaCopy to + virtual registers at beginning of the entry block and copies from virtual + registers to CSRsViaCopy at beginning of the exit blocks. + 3> we also need to make sure the explicit copies will not be eliminated. + + Author: Tom Jablin (tjablin) + Reviewers: hfinkel kbarton cycheng + + http://reviews.llvm.org/D17533 + + git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265781 91177308-0d34-0410-b5e6-96231b3b80d8 + +diff --git a/lib/CodeGen/TargetFrameLoweringImpl.cpp b/lib/CodeGen/TargetFrameLoweringImpl.cpp +index 679ade1..0a0e079 100644 +--- a/lib/CodeGen/TargetFrameLoweringImpl.cpp ++++ b/lib/CodeGen/TargetFrameLoweringImpl.cpp +@@ -63,12 +63,15 @@ void TargetFrameLowering::determineCalleeSaves(MachineFunction &MF, + const TargetRegisterInfo &TRI = *MF.getSubtarget().getRegisterInfo(); + const MCPhysReg *CSRegs = TRI.getCalleeSavedRegs(&MF); + ++ // Resize before the early returns. Some backends expect that ++ // SavedRegs.size() == TRI.getNumRegs() after this call even if there are no ++ // saved registers. ++ SavedRegs.resize(TRI.getNumRegs()); ++ + // Early exit if there are no callee saved registers. + if (!CSRegs || CSRegs[0] == 0) + return; + +- SavedRegs.resize(TRI.getNumRegs()); +- + // In Naked functions we aren't going to save any registers. + if (MF.getFunction()->hasFnAttribute(Attribute::Naked)) + return; diff --git a/nixpkgs/pkgs/development/compilers/llvm/3.8/clang/default.nix b/nixpkgs/pkgs/development/compilers/llvm/3.8/clang/default.nix new file mode 100644 index 000000000000..cc25a41b0400 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/3.8/clang/default.nix @@ -0,0 +1,78 @@ +{ stdenv, fetch, cmake, libxml2, llvm, version, clang-tools-extra_src, python }: + +let + gcc = if stdenv.cc.isGNU then stdenv.cc.cc else stdenv.cc.cc.gcc; + self = stdenv.mkDerivation { + name = "clang-${version}"; + + unpackPhase = '' + unpackFile ${fetch "cfe" "1prc72xmkgx8wrzmrr337776676nhsp1qd3mw2bvb22bzdnq7lsc"} + mv cfe-${version}.src clang + sourceRoot=$PWD/clang + unpackFile ${clang-tools-extra_src} + mv clang-tools-extra-* $sourceRoot/tools/extra + ''; + + nativeBuildInputs = [ cmake ]; + buildInputs = [ libxml2 llvm python ]; + + cmakeFlags = [ + "-DCMAKE_CXX_FLAGS=-std=c++11" + ] ++ + # Maybe with compiler-rt this won't be needed? + (stdenv.lib.optional stdenv.isLinux "-DGCC_INSTALL_PREFIX=${gcc}") ++ + (stdenv.lib.optional (stdenv.cc.libc != null) "-DC_INCLUDE_DIRS=${stdenv.cc.libc}/include"); + + patches = [ ./purity.patch ]; + + postPatch = '' + sed -i -e 's/Args.hasArg(options::OPT_nostdlibinc)/true/' lib/Driver/Tools.cpp + sed -i -e 's/DriverArgs.hasArg(options::OPT_nostdlibinc)/true/' lib/Driver/ToolChains.cpp + '' + stdenv.lib.optionalString stdenv.hostPlatform.isMusl '' + sed -i -e 's/lgcc_s/lgcc_eh/' lib/Driver/Tools.cpp + ''; + + outputs = [ "out" "lib" "python" ]; + + # Clang expects to find LLVMgold in its own prefix + # Clang expects to find sanitizer libraries in its own prefix + postInstall = '' + if [ -e ${llvm}/lib/LLVMgold.so ]; then + ln -sv ${llvm}/lib/LLVMgold.so $out/lib + fi + + ln -sv ${llvm}/lib/clang/${version}/lib $out/lib/clang/${version}/ + ln -sv $out/bin/clang $out/bin/cpp + + # Move libclang to 'lib' output + moveToOutput "lib/libclang.*" "$lib" + substituteInPlace $out/share/clang/cmake/ClangTargets-release.cmake \ + --replace "\''${_IMPORT_PREFIX}/lib/libclang." "$lib/lib/libclang." + + mkdir -p $python/bin $python/share/clang/ + mv $out/bin/{git-clang-format,scan-view} $python/bin + if [ -e $out/bin/set-xcode-analyzer ]; then + mv $out/bin/set-xcode-analyzer $python/bin + fi + mv $out/share/clang/*.py $python/share/clang + + rm $out/bin/c-index-test + ''; + + enableParallelBuilding = true; + + passthru = { + isClang = true; + inherit llvm; + } // stdenv.lib.optionalAttrs stdenv.isLinux { + inherit gcc; + }; + + meta = { + description = "A c, c++, objective-c, and objective-c++ frontend for the llvm compiler"; + homepage = http://llvm.org/; + license = stdenv.lib.licenses.ncsa; + platforms = stdenv.lib.platforms.all; + }; + }; +in self diff --git a/nixpkgs/pkgs/development/compilers/llvm/3.8/clang/purity.patch b/nixpkgs/pkgs/development/compilers/llvm/3.8/clang/purity.patch new file mode 100644 index 000000000000..2d1c68d865e6 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/3.8/clang/purity.patch @@ -0,0 +1,17 @@ +--- a/lib/Driver/Tools.cpp 2016-02-12 15:51:41.000000000 -0700 ++++ b/lib/Driver/Tools.cpp 2016-03-08 15:39:06.790111122 -0700 +@@ -8833,15 +8833,6 @@ + CmdArgs.push_back("-shared"); + } + +- if (Arch == llvm::Triple::arm || Arch == llvm::Triple::armeb || +- Arch == llvm::Triple::thumb || Arch == llvm::Triple::thumbeb || +- (!Args.hasArg(options::OPT_static) && +- !Args.hasArg(options::OPT_shared))) { +- CmdArgs.push_back("-dynamic-linker"); +- CmdArgs.push_back(Args.MakeArgString( +- D.DyldPrefix + getLinuxDynamicLinker(Args, ToolChain))); +- } +- + CmdArgs.push_back("-o"); + CmdArgs.push_back(Output.getFilename()); diff --git a/nixpkgs/pkgs/development/compilers/llvm/3.8/default.nix b/nixpkgs/pkgs/development/compilers/llvm/3.8/default.nix new file mode 100644 index 000000000000..a848c8b9252b --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/3.8/default.nix @@ -0,0 +1,59 @@ +{ newScope, stdenv, libstdcxxHook, isl, fetchurl, overrideCC, wrapCCWith +, buildLlvmTools # tools, but from the previous stage, for cross +, targetLlvmLibraries # libraries, but from the next stage, for cross +}: + +let + version = "3.8.1"; + + fetch = fetch_v version; + fetch_v = ver: name: sha256: fetchurl { + url = "https://releases.llvm.org/${ver}/${name}-${ver}.src.tar.xz"; + inherit sha256; + }; + + compiler-rt_src = fetch "compiler-rt" "0p0y85c7izndbpg2l816z7z7558axq11d5pwkm4h11sdw7d13w0d"; + clang-tools-extra_src = fetch "clang-tools-extra" "15n39r4ssphpaq4a0wzyjm7ilwxb0bch6nrapy8c5s8d49h5qjk6"; + + tools = stdenv.lib.makeExtensible (tools: let + callPackage = newScope (tools // { inherit stdenv isl version fetch; }); + in { + llvm = callPackage ./llvm.nix { + inherit compiler-rt_src; + }; + + clang-unwrapped = callPackage ./clang { + inherit clang-tools-extra_src; + }; + + libclang = tools.clang-unwrapped.lib; + + clang = if stdenv.cc.isGNU then tools.libstdcxxClang else tools.libcxxClang; + + libstdcxxClang = wrapCCWith { + cc = tools.clang-unwrapped; + extraPackages = [ libstdcxxHook ]; + }; + + libcxxClang = wrapCCWith { + cc = tools.clang-unwrapped; + extraPackages = [ targetLlvmLibraries.libcxx targetLlvmLibraries.libcxxabi ]; + }; + + lldb = callPackage ./lldb.nix {}; + }); + + libraries = stdenv.lib.makeExtensible (libraries: let + callPackage = newScope (libraries // buildLlvmTools // { inherit stdenv isl version fetch; }); + in { + + stdenv = overrideCC stdenv buildLlvmTools.clang; + + libcxxStdenv = overrideCC stdenv buildLlvmTools.libcxxClang; + + libcxx = callPackage ./libc++ {}; + + libcxxabi = callPackage ./libc++abi.nix {}; + }); + +in { inherit tools libraries; } // libraries // tools diff --git a/nixpkgs/pkgs/development/compilers/llvm/3.8/fix-llvm-config.patch b/nixpkgs/pkgs/development/compilers/llvm/3.8/fix-llvm-config.patch new file mode 100644 index 000000000000..6e56c67c8977 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/3.8/fix-llvm-config.patch @@ -0,0 +1,11 @@ +--- llvm.org/utils/llvm-build/llvmbuild/main.py 2015-10-07 00:24:35.000000000 +0100 ++++ llvm/utils/llvm-build/llvmbuild/main.py 2017-06-16 17:08:39.866586578 +0100 +@@ -413,7 +413,7 @@ + if library_name is None: + library_name_as_cstr = 'nullptr' + else: +- library_name_as_cstr = '"lib%s.a"' % library_name ++ library_name_as_cstr = '"lib%s.so"' % library_name + if is_installed: + is_installed_as_cstr = 'true' + else: diff --git a/nixpkgs/pkgs/development/compilers/llvm/3.8/libc++/darwin.patch b/nixpkgs/pkgs/development/compilers/llvm/3.8/libc++/darwin.patch new file mode 100644 index 000000000000..6dd756f01cc2 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/3.8/libc++/darwin.patch @@ -0,0 +1,39 @@ +--- libcxx-3.8.0.src.org/lib/CMakeLists.txt 2015-12-16 15:41:05.000000000 -0800 ++++ libcxx-3.8.0.src/lib/CMakeLists.txt 2016-06-17 19:40:00.293394500 -0700 +@@ -94,30 +94,30 @@ + add_definitions(-D__STRICT_ANSI__) + add_link_flags( + "-compatibility_version 1" + "-current_version 1" +- "-install_name /usr/lib/libc++.1.dylib" +- "-Wl,-reexport_library,/usr/lib/libc++abi.dylib" ++ "-install_name ${LIBCXX_LIBCXXABI_LIB_PATH}/libc++.1.dylib" ++ "-Wl,-reexport_library,${LIBCXX_LIBCXXABI_LIB_PATH}/libc++abi.dylib" + "-Wl,-unexported_symbols_list,${CMAKE_CURRENT_SOURCE_DIR}/libc++unexp.exp" + "/usr/lib/libSystem.B.dylib") + else() + if ( ${CMAKE_OSX_SYSROOT} ) + list(FIND ${CMAKE_OSX_ARCHITECTURES} "armv7" OSX_HAS_ARMV7) + if (OSX_HAS_ARMV7) + set(OSX_RE_EXPORT_LINE +- "${CMAKE_OSX_SYSROOT}/usr/lib/libc++abi.dylib" ++ "${CMAKE_OSX_SYSROOT}${LIBCXX_LIBCXXABI_LIB_PATH}/libc++abi.dylib" + "-Wl,-reexported_symbols_list,${CMAKE_CURRENT_SOURCE_DIR}/libc++sjlj-abi.exp") + else() + set(OSX_RE_EXPORT_LINE +- "-Wl,-reexport_library,${CMAKE_OSX_SYSROOT}/usr/lib/libc++abi.dylib") ++ "-Wl,-reexport_library,${CMAKE_OSX_SYSROOT}${LIBCXX_LIBCXXABI_LIB_PATH}/libc++abi.dylib") + endif() + else() +- set(OSX_RE_EXPORT_LINE "/usr/lib/libc++abi.dylib -Wl,-reexported_symbols_list,${CMAKE_CURRENT_SOURCE_DIR}/libc++abi${LIBCXX_LIBCPPABI_VERSION}.exp") ++ set(OSX_RE_EXPORT_LINE "${LIBCXX_LIBCXXABI_LIB_PATH}/libc++abi.dylib -Wl,-reexported_symbols_list,${CMAKE_CURRENT_SOURCE_DIR}/libc++abi${LIBCXX_LIBCPPABI_VERSION}.exp") + endif() + + add_link_flags( + "-compatibility_version 1" +- "-install_name /usr/lib/libc++.1.dylib" ++ "-install_name ${LIBCXX_LIBCXXABI_LIB_PATH}/libc++.1.dylib" + "-Wl,-unexported_symbols_list,${CMAKE_CURRENT_SOURCE_DIR}/libc++unexp.exp" + "${OSX_RE_EXPORT_LINE}" + "-Wl,-force_symbols_not_weak_list,${CMAKE_CURRENT_SOURCE_DIR}/notweak.exp" + "-Wl,-force_symbols_weak_list,${CMAKE_CURRENT_SOURCE_DIR}/weak.exp") diff --git a/nixpkgs/pkgs/development/compilers/llvm/3.8/libc++/default.nix b/nixpkgs/pkgs/development/compilers/llvm/3.8/libc++/default.nix new file mode 100644 index 000000000000..5a0410302f2f --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/3.8/libc++/default.nix @@ -0,0 +1,52 @@ +{ lib, stdenv, fetch, cmake, libcxxabi, fixDarwinDylibNames, version }: + +stdenv.mkDerivation rec { + name = "libc++-${version}"; + + src = fetch "libcxx" "1k7f9qk5bgwa02ksh6yr9hccwcbhmcdzl1fpbdw6s2c89iwg7mvp"; + + postUnpack = '' + unpackFile ${libcxxabi.src} + ''; + + preConfigure = '' + # Get headers from the cxxabi source so we can see private headers not installed by the cxxabi package + cmakeFlagsArray=($cmakeFlagsArray -DLIBCXX_CXX_ABI_INCLUDE_PATHS="$NIX_BUILD_TOP/libcxxabi-${version}.src/include") + ''; + + patches = [ + # glibc 2.26 fix + ../../3.9/libc++/xlocale-glibc-2.26.patch + ] + ++ lib.optional stdenv.isDarwin ./darwin.patch + ++ stdenv.lib.optionals stdenv.hostPlatform.isMusl [ + ../../libcxx-0001-musl-hacks.patch + ../../libcxx-max_align_t.patch + ]; + + nativeBuildInputs = [ cmake ]; + + buildInputs = [ libcxxabi ] ++ lib.optional stdenv.isDarwin fixDarwinDylibNames; + + cmakeFlags = [ + "-DLIBCXX_LIBCXXABI_LIB_PATH=${libcxxabi}/lib" + "-DLIBCXX_LIBCPPABI_VERSION=2" + "-DLIBCXX_CXX_ABI=libcxxabi" + ] ++ stdenv.lib.optional stdenv.hostPlatform.isMusl "-DLIBCXX_HAS_MUSL_LIBC=1"; + + enableParallelBuilding = true; + + linkCxxAbi = stdenv.isLinux; + + setupHooks = [ + ../../../../../build-support/setup-hooks/role.bash + ./setup-hook.sh + ]; + + meta = { + homepage = http://libcxx.llvm.org/; + description = "A new implementation of the C++ standard library, targeting C++11"; + license = with stdenv.lib.licenses; [ ncsa mit ]; + platforms = stdenv.lib.platforms.unix; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/llvm/3.8/libc++/setup-hook.sh b/nixpkgs/pkgs/development/compilers/llvm/3.8/libc++/setup-hook.sh new file mode 100644 index 000000000000..6611259165ae --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/3.8/libc++/setup-hook.sh @@ -0,0 +1,6 @@ +# See pkgs/build-support/setup-hooks/role.bash +getHostRole + +linkCxxAbi="@linkCxxAbi@" +export NIX_${role_pre}CXXSTDLIB_COMPILE+=" -isystem @out@/include/c++/v1" +export NIX_${role_pre}CXXSTDLIB_LINK=" -stdlib=libc++${linkCxxAbi:+" -lc++abi"}" diff --git a/nixpkgs/pkgs/development/compilers/llvm/3.8/libc++abi.nix b/nixpkgs/pkgs/development/compilers/llvm/3.8/libc++abi.nix new file mode 100644 index 000000000000..8b25681c2dbf --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/3.8/libc++abi.nix @@ -0,0 +1,51 @@ +{ stdenv, cmake, fetch, libcxx, libunwind, llvm, version }: + +stdenv.mkDerivation { + name = "libc++abi-${version}"; + + src = fetch "libcxxabi" "1qfs2iis1i0ppv11jndc98cvd7s25pj46pq2sfyldmzswdxmzdg1"; + + nativeBuildInputs = [ cmake ]; + buildInputs = stdenv.lib.optional (!stdenv.isDarwin && !stdenv.isFreeBSD) libunwind; + + postUnpack = '' + unpackFile ${libcxx.src} + unpackFile ${llvm.src} + export NIX_CFLAGS_COMPILE+=" -I$PWD/include" + export cmakeFlags="-DLLVM_PATH=$PWD/$(ls -d llvm-*) -DLIBCXXABI_LIBCXX_INCLUDES=$PWD/$(ls -d libcxx-*)/include" + '' + stdenv.lib.optionalString stdenv.isDarwin '' + export TRIPLE=x86_64-apple-darwin + '' + stdenv.lib.optionalString stdenv.hostPlatform.isMusl '' + patch -p1 -d $(ls -d libcxx-*) -i ${../libcxx-0001-musl-hacks.patch} + patch -p1 -d $(ls -d libcxx-*) -i ${../libcxx-max_align_t.patch} + ''; + + installPhase = if stdenv.isDarwin + then '' + for file in lib/*.dylib; do + # this should be done in CMake, but having trouble figuring out + # the magic combination of necessary CMake variables + # if you fancy a try, take a look at + # http://www.cmake.org/Wiki/CMake_RPATH_handling + install_name_tool -id $out/$file $file + done + make install + install -d 755 $out/include + install -m 644 ../include/*.h $out/include + '' + else '' + install -d -m 755 $out/include $out/lib + install -m 644 lib/libc++abi.so.1.0 $out/lib + install -m 644 ../include/cxxabi.h $out/include + ln -s libc++abi.so.1.0 $out/lib/libc++abi.so + ln -s libc++abi.so.1.0 $out/lib/libc++abi.so.1 + ''; + + meta = { + homepage = http://libcxxabi.llvm.org/; + description = "A new implementation of low level support for a standard C++ library"; + license = with stdenv.lib.licenses; [ ncsa mit ]; + maintainers = with stdenv.lib.maintainers; [ vlstill ]; + platforms = stdenv.lib.platforms.unix; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/llvm/3.8/lldb.nix b/nixpkgs/pkgs/development/compilers/llvm/3.8/lldb.nix new file mode 100644 index 000000000000..d27786464c05 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/3.8/lldb.nix @@ -0,0 +1,50 @@ +{ stdenv +, fetch +, cmake +, zlib +, ncurses +, swig +, which +, libedit +, llvm +, clang-unwrapped +, python +, version +}: + +stdenv.mkDerivation { + name = "lldb-${version}"; + + src = fetch "lldb" "18z8vhfgh4m57hl66i83cp4d4mv3i86z2hjhbp5rvqs7d88li49l"; + + postUnpack = '' + # Hack around broken standalone builf as of 3.8 + unpackFile ${llvm.src} + srcDir="$(ls -d lldb-*.src)" + mkdir -p "$srcDir/tools/lib/Support" + cp "$(ls -d llvm-*.src)/lib/Support/regex_impl.h" "$srcDir/tools/lib/Support/" + ''; + + buildInputs = [ cmake python which swig ncurses zlib libedit llvm ]; + + hardeningDisable = [ "format" ]; + + cmakeFlags = [ + "-DLLDB_PATH_TO_LLVM_BUILD=${llvm}" + "-DLLVM_MAIN_INCLUDE_DIR=${llvm}/include" + "-DLLDB_PATH_TO_CLANG_BUILD=${clang-unwrapped}" + "-DCLANG_MAIN_INCLUDE_DIR=${clang-unwrapped}/include" + "-DPYTHON_VERSION_MAJOR=2" + "-DPYTHON_VERSION_MINOR=7" + "-DLLDB_DISABLE_LIBEDIT=1" # https://llvm.org/bugs/show_bug.cgi?id=28898 + ]; + + enableParallelBuilding = true; + + meta = { + description = "A next-generation high-performance debugger"; + homepage = http://llvm.org/; + license = stdenv.lib.licenses.ncsa; + platforms = stdenv.lib.platforms.all; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/llvm/3.8/llvm.nix b/nixpkgs/pkgs/development/compilers/llvm/3.8/llvm.nix new file mode 100644 index 000000000000..261a1d0f94ca --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/3.8/llvm.nix @@ -0,0 +1,117 @@ +{ stdenv +, fetch +, fetchpatch +, perl +, groff +, cmake +, python +, libffi +, libbfd +, libxml2 +, ncurses +, version +, zlib +, compiler-rt_src +, debugVersion ? false +, enableSharedLibraries ? true +}: + +let + src = fetch "llvm" "1ybmnid4pw2hxn12ax5qa5kl1ldfns0njg8533y3mzslvd5cx0kf"; +in stdenv.mkDerivation rec { + name = "llvm-${version}"; + + unpackPhase = '' + unpackFile ${src} + mv llvm-${version}.src llvm + sourceRoot=$PWD/llvm + unpackFile ${compiler-rt_src} + mv compiler-rt-* $sourceRoot/projects/compiler-rt + ''; + + buildInputs = [ perl groff cmake libxml2 python libffi ]; + + propagatedBuildInputs = [ ncurses zlib ]; + + # Fix a segfault in llc + # See http://lists.llvm.org/pipermail/llvm-dev/2016-October/106500.html + patches = [ ./D17533-1.patch ] + ++ stdenv.lib.optional (!stdenv.isDarwin) ./fix-llvm-config.patch + ++ stdenv.lib.optionals stdenv.hostPlatform.isMusl [ + ../TLI-musl.patch + ../dynamiclibrary-musl.patch + ]; + + # hacky fix: New LLVM releases require a newer macOS SDK than + # 10.9. This is a temporary measure until nixpkgs darwin support is + # updated. + postPatch = stdenv.lib.optionalString stdenv.isDarwin '' + sed -i 's/os_trace(\(.*\)");$/printf(\1\\n");/g' ./projects/compiler-rt/lib/sanitizer_common/sanitizer_mac.cc + + substituteInPlace CMakeLists.txt \ + --replace 'set(CMAKE_INSTALL_NAME_DIR "@rpath")' "set(CMAKE_INSTALL_NAME_DIR "$out/lib")" \ + --replace 'set(CMAKE_INSTALL_RPATH "@executable_path/../lib")' "" + '' + + '' + ( + cd projects/compiler-rt + patch -p1 < ${ + fetchpatch { + name = "sigaltstack.patch"; # for glibc-2.26 + url = https://github.com/llvm-mirror/compiler-rt/commit/8a5e425a68d.diff; + sha256 = "0h4y5vl74qaa7dl54b1fcyqalvlpd8zban2d1jxfkxpzyi7m8ifi"; + } + } + ) + ''; + + # hacky fix: created binaries need to be run before installation + preBuild = '' + mkdir -p $out/ + ln -sv $PWD/lib $out + ''; + + cmakeFlags = with stdenv; [ + "-DCMAKE_BUILD_TYPE=${if debugVersion then "Debug" else "Release"}" + "-DLLVM_INSTALL_UTILS=ON" # Needed by rustc + "-DLLVM_BUILD_TESTS=ON" + "-DLLVM_ENABLE_FFI=ON" + "-DLLVM_ENABLE_RTTI=ON" + + "-DLLVM_HOST_TRIPLE=${stdenv.hostPlatform.config}" + "-DLLVM_DEFAULT_TARGET_TRIPLE=${stdenv.hostPlatform.config}" + "-DTARGET_TRIPLE=${stdenv.hostPlatform.config}" + ] ++ stdenv.lib.optional enableSharedLibraries [ + "-DLLVM_LINK_LLVM_DYLIB=ON" + ] ++ stdenv.lib.optional (!isDarwin) + "-DLLVM_BINUTILS_INCDIR=${libbfd.dev}/include" + ++ stdenv.lib.optionals ( isDarwin) [ + "-DLLVM_ENABLE_LIBCXX=ON" + "-DCAN_TARGET_i386=false" + ] ++ stdenv.lib.optionals stdenv.hostPlatform.isMusl [ + # Not yet supported + "-DCOMPILER_RT_BUILD_SANITIZERS=OFF" + "-DCOMPILER_RT_BUILD_XRAY=OFF" + + ]; + + postBuild = '' + rm -fR $out + ''; + + postInstall = stdenv.lib.optionalString (stdenv.isDarwin && enableSharedLibraries) '' + ln -s $out/lib/libLLVM.dylib $out/lib/libLLVM-${version}.dylib + ''; + + enableParallelBuilding = true; + + passthru.src = src; + + meta = { + description = "Collection of modular and reusable compiler and toolchain technologies"; + homepage = http://llvm.org/; + license = stdenv.lib.licenses.ncsa; + maintainers = with stdenv.lib.maintainers; [ lovek323 raskin ]; + platforms = stdenv.lib.platforms.all; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/llvm/3.9/clang/default.nix b/nixpkgs/pkgs/development/compilers/llvm/3.9/clang/default.nix new file mode 100644 index 000000000000..f597c559dba6 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/3.9/clang/default.nix @@ -0,0 +1,79 @@ +{ stdenv, fetch, cmake, libxml2, llvm, version, clang-tools-extra_src, python }: + +let + gcc = if stdenv.cc.isGNU then stdenv.cc.cc else stdenv.cc.cc.gcc; + self = stdenv.mkDerivation { + name = "clang-${version}"; + + unpackPhase = '' + unpackFile ${fetch "cfe" "0qsyyb40iwifhhlx9a3drf8z6ni6zwyk3bvh0kx2gs6yjsxwxi76"} + mv cfe-${version}.src clang + sourceRoot=$PWD/clang + unpackFile ${clang-tools-extra_src} + mv clang-tools-extra-* $sourceRoot/tools/extra + ''; + + nativeBuildInputs = [ cmake ]; + + buildInputs = [ libxml2 llvm python ]; + + cmakeFlags = [ + "-DCMAKE_CXX_FLAGS=-std=c++11" + ] ++ + # Maybe with compiler-rt this won't be needed? + (stdenv.lib.optional stdenv.isLinux "-DGCC_INSTALL_PREFIX=${gcc}") ++ + (stdenv.lib.optional (stdenv.cc.libc != null) "-DC_INCLUDE_DIRS=${stdenv.cc.libc}/include"); + + patches = [ ./purity.patch ]; + + postPatch = '' + sed -i -e 's/Args.hasArg(options::OPT_nostdlibinc)/true/' lib/Driver/Tools.cpp + sed -i -e 's/DriverArgs.hasArg(options::OPT_nostdlibinc)/true/' lib/Driver/ToolChains.cpp + '' + stdenv.lib.optionalString stdenv.hostPlatform.isMusl '' + sed -i -e 's/lgcc_s/lgcc_eh/' lib/Driver/Tools.cpp + ''; + + outputs = [ "out" "lib" "python" ]; + + # Clang expects to find LLVMgold in its own prefix + # Clang expects to find sanitizer libraries in its own prefix + postInstall = '' + if [ -e ${llvm}/lib/LLVMgold.so ]; then + ln -sv ${llvm}/lib/LLVMgold.so $out/lib + fi + + ln -sv ${llvm}/lib/clang/${version}/lib $out/lib/clang/${version}/ + ln -sv $out/bin/clang $out/bin/cpp + + # Move libclang to 'lib' output + moveToOutput "lib/libclang.*" "$lib" + substituteInPlace $out/lib/cmake/clang/ClangTargets-release.cmake \ + --replace "\''${_IMPORT_PREFIX}/lib/libclang." "$lib/lib/libclang." + + mkdir -p $python/bin $python/share/clang/ + mv $out/bin/{git-clang-format,scan-view} $python/bin + if [ -e $out/bin/set-xcode-analyzer ]; then + mv $out/bin/set-xcode-analyzer $python/bin + fi + mv $out/share/clang/*.py $python/share/clang + + rm $out/bin/c-index-test + ''; + + enableParallelBuilding = true; + + passthru = { + isClang = true; + inherit llvm; + } // stdenv.lib.optionalAttrs stdenv.isLinux { + inherit gcc; + }; + + meta = { + description = "A c, c++, objective-c, and objective-c++ frontend for the llvm compiler"; + homepage = http://llvm.org/; + license = stdenv.lib.licenses.ncsa; + platforms = stdenv.lib.platforms.all; + }; + }; +in self diff --git a/nixpkgs/pkgs/development/compilers/llvm/3.9/clang/purity.patch b/nixpkgs/pkgs/development/compilers/llvm/3.9/clang/purity.patch new file mode 100644 index 000000000000..f5fb4c73af47 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/3.9/clang/purity.patch @@ -0,0 +1,16 @@ +--- a/lib/Driver/Tools.cpp 2016-08-25 15:48:05.187553443 +0200 ++++ b/lib/Driver/Tools.cpp 2016-08-25 15:48:47.534468882 +0200 +@@ -9420,13 +9420,6 @@ + if (!Args.hasArg(options::OPT_static)) { + if (Args.hasArg(options::OPT_rdynamic)) + CmdArgs.push_back("-export-dynamic"); +- +- if (!Args.hasArg(options::OPT_shared)) { +- const std::string Loader = +- D.DyldPrefix + ToolChain.getDynamicLinker(Args); +- CmdArgs.push_back("-dynamic-linker"); +- CmdArgs.push_back(Args.MakeArgString(Loader)); +- } + } + + CmdArgs.push_back("-o"); diff --git a/nixpkgs/pkgs/development/compilers/llvm/3.9/default.nix b/nixpkgs/pkgs/development/compilers/llvm/3.9/default.nix new file mode 100644 index 000000000000..752790cdd853 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/3.9/default.nix @@ -0,0 +1,59 @@ +{ newScope, stdenv, libstdcxxHook, isl, fetchurl, overrideCC, wrapCCWith +, buildLlvmTools # tools, but from the previous stage, for cross +, targetLlvmLibraries # libraries, but from the next stage, for cross +}: + +let + version = "3.9.1"; + + fetch = fetch_v version; + fetch_v = ver: name: sha256: fetchurl { + url = "https://releases.llvm.org/${version}/${name}-${ver}.src.tar.xz"; + inherit sha256; + }; + + compiler-rt_src = fetch "compiler-rt" "16gc2gdmp5c800qvydrdhsp0bzb97s8wrakl6i8a4lgslnqnf2fk"; + clang-tools-extra_src = fetch "clang-tools-extra" "0d9nh7j7brbh9avigcn69dlaihsl9p3cf9s45mw6fxzzvrdvd999"; + + tools = stdenv.lib.makeExtensible (tools: let + callPackage = newScope (tools // { inherit stdenv isl version fetch; }); + in { + llvm = callPackage ./llvm.nix { + inherit compiler-rt_src; + }; + + clang-unwrapped = callPackage ./clang { + inherit clang-tools-extra_src; + }; + + libclang = tools.clang-unwrapped.lib; + + clang = if stdenv.cc.isGNU then tools.libstdcxxClang else tools.libcxxClang; + + libstdcxxClang = wrapCCWith { + cc = tools.clang-unwrapped; + extraPackages = [ libstdcxxHook ]; + }; + + libcxxClang = wrapCCWith { + cc = tools.clang-unwrapped; + extraPackages = [ targetLlvmLibraries.libcxx targetLlvmLibraries.libcxxabi ]; + }; + + lldb = callPackage ./lldb.nix {}; + }); + + libraries = stdenv.lib.makeExtensible (libraries: let + callPackage = newScope (libraries // buildLlvmTools // { inherit stdenv isl version fetch; }); + in { + + stdenv = overrideCC stdenv buildLlvmTools.clang; + + libcxxStdenv = overrideCC stdenv buildLlvmTools.libcxxClang; + + libcxx = callPackage ./libc++ {}; + + libcxxabi = callPackage ./libc++abi.nix {}; + }); + +in { inherit tools libraries; } // libraries // tools diff --git a/nixpkgs/pkgs/development/compilers/llvm/3.9/libc++/darwin.patch b/nixpkgs/pkgs/development/compilers/llvm/3.9/libc++/darwin.patch new file mode 100644 index 000000000000..6dd756f01cc2 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/3.9/libc++/darwin.patch @@ -0,0 +1,39 @@ +--- libcxx-3.8.0.src.org/lib/CMakeLists.txt 2015-12-16 15:41:05.000000000 -0800 ++++ libcxx-3.8.0.src/lib/CMakeLists.txt 2016-06-17 19:40:00.293394500 -0700 +@@ -94,30 +94,30 @@ + add_definitions(-D__STRICT_ANSI__) + add_link_flags( + "-compatibility_version 1" + "-current_version 1" +- "-install_name /usr/lib/libc++.1.dylib" +- "-Wl,-reexport_library,/usr/lib/libc++abi.dylib" ++ "-install_name ${LIBCXX_LIBCXXABI_LIB_PATH}/libc++.1.dylib" ++ "-Wl,-reexport_library,${LIBCXX_LIBCXXABI_LIB_PATH}/libc++abi.dylib" + "-Wl,-unexported_symbols_list,${CMAKE_CURRENT_SOURCE_DIR}/libc++unexp.exp" + "/usr/lib/libSystem.B.dylib") + else() + if ( ${CMAKE_OSX_SYSROOT} ) + list(FIND ${CMAKE_OSX_ARCHITECTURES} "armv7" OSX_HAS_ARMV7) + if (OSX_HAS_ARMV7) + set(OSX_RE_EXPORT_LINE +- "${CMAKE_OSX_SYSROOT}/usr/lib/libc++abi.dylib" ++ "${CMAKE_OSX_SYSROOT}${LIBCXX_LIBCXXABI_LIB_PATH}/libc++abi.dylib" + "-Wl,-reexported_symbols_list,${CMAKE_CURRENT_SOURCE_DIR}/libc++sjlj-abi.exp") + else() + set(OSX_RE_EXPORT_LINE +- "-Wl,-reexport_library,${CMAKE_OSX_SYSROOT}/usr/lib/libc++abi.dylib") ++ "-Wl,-reexport_library,${CMAKE_OSX_SYSROOT}${LIBCXX_LIBCXXABI_LIB_PATH}/libc++abi.dylib") + endif() + else() +- set(OSX_RE_EXPORT_LINE "/usr/lib/libc++abi.dylib -Wl,-reexported_symbols_list,${CMAKE_CURRENT_SOURCE_DIR}/libc++abi${LIBCXX_LIBCPPABI_VERSION}.exp") ++ set(OSX_RE_EXPORT_LINE "${LIBCXX_LIBCXXABI_LIB_PATH}/libc++abi.dylib -Wl,-reexported_symbols_list,${CMAKE_CURRENT_SOURCE_DIR}/libc++abi${LIBCXX_LIBCPPABI_VERSION}.exp") + endif() + + add_link_flags( + "-compatibility_version 1" +- "-install_name /usr/lib/libc++.1.dylib" ++ "-install_name ${LIBCXX_LIBCXXABI_LIB_PATH}/libc++.1.dylib" + "-Wl,-unexported_symbols_list,${CMAKE_CURRENT_SOURCE_DIR}/libc++unexp.exp" + "${OSX_RE_EXPORT_LINE}" + "-Wl,-force_symbols_not_weak_list,${CMAKE_CURRENT_SOURCE_DIR}/notweak.exp" + "-Wl,-force_symbols_weak_list,${CMAKE_CURRENT_SOURCE_DIR}/weak.exp") diff --git a/nixpkgs/pkgs/development/compilers/llvm/3.9/libc++/default.nix b/nixpkgs/pkgs/development/compilers/llvm/3.9/libc++/default.nix new file mode 100644 index 000000000000..bd2cc19d2e0b --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/3.9/libc++/default.nix @@ -0,0 +1,51 @@ +{ lib, stdenv, fetch, cmake, libcxxabi, fixDarwinDylibNames, version }: + +stdenv.mkDerivation rec { + name = "libc++-${version}"; + + src = fetch "libcxx" "0qbl3afl2p2h87p977lsqr5kykl6cgjpkzczs0g6a3pn53j1bri5"; + + postUnpack = '' + unpackFile ${libcxxabi.src} + ''; + + preConfigure = '' + # Get headers from the cxxabi source so we can see private headers not installed by the cxxabi package + cmakeFlagsArray=($cmakeFlagsArray -DLIBCXX_CXX_ABI_INCLUDE_PATHS="$NIX_BUILD_TOP/libcxxabi-${version}.src/include") + ''; + + patches = [ + # glibc 2.26 fix + ./xlocale-glibc-2.26.patch + ] + ++ lib.optional stdenv.isDarwin ./darwin.patch + ++ stdenv.lib.optionals stdenv.hostPlatform.isMusl [ + ../../libcxx-0001-musl-hacks.patch + ../../libcxx-max_align_t.patch + ]; + + nativeBuildInputs = [ cmake ]; + buildInputs = [ libcxxabi ] ++ lib.optional stdenv.isDarwin fixDarwinDylibNames; + + cmakeFlags = [ + "-DLIBCXX_LIBCXXABI_LIB_PATH=${libcxxabi}/lib" + "-DLIBCXX_LIBCPPABI_VERSION=2" + "-DLIBCXX_CXX_ABI=libcxxabi" + ] ++ stdenv.lib.optional stdenv.hostPlatform.isMusl "-DLIBCXX_HAS_MUSL_LIBC=1"; + + enableParallelBuilding = true; + + linkCxxAbi = stdenv.isLinux; + + setupHooks = [ + ../../../../../build-support/setup-hooks/role.bash + ./setup-hook.sh + ]; + + meta = { + homepage = http://libcxx.llvm.org/; + description = "A new implementation of the C++ standard library, targeting C++11"; + license = with stdenv.lib.licenses; [ ncsa mit ]; + platforms = stdenv.lib.platforms.unix; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/llvm/3.9/libc++/setup-hook.sh b/nixpkgs/pkgs/development/compilers/llvm/3.9/libc++/setup-hook.sh new file mode 100644 index 000000000000..6611259165ae --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/3.9/libc++/setup-hook.sh @@ -0,0 +1,6 @@ +# See pkgs/build-support/setup-hooks/role.bash +getHostRole + +linkCxxAbi="@linkCxxAbi@" +export NIX_${role_pre}CXXSTDLIB_COMPILE+=" -isystem @out@/include/c++/v1" +export NIX_${role_pre}CXXSTDLIB_LINK=" -stdlib=libc++${linkCxxAbi:+" -lc++abi"}" diff --git a/nixpkgs/pkgs/development/compilers/llvm/3.9/libc++/xlocale-glibc-2.26.patch b/nixpkgs/pkgs/development/compilers/llvm/3.9/libc++/xlocale-glibc-2.26.patch new file mode 100644 index 000000000000..4cc042554c85 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/3.9/libc++/xlocale-glibc-2.26.patch @@ -0,0 +1,19 @@ +diff --git a/include/__locale b/include/__locale +index 7bc701d..ea75c86 100644 +--- a/include/__locale ++++ b/include/__locale +@@ -34,12 +34,12 @@ + # include <support/solaris/xlocale.h> + #elif defined(_NEWLIB_VERSION) + # include <support/newlib/xlocale.h> +-#elif (defined(__GLIBC__) || defined(__APPLE__) || defined(__FreeBSD__) \ ++#elif (defined(__APPLE__) || defined(__FreeBSD__) \ + || defined(__EMSCRIPTEN__) || defined(__IBMCPP__)) + # include <xlocale.h> + #elif defined(_LIBCPP_HAS_MUSL_LIBC) + # include <support/musl/xlocale.h> +-#endif // __GLIBC__ || __APPLE__ || __FreeBSD__ || __sun__ || __EMSCRIPTEN__ || __IBMCPP__ ++#endif // __APPLE__ || __FreeBSD__ || __sun__ || __EMSCRIPTEN__ || __IBMCPP__ + + #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) + #pragma GCC system_header diff --git a/nixpkgs/pkgs/development/compilers/llvm/3.9/libc++abi.nix b/nixpkgs/pkgs/development/compilers/llvm/3.9/libc++abi.nix new file mode 100644 index 000000000000..dffb207a32b6 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/3.9/libc++abi.nix @@ -0,0 +1,51 @@ +{ stdenv, cmake, fetch, libcxx, libunwind, llvm, version }: + +stdenv.mkDerivation { + name = "libc++abi-${version}"; + + src = fetch "libcxxabi" "1qi9q06zanqm8awzq83810avmvi52air6gr9zfip8mbg5viqn3cj"; + + nativeBuildInputs = [ cmake ]; + buildInputs = stdenv.lib.optional (!stdenv.isDarwin && !stdenv.isFreeBSD) libunwind; + + postUnpack = '' + unpackFile ${libcxx.src} + unpackFile ${llvm.src} + export NIX_CFLAGS_COMPILE+=" -I$PWD/include" + export cmakeFlags="-DLLVM_PATH=$PWD/$(ls -d llvm-*) -DLIBCXXABI_LIBCXX_INCLUDES=$PWD/$(ls -d libcxx-*)/include" + '' + stdenv.lib.optionalString stdenv.isDarwin '' + export TRIPLE=x86_64-apple-darwin + '' + stdenv.lib.optionalString stdenv.hostPlatform.isMusl '' + patch -p1 -d $(ls -d libcxx-*) -i ${../libcxx-0001-musl-hacks.patch} + patch -p1 -d $(ls -d libcxx-*) -i ${../libcxx-max_align_t.patch} + ''; + + installPhase = if stdenv.isDarwin + then '' + for file in lib/*.dylib; do + # this should be done in CMake, but having trouble figuring out + # the magic combination of necessary CMake variables + # if you fancy a try, take a look at + # http://www.cmake.org/Wiki/CMake_RPATH_handling + install_name_tool -id $out/$file $file + done + make install + install -d 755 $out/include + install -m 644 ../include/*.h $out/include + '' + else '' + install -d -m 755 $out/include $out/lib + install -m 644 lib/libc++abi.so.1.0 $out/lib + install -m 644 ../include/cxxabi.h $out/include + ln -s libc++abi.so.1.0 $out/lib/libc++abi.so + ln -s libc++abi.so.1.0 $out/lib/libc++abi.so.1 + ''; + + meta = { + homepage = http://libcxxabi.llvm.org/; + description = "A new implementation of low level support for a standard C++ library"; + license = with stdenv.lib.licenses; [ ncsa mit ]; + maintainers = with stdenv.lib.maintainers; [ vlstill ]; + platforms = stdenv.lib.platforms.unix; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/llvm/3.9/lldb.nix b/nixpkgs/pkgs/development/compilers/llvm/3.9/lldb.nix new file mode 100644 index 000000000000..52f27de8cdb5 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/3.9/lldb.nix @@ -0,0 +1,56 @@ +{ stdenv +, fetch +, cmake +, zlib +, ncurses +, swig +, which +, libedit +, llvm +, clang-unwrapped +, python +, version +}: + +stdenv.mkDerivation { + name = "lldb-${version}"; + + src = fetch "lldb" "1z30ljmcpp261bjng1i5k3bb9jkrs1cr97z04qs4s3zql6r12cvy"; + + postUnpack = '' + # Hack around broken standalone build as of 3.8 + unpackFile ${llvm.src} + srcDir="$(ls -d lldb-*.src)" + mkdir -p "$srcDir/tools/lib/Support" + cp "$(ls -d llvm-*.src)/lib/Support/regex_impl.h" "$srcDir/tools/lib/Support/" + + # Fix up various paths that assume llvm and clang are installed in the same place + substituteInPlace $srcDir/cmake/modules/LLDBStandalone.cmake \ + --replace CheckAtomic $(readlink -f llvm-*.src)/cmake/modules/CheckAtomic.cmake + sed -i 's,".*ClangConfig.cmake","${clang-unwrapped}/lib/cmake/clang/ClangConfig.cmake",' \ + $srcDir/cmake/modules/LLDBStandalone.cmake + sed -i 's,".*tools/clang/include","${clang-unwrapped}/include",' \ + $srcDir/cmake/modules/LLDBStandalone.cmake + sed -i 's,"$.LLVM_LIBRARY_DIR.",${llvm}/lib ${clang-unwrapped}/lib,' \ + $srcDir/cmake/modules/LLDBStandalone.cmake + ''; + + buildInputs = [ cmake python which swig ncurses zlib libedit llvm ]; + + CXXFLAGS = "-fno-rtti"; + hardeningDisable = [ "format" ]; + + cmakeFlags = [ + "-DLLVM_MAIN_INCLUDE_DIR=${llvm}/include" + "-DLLDB_DISABLE_LIBEDIT=1" # https://llvm.org/bugs/show_bug.cgi?id=28898 + ]; + + enableParallelBuilding = true; + + meta = { + description = "A next-generation high-performance debugger"; + homepage = http://llvm.org/; + license = stdenv.lib.licenses.ncsa; + platforms = stdenv.lib.platforms.all; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/llvm/3.9/llvm-outputs.patch b/nixpkgs/pkgs/development/compilers/llvm/3.9/llvm-outputs.patch new file mode 100644 index 000000000000..40096fa3497f --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/3.9/llvm-outputs.patch @@ -0,0 +1,26 @@ +diff --git a/tools/llvm-config/llvm-config.cpp b/tools/llvm-config/llvm-config.cpp +index 94d426b..37f7794 100644 +--- a/tools/llvm-config/llvm-config.cpp ++++ b/tools/llvm-config/llvm-config.cpp +@@ -333,6 +333,21 @@ int main(int argc, char **argv) { + ActiveIncludeOption = "-I" + ActiveIncludeDir; + } + ++ /// Nix-specific multiple-output handling: override ActiveLibDir if --link-shared ++ if (!IsInDevelopmentTree) { ++ bool WantShared = true; ++ for (int i = 1; i < argc; ++i) { ++ StringRef Arg = argv[i]; ++ if (Arg == "--link-shared") ++ WantShared = true; ++ else if (Arg == "--link-static") ++ WantShared = false; // the last one wins ++ } ++ ++ if (WantShared) ++ ActiveLibDir = std::string("@lib@") + "/lib" + LLVM_LIBDIR_SUFFIX; ++ } ++ + /// We only use `shared library` mode in cases where the static library form + /// of the components provided are not available; note however that this is + /// skipped if we're run from within the build dir. However, once installed, diff --git a/nixpkgs/pkgs/development/compilers/llvm/3.9/llvm.nix b/nixpkgs/pkgs/development/compilers/llvm/3.9/llvm.nix new file mode 100644 index 000000000000..6c935fd88de5 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/3.9/llvm.nix @@ -0,0 +1,171 @@ +{ stdenv +, fetch +, fetchpatch +, perl +, groff +, cmake +, python +, libffi +, libbfd +, libxml2 +, ncurses +, version +, zlib +, compiler-rt_src +, debugVersion ? false +, enableSharedLibraries ? (stdenv.buildPlatform == stdenv.hostPlatform) +, buildPackages +}: + +assert (stdenv.hostPlatform != stdenv.buildPlatform) -> !enableSharedLibraries; + +let + src = fetch "llvm" "1vi9sf7rx1q04wj479rsvxayb6z740iaz3qniwp266fgp5a07n8z"; + + # Used when creating a version-suffixed symlink of libLLVM.dylib + shortVersion = with stdenv.lib; + concatStringsSep "." (take 2 (splitString "." version)); +in stdenv.mkDerivation rec { + name = "llvm-${version}"; + + unpackPhase = '' + unpackFile ${src} + mv llvm-${version}.src llvm + sourceRoot=$PWD/llvm + unpackFile ${compiler-rt_src} + mv compiler-rt-* $sourceRoot/projects/compiler-rt + ''; + + outputs = [ "out" ] ++ stdenv.lib.optional enableSharedLibraries "lib"; + + nativeBuildInputs = [ + perl + cmake + python + ]; + + buildInputs = [ + groff + libxml2 + libffi + ]; + + propagatedBuildInputs = [ ncurses zlib ]; + + patches = [ + # fix output of llvm-config (fixed in llvm 4.0) + (fetchpatch { + url = https://github.com/llvm-mirror/llvm/commit/5340b5b3d970069aebf3dde49d8964583742e01a.patch; + sha256 = "095f8knplwqbc2p7rad1kq8633i34qynni9jna93an7kyc80wdxl"; + }) + ] ++ stdenv.lib.optionals stdenv.hostPlatform.isMusl [ + ../TLI-musl.patch + ../dynamiclibrary-musl.patch + ]; + + postPatch = "" + + '' + patch -p1 --reverse < ${fetchpatch { + name = "fix-red-icons.diff"; # https://bugs.freedesktop.org/show_bug.cgi?id=99078 + url = https://github.com/llvm-mirror/llvm/commit/c280d74837d8.diff; + sha256 = "11sq86spw41v72f676igksapdlsgh7fiqp5qkkmgfj0ndqcn9skf"; + }} + '' + # TSAN requires XPC on Darwin, which we have no public/free source files for. We can depend on the Apple frameworks + # to get it, but they're unfree. Since LLVM is rather central to the stdenv, we patch out TSAN support so that Hydra + # can build this. If we didn't do it, basically the entire nixpkgs on Darwin would have an unfree dependency and we'd + # get no binary cache for the entire platform. If you really find yourself wanting the TSAN, make this controllable by + # a flag and turn the flag off during the stdenv build. I realize that this LLVM isn't used in the stdenv but I want to + # keep it consistent with 4.0. We really shouldn't be copying and pasting all this code around... + + stdenv.lib.optionalString stdenv.isDarwin '' + substituteInPlace ./projects/compiler-rt/cmake/config-ix.cmake \ + --replace 'set(COMPILER_RT_HAS_TSAN TRUE)' 'set(COMPILER_RT_HAS_TSAN FALSE)' + + substituteInPlace CMakeLists.txt \ + --replace 'set(CMAKE_INSTALL_NAME_DIR "@rpath")' "set(CMAKE_INSTALL_NAME_DIR "$lib/lib")" \ + --replace 'set(CMAKE_INSTALL_RPATH "@executable_path/../lib")' "" + '' + # Patch llvm-config to return correct library path based on --link-{shared,static}. + + stdenv.lib.optionalString (enableSharedLibraries) '' + substitute '${./llvm-outputs.patch}' ./llvm-outputs.patch --subst-var lib + patch -p1 < ./llvm-outputs.patch + '' + + '' + ( + cd projects/compiler-rt + patch -p1 < ${ + fetchpatch { + name = "sigaltstack.patch"; # for glibc-2.26 + url = https://github.com/llvm-mirror/compiler-rt/commit/8a5e425a68d.diff; + sha256 = "0h4y5vl74qaa7dl54b1fcyqalvlpd8zban2d1jxfkxpzyi7m8ifi"; + } + } + substituteInPlace lib/esan/esan_sideline_linux.cpp \ + --replace 'struct sigaltstack' 'stack_t' + ) + ''; + + # hacky fix: created binaries need to be run before installation + preBuild = '' + mkdir -p $out/ + ln -sv $PWD/lib $out + ''; + + cmakeFlags = with stdenv; [ + "-DCMAKE_BUILD_TYPE=${if debugVersion then "Debug" else "Release"}" + "-DLLVM_INSTALL_UTILS=ON" # Needed by rustc + "-DLLVM_BUILD_TESTS=ON" + "-DLLVM_ENABLE_FFI=ON" + "-DLLVM_ENABLE_RTTI=ON" + "-DCOMPILER_RT_INCLUDE_TESTS=OFF" # FIXME: requires clang source code + + "-DLLVM_HOST_TRIPLE=${stdenv.hostPlatform.config}" + "-DLLVM_DEFAULT_TARGET_TRIPLE=${stdenv.hostPlatform.config}" + "-DTARGET_TRIPLE=${stdenv.hostPlatform.config}" + ] ++ stdenv.lib.optional enableSharedLibraries [ + "-DLLVM_LINK_LLVM_DYLIB=ON" + ] ++ stdenv.lib.optional (!isDarwin) + "-DLLVM_BINUTILS_INCDIR=${libbfd.dev}/include" + ++ stdenv.lib.optionals (isDarwin) [ + "-DLLVM_ENABLE_LIBCXX=ON" + "-DCAN_TARGET_i386=false" + ] ++ stdenv.lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform) [ + "-DCMAKE_CROSSCOMPILING=True" + "-DLLVM_TABLEGEN=${buildPackages.llvmPackages_39.llvm}/bin/llvm-tblgen" + ] ++ stdenv.lib.optionals stdenv.hostPlatform.isMusl [ + # Not yet supported + "-DCOMPILER_RT_BUILD_SANITIZERS=OFF" + "-DCOMPILER_RT_BUILD_XRAY=OFF" + + ]; + + postBuild = '' + rm -fR $out + ''; + + postInstall = "" + + stdenv.lib.optionalString (enableSharedLibraries) '' + moveToOutput "lib/libLLVM-*" "$lib" + moveToOutput "lib/libLLVM${stdenv.hostPlatform.extensions.sharedLibrary}" "$lib" + substituteInPlace "$out/lib/cmake/llvm/LLVMExports-release.cmake" \ + --replace "\''${_IMPORT_PREFIX}/lib/libLLVM-" "$lib/lib/libLLVM-" + '' + + stdenv.lib.optionalString (stdenv.isDarwin && enableSharedLibraries) '' + substituteInPlace "$out/lib/cmake/llvm/LLVMExports-release.cmake" \ + --replace "\''${_IMPORT_PREFIX}/lib/libLLVM.dylib" "$lib/lib/libLLVM.dylib" + ln -s $lib/lib/libLLVM.dylib $lib/lib/libLLVM-${shortVersion}.dylib + ln -s $lib/lib/libLLVM.dylib $lib/lib/libLLVM-${version}.dylib + ''; + + enableParallelBuilding = true; + + passthru.src = src; + + meta = { + description = "Collection of modular and reusable compiler and toolchain technologies"; + homepage = http://llvm.org/; + license = stdenv.lib.licenses.ncsa; + maintainers = with stdenv.lib.maintainers; [ lovek323 raskin ]; + platforms = stdenv.lib.platforms.all; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/llvm/4/clang/default.nix b/nixpkgs/pkgs/development/compilers/llvm/4/clang/default.nix new file mode 100644 index 000000000000..c6538282f23e --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/4/clang/default.nix @@ -0,0 +1,110 @@ +{ stdenv, fetch, cmake, libxml2, llvm, version, release_version, clang-tools-extra_src, python +, fixDarwinDylibNames +, enableManpages ? false +}: + +let + gcc = if stdenv.cc.isGNU then stdenv.cc.cc else stdenv.cc.cc.gcc; + self = stdenv.mkDerivation ({ + name = "clang-${version}"; + + unpackPhase = '' + unpackFile ${fetch "cfe" "16vnv3msnvx33dydd17k2cq0icndi1a06bg5vcxkrhjjb1rqlwv1"} + mv cfe-${version}* clang + sourceRoot=$PWD/clang + unpackFile ${clang-tools-extra_src} + mv clang-tools-extra-* $sourceRoot/tools/extra + ''; + + nativeBuildInputs = [ cmake python ] + ++ stdenv.lib.optional enableManpages python.pkgs.sphinx; + + buildInputs = [ libxml2 llvm ] + ++ stdenv.lib.optional stdenv.isDarwin fixDarwinDylibNames; + + cmakeFlags = [ + "-DCMAKE_CXX_FLAGS=-std=c++11" + ] ++ stdenv.lib.optionals enableManpages [ + "-DCLANG_INCLUDE_DOCS=ON" + "-DLLVM_ENABLE_SPHINX=ON" + "-DSPHINX_OUTPUT_MAN=ON" + "-DSPHINX_OUTPUT_HTML=OFF" + "-DSPHINX_WARNINGS_AS_ERRORS=OFF" + ] + # Maybe with compiler-rt this won't be needed? + ++ stdenv.lib.optional stdenv.isLinux "-DGCC_INSTALL_PREFIX=${gcc}" + ++ stdenv.lib.optional (stdenv.cc.libc != null) "-DC_INCLUDE_DIRS=${stdenv.cc.libc}/include"; + + patches = [ ./purity.patch ]; + + postPatch = '' + sed -i -e 's/Args.hasArg(options::OPT_nostdlibinc)/true/' lib/Driver/Tools.cpp + sed -i -e 's/DriverArgs.hasArg(options::OPT_nostdlibinc)/true/' lib/Driver/ToolChains.cpp + + # Patch for standalone doc building + sed -i '1s,^,find_package(Sphinx REQUIRED)\n,' docs/CMakeLists.txt + '' + stdenv.lib.optionalString stdenv.hostPlatform.isMusl '' + sed -i -e 's/lgcc_s/lgcc_eh/' lib/Driver/Tools.cpp + ''; + + outputs = [ "out" "lib" "python" ]; + + # Clang expects to find LLVMgold in its own prefix + # Clang expects to find sanitizer libraries in its own prefix + postInstall = '' + if [ -e ${llvm}/lib/LLVMgold.so ]; then + ln -sv ${llvm}/lib/LLVMgold.so $out/lib + fi + + ln -sv ${llvm}/lib/clang/${release_version}/lib $out/lib/clang/${release_version}/ + ln -sv $out/bin/clang $out/bin/cpp + + # Move libclang to 'lib' output + moveToOutput "lib/libclang.*" "$lib" + substituteInPlace $out/lib/cmake/clang/ClangTargets-release.cmake \ + --replace "\''${_IMPORT_PREFIX}/lib/libclang." "$lib/lib/libclang." + + mkdir -p $python/bin $python/share/clang/ + mv $out/bin/{git-clang-format,scan-view} $python/bin + if [ -e $out/bin/set-xcode-analyzer ]; then + mv $out/bin/set-xcode-analyzer $python/bin + fi + mv $out/share/clang/*.py $python/share/clang + rm $out/bin/c-index-test + ''; + + enableParallelBuilding = true; + + passthru = { + isClang = true; + inherit llvm; + } // stdenv.lib.optionalAttrs stdenv.isLinux { + inherit gcc; + }; + + meta = { + description = "A c, c++, objective-c, and objective-c++ frontend for the llvm compiler"; + homepage = http://llvm.org/; + license = stdenv.lib.licenses.ncsa; + platforms = stdenv.lib.platforms.all; + }; + } // stdenv.lib.optionalAttrs enableManpages { + name = "clang-manpages-${version}"; + + buildPhase = '' + make docs-clang-man + ''; + + installPhase = '' + mkdir -p $out/share/man/man1 + # Manually install clang manpage + cp docs/man/*.1 $out/share/man/man1/ + ''; + + outputs = [ "out" ]; + + doCheck = false; + + meta.description = "man page for Clang ${version}"; + }); +in self diff --git a/nixpkgs/pkgs/development/compilers/llvm/4/clang/purity.patch b/nixpkgs/pkgs/development/compilers/llvm/4/clang/purity.patch new file mode 100644 index 000000000000..f5fb4c73af47 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/4/clang/purity.patch @@ -0,0 +1,16 @@ +--- a/lib/Driver/Tools.cpp 2016-08-25 15:48:05.187553443 +0200 ++++ b/lib/Driver/Tools.cpp 2016-08-25 15:48:47.534468882 +0200 +@@ -9420,13 +9420,6 @@ + if (!Args.hasArg(options::OPT_static)) { + if (Args.hasArg(options::OPT_rdynamic)) + CmdArgs.push_back("-export-dynamic"); +- +- if (!Args.hasArg(options::OPT_shared)) { +- const std::string Loader = +- D.DyldPrefix + ToolChain.getDynamicLinker(Args); +- CmdArgs.push_back("-dynamic-linker"); +- CmdArgs.push_back(Args.MakeArgString(Loader)); +- } + } + + CmdArgs.push_back("-o"); diff --git a/nixpkgs/pkgs/development/compilers/llvm/4/cmdline-help.patch b/nixpkgs/pkgs/development/compilers/llvm/4/cmdline-help.patch new file mode 100644 index 000000000000..a693719c2cfa --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/4/cmdline-help.patch @@ -0,0 +1,39 @@ +From c7a9aa3a697c81432786a5583bf973771c7be15e Mon Sep 17 00:00:00 2001 +From: Don Hinton <hintonda@gmail.com> +Date: Wed, 12 Jul 2017 01:15:46 +0000 +Subject: [PATCH] Fix minor typo introduced in r276404 + +Summary: +A space was added between '-' and 'help' when emitting help output. + +See https://reviews.llvm.org/D22621 for details. + +Reviewers: MaggieYi, vsk + +Reviewed By: vsk + +Subscribers: llvm-commits + +Differential Revision: https://reviews.llvm.org/D35283 + +git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@307745 91177308-0d34-0410-b5e6-96231b3b80d8 +--- + lib/Support/CommandLine.cpp | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/lib/Support/CommandLine.cpp b/lib/Support/CommandLine.cpp +index 3889902eea5..79defa5c36c 100644 +--- a/lib/Support/CommandLine.cpp ++++ b/lib/Support/CommandLine.cpp +@@ -1236,7 +1236,7 @@ bool CommandLineParser::ParseCommandLineOptions(int argc, + << ": Not enough positional command line arguments specified!\n" + << "Must specify at least " << NumPositionalRequired + << " positional argument" << (NumPositionalRequired > 1 ? "s" : "") +- << ": See: " << argv[0] << " - help\n"; ++ << ": See: " << argv[0] << " -help\n"; + } + + ErrorParsing = true; +-- +2.14.0 + diff --git a/nixpkgs/pkgs/development/compilers/llvm/4/default.nix b/nixpkgs/pkgs/development/compilers/llvm/4/default.nix new file mode 100644 index 000000000000..9651dbb72f4d --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/4/default.nix @@ -0,0 +1,74 @@ +{ lowPrio, newScope, pkgs, stdenv, cmake, libstdcxxHook +, libxml2, python, isl, fetchurl, overrideCC, wrapCCWith +, buildLlvmTools # tools, but from the previous stage, for cross +, targetLlvmLibraries # libraries, but from the next stage, for cross +}: + +let + release_version = "4.0.1"; + version = release_version; # differentiating these is important for rc's + + fetch = name: sha256: fetchurl { + url = "https://releases.llvm.org/${release_version}/${name}-${version}.src.tar.xz"; + inherit sha256; + }; + + compiler-rt_src = fetch "compiler-rt" "0h5lpv1z554szi4r4blbskhwrkd78ir50v3ng8xvk1s86fa7gj53"; + clang-tools-extra_src = fetch "clang-tools-extra" "1dhmp7ccfpr42bmvk3kp37ngjpf3a9m5d4kkpsn7d00hzi7fdl9m"; + + tools = stdenv.lib.makeExtensible (tools: let + callPackage = newScope (tools // { inherit stdenv cmake libxml2 python isl release_version version fetch; }); + in { + + llvm = callPackage ./llvm.nix { + inherit compiler-rt_src; + }; + clang-unwrapped = callPackage ./clang { + inherit clang-tools-extra_src; + }; + + llvm-manpages = lowPrio (tools.llvm.override { + enableManpages = true; + python = pkgs.python; # don't use python-boot + }); + + clang-manpages = lowPrio (tools.clang-unwrapped.override { + enableManpages = true; + python = pkgs.python; # don't use python-boot + }); + + libclang = tools.clang-unwrapped.lib; + + clang = if stdenv.cc.isGNU then tools.libstdcxxClang else tools.libcxxClang; + + libstdcxxClang = wrapCCWith { + cc = tools.clang-unwrapped; + extraPackages = [ libstdcxxHook ]; + }; + + libcxxClang = wrapCCWith { + cc = tools.clang-unwrapped; + extraPackages = [ targetLlvmLibraries.libcxx targetLlvmLibraries.libcxxabi ]; + }; + + lld = callPackage ./lld.nix {}; + + lldb = callPackage ./lldb.nix {}; + }); + + libraries = stdenv.lib.makeExtensible (libraries: let + callPackage = newScope (libraries // buildLlvmTools // { inherit stdenv cmake libxml2 python isl release_version version fetch; }); + in { + + stdenv = overrideCC stdenv buildLlvmTools.clang; + + libcxxStdenv = overrideCC stdenv buildLlvmTools.libcxxClang; + + libcxx = callPackage ./libc++ {}; + + libcxxabi = callPackage ./libc++abi.nix {}; + + openmp = callPackage ./openmp.nix {}; + }); + +in { inherit tools libraries; } // libraries // tools diff --git a/nixpkgs/pkgs/development/compilers/llvm/4/libc++/default.nix b/nixpkgs/pkgs/development/compilers/llvm/4/libc++/default.nix new file mode 100644 index 000000000000..2b543b9d793a --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/4/libc++/default.nix @@ -0,0 +1,58 @@ +{ lib, stdenv, fetch, cmake, python, libcxxabi, fixDarwinDylibNames, version }: + +stdenv.mkDerivation rec { + name = "libc++-${version}"; + + src = fetch "libcxx" "0k6cmjcxnp2pyl8xwy1wkyyckkmdrjddim94yf1gzjbjy9qi22jj"; + + postUnpack = '' + unpackFile ${libcxxabi.src} + export LIBCXXABI_INCLUDE_DIR="$PWD/$(ls -d libcxxabi-${version}*)/include" + ''; + + patches = [ + # https://github.com/llvm-mirror/libcxx/commit/bcc92d75df0274b9593ebd097fcae60494e3bffc + ./pthread_mach_thread_np.patch + # glibc 2.26 fix + ./xlocale-glibc-2.26.patch + ] ++ stdenv.lib.optionals stdenv.hostPlatform.isMusl [ + ../../libcxx-0001-musl-hacks.patch + ../../libcxx-max_align_t.patch + ]; + + prePatch = '' + substituteInPlace lib/CMakeLists.txt --replace "/usr/lib/libc++" "\''${LIBCXX_LIBCXXABI_LIB_PATH}/libc++" + ''; + + preConfigure = '' + # Get headers from the cxxabi source so we can see private headers not installed by the cxxabi package + cmakeFlagsArray=($cmakeFlagsArray -DLIBCXX_CXX_ABI_INCLUDE_PATHS="$LIBCXXABI_INCLUDE_DIR") + '' + lib.optionalString stdenv.hostPlatform.isMusl '' + patchShebangs utils/cat_files.py + ''; + nativeBuildInputs = [ cmake ] ++ stdenv.lib.optional stdenv.hostPlatform.isMusl python; + + buildInputs = [ libcxxabi ] ++ lib.optional stdenv.isDarwin fixDarwinDylibNames; + + cmakeFlags = [ + "-DLIBCXX_LIBCXXABI_LIB_PATH=${libcxxabi}/lib" + "-DLIBCXX_LIBCPPABI_VERSION=2" + "-DLIBCXX_CXX_ABI=libcxxabi" + ] ++ stdenv.lib.optional stdenv.hostPlatform.isMusl "-DLIBCXX_HAS_MUSL_LIBC=1"; + + enableParallelBuilding = true; + + linkCxxAbi = stdenv.isLinux; + + setupHooks = [ + ../../../../../build-support/setup-hooks/role.bash + ./setup-hook.sh + ]; + + meta = { + homepage = http://libcxx.llvm.org/; + description = "A new implementation of the C++ standard library, targeting C++11"; + license = with stdenv.lib.licenses; [ ncsa mit ]; + platforms = stdenv.lib.platforms.unix; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/llvm/4/libc++/pthread_mach_thread_np.patch b/nixpkgs/pkgs/development/compilers/llvm/4/libc++/pthread_mach_thread_np.patch new file mode 100644 index 000000000000..8c71f1b815db --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/4/libc++/pthread_mach_thread_np.patch @@ -0,0 +1,41 @@ +From bcc92d75df0274b9593ebd097fcae60494e3bffc Mon Sep 17 00:00:00 2001 +From: Asiri Rathnayake <asiri.rathnayake@arm.com> +Date: Thu, 26 Jan 2017 10:40:17 +0000 +Subject: [PATCH] Fix chromium build (libcxx) + +Remove the reference to pthread_mach_thread_np() in libcxx headers. + +git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@293167 91177308-0d34-0410-b5e6-96231b3b80d8 +--- + include/__threading_support | 11 ----------- + 1 file changed, 11 deletions(-) + +diff --git a/include/__threading_support b/include/__threading_support +index 13ab769..dfe7fe1 100644 +--- a/include/__threading_support ++++ b/include/__threading_support +@@ -149,11 +149,6 @@ int __libcpp_execute_once(__libcpp_exec_once_flag *flag, + void (*init_routine)(void)); + + // Thread id +-#if defined(__APPLE__) && !defined(__arm__) +-_LIBCPP_THREAD_ABI_VISIBILITY +-mach_port_t __libcpp_thread_get_port(); +-#endif +- + _LIBCPP_THREAD_ABI_VISIBILITY + bool __libcpp_thread_id_equal(__libcpp_thread_id t1, __libcpp_thread_id t2); + +@@ -297,12 +292,6 @@ int __libcpp_execute_once(__libcpp_exec_once_flag *flag, + } + + // Thread id +-#if defined(__APPLE__) && !defined(__arm__) +-mach_port_t __libcpp_thread_get_port() { +- return pthread_mach_thread_np(pthread_self()); +-} +-#endif +- + // Returns non-zero if the thread ids are equal, otherwise 0 + bool __libcpp_thread_id_equal(__libcpp_thread_id t1, __libcpp_thread_id t2) + { diff --git a/nixpkgs/pkgs/development/compilers/llvm/4/libc++/setup-hook.sh b/nixpkgs/pkgs/development/compilers/llvm/4/libc++/setup-hook.sh new file mode 100644 index 000000000000..6611259165ae --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/4/libc++/setup-hook.sh @@ -0,0 +1,6 @@ +# See pkgs/build-support/setup-hooks/role.bash +getHostRole + +linkCxxAbi="@linkCxxAbi@" +export NIX_${role_pre}CXXSTDLIB_COMPILE+=" -isystem @out@/include/c++/v1" +export NIX_${role_pre}CXXSTDLIB_LINK=" -stdlib=libc++${linkCxxAbi:+" -lc++abi"}" diff --git a/nixpkgs/pkgs/development/compilers/llvm/4/libc++/xlocale-glibc-2.26.patch b/nixpkgs/pkgs/development/compilers/llvm/4/libc++/xlocale-glibc-2.26.patch new file mode 100644 index 000000000000..e411d85066b4 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/4/libc++/xlocale-glibc-2.26.patch @@ -0,0 +1,19 @@ +diff --git a/include/__locale b/include/__locale +index f4882de..29443b4 100644 +--- a/include/__locale ++++ b/include/__locale +@@ -34,12 +34,12 @@ + # include <support/solaris/xlocale.h> + #elif defined(_NEWLIB_VERSION) + # include <support/newlib/xlocale.h> +-#elif (defined(__GLIBC__) || defined(__APPLE__) || defined(__FreeBSD__) \ ++#elif (defined(__APPLE__) || defined(__FreeBSD__) \ + || defined(__EMSCRIPTEN__) || defined(__IBMCPP__)) + # include <xlocale.h> + #elif defined(_LIBCPP_HAS_MUSL_LIBC) + # include <support/musl/xlocale.h> +-#endif // __GLIBC__ || __APPLE__ || __FreeBSD__ || __sun__ || __EMSCRIPTEN__ || __IBMCPP__ ++#endif // __APPLE__ || __FreeBSD__ || __sun__ || __EMSCRIPTEN__ || __IBMCPP__ + + #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) + #pragma GCC system_header diff --git a/nixpkgs/pkgs/development/compilers/llvm/4/libc++abi.nix b/nixpkgs/pkgs/development/compilers/llvm/4/libc++abi.nix new file mode 100644 index 000000000000..735c5e9e7435 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/4/libc++abi.nix @@ -0,0 +1,51 @@ +{ stdenv, cmake, fetch, libcxx, libunwind, llvm, version }: + +stdenv.mkDerivation { + name = "libc++abi-${version}"; + + src = fetch "libcxxabi" "0cqvzallxh0nwiijsf6i4d5ds9m5ijfzywg7376ncv50i64if24g"; + + nativeBuildInputs = [ cmake ]; + buildInputs = stdenv.lib.optional (!stdenv.isDarwin && !stdenv.isFreeBSD) libunwind; + + postUnpack = '' + unpackFile ${libcxx.src} + unpackFile ${llvm.src} + export cmakeFlags="-DLLVM_PATH=$PWD/$(ls -d llvm-*) -DLIBCXXABI_LIBCXX_PATH=$PWD/$(ls -d libcxx-*)" + '' + stdenv.lib.optionalString stdenv.isDarwin '' + export TRIPLE=x86_64-apple-darwin + '' + stdenv.lib.optionalString stdenv.hostPlatform.isMusl '' + patch -p1 -d $(ls -d libcxx-*) -i ${../libcxx-0001-musl-hacks.patch} + patch -p1 -d $(ls -d libcxx-*) -i ${../libcxx-max_align_t.patch} + ''; + + installPhase = if stdenv.isDarwin + then '' + for file in lib/*.dylib; do + # this should be done in CMake, but having trouble figuring out + # the magic combination of necessary CMake variables + # if you fancy a try, take a look at + # http://www.cmake.org/Wiki/CMake_RPATH_handling + install_name_tool -id $out/$file $file + done + make install + install -d 755 $out/include + install -m 644 ../include/*.h $out/include + '' + else '' + install -d -m 755 $out/include $out/lib + install -m 644 lib/libc++abi.a $out/lib + install -m 644 lib/libc++abi.so.1.0 $out/lib + install -m 644 ../include/cxxabi.h $out/include + ln -s libc++abi.so.1.0 $out/lib/libc++abi.so + ln -s libc++abi.so.1.0 $out/lib/libc++abi.so.1 + ''; + + meta = { + homepage = http://libcxxabi.llvm.org/; + description = "A new implementation of low level support for a standard C++ library"; + license = with stdenv.lib.licenses; [ ncsa mit ]; + maintainers = with stdenv.lib.maintainers; [ vlstill ]; + platforms = stdenv.lib.platforms.unix; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/llvm/4/lld.nix b/nixpkgs/pkgs/development/compilers/llvm/4/lld.nix new file mode 100644 index 000000000000..21b0c1c3601c --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/4/lld.nix @@ -0,0 +1,31 @@ +{ stdenv +, fetch +, cmake +, llvm +, version +}: + +stdenv.mkDerivation { + name = "lld-${version}"; + + src = fetch "lld" "1v9nkpr158j4yd4zmi6rpnfxkp78r1fapr8wji9s6v176gji1kk3"; + + nativeBuildInputs = [ cmake ]; + buildInputs = [ llvm ]; + + outputs = [ "out" "dev" ]; + + enableParallelBuilding = true; + + postInstall = '' + moveToOutput include "$dev" + moveToOutput lib "$dev" + ''; + + meta = { + description = "The LLVM Linker"; + homepage = http://lld.llvm.org/; + license = stdenv.lib.licenses.ncsa; + platforms = stdenv.lib.platforms.all; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/llvm/4/lldb-libedit.patch b/nixpkgs/pkgs/development/compilers/llvm/4/lldb-libedit.patch new file mode 100644 index 000000000000..73459ce6c864 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/4/lldb-libedit.patch @@ -0,0 +1,30 @@ +From 94764369222a8e6c65420a6981d7f179a18a5417 Mon Sep 17 00:00:00 2001 +From: Will Dietz <w@wdtz.org> +Date: Thu, 25 May 2017 15:03:42 -0500 +Subject: [PATCH] EditLine.h: libedit supports wide chars on NixOS + +--- + include/lldb/Host/Editline.h | 5 +---- + 1 file changed, 1 insertion(+), 4 deletions(-) + +diff --git a/include/lldb/Host/Editline.h b/include/lldb/Host/Editline.h +index faed373bc..b248cdee1 100644 +--- a/include/lldb/Host/Editline.h ++++ b/include/lldb/Host/Editline.h +@@ -43,12 +43,9 @@ + // will only be + // used in cases where this is true. This is a compile time dependecy, for now + // selected per target Platform +-#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) ++// (libedit on NixOS is always wide-char capable) + #define LLDB_EDITLINE_USE_WCHAR 1 + #include <codecvt> +-#else +-#define LLDB_EDITLINE_USE_WCHAR 0 +-#endif + + #include "lldb/Host/ConnectionFileDescriptor.h" + #include "lldb/lldb-private.h" +-- +2.13.0 + diff --git a/nixpkgs/pkgs/development/compilers/llvm/4/lldb.nix b/nixpkgs/pkgs/development/compilers/llvm/4/lldb.nix new file mode 100644 index 000000000000..0be8a4d41865 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/4/lldb.nix @@ -0,0 +1,62 @@ +{ stdenv +, fetch +, cmake +, zlib +, ncurses +, swig +, which +, libedit +, libxml2 +, llvm +, clang-unwrapped +, python +, version +, darwin +}: + +stdenv.mkDerivation { + name = "lldb-${version}"; + + src = fetch "lldb" "0yy43a27zx3r51b6gkv3v2mdiqcq3mf0ngki47ya0i30v3gx4cl4"; + + patches = [ ./lldb-libedit.patch ]; + postPatch = '' + # Fix up various paths that assume llvm and clang are installed in the same place + sed -i 's,".*ClangConfig.cmake","${clang-unwrapped}/lib/cmake/clang/ClangConfig.cmake",' \ + cmake/modules/LLDBStandalone.cmake + sed -i 's,".*tools/clang/include","${clang-unwrapped}/include",' \ + cmake/modules/LLDBStandalone.cmake + sed -i 's,"$.LLVM_LIBRARY_DIR.",${llvm}/lib ${clang-unwrapped}/lib,' \ + cmake/modules/LLDBStandalone.cmake + ''; + + nativeBuildInputs = [ cmake python which swig ]; + buildInputs = [ ncurses zlib libedit libxml2 llvm ] + ++ stdenv.lib.optionals stdenv.isDarwin [ darwin.libobjc darwin.apple_sdk.libs.xpc darwin.apple_sdk.frameworks.Foundation darwin.bootstrap_cmds darwin.apple_sdk.frameworks.Carbon darwin.apple_sdk.frameworks.Cocoa darwin.cf-private ]; + + CXXFLAGS = "-fno-rtti"; + hardeningDisable = [ "format" ]; + + cmakeFlags = [ + "-DLLDB_CODESIGN_IDENTITY=" # codesigning makes nondeterministic + ]; + + # Add missing include to fix error when using std::bind + prePatch = '' + sed -i -e '30i#include <functional>' include/lldb/Utility/TaskPool.h + ''; + + enableParallelBuilding = true; + + postInstall = '' + mkdir -p $out/share/man/man1 + cp ../docs/lldb.1 $out/share/man/man1/ + ''; + + meta = with stdenv.lib; { + description = "A next-generation high-performance debugger"; + homepage = http://llvm.org/; + license = licenses.ncsa; + platforms = platforms.all; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/llvm/4/llvm-outputs.patch b/nixpkgs/pkgs/development/compilers/llvm/4/llvm-outputs.patch new file mode 100644 index 000000000000..40096fa3497f --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/4/llvm-outputs.patch @@ -0,0 +1,26 @@ +diff --git a/tools/llvm-config/llvm-config.cpp b/tools/llvm-config/llvm-config.cpp +index 94d426b..37f7794 100644 +--- a/tools/llvm-config/llvm-config.cpp ++++ b/tools/llvm-config/llvm-config.cpp +@@ -333,6 +333,21 @@ int main(int argc, char **argv) { + ActiveIncludeOption = "-I" + ActiveIncludeDir; + } + ++ /// Nix-specific multiple-output handling: override ActiveLibDir if --link-shared ++ if (!IsInDevelopmentTree) { ++ bool WantShared = true; ++ for (int i = 1; i < argc; ++i) { ++ StringRef Arg = argv[i]; ++ if (Arg == "--link-shared") ++ WantShared = true; ++ else if (Arg == "--link-static") ++ WantShared = false; // the last one wins ++ } ++ ++ if (WantShared) ++ ActiveLibDir = std::string("@lib@") + "/lib" + LLVM_LIBDIR_SUFFIX; ++ } ++ + /// We only use `shared library` mode in cases where the static library form + /// of the components provided are not available; note however that this is + /// skipped if we're run from within the build dir. However, once installed, diff --git a/nixpkgs/pkgs/development/compilers/llvm/4/llvm.nix b/nixpkgs/pkgs/development/compilers/llvm/4/llvm.nix new file mode 100644 index 000000000000..5cd7901fe22c --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/4/llvm.nix @@ -0,0 +1,176 @@ +{ stdenv +, fetch +, fetchpatch +, cmake +, python +, libffi +, libbfd +, libxml2 +, ncurses +, version +, release_version +, zlib +, compiler-rt_src +, debugVersion ? false +, enableManpages ? false +, enableSharedLibraries ? !enableManpages +}: + +let + src = fetch "llvm" "0l9bf7kdwhlj0kq1hawpyxhna1062z3h7qcz2y8nfl9dz2qksy6s"; + + # Used when creating a version-suffixed symlink of libLLVM.dylib + shortVersion = with stdenv.lib; + concatStringsSep "." (take 2 (splitString "." release_version)); +in stdenv.mkDerivation (rec { + name = "llvm-${version}"; + + unpackPhase = '' + unpackFile ${src} + mv llvm-${version}* llvm + sourceRoot=$PWD/llvm + unpackFile ${compiler-rt_src} + mv compiler-rt-* $sourceRoot/projects/compiler-rt + ''; + + outputs = [ "out" ] + ++ stdenv.lib.optional enableSharedLibraries "lib"; + + nativeBuildInputs = [ cmake python ] + ++ stdenv.lib.optional enableManpages python.pkgs.sphinx; + + buildInputs = [ libxml2 libffi ]; + + propagatedBuildInputs = [ ncurses zlib ]; + + # TSAN requires XPC on Darwin, which we have no public/free source files for. We can depend on the Apple frameworks + # to get it, but they're unfree. Since LLVM is rather central to the stdenv, we patch out TSAN support so that Hydra + # can build this. If we didn't do it, basically the entire nixpkgs on Darwin would have an unfree dependency and we'd + # get no binary cache for the entire platform. If you really find yourself wanting the TSAN, make this controllable by + # a flag and turn the flag off during the stdenv build. + postPatch = stdenv.lib.optionalString stdenv.isDarwin '' + substituteInPlace ./projects/compiler-rt/cmake/config-ix.cmake \ + --replace 'set(COMPILER_RT_HAS_TSAN TRUE)' 'set(COMPILER_RT_HAS_TSAN FALSE)' + + substituteInPlace cmake/modules/AddLLVM.cmake \ + --replace 'set(_install_name_dir INSTALL_NAME_DIR "@rpath")' "set(_install_name_dir)" \ + --replace 'set(_install_rpath "@loader_path/../lib" ''${extra_libdir})' "" + '' + # Patch llvm-config to return correct library path based on --link-{shared,static}. + + stdenv.lib.optionalString (enableSharedLibraries) '' + substitute '${./llvm-outputs.patch}' ./llvm-outputs.patch --subst-var lib + patch -p1 < ./llvm-outputs.patch + '' + + '' + ( + cd projects/compiler-rt + patch -p1 < ${ + fetchpatch { + name = "sigaltstack.patch"; # for glibc-2.26 + url = https://github.com/llvm-mirror/compiler-rt/commit/8a5e425a68d.diff; + sha256 = "0h4y5vl74qaa7dl54b1fcyqalvlpd8zban2d1jxfkxpzyi7m8ifi"; + } + } + substituteInPlace lib/esan/esan_sideline_linux.cpp \ + --replace 'struct sigaltstack' 'stack_t' + ) + '' + # Fix extra space printed in commandline help sometimes, "- help" + '' + patch -p1 -i ${./cmdline-help.patch} + '' + stdenv.lib.optionalString stdenv.isAarch64 '' + patch -p0 < ${../aarch64.patch} + '' + stdenv.lib.optionalString stdenv.hostPlatform.isMusl '' + patch -p1 -i ${../TLI-musl.patch} + patch -p1 -i ${../dynamiclibrary-musl.patch} + patch -p1 -i ${./sanitizers-nongnu.patch} -d projects/compiler-rt + ''; + + # hacky fix: created binaries need to be run before installation + preBuild = '' + mkdir -p $out/ + ln -sv $PWD/lib $out + ''; + + cmakeFlags = with stdenv; [ + "-DCMAKE_BUILD_TYPE=${if debugVersion then "Debug" else "Release"}" + "-DLLVM_INSTALL_UTILS=ON" # Needed by rustc + "-DLLVM_BUILD_TESTS=ON" + "-DLLVM_ENABLE_FFI=ON" + "-DLLVM_ENABLE_RTTI=ON" + "-DCOMPILER_RT_INCLUDE_TESTS=OFF" # FIXME: requires clang source code + + "-DLLVM_HOST_TRIPLE=${stdenv.hostPlatform.config}" + "-DLLVM_DEFAULT_TARGET_TRIPLE=${stdenv.hostPlatform.config}" + "-DTARGET_TRIPLE=${stdenv.hostPlatform.config}" + ] + ++ stdenv.lib.optional enableSharedLibraries + "-DLLVM_LINK_LLVM_DYLIB=ON" + ++ stdenv.lib.optionals enableManpages [ + "-DLLVM_BUILD_DOCS=ON" + "-DLLVM_ENABLE_SPHINX=ON" + "-DSPHINX_OUTPUT_MAN=ON" + "-DSPHINX_OUTPUT_HTML=OFF" + "-DSPHINX_WARNINGS_AS_ERRORS=OFF" + ] + ++ stdenv.lib.optional (!isDarwin) + "-DLLVM_BINUTILS_INCDIR=${libbfd.dev}/include" + ++ stdenv.lib.optionals (isDarwin) [ + "-DLLVM_ENABLE_LIBCXX=ON" + "-DCAN_TARGET_i386=false" + ]; + + postBuild = '' + rm -fR $out + ''; + + preCheck = '' + export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$PWD/lib + ''; + + postInstall = stdenv.lib.optionalString enableSharedLibraries '' + moveToOutput "lib/libLLVM-*" "$lib" + moveToOutput "lib/libLLVM${stdenv.hostPlatform.extensions.sharedLibrary}" "$lib" + substituteInPlace "$out/lib/cmake/llvm/LLVMExports-${if debugVersion then "debug" else "release"}.cmake" \ + --replace "\''${_IMPORT_PREFIX}/lib/libLLVM-" "$lib/lib/libLLVM-" + '' + + stdenv.lib.optionalString (stdenv.isDarwin && enableSharedLibraries) '' + substituteInPlace "$out/lib/cmake/llvm/LLVMExports-${if debugVersion then "debug" else "release"}.cmake" \ + --replace "\''${_IMPORT_PREFIX}/lib/libLLVM.dylib" "$lib/lib/libLLVM.dylib" + ln -s $lib/lib/libLLVM.dylib $lib/lib/libLLVM-${shortVersion}.dylib + ln -s $lib/lib/libLLVM.dylib $lib/lib/libLLVM-${release_version}.dylib + ''; + + doCheck = stdenv.isLinux && (!stdenv.isi686); + + checkTarget = "check-all"; + + enableParallelBuilding = true; + + passthru.src = src; + + meta = { + description = "Collection of modular and reusable compiler and toolchain technologies"; + homepage = http://llvm.org/; + license = stdenv.lib.licenses.ncsa; + maintainers = with stdenv.lib.maintainers; [ lovek323 raskin dtzWill ]; + platforms = stdenv.lib.platforms.all; + }; +} // stdenv.lib.optionalAttrs enableManpages { + name = "llvm-manpages-${version}"; + + buildPhase = '' + make docs-llvm-man + ''; + + propagatedBuildInputs = [ ]; + + installPhase = '' + make -C docs install + ''; + + outputs = [ "out" ]; + + doCheck = false; + + meta.description = "man pages for LLVM ${version}"; +}) diff --git a/nixpkgs/pkgs/development/compilers/llvm/4/openmp.nix b/nixpkgs/pkgs/development/compilers/llvm/4/openmp.nix new file mode 100644 index 000000000000..a8a6b3dfea87 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/4/openmp.nix @@ -0,0 +1,25 @@ +{ stdenv +, fetch +, cmake +, llvm +, perl +, version +}: + +stdenv.mkDerivation { + name = "openmp-${version}"; + + src = fetch "openmp" "195dykamd39yhi5az7nqj3ksqhb3wq30l93jnfkxl0061qbknsgc"; + + nativeBuildInputs = [ cmake perl ]; + buildInputs = [ llvm ]; + + enableParallelBuilding = true; + + meta = { + description = "Components required to build an executable OpenMP program"; + homepage = http://openmp.llvm.org/; + license = stdenv.lib.licenses.mit; + platforms = stdenv.lib.platforms.all; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/llvm/4/sanitizers-nongnu.patch b/nixpkgs/pkgs/development/compilers/llvm/4/sanitizers-nongnu.patch new file mode 100644 index 000000000000..5bd858f8ae79 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/4/sanitizers-nongnu.patch @@ -0,0 +1,368 @@ +From dac4d3912378069b44340204e5fc6237aa1baf94 Mon Sep 17 00:00:00 2001 +From: Matthias Maier <tamiko@43-1.org> +Date: Fri, 5 May 2017 17:47:39 +0000 +Subject: [PATCH] Musl patches + +Ported to compiler-rt-sanitizers-4.0.0. Taken from + + https://gist.githubusercontent.com/pwaller/2337f3290f12634cad3e3730cff0a6c1/raw/83c87a8585e2f9662494db5662e5361beb093c26/nongnu.patch +--- + lib/asan/asan_linux.cc | 4 +-- + lib/interception/interception_linux.cc | 2 +- + lib/interception/interception_linux.h | 2 +- + lib/msan/msan_linux.cc | 2 +- + .../sanitizer_common_interceptors_ioctl.inc | 4 +-- + lib/sanitizer_common/sanitizer_common_syscalls.inc | 2 +- + lib/sanitizer_common/sanitizer_linux_libcdep.cc | 12 +++---- + lib/sanitizer_common/sanitizer_platform.h | 7 ++++ + .../sanitizer_platform_interceptors.h | 2 +- + .../sanitizer_platform_limits_posix.cc | 39 +++++++++++++--------- + lib/tsan/rtl/tsan_platform_linux.cc | 2 +- + 11 files changed, 46 insertions(+), 32 deletions(-) + +diff --git a/lib/asan/asan_linux.cc b/lib/asan/asan_linux.cc +index c051573dd..e295f6004 100644 +--- a/lib/asan/asan_linux.cc ++++ b/lib/asan/asan_linux.cc +@@ -39,7 +39,7 @@ + #include <sys/link_elf.h> + #endif + +-#if SANITIZER_ANDROID || SANITIZER_FREEBSD ++#if SANITIZER_ANDROID || SANITIZER_FREEBSD || SANITIZER_NONGNU + #include <ucontext.h> + extern "C" void* _DYNAMIC; + #else +@@ -80,7 +80,7 @@ void AsanApplyToGlobals(globals_op_fptr op, const void *needle) { + UNIMPLEMENTED(); + } + +-#if SANITIZER_ANDROID ++#if SANITIZER_ANDROID || SANITIZER_NONGNU + // FIXME: should we do anything for Android? + void AsanCheckDynamicRTPrereqs() {} + void AsanCheckIncompatibleRT() {} +diff --git a/lib/interception/interception_linux.cc b/lib/interception/interception_linux.cc +index 6e908ac01..8f23d9adc 100644 +--- a/lib/interception/interception_linux.cc ++++ b/lib/interception/interception_linux.cc +@@ -24,7 +24,7 @@ bool GetRealFunctionAddress(const char *func_name, uptr *func_addr, + return real == wrapper; + } + +-#if !defined(__ANDROID__) // android does not have dlvsym ++#if !defined(__ANDROID__) && !SANITIZER_NONGNU // android does not have dlvsym + void *GetFuncAddrVer(const char *func_name, const char *ver) { + return dlvsym(RTLD_NEXT, func_name, ver); + } +diff --git a/lib/interception/interception_linux.h b/lib/interception/interception_linux.h +index 27a66c882..3b559a303 100644 +--- a/lib/interception/interception_linux.h ++++ b/lib/interception/interception_linux.h +@@ -34,7 +34,7 @@ void *GetFuncAddrVer(const char *func_name, const char *ver); + (::__interception::uptr) & (func), \ + (::__interception::uptr) & WRAP(func)) + +-#if !defined(__ANDROID__) // android does not have dlvsym ++#if !defined(__ANDROID__) && !SANITIZER_NONGNU // android does not have dlvsym + #define INTERCEPT_FUNCTION_VER_LINUX_OR_FREEBSD(func, symver) \ + (::__interception::real_##func = (func##_f)( \ + unsigned long)::__interception::GetFuncAddrVer(#func, symver)) +diff --git a/lib/msan/msan_linux.cc b/lib/msan/msan_linux.cc +index 0a687f620..0852d97d7 100644 +--- a/lib/msan/msan_linux.cc ++++ b/lib/msan/msan_linux.cc +@@ -13,7 +13,7 @@ + //===----------------------------------------------------------------------===// + + #include "sanitizer_common/sanitizer_platform.h" +-#if SANITIZER_FREEBSD || SANITIZER_LINUX ++#if SANITIZER_FREEBSD || SANITIZER_LINUX && !SANITIZER_NONGNU + + #include "msan.h" + #include "msan_thread.h" +diff --git a/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc b/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc +index 4ed9afedf..64f584e93 100644 +--- a/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc ++++ b/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc +@@ -100,7 +100,7 @@ static void ioctl_table_fill() { + _(SIOCGETVIFCNT, WRITE, struct_sioc_vif_req_sz); + #endif + +-#if SANITIZER_LINUX ++#if SANITIZER_LINUX && !SANITIZER_NONGNU + // Conflicting request ids. + // _(CDROMAUDIOBUFSIZ, NONE, 0); + // _(SNDCTL_TMR_CONTINUE, NONE, 0); +@@ -361,7 +361,7 @@ static void ioctl_table_fill() { + _(VT_WAITACTIVE, NONE, 0); + #endif + +-#if SANITIZER_LINUX && !SANITIZER_ANDROID ++#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU + // _(SIOCDEVPLIP, WRITE, struct_ifreq_sz); // the same as EQL_ENSLAVE + _(CYGETDEFTHRESH, WRITE, sizeof(int)); + _(CYGETDEFTIMEOUT, WRITE, sizeof(int)); +diff --git a/lib/sanitizer_common/sanitizer_common_syscalls.inc b/lib/sanitizer_common/sanitizer_common_syscalls.inc +index 469c8eb7e..24f87867d 100644 +--- a/lib/sanitizer_common/sanitizer_common_syscalls.inc ++++ b/lib/sanitizer_common/sanitizer_common_syscalls.inc +@@ -2038,7 +2038,7 @@ POST_SYSCALL(setrlimit)(long res, long resource, void *rlim) { + } + } + +-#if !SANITIZER_ANDROID ++#if !SANITIZER_ANDROID && !SANITIZER_NONGNU + PRE_SYSCALL(prlimit64)(long pid, long resource, const void *new_rlim, + void *old_rlim) { + if (new_rlim) PRE_READ(new_rlim, struct_rlimit64_sz); +diff --git a/lib/sanitizer_common/sanitizer_linux_libcdep.cc b/lib/sanitizer_common/sanitizer_linux_libcdep.cc +index f99f0b594..3a773a94e 100644 +--- a/lib/sanitizer_common/sanitizer_linux_libcdep.cc ++++ b/lib/sanitizer_common/sanitizer_linux_libcdep.cc +@@ -152,7 +152,7 @@ bool SanitizerGetThreadName(char *name, int max_len) { + #endif + } + +-#if !SANITIZER_FREEBSD && !SANITIZER_ANDROID && !SANITIZER_GO ++#if !SANITIZER_FREEBSD && !SANITIZER_ANDROID && !SANITIZER_GO && !SANITIZER_NONGNU + static uptr g_tls_size; + + #ifdef __i386__ +@@ -180,11 +180,11 @@ void InitTlsSize() { + } + #else + void InitTlsSize() { } +-#endif // !SANITIZER_FREEBSD && !SANITIZER_ANDROID && !SANITIZER_GO ++#endif // !SANITIZER_FREEBSD && !SANITIZER_ANDROID && !SANITIZER_GO && !SANITIZER_NONGNU + + #if (defined(__x86_64__) || defined(__i386__) || defined(__mips__) \ + || defined(__aarch64__) || defined(__powerpc64__) || defined(__s390__)) \ +- && SANITIZER_LINUX && !SANITIZER_ANDROID ++ && SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU + // sizeof(struct pthread) from glibc. + static atomic_uintptr_t kThreadDescriptorSize; + +@@ -338,7 +338,7 @@ uptr ThreadSelf() { + + #if !SANITIZER_GO + static void GetTls(uptr *addr, uptr *size) { +-#if SANITIZER_LINUX && !SANITIZER_ANDROID ++#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU + # if defined(__x86_64__) || defined(__i386__) || defined(__s390__) + *addr = ThreadSelf(); + *size = GetTlsSize(); +@@ -364,7 +364,7 @@ static void GetTls(uptr *addr, uptr *size) { + *addr = (uptr) dtv[2]; + *size = (*addr == 0) ? 0 : ((uptr) segbase[0] - (uptr) dtv[2]); + } +-#elif SANITIZER_ANDROID ++#elif SANITIZER_ANDROID || SANITIZER_NONGNU + *addr = 0; + *size = 0; + #else +@@ -375,7 +375,7 @@ static void GetTls(uptr *addr, uptr *size) { + + #if !SANITIZER_GO + uptr GetTlsSize() { +-#if SANITIZER_FREEBSD || SANITIZER_ANDROID ++#if SANITIZER_FREEBSD || SANITIZER_ANDROID || SANITIZER_NONGNU + uptr addr, size; + GetTls(&addr, &size); + return size; +diff --git a/lib/sanitizer_common/sanitizer_platform.h b/lib/sanitizer_common/sanitizer_platform.h +index d9a8e8df1..fe01c5744 100644 +--- a/lib/sanitizer_common/sanitizer_platform.h ++++ b/lib/sanitizer_common/sanitizer_platform.h +@@ -162,6 +162,13 @@ + # define SANITIZER_PPC64V2 0 + #endif + ++ ++#if defined(__linux__) && !defined(__GLIBC__) ++# define SANITIZER_NONGNU 1 ++#else ++# define SANITIZER_NONGNU 0 ++#endif ++ + // By default we allow to use SizeClassAllocator64 on 64-bit platform. + // But in some cases (e.g. AArch64's 39-bit address space) SizeClassAllocator64 + // does not work well and we need to fallback to SizeClassAllocator32. +diff --git a/lib/sanitizer_common/sanitizer_platform_interceptors.h b/lib/sanitizer_common/sanitizer_platform_interceptors.h +index 62875d11a..212e6e882 100644 +--- a/lib/sanitizer_common/sanitizer_platform_interceptors.h ++++ b/lib/sanitizer_common/sanitizer_platform_interceptors.h +@@ -23,7 +23,7 @@ + # define SI_NOT_WINDOWS 0 + #endif + +-#if SANITIZER_LINUX && !SANITIZER_ANDROID ++#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU + # define SI_LINUX_NOT_ANDROID 1 + #else + # define SI_LINUX_NOT_ANDROID 0 +diff --git a/lib/sanitizer_common/sanitizer_platform_limits_posix.cc b/lib/sanitizer_common/sanitizer_platform_limits_posix.cc +index 683f019d7..fd4880962 100644 +--- a/lib/sanitizer_common/sanitizer_platform_limits_posix.cc ++++ b/lib/sanitizer_common/sanitizer_platform_limits_posix.cc +@@ -14,6 +14,8 @@ + + #include "sanitizer_platform.h" + ++#define _LINUX_SYSINFO_H ++ + #if SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_MAC + // Tests in this file assume that off_t-dependent data structures match the + // libc ABI. For example, struct dirent here is what readdir() function (as +@@ -139,12 +141,14 @@ typedef struct user_fpregs elf_fpregset_t; + + #if SANITIZER_LINUX && !SANITIZER_ANDROID + #include <glob.h> +-#include <obstack.h> ++# if !SANITIZER_NONGNU ++# include <obstack.h> ++# endif + #include <mqueue.h> +-#include <net/if_ppp.h> +-#include <netax25/ax25.h> +-#include <netipx/ipx.h> +-#include <netrom/netrom.h> ++#include <linux/if_ppp.h> ++#include <linux/ax25.h> ++#include <linux/ipx.h> ++#include <linux/netrom.h> + #if HAVE_RPC_XDR_H + # include <rpc/xdr.h> + #elif HAVE_TIRPC_RPC_XDR_H +@@ -160,7 +164,8 @@ typedef struct user_fpregs elf_fpregset_t; + # include <sys/procfs.h> + #endif + #include <sys/user.h> +-#include <sys/ustat.h> ++// #include <sys/ustat.h> ++#include <sys/statfs.h> + #include <linux/cyclades.h> + #include <linux/if_eql.h> + #include <linux/if_plip.h> +@@ -252,7 +257,7 @@ namespace __sanitizer { + unsigned struct_itimerspec_sz = sizeof(struct itimerspec); + #endif // SANITIZER_LINUX || SANITIZER_FREEBSD + +-#if SANITIZER_LINUX && !SANITIZER_ANDROID ++#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU + unsigned struct_ustat_sz = sizeof(struct ustat); + unsigned struct_rlimit64_sz = sizeof(struct rlimit64); + unsigned struct_statvfs64_sz = sizeof(struct statvfs64); +@@ -310,7 +315,7 @@ unsigned struct_ElfW_Phdr_sz = sizeof(ElfW(Phdr)); + unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr); + #endif + +-#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID ++#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID && !SANITIZER_NONGNU + int glob_nomatch = GLOB_NOMATCH; + int glob_altdirfunc = GLOB_ALTDIRFUNC; + #endif +@@ -404,7 +409,7 @@ unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr); + unsigned struct_termios_sz = sizeof(struct termios); + unsigned struct_winsize_sz = sizeof(struct winsize); + +-#if SANITIZER_LINUX ++#if SANITIZER_LINUX && !SANITIZER_NONGNU + unsigned struct_arpreq_sz = sizeof(struct arpreq); + unsigned struct_cdrom_msf_sz = sizeof(struct cdrom_msf); + unsigned struct_cdrom_multisession_sz = sizeof(struct cdrom_multisession); +@@ -454,7 +459,7 @@ unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr); + unsigned struct_vt_mode_sz = sizeof(struct vt_mode); + #endif // SANITIZER_LINUX || SANITIZER_FREEBSD + +-#if SANITIZER_LINUX && !SANITIZER_ANDROID ++#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU + unsigned struct_ax25_parms_struct_sz = sizeof(struct ax25_parms_struct); + unsigned struct_cyclades_monitor_sz = sizeof(struct cyclades_monitor); + #if EV_VERSION > (0x010000) +@@ -822,7 +827,7 @@ unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr); + unsigned IOCTL_VT_WAITACTIVE = VT_WAITACTIVE; + #endif // SANITIZER_LINUX || SANITIZER_FREEBSD + +-#if SANITIZER_LINUX && !SANITIZER_ANDROID ++#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU + unsigned IOCTL_CYGETDEFTHRESH = CYGETDEFTHRESH; + unsigned IOCTL_CYGETDEFTIMEOUT = CYGETDEFTIMEOUT; + unsigned IOCTL_CYGETMON = CYGETMON; +@@ -985,7 +990,7 @@ CHECK_SIZE_AND_OFFSET(dl_phdr_info, dlpi_phdr); + CHECK_SIZE_AND_OFFSET(dl_phdr_info, dlpi_phnum); + #endif // SANITIZER_LINUX || SANITIZER_FREEBSD + +-#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID ++#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID && !SANITIZER_NONGNU + CHECK_TYPE_SIZE(glob_t); + CHECK_SIZE_AND_OFFSET(glob_t, gl_pathc); + CHECK_SIZE_AND_OFFSET(glob_t, gl_pathv); +@@ -1019,6 +1024,7 @@ CHECK_TYPE_SIZE(iovec); + CHECK_SIZE_AND_OFFSET(iovec, iov_base); + CHECK_SIZE_AND_OFFSET(iovec, iov_len); + ++#if !SANITIZER_NONGNU + CHECK_TYPE_SIZE(msghdr); + CHECK_SIZE_AND_OFFSET(msghdr, msg_name); + CHECK_SIZE_AND_OFFSET(msghdr, msg_namelen); +@@ -1032,6 +1038,7 @@ CHECK_TYPE_SIZE(cmsghdr); + CHECK_SIZE_AND_OFFSET(cmsghdr, cmsg_len); + CHECK_SIZE_AND_OFFSET(cmsghdr, cmsg_level); + CHECK_SIZE_AND_OFFSET(cmsghdr, cmsg_type); ++#endif + + COMPILER_CHECK(sizeof(__sanitizer_dirent) <= sizeof(dirent)); + CHECK_SIZE_AND_OFFSET(dirent, d_ino); +@@ -1134,7 +1141,7 @@ CHECK_SIZE_AND_OFFSET(mntent, mnt_passno); + + CHECK_TYPE_SIZE(ether_addr); + +-#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID ++#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID && !SANITIZER_NONGNU + CHECK_TYPE_SIZE(ipc_perm); + # if SANITIZER_FREEBSD + CHECK_SIZE_AND_OFFSET(ipc_perm, key); +@@ -1195,7 +1202,7 @@ CHECK_SIZE_AND_OFFSET(ifaddrs, ifa_dstaddr); + CHECK_SIZE_AND_OFFSET(ifaddrs, ifa_data); + #endif + +-#if SANITIZER_LINUX ++#if SANITIZER_LINUX && !SANITIZER_NONGNU + COMPILER_CHECK(sizeof(__sanitizer_mallinfo) == sizeof(struct mallinfo)); + #endif + +@@ -1245,7 +1252,7 @@ COMPILER_CHECK(__sanitizer_XDR_DECODE == XDR_DECODE); + COMPILER_CHECK(__sanitizer_XDR_FREE == XDR_FREE); + #endif + +-#if SANITIZER_LINUX && !SANITIZER_ANDROID ++#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU + COMPILER_CHECK(sizeof(__sanitizer_FILE) <= sizeof(FILE)); + CHECK_SIZE_AND_OFFSET(FILE, _flags); + CHECK_SIZE_AND_OFFSET(FILE, _IO_read_ptr); +@@ -1264,7 +1271,7 @@ CHECK_SIZE_AND_OFFSET(FILE, _chain); + CHECK_SIZE_AND_OFFSET(FILE, _fileno); + #endif + +-#if SANITIZER_LINUX && !SANITIZER_ANDROID ++#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU + COMPILER_CHECK(sizeof(__sanitizer__obstack_chunk) <= sizeof(_obstack_chunk)); + CHECK_SIZE_AND_OFFSET(_obstack_chunk, limit); + CHECK_SIZE_AND_OFFSET(_obstack_chunk, prev); +diff --git a/lib/tsan/rtl/tsan_platform_linux.cc b/lib/tsan/rtl/tsan_platform_linux.cc +index 3313288a7..103c7b6b9 100644 +--- a/lib/tsan/rtl/tsan_platform_linux.cc ++++ b/lib/tsan/rtl/tsan_platform_linux.cc +@@ -287,7 +287,7 @@ void InitializePlatform() { + // This is required to properly "close" the fds, because we do not see internal + // closes within glibc. The code is a pure hack. + int ExtractResolvFDs(void *state, int *fds, int nfd) { +-#if SANITIZER_LINUX && !SANITIZER_ANDROID ++#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU + int cnt = 0; + __res_state *statp = (__res_state*)state; + for (int i = 0; i < MAXNS && cnt < nfd; i++) { +-- +2.16.2 + diff --git a/nixpkgs/pkgs/development/compilers/llvm/5/clang/default.nix b/nixpkgs/pkgs/development/compilers/llvm/5/clang/default.nix new file mode 100644 index 000000000000..5fd0271f0261 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/5/clang/default.nix @@ -0,0 +1,106 @@ +{ stdenv, fetch, cmake, libxml2, llvm, version, clang-tools-extra_src, python +, fixDarwinDylibNames +, enableManpages ? false +}: + +let + gcc = if stdenv.cc.isGNU then stdenv.cc.cc else stdenv.cc.cc.gcc; + self = stdenv.mkDerivation ({ + name = "clang-${version}"; + + unpackPhase = '' + unpackFile ${fetch "cfe" "0018520c4qxf5hgjdqgpz2dgl3faf4gsz87fdlb8zdmx99rfk77s"} + mv cfe-${version}* clang + sourceRoot=$PWD/clang + unpackFile ${clang-tools-extra_src} + mv clang-tools-extra-* $sourceRoot/tools/extra + ''; + + nativeBuildInputs = [ cmake python ] + ++ stdenv.lib.optional enableManpages python.pkgs.sphinx; + + buildInputs = [ libxml2 llvm ] + ++ stdenv.lib.optional stdenv.isDarwin fixDarwinDylibNames; + + cmakeFlags = [ + "-DCMAKE_CXX_FLAGS=-std=c++11" + ] ++ stdenv.lib.optionals enableManpages [ + "-DCLANG_INCLUDE_DOCS=ON" + "-DLLVM_ENABLE_SPHINX=ON" + "-DSPHINX_OUTPUT_MAN=ON" + "-DSPHINX_OUTPUT_HTML=OFF" + "-DSPHINX_WARNINGS_AS_ERRORS=OFF" + ]; + + patches = [ ./purity.patch ]; + + postPatch = '' + sed -i -e 's/DriverArgs.hasArg(options::OPT_nostdlibinc)/true/' \ + -e 's/Args.hasArg(options::OPT_nostdlibinc)/true/' \ + lib/Driver/ToolChains/*.cpp + + # Patch for standalone doc building + sed -i '1s,^,find_package(Sphinx REQUIRED)\n,' docs/CMakeLists.txt + '' + stdenv.lib.optionalString stdenv.hostPlatform.isMusl '' + sed -i -e 's/lgcc_s/lgcc_eh/' lib/Driver/ToolChains/*.cpp + ''; + + outputs = [ "out" "lib" "python" ]; + + # Clang expects to find LLVMgold in its own prefix + postInstall = '' + if [ -e ${llvm}/lib/LLVMgold.so ]; then + ln -sv ${llvm}/lib/LLVMgold.so $out/lib + fi + + ln -sv $out/bin/clang $out/bin/cpp + + # Move libclang to 'lib' output + moveToOutput "lib/libclang.*" "$lib" + substituteInPlace $out/lib/cmake/clang/ClangTargets-release.cmake \ + --replace "\''${_IMPORT_PREFIX}/lib/libclang." "$lib/lib/libclang." + + mkdir -p $python/bin $python/share/clang/ + mv $out/bin/{git-clang-format,scan-view} $python/bin + if [ -e $out/bin/set-xcode-analyzer ]; then + mv $out/bin/set-xcode-analyzer $python/bin + fi + mv $out/share/clang/*.py $python/share/clang + rm $out/bin/c-index-test + ''; + + enableParallelBuilding = true; + + passthru = { + isClang = true; + inherit llvm; + } // stdenv.lib.optionalAttrs stdenv.isLinux { + inherit gcc; + }; + + meta = { + description = "A c, c++, objective-c, and objective-c++ frontend for the llvm compiler"; + homepage = http://llvm.org/; + license = stdenv.lib.licenses.ncsa; + platforms = stdenv.lib.platforms.all; + }; + } // stdenv.lib.optionalAttrs enableManpages { + name = "clang-manpages-${version}"; + + buildPhase = '' + make docs-clang-man + ''; + + installPhase = '' + mkdir -p $out/share/man/man1 + # Manually install clang manpage + cp docs/man/*.1 $out/share/man/man1/ + ''; + + outputs = [ "out" ]; + + doCheck = false; + + meta.description = "man page for Clang ${version}"; + }); +in self diff --git a/nixpkgs/pkgs/development/compilers/llvm/5/clang/purity.patch b/nixpkgs/pkgs/development/compilers/llvm/5/clang/purity.patch new file mode 100644 index 000000000000..b30d0d0b5d5b --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/5/clang/purity.patch @@ -0,0 +1,30 @@ +From 4add81bba40dcec62c4ea4481be8e35ac53e89d8 Mon Sep 17 00:00:00 2001 +From: Will Dietz <w@wdtz.org> +Date: Thu, 18 May 2017 11:56:12 -0500 +Subject: [PATCH] "purity" patch for 5.0 + +--- + lib/Driver/ToolChains/Gnu.cpp | 7 ------- + 1 file changed, 7 deletions(-) + +diff --git a/lib/Driver/ToolChains/Gnu.cpp b/lib/Driver/ToolChains/Gnu.cpp +index fe3c0191bb..c6a482bece 100644 +--- a/lib/Driver/ToolChains/Gnu.cpp ++++ b/lib/Driver/ToolChains/Gnu.cpp +@@ -494,13 +494,6 @@ void tools::gnutools::Linker::ConstructJob(Compilation &C, const JobAction &JA, + if (!Args.hasArg(options::OPT_static)) { + if (Args.hasArg(options::OPT_rdynamic)) + CmdArgs.push_back("-export-dynamic"); +- +- if (!Args.hasArg(options::OPT_shared)) { +- const std::string Loader = +- D.DyldPrefix + ToolChain.getDynamicLinker(Args); +- CmdArgs.push_back("-dynamic-linker"); +- CmdArgs.push_back(Args.MakeArgString(Loader)); +- } + } + + CmdArgs.push_back("-o"); +-- +2.11.0 + diff --git a/nixpkgs/pkgs/development/compilers/llvm/5/compiler-rt-codesign.patch b/nixpkgs/pkgs/development/compilers/llvm/5/compiler-rt-codesign.patch new file mode 100644 index 000000000000..8f4c76bca1eb --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/5/compiler-rt-codesign.patch @@ -0,0 +1,155 @@ +From 3dec5f3475a26aeb4678627795c4b67c6b7b4785 Mon Sep 17 00:00:00 2001 +From: Will Dietz <w@wdtz.org> +Date: Tue, 19 Sep 2017 13:13:06 -0500 +Subject: [PATCH] remove codesign use on Apple, disable ios sim testing that + needs it + +--- + cmake/Modules/AddCompilerRT.cmake | 8 ------ + test/asan/CMakeLists.txt | 52 --------------------------------------- + test/tsan/CMakeLists.txt | 47 ----------------------------------- + 3 files changed, 107 deletions(-) + +diff --git a/cmake/Modules/AddCompilerRT.cmake b/cmake/Modules/AddCompilerRT.cmake +index bc5fb9ff7..b64eb4246 100644 +--- a/cmake/Modules/AddCompilerRT.cmake ++++ b/cmake/Modules/AddCompilerRT.cmake +@@ -210,14 +210,6 @@ function(add_compiler_rt_runtime name type) + set_target_properties(${libname} PROPERTIES IMPORT_PREFIX "") + set_target_properties(${libname} PROPERTIES IMPORT_SUFFIX ".lib") + endif() +- if(APPLE) +- # Ad-hoc sign the dylibs +- add_custom_command(TARGET ${libname} +- POST_BUILD +- COMMAND codesign --sign - $<TARGET_FILE:${libname}> +- WORKING_DIRECTORY ${COMPILER_RT_LIBRARY_OUTPUT_DIR} +- ) +- endif() + endif() + install(TARGETS ${libname} + ARCHIVE DESTINATION ${COMPILER_RT_LIBRARY_INSTALL_DIR} +diff --git a/test/asan/CMakeLists.txt b/test/asan/CMakeLists.txt +index 8bfc15b5c..f23d0f71a 100644 +--- a/test/asan/CMakeLists.txt ++++ b/test/asan/CMakeLists.txt +@@ -83,58 +83,6 @@ foreach(arch ${ASAN_TEST_ARCH}) + endif() + endforeach() + +-# iOS and iOS simulator test suites +-# These are not added into "check-all", in order to run these tests, use +-# "check-asan-iossim-x86_64" and similar. They also require that an extra env +-# variable to select which iOS device or simulator to use, e.g.: +-# SANITIZER_IOSSIM_TEST_DEVICE_IDENTIFIER="iPhone 6" +-if(APPLE) +- set(EXCLUDE_FROM_ALL ON) +- +- set(ASAN_TEST_TARGET_CC ${COMPILER_RT_TEST_COMPILER}) +- set(ASAN_TEST_IOS "1") +- pythonize_bool(ASAN_TEST_IOS) +- set(ASAN_TEST_DYNAMIC True) +- +- foreach(arch ${DARWIN_iossim_ARCHS}) +- set(ASAN_TEST_IOSSIM "1") +- pythonize_bool(ASAN_TEST_IOSSIM) +- set(ASAN_TEST_TARGET_ARCH ${arch}) +- set(ASAN_TEST_TARGET_CFLAGS "-arch ${arch} -isysroot ${DARWIN_iossim_SYSROOT} ${COMPILER_RT_TEST_COMPILER_CFLAGS}") +- set(ASAN_TEST_CONFIG_SUFFIX "-${arch}-iossim") +- get_bits_for_arch(${arch} ASAN_TEST_BITS) +- string(TOUPPER ${arch} ARCH_UPPER_CASE) +- set(CONFIG_NAME "IOSSim${ARCH_UPPER_CASE}Config") +- configure_lit_site_cfg( +- ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in +- ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/lit.site.cfg +- ) +- add_lit_testsuite(check-asan-iossim-${arch} "AddressSanitizer iOS Simulator ${arch} tests" +- ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/ +- DEPENDS ${ASAN_TEST_DEPS}) +- endforeach() +- +- foreach (arch ${DARWIN_ios_ARCHS}) +- set(ASAN_TEST_IOSSIM "0") +- pythonize_bool(ASAN_TEST_IOSSIM) +- set(ASAN_TEST_TARGET_ARCH ${arch}) +- set(ASAN_TEST_TARGET_CFLAGS "-arch ${arch} -isysroot ${DARWIN_ios_SYSROOT} ${COMPILER_RT_TEST_COMPILER_CFLAGS}") +- set(ASAN_TEST_CONFIG_SUFFIX "-${arch}-ios") +- get_bits_for_arch(${arch} ASAN_TEST_BITS) +- string(TOUPPER ${arch} ARCH_UPPER_CASE) +- set(CONFIG_NAME "IOS${ARCH_UPPER_CASE}Config") +- configure_lit_site_cfg( +- ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in +- ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/lit.site.cfg +- ) +- add_lit_testsuite(check-asan-ios-${arch} "AddressSanitizer iOS ${arch} tests" +- ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/ +- DEPENDS ${ASAN_TEST_DEPS}) +- endforeach() +- +- set(EXCLUDE_FROM_ALL OFF) +-endif() +- + # Add unit tests. + if(COMPILER_RT_INCLUDE_TESTS) + set(ASAN_TEST_DYNAMIC False) +diff --git a/test/tsan/CMakeLists.txt b/test/tsan/CMakeLists.txt +index a68908612..cde0accb5 100644 +--- a/test/tsan/CMakeLists.txt ++++ b/test/tsan/CMakeLists.txt +@@ -42,53 +42,6 @@ foreach(arch ${TSAN_TEST_ARCH}) + list(APPEND TSAN_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}) + endforeach() + +-# iOS and iOS simulator test suites +-# These are not added into "check-all", in order to run these tests, use +-# "check-tsan-iossim-x86_64" and similar. They also require an extra environment +-# variable to select which iOS device or simulator to use, e.g.: +-# SANITIZER_IOSSIM_TEST_DEVICE_IDENTIFIER="iPhone 6" +-if(APPLE) +- set(EXCLUDE_FROM_ALL ON) +- +- set(TSAN_TEST_TARGET_CC ${COMPILER_RT_TEST_COMPILER}) +- set(TSAN_TEST_IOS "1") +- pythonize_bool(TSAN_TEST_IOS) +- +- set(arch "x86_64") +- set(TSAN_TEST_IOSSIM "1") +- pythonize_bool(TSAN_TEST_IOSSIM) +- set(TSAN_TEST_TARGET_ARCH ${arch}) +- set(TSAN_TEST_TARGET_CFLAGS "-arch ${arch} -isysroot ${DARWIN_iossim_SYSROOT} ${COMPILER_RT_TEST_COMPILER_CFLAGS}") +- set(TSAN_TEST_CONFIG_SUFFIX "-${arch}-iossim") +- string(TOUPPER ${arch} ARCH_UPPER_CASE) +- set(CONFIG_NAME "IOSSim${ARCH_UPPER_CASE}Config") +- configure_lit_site_cfg( +- ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in +- ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/lit.site.cfg +- ) +- add_lit_testsuite(check-tsan-iossim-${arch} "ThreadSanitizer iOS Simulator ${arch} tests" +- ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/ +- DEPENDS ${TSAN_TEST_DEPS}) +- +- set(arch "arm64") +- set(TSAN_TEST_IOSSIM "0") +- pythonize_bool(TSAN_TEST_IOSSIM) +- set(TSAN_TEST_TARGET_ARCH ${arch}) +- set(TSAN_TEST_TARGET_CFLAGS "-arch ${arch} -isysroot ${DARWIN_ios_SYSROOT} ${COMPILER_RT_TEST_COMPILER_CFLAGS}") +- set(TSAN_TEST_CONFIG_SUFFIX "-${arch}-ios") +- string(TOUPPER ${arch} ARCH_UPPER_CASE) +- set(CONFIG_NAME "IOS${ARCH_UPPER_CASE}Config") +- configure_lit_site_cfg( +- ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in +- ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/lit.site.cfg +- ) +- add_lit_testsuite(check-tsan-ios-${arch} "ThreadSanitizer iOS Simulator ${arch} tests" +- ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/ +- DEPENDS ${TSAN_TEST_DEPS}) +- +- set(EXCLUDE_FROM_ALL OFF) +-endif() +- + if(COMPILER_RT_INCLUDE_TESTS) + configure_lit_site_cfg( + ${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.site.cfg.in +-- +2.14.1 + diff --git a/nixpkgs/pkgs/development/compilers/llvm/5/compiler-rt.nix b/nixpkgs/pkgs/development/compilers/llvm/5/compiler-rt.nix new file mode 100644 index 000000000000..19833e4d3d4a --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/5/compiler-rt.nix @@ -0,0 +1,37 @@ +{ stdenv, version, fetch, cmake, python, llvm, libcxxabi }: +with stdenv.lib; +stdenv.mkDerivation rec { + name = "compiler-rt-${version}"; + inherit version; + src = fetch "compiler-rt" "0ipd4jdxpczgr2w6lzrabymz6dhzj69ywmyybjjc1q397zgrvziy"; + + nativeBuildInputs = [ cmake python llvm ]; + buildInputs = stdenv.lib.optional stdenv.hostPlatform.isDarwin libcxxabi; + + configureFlags = [ + "-DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON" + ]; + + outputs = [ "out" "dev" ]; + + patches = [ + ./compiler-rt-codesign.patch # Revert compiler-rt commit that makes codesign mandatory + ] ++ optional stdenv.hostPlatform.isMusl ./sanitizers-nongnu.patch; + + # TSAN requires XPC on Darwin, which we have no public/free source files for. We can depend on the Apple frameworks + # to get it, but they're unfree. Since LLVM is rather central to the stdenv, we patch out TSAN support so that Hydra + # can build this. If we didn't do it, basically the entire nixpkgs on Darwin would have an unfree dependency and we'd + # get no binary cache for the entire platform. If you really find yourself wanting the TSAN, make this controllable by + # a flag and turn the flag off during the stdenv build. + postPatch = stdenv.lib.optionalString stdenv.isDarwin '' + substituteInPlace cmake/config-ix.cmake \ + --replace 'set(COMPILER_RT_HAS_TSAN TRUE)' 'set(COMPILER_RT_HAS_TSAN FALSE)' + ''; + + # Hack around weird upsream RPATH bug + postInstall = stdenv.lib.optionalString stdenv.isDarwin '' + ln -s "$out/lib"/*/* "$out/lib" + ''; + + enableParallelBuilding = true; +} diff --git a/nixpkgs/pkgs/development/compilers/llvm/5/default.nix b/nixpkgs/pkgs/development/compilers/llvm/5/default.nix new file mode 100644 index 000000000000..6807240df81e --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/5/default.nix @@ -0,0 +1,93 @@ +{ lowPrio, newScope, pkgs, stdenv, cmake, libstdcxxHook +, libxml2, python, isl, fetchurl, overrideCC, wrapCCWith +, buildLlvmTools # tools, but from the previous stage, for cross +, targetLlvmLibraries # libraries, but from the next stage, for cross +}: + +let + release_version = "5.0.2"; + version = release_version; # differentiating these is important for rc's + + fetch = name: sha256: fetchurl { + url = "https://releases.llvm.org/${release_version}/${name}-${version}.src.tar.xz"; + inherit sha256; + }; + + clang-tools-extra_src = fetch "clang-tools-extra" "018b3fiwah8f8br5i26qmzh6sjvzchpn358sn8v079m49f2jldm3"; + + tools = stdenv.lib.makeExtensible (tools: let + callPackage = newScope (tools // { inherit stdenv cmake libxml2 python isl release_version version fetch; }); + mkExtraBuildCommands = cc: '' + rsrc="$out/resource-root" + mkdir "$rsrc" + ln -s "${cc}/lib/clang/${release_version}/include" "$rsrc" + ln -s "${targetLlvmLibraries.compiler-rt.out}/lib" "$rsrc/lib" + echo "-resource-dir=$rsrc" >> $out/nix-support/cc-cflags + '' + stdenv.lib.optionalString stdenv.targetPlatform.isLinux '' + echo "--gcc-toolchain=${tools.clang-unwrapped.gcc}" >> $out/nix-support/cc-cflags + ''; + in { + + llvm = callPackage ./llvm.nix { }; + + clang-unwrapped = callPackage ./clang { + inherit clang-tools-extra_src; + }; + + llvm-manpages = lowPrio (tools.llvm.override { + enableManpages = true; + python = pkgs.python; # don't use python-boot + }); + + clang-manpages = lowPrio (tools.clang-unwrapped.override { + enableManpages = true; + python = pkgs.python; # don't use python-boot + }); + + libclang = tools.clang-unwrapped.lib; + + clang = if stdenv.cc.isGNU then tools.libstdcxxClang else tools.libcxxClang; + + libstdcxxClang = wrapCCWith rec { + cc = tools.clang-unwrapped; + extraPackages = [ + libstdcxxHook + targetLlvmLibraries.compiler-rt + ]; + extraBuildCommands = mkExtraBuildCommands cc; + }; + + libcxxClang = wrapCCWith rec { + cc = tools.clang-unwrapped; + libcxx = targetLlvmLibraries.libcxx; + extraPackages = [ + targetLlvmLibraries.libcxx + targetLlvmLibraries.libcxxabi + targetLlvmLibraries.compiler-rt + ]; + extraBuildCommands = mkExtraBuildCommands cc; + }; + + lld = callPackage ./lld.nix {}; + + lldb = callPackage ./lldb.nix {}; + }); + + libraries = stdenv.lib.makeExtensible (libraries: let + callPackage = newScope (libraries // buildLlvmTools // { inherit stdenv cmake libxml2 python isl release_version version fetch; }); + in { + + compiler-rt = callPackage ./compiler-rt.nix {}; + + stdenv = overrideCC stdenv buildLlvmTools.clang; + + libcxxStdenv = overrideCC stdenv buildLlvmTools.libcxxClang; + + libcxx = callPackage ./libc++ {}; + + libcxxabi = callPackage ./libc++abi.nix {}; + + openmp = callPackage ./openmp.nix {}; + }); + +in { inherit tools libraries; } // libraries // tools diff --git a/nixpkgs/pkgs/development/compilers/llvm/5/libc++/default.nix b/nixpkgs/pkgs/development/compilers/llvm/5/libc++/default.nix new file mode 100644 index 000000000000..b182f1250e72 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/5/libc++/default.nix @@ -0,0 +1,52 @@ +{ lib, stdenv, fetch, cmake, python, libcxxabi, fixDarwinDylibNames, version }: + +stdenv.mkDerivation rec { + name = "libc++-${version}"; + + src = fetch "libcxx" "1672aaf95fgy4xsfra8pw24f6r93zwzpan1033hkcm8p2glqipvf"; + + postUnpack = '' + unpackFile ${libcxxabi.src} + export LIBCXXABI_INCLUDE_DIR="$PWD/$(ls -d libcxxabi-${version}*)/include" + ''; + + patches = stdenv.lib.optionals stdenv.hostPlatform.isMusl [ + ../../libcxx-0001-musl-hacks.patch + ]; + + prePatch = '' + substituteInPlace lib/CMakeLists.txt --replace "/usr/lib/libc++" "\''${LIBCXX_LIBCXXABI_LIB_PATH}/libc++" + ''; + + preConfigure = '' + # Get headers from the cxxabi source so we can see private headers not installed by the cxxabi package + cmakeFlagsArray=($cmakeFlagsArray -DLIBCXX_CXX_ABI_INCLUDE_PATHS="$LIBCXXABI_INCLUDE_DIR") + '' + lib.optionalString stdenv.hostPlatform.isMusl '' + patchShebangs utils/cat_files.py + ''; + nativeBuildInputs = [ cmake ] ++ stdenv.lib.optional stdenv.hostPlatform.isMusl python; + + buildInputs = [ libcxxabi ] ++ lib.optional stdenv.isDarwin fixDarwinDylibNames; + + cmakeFlags = [ + "-DLIBCXX_LIBCXXABI_LIB_PATH=${libcxxabi}/lib" + "-DLIBCXX_LIBCPPABI_VERSION=2" + "-DLIBCXX_CXX_ABI=libcxxabi" + ] ++ stdenv.lib.optional stdenv.hostPlatform.isMusl "-DLIBCXX_HAS_MUSL_LIBC=1"; + + enableParallelBuilding = true; + + linkCxxAbi = stdenv.isLinux; + + setupHooks = [ + ../../../../../build-support/setup-hooks/role.bash + ./setup-hook.sh + ]; + + meta = { + homepage = http://libcxx.llvm.org/; + description = "A new implementation of the C++ standard library, targeting C++11"; + license = with stdenv.lib.licenses; [ ncsa mit ]; + platforms = stdenv.lib.platforms.unix; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/llvm/5/libc++/setup-hook.sh b/nixpkgs/pkgs/development/compilers/llvm/5/libc++/setup-hook.sh new file mode 100644 index 000000000000..6611259165ae --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/5/libc++/setup-hook.sh @@ -0,0 +1,6 @@ +# See pkgs/build-support/setup-hooks/role.bash +getHostRole + +linkCxxAbi="@linkCxxAbi@" +export NIX_${role_pre}CXXSTDLIB_COMPILE+=" -isystem @out@/include/c++/v1" +export NIX_${role_pre}CXXSTDLIB_LINK=" -stdlib=libc++${linkCxxAbi:+" -lc++abi"}" diff --git a/nixpkgs/pkgs/development/compilers/llvm/5/libc++abi.nix b/nixpkgs/pkgs/development/compilers/llvm/5/libc++abi.nix new file mode 100644 index 000000000000..227ecbeda194 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/5/libc++abi.nix @@ -0,0 +1,50 @@ +{ stdenv, cmake, fetch, libcxx, libunwind, llvm, version }: + +stdenv.mkDerivation { + name = "libc++abi-${version}"; + + src = fetch "libcxxabi" "12lp799rskr4fc2xr64qn4jfkjnfd8b1aymvsxyn4k9ar7r9pgqv"; + + nativeBuildInputs = [ cmake ]; + buildInputs = stdenv.lib.optional (!stdenv.isDarwin && !stdenv.isFreeBSD) libunwind; + + postUnpack = '' + unpackFile ${libcxx.src} + unpackFile ${llvm.src} + export cmakeFlags="-DLLVM_PATH=$PWD/$(ls -d llvm-*) -DLIBCXXABI_LIBCXX_PATH=$PWD/$(ls -d libcxx-*)" + '' + stdenv.lib.optionalString stdenv.isDarwin '' + export TRIPLE=x86_64-apple-darwin + '' + stdenv.lib.optionalString stdenv.hostPlatform.isMusl '' + patch -p1 -d $(ls -d libcxx-*) -i ${../libcxx-0001-musl-hacks.patch} + ''; + + installPhase = if stdenv.isDarwin + then '' + for file in lib/*.dylib; do + # this should be done in CMake, but having trouble figuring out + # the magic combination of necessary CMake variables + # if you fancy a try, take a look at + # http://www.cmake.org/Wiki/CMake_RPATH_handling + install_name_tool -id $out/$file $file + done + make install + install -d 755 $out/include + install -m 644 ../include/*.h $out/include + '' + else '' + install -d -m 755 $out/include $out/lib + install -m 644 lib/libc++abi.a $out/lib + install -m 644 lib/libc++abi.so.1.0 $out/lib + install -m 644 ../include/cxxabi.h $out/include + ln -s libc++abi.so.1.0 $out/lib/libc++abi.so + ln -s libc++abi.so.1.0 $out/lib/libc++abi.so.1 + ''; + + meta = { + homepage = http://libcxxabi.llvm.org/; + description = "A new implementation of low level support for a standard C++ library"; + license = with stdenv.lib.licenses; [ ncsa mit ]; + maintainers = with stdenv.lib.maintainers; [ vlstill ]; + platforms = stdenv.lib.platforms.unix; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/llvm/5/lld.nix b/nixpkgs/pkgs/development/compilers/llvm/5/lld.nix new file mode 100644 index 000000000000..9a47435cf140 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/5/lld.nix @@ -0,0 +1,31 @@ +{ stdenv +, fetch +, cmake +, llvm +, version +}: + +stdenv.mkDerivation { + name = "lld-${version}"; + + src = fetch "lld" "1ah75rjly6747jk1zbwca3z0svr9b09ylgxd4x9ns721xir6sia6"; + + nativeBuildInputs = [ cmake ]; + buildInputs = [ llvm ]; + + outputs = [ "out" "dev" ]; + + enableParallelBuilding = true; + + postInstall = '' + moveToOutput include "$dev" + moveToOutput lib "$dev" + ''; + + meta = { + description = "The LLVM Linker"; + homepage = http://lld.llvm.org/; + license = stdenv.lib.licenses.ncsa; + platforms = stdenv.lib.platforms.all; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/llvm/5/lldb.nix b/nixpkgs/pkgs/development/compilers/llvm/5/lldb.nix new file mode 100644 index 000000000000..7be9a7e47b74 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/5/lldb.nix @@ -0,0 +1,56 @@ +{ stdenv +, fetch +, cmake +, zlib +, ncurses +, swig +, which +, libedit +, libxml2 +, llvm +, clang-unwrapped +, python +, version +, darwin +}: + +stdenv.mkDerivation { + name = "lldb-${version}"; + + src = fetch "lldb" "05j2a63yzln43852nng8a7y47spzlyr1cvdmgmbxgd29c8r0bfkq"; + + postPatch = '' + # Fix up various paths that assume llvm and clang are installed in the same place + sed -i 's,".*ClangConfig.cmake","${clang-unwrapped}/lib/cmake/clang/ClangConfig.cmake",' \ + cmake/modules/LLDBStandalone.cmake + sed -i 's,".*tools/clang/include","${clang-unwrapped}/include",' \ + cmake/modules/LLDBStandalone.cmake + sed -i 's,"$.LLVM_LIBRARY_DIR.",${llvm}/lib ${clang-unwrapped}/lib,' \ + cmake/modules/LLDBStandalone.cmake + ''; + + nativeBuildInputs = [ cmake python which swig ]; + buildInputs = [ ncurses zlib libedit libxml2 llvm ] + ++ stdenv.lib.optionals stdenv.isDarwin [ darwin.libobjc darwin.apple_sdk.libs.xpc darwin.apple_sdk.frameworks.Foundation darwin.bootstrap_cmds darwin.apple_sdk.frameworks.Carbon darwin.apple_sdk.frameworks.Cocoa darwin.cf-private ]; + + CXXFLAGS = "-fno-rtti"; + hardeningDisable = [ "format" ]; + + cmakeFlags = [ + "-DLLDB_CODESIGN_IDENTITY=" # codesigning makes nondeterministic + ]; + + enableParallelBuilding = true; + + postInstall = '' + mkdir -p $out/share/man/man1 + cp ../docs/lldb.1 $out/share/man/man1/ + ''; + + meta = with stdenv.lib; { + description = "A next-generation high-performance debugger"; + homepage = http://llvm.org/; + license = licenses.ncsa; + platforms = platforms.all; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/llvm/5/llvm-outputs.patch b/nixpkgs/pkgs/development/compilers/llvm/5/llvm-outputs.patch new file mode 100644 index 000000000000..40096fa3497f --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/5/llvm-outputs.patch @@ -0,0 +1,26 @@ +diff --git a/tools/llvm-config/llvm-config.cpp b/tools/llvm-config/llvm-config.cpp +index 94d426b..37f7794 100644 +--- a/tools/llvm-config/llvm-config.cpp ++++ b/tools/llvm-config/llvm-config.cpp +@@ -333,6 +333,21 @@ int main(int argc, char **argv) { + ActiveIncludeOption = "-I" + ActiveIncludeDir; + } + ++ /// Nix-specific multiple-output handling: override ActiveLibDir if --link-shared ++ if (!IsInDevelopmentTree) { ++ bool WantShared = true; ++ for (int i = 1; i < argc; ++i) { ++ StringRef Arg = argv[i]; ++ if (Arg == "--link-shared") ++ WantShared = true; ++ else if (Arg == "--link-static") ++ WantShared = false; // the last one wins ++ } ++ ++ if (WantShared) ++ ActiveLibDir = std::string("@lib@") + "/lib" + LLVM_LIBDIR_SUFFIX; ++ } ++ + /// We only use `shared library` mode in cases where the static library form + /// of the components provided are not available; note however that this is + /// skipped if we're run from within the build dir. However, once installed, diff --git a/nixpkgs/pkgs/development/compilers/llvm/5/llvm.nix b/nixpkgs/pkgs/development/compilers/llvm/5/llvm.nix new file mode 100644 index 000000000000..41dc20ec4fe3 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/5/llvm.nix @@ -0,0 +1,160 @@ +{ stdenv +, fetch +, cmake +, python +, libffi +, libbfd +, libxml2 +, ncurses +, version +, release_version +, zlib +, libcxxabi +, debugVersion ? false +, enableManpages ? false +, enableSharedLibraries ? !enableManpages +}: + +let + src = fetch "llvm" "0g1bbj2n6xv4p1n6hh17vj3vpvg56wacipc81dgwga9mg2lys8nm"; + + # Used when creating a version-suffixed symlink of libLLVM.dylib + shortVersion = with stdenv.lib; + concatStringsSep "." (take 2 (splitString "." release_version)); +in stdenv.mkDerivation (rec { + name = "llvm-${version}"; + + unpackPhase = '' + unpackFile ${src} + mv llvm-${version}* llvm + sourceRoot=$PWD/llvm + ''; + + outputs = [ "out" "python" ] + ++ stdenv.lib.optional enableSharedLibraries "lib"; + + nativeBuildInputs = [ cmake python ] + ++ stdenv.lib.optional enableManpages python.pkgs.sphinx; + + buildInputs = [ libxml2 libffi ]; + + propagatedBuildInputs = [ ncurses zlib ]; + + postPatch = stdenv.lib.optionalString stdenv.isDarwin '' + substituteInPlace cmake/modules/AddLLVM.cmake \ + --replace 'set(_install_name_dir INSTALL_NAME_DIR "@rpath")' "set(_install_name_dir)" \ + --replace 'set(_install_rpath "@loader_path/../lib" ''${extra_libdir})' "" + '' + # Patch llvm-config to return correct library path based on --link-{shared,static}. + + stdenv.lib.optionalString (enableSharedLibraries) '' + substitute '${./llvm-outputs.patch}' ./llvm-outputs.patch --subst-var lib + patch -p1 < ./llvm-outputs.patch + '' + '' + # FileSystem permissions tests fail with various special bits + substituteInPlace unittests/Support/CMakeLists.txt \ + --replace "Path.cpp" "" + rm unittests/Support/Path.cpp + '' + stdenv.lib.optionalString stdenv.isAarch64 '' + patch -p0 < ${../aarch64.patch} + '' + stdenv.lib.optionalString stdenv.hostPlatform.isMusl '' + patch -p1 -i ${../TLI-musl.patch} + substituteInPlace unittests/Support/CMakeLists.txt \ + --replace "add_subdirectory(DynamicLibrary)" "" + rm unittests/Support/DynamicLibrary/DynamicLibraryTest.cpp + ''; + + # hacky fix: created binaries need to be run before installation + preBuild = '' + mkdir -p $out/ + ln -sv $PWD/lib $out + ''; + + cmakeFlags = with stdenv; [ + "-DCMAKE_BUILD_TYPE=${if debugVersion then "Debug" else "Release"}" + "-DLLVM_INSTALL_UTILS=ON" # Needed by rustc + "-DLLVM_BUILD_TESTS=ON" + "-DLLVM_ENABLE_FFI=ON" + "-DLLVM_ENABLE_RTTI=ON" + + "-DLLVM_HOST_TRIPLE=${stdenv.hostPlatform.config}" + "-DLLVM_DEFAULT_TARGET_TRIPLE=${stdenv.hostPlatform.config}" + "-DTARGET_TRIPLE=${stdenv.hostPlatform.config}" + ] + ++ stdenv.lib.optional enableSharedLibraries + "-DLLVM_LINK_LLVM_DYLIB=ON" + ++ stdenv.lib.optionals enableManpages [ + "-DLLVM_BUILD_DOCS=ON" + "-DLLVM_ENABLE_SPHINX=ON" + "-DSPHINX_OUTPUT_MAN=ON" + "-DSPHINX_OUTPUT_HTML=OFF" + "-DSPHINX_WARNINGS_AS_ERRORS=OFF" + ] + ++ stdenv.lib.optional (!isDarwin) + "-DLLVM_BINUTILS_INCDIR=${libbfd.dev}/include" + ++ stdenv.lib.optionals (isDarwin) [ + "-DLLVM_ENABLE_LIBCXX=ON" + "-DCAN_TARGET_i386=false" + ]; + + postBuild = '' + rm -fR $out + ''; + + preCheck = '' + export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$PWD/lib + ''; + + postInstall = '' + mkdir -p $python/share + mv $out/share/opt-viewer $python/share/opt-viewer + '' + + stdenv.lib.optionalString enableSharedLibraries '' + moveToOutput "lib/libLLVM-*" "$lib" + moveToOutput "lib/libLLVM${stdenv.hostPlatform.extensions.sharedLibrary}" "$lib" + moveToOutput "lib/libLTO${stdenv.hostPlatform.extensions.sharedLibrary}" "$lib" + substituteInPlace "$out/lib/cmake/llvm/LLVMExports-${if debugVersion then "debug" else "release"}.cmake" \ + --replace "\''${_IMPORT_PREFIX}/lib/libLLVM-" "$lib/lib/libLLVM-" + '' + + stdenv.lib.optionalString (stdenv.isDarwin && enableSharedLibraries) '' + substituteInPlace "$out/lib/cmake/llvm/LLVMExports-${if debugVersion then "debug" else "release"}.cmake" \ + --replace "\''${_IMPORT_PREFIX}/lib/libLLVM.dylib" "$lib/lib/libLLVM.dylib" \ + --replace "\''${_IMPORT_PREFIX}/lib/libLTO.dylib" "$lib/lib/libLTO.dylib" + ln -s $lib/lib/libLLVM.dylib $lib/lib/libLLVM-${shortVersion}.dylib + ln -s $lib/lib/libLLVM.dylib $lib/lib/libLLVM-${release_version}.dylib + ''; + + doCheck = stdenv.isLinux && (!stdenv.isi686); + + checkTarget = "check-all"; + + enableParallelBuilding = true; + + passthru.src = src; + + requiredSystemFeatures = [ "big-parallel" ]; + meta = { + description = "Collection of modular and reusable compiler and toolchain technologies"; + homepage = http://llvm.org/; + license = stdenv.lib.licenses.ncsa; + maintainers = with stdenv.lib.maintainers; [ lovek323 raskin dtzWill ]; + platforms = stdenv.lib.platforms.all; + }; +} // stdenv.lib.optionalAttrs enableManpages { + name = "llvm-manpages-${version}"; + + buildPhase = '' + make docs-llvm-man + ''; + + propagatedBuildInputs = []; + + installPhase = '' + make -C docs install + ''; + + outputs = [ "out" ]; + + doCheck = false; + + meta.description = "man pages for LLVM ${version}"; +}) diff --git a/nixpkgs/pkgs/development/compilers/llvm/5/openmp.nix b/nixpkgs/pkgs/development/compilers/llvm/5/openmp.nix new file mode 100644 index 000000000000..901015bf2ff4 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/5/openmp.nix @@ -0,0 +1,25 @@ +{ stdenv +, fetch +, cmake +, llvm +, perl +, version +}: + +stdenv.mkDerivation { + name = "openmp-${version}"; + + src = fetch "openmp" "0p2n52676wlq6y9q99n5pivq6pvvda1p994r69fxj206ahn59jir"; + + nativeBuildInputs = [ cmake perl ]; + buildInputs = [ llvm ]; + + enableParallelBuilding = true; + + meta = { + description = "Components required to build an executable OpenMP program"; + homepage = http://openmp.llvm.org/; + license = stdenv.lib.licenses.mit; + platforms = stdenv.lib.platforms.all; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/llvm/5/sanitizers-nongnu.patch b/nixpkgs/pkgs/development/compilers/llvm/5/sanitizers-nongnu.patch new file mode 100644 index 000000000000..c9ddfe45c898 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/5/sanitizers-nongnu.patch @@ -0,0 +1,370 @@ +From 3e1fcb7d4909db8f0f7dd0109b2eee20115c8be3 Mon Sep 17 00:00:00 2001 +From: "Jory A. Pratt" <anarchy@gentoo.org> +Date: Sat, 9 Sep 2017 08:31:15 -0500 +Subject: [PATCH] Ported to compiler-rt-sanitizers-5.0.0. Taken from + +https://gist.githubusercontent.com/pwaller/2337f3290f12634cad3e3730cff0a6c1/raw/83c87a8585e2f9662494db5662e5361beb093c26/nongnu.patch +Signed-off-by: Jory A. Pratt <anarchy@gentoo.org> + +Taken from gentoo-musl project, with a few additional minor fixes. +--- + lib/asan/asan_linux.cc | 4 +-- + lib/interception/interception_linux.cc | 2 +- + lib/interception/interception_linux.h | 2 +- + lib/msan/msan_linux.cc | 2 +- + .../sanitizer_common_interceptors_ioctl.inc | 4 +-- + lib/sanitizer_common/sanitizer_common_syscalls.inc | 2 +- + lib/sanitizer_common/sanitizer_linux_libcdep.cc | 12 +++---- + lib/sanitizer_common/sanitizer_platform.h | 7 ++++ + .../sanitizer_platform_interceptors.h | 2 +- + .../sanitizer_platform_limits_posix.cc | 40 +++++++++++++--------- + lib/tsan/rtl/tsan_platform_linux.cc | 2 +- + 11 files changed, 47 insertions(+), 32 deletions(-) + +diff --git a/lib/asan/asan_linux.cc b/lib/asan/asan_linux.cc +index 6d47ba432..c58dd4864 100644 +--- a/lib/asan/asan_linux.cc ++++ b/lib/asan/asan_linux.cc +@@ -39,7 +39,7 @@ + #include <sys/link_elf.h> + #endif + +-#if SANITIZER_ANDROID || SANITIZER_FREEBSD ++#if SANITIZER_ANDROID || SANITIZER_FREEBSD || SANITIZER_NONGNU + #include <ucontext.h> + extern "C" void* _DYNAMIC; + #else +@@ -86,7 +86,7 @@ void AsanApplyToGlobals(globals_op_fptr op, const void *needle) { + UNIMPLEMENTED(); + } + +-#if SANITIZER_ANDROID ++#if SANITIZER_ANDROID || SANITIZER_NONGNU + // FIXME: should we do anything for Android? + void AsanCheckDynamicRTPrereqs() {} + void AsanCheckIncompatibleRT() {} +diff --git a/lib/interception/interception_linux.cc b/lib/interception/interception_linux.cc +index 6e908ac01..76c1688ce 100644 +--- a/lib/interception/interception_linux.cc ++++ b/lib/interception/interception_linux.cc +@@ -24,7 +24,7 @@ bool GetRealFunctionAddress(const char *func_name, uptr *func_addr, + return real == wrapper; + } + +-#if !defined(__ANDROID__) // android does not have dlvsym ++#if !defined(__ANDROID__) && defined(__GLIBC__) // android does not have dlvsym + void *GetFuncAddrVer(const char *func_name, const char *ver) { + return dlvsym(RTLD_NEXT, func_name, ver); + } +diff --git a/lib/interception/interception_linux.h b/lib/interception/interception_linux.h +index 27a66c882..f60c38991 100644 +--- a/lib/interception/interception_linux.h ++++ b/lib/interception/interception_linux.h +@@ -34,7 +34,7 @@ void *GetFuncAddrVer(const char *func_name, const char *ver); + (::__interception::uptr) & (func), \ + (::__interception::uptr) & WRAP(func)) + +-#if !defined(__ANDROID__) // android does not have dlvsym ++#if !defined(__ANDROID__) && !SANITIZER_NONGNU // android does not have dlvsym + #define INTERCEPT_FUNCTION_VER_LINUX_OR_FREEBSD(func, symver) \ + (::__interception::real_##func = (func##_f)( \ + unsigned long)::__interception::GetFuncAddrVer(#func, symver)) +diff --git a/lib/msan/msan_linux.cc b/lib/msan/msan_linux.cc +index 0a687f620..0852d97d7 100644 +--- a/lib/msan/msan_linux.cc ++++ b/lib/msan/msan_linux.cc +@@ -13,7 +13,7 @@ + //===----------------------------------------------------------------------===// + + #include "sanitizer_common/sanitizer_platform.h" +-#if SANITIZER_FREEBSD || SANITIZER_LINUX ++#if SANITIZER_FREEBSD || SANITIZER_LINUX && !SANITIZER_NONGNU + + #include "msan.h" + #include "msan_thread.h" +diff --git a/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc b/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc +index 4ed9afedf..64f584e93 100644 +--- a/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc ++++ b/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc +@@ -100,7 +100,7 @@ static void ioctl_table_fill() { + _(SIOCGETVIFCNT, WRITE, struct_sioc_vif_req_sz); + #endif + +-#if SANITIZER_LINUX ++#if SANITIZER_LINUX && !SANITIZER_NONGNU + // Conflicting request ids. + // _(CDROMAUDIOBUFSIZ, NONE, 0); + // _(SNDCTL_TMR_CONTINUE, NONE, 0); +@@ -361,7 +361,7 @@ static void ioctl_table_fill() { + _(VT_WAITACTIVE, NONE, 0); + #endif + +-#if SANITIZER_LINUX && !SANITIZER_ANDROID ++#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU + // _(SIOCDEVPLIP, WRITE, struct_ifreq_sz); // the same as EQL_ENSLAVE + _(CYGETDEFTHRESH, WRITE, sizeof(int)); + _(CYGETDEFTIMEOUT, WRITE, sizeof(int)); +diff --git a/lib/sanitizer_common/sanitizer_common_syscalls.inc b/lib/sanitizer_common/sanitizer_common_syscalls.inc +index 469c8eb7e..24f87867d 100644 +--- a/lib/sanitizer_common/sanitizer_common_syscalls.inc ++++ b/lib/sanitizer_common/sanitizer_common_syscalls.inc +@@ -2038,7 +2038,7 @@ POST_SYSCALL(setrlimit)(long res, long resource, void *rlim) { + } + } + +-#if !SANITIZER_ANDROID ++#if !SANITIZER_ANDROID && !SANITIZER_NONGNU + PRE_SYSCALL(prlimit64)(long pid, long resource, const void *new_rlim, + void *old_rlim) { + if (new_rlim) PRE_READ(new_rlim, struct_rlimit64_sz); +diff --git a/lib/sanitizer_common/sanitizer_linux_libcdep.cc b/lib/sanitizer_common/sanitizer_linux_libcdep.cc +index 52196db12..045d9331f 100644 +--- a/lib/sanitizer_common/sanitizer_linux_libcdep.cc ++++ b/lib/sanitizer_common/sanitizer_linux_libcdep.cc +@@ -148,7 +148,7 @@ bool SanitizerGetThreadName(char *name, int max_len) { + #endif + } + +-#if !SANITIZER_FREEBSD && !SANITIZER_ANDROID && !SANITIZER_GO ++#if !SANITIZER_FREEBSD && !SANITIZER_ANDROID && !SANITIZER_GO && !SANITIZER_NONGNU + static uptr g_tls_size; + + #ifdef __i386__ +@@ -176,11 +176,11 @@ void InitTlsSize() { + } + #else + void InitTlsSize() { } +-#endif // !SANITIZER_FREEBSD && !SANITIZER_ANDROID && !SANITIZER_GO ++#endif // !SANITIZER_FREEBSD && !SANITIZER_ANDROID && !SANITIZER_GO && !SANITIZER_NONGNU + + #if (defined(__x86_64__) || defined(__i386__) || defined(__mips__) \ + || defined(__aarch64__) || defined(__powerpc64__) || defined(__s390__) \ +- || defined(__arm__)) && SANITIZER_LINUX && !SANITIZER_ANDROID ++ || defined(__arm__)) && SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU + // sizeof(struct pthread) from glibc. + static atomic_uintptr_t kThreadDescriptorSize; + +@@ -335,7 +335,7 @@ uptr ThreadSelf() { + + #if !SANITIZER_GO + static void GetTls(uptr *addr, uptr *size) { +-#if SANITIZER_LINUX && !SANITIZER_ANDROID ++#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU + # if defined(__x86_64__) || defined(__i386__) || defined(__s390__) + *addr = ThreadSelf(); + *size = GetTlsSize(); +@@ -362,7 +362,7 @@ static void GetTls(uptr *addr, uptr *size) { + *addr = (uptr) dtv[2]; + *size = (*addr == 0) ? 0 : ((uptr) segbase[0] - (uptr) dtv[2]); + } +-#elif SANITIZER_ANDROID ++#elif SANITIZER_ANDROID || SANITIZER_NONGNU + *addr = 0; + *size = 0; + #else +@@ -373,7 +373,7 @@ static void GetTls(uptr *addr, uptr *size) { + + #if !SANITIZER_GO + uptr GetTlsSize() { +-#if SANITIZER_FREEBSD || SANITIZER_ANDROID ++#if SANITIZER_FREEBSD || SANITIZER_ANDROID || SANITIZER_NONGNU + uptr addr, size; + GetTls(&addr, &size); + return size; +diff --git a/lib/sanitizer_common/sanitizer_platform.h b/lib/sanitizer_common/sanitizer_platform.h +index 396f7c934..5af6f1ed5 100644 +--- a/lib/sanitizer_common/sanitizer_platform.h ++++ b/lib/sanitizer_common/sanitizer_platform.h +@@ -175,6 +175,13 @@ + # define SANITIZER_ARM 0 + #endif + ++ ++#if defined(__linux__) && !defined(__GLIBC__) ++# define SANITIZER_NONGNU 1 ++#else ++# define SANITIZER_NONGNU 0 ++#endif ++ + // By default we allow to use SizeClassAllocator64 on 64-bit platform. + // But in some cases (e.g. AArch64's 39-bit address space) SizeClassAllocator64 + // does not work well and we need to fallback to SizeClassAllocator32. +diff --git a/lib/sanitizer_common/sanitizer_platform_interceptors.h b/lib/sanitizer_common/sanitizer_platform_interceptors.h +index 0380cee92..0a39abbd0 100644 +--- a/lib/sanitizer_common/sanitizer_platform_interceptors.h ++++ b/lib/sanitizer_common/sanitizer_platform_interceptors.h +@@ -31,7 +31,7 @@ + # define SI_POSIX 0 + #endif + +-#if SANITIZER_LINUX && !SANITIZER_ANDROID ++#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU + # define SI_LINUX_NOT_ANDROID 1 + #else + # define SI_LINUX_NOT_ANDROID 0 +diff --git a/lib/sanitizer_common/sanitizer_platform_limits_posix.cc b/lib/sanitizer_common/sanitizer_platform_limits_posix.cc +index 83f4fd22f..fa8c1b8bd 100644 +--- a/lib/sanitizer_common/sanitizer_platform_limits_posix.cc ++++ b/lib/sanitizer_common/sanitizer_platform_limits_posix.cc +@@ -14,6 +14,9 @@ + + #include "sanitizer_platform.h" + ++// Workaround musl <--> linux conflicting definition of 'struct sysinfo' ++#define _LINUX_SYSINFO_H ++ + #if SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_MAC + // Tests in this file assume that off_t-dependent data structures match the + // libc ABI. For example, struct dirent here is what readdir() function (as +@@ -138,12 +141,14 @@ typedef struct user_fpregs elf_fpregset_t; + + #if SANITIZER_LINUX && !SANITIZER_ANDROID + #include <glob.h> +-#include <obstack.h> ++# if !SANITIZER_NONGNU ++# include <obstack.h> ++# endif + #include <mqueue.h> +-#include <net/if_ppp.h> +-#include <netax25/ax25.h> +-#include <netipx/ipx.h> +-#include <netrom/netrom.h> ++#include <linux/if_ppp.h> ++#include <linux/ax25.h> ++#include <linux/ipx.h> ++#include <linux/netrom.h> + #if HAVE_RPC_XDR_H + # include <rpc/xdr.h> + #elif HAVE_TIRPC_RPC_XDR_H +@@ -159,7 +164,8 @@ typedef struct user_fpregs elf_fpregset_t; + # include <sys/procfs.h> + #endif + #include <sys/user.h> +-#include <sys/ustat.h> ++// #include <sys/ustat.h> ++#include <sys/statfs.h> + #include <linux/cyclades.h> + #include <linux/if_eql.h> + #include <linux/if_plip.h> +@@ -251,7 +257,7 @@ namespace __sanitizer { + unsigned struct_itimerspec_sz = sizeof(struct itimerspec); + #endif // SANITIZER_LINUX || SANITIZER_FREEBSD + +-#if SANITIZER_LINUX && !SANITIZER_ANDROID ++#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU + unsigned struct_ustat_sz = sizeof(struct ustat); + unsigned struct_rlimit64_sz = sizeof(struct rlimit64); + unsigned struct_statvfs64_sz = sizeof(struct statvfs64); +@@ -309,7 +315,7 @@ unsigned struct_ElfW_Phdr_sz = sizeof(ElfW(Phdr)); + unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr); + #endif + +-#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID ++#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID && !SANITIZER_NONGNU + int glob_nomatch = GLOB_NOMATCH; + int glob_altdirfunc = GLOB_ALTDIRFUNC; + #endif +@@ -403,7 +409,7 @@ unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr); + unsigned struct_termios_sz = sizeof(struct termios); + unsigned struct_winsize_sz = sizeof(struct winsize); + +-#if SANITIZER_LINUX ++#if SANITIZER_LINUX && !SANITIZER_NONGNU + unsigned struct_arpreq_sz = sizeof(struct arpreq); + unsigned struct_cdrom_msf_sz = sizeof(struct cdrom_msf); + unsigned struct_cdrom_multisession_sz = sizeof(struct cdrom_multisession); +@@ -453,7 +459,7 @@ unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr); + unsigned struct_vt_mode_sz = sizeof(struct vt_mode); + #endif // SANITIZER_LINUX || SANITIZER_FREEBSD + +-#if SANITIZER_LINUX && !SANITIZER_ANDROID ++#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU + unsigned struct_ax25_parms_struct_sz = sizeof(struct ax25_parms_struct); + unsigned struct_cyclades_monitor_sz = sizeof(struct cyclades_monitor); + #if EV_VERSION > (0x010000) +@@ -821,7 +827,7 @@ unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr); + unsigned IOCTL_VT_WAITACTIVE = VT_WAITACTIVE; + #endif // SANITIZER_LINUX || SANITIZER_FREEBSD + +-#if SANITIZER_LINUX && !SANITIZER_ANDROID ++#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU + unsigned IOCTL_CYGETDEFTHRESH = CYGETDEFTHRESH; + unsigned IOCTL_CYGETDEFTIMEOUT = CYGETDEFTIMEOUT; + unsigned IOCTL_CYGETMON = CYGETMON; +@@ -976,7 +982,7 @@ CHECK_SIZE_AND_OFFSET(dl_phdr_info, dlpi_phdr); + CHECK_SIZE_AND_OFFSET(dl_phdr_info, dlpi_phnum); + #endif // SANITIZER_LINUX || SANITIZER_FREEBSD + +-#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID ++#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID && !SANITIZER_NONGNU + CHECK_TYPE_SIZE(glob_t); + CHECK_SIZE_AND_OFFSET(glob_t, gl_pathc); + CHECK_SIZE_AND_OFFSET(glob_t, gl_pathv); +@@ -1010,6 +1016,7 @@ CHECK_TYPE_SIZE(iovec); + CHECK_SIZE_AND_OFFSET(iovec, iov_base); + CHECK_SIZE_AND_OFFSET(iovec, iov_len); + ++#if !SANITIZER_NONGNU + CHECK_TYPE_SIZE(msghdr); + CHECK_SIZE_AND_OFFSET(msghdr, msg_name); + CHECK_SIZE_AND_OFFSET(msghdr, msg_namelen); +@@ -1023,6 +1030,7 @@ CHECK_TYPE_SIZE(cmsghdr); + CHECK_SIZE_AND_OFFSET(cmsghdr, cmsg_len); + CHECK_SIZE_AND_OFFSET(cmsghdr, cmsg_level); + CHECK_SIZE_AND_OFFSET(cmsghdr, cmsg_type); ++#endif + + COMPILER_CHECK(sizeof(__sanitizer_dirent) <= sizeof(dirent)); + CHECK_SIZE_AND_OFFSET(dirent, d_ino); +@@ -1125,7 +1133,7 @@ CHECK_SIZE_AND_OFFSET(mntent, mnt_passno); + + CHECK_TYPE_SIZE(ether_addr); + +-#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID ++#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID && !SANITIZER_NONGNU + CHECK_TYPE_SIZE(ipc_perm); + # if SANITIZER_FREEBSD + CHECK_SIZE_AND_OFFSET(ipc_perm, key); +@@ -1186,7 +1194,7 @@ CHECK_SIZE_AND_OFFSET(ifaddrs, ifa_dstaddr); + CHECK_SIZE_AND_OFFSET(ifaddrs, ifa_data); + #endif + +-#if SANITIZER_LINUX ++#if SANITIZER_LINUX && !SANITIZER_NONGNU + COMPILER_CHECK(sizeof(__sanitizer_mallinfo) == sizeof(struct mallinfo)); + #endif + +@@ -1236,7 +1244,7 @@ COMPILER_CHECK(__sanitizer_XDR_DECODE == XDR_DECODE); + COMPILER_CHECK(__sanitizer_XDR_FREE == XDR_FREE); + #endif + +-#if SANITIZER_LINUX && !SANITIZER_ANDROID ++#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU + COMPILER_CHECK(sizeof(__sanitizer_FILE) <= sizeof(FILE)); + CHECK_SIZE_AND_OFFSET(FILE, _flags); + CHECK_SIZE_AND_OFFSET(FILE, _IO_read_ptr); +@@ -1255,7 +1263,7 @@ CHECK_SIZE_AND_OFFSET(FILE, _chain); + CHECK_SIZE_AND_OFFSET(FILE, _fileno); + #endif + +-#if SANITIZER_LINUX && !SANITIZER_ANDROID ++#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU + COMPILER_CHECK(sizeof(__sanitizer__obstack_chunk) <= sizeof(_obstack_chunk)); + CHECK_SIZE_AND_OFFSET(_obstack_chunk, limit); + CHECK_SIZE_AND_OFFSET(_obstack_chunk, prev); +diff --git a/lib/tsan/rtl/tsan_platform_linux.cc b/lib/tsan/rtl/tsan_platform_linux.cc +index ead1e5704..2c020e3fe 100644 +--- a/lib/tsan/rtl/tsan_platform_linux.cc ++++ b/lib/tsan/rtl/tsan_platform_linux.cc +@@ -284,7 +284,7 @@ void InitializePlatform() { + // This is required to properly "close" the fds, because we do not see internal + // closes within glibc. The code is a pure hack. + int ExtractResolvFDs(void *state, int *fds, int nfd) { +-#if SANITIZER_LINUX && !SANITIZER_ANDROID ++#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU + int cnt = 0; + struct __res_state *statp = (struct __res_state*)state; + for (int i = 0; i < MAXNS && cnt < nfd; i++) { +-- +2.16.2 + diff --git a/nixpkgs/pkgs/development/compilers/llvm/6/clang/default.nix b/nixpkgs/pkgs/development/compilers/llvm/6/clang/default.nix new file mode 100644 index 000000000000..840567496785 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/6/clang/default.nix @@ -0,0 +1,106 @@ +{ stdenv, fetch, cmake, libxml2, llvm, version, clang-tools-extra_src, python +, fixDarwinDylibNames +, enableManpages ? false +}: + +let + gcc = if stdenv.cc.isGNU then stdenv.cc.cc else stdenv.cc.cc.gcc; + self = stdenv.mkDerivation ({ + name = "clang-${version}"; + + unpackPhase = '' + unpackFile ${fetch "cfe" "0rxn4rh7rrnsqbdgp4gzc8ishbkryhpl1kd3mpnxzpxxhla3y93w"} + mv cfe-${version}* clang + sourceRoot=$PWD/clang + unpackFile ${clang-tools-extra_src} + mv clang-tools-extra-* $sourceRoot/tools/extra + ''; + + nativeBuildInputs = [ cmake python ] + ++ stdenv.lib.optional enableManpages python.pkgs.sphinx; + + buildInputs = [ libxml2 llvm ] + ++ stdenv.lib.optional stdenv.isDarwin fixDarwinDylibNames; + + cmakeFlags = [ + "-DCMAKE_CXX_FLAGS=-std=c++11" + ] ++ stdenv.lib.optionals enableManpages [ + "-DCLANG_INCLUDE_DOCS=ON" + "-DLLVM_ENABLE_SPHINX=ON" + "-DSPHINX_OUTPUT_MAN=ON" + "-DSPHINX_OUTPUT_HTML=OFF" + "-DSPHINX_WARNINGS_AS_ERRORS=OFF" + ]; + + patches = [ ./purity.patch ]; + + postPatch = '' + sed -i -e 's/DriverArgs.hasArg(options::OPT_nostdlibinc)/true/' \ + -e 's/Args.hasArg(options::OPT_nostdlibinc)/true/' \ + lib/Driver/ToolChains/*.cpp + + # Patch for standalone doc building + sed -i '1s,^,find_package(Sphinx REQUIRED)\n,' docs/CMakeLists.txt + '' + stdenv.lib.optionalString stdenv.hostPlatform.isMusl '' + sed -i -e 's/lgcc_s/lgcc_eh/' lib/Driver/ToolChains/*.cpp + ''; + + outputs = [ "out" "lib" "python" ]; + + # Clang expects to find LLVMgold in its own prefix + postInstall = '' + if [ -e ${llvm}/lib/LLVMgold.so ]; then + ln -sv ${llvm}/lib/LLVMgold.so $out/lib + fi + + ln -sv $out/bin/clang $out/bin/cpp + + # Move libclang to 'lib' output + moveToOutput "lib/libclang.*" "$lib" + substituteInPlace $out/lib/cmake/clang/ClangTargets-release.cmake \ + --replace "\''${_IMPORT_PREFIX}/lib/libclang." "$lib/lib/libclang." + + mkdir -p $python/bin $python/share/clang/ + mv $out/bin/{git-clang-format,scan-view} $python/bin + if [ -e $out/bin/set-xcode-analyzer ]; then + mv $out/bin/set-xcode-analyzer $python/bin + fi + mv $out/share/clang/*.py $python/share/clang + rm $out/bin/c-index-test + ''; + + enableParallelBuilding = true; + + passthru = { + isClang = true; + inherit llvm; + } // stdenv.lib.optionalAttrs stdenv.targetPlatform.isLinux { + inherit gcc; + }; + + meta = { + description = "A c, c++, objective-c, and objective-c++ frontend for the llvm compiler"; + homepage = http://llvm.org/; + license = stdenv.lib.licenses.ncsa; + platforms = stdenv.lib.platforms.all; + }; + } // stdenv.lib.optionalAttrs enableManpages { + name = "clang-manpages-${version}"; + + buildPhase = '' + make docs-clang-man + ''; + + installPhase = '' + mkdir -p $out/share/man/man1 + # Manually install clang manpage + cp docs/man/*.1 $out/share/man/man1/ + ''; + + outputs = [ "out" ]; + + doCheck = false; + + meta.description = "man page for Clang ${version}"; + }); +in self diff --git a/nixpkgs/pkgs/development/compilers/llvm/6/clang/purity.patch b/nixpkgs/pkgs/development/compilers/llvm/6/clang/purity.patch new file mode 100644 index 000000000000..b30d0d0b5d5b --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/6/clang/purity.patch @@ -0,0 +1,30 @@ +From 4add81bba40dcec62c4ea4481be8e35ac53e89d8 Mon Sep 17 00:00:00 2001 +From: Will Dietz <w@wdtz.org> +Date: Thu, 18 May 2017 11:56:12 -0500 +Subject: [PATCH] "purity" patch for 5.0 + +--- + lib/Driver/ToolChains/Gnu.cpp | 7 ------- + 1 file changed, 7 deletions(-) + +diff --git a/lib/Driver/ToolChains/Gnu.cpp b/lib/Driver/ToolChains/Gnu.cpp +index fe3c0191bb..c6a482bece 100644 +--- a/lib/Driver/ToolChains/Gnu.cpp ++++ b/lib/Driver/ToolChains/Gnu.cpp +@@ -494,13 +494,6 @@ void tools::gnutools::Linker::ConstructJob(Compilation &C, const JobAction &JA, + if (!Args.hasArg(options::OPT_static)) { + if (Args.hasArg(options::OPT_rdynamic)) + CmdArgs.push_back("-export-dynamic"); +- +- if (!Args.hasArg(options::OPT_shared)) { +- const std::string Loader = +- D.DyldPrefix + ToolChain.getDynamicLinker(Args); +- CmdArgs.push_back("-dynamic-linker"); +- CmdArgs.push_back(Args.MakeArgString(Loader)); +- } + } + + CmdArgs.push_back("-o"); +-- +2.11.0 + diff --git a/nixpkgs/pkgs/development/compilers/llvm/6/compiler-rt-codesign.patch b/nixpkgs/pkgs/development/compilers/llvm/6/compiler-rt-codesign.patch new file mode 100644 index 000000000000..8f4c76bca1eb --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/6/compiler-rt-codesign.patch @@ -0,0 +1,155 @@ +From 3dec5f3475a26aeb4678627795c4b67c6b7b4785 Mon Sep 17 00:00:00 2001 +From: Will Dietz <w@wdtz.org> +Date: Tue, 19 Sep 2017 13:13:06 -0500 +Subject: [PATCH] remove codesign use on Apple, disable ios sim testing that + needs it + +--- + cmake/Modules/AddCompilerRT.cmake | 8 ------ + test/asan/CMakeLists.txt | 52 --------------------------------------- + test/tsan/CMakeLists.txt | 47 ----------------------------------- + 3 files changed, 107 deletions(-) + +diff --git a/cmake/Modules/AddCompilerRT.cmake b/cmake/Modules/AddCompilerRT.cmake +index bc5fb9ff7..b64eb4246 100644 +--- a/cmake/Modules/AddCompilerRT.cmake ++++ b/cmake/Modules/AddCompilerRT.cmake +@@ -210,14 +210,6 @@ function(add_compiler_rt_runtime name type) + set_target_properties(${libname} PROPERTIES IMPORT_PREFIX "") + set_target_properties(${libname} PROPERTIES IMPORT_SUFFIX ".lib") + endif() +- if(APPLE) +- # Ad-hoc sign the dylibs +- add_custom_command(TARGET ${libname} +- POST_BUILD +- COMMAND codesign --sign - $<TARGET_FILE:${libname}> +- WORKING_DIRECTORY ${COMPILER_RT_LIBRARY_OUTPUT_DIR} +- ) +- endif() + endif() + install(TARGETS ${libname} + ARCHIVE DESTINATION ${COMPILER_RT_LIBRARY_INSTALL_DIR} +diff --git a/test/asan/CMakeLists.txt b/test/asan/CMakeLists.txt +index 8bfc15b5c..f23d0f71a 100644 +--- a/test/asan/CMakeLists.txt ++++ b/test/asan/CMakeLists.txt +@@ -83,58 +83,6 @@ foreach(arch ${ASAN_TEST_ARCH}) + endif() + endforeach() + +-# iOS and iOS simulator test suites +-# These are not added into "check-all", in order to run these tests, use +-# "check-asan-iossim-x86_64" and similar. They also require that an extra env +-# variable to select which iOS device or simulator to use, e.g.: +-# SANITIZER_IOSSIM_TEST_DEVICE_IDENTIFIER="iPhone 6" +-if(APPLE) +- set(EXCLUDE_FROM_ALL ON) +- +- set(ASAN_TEST_TARGET_CC ${COMPILER_RT_TEST_COMPILER}) +- set(ASAN_TEST_IOS "1") +- pythonize_bool(ASAN_TEST_IOS) +- set(ASAN_TEST_DYNAMIC True) +- +- foreach(arch ${DARWIN_iossim_ARCHS}) +- set(ASAN_TEST_IOSSIM "1") +- pythonize_bool(ASAN_TEST_IOSSIM) +- set(ASAN_TEST_TARGET_ARCH ${arch}) +- set(ASAN_TEST_TARGET_CFLAGS "-arch ${arch} -isysroot ${DARWIN_iossim_SYSROOT} ${COMPILER_RT_TEST_COMPILER_CFLAGS}") +- set(ASAN_TEST_CONFIG_SUFFIX "-${arch}-iossim") +- get_bits_for_arch(${arch} ASAN_TEST_BITS) +- string(TOUPPER ${arch} ARCH_UPPER_CASE) +- set(CONFIG_NAME "IOSSim${ARCH_UPPER_CASE}Config") +- configure_lit_site_cfg( +- ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in +- ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/lit.site.cfg +- ) +- add_lit_testsuite(check-asan-iossim-${arch} "AddressSanitizer iOS Simulator ${arch} tests" +- ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/ +- DEPENDS ${ASAN_TEST_DEPS}) +- endforeach() +- +- foreach (arch ${DARWIN_ios_ARCHS}) +- set(ASAN_TEST_IOSSIM "0") +- pythonize_bool(ASAN_TEST_IOSSIM) +- set(ASAN_TEST_TARGET_ARCH ${arch}) +- set(ASAN_TEST_TARGET_CFLAGS "-arch ${arch} -isysroot ${DARWIN_ios_SYSROOT} ${COMPILER_RT_TEST_COMPILER_CFLAGS}") +- set(ASAN_TEST_CONFIG_SUFFIX "-${arch}-ios") +- get_bits_for_arch(${arch} ASAN_TEST_BITS) +- string(TOUPPER ${arch} ARCH_UPPER_CASE) +- set(CONFIG_NAME "IOS${ARCH_UPPER_CASE}Config") +- configure_lit_site_cfg( +- ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in +- ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/lit.site.cfg +- ) +- add_lit_testsuite(check-asan-ios-${arch} "AddressSanitizer iOS ${arch} tests" +- ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/ +- DEPENDS ${ASAN_TEST_DEPS}) +- endforeach() +- +- set(EXCLUDE_FROM_ALL OFF) +-endif() +- + # Add unit tests. + if(COMPILER_RT_INCLUDE_TESTS) + set(ASAN_TEST_DYNAMIC False) +diff --git a/test/tsan/CMakeLists.txt b/test/tsan/CMakeLists.txt +index a68908612..cde0accb5 100644 +--- a/test/tsan/CMakeLists.txt ++++ b/test/tsan/CMakeLists.txt +@@ -42,53 +42,6 @@ foreach(arch ${TSAN_TEST_ARCH}) + list(APPEND TSAN_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}) + endforeach() + +-# iOS and iOS simulator test suites +-# These are not added into "check-all", in order to run these tests, use +-# "check-tsan-iossim-x86_64" and similar. They also require an extra environment +-# variable to select which iOS device or simulator to use, e.g.: +-# SANITIZER_IOSSIM_TEST_DEVICE_IDENTIFIER="iPhone 6" +-if(APPLE) +- set(EXCLUDE_FROM_ALL ON) +- +- set(TSAN_TEST_TARGET_CC ${COMPILER_RT_TEST_COMPILER}) +- set(TSAN_TEST_IOS "1") +- pythonize_bool(TSAN_TEST_IOS) +- +- set(arch "x86_64") +- set(TSAN_TEST_IOSSIM "1") +- pythonize_bool(TSAN_TEST_IOSSIM) +- set(TSAN_TEST_TARGET_ARCH ${arch}) +- set(TSAN_TEST_TARGET_CFLAGS "-arch ${arch} -isysroot ${DARWIN_iossim_SYSROOT} ${COMPILER_RT_TEST_COMPILER_CFLAGS}") +- set(TSAN_TEST_CONFIG_SUFFIX "-${arch}-iossim") +- string(TOUPPER ${arch} ARCH_UPPER_CASE) +- set(CONFIG_NAME "IOSSim${ARCH_UPPER_CASE}Config") +- configure_lit_site_cfg( +- ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in +- ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/lit.site.cfg +- ) +- add_lit_testsuite(check-tsan-iossim-${arch} "ThreadSanitizer iOS Simulator ${arch} tests" +- ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/ +- DEPENDS ${TSAN_TEST_DEPS}) +- +- set(arch "arm64") +- set(TSAN_TEST_IOSSIM "0") +- pythonize_bool(TSAN_TEST_IOSSIM) +- set(TSAN_TEST_TARGET_ARCH ${arch}) +- set(TSAN_TEST_TARGET_CFLAGS "-arch ${arch} -isysroot ${DARWIN_ios_SYSROOT} ${COMPILER_RT_TEST_COMPILER_CFLAGS}") +- set(TSAN_TEST_CONFIG_SUFFIX "-${arch}-ios") +- string(TOUPPER ${arch} ARCH_UPPER_CASE) +- set(CONFIG_NAME "IOS${ARCH_UPPER_CASE}Config") +- configure_lit_site_cfg( +- ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in +- ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/lit.site.cfg +- ) +- add_lit_testsuite(check-tsan-ios-${arch} "ThreadSanitizer iOS Simulator ${arch} tests" +- ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/ +- DEPENDS ${TSAN_TEST_DEPS}) +- +- set(EXCLUDE_FROM_ALL OFF) +-endif() +- + if(COMPILER_RT_INCLUDE_TESTS) + configure_lit_site_cfg( + ${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.site.cfg.in +-- +2.14.1 + diff --git a/nixpkgs/pkgs/development/compilers/llvm/6/compiler-rt.nix b/nixpkgs/pkgs/development/compilers/llvm/6/compiler-rt.nix new file mode 100644 index 000000000000..be18a315f12a --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/6/compiler-rt.nix @@ -0,0 +1,37 @@ +{ stdenv, version, fetch, cmake, python, llvm, libcxxabi }: +with stdenv.lib; +stdenv.mkDerivation rec { + name = "compiler-rt-${version}"; + inherit version; + src = fetch "compiler-rt" "1fcr3jn24yr8lh36nc0c4ikli4744i2q9m1ik67p1jymwwaixkgl"; + + nativeBuildInputs = [ cmake python llvm ]; + buildInputs = stdenv.lib.optional stdenv.hostPlatform.isDarwin libcxxabi; + + configureFlags = [ + "-DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON" + ]; + + outputs = [ "out" "dev" ]; + + patches = [ + ./compiler-rt-codesign.patch # Revert compiler-rt commit that makes codesign mandatory + ] ++ optional stdenv.hostPlatform.isMusl ./sanitizers-nongnu.patch; + + # TSAN requires XPC on Darwin, which we have no public/free source files for. We can depend on the Apple frameworks + # to get it, but they're unfree. Since LLVM is rather central to the stdenv, we patch out TSAN support so that Hydra + # can build this. If we didn't do it, basically the entire nixpkgs on Darwin would have an unfree dependency and we'd + # get no binary cache for the entire platform. If you really find yourself wanting the TSAN, make this controllable by + # a flag and turn the flag off during the stdenv build. + postPatch = stdenv.lib.optionalString stdenv.isDarwin '' + substituteInPlace cmake/config-ix.cmake \ + --replace 'set(COMPILER_RT_HAS_TSAN TRUE)' 'set(COMPILER_RT_HAS_TSAN FALSE)' + ''; + + # Hack around weird upsream RPATH bug + postInstall = stdenv.lib.optionalString stdenv.isDarwin '' + ln -s "$out/lib"/*/* "$out/lib" + ''; + + enableParallelBuilding = true; +} diff --git a/nixpkgs/pkgs/development/compilers/llvm/6/default.nix b/nixpkgs/pkgs/development/compilers/llvm/6/default.nix new file mode 100644 index 000000000000..ae51c19ec728 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/6/default.nix @@ -0,0 +1,93 @@ +{ lowPrio, newScope, pkgs, stdenv, cmake, libstdcxxHook +, libxml2, python, isl, fetchurl, overrideCC, wrapCCWith +, buildLlvmTools # tools, but from the previous stage, for cross +, targetLlvmLibraries # libraries, but from the next stage, for cross +}: + +let + release_version = "6.0.1"; + version = release_version; # differentiating these is important for rc's + + fetch = name: sha256: fetchurl { + url = "https://releases.llvm.org/${release_version}/${name}-${version}.src.tar.xz"; + inherit sha256; + }; + + clang-tools-extra_src = fetch "clang-tools-extra" "1w8ml7fyn4vyxmy59n2qm4r1k1kgwgwkaldp6m45fdv4g0kkfbhd"; + + tools = stdenv.lib.makeExtensible (tools: let + callPackage = newScope (tools // { inherit stdenv cmake libxml2 python isl release_version version fetch; }); + mkExtraBuildCommands = cc: '' + rsrc="$out/resource-root" + mkdir "$rsrc" + ln -s "${cc}/lib/clang/${release_version}/include" "$rsrc" + ln -s "${targetLlvmLibraries.compiler-rt.out}/lib" "$rsrc/lib" + echo "-resource-dir=$rsrc" >> $out/nix-support/cc-cflags + '' + stdenv.lib.optionalString stdenv.targetPlatform.isLinux '' + echo "--gcc-toolchain=${tools.clang-unwrapped.gcc}" >> $out/nix-support/cc-cflags + ''; + in { + + llvm = callPackage ./llvm.nix { }; + + clang-unwrapped = callPackage ./clang { + inherit clang-tools-extra_src; + }; + + llvm-manpages = lowPrio (tools.llvm.override { + enableManpages = true; + python = pkgs.python; # don't use python-boot + }); + + clang-manpages = lowPrio (tools.clang-unwrapped.override { + enableManpages = true; + python = pkgs.python; # don't use python-boot + }); + + libclang = tools.clang-unwrapped.lib; + + clang = if stdenv.cc.isGNU then tools.libstdcxxClang else tools.libcxxClang; + + libstdcxxClang = wrapCCWith rec { + cc = tools.clang-unwrapped; + extraPackages = [ + libstdcxxHook + targetLlvmLibraries.compiler-rt + ]; + extraBuildCommands = mkExtraBuildCommands cc; + }; + + libcxxClang = wrapCCWith rec { + cc = tools.clang-unwrapped; + libcxx = targetLlvmLibraries.libcxx; + extraPackages = [ + targetLlvmLibraries.libcxx + targetLlvmLibraries.libcxxabi + targetLlvmLibraries.compiler-rt + ]; + extraBuildCommands = mkExtraBuildCommands cc; + }; + + lld = callPackage ./lld.nix {}; + + lldb = callPackage ./lldb.nix {}; + }); + + libraries = stdenv.lib.makeExtensible (libraries: let + callPackage = newScope (libraries // buildLlvmTools // { inherit stdenv cmake libxml2 python isl release_version version fetch; }); + in { + + compiler-rt = callPackage ./compiler-rt.nix {}; + + stdenv = overrideCC stdenv buildLlvmTools.clang; + + libcxxStdenv = overrideCC stdenv buildLlvmTools.libcxxClang; + + libcxx = callPackage ./libc++ {}; + + libcxxabi = callPackage ./libc++abi.nix {}; + + openmp = callPackage ./openmp.nix {}; + }); + +in { inherit tools libraries; } // libraries // tools diff --git a/nixpkgs/pkgs/development/compilers/llvm/6/libc++/default.nix b/nixpkgs/pkgs/development/compilers/llvm/6/libc++/default.nix new file mode 100644 index 000000000000..3a165e9da7b1 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/6/libc++/default.nix @@ -0,0 +1,52 @@ +{ lib, stdenv, fetch, cmake, python, libcxxabi, fixDarwinDylibNames, version }: + +stdenv.mkDerivation rec { + name = "libc++-${version}"; + + src = fetch "libcxx" "0rzw4qvxp6qx4l4h9amrq02gp7hbg8lw4m0sy3k60f50234gnm3n"; + + postUnpack = '' + unpackFile ${libcxxabi.src} + export LIBCXXABI_INCLUDE_DIR="$PWD/$(ls -d libcxxabi-${version}*)/include" + ''; + + patches = stdenv.lib.optionals stdenv.hostPlatform.isMusl [ + ../../libcxx-0001-musl-hacks.patch + ]; + + prePatch = '' + substituteInPlace lib/CMakeLists.txt --replace "/usr/lib/libc++" "\''${LIBCXX_LIBCXXABI_LIB_PATH}/libc++" + ''; + + preConfigure = '' + # Get headers from the cxxabi source so we can see private headers not installed by the cxxabi package + cmakeFlagsArray=($cmakeFlagsArray -DLIBCXX_CXX_ABI_INCLUDE_PATHS="$LIBCXXABI_INCLUDE_DIR") + '' + lib.optionalString stdenv.hostPlatform.isMusl '' + patchShebangs utils/cat_files.py + ''; + nativeBuildInputs = [ cmake ] ++ stdenv.lib.optional stdenv.hostPlatform.isMusl python; + + buildInputs = [ libcxxabi ] ++ lib.optional stdenv.isDarwin fixDarwinDylibNames; + + cmakeFlags = [ + "-DLIBCXX_LIBCXXABI_LIB_PATH=${libcxxabi}/lib" + "-DLIBCXX_LIBCPPABI_VERSION=2" + "-DLIBCXX_CXX_ABI=libcxxabi" + ] ++ stdenv.lib.optional stdenv.hostPlatform.isMusl "-DLIBCXX_HAS_MUSL_LIBC=1"; + + enableParallelBuilding = true; + + linkCxxAbi = stdenv.isLinux; + + setupHooks = [ + ../../../../../build-support/setup-hooks/role.bash + ./setup-hook.sh + ]; + + meta = { + homepage = http://libcxx.llvm.org/; + description = "A new implementation of the C++ standard library, targeting C++11"; + license = with stdenv.lib.licenses; [ ncsa mit ]; + platforms = stdenv.lib.platforms.unix; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/llvm/6/libc++/setup-hook.sh b/nixpkgs/pkgs/development/compilers/llvm/6/libc++/setup-hook.sh new file mode 100644 index 000000000000..6611259165ae --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/6/libc++/setup-hook.sh @@ -0,0 +1,6 @@ +# See pkgs/build-support/setup-hooks/role.bash +getHostRole + +linkCxxAbi="@linkCxxAbi@" +export NIX_${role_pre}CXXSTDLIB_COMPILE+=" -isystem @out@/include/c++/v1" +export NIX_${role_pre}CXXSTDLIB_LINK=" -stdlib=libc++${linkCxxAbi:+" -lc++abi"}" diff --git a/nixpkgs/pkgs/development/compilers/llvm/6/libc++abi.nix b/nixpkgs/pkgs/development/compilers/llvm/6/libc++abi.nix new file mode 100644 index 000000000000..df9c784a10f4 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/6/libc++abi.nix @@ -0,0 +1,50 @@ +{ stdenv, cmake, fetch, libcxx, libunwind, llvm, version }: + +stdenv.mkDerivation { + name = "libc++abi-${version}"; + + src = fetch "libcxxabi" "0prqvdj317qrc8nddaq1hh2ag9algkd9wbkj3y4mr5588k12x7r0"; + + nativeBuildInputs = [ cmake ]; + buildInputs = stdenv.lib.optional (!stdenv.isDarwin && !stdenv.isFreeBSD) libunwind; + + postUnpack = '' + unpackFile ${libcxx.src} + unpackFile ${llvm.src} + export cmakeFlags="-DLLVM_PATH=$PWD/$(ls -d llvm-*) -DLIBCXXABI_LIBCXX_PATH=$PWD/$(ls -d libcxx-*)" + '' + stdenv.lib.optionalString stdenv.isDarwin '' + export TRIPLE=x86_64-apple-darwin + '' + stdenv.lib.optionalString stdenv.hostPlatform.isMusl '' + patch -p1 -d $(ls -d libcxx-*) -i ${../libcxx-0001-musl-hacks.patch} + ''; + + installPhase = if stdenv.isDarwin + then '' + for file in lib/*.dylib; do + # this should be done in CMake, but having trouble figuring out + # the magic combination of necessary CMake variables + # if you fancy a try, take a look at + # http://www.cmake.org/Wiki/CMake_RPATH_handling + install_name_tool -id $out/$file $file + done + make install + install -d 755 $out/include + install -m 644 ../include/*.h $out/include + '' + else '' + install -d -m 755 $out/include $out/lib + install -m 644 lib/libc++abi.a $out/lib + install -m 644 lib/libc++abi.so.1.0 $out/lib + install -m 644 ../include/cxxabi.h $out/include + ln -s libc++abi.so.1.0 $out/lib/libc++abi.so + ln -s libc++abi.so.1.0 $out/lib/libc++abi.so.1 + ''; + + meta = { + homepage = http://libcxxabi.llvm.org/; + description = "A new implementation of low level support for a standard C++ library"; + license = with stdenv.lib.licenses; [ ncsa mit ]; + maintainers = with stdenv.lib.maintainers; [ vlstill ]; + platforms = stdenv.lib.platforms.unix; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/llvm/6/lld.nix b/nixpkgs/pkgs/development/compilers/llvm/6/lld.nix new file mode 100644 index 000000000000..1e68276945ec --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/6/lld.nix @@ -0,0 +1,32 @@ +{ stdenv +, fetch +, cmake +, libxml2 +, llvm +, version +}: + +stdenv.mkDerivation { + name = "lld-${version}"; + + src = fetch "lld" "04afcfq2h7ysyqxxhyhb7ig4p0vdw7mi63kh8mffl74j0rc781p7"; + + nativeBuildInputs = [ cmake ]; + buildInputs = [ llvm libxml2 ]; + + outputs = [ "out" "dev" ]; + + enableParallelBuilding = true; + + postInstall = '' + moveToOutput include "$dev" + moveToOutput lib "$dev" + ''; + + meta = { + description = "The LLVM Linker"; + homepage = http://lld.llvm.org/; + license = stdenv.lib.licenses.ncsa; + platforms = stdenv.lib.platforms.all; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/llvm/6/lldb.nix b/nixpkgs/pkgs/development/compilers/llvm/6/lldb.nix new file mode 100644 index 000000000000..d33de2488350 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/6/lldb.nix @@ -0,0 +1,56 @@ +{ stdenv +, fetch +, cmake +, zlib +, ncurses +, swig +, which +, libedit +, libxml2 +, llvm +, clang-unwrapped +, python +, version +, darwin +}: + +stdenv.mkDerivation { + name = "lldb-${version}"; + + src = fetch "lldb" "05178zkyh84x32n91md6wm22lkzzrrfwa5cpmgzn0yrg3y2771bb"; + + postPatch = '' + # Fix up various paths that assume llvm and clang are installed in the same place + sed -i 's,".*ClangConfig.cmake","${clang-unwrapped}/lib/cmake/clang/ClangConfig.cmake",' \ + cmake/modules/LLDBStandalone.cmake + sed -i 's,".*tools/clang/include","${clang-unwrapped}/include",' \ + cmake/modules/LLDBStandalone.cmake + sed -i 's,"$.LLVM_LIBRARY_DIR.",${llvm}/lib ${clang-unwrapped}/lib,' \ + cmake/modules/LLDBStandalone.cmake + ''; + + nativeBuildInputs = [ cmake python which swig ]; + buildInputs = [ ncurses zlib libedit libxml2 llvm ] + ++ stdenv.lib.optionals stdenv.isDarwin [ darwin.libobjc darwin.apple_sdk.libs.xpc darwin.apple_sdk.frameworks.Foundation darwin.bootstrap_cmds darwin.apple_sdk.frameworks.Carbon darwin.apple_sdk.frameworks.Cocoa darwin.cf-private ]; + + CXXFLAGS = "-fno-rtti"; + hardeningDisable = [ "format" ]; + + cmakeFlags = [ + "-DLLDB_CODESIGN_IDENTITY=" # codesigning makes nondeterministic + ]; + + enableParallelBuilding = true; + + postInstall = '' + mkdir -p $out/share/man/man1 + cp ../docs/lldb.1 $out/share/man/man1/ + ''; + + meta = with stdenv.lib; { + description = "A next-generation high-performance debugger"; + homepage = http://llvm.org/; + license = licenses.ncsa; + platforms = platforms.all; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/llvm/6/llvm-outputs.patch b/nixpkgs/pkgs/development/compilers/llvm/6/llvm-outputs.patch new file mode 100644 index 000000000000..40096fa3497f --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/6/llvm-outputs.patch @@ -0,0 +1,26 @@ +diff --git a/tools/llvm-config/llvm-config.cpp b/tools/llvm-config/llvm-config.cpp +index 94d426b..37f7794 100644 +--- a/tools/llvm-config/llvm-config.cpp ++++ b/tools/llvm-config/llvm-config.cpp +@@ -333,6 +333,21 @@ int main(int argc, char **argv) { + ActiveIncludeOption = "-I" + ActiveIncludeDir; + } + ++ /// Nix-specific multiple-output handling: override ActiveLibDir if --link-shared ++ if (!IsInDevelopmentTree) { ++ bool WantShared = true; ++ for (int i = 1; i < argc; ++i) { ++ StringRef Arg = argv[i]; ++ if (Arg == "--link-shared") ++ WantShared = true; ++ else if (Arg == "--link-static") ++ WantShared = false; // the last one wins ++ } ++ ++ if (WantShared) ++ ActiveLibDir = std::string("@lib@") + "/lib" + LLVM_LIBDIR_SUFFIX; ++ } ++ + /// We only use `shared library` mode in cases where the static library form + /// of the components provided are not available; note however that this is + /// skipped if we're run from within the build dir. However, once installed, diff --git a/nixpkgs/pkgs/development/compilers/llvm/6/llvm.nix b/nixpkgs/pkgs/development/compilers/llvm/6/llvm.nix new file mode 100644 index 000000000000..1d96513a0ece --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/6/llvm.nix @@ -0,0 +1,173 @@ +{ stdenv +, fetch +, cmake +, python +, libffi +, libbfd +, libxml2 +, ncurses +, version +, release_version +, zlib +, buildPackages +, fetchpatch +, debugVersion ? false +, enableManpages ? false +, enableSharedLibraries ? true +}: + +let + inherit (stdenv.lib) optional optionals optionalString; + + src = fetch "llvm" "1qpls3vk85lydi5b4axl0809fv932qgsqgdgrk098567z4jc7mmn"; + + # Used when creating a version-suffixed symlink of libLLVM.dylib + shortVersion = with stdenv.lib; + concatStringsSep "." (take 2 (splitString "." release_version)); + +in stdenv.mkDerivation (rec { + name = "llvm-${version}"; + + unpackPhase = '' + unpackFile ${src} + mv llvm-${version}* llvm + sourceRoot=$PWD/llvm + ''; + + outputs = [ "out" "python" ] + ++ optional enableSharedLibraries "lib"; + + nativeBuildInputs = [ cmake python ] + ++ optional enableManpages python.pkgs.sphinx; + + buildInputs = [ libxml2 libffi ]; + + propagatedBuildInputs = [ ncurses zlib ]; + + patches = [ + # Patches to fix tests, included in llvm_7 + (fetchpatch { + url = "https://github.com/llvm-mirror/llvm/commit/737553be0c9c25c497b45a241689994f177d5a5d.patch"; + sha256 = "0hnaxnkx7zy5yg98f1ggv8a9l0r6g19n6ygqsv26masrnlcbccli"; + }) + (fetchpatch { + url = "https://github.com/llvm-mirror/llvm/commit/1c0dd31a7837c3e2f1c4ac14e4d5ac640688bd1f.patch"; + includes = [ "test/tools/gold/X86/common.ll" ]; + sha256 = "0fxgrxmfnjx17w3lcq19rk68b2xksh1bynz3ina784kma7hp4wdb"; + }) + ]; + + postPatch = optionalString stdenv.isDarwin '' + substituteInPlace cmake/modules/AddLLVM.cmake \ + --replace 'set(_install_name_dir INSTALL_NAME_DIR "@rpath")' "set(_install_name_dir)" \ + --replace 'set(_install_rpath "@loader_path/../lib" ''${extra_libdir})' "" + '' + # Patch llvm-config to return correct library path based on --link-{shared,static}. + + optionalString (enableSharedLibraries) '' + substitute '${./llvm-outputs.patch}' ./llvm-outputs.patch --subst-var lib + patch -p1 < ./llvm-outputs.patch + '' + '' + # FileSystem permissions tests fail with various special bits + substituteInPlace unittests/Support/CMakeLists.txt \ + --replace "Path.cpp" "" + rm unittests/Support/Path.cpp + '' + optionalString stdenv.hostPlatform.isMusl '' + patch -p1 -i ${../TLI-musl.patch} + substituteInPlace unittests/Support/CMakeLists.txt \ + --replace "add_subdirectory(DynamicLibrary)" "" + rm unittests/Support/DynamicLibrary/DynamicLibraryTest.cpp + ''; + + # hacky fix: created binaries need to be run before installation + preBuild = '' + mkdir -p $out/ + ln -sv $PWD/lib $out + ''; + + cmakeFlags = with stdenv; [ + "-DCMAKE_BUILD_TYPE=${if debugVersion then "Debug" else "Release"}" + "-DLLVM_INSTALL_UTILS=ON" # Needed by rustc + "-DLLVM_BUILD_TESTS=ON" + "-DLLVM_ENABLE_FFI=ON" + "-DLLVM_ENABLE_RTTI=ON" + "-DLLVM_HOST_TRIPLE=${stdenv.hostPlatform.config}" + "-DLLVM_DEFAULT_TARGET_TRIPLE=${stdenv.hostPlatform.config}" + "-DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=WebAssembly" + "-DLLVM_ENABLE_DUMP=ON" + ] ++ optionals enableSharedLibraries [ + "-DLLVM_LINK_LLVM_DYLIB=ON" + ] ++ optionals enableManpages [ + "-DLLVM_BUILD_DOCS=ON" + "-DLLVM_ENABLE_SPHINX=ON" + "-DSPHINX_OUTPUT_MAN=ON" + "-DSPHINX_OUTPUT_HTML=OFF" + "-DSPHINX_WARNINGS_AS_ERRORS=OFF" + ] ++ optionals (!isDarwin) [ + "-DLLVM_BINUTILS_INCDIR=${libbfd.dev}/include" + ] ++ optionals (isDarwin) [ + "-DLLVM_ENABLE_LIBCXX=ON" + "-DCAN_TARGET_i386=false" + ] ++ optionals (stdenv.hostPlatform != stdenv.buildPlatform) [ + "-DCMAKE_CROSSCOMPILING=True" + "-DLLVM_TABLEGEN=${buildPackages.llvm_6}/bin/llvm-tblgen" + ]; + + postBuild = '' + rm -fR $out + ''; + + preCheck = '' + export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$PWD/lib + ''; + + postInstall = '' + mkdir -p $python/share + mv $out/share/opt-viewer $python/share/opt-viewer + '' + + optionalString enableSharedLibraries '' + moveToOutput "lib/libLLVM-*" "$lib" + moveToOutput "lib/libLLVM${stdenv.hostPlatform.extensions.sharedLibrary}" "$lib" + substituteInPlace "$out/lib/cmake/llvm/LLVMExports-${if debugVersion then "debug" else "release"}.cmake" \ + --replace "\''${_IMPORT_PREFIX}/lib/libLLVM-" "$lib/lib/libLLVM-" + '' + + optionalString (stdenv.isDarwin && enableSharedLibraries) '' + substituteInPlace "$out/lib/cmake/llvm/LLVMExports-${if debugVersion then "debug" else "release"}.cmake" \ + --replace "\''${_IMPORT_PREFIX}/lib/libLLVM.dylib" "$lib/lib/libLLVM.dylib" + ln -s $lib/lib/libLLVM.dylib $lib/lib/libLLVM-${shortVersion}.dylib + ln -s $lib/lib/libLLVM.dylib $lib/lib/libLLVM-${release_version}.dylib + ''; + + doCheck = stdenv.isLinux && (!stdenv.isi686); + + checkTarget = "check-all"; + + enableParallelBuilding = true; + + passthru.src = src; + + meta = { + description = "Collection of modular and reusable compiler and toolchain technologies"; + homepage = http://llvm.org/; + license = stdenv.lib.licenses.ncsa; + maintainers = with stdenv.lib.maintainers; [ lovek323 raskin dtzWill ]; + platforms = stdenv.lib.platforms.all; + }; +} // stdenv.lib.optionalAttrs enableManpages { + name = "llvm-manpages-${version}"; + + buildPhase = '' + make docs-llvm-man + ''; + + propagatedBuildInputs = []; + + installPhase = '' + make -C docs install + ''; + + outputs = [ "out" ]; + + doCheck = false; + + meta.description = "man pages for LLVM ${version}"; +}) diff --git a/nixpkgs/pkgs/development/compilers/llvm/6/openmp.nix b/nixpkgs/pkgs/development/compilers/llvm/6/openmp.nix new file mode 100644 index 000000000000..908a5f1218f7 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/6/openmp.nix @@ -0,0 +1,25 @@ +{ stdenv +, fetch +, cmake +, llvm +, perl +, version +}: + +stdenv.mkDerivation { + name = "openmp-${version}"; + + src = fetch "openmp" "0nhwfba9c351r16zgyjyfwdayr98nairky3c2f0b2lc360mwmbv6"; + + nativeBuildInputs = [ cmake perl ]; + buildInputs = [ llvm ]; + + enableParallelBuilding = true; + + meta = { + description = "Components required to build an executable OpenMP program"; + homepage = http://openmp.llvm.org/; + license = stdenv.lib.licenses.mit; + platforms = stdenv.lib.platforms.all; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/llvm/6/sanitizers-nongnu.patch b/nixpkgs/pkgs/development/compilers/llvm/6/sanitizers-nongnu.patch new file mode 100644 index 000000000000..6266eb1958d1 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/6/sanitizers-nongnu.patch @@ -0,0 +1,413 @@ +From 7b4b3333a2718628b1d510ec1d8438ad67308299 Mon Sep 17 00:00:00 2001 +From: Will Dietz <w@wdtz.org> +Date: Fri, 29 Jun 2018 09:48:59 -0500 +Subject: [PATCH] Ported to 6.0, taken from gentoo-musl project. + +------ +Ported to compiler-rt-sanitizers-5.0.0. Taken from + +https://gist.githubusercontent.com/pwaller/2337f3290f12634cad3e3730cff0a6c1/raw/83c87a8585e2f9662494db5662e5361beb093c26/nongnu.patch +Signed-off-by: Jory A. Pratt <anarchy@gentoo.org> + +Taken from gentoo-musl project, with a few additional minor fixes. +--- + lib/asan/asan_linux.cc | 4 +- + lib/interception/interception_linux.cc | 2 +- + lib/interception/interception_linux.h | 3 +- + lib/msan/msan_linux.cc | 2 +- + lib/sanitizer_common/sanitizer_allocator.cc | 2 +- + .../sanitizer_common_interceptors_ioctl.inc | 4 +- + .../sanitizer_common_syscalls.inc | 2 +- + lib/sanitizer_common/sanitizer_linux.cc | 8 +++- + .../sanitizer_linux_libcdep.cc | 10 ++--- + lib/sanitizer_common/sanitizer_platform.h | 6 +++ + .../sanitizer_platform_interceptors.h | 4 +- + .../sanitizer_platform_limits_posix.cc | 37 +++++++++++-------- + lib/tsan/rtl/tsan_platform_linux.cc | 2 +- + 13 files changed, 51 insertions(+), 35 deletions(-) + +diff --git a/lib/asan/asan_linux.cc b/lib/asan/asan_linux.cc +index 625f32d40..73cf77aca 100644 +--- a/lib/asan/asan_linux.cc ++++ b/lib/asan/asan_linux.cc +@@ -46,7 +46,7 @@ + #include <link.h> + #endif + +-#if SANITIZER_ANDROID || SANITIZER_FREEBSD || SANITIZER_SOLARIS ++#if SANITIZER_ANDROID || SANITIZER_FREEBSD || SANITIZER_SOLARIS || SANITIZER_NONGNU + #include <ucontext.h> + extern "C" void* _DYNAMIC; + #elif SANITIZER_NETBSD +@@ -139,7 +139,7 @@ void AsanApplyToGlobals(globals_op_fptr op, const void *needle) { + UNIMPLEMENTED(); + } + +-#if SANITIZER_ANDROID ++#if SANITIZER_ANDROID || SANITIZER_NONGNU + // FIXME: should we do anything for Android? + void AsanCheckDynamicRTPrereqs() {} + void AsanCheckIncompatibleRT() {} +diff --git a/lib/interception/interception_linux.cc b/lib/interception/interception_linux.cc +index c991550a4..2b706418b 100644 +--- a/lib/interception/interception_linux.cc ++++ b/lib/interception/interception_linux.cc +@@ -43,7 +43,7 @@ bool GetRealFunctionAddress(const char *func_name, uptr *func_addr, + } + + // Android and Solaris do not have dlvsym +-#if !SANITIZER_ANDROID && !SANITIZER_SOLARIS ++#if !SANITIZER_ANDROID && !SANITIZER_SOLARIS && !SANITIZER_NONGNU + void *GetFuncAddrVer(const char *func_name, const char *ver) { + return dlvsym(RTLD_NEXT, func_name, ver); + } +diff --git a/lib/interception/interception_linux.h b/lib/interception/interception_linux.h +index 98fe51b85..c13302b98 100644 +--- a/lib/interception/interception_linux.h ++++ b/lib/interception/interception_linux.h +@@ -35,8 +35,7 @@ void *GetFuncAddrVer(const char *func_name, const char *ver); + (::__interception::uptr) & (func), \ + (::__interception::uptr) & WRAP(func)) + +-// Android and Solaris do not have dlvsym +-#if !SANITIZER_ANDROID && !SANITIZER_SOLARIS ++#if !SANITIZER_ANDROID && !SANITIZER_SOLARIS && !SANITIZER_NONGNU + #define INTERCEPT_FUNCTION_VER_LINUX_OR_FREEBSD(func, symver) \ + (::__interception::real_##func = (func##_f)( \ + unsigned long)::__interception::GetFuncAddrVer(#func, symver)) +diff --git a/lib/msan/msan_linux.cc b/lib/msan/msan_linux.cc +index 4e6321fcb..4d50feb82 100644 +--- a/lib/msan/msan_linux.cc ++++ b/lib/msan/msan_linux.cc +@@ -13,7 +13,7 @@ + //===----------------------------------------------------------------------===// + + #include "sanitizer_common/sanitizer_platform.h" +-#if SANITIZER_FREEBSD || SANITIZER_LINUX || SANITIZER_NETBSD ++#if SANITIZER_FREEBSD || (SANITIZER_LINUX && !SANITIZER_NONGNU) || SANITIZER_NETBSD + + #include "msan.h" + #include "msan_thread.h" +diff --git a/lib/sanitizer_common/sanitizer_allocator.cc b/lib/sanitizer_common/sanitizer_allocator.cc +index fc4f7a75a..76cf4f769 100644 +--- a/lib/sanitizer_common/sanitizer_allocator.cc ++++ b/lib/sanitizer_common/sanitizer_allocator.cc +@@ -23,7 +23,7 @@ namespace __sanitizer { + + // ThreadSanitizer for Go uses libc malloc/free. + #if SANITIZER_GO || defined(SANITIZER_USE_MALLOC) +-# if SANITIZER_LINUX && !SANITIZER_ANDROID ++# if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU + extern "C" void *__libc_malloc(uptr size); + # if !SANITIZER_GO + extern "C" void *__libc_memalign(uptr alignment, uptr size); +diff --git a/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc b/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc +index 24e7548a5..20259b1d6 100644 +--- a/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc ++++ b/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc +@@ -102,7 +102,7 @@ static void ioctl_table_fill() { + _(SIOCGETVIFCNT, WRITE, struct_sioc_vif_req_sz); + #endif + +-#if SANITIZER_LINUX ++#if SANITIZER_LINUX && !SANITIZER_NONGNU + // Conflicting request ids. + // _(CDROMAUDIOBUFSIZ, NONE, 0); + // _(SNDCTL_TMR_CONTINUE, NONE, 0); +@@ -363,7 +363,7 @@ static void ioctl_table_fill() { + _(VT_WAITACTIVE, NONE, 0); + #endif + +-#if SANITIZER_LINUX && !SANITIZER_ANDROID ++#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU + // _(SIOCDEVPLIP, WRITE, struct_ifreq_sz); // the same as EQL_ENSLAVE + _(CYGETDEFTHRESH, WRITE, sizeof(int)); + _(CYGETDEFTIMEOUT, WRITE, sizeof(int)); +diff --git a/lib/sanitizer_common/sanitizer_common_syscalls.inc b/lib/sanitizer_common/sanitizer_common_syscalls.inc +index 469c8eb7e..24f87867d 100644 +--- a/lib/sanitizer_common/sanitizer_common_syscalls.inc ++++ b/lib/sanitizer_common/sanitizer_common_syscalls.inc +@@ -2038,7 +2038,7 @@ POST_SYSCALL(setrlimit)(long res, long resource, void *rlim) { + } + } + +-#if !SANITIZER_ANDROID ++#if !SANITIZER_ANDROID && !SANITIZER_NONGNU + PRE_SYSCALL(prlimit64)(long pid, long resource, const void *new_rlim, + void *old_rlim) { + if (new_rlim) PRE_READ(new_rlim, struct_rlimit64_sz); +diff --git a/lib/sanitizer_common/sanitizer_linux.cc b/lib/sanitizer_common/sanitizer_linux.cc +index 6c83e8db4..542c4fe64 100644 +--- a/lib/sanitizer_common/sanitizer_linux.cc ++++ b/lib/sanitizer_common/sanitizer_linux.cc +@@ -522,13 +522,13 @@ const char *GetEnv(const char *name) { + #endif + } + +-#if !SANITIZER_FREEBSD && !SANITIZER_NETBSD ++#if !SANITIZER_FREEBSD && !SANITIZER_NETBSD && !SANITIZER_NONGNU + extern "C" { + SANITIZER_WEAK_ATTRIBUTE extern void *__libc_stack_end; + } + #endif + +-#if !SANITIZER_GO && !SANITIZER_FREEBSD && !SANITIZER_NETBSD ++#if (!SANITIZER_GO || SANITIZER_NONGNU) && !SANITIZER_FREEBSD && !SANITIZER_NETBSD + static void ReadNullSepFileToArray(const char *path, char ***arr, + int arr_size) { + char *buff; +@@ -569,6 +569,10 @@ static void GetArgsAndEnv(char ***argv, char ***envp) { + #elif SANITIZER_NETBSD + *argv = __ps_strings->ps_argvstr; + *argv = __ps_strings->ps_envstr; ++#elif SANITIZER_NONGNU ++ static const int kMaxArgv = 2000, kMaxEnvp = 2000; ++ ReadNullSepFileToArray("/proc/self/cmdline", argv, kMaxArgv); ++ ReadNullSepFileToArray("/proc/self/environ", envp, kMaxEnvp); + #else + #if !SANITIZER_GO + if (&__libc_stack_end) { +diff --git a/lib/sanitizer_common/sanitizer_linux_libcdep.cc b/lib/sanitizer_common/sanitizer_linux_libcdep.cc +index 56fdfc870..a932d5db1 100644 +--- a/lib/sanitizer_common/sanitizer_linux_libcdep.cc ++++ b/lib/sanitizer_common/sanitizer_linux_libcdep.cc +@@ -174,7 +174,7 @@ bool SanitizerGetThreadName(char *name, int max_len) { + } + + #if !SANITIZER_FREEBSD && !SANITIZER_ANDROID && !SANITIZER_GO && \ +- !SANITIZER_NETBSD && !SANITIZER_SOLARIS ++ !SANITIZER_NETBSD && !SANITIZER_SOLARIS && !SANITIZER_NONGNU + static uptr g_tls_size; + + #ifdef __i386__ +@@ -207,7 +207,7 @@ void InitTlsSize() { } + + #if (defined(__x86_64__) || defined(__i386__) || defined(__mips__) \ + || defined(__aarch64__) || defined(__powerpc64__) || defined(__s390__) \ +- || defined(__arm__)) && SANITIZER_LINUX && !SANITIZER_ANDROID ++ || defined(__arm__)) && SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU + // sizeof(struct pthread) from glibc. + static atomic_uintptr_t kThreadDescriptorSize; + +@@ -391,7 +391,7 @@ int GetSizeFromHdr(struct dl_phdr_info *info, size_t size, void *data) { + + #if !SANITIZER_GO + static void GetTls(uptr *addr, uptr *size) { +-#if SANITIZER_LINUX && !SANITIZER_ANDROID ++#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU + # if defined(__x86_64__) || defined(__i386__) || defined(__s390__) + *addr = ThreadSelf(); + *size = GetTlsSize(); +@@ -432,7 +432,7 @@ static void GetTls(uptr *addr, uptr *size) { + *addr = (uptr)tcb->tcb_dtv[1]; + } + } +-#elif SANITIZER_ANDROID ++#elif SANITIZER_ANDROID || SANITIZER_NONGNU + *addr = 0; + *size = 0; + #elif SANITIZER_SOLARIS +@@ -448,7 +448,7 @@ static void GetTls(uptr *addr, uptr *size) { + #if !SANITIZER_GO + uptr GetTlsSize() { + #if SANITIZER_FREEBSD || SANITIZER_ANDROID || SANITIZER_NETBSD || \ +- SANITIZER_SOLARIS ++ SANITIZER_SOLARIS || SANITIZER_NONGNU + uptr addr, size; + GetTls(&addr, &size); + return size; +diff --git a/lib/sanitizer_common/sanitizer_platform.h b/lib/sanitizer_common/sanitizer_platform.h +index 334903c26..fc2afac2c 100644 +--- a/lib/sanitizer_common/sanitizer_platform.h ++++ b/lib/sanitizer_common/sanitizer_platform.h +@@ -195,6 +195,12 @@ + # define SANITIZER_SOLARIS32 0 + #endif + ++#if defined(__linux__) && !defined(__GLIBC__) ++# define SANITIZER_NONGNU 1 ++#else ++# define SANITIZER_NONGNU 0 ++#endif ++ + // By default we allow to use SizeClassAllocator64 on 64-bit platform. + // But in some cases (e.g. AArch64's 39-bit address space) SizeClassAllocator64 + // does not work well and we need to fallback to SizeClassAllocator32. +diff --git a/lib/sanitizer_common/sanitizer_platform_interceptors.h b/lib/sanitizer_common/sanitizer_platform_interceptors.h +index b99ac4480..628d226a1 100644 +--- a/lib/sanitizer_common/sanitizer_platform_interceptors.h ++++ b/lib/sanitizer_common/sanitizer_platform_interceptors.h +@@ -38,7 +38,7 @@ + # include "sanitizer_platform_limits_solaris.h" + #endif + +-#if SANITIZER_LINUX && !SANITIZER_ANDROID ++#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU + # define SI_LINUX_NOT_ANDROID 1 + #else + # define SI_LINUX_NOT_ANDROID 0 +@@ -291,7 +291,7 @@ + (SI_FREEBSD || SI_MAC || SI_LINUX_NOT_ANDROID) + #define SANITIZER_INTERCEPT_ETHER_R (SI_FREEBSD || SI_LINUX_NOT_ANDROID) + #define SANITIZER_INTERCEPT_SHMCTL \ +- (SI_NETBSD || SI_SOLARIS || ((SI_FREEBSD || SI_LINUX_NOT_ANDROID) && \ ++ (SI_NETBSD || SI_SOLARIS || ((SI_FREEBSD || SI_LINUX_NOT_ANDROID || SANITIZER_NONGNU) && \ + SANITIZER_WORDSIZE == 64)) // NOLINT + #define SANITIZER_INTERCEPT_RANDOM_R SI_LINUX_NOT_ANDROID + #define SANITIZER_INTERCEPT_PTHREAD_ATTR_GET SI_POSIX +diff --git a/lib/sanitizer_common/sanitizer_platform_limits_posix.cc b/lib/sanitizer_common/sanitizer_platform_limits_posix.cc +index feb7bad6f..4e89ab2a6 100644 +--- a/lib/sanitizer_common/sanitizer_platform_limits_posix.cc ++++ b/lib/sanitizer_common/sanitizer_platform_limits_posix.cc +@@ -14,6 +14,9 @@ + + #include "sanitizer_platform.h" + ++// Workaround musl <--> linux conflicting definition of 'struct sysinfo' ++#define _LINUX_SYSINFO_H ++ + #if SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_MAC + // Tests in this file assume that off_t-dependent data structures match the + // libc ABI. For example, struct dirent here is what readdir() function (as +@@ -138,12 +141,14 @@ typedef struct user_fpregs elf_fpregset_t; + + #if SANITIZER_LINUX && !SANITIZER_ANDROID + #include <glob.h> +-#include <obstack.h> ++# if !SANITIZER_NONGNU ++# include <obstack.h> ++# endif + #include <mqueue.h> +-#include <net/if_ppp.h> +-#include <netax25/ax25.h> +-#include <netipx/ipx.h> +-#include <netrom/netrom.h> ++#include <linux/if_ppp.h> ++#include <linux/ax25.h> ++#include <linux/ipx.h> ++#include <linux/netrom.h> + #if HAVE_RPC_XDR_H + # include <rpc/xdr.h> + #elif HAVE_TIRPC_RPC_XDR_H +@@ -251,7 +256,7 @@ namespace __sanitizer { + unsigned struct_itimerspec_sz = sizeof(struct itimerspec); + #endif // SANITIZER_LINUX || SANITIZER_FREEBSD + +-#if SANITIZER_LINUX && !SANITIZER_ANDROID ++#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU + // Use pre-computed size of struct ustat to avoid <sys/ustat.h> which + // has been removed from glibc 2.28. + #if defined(__aarch64__) || defined(__s390x__) || defined (__mips64) \ +@@ -322,7 +327,7 @@ unsigned struct_ElfW_Phdr_sz = sizeof(ElfW(Phdr)); + unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr); + #endif + +-#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID ++#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID && !SANITIZER_NONGNU + int glob_nomatch = GLOB_NOMATCH; + int glob_altdirfunc = GLOB_ALTDIRFUNC; + #endif +@@ -416,7 +421,7 @@ unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr); + unsigned struct_termios_sz = sizeof(struct termios); + unsigned struct_winsize_sz = sizeof(struct winsize); + +-#if SANITIZER_LINUX ++#if SANITIZER_LINUX && !SANITIZER_NONGNU + unsigned struct_arpreq_sz = sizeof(struct arpreq); + unsigned struct_cdrom_msf_sz = sizeof(struct cdrom_msf); + unsigned struct_cdrom_multisession_sz = sizeof(struct cdrom_multisession); +@@ -466,7 +471,7 @@ unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr); + unsigned struct_vt_mode_sz = sizeof(struct vt_mode); + #endif // SANITIZER_LINUX || SANITIZER_FREEBSD + +-#if SANITIZER_LINUX && !SANITIZER_ANDROID ++#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU + unsigned struct_ax25_parms_struct_sz = sizeof(struct ax25_parms_struct); + unsigned struct_cyclades_monitor_sz = sizeof(struct cyclades_monitor); + #if EV_VERSION > (0x010000) +@@ -834,7 +839,7 @@ unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr); + unsigned IOCTL_VT_WAITACTIVE = VT_WAITACTIVE; + #endif // SANITIZER_LINUX || SANITIZER_FREEBSD + +-#if SANITIZER_LINUX && !SANITIZER_ANDROID ++#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU + unsigned IOCTL_CYGETDEFTHRESH = CYGETDEFTHRESH; + unsigned IOCTL_CYGETDEFTIMEOUT = CYGETDEFTIMEOUT; + unsigned IOCTL_CYGETMON = CYGETMON; +@@ -989,7 +994,7 @@ CHECK_SIZE_AND_OFFSET(dl_phdr_info, dlpi_phdr); + CHECK_SIZE_AND_OFFSET(dl_phdr_info, dlpi_phnum); + #endif // SANITIZER_LINUX || SANITIZER_FREEBSD + +-#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID ++#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID && !SANITIZER_NONGNU + CHECK_TYPE_SIZE(glob_t); + CHECK_SIZE_AND_OFFSET(glob_t, gl_pathc); + CHECK_SIZE_AND_OFFSET(glob_t, gl_pathv); +@@ -1023,6 +1028,7 @@ CHECK_TYPE_SIZE(iovec); + CHECK_SIZE_AND_OFFSET(iovec, iov_base); + CHECK_SIZE_AND_OFFSET(iovec, iov_len); + ++#if !SANITIZER_NONGNU + CHECK_TYPE_SIZE(msghdr); + CHECK_SIZE_AND_OFFSET(msghdr, msg_name); + CHECK_SIZE_AND_OFFSET(msghdr, msg_namelen); +@@ -1036,6 +1042,7 @@ CHECK_TYPE_SIZE(cmsghdr); + CHECK_SIZE_AND_OFFSET(cmsghdr, cmsg_len); + CHECK_SIZE_AND_OFFSET(cmsghdr, cmsg_level); + CHECK_SIZE_AND_OFFSET(cmsghdr, cmsg_type); ++#endif + + COMPILER_CHECK(sizeof(__sanitizer_dirent) <= sizeof(dirent)); + CHECK_SIZE_AND_OFFSET(dirent, d_ino); +@@ -1138,7 +1145,7 @@ CHECK_SIZE_AND_OFFSET(mntent, mnt_passno); + + CHECK_TYPE_SIZE(ether_addr); + +-#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID ++#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID && !SANITIZER_NONGNU + CHECK_TYPE_SIZE(ipc_perm); + # if SANITIZER_FREEBSD + CHECK_SIZE_AND_OFFSET(ipc_perm, key); +@@ -1199,7 +1206,7 @@ CHECK_SIZE_AND_OFFSET(ifaddrs, ifa_dstaddr); + CHECK_SIZE_AND_OFFSET(ifaddrs, ifa_data); + #endif + +-#if SANITIZER_LINUX ++#if SANITIZER_LINUX && !SANITIZER_NONGNU + COMPILER_CHECK(sizeof(__sanitizer_mallinfo) == sizeof(struct mallinfo)); + #endif + +@@ -1249,7 +1256,7 @@ COMPILER_CHECK(__sanitizer_XDR_DECODE == XDR_DECODE); + COMPILER_CHECK(__sanitizer_XDR_FREE == XDR_FREE); + #endif + +-#if SANITIZER_LINUX && !SANITIZER_ANDROID ++#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU + COMPILER_CHECK(sizeof(__sanitizer_FILE) <= sizeof(FILE)); + CHECK_SIZE_AND_OFFSET(FILE, _flags); + CHECK_SIZE_AND_OFFSET(FILE, _IO_read_ptr); +@@ -1268,7 +1275,7 @@ CHECK_SIZE_AND_OFFSET(FILE, _chain); + CHECK_SIZE_AND_OFFSET(FILE, _fileno); + #endif + +-#if SANITIZER_LINUX && !SANITIZER_ANDROID ++#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU + COMPILER_CHECK(sizeof(__sanitizer__obstack_chunk) <= sizeof(_obstack_chunk)); + CHECK_SIZE_AND_OFFSET(_obstack_chunk, limit); + CHECK_SIZE_AND_OFFSET(_obstack_chunk, prev); +diff --git a/lib/tsan/rtl/tsan_platform_linux.cc b/lib/tsan/rtl/tsan_platform_linux.cc +index e14d5f575..389a3bc88 100644 +--- a/lib/tsan/rtl/tsan_platform_linux.cc ++++ b/lib/tsan/rtl/tsan_platform_linux.cc +@@ -285,7 +285,7 @@ void InitializePlatform() { + // This is required to properly "close" the fds, because we do not see internal + // closes within glibc. The code is a pure hack. + int ExtractResolvFDs(void *state, int *fds, int nfd) { +-#if SANITIZER_LINUX && !SANITIZER_ANDROID ++#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU + int cnt = 0; + struct __res_state *statp = (struct __res_state*)state; + for (int i = 0; i < MAXNS && cnt < nfd; i++) { +-- +2.18.0 + diff --git a/nixpkgs/pkgs/development/compilers/llvm/7/bintools.nix b/nixpkgs/pkgs/development/compilers/llvm/7/bintools.nix new file mode 100644 index 000000000000..72a2a7331930 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/7/bintools.nix @@ -0,0 +1,19 @@ +{ runCommand, stdenv, llvm, lld, version }: + +let + prefix = + if stdenv.hostPlatform != stdenv.targetPlatform + then "${stdenv.targetPlatform.config}-" + else ""; +in runCommand "llvm-binutils-${version}" { preferLocalBuild = true; } '' + mkdir -p $out/bin + for prog in ${lld}/bin/*; do + ln -s $prog $out/bin/${prefix}$(basename $prog) + done + for prog in ${llvm}/bin/*; do + ln -s $prog $out/bin/${prefix}$(echo $(basename $prog) | sed -e "s|llvm-||") + ln -sf $prog $out/bin/${prefix}$(basename $prog) + done + rm -f $out/bin/${prefix}cat + ln -s ${lld}/bin/lld $out/bin/${prefix}ld +'' diff --git a/nixpkgs/pkgs/development/compilers/llvm/7/clang/default.nix b/nixpkgs/pkgs/development/compilers/llvm/7/clang/default.nix new file mode 100644 index 000000000000..e4252647ce6d --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/7/clang/default.nix @@ -0,0 +1,112 @@ +{ stdenv, fetch, cmake, libxml2, llvm, version, clang-tools-extra_src, python +, fixDarwinDylibNames +, enableManpages ? false +, enablePolly ? false # TODO: get this info from llvm (passthru?) +}: + +let + self = stdenv.mkDerivation ({ + name = "clang-${version}"; + + unpackPhase = '' + unpackFile ${fetch "cfe" "067lwggnbg0w1dfrps790r5l6k8n5zwhlsw7zb6zvmfpwpfn4nx4"} + mv cfe-${version}* clang + sourceRoot=$PWD/clang + unpackFile ${clang-tools-extra_src} + mv clang-tools-extra-* $sourceRoot/tools/extra + ''; + + nativeBuildInputs = [ cmake python ] + ++ stdenv.lib.optional enableManpages python.pkgs.sphinx; + + buildInputs = [ libxml2 llvm ] + ++ stdenv.lib.optional stdenv.isDarwin fixDarwinDylibNames; + + cmakeFlags = [ + "-DCMAKE_CXX_FLAGS=-std=c++11" + ] ++ stdenv.lib.optionals enableManpages [ + "-DCLANG_INCLUDE_DOCS=ON" + "-DLLVM_ENABLE_SPHINX=ON" + "-DSPHINX_OUTPUT_MAN=ON" + "-DSPHINX_OUTPUT_HTML=OFF" + "-DSPHINX_WARNINGS_AS_ERRORS=OFF" + ] ++ stdenv.lib.optionals enablePolly [ + "-DWITH_POLLY=ON" + "-DLINK_POLLY_INTO_TOOLS=ON" + ]; + + patches = [ ./purity.patch ]; + + postPatch = '' + sed -i -e 's/DriverArgs.hasArg(options::OPT_nostdlibinc)/true/' \ + -e 's/Args.hasArg(options::OPT_nostdlibinc)/true/' \ + lib/Driver/ToolChains/*.cpp + + # Patch for standalone doc building + sed -i '1s,^,find_package(Sphinx REQUIRED)\n,' docs/CMakeLists.txt + '' + stdenv.lib.optionalString stdenv.hostPlatform.isMusl '' + sed -i -e 's/lgcc_s/lgcc_eh/' lib/Driver/ToolChains/*.cpp + '' + stdenv.lib.optionalString stdenv.hostPlatform.isDarwin '' + substituteInPlace tools/extra/clangd/CMakeLists.txt \ + --replace "NOT HAVE_CXX_ATOMICS64_WITHOUT_LIB" FALSE + ''; + + outputs = [ "out" "lib" "python" ]; + + # Clang expects to find LLVMgold in its own prefix + postInstall = '' + if [ -e ${llvm}/lib/LLVMgold.so ]; then + ln -sv ${llvm}/lib/LLVMgold.so $out/lib + fi + + ln -sv $out/bin/clang $out/bin/cpp + + # Move libclang to 'lib' output + moveToOutput "lib/libclang.*" "$lib" + substituteInPlace $out/lib/cmake/clang/ClangTargets-release.cmake \ + --replace "\''${_IMPORT_PREFIX}/lib/libclang." "$lib/lib/libclang." + + mkdir -p $python/bin $python/share/clang/ + mv $out/bin/{git-clang-format,scan-view} $python/bin + if [ -e $out/bin/set-xcode-analyzer ]; then + mv $out/bin/set-xcode-analyzer $python/bin + fi + mv $out/share/clang/*.py $python/share/clang + rm $out/bin/c-index-test + ''; + + enableParallelBuilding = true; + + passthru = { + isClang = true; + inherit llvm; + } // stdenv.lib.optionalAttrs (stdenv.targetPlatform.isLinux || (stdenv.cc.isGNU && stdenv.cc.cc ? gcc)) { + gcc = if stdenv.cc.isGNU then stdenv.cc.cc else stdenv.cc.cc.gcc; + }; + + meta = { + description = "A c, c++, objective-c, and objective-c++ frontend for the llvm compiler"; + homepage = http://llvm.org/; + license = stdenv.lib.licenses.ncsa; + platforms = stdenv.lib.platforms.all; + }; + } // stdenv.lib.optionalAttrs enableManpages { + name = "clang-manpages-${version}"; + + buildPhase = '' + make docs-clang-man + ''; + + installPhase = '' + mkdir -p $out/share/man/man1 + # Manually install clang manpage + cp docs/man/*.1 $out/share/man/man1/ + ''; + + outputs = [ "out" ]; + + doCheck = false; + + meta.description = "man page for Clang ${version}"; + }); +in self diff --git a/nixpkgs/pkgs/development/compilers/llvm/7/clang/purity.patch b/nixpkgs/pkgs/development/compilers/llvm/7/clang/purity.patch new file mode 100644 index 000000000000..b30d0d0b5d5b --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/7/clang/purity.patch @@ -0,0 +1,30 @@ +From 4add81bba40dcec62c4ea4481be8e35ac53e89d8 Mon Sep 17 00:00:00 2001 +From: Will Dietz <w@wdtz.org> +Date: Thu, 18 May 2017 11:56:12 -0500 +Subject: [PATCH] "purity" patch for 5.0 + +--- + lib/Driver/ToolChains/Gnu.cpp | 7 ------- + 1 file changed, 7 deletions(-) + +diff --git a/lib/Driver/ToolChains/Gnu.cpp b/lib/Driver/ToolChains/Gnu.cpp +index fe3c0191bb..c6a482bece 100644 +--- a/lib/Driver/ToolChains/Gnu.cpp ++++ b/lib/Driver/ToolChains/Gnu.cpp +@@ -494,13 +494,6 @@ void tools::gnutools::Linker::ConstructJob(Compilation &C, const JobAction &JA, + if (!Args.hasArg(options::OPT_static)) { + if (Args.hasArg(options::OPT_rdynamic)) + CmdArgs.push_back("-export-dynamic"); +- +- if (!Args.hasArg(options::OPT_shared)) { +- const std::string Loader = +- D.DyldPrefix + ToolChain.getDynamicLinker(Args); +- CmdArgs.push_back("-dynamic-linker"); +- CmdArgs.push_back(Args.MakeArgString(Loader)); +- } + } + + CmdArgs.push_back("-o"); +-- +2.11.0 + diff --git a/nixpkgs/pkgs/development/compilers/llvm/7/compiler-rt-clock_gettime.patch b/nixpkgs/pkgs/development/compilers/llvm/7/compiler-rt-clock_gettime.patch new file mode 100644 index 000000000000..f9323ed95c05 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/7/compiler-rt-clock_gettime.patch @@ -0,0 +1,74 @@ +commit f00c7bccf7955b7dfbb4859fd9019e9eb3349f2d +Author: Tobias Mayer <tobim@fastmail.fm> +Date: Wed Feb 13 12:44:17 2019 +0100 + + Provide clock_gettime for xray on macos < 10.12 + +diff --git a/lib/xray/xray_basic_logging.cc b/lib/xray/xray_basic_logging.cc +index a46c151af..38aea6932 100644 +--- a/lib/xray/xray_basic_logging.cc ++++ b/lib/xray/xray_basic_logging.cc +@@ -36,6 +36,29 @@ + #include "xray_tsc.h" + #include "xray_utils.h" + ++#if __MACH__ ++#include <mach/clock.h> ++#include <mach/mach.h> ++enum clockid_t { ++ CLOCK_MONOTONIC = REALTIME_CLOCK, ++ CLOCK_REALTIME = REALTIME_CLOCK ++}; ++ ++int clock_gettime(clockid_t clock_id, struct timespec *ts) { ++ if (ts != NULL) { ++ clock_serv_t cclock; ++ mach_timespec_t mts; ++ host_get_clock_service(mach_host_self(), clock_id, &cclock); ++ clock_get_time(cclock, &mts); ++ mach_port_deallocate(mach_task_self(), cclock); ++ ts->tv_sec = mts.tv_sec; ++ ts->tv_nsec = mts.tv_nsec; ++ return 0; ++ } ++ return -1; ++} ++#endif ++ + namespace __xray { + + SpinMutex LogMutex; +diff --git a/lib/xray/xray_fdr_logging.cc b/lib/xray/xray_fdr_logging.cc +index 4b308b27f..1d044c8fd 100644 +--- a/lib/xray/xray_fdr_logging.cc ++++ b/lib/xray/xray_fdr_logging.cc +@@ -38,6 +38,29 @@ + #include "xray_tsc.h" + #include "xray_utils.h" + ++#if __MACH__ ++#include <mach/clock.h> ++#include <mach/mach.h> ++enum clockid_t { ++ CLOCK_MONOTONIC = REALTIME_CLOCK, ++ CLOCK_REALTIME = REALTIME_CLOCK ++}; ++ ++int clock_gettime(clockid_t clock_id, struct timespec *ts) { ++ if (ts != NULL) { ++ clock_serv_t cclock; ++ mach_timespec_t mts; ++ host_get_clock_service(mach_host_self(), clock_id, &cclock); ++ clock_get_time(cclock, &mts); ++ mach_port_deallocate(mach_task_self(), cclock); ++ ts->tv_sec = mts.tv_sec; ++ ts->tv_nsec = mts.tv_nsec; ++ return 0; ++ } ++ return -1; ++} ++#endif ++ + namespace __xray { + + atomic_sint32_t LoggingStatus = {XRayLogInitStatus::XRAY_LOG_UNINITIALIZED}; diff --git a/nixpkgs/pkgs/development/compilers/llvm/7/compiler-rt-codesign.patch b/nixpkgs/pkgs/development/compilers/llvm/7/compiler-rt-codesign.patch new file mode 100644 index 000000000000..3cc12b94b200 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/7/compiler-rt-codesign.patch @@ -0,0 +1,33 @@ +From 3dec5f3475a26aeb4678627795c4b67c6b7b4785 Mon Sep 17 00:00:00 2001 +From: Will Dietz <w@wdtz.org> +Date: Tue, 19 Sep 2017 13:13:06 -0500 +Subject: [PATCH] remove codesign use on Apple, disable ios sim testing that + needs it + +--- + cmake/Modules/AddCompilerRT.cmake | 8 ------ + test/asan/CMakeLists.txt | 52 --------------------------------------- + test/tsan/CMakeLists.txt | 47 ----------------------------------- + 3 files changed, 107 deletions(-) + +diff --git a/cmake/Modules/AddCompilerRT.cmake b/cmake/Modules/AddCompilerRT.cmake +index bc5fb9ff7..b64eb4246 100644 +--- a/cmake/Modules/AddCompilerRT.cmake ++++ b/cmake/Modules/AddCompilerRT.cmake +@@ -210,14 +210,6 @@ function(add_compiler_rt_runtime name type) + set_target_properties(${libname} PROPERTIES IMPORT_PREFIX "") + set_target_properties(${libname} PROPERTIES IMPORT_SUFFIX ".lib") + endif() +- if(APPLE) +- # Ad-hoc sign the dylibs +- add_custom_command(TARGET ${libname} +- POST_BUILD +- COMMAND codesign --sign - $<TARGET_FILE:${libname}> +- WORKING_DIRECTORY ${COMPILER_RT_LIBRARY_OUTPUT_DIR} +- ) +- endif() + endif() + install(TARGETS ${libname} + ARCHIVE DESTINATION ${COMPILER_RT_LIBRARY_INSTALL_DIR} +2.14.1 + diff --git a/nixpkgs/pkgs/development/compilers/llvm/7/compiler-rt.nix b/nixpkgs/pkgs/development/compilers/llvm/7/compiler-rt.nix new file mode 100644 index 000000000000..7a6c91fb832b --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/7/compiler-rt.nix @@ -0,0 +1,61 @@ +{ stdenv, version, fetch, cmake, python, llvm, libcxxabi }: +stdenv.mkDerivation rec { + name = "compiler-rt-${version}"; + inherit version; + src = fetch "compiler-rt" "065ybd8fsc4h2hikbdyricj6pyv4r7r7kpcikhb2y5zf370xybkq"; + + nativeBuildInputs = [ cmake python llvm ]; + buildInputs = stdenv.lib.optional stdenv.hostPlatform.isDarwin libcxxabi; + + cmakeFlags = [ + "-DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON" + "-DCMAKE_C_COMPILER_TARGET=${stdenv.hostPlatform.config}" + "-DCMAKE_ASM_COMPILER_TARGET=${stdenv.hostPlatform.config}" + ] ++ stdenv.lib.optional (stdenv.hostPlatform != stdenv.buildPlatform) [ + "-DCMAKE_C_FLAGS=-nodefaultlibs" + "-DCMAKE_CXX_COMPILER_WORKS=ON" + "-DCOMPILER_RT_BUILD_BUILTINS=ON" + "-DCOMPILER_RT_BUILD_SANITIZERS=OFF" + "-DCOMPILER_RT_BUILD_XRAY=OFF" + "-DCOMPILER_RT_BUILD_LIBFUZZER=OFF" + "-DCOMPILER_RT_BUILD_PROFILE=OFF" + "-DCOMPILER_RT_BAREMETAL_BUILD=ON" + ]; + + outputs = [ "out" "dev" ]; + + patches = [ + ./compiler-rt-codesign.patch # Revert compiler-rt commit that makes codesign mandatory + ] ++ stdenv.lib.optional stdenv.hostPlatform.isMusl ./sanitizers-nongnu.patch + ++ stdenv.lib.optional (stdenv.hostPlatform != stdenv.buildPlatform) ./crtbegin-and-end.patch + ++ stdenv.lib.optional stdenv.hostPlatform.isDarwin ./compiler-rt-clock_gettime.patch; + + # TSAN requires XPC on Darwin, which we have no public/free source files for. We can depend on the Apple frameworks + # to get it, but they're unfree. Since LLVM is rather central to the stdenv, we patch out TSAN support so that Hydra + # can build this. If we didn't do it, basically the entire nixpkgs on Darwin would have an unfree dependency and we'd + # get no binary cache for the entire platform. If you really find yourself wanting the TSAN, make this controllable by + # a flag and turn the flag off during the stdenv build. + postPatch = stdenv.lib.optionalString stdenv.isDarwin '' + substituteInPlace cmake/config-ix.cmake \ + --replace 'set(COMPILER_RT_HAS_TSAN TRUE)' 'set(COMPILER_RT_HAS_TSAN FALSE)' + '' + stdenv.lib.optionalString (stdenv.hostPlatform != stdenv.buildPlatform) '' + substituteInPlace lib/builtins/int_util.c \ + --replace "#include <stdlib.h>" "" + substituteInPlace lib/builtins/clear_cache.c \ + --replace "#include <assert.h>" "" + substituteInPlace lib/builtins/cpu_model.c \ + --replace "#include <assert.h>" "" + ''; + + # Hack around weird upsream RPATH bug + postInstall = stdenv.lib.optionalString stdenv.isDarwin '' + ln -s "$out/lib"/*/* "$out/lib" + '' + stdenv.lib.optionalString (stdenv.hostPlatform != stdenv.buildPlatform) '' + ln -s $out/lib/*/clang_rt.crtbegin-*.o $out/lib/linux/crtbegin.o + ln -s $out/lib/*/clang_rt.crtend-*.o $out/lib/linux/crtend.o + ln -s $out/lib/*/clang_rt.crtbegin_shared-*.o $out/lib/linux/crtbeginS.o + ln -s $out/lib/*/clang_rt.crtend_shared-*.o $out/lib/linux/crtendS.o + ''; + + enableParallelBuilding = true; +} diff --git a/nixpkgs/pkgs/development/compilers/llvm/7/crtbegin-and-end.patch b/nixpkgs/pkgs/development/compilers/llvm/7/crtbegin-and-end.patch new file mode 100644 index 000000000000..e63be181f95c --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/7/crtbegin-and-end.patch @@ -0,0 +1,595 @@ +Get crtbegin and crtend without compiler GCC! PR is at https://reviews.llvm.org/D28791 + +Index: compiler-rt/CMakeLists.txt +=================================================================== +--- compiler-rt/CMakeLists.txt ++++ compiler-rt/CMakeLists.txt +@@ -29,6 +29,8 @@ + + option(COMPILER_RT_BUILD_BUILTINS "Build builtins" ON) + mark_as_advanced(COMPILER_RT_BUILD_BUILTINS) ++option(COMPILER_RT_BUILD_CRT "Build crtbegin.o/crtend.o" ON) ++mark_as_advanced(COMPILER_RT_BUILD_CRT) + option(COMPILER_RT_BUILD_SANITIZERS "Build sanitizers" ON) + mark_as_advanced(COMPILER_RT_BUILD_SANITIZERS) + option(COMPILER_RT_BUILD_XRAY "Build xray" ON) +Index: compiler-rt/cmake/Modules/AddCompilerRT.cmake +=================================================================== +--- compiler-rt/cmake/Modules/AddCompilerRT.cmake ++++ compiler-rt/cmake/Modules/AddCompilerRT.cmake +@@ -132,7 +132,7 @@ + # Adds static or shared runtime for a list of architectures and operating + # systems and puts it in the proper directory in the build and install trees. + # add_compiler_rt_runtime(<name> +-# {STATIC|SHARED} ++# {OBJECT|STATIC|SHARED} + # ARCHS <architectures> + # OS <os list> + # SOURCES <source files> +@@ -144,8 +144,8 @@ + # PARENT_TARGET <convenience parent target> + # ADDITIONAL_HEADERS <header files>) + function(add_compiler_rt_runtime name type) +- if(NOT type MATCHES "^(STATIC|SHARED)$") +- message(FATAL_ERROR "type argument must be STATIC or SHARED") ++ if(NOT type MATCHES "^(OBJECT|STATIC|SHARED)$") ++ message(FATAL_ERROR "type argument must be OBJECT, STATIC or SHARED") + return() + endif() + cmake_parse_arguments(LIB +@@ -204,7 +204,10 @@ + message(FATAL_ERROR "Architecture ${arch} can't be targeted") + return() + endif() +- if(type STREQUAL "STATIC") ++ if(type STREQUAL "OBJECT") ++ set(libname "${name}-${arch}") ++ set(output_name_${libname} ${libname}${COMPILER_RT_OS_SUFFIX}) ++ elseif(type STREQUAL "STATIC") + set(libname "${name}-${arch}") + set_output_name(output_name_${libname} ${name} ${arch}) + else() +@@ -270,12 +273,34 @@ + set(COMPONENT_OPTION COMPONENT ${libname}) + endif() + +- add_library(${libname} ${type} ${sources_${libname}}) +- set_target_compile_flags(${libname} ${extra_cflags_${libname}}) +- set_target_link_flags(${libname} ${extra_link_flags_${libname}}) +- set_property(TARGET ${libname} APPEND PROPERTY +- COMPILE_DEFINITIONS ${LIB_DEFS}) +- set_target_output_directories(${libname} ${output_dir_${libname}}) ++ if(type STREQUAL "OBJECT") ++ string(TOUPPER ${CMAKE_BUILD_TYPE} config) ++ get_property(cflags SOURCE ${sources_${libname}} PROPERTY COMPILE_FLAGS) ++ separate_arguments(cflags) ++ add_custom_command( ++ OUTPUT ${output_dir_${libname}}/${libname}.o ++ COMMAND ${CMAKE_C_COMPILER} ${sources_${libname}} ${cflags} ${extra_cflags_${libname}} -c -o ${output_dir_${libname}}/${libname}.o ++ DEPENDS ${sources_${libname}} ++ COMMENT "Building C object ${libname}.o") ++ add_custom_target(${libname} DEPENDS ${output_dir_${libname}}/${libname}.o) ++ install(FILES ${output_dir_${libname}}/${libname}.o ++ DESTINATION ${install_dir_${libname}} ++ ${COMPONENT_OPTION}) ++ else() ++ add_library(${libname} ${type} ${sources_${libname}}) ++ set_target_compile_flags(${libname} ${extra_cflags_${libname}}) ++ set_target_link_flags(${libname} ${extra_link_flags_${libname}}) ++ set_property(TARGET ${libname} APPEND PROPERTY ++ COMPILE_DEFINITIONS ${LIB_DEFS}) ++ set_target_output_directories(${libname} ${output_dir_${libname}}) ++ install(TARGETS ${libname} ++ ARCHIVE DESTINATION ${install_dir_${libname}} ++ ${COMPONENT_OPTION} ++ LIBRARY DESTINATION ${install_dir_${libname}} ++ ${COMPONENT_OPTION} ++ RUNTIME DESTINATION ${install_dir_${libname}} ++ ${COMPONENT_OPTION}) ++ endif() + set_target_properties(${libname} PROPERTIES + OUTPUT_NAME ${output_name_${libname}}) + set_target_properties(${libname} PROPERTIES FOLDER "Compiler-RT Runtime") +@@ -299,13 +324,6 @@ + ) + endif() + endif() +- install(TARGETS ${libname} +- ARCHIVE DESTINATION ${install_dir_${libname}} +- ${COMPONENT_OPTION} +- LIBRARY DESTINATION ${install_dir_${libname}} +- ${COMPONENT_OPTION} +- RUNTIME DESTINATION ${install_dir_${libname}} +- ${COMPONENT_OPTION}) + + # We only want to generate per-library install targets if you aren't using + # an IDE because the extra targets get cluttered in IDEs. +Index: compiler-rt/cmake/config-ix.cmake +=================================================================== +--- compiler-rt/cmake/config-ix.cmake ++++ compiler-rt/cmake/config-ix.cmake +@@ -227,6 +227,7 @@ + ${ARM32} ${ARM64} ${MIPS32} ${MIPS64} ${S390X}) + set(ALL_ASAN_SUPPORTED_ARCH ${X86} ${X86_64} ${ARM32} ${ARM64} + ${MIPS32} ${MIPS64} ${PPC64} ${S390X}) ++set(ALL_CRT_SUPPORTED_ARCH ${X86} ${X86_64} ${ARM32} ${ARM64}) + set(ALL_DFSAN_SUPPORTED_ARCH ${X86_64} ${MIPS64} ${ARM64}) + set(ALL_FUZZER_SUPPORTED_ARCH ${X86_64} ${ARM64}) + +@@ -474,6 +475,7 @@ + SANITIZER_COMMON_SUPPORTED_ARCH) + + else() ++ filter_available_targets(CRT_SUPPORTED_ARCH ${ALL_CRT_SUPPORTED_ARCH}) + # Architectures supported by compiler-rt libraries. + filter_available_targets(SANITIZER_COMMON_SUPPORTED_ARCH + ${ALL_SANITIZER_COMMON_SUPPORTED_ARCH}) +@@ -563,6 +565,12 @@ + + # TODO: Add builtins support. + ++if (CRT_SUPPORTED_ARCH AND OS_NAME MATCHES "Linux") ++ set(COMPILER_RT_HAS_CRT TRUE) ++else() ++ set(COMPILER_RT_HAS_CRT FALSE) ++endif() ++ + if (COMPILER_RT_HAS_SANITIZER_COMMON AND DFSAN_SUPPORTED_ARCH AND + OS_NAME MATCHES "Linux") + set(COMPILER_RT_HAS_DFSAN TRUE) +Index: compiler-rt/lib/CMakeLists.txt +=================================================================== +--- compiler-rt/lib/CMakeLists.txt ++++ compiler-rt/lib/CMakeLists.txt +@@ -17,6 +17,10 @@ + add_subdirectory(builtins) + endif() + ++if(COMPILER_RT_BUILD_CRT) ++ add_subdirectory(crt) ++endif() ++ + function(compiler_rt_build_runtime runtime) + string(TOUPPER ${runtime} runtime_uppercase) + if(COMPILER_RT_HAS_${runtime_uppercase}) +Index: compiler-rt/lib/crt/CMakeLists.txt +=================================================================== +--- /dev/null ++++ compiler-rt/lib/crt/CMakeLists.txt +@@ -0,0 +1,102 @@ ++add_compiler_rt_component(crt) ++ ++function(check_cxx_section_exists section output) ++ cmake_parse_arguments(ARG "" "" "SOURCE;FLAGS" ${ARGN}) ++ if(NOT ARG_SOURCE) ++ set(ARG_SOURCE "int main() { return 0; }\n") ++ endif() ++ ++ string(RANDOM TARGET_NAME) ++ set(TARGET_NAME "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/cmTC_${TARGET_NAME}.dir") ++ file(MAKE_DIRECTORY ${TARGET_NAME}) ++ ++ file(WRITE "${TARGET_NAME}/CheckSectionExists.c" "${ARG_SOURCE}\n") ++ ++ string(REGEX MATCHALL "<[A-Za-z0-9_]*>" substitutions ++ ${CMAKE_C_COMPILE_OBJECT}) ++ ++ set(try_compile_flags "${ARG_FLAGS}") ++ if(CMAKE_C_COMPILER_ID MATCHES Clang AND CMAKE_C_COMPILER_TARGET) ++ list(APPEND try_compile_flags "-target ${CMAKE_C_COMPILER_TARGET}") ++ endif() ++ ++ string(REPLACE ";" " " extra_flags "${try_compile_flags}") ++ ++ set(test_compile_command "${CMAKE_C_COMPILE_OBJECT}") ++ foreach(substitution ${substitutions}) ++ if(substitution STREQUAL "<CMAKE_C_COMPILER>") ++ string(REPLACE "<CMAKE_C_COMPILER>" ++ "${CMAKE_C_COMPILER}" test_compile_command ${test_compile_command}) ++ elseif(substitution STREQUAL "<OBJECT>") ++ string(REPLACE "<OBJECT>" "${TARGET_NAME}/CheckSectionExists.o" ++ test_compile_command ${test_compile_command}) ++ elseif(substitution STREQUAL "<SOURCE>") ++ string(REPLACE "<SOURCE>" "${TARGET_NAME}/CheckSectionExists.c" ++ test_compile_command ${test_compile_command}) ++ elseif(substitution STREQUAL "<FLAGS>") ++ string(REPLACE "<FLAGS>" "${CMAKE_C_FLAGS} ${extra_flags}" ++ test_compile_command ${test_compile_command}) ++ else() ++ string(REPLACE "${substitution}" "" test_compile_command ++ ${test_compile_command}) ++ endif() ++ endforeach() ++ ++ string(REPLACE " " ";" test_compile_command "${test_compile_command}") ++ ++ execute_process( ++ COMMAND ${test_compile_command} ++ RESULT_VARIABLE TEST_RESULT ++ OUTPUT_VARIABLE TEST_OUTPUT ++ ERROR_VARIABLE TEST_ERROR ++ ) ++ ++ execute_process( ++ COMMAND ${CMAKE_OBJDUMP} -h "${TARGET_NAME}/CheckSectionExists.o" ++ RESULT_VARIABLE CHECK_RESULT ++ OUTPUT_VARIABLE CHECK_OUTPUT ++ ERROR_VARIABLE CHECK_ERROR ++ ) ++ string(FIND "${CHECK_OUTPUT}" "${section}" SECTION_FOUND) ++ ++ if(NOT SECTION_FOUND EQUAL -1) ++ set(${output} TRUE PARENT_SCOPE) ++ else() ++ set(${output} FALSE PARENT_SCOPE) ++ endif() ++ ++ file(REMOVE_RECURSE ${TARGET_NAME}) ++endfunction() ++ ++check_cxx_section_exists(".init_array" COMPILER_RT_HAS_INITFINI_ARRAY ++ SOURCE "__attribute__((constructor)) void f() {}\nint main() { return 0; }\n") ++ ++append_list_if(COMPILER_RT_HAS_INITFINI_ARRAY -DCRT_HAS_INITFINI_ARRAY CRT_CFLAGS) ++append_list_if(COMPILER_RT_HAS_FPIC_FLAG -fPIC CRT_CFLAGS) ++ ++foreach(arch ${CRT_SUPPORTED_ARCH}) ++ add_compiler_rt_runtime(clang_rt.crtbegin ++ OBJECT ++ ARCHS ${arch} ++ SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/crtbegin.c ++ CFLAGS ${CRT_CFLAGS} ++ PARENT_TARGET crt) ++ add_compiler_rt_runtime(clang_rt.crtbegin_shared ++ OBJECT ++ ARCHS ${arch} ++ SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/crtbegin.c ++ CFLAGS ${CRT_CFLAGS} -DCRT_SHARED ++ PARENT_TARGET crt) ++ add_compiler_rt_runtime(clang_rt.crtend ++ OBJECT ++ ARCHS ${arch} ++ SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/crtend.c ++ CFLAGS ${CRT_CFLAGS} ++ PARENT_TARGET crt) ++ add_compiler_rt_runtime(clang_rt.crtend_shared ++ OBJECT ++ ARCHS ${arch} ++ SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/crtend.c ++ CFLAGS ${CRT_CFLAGS} -DCRT_SHARED ++ PARENT_TARGET crt) ++endforeach() +Index: compiler-rt/lib/crt/crtbegin.c +=================================================================== +--- /dev/null ++++ compiler-rt/lib/crt/crtbegin.c +@@ -0,0 +1,108 @@ ++/* ===-- crtbegin.c - Start of constructors and destructors ----------------=== ++ * ++ * The LLVM Compiler Infrastructure ++ * ++ * This file is dual licensed under the MIT and the University of Illinois Open ++ * Source Licenses. See LICENSE.TXT for details. ++ * ++ * ===----------------------------------------------------------------------=== ++ */ ++ ++#include <stddef.h> ++ ++__attribute__((visibility("hidden"))) ++#ifdef CRT_SHARED ++void *__dso_handle = &__dso_handle; ++#else ++void *__dso_handle = (void *)0; ++#endif ++ ++static long __EH_FRAME_LIST__[] ++ __attribute__((section(".eh_frame"), aligned(sizeof(void *)))) = {}; ++ ++extern void __register_frame_info(const void *, void *) __attribute__((weak)); ++extern void *__deregister_frame_info(const void *) __attribute__((weak)); ++ ++#ifndef CRT_HAS_INITFINI_ARRAY ++typedef void (*fp)(void); ++ ++static fp __CTOR_LIST__[] ++ __attribute__((section(".ctors"), aligned(sizeof(fp)), used)) = {(fp)-1}; ++extern fp __CTOR_LIST_END__[]; ++#endif ++ ++#ifdef CRT_SHARED ++extern void __cxa_finalize(void *) __attribute__((weak)); ++#endif ++ ++static void __attribute__((used)) __do_init() { ++ static _Bool __initialized; ++ if (__builtin_expect(__initialized, 0)) ++ return; ++ __initialized = 1; ++ ++ static struct { void *p[8]; } __object; ++ if (__register_frame_info) ++ __register_frame_info(__EH_FRAME_LIST__, &__object); ++ ++#ifndef CRT_HAS_INITFINI_ARRAY ++ const size_t n = __CTOR_LIST_END__ - __CTOR_LIST__ - 1; ++ for (size_t i = n; i >= 1; i--) __CTOR_LIST__[i](); ++#endif ++} ++ ++#ifdef CRT_HAS_INITFINI_ARRAY ++__attribute__((section(".init_array"), ++ used)) static void (*__init)(void) = __do_init; ++#else // CRT_HAS_INITFINI_ARRAY ++#if defined(__i386__) || defined(__x86_64__) ++asm(".pushsection .init,\"ax\",@progbits\n\t" ++ "call " __USER_LABEL_PREFIX__ "__do_init\n\t" ++ ".popsection"); ++#elif defined(__arm__) ++asm(".pushsection .init,\"ax\",%progbits\n\t" ++ "bl " __USER_LABEL_PREFIX__ "__do_init\n\t" ++ ".popsection"); ++#endif // CRT_HAS_INITFINI_ARRAY ++#endif ++ ++#ifndef CRT_HAS_INITFINI_ARRAY ++static fp __DTOR_LIST__[] ++ __attribute__((section(".dtors"), aligned(sizeof(fp)), used)) = {(fp)-1}; ++extern fp __DTOR_LIST_END__[]; ++#endif ++ ++static void __attribute__((used)) __do_fini() { ++ static _Bool __finalized; ++ if (__builtin_expect(__finalized, 0)) ++ return; ++ __finalized = 1; ++ ++#ifdef CRT_SHARED ++ if (__cxa_finalize) ++ __cxa_finalize(__dso_handle); ++#endif ++ ++#ifndef CRT_HAS_INITFINI_ARRAY ++ if (__deregister_frame_info) ++ __deregister_frame_info(__EH_FRAME_LIST__); ++ ++ const size_t n = __DTOR_LIST_END__ - __DTOR_LIST__ - 1; ++ for (size_t i = 1; i < n; i++) __DTOR_LIST__[i](); ++#endif ++} ++ ++#ifdef CRT_HAS_INITFINI_ARRAY ++__attribute__((section(".fini_array"), ++ used)) static void (*__fini)(void) = __do_fini; ++#else // CRT_HAS_INITFINI_ARRAY ++#if defined(__i386__) || defined(__x86_64__) ++asm(".pushsection .fini,\"ax\",@progbits\n\t" ++ "call " __USER_LABEL_PREFIX__ "__do_fini\n\t" ++ ".popsection"); ++#elif defined(__arm__) ++asm(".pushsection .fini,\"ax\",%progbits\n\t" ++ "bl " __USER_LABEL_PREFIX__ "__do_fini\n\t" ++ ".popsection"); ++#endif ++#endif // CRT_HAS_INIT_FINI_ARRAY +Index: compiler-rt/lib/crt/crtend.c +=================================================================== +--- /dev/null ++++ compiler-rt/lib/crt/crtend.c +@@ -0,0 +1,24 @@ ++/* ===-- crtend.c - End of constructors and destructors --------------------=== ++ * ++ * The LLVM Compiler Infrastructure ++ * ++ * This file is dual licensed under the MIT and the University of Illinois Open ++ * Source Licenses. See LICENSE.TXT for details. ++ * ++ * ===----------------------------------------------------------------------=== ++ */ ++ ++#include <stdint.h> ++ ++// Put 4-byte zero which is the length field in FDE at the end as a terminator. ++const int32_t __EH_FRAME_LIST_END__[] ++ __attribute__((section(".eh_frame"), aligned(sizeof(int32_t)), ++ visibility("hidden"), used)) = {0}; ++ ++#ifndef CRT_HAS_INITFINI_ARRAY ++typedef void (*fp)(void); ++fp __CTOR_LIST_END__[] ++ __attribute__((section(".ctors"), visibility("hidden"), used)) = {0}; ++fp __DTOR_LIST_END__[] ++ __attribute__((section(".dtors"), visibility("hidden"), used)) = {0}; ++#endif +Index: compiler-rt/test/CMakeLists.txt +=================================================================== +--- compiler-rt/test/CMakeLists.txt ++++ compiler-rt/test/CMakeLists.txt +@@ -73,6 +73,9 @@ + if(COMPILER_RT_BUILD_XRAY) + compiler_rt_test_runtime(xray) + endif() ++ if(COMPILER_RT_HAS_CRT) ++ add_subdirectory(crt) ++ endif() + # ShadowCallStack does not yet provide a runtime with compiler-rt, the tests + # include their own minimal runtime + add_subdirectory(shadowcallstack) +Index: compiler-rt/test/crt/CMakeLists.txt +=================================================================== +--- /dev/null ++++ compiler-rt/test/crt/CMakeLists.txt +@@ -0,0 +1,31 @@ ++set(CRT_LIT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) ++ ++set(CRT_TESTSUITES) ++ ++set(CRT_TEST_DEPS "") ++ ++if(NOT COMPILER_RT_STANDALONE_BUILD AND COMPILER_RT_BUILD_CRT AND ++ COMPILER_RT_HAS_CRT) ++ list(APPEND CRT_TEST_DEPS crt) ++endif() ++ ++set(CRT_TEST_ARCH ${CRT_SUPPORTED_ARCH}) ++if (COMPILER_RT_BUILD_CRT AND COMPILER_RT_HAS_CRT) ++ foreach(arch ${CRT_TEST_ARCH}) ++ set(CRT_TEST_TARGET_ARCH ${arch}) ++ string(TOLOWER "-${arch}-${OS_NAME}" CRT_TEST_CONFIG_SUFFIX) ++ get_test_cc_for_arch(${arch} CRT_TEST_TARGET_CC CRT_TEST_TARGET_CFLAGS) ++ string(TOUPPER ${arch} ARCH_UPPER_CASE) ++ set(CONFIG_NAME ${ARCH_UPPER_CASE}${OS_NAME}Config) ++ ++ configure_lit_site_cfg( ++ ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in ++ ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/lit.site.cfg) ++ list(APPEND CRT_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}) ++ endforeach() ++endif() ++ ++add_lit_testsuite(check-crt "Running the CRT tests" ++ ${CRT_TESTSUITES} ++ DEPENDS ${CRT_TEST_DEPS}) ++set_target_properties(check-crt PROPERTIES FOLDER "Compiler-RT Misc") +Index: compiler-rt/test/crt/dso_handle.cpp +=================================================================== +--- /dev/null ++++ compiler-rt/test/crt/dso_handle.cpp +@@ -0,0 +1,33 @@ ++// RUN: %clangxx -g -DCRT_SHARED -c %s -fPIC -o %tshared.o ++// RUN: %clangxx -g -c %s -fPIC -o %t.o ++// RUN: %clangxx -g -shared -o %t.so -nostdlib %crti %shared_crtbegin %tshared.o %libstdcxx -lc -lm -lgcc_s %shared_crtend %crtn ++// RUN: %clangxx -g -o %t -nostdlib %crt1 %crti %crtbegin %t.o %libstdcxx -lc -lm %libgcc %t.so %crtend %crtn ++// RUN: %run %t 2>&1 | FileCheck %s ++ ++#include <stdio.h> ++ ++// CHECK: 1 ++// CHECK-NEXT: ~A() ++ ++#ifdef CRT_SHARED ++bool G; ++void C() { ++ printf("%d\n", G); ++} ++ ++struct A { ++ A() { G = true; } ++ ~A() { ++ printf("~A()\n"); ++ } ++}; ++ ++A a; ++#else ++void C(); ++ ++int main() { ++ C(); ++ return 0; ++} ++#endif +Index: compiler-rt/test/crt/lit.cfg +=================================================================== +--- /dev/null ++++ compiler-rt/test/crt/lit.cfg +@@ -0,0 +1,80 @@ ++# -*- Python -*- ++ ++import os ++import subprocess ++ ++# Setup config name. ++config.name = 'CRT' + config.name_suffix ++ ++# Setup source root. ++config.test_source_root = os.path.dirname(__file__) ++ ++ ++def get_library_path(file): ++ cmd = subprocess.Popen([config.clang.strip(), ++ config.target_cflags.strip(), ++ '-print-file-name=%s' % file], ++ stdout=subprocess.PIPE, ++ env=config.environment) ++ if not cmd.stdout: ++ lit_config.fatal("Couldn't find the library path for '%s'" % file) ++ dir = cmd.stdout.read().strip() ++ if sys.platform in ['win32'] and execute_external: ++ # Don't pass dosish path separator to msys bash.exe. ++ dir = dir.replace('\\', '/') ++ # Ensure the result is an ascii string, across Python2.5+ - Python3. ++ return str(dir.decode('ascii')) ++ ++ ++def get_libgcc_file_name(): ++ cmd = subprocess.Popen([config.clang.strip(), ++ config.target_cflags.strip(), ++ '-print-libgcc-file-name'], ++ stdout=subprocess.PIPE, ++ env=config.environment) ++ if not cmd.stdout: ++ lit_config.fatal("Couldn't find the library path for '%s'" % file) ++ dir = cmd.stdout.read().strip() ++ if sys.platform in ['win32'] and execute_external: ++ # Don't pass dosish path separator to msys bash.exe. ++ dir = dir.replace('\\', '/') ++ # Ensure the result is an ascii string, across Python2.5+ - Python3. ++ return str(dir.decode('ascii')) ++ ++ ++def build_invocation(compile_flags): ++ return ' ' + ' '.join([config.clang] + compile_flags) + ' ' ++ ++ ++# Setup substitutions. ++config.substitutions.append( ++ ('%clang ', build_invocation([config.target_cflags]))) ++config.substitutions.append( ++ ('%clangxx ', ++ build_invocation(config.cxx_mode_flags + [config.target_cflags]))) ++ ++base_lib = os.path.join( ++ config.compiler_rt_libdir, "clang_rt.%%s-%s.o" % config.target_arch) ++config.substitutions.append(('%crtbegin', base_lib % "crtbegin")) ++config.substitutions.append(('%shared_crtbegin', base_lib % "crtbegin_shared")) ++config.substitutions.append(('%crtend', base_lib % "crtend")) ++config.substitutions.append(('%shared_crtend', base_lib % "crtend_shared")) ++ ++config.substitutions.append( ++ ('%crt1', get_library_path('crt1.o'))) ++config.substitutions.append( ++ ('%crti', get_library_path('crti.o'))) ++config.substitutions.append( ++ ('%crtn', get_library_path('crtn.o'))) ++ ++config.substitutions.append( ++ ('%libgcc', get_libgcc_file_name())) ++ ++config.substitutions.append( ++ ('%libstdcxx', '-l' + config.sanitizer_cxx_lib.lstrip('lib'))) ++ ++# Default test suffixes. ++config.suffixes = ['.c', '.cc', '.cpp'] ++ ++if config.host_os not in ['Linux']: ++ config.unsupported = True +Index: compiler-rt/test/crt/lit.site.cfg.in +=================================================================== +--- /dev/null ++++ compiler-rt/test/crt/lit.site.cfg.in +@@ -0,0 +1,14 @@ ++@LIT_SITE_CFG_IN_HEADER@ ++ ++# Tool-specific config options. ++config.name_suffix = "@CRT_TEST_CONFIG_SUFFIX@" ++config.crt_lit_source_dir = "@CRT_LIT_SOURCE_DIR@" ++config.target_cflags = "@CRT_TEST_TARGET_CFLAGS@" ++config.target_arch = "@CRT_TEST_TARGET_ARCH@" ++config.sanitizer_cxx_lib = "@SANITIZER_TEST_CXX_LIBNAME@" ++ ++# Load common config for all compiler-rt lit tests ++lit_config.load_config(config, "@COMPILER_RT_BINARY_DIR@/test/lit.common.configured") ++ ++# Load tool-specific config that would do the real work. ++lit_config.load_config(config, "@CRT_LIT_SOURCE_DIR@/lit.cfg") diff --git a/nixpkgs/pkgs/development/compilers/llvm/7/default.nix b/nixpkgs/pkgs/development/compilers/llvm/7/default.nix new file mode 100644 index 000000000000..060bef69bc15 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/7/default.nix @@ -0,0 +1,149 @@ +{ lowPrio, newScope, pkgs, stdenv, cmake, libstdcxxHook +, libxml2, python, isl, fetchurl, overrideCC, wrapCCWith, wrapBintoolsWith +, buildLlvmTools # tools, but from the previous stage, for cross +, targetLlvmLibraries # libraries, but from the next stage, for cross +}: + +let + release_version = "7.0.1"; + version = release_version; # differentiating these is important for rc's + + fetch = name: sha256: fetchurl { + url = "https://releases.llvm.org/${release_version}/${name}-${version}.src.tar.xz"; + inherit sha256; + }; + + clang-tools-extra_src = fetch "clang-tools-extra" "1v9vc7id1761qm7mywlknsp810232iwyz8rd4y5km4h7pg9cg4sc"; + + tools = stdenv.lib.makeExtensible (tools: let + callPackage = newScope (tools // { inherit stdenv cmake libxml2 python isl release_version version fetch; }); + mkExtraBuildCommands = cc: '' + rsrc="$out/resource-root" + mkdir "$rsrc" + ln -s "${cc}/lib/clang/${release_version}/include" "$rsrc" + ln -s "${targetLlvmLibraries.compiler-rt.out}/lib" "$rsrc/lib" + echo "-resource-dir=$rsrc" >> $out/nix-support/cc-cflags + '' + stdenv.lib.optionalString (stdenv.targetPlatform.isLinux && tools.clang-unwrapped ? gcc) '' + echo "--gcc-toolchain=${tools.clang-unwrapped.gcc}" >> $out/nix-support/cc-cflags + ''; + in { + + llvm = callPackage ./llvm.nix { }; + llvm-polly = callPackage ./llvm.nix { enablePolly = true; }; + + clang-unwrapped = callPackage ./clang { + inherit clang-tools-extra_src; + }; + clang-polly-unwrapped = callPackage ./clang { + inherit clang-tools-extra_src; + llvm = tools.llvm-polly; + enablePolly = true; + }; + + llvm-manpages = lowPrio (tools.llvm.override { + enableManpages = true; + python = pkgs.python; # don't use python-boot + }); + + clang-manpages = lowPrio (tools.clang-unwrapped.override { + enableManpages = true; + python = pkgs.python; # don't use python-boot + }); + + libclang = tools.clang-unwrapped.lib; + + clang = if stdenv.cc.isGNU then tools.libstdcxxClang else tools.libcxxClang; + + libstdcxxClang = wrapCCWith rec { + cc = tools.clang-unwrapped; + extraPackages = [ + libstdcxxHook + targetLlvmLibraries.compiler-rt + ]; + extraBuildCommands = mkExtraBuildCommands cc; + }; + + libcxxClang = wrapCCWith rec { + cc = tools.clang-unwrapped; + libcxx = targetLlvmLibraries.libcxx; + extraPackages = [ + targetLlvmLibraries.libcxx + targetLlvmLibraries.libcxxabi + targetLlvmLibraries.compiler-rt + ]; + extraBuildCommands = mkExtraBuildCommands cc; + }; + + lld = callPackage ./lld.nix {}; + + lldb = callPackage ./lldb.nix {}; + + bintools = callPackage ./bintools.nix {}; + + lldClang = wrapCCWith rec { + cc = tools.clang-unwrapped; + bintools = wrapBintoolsWith { + inherit (tools) bintools; + }; + extraPackages = [ + # targetLlvmLibraries.libcxx + # targetLlvmLibraries.libcxxabi + targetLlvmLibraries.compiler-rt + ]; + extraBuildCommands = '' + echo "-target ${stdenv.targetPlatform.config} -rtlib=compiler-rt" >> $out/nix-support/cc-cflags + '' + mkExtraBuildCommands cc; + }; + + lldClangNoLibc = wrapCCWith rec { + cc = tools.clang-unwrapped; + bintools = wrapBintoolsWith { + inherit (tools) bintools; + libc = null; + }; + extraPackages = [ + # targetLlvmLibraries.libcxx + # targetLlvmLibraries.libcxxabi + targetLlvmLibraries.compiler-rt + ]; + extraBuildCommands = '' + echo "-target ${stdenv.targetPlatform.config} -rtlib=compiler-rt" >> $out/nix-support/cc-cflags + '' + mkExtraBuildCommands cc; + }; + + lldClangNoCompilerRt = wrapCCWith rec { + cc = tools.clang-unwrapped; + bintools = wrapBintoolsWith { + inherit (tools) bintools; + libc = null; + }; + extraPackages = [ ]; + extraBuildCommands = '' + echo "-nostartfiles -target ${stdenv.targetPlatform.config}" >> $out/nix-support/cc-cflags + ''; + }; + + }); + + libraries = stdenv.lib.makeExtensible (libraries: let + callPackage = newScope (libraries // buildLlvmTools // { inherit stdenv cmake libxml2 python isl release_version version fetch; }); + in { + + compiler-rt = callPackage ./compiler-rt.nix { + stdenv = if stdenv.hostPlatform.useLLVM or false + then overrideCC stdenv buildLlvmTools.lldClangNoCompilerRt + else stdenv; + }; + + stdenv = overrideCC stdenv buildLlvmTools.clang; + + libcxxStdenv = overrideCC stdenv buildLlvmTools.libcxxClang; + + libcxx = callPackage ./libc++ {}; + + libcxxabi = callPackage ./libc++abi.nix {}; + + openmp = callPackage ./openmp.nix {}; + }); + +in { inherit tools libraries; } // libraries // tools diff --git a/nixpkgs/pkgs/development/compilers/llvm/7/libc++/default.nix b/nixpkgs/pkgs/development/compilers/llvm/7/libc++/default.nix new file mode 100644 index 000000000000..d372984dac7c --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/7/libc++/default.nix @@ -0,0 +1,50 @@ +{ lib, stdenv, fetch, cmake, python, libcxxabi, fixDarwinDylibNames, version }: + +stdenv.mkDerivation rec { + name = "libc++-${version}"; + + src = fetch "libcxx" "1wdrxg365ig0kngx52pd0n820sncp24blb0zpalc579iidhh4002"; + + postUnpack = '' + unpackFile ${libcxxabi.src} + export LIBCXXABI_INCLUDE_DIR="$PWD/$(ls -d libcxxabi-${version}*)/include" + ''; + + patches = stdenv.lib.optional stdenv.hostPlatform.isMusl ../../libcxx-0001-musl-hacks.patch; + + prePatch = '' + substituteInPlace lib/CMakeLists.txt --replace "/usr/lib/libc++" "\''${LIBCXX_LIBCXXABI_LIB_PATH}/libc++" + ''; + + preConfigure = '' + # Get headers from the cxxabi source so we can see private headers not installed by the cxxabi package + cmakeFlagsArray=($cmakeFlagsArray -DLIBCXX_CXX_ABI_INCLUDE_PATHS="$LIBCXXABI_INCLUDE_DIR") + '' + lib.optionalString stdenv.hostPlatform.isMusl '' + patchShebangs utils/cat_files.py + ''; + nativeBuildInputs = [ cmake ] ++ stdenv.lib.optional stdenv.hostPlatform.isMusl python; + + buildInputs = [ libcxxabi ] ++ lib.optional stdenv.isDarwin fixDarwinDylibNames; + + cmakeFlags = [ + "-DLIBCXX_LIBCXXABI_LIB_PATH=${libcxxabi}/lib" + "-DLIBCXX_LIBCPPABI_VERSION=2" + "-DLIBCXX_CXX_ABI=libcxxabi" + ] ++ stdenv.lib.optional stdenv.hostPlatform.isMusl "-DLIBCXX_HAS_MUSL_LIBC=1"; + + enableParallelBuilding = true; + + linkCxxAbi = stdenv.isLinux; + + setupHooks = [ + ../../../../../build-support/setup-hooks/role.bash + ./setup-hook.sh + ]; + + meta = { + homepage = http://libcxx.llvm.org/; + description = "A new implementation of the C++ standard library, targeting C++11"; + license = with stdenv.lib.licenses; [ ncsa mit ]; + platforms = stdenv.lib.platforms.unix; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/llvm/7/libc++/setup-hook.sh b/nixpkgs/pkgs/development/compilers/llvm/7/libc++/setup-hook.sh new file mode 100644 index 000000000000..6611259165ae --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/7/libc++/setup-hook.sh @@ -0,0 +1,6 @@ +# See pkgs/build-support/setup-hooks/role.bash +getHostRole + +linkCxxAbi="@linkCxxAbi@" +export NIX_${role_pre}CXXSTDLIB_COMPILE+=" -isystem @out@/include/c++/v1" +export NIX_${role_pre}CXXSTDLIB_LINK=" -stdlib=libc++${linkCxxAbi:+" -lc++abi"}" diff --git a/nixpkgs/pkgs/development/compilers/llvm/7/libc++abi.nix b/nixpkgs/pkgs/development/compilers/llvm/7/libc++abi.nix new file mode 100644 index 000000000000..b65b75b36886 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/7/libc++abi.nix @@ -0,0 +1,50 @@ +{ stdenv, cmake, fetch, libcxx, libunwind, llvm, version }: + +stdenv.mkDerivation { + name = "libc++abi-${version}"; + + src = fetch "libcxxabi" "1n6yx0949l9bprh75dffchahn8wplkm79ffk4f2ap9vw2lx90s41"; + + nativeBuildInputs = [ cmake ]; + buildInputs = stdenv.lib.optional (!stdenv.isDarwin && !stdenv.isFreeBSD) libunwind; + + postUnpack = '' + unpackFile ${libcxx.src} + unpackFile ${llvm.src} + export cmakeFlags="-DLLVM_PATH=$PWD/$(ls -d llvm-*) -DLIBCXXABI_LIBCXX_PATH=$PWD/$(ls -d libcxx-*)" + '' + stdenv.lib.optionalString stdenv.isDarwin '' + export TRIPLE=x86_64-apple-darwin + '' + stdenv.lib.optionalString stdenv.hostPlatform.isMusl '' + patch -p1 -d $(ls -d libcxx-*) -i ${../libcxx-0001-musl-hacks.patch} + ''; + + installPhase = if stdenv.isDarwin + then '' + for file in lib/*.dylib; do + # this should be done in CMake, but having trouble figuring out + # the magic combination of necessary CMake variables + # if you fancy a try, take a look at + # http://www.cmake.org/Wiki/CMake_RPATH_handling + install_name_tool -id $out/$file $file + done + make install + install -d 755 $out/include + install -m 644 ../include/*.h $out/include + '' + else '' + install -d -m 755 $out/include $out/lib + install -m 644 lib/libc++abi.a $out/lib + install -m 644 lib/libc++abi.so.1.0 $out/lib + install -m 644 ../include/cxxabi.h $out/include + ln -s libc++abi.so.1.0 $out/lib/libc++abi.so + ln -s libc++abi.so.1.0 $out/lib/libc++abi.so.1 + ''; + + meta = { + homepage = http://libcxxabi.llvm.org/; + description = "A new implementation of low level support for a standard C++ library"; + license = with stdenv.lib.licenses; [ ncsa mit ]; + maintainers = with stdenv.lib.maintainers; [ vlstill ]; + platforms = stdenv.lib.platforms.unix; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/llvm/7/lld.nix b/nixpkgs/pkgs/development/compilers/llvm/7/lld.nix new file mode 100644 index 000000000000..33085eb3c808 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/7/lld.nix @@ -0,0 +1,32 @@ +{ stdenv +, fetch +, cmake +, libxml2 +, llvm +, version +}: + +stdenv.mkDerivation { + name = "lld-${version}"; + + src = fetch "lld" "0ca0qygrk87lhjk6cpv1wbmdfnficqqjsda3k7b013idvnralsc8"; + + nativeBuildInputs = [ cmake ]; + buildInputs = [ llvm libxml2 ]; + + outputs = [ "out" "dev" ]; + + enableParallelBuilding = true; + + postInstall = '' + moveToOutput include "$dev" + moveToOutput lib "$dev" + ''; + + meta = { + description = "The LLVM Linker"; + homepage = http://lld.llvm.org/; + license = stdenv.lib.licenses.ncsa; + platforms = stdenv.lib.platforms.all; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/llvm/7/lldb.nix b/nixpkgs/pkgs/development/compilers/llvm/7/lldb.nix new file mode 100644 index 000000000000..14cc0514fe6d --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/7/lldb.nix @@ -0,0 +1,56 @@ +{ stdenv +, fetch +, cmake +, zlib +, ncurses +, swig +, which +, libedit +, libxml2 +, llvm +, clang-unwrapped +, python +, version +, darwin +}: + +stdenv.mkDerivation { + name = "lldb-${version}"; + + src = fetch "lldb" "10k9lyk3i72j9hca523r9pz79qp7d8q7jqnjy0i3saj1bgknpd3n"; + + postPatch = '' + # Fix up various paths that assume llvm and clang are installed in the same place + sed -i 's,".*ClangConfig.cmake","${clang-unwrapped}/lib/cmake/clang/ClangConfig.cmake",' \ + cmake/modules/LLDBStandalone.cmake + sed -i 's,".*tools/clang/include","${clang-unwrapped}/include",' \ + cmake/modules/LLDBStandalone.cmake + sed -i 's,"$.LLVM_LIBRARY_DIR.",${llvm}/lib ${clang-unwrapped}/lib,' \ + cmake/modules/LLDBStandalone.cmake + ''; + + nativeBuildInputs = [ cmake python which swig ]; + buildInputs = [ ncurses zlib libedit libxml2 llvm ] + ++ stdenv.lib.optionals stdenv.isDarwin [ darwin.libobjc darwin.apple_sdk.libs.xpc darwin.apple_sdk.frameworks.Foundation darwin.bootstrap_cmds darwin.apple_sdk.frameworks.Carbon darwin.apple_sdk.frameworks.Cocoa darwin.cf-private ]; + + CXXFLAGS = "-fno-rtti"; + hardeningDisable = [ "format" ]; + + cmakeFlags = [ + "-DLLDB_CODESIGN_IDENTITY=" # codesigning makes nondeterministic + ]; + + enableParallelBuilding = true; + + postInstall = '' + mkdir -p $out/share/man/man1 + cp ../docs/lldb.1 $out/share/man/man1/ + ''; + + meta = with stdenv.lib; { + description = "A next-generation high-performance debugger"; + homepage = http://llvm.org/; + license = licenses.ncsa; + platforms = platforms.all; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/llvm/7/llvm-outputs.patch b/nixpkgs/pkgs/development/compilers/llvm/7/llvm-outputs.patch new file mode 100644 index 000000000000..40096fa3497f --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/7/llvm-outputs.patch @@ -0,0 +1,26 @@ +diff --git a/tools/llvm-config/llvm-config.cpp b/tools/llvm-config/llvm-config.cpp +index 94d426b..37f7794 100644 +--- a/tools/llvm-config/llvm-config.cpp ++++ b/tools/llvm-config/llvm-config.cpp +@@ -333,6 +333,21 @@ int main(int argc, char **argv) { + ActiveIncludeOption = "-I" + ActiveIncludeDir; + } + ++ /// Nix-specific multiple-output handling: override ActiveLibDir if --link-shared ++ if (!IsInDevelopmentTree) { ++ bool WantShared = true; ++ for (int i = 1; i < argc; ++i) { ++ StringRef Arg = argv[i]; ++ if (Arg == "--link-shared") ++ WantShared = true; ++ else if (Arg == "--link-static") ++ WantShared = false; // the last one wins ++ } ++ ++ if (WantShared) ++ ActiveLibDir = std::string("@lib@") + "/lib" + LLVM_LIBDIR_SUFFIX; ++ } ++ + /// We only use `shared library` mode in cases where the static library form + /// of the components provided are not available; note however that this is + /// skipped if we're run from within the build dir. However, once installed, diff --git a/nixpkgs/pkgs/development/compilers/llvm/7/llvm.nix b/nixpkgs/pkgs/development/compilers/llvm/7/llvm.nix new file mode 100644 index 000000000000..34f8a5478d1b --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/7/llvm.nix @@ -0,0 +1,191 @@ +{ stdenv +, fetch +, fetchpatch +, cmake +, python +, libffi +, libbfd +, libpfm +, libxml2 +, ncurses +, version +, release_version +, zlib +, buildPackages +, debugVersion ? false +, enableManpages ? false +, enableSharedLibraries ? true +, enablePFM ? !stdenv.isDarwin +, enablePolly ? false +}: + +let + inherit (stdenv.lib) optional optionals optionalString; + + src = fetch "llvm" "16s196wqzdw4pmri15hadzqgdi926zln3an2viwyq0kini6zr3d3"; + polly_src = fetch "polly" "0wgvayfilgb530bq51l7szxfb13l24nnrmyji2f6ncq95a24dw8v"; + + # Used when creating a version-suffixed symlink of libLLVM.dylib + shortVersion = with stdenv.lib; + concatStringsSep "." (take 1 (splitString "." release_version)); + +in stdenv.mkDerivation (rec { + name = "llvm-${version}"; + + unpackPhase = '' + unpackFile ${src} + mv llvm-${version}* llvm + sourceRoot=$PWD/llvm + '' + optionalString enablePolly '' + unpackFile ${polly_src} + mv polly-* $sourceRoot/tools/polly + ''; + + outputs = [ "out" "python" ] + ++ optional enableSharedLibraries "lib"; + + nativeBuildInputs = [ cmake python ] + ++ optional enableManpages python.pkgs.sphinx; + + buildInputs = [ libxml2 libffi ] + ++ optional enablePFM libpfm; # exegesis + + propagatedBuildInputs = [ ncurses zlib ]; + + patches = [ + # https://bugs.llvm.org/show_bug.cgi?id=39427 + # https://github.com/NixOS/nixpkgs/issues/54370 + (fetchpatch { + url = "https://github.com/llvm-mirror/llvm/commit/57567def148f387153a8149fb590bd39b1b006a1.patch"; + sha256 = "1w1xg5pxpc6cals1nf5j5k4p6qi8lcrpvn0paxc86m415i79xmcg"; + }) + # backport, fix building rust crates with lto + (fetchpatch { + url = "https://github.com/llvm-mirror/llvm/commit/da1fb72bb305d6bc1f3899d541414146934bf80f.patch"; + sha256 = "0p81gkhc1xhcx0hmnkwyhrn8x8l8fd24xgaj1whni29yga466dwc"; + }) + (fetchpatch { + url = "https://github.com/llvm-mirror/llvm/commit/cc1f2a595ead516812a6c50398f0f3480ebe031f.patch"; + sha256 = "0k6k1p5yisgwx417a67s7sr9930rqh1n0zv5jvply8vjjy4b3kf8"; + }) + ]; + + postPatch = optionalString stdenv.isDarwin '' + substituteInPlace cmake/modules/AddLLVM.cmake \ + --replace 'set(_install_name_dir INSTALL_NAME_DIR "@rpath")' "set(_install_name_dir)" \ + --replace 'set(_install_rpath "@loader_path/../lib" ''${extra_libdir})' "" + '' + # Patch llvm-config to return correct library path based on --link-{shared,static}. + + optionalString (enableSharedLibraries) '' + substitute '${./llvm-outputs.patch}' ./llvm-outputs.patch --subst-var lib + patch -p1 < ./llvm-outputs.patch + '' + '' + # FileSystem permissions tests fail with various special bits + substituteInPlace unittests/Support/CMakeLists.txt \ + --replace "Path.cpp" "" + rm unittests/Support/Path.cpp + '' + optionalString stdenv.hostPlatform.isMusl '' + patch -p1 -i ${../TLI-musl.patch} + substituteInPlace unittests/Support/CMakeLists.txt \ + --replace "add_subdirectory(DynamicLibrary)" "" + rm unittests/Support/DynamicLibrary/DynamicLibraryTest.cpp + '' + '' + patchShebangs test/BugPoint/compile-custom.ll.py + ''; + + # hacky fix: created binaries need to be run before installation + preBuild = '' + mkdir -p $out/ + ln -sv $PWD/lib $out + ''; + + cmakeFlags = with stdenv; [ + "-DCMAKE_BUILD_TYPE=${if debugVersion then "Debug" else "Release"}" + "-DLLVM_INSTALL_UTILS=ON" # Needed by rustc + "-DLLVM_BUILD_TESTS=ON" + "-DLLVM_ENABLE_FFI=ON" + "-DLLVM_ENABLE_RTTI=ON" + "-DLLVM_HOST_TRIPLE=${stdenv.hostPlatform.config}" + "-DLLVM_DEFAULT_TARGET_TRIPLE=${stdenv.hostPlatform.config}" + "-DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=WebAssembly" + "-DLLVM_ENABLE_DUMP=ON" + ] ++ optionals enableSharedLibraries [ + "-DLLVM_LINK_LLVM_DYLIB=ON" + ] ++ optionals enableManpages [ + "-DLLVM_BUILD_DOCS=ON" + "-DLLVM_ENABLE_SPHINX=ON" + "-DSPHINX_OUTPUT_MAN=ON" + "-DSPHINX_OUTPUT_HTML=OFF" + "-DSPHINX_WARNINGS_AS_ERRORS=OFF" + ] ++ optionals (!isDarwin) [ + "-DLLVM_BINUTILS_INCDIR=${libbfd.dev}/include" + ] ++ optionals (isDarwin) [ + "-DLLVM_ENABLE_LIBCXX=ON" + "-DCAN_TARGET_i386=false" + ] ++ optionals (stdenv.hostPlatform != stdenv.buildPlatform) [ + "-DCMAKE_CROSSCOMPILING=True" + "-DLLVM_TABLEGEN=${buildPackages.llvm_7}/bin/llvm-tblgen" + ]; + + postBuild = '' + rm -fR $out + ''; + + preCheck = '' + export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$PWD/lib + ''; + + postInstall = '' + mkdir -p $python/share + mv $out/share/opt-viewer $python/share/opt-viewer + '' + + optionalString enableSharedLibraries '' + moveToOutput "lib/libLLVM-*" "$lib" + moveToOutput "lib/libLLVM${stdenv.hostPlatform.extensions.sharedLibrary}" "$lib" + substituteInPlace "$out/lib/cmake/llvm/LLVMExports-${if debugVersion then "debug" else "release"}.cmake" \ + --replace "\''${_IMPORT_PREFIX}/lib/libLLVM-" "$lib/lib/libLLVM-" + '' + + optionalString (stdenv.isDarwin && enableSharedLibraries) '' + substituteInPlace "$out/lib/cmake/llvm/LLVMExports-${if debugVersion then "debug" else "release"}.cmake" \ + --replace "\''${_IMPORT_PREFIX}/lib/libLLVM.dylib" "$lib/lib/libLLVM.dylib" + ln -s $lib/lib/libLLVM.dylib $lib/lib/libLLVM-${shortVersion}.dylib + ln -s $lib/lib/libLLVM.dylib $lib/lib/libLLVM-${release_version}.dylib + ''; + + doCheck = stdenv.isLinux && (!stdenv.isx86_32); + + checkTarget = "check-all"; + + enableParallelBuilding = true; + + passthru.src = src; + + meta = { + description = "Collection of modular and reusable compiler and toolchain technologies"; + homepage = http://llvm.org/; + license = stdenv.lib.licenses.ncsa; + maintainers = with stdenv.lib.maintainers; [ lovek323 raskin dtzWill ]; + platforms = stdenv.lib.platforms.all; + }; +} // stdenv.lib.optionalAttrs enableManpages { + name = "llvm-manpages-${version}"; + + buildPhase = '' + make docs-llvm-man + ''; + + propagatedBuildInputs = []; + + installPhase = '' + make -C docs install + ''; + + postPatch = null; + postInstall = null; + + outputs = [ "out" ]; + + doCheck = false; + + meta.description = "man pages for LLVM ${version}"; +}) diff --git a/nixpkgs/pkgs/development/compilers/llvm/7/openmp.nix b/nixpkgs/pkgs/development/compilers/llvm/7/openmp.nix new file mode 100644 index 000000000000..fb856eaa51fd --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/7/openmp.nix @@ -0,0 +1,25 @@ +{ stdenv +, fetch +, cmake +, llvm +, perl +, version +}: + +stdenv.mkDerivation { + name = "openmp-${version}"; + + src = fetch "openmp" "030dkg5cypd7j9hq0mcqb5gs31lxwmzfq52j81l7v9ldcy5bf5mz"; + + nativeBuildInputs = [ cmake perl ]; + buildInputs = [ llvm ]; + + enableParallelBuilding = true; + + meta = { + description = "Components required to build an executable OpenMP program"; + homepage = http://openmp.llvm.org/; + license = stdenv.lib.licenses.mit; + platforms = stdenv.lib.platforms.all; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/llvm/7/sanitizers-nongnu.patch b/nixpkgs/pkgs/development/compilers/llvm/7/sanitizers-nongnu.patch new file mode 100644 index 000000000000..1f2ac97818eb --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/7/sanitizers-nongnu.patch @@ -0,0 +1,412 @@ +From f7a253f8f85d0f49df6b73996737a3e84ac64236 Mon Sep 17 00:00:00 2001 +From: Will Dietz <w@wdtz.org> +Date: Mon, 24 Sep 2018 11:17:25 -0500 +Subject: [PATCH] Ported to 7.0, taken from gentoo-musl project. + +------ +Ported to compiler-rt-sanitizers-5.0.0. Taken from + +https://gist.githubusercontent.com/pwaller/2337f3290f12634cad3e3730cff0a6c1/raw/83c87a8585e2f9662494db5662e5361beb093c26/nongnu.patch +Signed-off-by: Jory A. Pratt <anarchy@gentoo.org> + +Taken from gentoo-musl project, with a few additional minor fixes. +--- + lib/asan/asan_linux.cc | 4 +- + lib/interception/interception_linux.cc | 2 +- + lib/interception/interception_linux.h | 2 +- + lib/msan/msan_linux.cc | 2 +- + lib/sanitizer_common/sanitizer_allocator.cc | 2 +- + .../sanitizer_common_interceptors_ioctl.inc | 4 +- + .../sanitizer_common_syscalls.inc | 2 +- + lib/sanitizer_common/sanitizer_linux.cc | 8 +++- + .../sanitizer_linux_libcdep.cc | 10 ++--- + lib/sanitizer_common/sanitizer_platform.h | 6 +++ + .../sanitizer_platform_interceptors.h | 4 +- + .../sanitizer_platform_limits_posix.cc | 37 +++++++++++-------- + lib/tsan/rtl/tsan_platform_linux.cc | 2 +- + 13 files changed, 51 insertions(+), 34 deletions(-) + +diff --git a/lib/asan/asan_linux.cc b/lib/asan/asan_linux.cc +index 625f32d40..73cf77aca 100644 +--- a/lib/asan/asan_linux.cc ++++ b/lib/asan/asan_linux.cc +@@ -46,7 +46,7 @@ + #include <link.h> + #endif + +-#if SANITIZER_ANDROID || SANITIZER_FREEBSD || SANITIZER_SOLARIS ++#if SANITIZER_ANDROID || SANITIZER_FREEBSD || SANITIZER_SOLARIS || SANITIZER_NONGNU + #include <ucontext.h> + extern "C" void* _DYNAMIC; + #elif SANITIZER_NETBSD +@@ -139,7 +139,7 @@ void AsanApplyToGlobals(globals_op_fptr op, const void *needle) { + UNIMPLEMENTED(); + } + +-#if SANITIZER_ANDROID ++#if SANITIZER_ANDROID || SANITIZER_NONGNU + // FIXME: should we do anything for Android? + void AsanCheckDynamicRTPrereqs() {} + void AsanCheckIncompatibleRT() {} +diff --git a/lib/interception/interception_linux.cc b/lib/interception/interception_linux.cc +index 26bfcd8f6..529b234f7 100644 +--- a/lib/interception/interception_linux.cc ++++ b/lib/interception/interception_linux.cc +@@ -43,7 +43,7 @@ bool GetRealFunctionAddress(const char *func_name, uptr *func_addr, + } + + // Android and Solaris do not have dlvsym +-#if !SANITIZER_ANDROID && !SANITIZER_SOLARIS && !SANITIZER_OPENBSD ++#if !SANITIZER_ANDROID && !SANITIZER_SOLARIS && !SANITIZER_OPENBSD && !SANITIZER_NONGNU + void *GetFuncAddrVer(const char *func_name, const char *ver) { + return dlvsym(RTLD_NEXT, func_name, ver); + } +diff --git a/lib/interception/interception_linux.h b/lib/interception/interception_linux.h +index 942c25609..24a4d5080 100644 +--- a/lib/interception/interception_linux.h ++++ b/lib/interception/interception_linux.h +@@ -36,7 +36,7 @@ void *GetFuncAddrVer(const char *func_name, const char *ver); + (::__interception::uptr) & WRAP(func)) + + // Android, Solaris and OpenBSD do not have dlvsym +-#if !SANITIZER_ANDROID && !SANITIZER_SOLARIS && !SANITIZER_OPENBSD ++#if !SANITIZER_ANDROID && !SANITIZER_SOLARIS && !SANITIZER_OPENBSD && !SANITIZER_NONGNU + #define INTERCEPT_FUNCTION_VER_LINUX_OR_FREEBSD(func, symver) \ + (::__interception::real_##func = (func##_f)( \ + unsigned long)::__interception::GetFuncAddrVer(#func, symver)) +diff --git a/lib/msan/msan_linux.cc b/lib/msan/msan_linux.cc +index 385a650c4..6e30a8ce9 100644 +--- a/lib/msan/msan_linux.cc ++++ b/lib/msan/msan_linux.cc +@@ -13,7 +13,7 @@ + //===----------------------------------------------------------------------===// + + #include "sanitizer_common/sanitizer_platform.h" +-#if SANITIZER_FREEBSD || SANITIZER_LINUX || SANITIZER_NETBSD ++#if SANITIZER_FREEBSD || (SANITIZER_LINUX && !SANITIZER_NONGNU) || SANITIZER_NETBSD + + #include "msan.h" + #include "msan_report.h" +diff --git a/lib/sanitizer_common/sanitizer_allocator.cc b/lib/sanitizer_common/sanitizer_allocator.cc +index 6bfd5e5ee..048f6154f 100644 +--- a/lib/sanitizer_common/sanitizer_allocator.cc ++++ b/lib/sanitizer_common/sanitizer_allocator.cc +@@ -27,7 +27,7 @@ const char *SecondaryAllocatorName = "LargeMmapAllocator"; + + // ThreadSanitizer for Go uses libc malloc/free. + #if SANITIZER_GO || defined(SANITIZER_USE_MALLOC) +-# if SANITIZER_LINUX && !SANITIZER_ANDROID ++# if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU + extern "C" void *__libc_malloc(uptr size); + # if !SANITIZER_GO + extern "C" void *__libc_memalign(uptr alignment, uptr size); +diff --git a/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc b/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc +index 2d633c173..b6eb23116 100644 +--- a/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc ++++ b/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc +@@ -104,7 +104,7 @@ static void ioctl_table_fill() { + _(SIOCGETVIFCNT, WRITE, struct_sioc_vif_req_sz); + #endif + +-#if SANITIZER_LINUX ++#if SANITIZER_LINUX && !SANITIZER_NONGNU + // Conflicting request ids. + // _(CDROMAUDIOBUFSIZ, NONE, 0); + // _(SNDCTL_TMR_CONTINUE, NONE, 0); +@@ -365,7 +365,7 @@ static void ioctl_table_fill() { + _(VT_WAITACTIVE, NONE, 0); + #endif + +-#if SANITIZER_LINUX && !SANITIZER_ANDROID ++#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU + // _(SIOCDEVPLIP, WRITE, struct_ifreq_sz); // the same as EQL_ENSLAVE + _(CYGETDEFTHRESH, WRITE, sizeof(int)); + _(CYGETDEFTIMEOUT, WRITE, sizeof(int)); +diff --git a/lib/sanitizer_common/sanitizer_common_syscalls.inc b/lib/sanitizer_common/sanitizer_common_syscalls.inc +index 469c8eb7e..24f87867d 100644 +--- a/lib/sanitizer_common/sanitizer_common_syscalls.inc ++++ b/lib/sanitizer_common/sanitizer_common_syscalls.inc +@@ -2038,7 +2038,7 @@ POST_SYSCALL(setrlimit)(long res, long resource, void *rlim) { + } + } + +-#if !SANITIZER_ANDROID ++#if !SANITIZER_ANDROID && !SANITIZER_NONGNU + PRE_SYSCALL(prlimit64)(long pid, long resource, const void *new_rlim, + void *old_rlim) { + if (new_rlim) PRE_READ(new_rlim, struct_rlimit64_sz); +diff --git a/lib/sanitizer_common/sanitizer_linux.cc b/lib/sanitizer_common/sanitizer_linux.cc +index 96d6c1eff..9e2b7fb9d 100644 +--- a/lib/sanitizer_common/sanitizer_linux.cc ++++ b/lib/sanitizer_common/sanitizer_linux.cc +@@ -541,13 +541,13 @@ const char *GetEnv(const char *name) { + #endif + } + +-#if !SANITIZER_FREEBSD && !SANITIZER_NETBSD && !SANITIZER_OPENBSD ++#if !SANITIZER_FREEBSD && !SANITIZER_NETBSD && !SANITIZER_OPENBSD && !SANITIZER_NONGNU + extern "C" { + SANITIZER_WEAK_ATTRIBUTE extern void *__libc_stack_end; + } + #endif + +-#if !SANITIZER_GO && !SANITIZER_FREEBSD && !SANITIZER_NETBSD && \ ++#if (!SANITIZER_GO || SANITIZER_NONGNU) && !SANITIZER_FREEBSD && !SANITIZER_NETBSD && \ + !SANITIZER_OPENBSD + static void ReadNullSepFileToArray(const char *path, char ***arr, + int arr_size) { +@@ -590,6 +590,10 @@ static void GetArgsAndEnv(char ***argv, char ***envp) { + #elif SANITIZER_NETBSD + *argv = __ps_strings->ps_argvstr; + *envp = __ps_strings->ps_envstr; ++#elif SANITIZER_NONGNU ++ static const int kMaxArgv = 2000, kMaxEnvp = 2000; ++ ReadNullSepFileToArray("/proc/self/cmdline", argv, kMaxArgv); ++ ReadNullSepFileToArray("/proc/self/environ", envp, kMaxEnvp); + #else // SANITIZER_FREEBSD + #if !SANITIZER_GO + if (&__libc_stack_end) { +diff --git a/lib/sanitizer_common/sanitizer_linux_libcdep.cc b/lib/sanitizer_common/sanitizer_linux_libcdep.cc +index 4962ff832..438f94dbe 100644 +--- a/lib/sanitizer_common/sanitizer_linux_libcdep.cc ++++ b/lib/sanitizer_common/sanitizer_linux_libcdep.cc +@@ -179,7 +179,7 @@ __attribute__((unused)) static bool GetLibcVersion(int *major, int *minor, + } + + #if !SANITIZER_FREEBSD && !SANITIZER_ANDROID && !SANITIZER_GO && \ +- !SANITIZER_NETBSD && !SANITIZER_OPENBSD && !SANITIZER_SOLARIS ++ !SANITIZER_NETBSD && !SANITIZER_OPENBSD && !SANITIZER_SOLARIS && !SANITIZER_NONGNU + static uptr g_tls_size; + + #ifdef __i386__ +@@ -261,7 +261,7 @@ void InitTlsSize() { } + #if (defined(__x86_64__) || defined(__i386__) || defined(__mips__) || \ + defined(__aarch64__) || defined(__powerpc64__) || defined(__s390__) || \ + defined(__arm__)) && \ +- SANITIZER_LINUX && !SANITIZER_ANDROID ++ SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU + // sizeof(struct pthread) from glibc. + static atomic_uintptr_t thread_descriptor_size; + +@@ -426,7 +426,7 @@ int GetSizeFromHdr(struct dl_phdr_info *info, size_t size, void *data) { + + #if !SANITIZER_GO + static void GetTls(uptr *addr, uptr *size) { +-#if SANITIZER_LINUX && !SANITIZER_ANDROID ++#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU + # if defined(__x86_64__) || defined(__i386__) || defined(__s390__) + *addr = ThreadSelf(); + *size = GetTlsSize(); +@@ -470,7 +470,7 @@ static void GetTls(uptr *addr, uptr *size) { + #elif SANITIZER_OPENBSD + *addr = 0; + *size = 0; +-#elif SANITIZER_ANDROID ++#elif SANITIZER_ANDROID || SANITIZER_NONGNU + *addr = 0; + *size = 0; + #elif SANITIZER_SOLARIS +@@ -486,7 +486,7 @@ static void GetTls(uptr *addr, uptr *size) { + #if !SANITIZER_GO + uptr GetTlsSize() { + #if SANITIZER_FREEBSD || SANITIZER_ANDROID || SANITIZER_NETBSD || \ +- SANITIZER_OPENBSD || SANITIZER_SOLARIS ++ SANITIZER_OPENBSD || SANITIZER_SOLARIS || SANITIZER_NONGNU + uptr addr, size; + GetTls(&addr, &size); + return size; +diff --git a/lib/sanitizer_common/sanitizer_platform.h b/lib/sanitizer_common/sanitizer_platform.h +index d81e25580..e10680ac8 100644 +--- a/lib/sanitizer_common/sanitizer_platform.h ++++ b/lib/sanitizer_common/sanitizer_platform.h +@@ -208,6 +208,12 @@ + # define SANITIZER_SOLARIS32 0 + #endif + ++#if defined(__linux__) && !defined(__GLIBC__) ++# define SANITIZER_NONGNU 1 ++#else ++# define SANITIZER_NONGNU 0 ++#endif ++ + #if defined(__myriad2__) + # define SANITIZER_MYRIAD2 1 + #else +diff --git a/lib/sanitizer_common/sanitizer_platform_interceptors.h b/lib/sanitizer_common/sanitizer_platform_interceptors.h +index f95539a73..6c53b3415 100644 +--- a/lib/sanitizer_common/sanitizer_platform_interceptors.h ++++ b/lib/sanitizer_common/sanitizer_platform_interceptors.h +@@ -39,7 +39,7 @@ + # include "sanitizer_platform_limits_solaris.h" + #endif + +-#if SANITIZER_LINUX && !SANITIZER_ANDROID ++#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU + # define SI_LINUX_NOT_ANDROID 1 + #else + # define SI_LINUX_NOT_ANDROID 0 +@@ -322,7 +322,7 @@ + #define SANITIZER_INTERCEPT_ETHER_R (SI_FREEBSD || SI_LINUX_NOT_ANDROID) + #define SANITIZER_INTERCEPT_SHMCTL \ + (SI_NETBSD || SI_OPENBSD || SI_SOLARIS || \ +- ((SI_FREEBSD || SI_LINUX_NOT_ANDROID) && \ ++ ((SI_FREEBSD || SI_LINUX_NOT_ANDROID || SANITIZER_NONGNU) && \ + SANITIZER_WORDSIZE == 64)) // NOLINT + #define SANITIZER_INTERCEPT_RANDOM_R SI_LINUX_NOT_ANDROID + #define SANITIZER_INTERCEPT_PTHREAD_ATTR_GET SI_POSIX +diff --git a/lib/sanitizer_common/sanitizer_platform_limits_posix.cc b/lib/sanitizer_common/sanitizer_platform_limits_posix.cc +index 54da635d7..2f6ff69c3 100644 +--- a/lib/sanitizer_common/sanitizer_platform_limits_posix.cc ++++ b/lib/sanitizer_common/sanitizer_platform_limits_posix.cc +@@ -14,6 +14,9 @@ + + #include "sanitizer_platform.h" + ++// Workaround musl <--> linux conflicting definition of 'struct sysinfo' ++#define _LINUX_SYSINFO_H ++ + #if SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_MAC + // Tests in this file assume that off_t-dependent data structures match the + // libc ABI. For example, struct dirent here is what readdir() function (as +@@ -138,12 +141,14 @@ typedef struct user_fpregs elf_fpregset_t; + + #if SANITIZER_LINUX && !SANITIZER_ANDROID + #include <glob.h> +-#include <obstack.h> ++# if !SANITIZER_NONGNU ++# include <obstack.h> ++# endif + #include <mqueue.h> +-#include <net/if_ppp.h> +-#include <netax25/ax25.h> +-#include <netipx/ipx.h> +-#include <netrom/netrom.h> ++#include <linux/if_ppp.h> ++#include <linux/ax25.h> ++#include <linux/ipx.h> ++#include <linux/netrom.h> + #if HAVE_RPC_XDR_H + # include <rpc/xdr.h> + #elif HAVE_TIRPC_RPC_XDR_H +@@ -251,7 +256,7 @@ namespace __sanitizer { + unsigned struct_itimerspec_sz = sizeof(struct itimerspec); + #endif // SANITIZER_LINUX || SANITIZER_FREEBSD + +-#if SANITIZER_LINUX && !SANITIZER_ANDROID ++#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU + // Use pre-computed size of struct ustat to avoid <sys/ustat.h> which + // has been removed from glibc 2.28. + #if defined(__aarch64__) || defined(__s390x__) || defined (__mips64) \ +@@ -322,7 +327,7 @@ unsigned struct_ElfW_Phdr_sz = sizeof(ElfW(Phdr)); + unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr); + #endif + +-#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID ++#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID && !SANITIZER_NONGNU + int glob_nomatch = GLOB_NOMATCH; + int glob_altdirfunc = GLOB_ALTDIRFUNC; + #endif +@@ -416,7 +421,7 @@ unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr); + unsigned struct_termios_sz = sizeof(struct termios); + unsigned struct_winsize_sz = sizeof(struct winsize); + +-#if SANITIZER_LINUX ++#if SANITIZER_LINUX && !SANITIZER_NONGNU + unsigned struct_arpreq_sz = sizeof(struct arpreq); + unsigned struct_cdrom_msf_sz = sizeof(struct cdrom_msf); + unsigned struct_cdrom_multisession_sz = sizeof(struct cdrom_multisession); +@@ -466,7 +471,7 @@ unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr); + unsigned struct_vt_mode_sz = sizeof(struct vt_mode); + #endif // SANITIZER_LINUX || SANITIZER_FREEBSD + +-#if SANITIZER_LINUX && !SANITIZER_ANDROID ++#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU + unsigned struct_ax25_parms_struct_sz = sizeof(struct ax25_parms_struct); + unsigned struct_cyclades_monitor_sz = sizeof(struct cyclades_monitor); + #if EV_VERSION > (0x010000) +@@ -834,7 +839,7 @@ unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr); + unsigned IOCTL_VT_WAITACTIVE = VT_WAITACTIVE; + #endif // SANITIZER_LINUX || SANITIZER_FREEBSD + +-#if SANITIZER_LINUX && !SANITIZER_ANDROID ++#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU + unsigned IOCTL_CYGETDEFTHRESH = CYGETDEFTHRESH; + unsigned IOCTL_CYGETDEFTIMEOUT = CYGETDEFTIMEOUT; + unsigned IOCTL_CYGETMON = CYGETMON; +@@ -989,7 +994,7 @@ CHECK_SIZE_AND_OFFSET(dl_phdr_info, dlpi_phdr); + CHECK_SIZE_AND_OFFSET(dl_phdr_info, dlpi_phnum); + #endif // SANITIZER_LINUX || SANITIZER_FREEBSD + +-#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID ++#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID && !SANITIZER_NONGNU + CHECK_TYPE_SIZE(glob_t); + CHECK_SIZE_AND_OFFSET(glob_t, gl_pathc); + CHECK_SIZE_AND_OFFSET(glob_t, gl_pathv); +@@ -1023,6 +1028,7 @@ CHECK_TYPE_SIZE(iovec); + CHECK_SIZE_AND_OFFSET(iovec, iov_base); + CHECK_SIZE_AND_OFFSET(iovec, iov_len); + ++#if !SANITIZER_NONGNU + CHECK_TYPE_SIZE(msghdr); + CHECK_SIZE_AND_OFFSET(msghdr, msg_name); + CHECK_SIZE_AND_OFFSET(msghdr, msg_namelen); +@@ -1036,6 +1042,7 @@ CHECK_TYPE_SIZE(cmsghdr); + CHECK_SIZE_AND_OFFSET(cmsghdr, cmsg_len); + CHECK_SIZE_AND_OFFSET(cmsghdr, cmsg_level); + CHECK_SIZE_AND_OFFSET(cmsghdr, cmsg_type); ++#endif + + #ifndef __GLIBC_PREREQ + #define __GLIBC_PREREQ(x, y) 0 +@@ -1145,7 +1152,7 @@ CHECK_SIZE_AND_OFFSET(mntent, mnt_passno); + + CHECK_TYPE_SIZE(ether_addr); + +-#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID ++#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID && !SANITIZER_NONGNU + CHECK_TYPE_SIZE(ipc_perm); + # if SANITIZER_FREEBSD + CHECK_SIZE_AND_OFFSET(ipc_perm, key); +@@ -1206,7 +1213,7 @@ CHECK_SIZE_AND_OFFSET(ifaddrs, ifa_dstaddr); + CHECK_SIZE_AND_OFFSET(ifaddrs, ifa_data); + #endif + +-#if SANITIZER_LINUX ++#if SANITIZER_LINUX && !SANITIZER_NONGNU + COMPILER_CHECK(sizeof(__sanitizer_mallinfo) == sizeof(struct mallinfo)); + #endif + +@@ -1256,7 +1263,7 @@ COMPILER_CHECK(__sanitizer_XDR_DECODE == XDR_DECODE); + COMPILER_CHECK(__sanitizer_XDR_FREE == XDR_FREE); + #endif + +-#if SANITIZER_LINUX && !SANITIZER_ANDROID ++#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU + COMPILER_CHECK(sizeof(__sanitizer_FILE) <= sizeof(FILE)); + CHECK_SIZE_AND_OFFSET(FILE, _flags); + CHECK_SIZE_AND_OFFSET(FILE, _IO_read_ptr); +@@ -1275,7 +1282,7 @@ CHECK_SIZE_AND_OFFSET(FILE, _chain); + CHECK_SIZE_AND_OFFSET(FILE, _fileno); + #endif + +-#if SANITIZER_LINUX && !SANITIZER_ANDROID ++#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU + COMPILER_CHECK(sizeof(__sanitizer__obstack_chunk) <= sizeof(_obstack_chunk)); + CHECK_SIZE_AND_OFFSET(_obstack_chunk, limit); + CHECK_SIZE_AND_OFFSET(_obstack_chunk, prev); +diff --git a/lib/tsan/rtl/tsan_platform_linux.cc b/lib/tsan/rtl/tsan_platform_linux.cc +index de989b780..51a97b554 100644 +--- a/lib/tsan/rtl/tsan_platform_linux.cc ++++ b/lib/tsan/rtl/tsan_platform_linux.cc +@@ -294,7 +294,7 @@ void InitializePlatform() { + // This is required to properly "close" the fds, because we do not see internal + // closes within glibc. The code is a pure hack. + int ExtractResolvFDs(void *state, int *fds, int nfd) { +-#if SANITIZER_LINUX && !SANITIZER_ANDROID ++#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU + int cnt = 0; + struct __res_state *statp = (struct __res_state*)state; + for (int i = 0; i < MAXNS && cnt < nfd; i++) { +-- +2.19.0 + diff --git a/nixpkgs/pkgs/development/compilers/llvm/8/bintools.nix b/nixpkgs/pkgs/development/compilers/llvm/8/bintools.nix new file mode 100644 index 000000000000..72a2a7331930 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/8/bintools.nix @@ -0,0 +1,19 @@ +{ runCommand, stdenv, llvm, lld, version }: + +let + prefix = + if stdenv.hostPlatform != stdenv.targetPlatform + then "${stdenv.targetPlatform.config}-" + else ""; +in runCommand "llvm-binutils-${version}" { preferLocalBuild = true; } '' + mkdir -p $out/bin + for prog in ${lld}/bin/*; do + ln -s $prog $out/bin/${prefix}$(basename $prog) + done + for prog in ${llvm}/bin/*; do + ln -s $prog $out/bin/${prefix}$(echo $(basename $prog) | sed -e "s|llvm-||") + ln -sf $prog $out/bin/${prefix}$(basename $prog) + done + rm -f $out/bin/${prefix}cat + ln -s ${lld}/bin/lld $out/bin/${prefix}ld +'' diff --git a/nixpkgs/pkgs/development/compilers/llvm/8/clang/clang-xpc.patch b/nixpkgs/pkgs/development/compilers/llvm/8/clang/clang-xpc.patch new file mode 100644 index 000000000000..eb57d3458228 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/8/clang/clang-xpc.patch @@ -0,0 +1,41 @@ +From 61c9b97d7b81cc2c013b423bf1763a92b14fcae3 Mon Sep 17 00:00:00 2001 +From: Jan Korous <jkorous@apple.com> +Date: Tue, 26 Mar 2019 03:48:25 +0000 +Subject: [PATCH] [clangd][xpc][cmake] Respect explicit value of + CLANGD_BUILD_XPC + +We shouldn't prevent user from disabling XPC framework build on Darwin. +However, by keeping it on by default our CI systems also test +it by default on macOS. + +Based on user request: +http://lists.llvm.org/pipermail/cfe-dev/2019-March/061778.html + +Differential Revision: https://reviews.llvm.org/D59808 + +git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@356974 91177308-0d34-0410-b5e6-96231b3b80d8 +--- + CMakeLists.txt | 13 ++++++++++--- + 1 file changed, 10 insertions(+), 3 deletions(-) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 66ebeaeeaa..514b17fb3c 100644 +--- a/tools/extra/CMakeLists.txt ++++ b/tools/extra/CMakeLists.txt +@@ -1,6 +1,13 @@ +-option(CLANGD_BUILD_XPC "Build XPC Support For Clangd." OFF) +-if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") +- set(CLANGD_BUILD_XPC ON CACHE BOOL "" FORCE) ++if (NOT DEFINED CLANGD_BUILD_XPC) ++ if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") ++ set(CLANGD_BUILD_XPC_DEFAULT ON) ++ else () ++ set(CLANGD_BUILD_XPC_DEFAULT OFF) ++ endif () ++ ++ set(CLANGD_BUILD_XPC ${CLANGD_BUILD_XPC_DEFAULT} CACHE BOOL "Build XPC Support For Clangd." FORCE) ++ ++ unset(CLANGD_BUILD_XPC_DEFAULT) + endif () + + add_subdirectory(clang-apply-replacements) \ No newline at end of file diff --git a/nixpkgs/pkgs/development/compilers/llvm/8/clang/default.nix b/nixpkgs/pkgs/development/compilers/llvm/8/clang/default.nix new file mode 100644 index 000000000000..8709e47dd3aa --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/8/clang/default.nix @@ -0,0 +1,122 @@ +{ stdenv, fetch, fetchpatch, cmake, libxml2, llvm, version, clang-tools-extra_src, python +, fixDarwinDylibNames +, enableManpages ? false +, enablePolly ? false # TODO: get this info from llvm (passthru?) +}: + +let + self = stdenv.mkDerivation ({ + name = "clang-${version}"; + + unpackPhase = '' + unpackFile ${fetch "cfe" "0svk1f70hvpwrjp6x5i9kqwrqwxnmcrw5s7f4cxyd100mdd12k08"} + mv cfe-${version}* clang + sourceRoot=$PWD/clang + unpackFile ${clang-tools-extra_src} + mv clang-tools-extra-* $sourceRoot/tools/extra + ''; + + nativeBuildInputs = [ cmake python ] + ++ stdenv.lib.optional enableManpages python.pkgs.sphinx; + + buildInputs = [ libxml2 llvm ] + ++ stdenv.lib.optional stdenv.isDarwin fixDarwinDylibNames; + + cmakeFlags = [ + "-DCMAKE_CXX_FLAGS=-std=c++11" + "-DCLANGD_BUILD_XPC=OFF" + ] ++ stdenv.lib.optionals enableManpages [ + "-DCLANG_INCLUDE_DOCS=ON" + "-DLLVM_ENABLE_SPHINX=ON" + "-DSPHINX_OUTPUT_MAN=ON" + "-DSPHINX_OUTPUT_HTML=OFF" + "-DSPHINX_WARNINGS_AS_ERRORS=OFF" + ] ++ stdenv.lib.optionals enablePolly [ + "-DWITH_POLLY=ON" + "-DLINK_POLLY_INTO_TOOLS=ON" + ]; + + patches = [ + ./purity.patch + ./clang-xpc.patch + # Backport for -static-pie, which the latter touches, and which is nice in + # its own right. + ./static-pie.patch + # Backport for the `--unwindlib=[libgcc|complier-rt]` flag, which is + # needed for our bootstrapping to not interfere with C. + ./unwindlib.patch + ]; + + postPatch = '' + sed -i -e 's/DriverArgs.hasArg(options::OPT_nostdlibinc)/true/' \ + -e 's/Args.hasArg(options::OPT_nostdlibinc)/true/' \ + lib/Driver/ToolChains/*.cpp + + # Patch for standalone doc building + sed -i '1s,^,find_package(Sphinx REQUIRED)\n,' docs/CMakeLists.txt + '' + stdenv.lib.optionalString stdenv.hostPlatform.isMusl '' + sed -i -e 's/lgcc_s/lgcc_eh/' lib/Driver/ToolChains/*.cpp + '' + stdenv.lib.optionalString stdenv.hostPlatform.isDarwin '' + substituteInPlace tools/extra/clangd/CMakeLists.txt \ + --replace "NOT HAVE_CXX_ATOMICS64_WITHOUT_LIB" FALSE + ''; + + outputs = [ "out" "lib" "python" ]; + + # Clang expects to find LLVMgold in its own prefix + postInstall = '' + if [ -e ${llvm}/lib/LLVMgold.so ]; then + ln -sv ${llvm}/lib/LLVMgold.so $out/lib + fi + + ln -sv $out/bin/clang $out/bin/cpp + + # Move libclang to 'lib' output + moveToOutput "lib/libclang.*" "$lib" + substituteInPlace $out/lib/cmake/clang/ClangTargets-release.cmake \ + --replace "\''${_IMPORT_PREFIX}/lib/libclang." "$lib/lib/libclang." + + mkdir -p $python/bin $python/share/clang/ + mv $out/bin/{git-clang-format,scan-view} $python/bin + if [ -e $out/bin/set-xcode-analyzer ]; then + mv $out/bin/set-xcode-analyzer $python/bin + fi + mv $out/share/clang/*.py $python/share/clang + rm $out/bin/c-index-test + ''; + + enableParallelBuilding = true; + + passthru = { + isClang = true; + inherit llvm; + } // stdenv.lib.optionalAttrs (stdenv.targetPlatform.isLinux || (stdenv.cc.isGNU && stdenv.cc.cc ? gcc)) { + gcc = if stdenv.cc.isGNU then stdenv.cc.cc else stdenv.cc.cc.gcc; + }; + + meta = { + description = "A c, c++, objective-c, and objective-c++ frontend for the llvm compiler"; + homepage = http://llvm.org/; + license = stdenv.lib.licenses.ncsa; + platforms = stdenv.lib.platforms.all; + }; + } // stdenv.lib.optionalAttrs enableManpages { + name = "clang-manpages-${version}"; + + buildPhase = '' + make docs-clang-man + ''; + + installPhase = '' + mkdir -p $out/share/man/man1 + # Manually install clang manpage + cp docs/man/*.1 $out/share/man/man1/ + ''; + + outputs = [ "out" ]; + + doCheck = false; + + meta.description = "man page for Clang ${version}"; + }); +in self diff --git a/nixpkgs/pkgs/development/compilers/llvm/8/clang/purity.patch b/nixpkgs/pkgs/development/compilers/llvm/8/clang/purity.patch new file mode 100644 index 000000000000..b30d0d0b5d5b --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/8/clang/purity.patch @@ -0,0 +1,30 @@ +From 4add81bba40dcec62c4ea4481be8e35ac53e89d8 Mon Sep 17 00:00:00 2001 +From: Will Dietz <w@wdtz.org> +Date: Thu, 18 May 2017 11:56:12 -0500 +Subject: [PATCH] "purity" patch for 5.0 + +--- + lib/Driver/ToolChains/Gnu.cpp | 7 ------- + 1 file changed, 7 deletions(-) + +diff --git a/lib/Driver/ToolChains/Gnu.cpp b/lib/Driver/ToolChains/Gnu.cpp +index fe3c0191bb..c6a482bece 100644 +--- a/lib/Driver/ToolChains/Gnu.cpp ++++ b/lib/Driver/ToolChains/Gnu.cpp +@@ -494,13 +494,6 @@ void tools::gnutools::Linker::ConstructJob(Compilation &C, const JobAction &JA, + if (!Args.hasArg(options::OPT_static)) { + if (Args.hasArg(options::OPT_rdynamic)) + CmdArgs.push_back("-export-dynamic"); +- +- if (!Args.hasArg(options::OPT_shared)) { +- const std::string Loader = +- D.DyldPrefix + ToolChain.getDynamicLinker(Args); +- CmdArgs.push_back("-dynamic-linker"); +- CmdArgs.push_back(Args.MakeArgString(Loader)); +- } + } + + CmdArgs.push_back("-o"); +-- +2.11.0 + diff --git a/nixpkgs/pkgs/development/compilers/llvm/8/clang/static-pie.patch b/nixpkgs/pkgs/development/compilers/llvm/8/clang/static-pie.patch new file mode 100644 index 000000000000..d1f86a162327 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/8/clang/static-pie.patch @@ -0,0 +1,157 @@ +commit 7a9842bc92921e79b84630045276861be90b2d47 +Author: Siva Chandra <sivachandra@google.com> +Date: Wed Feb 20 19:07:04 2019 +0000 + + [Clang Driver] Add support for "-static-pie" argument to the Clang driver. + + Summary: This change mimics GCC's support for the "-static-pie" argument. + + Subscribers: cfe-commits + + Tags: #clang + + Differential Revision: https://reviews.llvm.org/D58307 + + git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@354502 91177308-0d34-0410-b5e6-96231b3b80d8 + (cherry picked from commit 7d6cd7825e6883f8650e32b07f3750824c2cef62) + +diff --git a/include/clang/Driver/Options.td b/include/clang/Driver/Options.td +index d02d9744d7..75a21e66c7 100644 +--- a/include/clang/Driver/Options.td ++++ b/include/clang/Driver/Options.td +@@ -2502,6 +2502,7 @@ def pthread : Flag<["-"], "pthread">, Flags<[CC1Option]>, + def no_pthread : Flag<["-"], "no-pthread">, Flags<[CC1Option]>; + def p : Flag<["-"], "p">; + def pie : Flag<["-"], "pie">; ++def static_pie : Flag<["-"], "static-pie">; + def read__only__relocs : Separate<["-"], "read_only_relocs">; + def remap : Flag<["-"], "remap">; + def rewrite_objc : Flag<["-"], "rewrite-objc">, Flags<[DriverOption,CC1Option]>, +diff --git a/lib/Driver/ToolChains/CommonArgs.cpp b/lib/Driver/ToolChains/CommonArgs.cpp +index d7e316befa..85ffc1618d 100644 +--- a/lib/Driver/ToolChains/CommonArgs.cpp ++++ b/lib/Driver/ToolChains/CommonArgs.cpp +@@ -1138,19 +1138,22 @@ static void AddLibgcc(const llvm::Triple &Triple, const Driver &D, + bool isCygMing = Triple.isOSCygMing(); + bool IsIAMCU = Triple.isOSIAMCU(); + bool StaticLibgcc = Args.hasArg(options::OPT_static_libgcc) || +- Args.hasArg(options::OPT_static); ++ Args.hasArg(options::OPT_static) || ++ Args.hasArg(options::OPT_static_pie); + + bool SharedLibgcc = Args.hasArg(options::OPT_shared_libgcc); + bool UnspecifiedLibgcc = !StaticLibgcc && !SharedLibgcc; + + // Gcc adds libgcc arguments in various ways: + // +- // gcc <none>: -lgcc --as-needed -lgcc_s --no-as-needed +- // g++ <none>: -lgcc_s -lgcc +- // gcc shared: -lgcc_s -lgcc +- // g++ shared: -lgcc_s -lgcc +- // gcc static: -lgcc -lgcc_eh +- // g++ static: -lgcc -lgcc_eh ++ // gcc <none>: -lgcc --as-needed -lgcc_s --no-as-needed ++ // g++ <none>: -lgcc_s -lgcc ++ // gcc shared: -lgcc_s -lgcc ++ // g++ shared: -lgcc_s -lgcc ++ // gcc static: -lgcc -lgcc_eh ++ // g++ static: -lgcc -lgcc_eh ++ // gcc static-pie: -lgcc -lgcc_eh ++ // g++ static-pie: -lgcc -lgcc_eh + // + // Also, certain targets need additional adjustments. + +diff --git a/lib/Driver/ToolChains/Gnu.cpp b/lib/Driver/ToolChains/Gnu.cpp +index 69dba8fec8..0faa0bb473 100644 +--- a/lib/Driver/ToolChains/Gnu.cpp ++++ b/lib/Driver/ToolChains/Gnu.cpp +@@ -334,6 +334,7 @@ void tools::gnutools::Linker::ConstructJob(Compilation &C, const JobAction &JA, + const bool isAndroid = ToolChain.getTriple().isAndroid(); + const bool IsIAMCU = ToolChain.getTriple().isOSIAMCU(); + const bool IsPIE = getPIE(Args, ToolChain); ++ const bool IsStaticPIE = Args.hasArg(options::OPT_static_pie); + const bool HasCRTBeginEndFiles = + ToolChain.getTriple().hasEnvironment() || + (ToolChain.getTriple().getVendor() != llvm::Triple::MipsTechnologies); +@@ -354,6 +355,12 @@ void tools::gnutools::Linker::ConstructJob(Compilation &C, const JobAction &JA, + if (IsPIE) + CmdArgs.push_back("-pie"); + ++ if (IsStaticPIE) { ++ CmdArgs.push_back("-static"); ++ CmdArgs.push_back("-pie"); ++ CmdArgs.push_back("--no-dynamic-linker"); ++ } ++ + if (Args.hasArg(options::OPT_rdynamic)) + CmdArgs.push_back("-export-dynamic"); + +@@ -415,6 +422,8 @@ void tools::gnutools::Linker::ConstructJob(Compilation &C, const JobAction &JA, + crt1 = "gcrt1.o"; + else if (IsPIE) + crt1 = "Scrt1.o"; ++ else if (IsStaticPIE) ++ crt1 = "rcrt1.o"; + else + crt1 = "crt1.o"; + } +@@ -432,7 +441,7 @@ void tools::gnutools::Linker::ConstructJob(Compilation &C, const JobAction &JA, + crtbegin = isAndroid ? "crtbegin_static.o" : "crtbeginT.o"; + else if (Args.hasArg(options::OPT_shared)) + crtbegin = isAndroid ? "crtbegin_so.o" : "crtbeginS.o"; +- else if (IsPIE) ++ else if (IsPIE || IsStaticPIE) + crtbegin = isAndroid ? "crtbegin_dynamic.o" : "crtbeginS.o"; + else + crtbegin = isAndroid ? "crtbegin_dynamic.o" : "crtbegin.o"; +@@ -483,7 +492,7 @@ void tools::gnutools::Linker::ConstructJob(Compilation &C, const JobAction &JA, + + if (!Args.hasArg(options::OPT_nostdlib)) { + if (!Args.hasArg(options::OPT_nodefaultlibs)) { +- if (Args.hasArg(options::OPT_static)) ++ if (Args.hasArg(options::OPT_static) || IsStaticPIE) + CmdArgs.push_back("--start-group"); + + if (NeedsSanitizerDeps) +@@ -518,7 +527,7 @@ void tools::gnutools::Linker::ConstructJob(Compilation &C, const JobAction &JA, + if (IsIAMCU) + CmdArgs.push_back("-lgloss"); + +- if (Args.hasArg(options::OPT_static)) ++ if (Args.hasArg(options::OPT_static) || IsStaticPIE) + CmdArgs.push_back("--end-group"); + else + AddRunTimeLibs(ToolChain, D, CmdArgs, Args); +@@ -535,7 +544,7 @@ void tools::gnutools::Linker::ConstructJob(Compilation &C, const JobAction &JA, + const char *crtend; + if (Args.hasArg(options::OPT_shared)) + crtend = isAndroid ? "crtend_so.o" : "crtendS.o"; +- else if (IsPIE) ++ else if (IsPIE || IsStaticPIE) + crtend = isAndroid ? "crtend_android.o" : "crtendS.o"; + else + crtend = isAndroid ? "crtend_android.o" : "crtend.o"; +diff --git a/test/Driver/linux-ld.c b/test/Driver/linux-ld.c +index 3ab81be490..800f782523 100644 +--- a/test/Driver/linux-ld.c ++++ b/test/Driver/linux-ld.c +@@ -176,6 +176,19 @@ + // CHECK-CLANG-NO-LIBGCC-STATIC: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]" + // CHECK-CLANG-NO-LIBGCC-STATIC: "--start-group" "-lgcc" "-lgcc_eh" "-lc" "--end-group" + // ++// RUN: %clang -static-pie -no-canonical-prefixes %s -### -o %t.o 2>&1 \ ++// RUN: --target=x86_64-unknown-linux -rtlib=platform \ ++// RUN: --gcc-toolchain="" \ ++// RUN: --sysroot=%S/Inputs/basic_linux_tree \ ++// RUN: | FileCheck --check-prefix=CHECK-CLANG-LD-STATIC-PIE %s ++// CHECK-CLANG-LD-STATIC-PIE: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]" ++// CHECK-CLANG-LD-STATIC-PIE: "-static" ++// CHECK-CLANG-LD-STATIC-PIE: "-pie" ++// CHECK-CLANG-LD-STATIC-PIE: "--no-dynamic-linker" ++// CHECK-CLANG-LD-STATIC-PIE: "-m" "elf_x86_64" ++// CHECK-CLANG-LD-STATIC-PIE: "{{.*}}rcrt1.o" ++// CHECK-CLANG-LD-STATIC-PIE: "--start-group" "-lgcc" "-lgcc_eh" "-lc" "--end-group" ++// + // RUN: %clang -dynamic -no-canonical-prefixes %s -### -o %t.o 2>&1 \ + // RUN: --target=x86_64-unknown-linux -rtlib=platform \ + // RUN: --gcc-toolchain="" \ diff --git a/nixpkgs/pkgs/development/compilers/llvm/8/clang/unwindlib.patch b/nixpkgs/pkgs/development/compilers/llvm/8/clang/unwindlib.patch new file mode 100644 index 000000000000..6958fce60cef --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/8/clang/unwindlib.patch @@ -0,0 +1,372 @@ +commit cd5603a4767277a29d3e67a9c3f2a5d2129cd973 +Author: Sterling Augustine <saugustine@google.com> +Date: Tue Mar 19 20:01:59 2019 +0000 + + Add --unwindlib=[libgcc|compiler-rt] to parallel --rtlib= [take 2] + + "clang++ hello.cc --rtlib=compiler-rt" + + now can works without specifying additional unwind or exception + handling libraries. + + This reworked version of the feature no longer modifies today's default + unwind library for compiler-rt: which is nothing. Rather, a user + can specify -DCLANG_DEFAULT_UNWINDLIB=libunwind when configuring + the compiler. + + This should address the issues from the previous version. + + Update tests for new --unwindlib semantics. + + Differential Revision: https://reviews.llvm.org/D59109 + + git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@356508 91177308-0d34-0410-b5e6-96231b3b80d8 + (cherry picked from commit 344aa82a52f2fae527f58284567ae305a314f7a8) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index c2016a45ca..edeb2b66a1 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -261,6 +261,24 @@ if (NOT(CLANG_DEFAULT_RTLIB STREQUAL "" OR + "Default runtime library to use (\"libgcc\" or \"compiler-rt\", empty for platform default)" FORCE) + endif() + ++set(CLANG_DEFAULT_UNWINDLIB "" CACHE STRING ++ "Default unwind library to use (\"none\" \"libgcc\" or \"libunwind\", empty to match runtime library.)") ++if (CLANG_DEFAULT_UNWINDLIB STREQUAL "") ++ if (CLANG_DEFAULT_RTLIB STREQUAL "libgcc") ++ set (CLANG_DEFAULT_UNWINDLIB "libgcc" CACHE STRING "" FORCE) ++ elseif (CLANG_DEFAULT_RTLIBS STREQUAL "libunwind") ++ set (CLANG_DEFAULT_UNWINDLIB "none" CACHE STRING "" FORCE) ++ endif() ++endif() ++ ++if (NOT(CLANG_DEFAULT_UNWINDLIB STREQUAL "none" OR ++ CLANG_DEFAULT_UNWINDLIB STREQUAL "libgcc" OR ++ CLANG_DEFAULT_UNWINDLIB STREQUAL "libunwind")) ++ message(WARNING "Resetting default unwindlib to use platform default") ++ set(CLANG_DEFAULT_UNWINDLIB "" CACHE STRING ++ "Default unwind library to use (\"none\" \"libgcc\" or \"libunwind\", empty for none)" FORCE) ++endif() ++ + set(CLANG_DEFAULT_OBJCOPY "objcopy" CACHE STRING + "Default objcopy executable to use.") + +diff --git a/include/clang/Basic/DiagnosticDriverKinds.td b/include/clang/Basic/DiagnosticDriverKinds.td +index 5475e28ed7..15971210e4 100644 +--- a/include/clang/Basic/DiagnosticDriverKinds.td ++++ b/include/clang/Basic/DiagnosticDriverKinds.td +@@ -52,6 +52,10 @@ def err_drv_invalid_rtlib_name : Error< + "invalid runtime library name in argument '%0'">; + def err_drv_unsupported_rtlib_for_platform : Error< + "unsupported runtime library '%0' for platform '%1'">; ++def err_drv_invalid_unwindlib_name : Error< ++ "invalid unwind library name in argument '%0'">; ++def err_drv_incompatible_unwindlib : Error< ++ "--rtlib=libgcc requires --unwindlib=libgcc">; + def err_drv_invalid_stdlib_name : Error< + "invalid library name in argument '%0'">; + def err_drv_invalid_output_with_multiple_archs : Error< +diff --git a/include/clang/Config/config.h.cmake b/include/clang/Config/config.h.cmake +index 1d624450b9..2d4cb747e8 100644 +--- a/include/clang/Config/config.h.cmake ++++ b/include/clang/Config/config.h.cmake +@@ -23,6 +23,9 @@ + /* Default runtime library to use. */ + #define CLANG_DEFAULT_RTLIB "${CLANG_DEFAULT_RTLIB}" + ++/* Default unwind library to use. */ ++#define CLANG_DEFAULT_UNWINDLIB "${CLANG_DEFAULT_UNWINDLIB}" ++ + /* Default objcopy to use */ + #define CLANG_DEFAULT_OBJCOPY "${CLANG_DEFAULT_OBJCOPY}" + +diff --git a/include/clang/Driver/Options.td b/include/clang/Driver/Options.td +index 75a21e66c7..4da0e54965 100644 +--- a/include/clang/Driver/Options.td ++++ b/include/clang/Driver/Options.td +@@ -2570,6 +2570,8 @@ def std_EQ : Joined<["-", "--"], "std=">, Flags<[CC1Option]>, + }]>; + def stdlib_EQ : Joined<["-", "--"], "stdlib=">, Flags<[CC1Option]>, + HelpText<"C++ standard library to use">, Values<"libc++,libstdc++,platform">; ++def unwindlib_EQ : Joined<["-", "--"], "unwindlib=">, Flags<[CC1Option]>, ++ HelpText<"Unwind library to use">, Values<"libgcc,unwindlib,platform">; + def sub__library : JoinedOrSeparate<["-"], "sub_library">; + def sub__umbrella : JoinedOrSeparate<["-"], "sub_umbrella">; + def system_header_prefix : Joined<["--"], "system-header-prefix=">, +diff --git a/include/clang/Driver/ToolChain.h b/include/clang/Driver/ToolChain.h +index d5f75b8271..4bedf760eb 100644 +--- a/include/clang/Driver/ToolChain.h ++++ b/include/clang/Driver/ToolChain.h +@@ -100,6 +100,12 @@ public: + RLT_Libgcc + }; + ++ enum UnwindLibType { ++ UNW_None, ++ UNW_CompilerRT, ++ UNW_Libgcc ++ }; ++ + enum RTTIMode { + RM_Enabled, + RM_Disabled, +@@ -368,6 +374,10 @@ public: + return ToolChain::CST_Libstdcxx; + } + ++ virtual UnwindLibType GetDefaultUnwindLibType() const { ++ return ToolChain::UNW_None; ++ } ++ + virtual std::string getCompilerRTPath() const; + + virtual std::string getCompilerRT(const llvm::opt::ArgList &Args, +@@ -512,6 +522,10 @@ public: + // given compilation arguments. + virtual CXXStdlibType GetCXXStdlibType(const llvm::opt::ArgList &Args) const; + ++ // GetUnwindLibType - Determine the unwind library type to use with the ++ // given compilation arguments. ++ virtual UnwindLibType GetUnwindLibType(const llvm::opt::ArgList &Args) const; ++ + /// AddClangCXXStdlibIncludeArgs - Add the clang -cc1 level arguments to set + /// the include paths to use for the given C++ standard library type. + virtual void +diff --git a/lib/Driver/ToolChain.cpp b/lib/Driver/ToolChain.cpp +index 88a627eab6..d82423f4a8 100644 +--- a/lib/Driver/ToolChain.cpp ++++ b/lib/Driver/ToolChain.cpp +@@ -680,6 +680,33 @@ ToolChain::RuntimeLibType ToolChain::GetRuntimeLibType( + return GetDefaultRuntimeLibType(); + } + ++ToolChain::UnwindLibType ToolChain::GetUnwindLibType( ++ const ArgList &Args) const { ++ const Arg *A = Args.getLastArg(options::OPT_unwindlib_EQ); ++ StringRef LibName = A ? A->getValue() : CLANG_DEFAULT_UNWINDLIB; ++ ++ if (LibName == "none") ++ return ToolChain::UNW_None; ++ else if (LibName == "platform" || LibName == "") { ++ ToolChain::RuntimeLibType RtLibType = GetRuntimeLibType(Args); ++ if (RtLibType == ToolChain::RLT_CompilerRT) ++ return ToolChain::UNW_None; ++ else if (RtLibType == ToolChain::RLT_Libgcc) ++ return ToolChain::UNW_Libgcc; ++ } else if (LibName == "libunwind") { ++ if (GetRuntimeLibType(Args) == RLT_Libgcc) ++ getDriver().Diag(diag::err_drv_incompatible_unwindlib); ++ return ToolChain::UNW_CompilerRT; ++ } else if (LibName == "libgcc") ++ return ToolChain::UNW_Libgcc; ++ ++ if (A) ++ getDriver().Diag(diag::err_drv_invalid_unwindlib_name) ++ << A->getAsString(Args); ++ ++ return GetDefaultUnwindLibType(); ++} ++ + ToolChain::CXXStdlibType ToolChain::GetCXXStdlibType(const ArgList &Args) const{ + const Arg *A = Args.getLastArg(options::OPT_stdlib_EQ); + StringRef LibName = A ? A->getValue() : CLANG_DEFAULT_CXX_STDLIB; +diff --git a/lib/Driver/ToolChains/CommonArgs.cpp b/lib/Driver/ToolChains/CommonArgs.cpp +index 85ffc1618d..9fd29726a4 100644 +--- a/lib/Driver/ToolChains/CommonArgs.cpp ++++ b/lib/Driver/ToolChains/CommonArgs.cpp +@@ -1132,47 +1132,80 @@ bool tools::isObjCAutoRefCount(const ArgList &Args) { + return Args.hasFlag(options::OPT_fobjc_arc, options::OPT_fno_objc_arc, false); + } + +-static void AddLibgcc(const llvm::Triple &Triple, const Driver &D, +- ArgStringList &CmdArgs, const ArgList &Args) { +- bool isAndroid = Triple.isAndroid(); +- bool isCygMing = Triple.isOSCygMing(); +- bool IsIAMCU = Triple.isOSIAMCU(); +- bool StaticLibgcc = Args.hasArg(options::OPT_static_libgcc) || +- Args.hasArg(options::OPT_static) || +- Args.hasArg(options::OPT_static_pie); +- +- bool SharedLibgcc = Args.hasArg(options::OPT_shared_libgcc); +- bool UnspecifiedLibgcc = !StaticLibgcc && !SharedLibgcc; +- +- // Gcc adds libgcc arguments in various ways: +- // +- // gcc <none>: -lgcc --as-needed -lgcc_s --no-as-needed +- // g++ <none>: -lgcc_s -lgcc +- // gcc shared: -lgcc_s -lgcc +- // g++ shared: -lgcc_s -lgcc +- // gcc static: -lgcc -lgcc_eh +- // g++ static: -lgcc -lgcc_eh +- // gcc static-pie: -lgcc -lgcc_eh +- // g++ static-pie: -lgcc -lgcc_eh +- // +- // Also, certain targets need additional adjustments. ++enum class LibGccType { UnspecifiedLibGcc, StaticLibGcc, SharedLibGcc }; ++ ++static LibGccType getLibGccType(const ArgList &Args) { ++ bool Static = Args.hasArg(options::OPT_static_libgcc) || ++ Args.hasArg(options::OPT_static) || ++ Args.hasArg(options::OPT_static_pie); ++ ++ bool Shared = Args.hasArg(options::OPT_shared_libgcc); ++ if (Shared) ++ return LibGccType::SharedLibGcc; ++ if (Static) ++ return LibGccType::StaticLibGcc; ++ return LibGccType::UnspecifiedLibGcc; ++} + +- bool LibGccFirst = (D.CCCIsCC() && UnspecifiedLibgcc) || StaticLibgcc; +- if (LibGccFirst) +- CmdArgs.push_back("-lgcc"); ++// Gcc adds libgcc arguments in various ways: ++// ++// gcc <none>: -lgcc --as-needed -lgcc_s --no-as-needed ++// g++ <none>: -lgcc_s -lgcc ++// gcc shared: -lgcc_s -lgcc ++// g++ shared: -lgcc_s -lgcc ++// gcc static: -lgcc -lgcc_eh ++// g++ static: -lgcc -lgcc_eh ++// gcc static-pie: -lgcc -lgcc_eh ++// g++ static-pie: -lgcc -lgcc_eh ++// ++// Also, certain targets need additional adjustments. ++ ++static void AddUnwindLibrary(const ToolChain &TC, const Driver &D, ++ ArgStringList &CmdArgs, const ArgList &Args) { ++ ToolChain::UnwindLibType UNW = TC.GetUnwindLibType(Args); ++ // Targets that don't use unwind libraries. ++ if (TC.getTriple().isAndroid() || TC.getTriple().isOSIAMCU() || ++ TC.getTriple().isOSBinFormatWasm() || ++ UNW == ToolChain::UNW_None) ++ return; + +- bool AsNeeded = D.CCCIsCC() && UnspecifiedLibgcc && !isAndroid && !isCygMing; ++ LibGccType LGT = getLibGccType(Args); ++ bool AsNeeded = D.CCCIsCC() && LGT == LibGccType::UnspecifiedLibGcc && ++ !TC.getTriple().isAndroid() && !TC.getTriple().isOSCygMing(); + if (AsNeeded) + CmdArgs.push_back("--as-needed"); + +- if ((UnspecifiedLibgcc || SharedLibgcc) && !isAndroid) +- CmdArgs.push_back("-lgcc_s"); +- +- else if (StaticLibgcc && !isAndroid && !IsIAMCU) +- CmdArgs.push_back("-lgcc_eh"); ++ switch (UNW) { ++ case ToolChain::UNW_None: ++ return; ++ case ToolChain::UNW_Libgcc: { ++ LibGccType LGT = getLibGccType(Args); ++ if (LGT == LibGccType::UnspecifiedLibGcc || LGT == LibGccType::SharedLibGcc) ++ CmdArgs.push_back("-lgcc_s"); ++ else if (LGT == LibGccType::StaticLibGcc) ++ CmdArgs.push_back("-lgcc_eh"); ++ break; ++ } ++ case ToolChain::UNW_CompilerRT: ++ CmdArgs.push_back("-lunwind"); ++ break; ++ } + + if (AsNeeded) + CmdArgs.push_back("--no-as-needed"); ++} ++ ++static void AddLibgcc(const ToolChain &TC, const Driver &D, ++ ArgStringList &CmdArgs, const ArgList &Args) { ++ bool isAndroid = TC.getTriple().isAndroid(); ++ ++ LibGccType LGT = getLibGccType(Args); ++ bool LibGccFirst = (D.CCCIsCC() && LGT == LibGccType::UnspecifiedLibGcc) || ++ LGT == LibGccType::StaticLibGcc; ++ if (LibGccFirst) ++ CmdArgs.push_back("-lgcc"); ++ ++ AddUnwindLibrary(TC, D, CmdArgs, Args); + + if (!LibGccFirst) + CmdArgs.push_back("-lgcc"); +@@ -1182,7 +1215,7 @@ static void AddLibgcc(const llvm::Triple &Triple, const Driver &D, + // + // NOTE: This fixes a link error on Android MIPS as well. The non-static + // libgcc for MIPS relies on _Unwind_Find_FDE and dl_iterate_phdr from libdl. +- if (isAndroid && !StaticLibgcc) ++ if (isAndroid && getLibGccType(Args) != LibGccType::StaticLibGcc) + CmdArgs.push_back("-ldl"); + } + +@@ -1194,6 +1227,7 @@ void tools::AddRunTimeLibs(const ToolChain &TC, const Driver &D, + switch (RLT) { + case ToolChain::RLT_CompilerRT: + CmdArgs.push_back(TC.getCompilerRTArgString(Args, "builtins")); ++ AddUnwindLibrary(TC, D, CmdArgs, Args); + break; + case ToolChain::RLT_Libgcc: + // Make sure libgcc is not used under MSVC environment by default +@@ -1205,7 +1239,7 @@ void tools::AddRunTimeLibs(const ToolChain &TC, const Driver &D, + << Args.getLastArg(options::OPT_rtlib_EQ)->getValue() << "MSVC"; + } + } else +- AddLibgcc(TC.getTriple(), D, CmdArgs, Args); ++ AddLibgcc(TC, D, CmdArgs, Args); + break; + } + } +diff --git a/test/Driver/compiler-rt-unwind.c b/test/Driver/compiler-rt-unwind.c +new file mode 100644 +index 0000000000..00024dfa7e +--- /dev/null ++++ b/test/Driver/compiler-rt-unwind.c +@@ -0,0 +1,49 @@ ++// General tests that the driver handles combinations of --rtlib=XXX and ++// --unwindlib=XXX properly. ++// ++// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ ++// RUN: --target=x86_64-unknown-linux \ ++// RUN: --gcc-toolchain="" \ ++// RUN: | FileCheck --check-prefix=RTLIB-EMPTY %s ++// RTLIB-EMPTY: "{{.*}}lgcc" ++// RTLIB-EMPTY: "{{.*}}-lgcc_s" ++// ++// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ ++// RUN: --target=x86_64-unknown-linux -rtlib=libgcc \ ++// RUN: --gcc-toolchain="" \ ++// RUN: | FileCheck --check-prefix=RTLIB-GCC %s ++// RTLIB-GCC: "{{.*}}lgcc" ++// RTLIB-GCC: "{{.*}}lgcc_s" ++// ++// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ ++// RUN: --target=x86_64-unknown-linux -rtlib=libgcc --unwindlib=libunwind \ ++// RUN: --gcc-toolchain="" \ ++// RUN: | FileCheck --check-prefix=RTLIB-GCC-UNWINDLIB-COMPILER-RT %s ++// RTLIB-GCC-UNWINDLIB-COMPILER-RT: "{{.*}}lgcc" ++// RTLIB-GCC-UNWINDLIB-COMPILER-RT: "{{.*}}lunwind" ++// ++// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ ++// RUN: --target=x86_64-unknown-linux -rtlib=compiler-rt \ ++// RUN: --gcc-toolchain="" \ ++// RUN: | FileCheck --check-prefix=RTLIB-COMPILER-RT %s ++// RTLIB-COMPILER-RT: "{{.*}}libclang_rt.builtins-x86_64.a" ++// ++// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ ++// RUN: --target=x86_64-unknown-linux -rtlib=compiler-rt --unwindlib=libgcc \ ++// RUN: --gcc-toolchain="" \ ++// RUN: | FileCheck --check-prefix=RTLIB-COMPILER-RT-UNWINDLIB-GCC %s ++// RTLIB-COMPILER-RT-UNWINDLIB-GCC: "{{.*}}libclang_rt.builtins-x86_64.a" ++// RTLIB-COMPILER-RT-UNWINDLIB-GCC: "{{.*}}lgcc_s" ++// ++// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ ++// RUN: --target=x86_64-unknown-linux -rtlib=compiler-rt --unwindlib=libgcc \ ++// RUN: -static --gcc-toolchain="" \ ++// RUN: | FileCheck --check-prefix=RTLIB-COMPILER-RT-UNWINDLIB-GCC-STATIC %s ++// RTLIB-COMPILER-RT-UNWINDLIB-GCC-STATIC: "{{.*}}libclang_rt.builtins-x86_64.a" ++// RTLIB-COMPILER-RT-UNWINDLIB-GCC-STATIC: "{{.*}}lgcc_eh" ++// ++// RUN: not %clang -no-canonical-prefixes %s -o %t.o 2> %t.err \ ++// RUN: --target=x86_64-unknown-linux -rtlib=libgcc --unwindlib=libunwind \ ++// RUN: --gcc-toolchain="" \ ++// RUN: FileCheck --input-file=%t.err --check-prefix=RTLIB-GCC-UNWINDLIB-COMPILER_RT %s ++// RTLIB-GCC-UNWINDLIB-COMPILER_RT: "{{[.|\\\n]*}}--rtlib=libgcc requires --unwindlib=libgcc" diff --git a/nixpkgs/pkgs/development/compilers/llvm/8/compiler-rt-clock_gettime.patch b/nixpkgs/pkgs/development/compilers/llvm/8/compiler-rt-clock_gettime.patch new file mode 100644 index 000000000000..f9323ed95c05 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/8/compiler-rt-clock_gettime.patch @@ -0,0 +1,74 @@ +commit f00c7bccf7955b7dfbb4859fd9019e9eb3349f2d +Author: Tobias Mayer <tobim@fastmail.fm> +Date: Wed Feb 13 12:44:17 2019 +0100 + + Provide clock_gettime for xray on macos < 10.12 + +diff --git a/lib/xray/xray_basic_logging.cc b/lib/xray/xray_basic_logging.cc +index a46c151af..38aea6932 100644 +--- a/lib/xray/xray_basic_logging.cc ++++ b/lib/xray/xray_basic_logging.cc +@@ -36,6 +36,29 @@ + #include "xray_tsc.h" + #include "xray_utils.h" + ++#if __MACH__ ++#include <mach/clock.h> ++#include <mach/mach.h> ++enum clockid_t { ++ CLOCK_MONOTONIC = REALTIME_CLOCK, ++ CLOCK_REALTIME = REALTIME_CLOCK ++}; ++ ++int clock_gettime(clockid_t clock_id, struct timespec *ts) { ++ if (ts != NULL) { ++ clock_serv_t cclock; ++ mach_timespec_t mts; ++ host_get_clock_service(mach_host_self(), clock_id, &cclock); ++ clock_get_time(cclock, &mts); ++ mach_port_deallocate(mach_task_self(), cclock); ++ ts->tv_sec = mts.tv_sec; ++ ts->tv_nsec = mts.tv_nsec; ++ return 0; ++ } ++ return -1; ++} ++#endif ++ + namespace __xray { + + SpinMutex LogMutex; +diff --git a/lib/xray/xray_fdr_logging.cc b/lib/xray/xray_fdr_logging.cc +index 4b308b27f..1d044c8fd 100644 +--- a/lib/xray/xray_fdr_logging.cc ++++ b/lib/xray/xray_fdr_logging.cc +@@ -38,6 +38,29 @@ + #include "xray_tsc.h" + #include "xray_utils.h" + ++#if __MACH__ ++#include <mach/clock.h> ++#include <mach/mach.h> ++enum clockid_t { ++ CLOCK_MONOTONIC = REALTIME_CLOCK, ++ CLOCK_REALTIME = REALTIME_CLOCK ++}; ++ ++int clock_gettime(clockid_t clock_id, struct timespec *ts) { ++ if (ts != NULL) { ++ clock_serv_t cclock; ++ mach_timespec_t mts; ++ host_get_clock_service(mach_host_self(), clock_id, &cclock); ++ clock_get_time(cclock, &mts); ++ mach_port_deallocate(mach_task_self(), cclock); ++ ts->tv_sec = mts.tv_sec; ++ ts->tv_nsec = mts.tv_nsec; ++ return 0; ++ } ++ return -1; ++} ++#endif ++ + namespace __xray { + + atomic_sint32_t LoggingStatus = {XRayLogInitStatus::XRAY_LOG_UNINITIALIZED}; diff --git a/nixpkgs/pkgs/development/compilers/llvm/8/compiler-rt-codesign.patch b/nixpkgs/pkgs/development/compilers/llvm/8/compiler-rt-codesign.patch new file mode 100644 index 000000000000..3cc12b94b200 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/8/compiler-rt-codesign.patch @@ -0,0 +1,33 @@ +From 3dec5f3475a26aeb4678627795c4b67c6b7b4785 Mon Sep 17 00:00:00 2001 +From: Will Dietz <w@wdtz.org> +Date: Tue, 19 Sep 2017 13:13:06 -0500 +Subject: [PATCH] remove codesign use on Apple, disable ios sim testing that + needs it + +--- + cmake/Modules/AddCompilerRT.cmake | 8 ------ + test/asan/CMakeLists.txt | 52 --------------------------------------- + test/tsan/CMakeLists.txt | 47 ----------------------------------- + 3 files changed, 107 deletions(-) + +diff --git a/cmake/Modules/AddCompilerRT.cmake b/cmake/Modules/AddCompilerRT.cmake +index bc5fb9ff7..b64eb4246 100644 +--- a/cmake/Modules/AddCompilerRT.cmake ++++ b/cmake/Modules/AddCompilerRT.cmake +@@ -210,14 +210,6 @@ function(add_compiler_rt_runtime name type) + set_target_properties(${libname} PROPERTIES IMPORT_PREFIX "") + set_target_properties(${libname} PROPERTIES IMPORT_SUFFIX ".lib") + endif() +- if(APPLE) +- # Ad-hoc sign the dylibs +- add_custom_command(TARGET ${libname} +- POST_BUILD +- COMMAND codesign --sign - $<TARGET_FILE:${libname}> +- WORKING_DIRECTORY ${COMPILER_RT_LIBRARY_OUTPUT_DIR} +- ) +- endif() + endif() + install(TARGETS ${libname} + ARCHIVE DESTINATION ${COMPILER_RT_LIBRARY_INSTALL_DIR} +2.14.1 + diff --git a/nixpkgs/pkgs/development/compilers/llvm/8/compiler-rt.nix b/nixpkgs/pkgs/development/compilers/llvm/8/compiler-rt.nix new file mode 100644 index 000000000000..2b591cc94aff --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/8/compiler-rt.nix @@ -0,0 +1,68 @@ +{ stdenv, version, fetch, cmake, python, llvm, libcxxabi }: +stdenv.mkDerivation rec { + name = "compiler-rt-${version}"; + inherit version; + src = fetch "compiler-rt" "1c919wsm17xnv7lr8bhpq2wkq8113lzlw6hzhfr737j59x3wfddl"; + + nativeBuildInputs = [ cmake python llvm ]; + buildInputs = stdenv.lib.optional stdenv.hostPlatform.isDarwin libcxxabi; + + cmakeFlags = [ + "-DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON" + "-DCMAKE_C_COMPILER_TARGET=${stdenv.hostPlatform.config}" + "-DCMAKE_ASM_COMPILER_TARGET=${stdenv.hostPlatform.config}" + ] ++ stdenv.lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [ + "-DCMAKE_C_FLAGS=-nodefaultlibs" + "-DCMAKE_CXX_COMPILER_WORKS=ON" + "-DCOMPILER_RT_BUILD_SANITIZERS=OFF" + "-DCOMPILER_RT_BUILD_XRAY=OFF" + "-DCOMPILER_RT_BUILD_LIBFUZZER=OFF" + "-DCOMPILER_RT_BUILD_PROFILE=OFF" + "-DCOMPILER_RT_BAREMETAL_BUILD=ON" + #https://stackoverflow.com/questions/53633705/cmake-the-c-compiler-is-not-able-to-compile-a-simple-test-program + "-DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY" + "-DCMAKE_SIZEOF_VOID_P=${toString (stdenv.hostPlatform.parsed.cpu.bits / 8)}" + ] ++ stdenv.lib.optionals stdenv.hostPlatform.isMusl [ + "-DCOMPILER_RT_BUILD_SANITIZERS=OFF" + "-DCOMPILER_RT_BUILD_XRAY=OFF" + "-DCOMPILER_RT_BUILD_LIBFUZZER=OFF" + "-DCOMPILER_RT_BUILD_PROFILE=OFF" + ]; + + outputs = [ "out" "dev" ]; + + patches = [ + ./compiler-rt-codesign.patch # Revert compiler-rt commit that makes codesign mandatory + ]# ++ stdenv.lib.optional stdenv.hostPlatform.isMusl ./sanitizers-nongnu.patch + ++ stdenv.lib.optional (stdenv.hostPlatform != stdenv.buildPlatform) ./crtbegin-and-end.patch + ++ stdenv.lib.optional stdenv.hostPlatform.isDarwin ./compiler-rt-clock_gettime.patch; + + # TSAN requires XPC on Darwin, which we have no public/free source files for. We can depend on the Apple frameworks + # to get it, but they're unfree. Since LLVM is rather central to the stdenv, we patch out TSAN support so that Hydra + # can build this. If we didn't do it, basically the entire nixpkgs on Darwin would have an unfree dependency and we'd + # get no binary cache for the entire platform. If you really find yourself wanting the TSAN, make this controllable by + # a flag and turn the flag off during the stdenv build. + postPatch = stdenv.lib.optionalString stdenv.isDarwin '' + substituteInPlace cmake/config-ix.cmake \ + --replace 'set(COMPILER_RT_HAS_TSAN TRUE)' 'set(COMPILER_RT_HAS_TSAN FALSE)' + '' + stdenv.lib.optionalString (stdenv.hostPlatform != stdenv.buildPlatform) '' + substituteInPlace lib/builtins/int_util.c \ + --replace "#include <stdlib.h>" "" + substituteInPlace lib/builtins/clear_cache.c \ + --replace "#include <assert.h>" "" + substituteInPlace lib/builtins/cpu_model.c \ + --replace "#include <assert.h>" "" + ''; + + # Hack around weird upsream RPATH bug + postInstall = stdenv.lib.optionalString (stdenv.hostPlatform.isDarwin || stdenv.hostPlatform.isWasm) '' + ln -s "$out/lib"/*/* "$out/lib" + '' + stdenv.lib.optionalString (stdenv.hostPlatform.useLLVM or false) '' + ln -s $out/lib/*/clang_rt.crtbegin-*.o $out/lib/crtbegin.o + ln -s $out/lib/*/clang_rt.crtend-*.o $out/lib/crtend.o + ln -s $out/lib/*/clang_rt.crtbegin_shared-*.o $out/lib/crtbeginS.o + ln -s $out/lib/*/clang_rt.crtend_shared-*.o $out/lib/crtendS.o + ''; + + enableParallelBuilding = true; +} diff --git a/nixpkgs/pkgs/development/compilers/llvm/8/crtbegin-and-end.patch b/nixpkgs/pkgs/development/compilers/llvm/8/crtbegin-and-end.patch new file mode 100644 index 000000000000..e63be181f95c --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/8/crtbegin-and-end.patch @@ -0,0 +1,595 @@ +Get crtbegin and crtend without compiler GCC! PR is at https://reviews.llvm.org/D28791 + +Index: compiler-rt/CMakeLists.txt +=================================================================== +--- compiler-rt/CMakeLists.txt ++++ compiler-rt/CMakeLists.txt +@@ -29,6 +29,8 @@ + + option(COMPILER_RT_BUILD_BUILTINS "Build builtins" ON) + mark_as_advanced(COMPILER_RT_BUILD_BUILTINS) ++option(COMPILER_RT_BUILD_CRT "Build crtbegin.o/crtend.o" ON) ++mark_as_advanced(COMPILER_RT_BUILD_CRT) + option(COMPILER_RT_BUILD_SANITIZERS "Build sanitizers" ON) + mark_as_advanced(COMPILER_RT_BUILD_SANITIZERS) + option(COMPILER_RT_BUILD_XRAY "Build xray" ON) +Index: compiler-rt/cmake/Modules/AddCompilerRT.cmake +=================================================================== +--- compiler-rt/cmake/Modules/AddCompilerRT.cmake ++++ compiler-rt/cmake/Modules/AddCompilerRT.cmake +@@ -132,7 +132,7 @@ + # Adds static or shared runtime for a list of architectures and operating + # systems and puts it in the proper directory in the build and install trees. + # add_compiler_rt_runtime(<name> +-# {STATIC|SHARED} ++# {OBJECT|STATIC|SHARED} + # ARCHS <architectures> + # OS <os list> + # SOURCES <source files> +@@ -144,8 +144,8 @@ + # PARENT_TARGET <convenience parent target> + # ADDITIONAL_HEADERS <header files>) + function(add_compiler_rt_runtime name type) +- if(NOT type MATCHES "^(STATIC|SHARED)$") +- message(FATAL_ERROR "type argument must be STATIC or SHARED") ++ if(NOT type MATCHES "^(OBJECT|STATIC|SHARED)$") ++ message(FATAL_ERROR "type argument must be OBJECT, STATIC or SHARED") + return() + endif() + cmake_parse_arguments(LIB +@@ -204,7 +204,10 @@ + message(FATAL_ERROR "Architecture ${arch} can't be targeted") + return() + endif() +- if(type STREQUAL "STATIC") ++ if(type STREQUAL "OBJECT") ++ set(libname "${name}-${arch}") ++ set(output_name_${libname} ${libname}${COMPILER_RT_OS_SUFFIX}) ++ elseif(type STREQUAL "STATIC") + set(libname "${name}-${arch}") + set_output_name(output_name_${libname} ${name} ${arch}) + else() +@@ -270,12 +273,34 @@ + set(COMPONENT_OPTION COMPONENT ${libname}) + endif() + +- add_library(${libname} ${type} ${sources_${libname}}) +- set_target_compile_flags(${libname} ${extra_cflags_${libname}}) +- set_target_link_flags(${libname} ${extra_link_flags_${libname}}) +- set_property(TARGET ${libname} APPEND PROPERTY +- COMPILE_DEFINITIONS ${LIB_DEFS}) +- set_target_output_directories(${libname} ${output_dir_${libname}}) ++ if(type STREQUAL "OBJECT") ++ string(TOUPPER ${CMAKE_BUILD_TYPE} config) ++ get_property(cflags SOURCE ${sources_${libname}} PROPERTY COMPILE_FLAGS) ++ separate_arguments(cflags) ++ add_custom_command( ++ OUTPUT ${output_dir_${libname}}/${libname}.o ++ COMMAND ${CMAKE_C_COMPILER} ${sources_${libname}} ${cflags} ${extra_cflags_${libname}} -c -o ${output_dir_${libname}}/${libname}.o ++ DEPENDS ${sources_${libname}} ++ COMMENT "Building C object ${libname}.o") ++ add_custom_target(${libname} DEPENDS ${output_dir_${libname}}/${libname}.o) ++ install(FILES ${output_dir_${libname}}/${libname}.o ++ DESTINATION ${install_dir_${libname}} ++ ${COMPONENT_OPTION}) ++ else() ++ add_library(${libname} ${type} ${sources_${libname}}) ++ set_target_compile_flags(${libname} ${extra_cflags_${libname}}) ++ set_target_link_flags(${libname} ${extra_link_flags_${libname}}) ++ set_property(TARGET ${libname} APPEND PROPERTY ++ COMPILE_DEFINITIONS ${LIB_DEFS}) ++ set_target_output_directories(${libname} ${output_dir_${libname}}) ++ install(TARGETS ${libname} ++ ARCHIVE DESTINATION ${install_dir_${libname}} ++ ${COMPONENT_OPTION} ++ LIBRARY DESTINATION ${install_dir_${libname}} ++ ${COMPONENT_OPTION} ++ RUNTIME DESTINATION ${install_dir_${libname}} ++ ${COMPONENT_OPTION}) ++ endif() + set_target_properties(${libname} PROPERTIES + OUTPUT_NAME ${output_name_${libname}}) + set_target_properties(${libname} PROPERTIES FOLDER "Compiler-RT Runtime") +@@ -299,13 +324,6 @@ + ) + endif() + endif() +- install(TARGETS ${libname} +- ARCHIVE DESTINATION ${install_dir_${libname}} +- ${COMPONENT_OPTION} +- LIBRARY DESTINATION ${install_dir_${libname}} +- ${COMPONENT_OPTION} +- RUNTIME DESTINATION ${install_dir_${libname}} +- ${COMPONENT_OPTION}) + + # We only want to generate per-library install targets if you aren't using + # an IDE because the extra targets get cluttered in IDEs. +Index: compiler-rt/cmake/config-ix.cmake +=================================================================== +--- compiler-rt/cmake/config-ix.cmake ++++ compiler-rt/cmake/config-ix.cmake +@@ -227,6 +227,7 @@ + ${ARM32} ${ARM64} ${MIPS32} ${MIPS64} ${S390X}) + set(ALL_ASAN_SUPPORTED_ARCH ${X86} ${X86_64} ${ARM32} ${ARM64} + ${MIPS32} ${MIPS64} ${PPC64} ${S390X}) ++set(ALL_CRT_SUPPORTED_ARCH ${X86} ${X86_64} ${ARM32} ${ARM64}) + set(ALL_DFSAN_SUPPORTED_ARCH ${X86_64} ${MIPS64} ${ARM64}) + set(ALL_FUZZER_SUPPORTED_ARCH ${X86_64} ${ARM64}) + +@@ -474,6 +475,7 @@ + SANITIZER_COMMON_SUPPORTED_ARCH) + + else() ++ filter_available_targets(CRT_SUPPORTED_ARCH ${ALL_CRT_SUPPORTED_ARCH}) + # Architectures supported by compiler-rt libraries. + filter_available_targets(SANITIZER_COMMON_SUPPORTED_ARCH + ${ALL_SANITIZER_COMMON_SUPPORTED_ARCH}) +@@ -563,6 +565,12 @@ + + # TODO: Add builtins support. + ++if (CRT_SUPPORTED_ARCH AND OS_NAME MATCHES "Linux") ++ set(COMPILER_RT_HAS_CRT TRUE) ++else() ++ set(COMPILER_RT_HAS_CRT FALSE) ++endif() ++ + if (COMPILER_RT_HAS_SANITIZER_COMMON AND DFSAN_SUPPORTED_ARCH AND + OS_NAME MATCHES "Linux") + set(COMPILER_RT_HAS_DFSAN TRUE) +Index: compiler-rt/lib/CMakeLists.txt +=================================================================== +--- compiler-rt/lib/CMakeLists.txt ++++ compiler-rt/lib/CMakeLists.txt +@@ -17,6 +17,10 @@ + add_subdirectory(builtins) + endif() + ++if(COMPILER_RT_BUILD_CRT) ++ add_subdirectory(crt) ++endif() ++ + function(compiler_rt_build_runtime runtime) + string(TOUPPER ${runtime} runtime_uppercase) + if(COMPILER_RT_HAS_${runtime_uppercase}) +Index: compiler-rt/lib/crt/CMakeLists.txt +=================================================================== +--- /dev/null ++++ compiler-rt/lib/crt/CMakeLists.txt +@@ -0,0 +1,102 @@ ++add_compiler_rt_component(crt) ++ ++function(check_cxx_section_exists section output) ++ cmake_parse_arguments(ARG "" "" "SOURCE;FLAGS" ${ARGN}) ++ if(NOT ARG_SOURCE) ++ set(ARG_SOURCE "int main() { return 0; }\n") ++ endif() ++ ++ string(RANDOM TARGET_NAME) ++ set(TARGET_NAME "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/cmTC_${TARGET_NAME}.dir") ++ file(MAKE_DIRECTORY ${TARGET_NAME}) ++ ++ file(WRITE "${TARGET_NAME}/CheckSectionExists.c" "${ARG_SOURCE}\n") ++ ++ string(REGEX MATCHALL "<[A-Za-z0-9_]*>" substitutions ++ ${CMAKE_C_COMPILE_OBJECT}) ++ ++ set(try_compile_flags "${ARG_FLAGS}") ++ if(CMAKE_C_COMPILER_ID MATCHES Clang AND CMAKE_C_COMPILER_TARGET) ++ list(APPEND try_compile_flags "-target ${CMAKE_C_COMPILER_TARGET}") ++ endif() ++ ++ string(REPLACE ";" " " extra_flags "${try_compile_flags}") ++ ++ set(test_compile_command "${CMAKE_C_COMPILE_OBJECT}") ++ foreach(substitution ${substitutions}) ++ if(substitution STREQUAL "<CMAKE_C_COMPILER>") ++ string(REPLACE "<CMAKE_C_COMPILER>" ++ "${CMAKE_C_COMPILER}" test_compile_command ${test_compile_command}) ++ elseif(substitution STREQUAL "<OBJECT>") ++ string(REPLACE "<OBJECT>" "${TARGET_NAME}/CheckSectionExists.o" ++ test_compile_command ${test_compile_command}) ++ elseif(substitution STREQUAL "<SOURCE>") ++ string(REPLACE "<SOURCE>" "${TARGET_NAME}/CheckSectionExists.c" ++ test_compile_command ${test_compile_command}) ++ elseif(substitution STREQUAL "<FLAGS>") ++ string(REPLACE "<FLAGS>" "${CMAKE_C_FLAGS} ${extra_flags}" ++ test_compile_command ${test_compile_command}) ++ else() ++ string(REPLACE "${substitution}" "" test_compile_command ++ ${test_compile_command}) ++ endif() ++ endforeach() ++ ++ string(REPLACE " " ";" test_compile_command "${test_compile_command}") ++ ++ execute_process( ++ COMMAND ${test_compile_command} ++ RESULT_VARIABLE TEST_RESULT ++ OUTPUT_VARIABLE TEST_OUTPUT ++ ERROR_VARIABLE TEST_ERROR ++ ) ++ ++ execute_process( ++ COMMAND ${CMAKE_OBJDUMP} -h "${TARGET_NAME}/CheckSectionExists.o" ++ RESULT_VARIABLE CHECK_RESULT ++ OUTPUT_VARIABLE CHECK_OUTPUT ++ ERROR_VARIABLE CHECK_ERROR ++ ) ++ string(FIND "${CHECK_OUTPUT}" "${section}" SECTION_FOUND) ++ ++ if(NOT SECTION_FOUND EQUAL -1) ++ set(${output} TRUE PARENT_SCOPE) ++ else() ++ set(${output} FALSE PARENT_SCOPE) ++ endif() ++ ++ file(REMOVE_RECURSE ${TARGET_NAME}) ++endfunction() ++ ++check_cxx_section_exists(".init_array" COMPILER_RT_HAS_INITFINI_ARRAY ++ SOURCE "__attribute__((constructor)) void f() {}\nint main() { return 0; }\n") ++ ++append_list_if(COMPILER_RT_HAS_INITFINI_ARRAY -DCRT_HAS_INITFINI_ARRAY CRT_CFLAGS) ++append_list_if(COMPILER_RT_HAS_FPIC_FLAG -fPIC CRT_CFLAGS) ++ ++foreach(arch ${CRT_SUPPORTED_ARCH}) ++ add_compiler_rt_runtime(clang_rt.crtbegin ++ OBJECT ++ ARCHS ${arch} ++ SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/crtbegin.c ++ CFLAGS ${CRT_CFLAGS} ++ PARENT_TARGET crt) ++ add_compiler_rt_runtime(clang_rt.crtbegin_shared ++ OBJECT ++ ARCHS ${arch} ++ SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/crtbegin.c ++ CFLAGS ${CRT_CFLAGS} -DCRT_SHARED ++ PARENT_TARGET crt) ++ add_compiler_rt_runtime(clang_rt.crtend ++ OBJECT ++ ARCHS ${arch} ++ SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/crtend.c ++ CFLAGS ${CRT_CFLAGS} ++ PARENT_TARGET crt) ++ add_compiler_rt_runtime(clang_rt.crtend_shared ++ OBJECT ++ ARCHS ${arch} ++ SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/crtend.c ++ CFLAGS ${CRT_CFLAGS} -DCRT_SHARED ++ PARENT_TARGET crt) ++endforeach() +Index: compiler-rt/lib/crt/crtbegin.c +=================================================================== +--- /dev/null ++++ compiler-rt/lib/crt/crtbegin.c +@@ -0,0 +1,108 @@ ++/* ===-- crtbegin.c - Start of constructors and destructors ----------------=== ++ * ++ * The LLVM Compiler Infrastructure ++ * ++ * This file is dual licensed under the MIT and the University of Illinois Open ++ * Source Licenses. See LICENSE.TXT for details. ++ * ++ * ===----------------------------------------------------------------------=== ++ */ ++ ++#include <stddef.h> ++ ++__attribute__((visibility("hidden"))) ++#ifdef CRT_SHARED ++void *__dso_handle = &__dso_handle; ++#else ++void *__dso_handle = (void *)0; ++#endif ++ ++static long __EH_FRAME_LIST__[] ++ __attribute__((section(".eh_frame"), aligned(sizeof(void *)))) = {}; ++ ++extern void __register_frame_info(const void *, void *) __attribute__((weak)); ++extern void *__deregister_frame_info(const void *) __attribute__((weak)); ++ ++#ifndef CRT_HAS_INITFINI_ARRAY ++typedef void (*fp)(void); ++ ++static fp __CTOR_LIST__[] ++ __attribute__((section(".ctors"), aligned(sizeof(fp)), used)) = {(fp)-1}; ++extern fp __CTOR_LIST_END__[]; ++#endif ++ ++#ifdef CRT_SHARED ++extern void __cxa_finalize(void *) __attribute__((weak)); ++#endif ++ ++static void __attribute__((used)) __do_init() { ++ static _Bool __initialized; ++ if (__builtin_expect(__initialized, 0)) ++ return; ++ __initialized = 1; ++ ++ static struct { void *p[8]; } __object; ++ if (__register_frame_info) ++ __register_frame_info(__EH_FRAME_LIST__, &__object); ++ ++#ifndef CRT_HAS_INITFINI_ARRAY ++ const size_t n = __CTOR_LIST_END__ - __CTOR_LIST__ - 1; ++ for (size_t i = n; i >= 1; i--) __CTOR_LIST__[i](); ++#endif ++} ++ ++#ifdef CRT_HAS_INITFINI_ARRAY ++__attribute__((section(".init_array"), ++ used)) static void (*__init)(void) = __do_init; ++#else // CRT_HAS_INITFINI_ARRAY ++#if defined(__i386__) || defined(__x86_64__) ++asm(".pushsection .init,\"ax\",@progbits\n\t" ++ "call " __USER_LABEL_PREFIX__ "__do_init\n\t" ++ ".popsection"); ++#elif defined(__arm__) ++asm(".pushsection .init,\"ax\",%progbits\n\t" ++ "bl " __USER_LABEL_PREFIX__ "__do_init\n\t" ++ ".popsection"); ++#endif // CRT_HAS_INITFINI_ARRAY ++#endif ++ ++#ifndef CRT_HAS_INITFINI_ARRAY ++static fp __DTOR_LIST__[] ++ __attribute__((section(".dtors"), aligned(sizeof(fp)), used)) = {(fp)-1}; ++extern fp __DTOR_LIST_END__[]; ++#endif ++ ++static void __attribute__((used)) __do_fini() { ++ static _Bool __finalized; ++ if (__builtin_expect(__finalized, 0)) ++ return; ++ __finalized = 1; ++ ++#ifdef CRT_SHARED ++ if (__cxa_finalize) ++ __cxa_finalize(__dso_handle); ++#endif ++ ++#ifndef CRT_HAS_INITFINI_ARRAY ++ if (__deregister_frame_info) ++ __deregister_frame_info(__EH_FRAME_LIST__); ++ ++ const size_t n = __DTOR_LIST_END__ - __DTOR_LIST__ - 1; ++ for (size_t i = 1; i < n; i++) __DTOR_LIST__[i](); ++#endif ++} ++ ++#ifdef CRT_HAS_INITFINI_ARRAY ++__attribute__((section(".fini_array"), ++ used)) static void (*__fini)(void) = __do_fini; ++#else // CRT_HAS_INITFINI_ARRAY ++#if defined(__i386__) || defined(__x86_64__) ++asm(".pushsection .fini,\"ax\",@progbits\n\t" ++ "call " __USER_LABEL_PREFIX__ "__do_fini\n\t" ++ ".popsection"); ++#elif defined(__arm__) ++asm(".pushsection .fini,\"ax\",%progbits\n\t" ++ "bl " __USER_LABEL_PREFIX__ "__do_fini\n\t" ++ ".popsection"); ++#endif ++#endif // CRT_HAS_INIT_FINI_ARRAY +Index: compiler-rt/lib/crt/crtend.c +=================================================================== +--- /dev/null ++++ compiler-rt/lib/crt/crtend.c +@@ -0,0 +1,24 @@ ++/* ===-- crtend.c - End of constructors and destructors --------------------=== ++ * ++ * The LLVM Compiler Infrastructure ++ * ++ * This file is dual licensed under the MIT and the University of Illinois Open ++ * Source Licenses. See LICENSE.TXT for details. ++ * ++ * ===----------------------------------------------------------------------=== ++ */ ++ ++#include <stdint.h> ++ ++// Put 4-byte zero which is the length field in FDE at the end as a terminator. ++const int32_t __EH_FRAME_LIST_END__[] ++ __attribute__((section(".eh_frame"), aligned(sizeof(int32_t)), ++ visibility("hidden"), used)) = {0}; ++ ++#ifndef CRT_HAS_INITFINI_ARRAY ++typedef void (*fp)(void); ++fp __CTOR_LIST_END__[] ++ __attribute__((section(".ctors"), visibility("hidden"), used)) = {0}; ++fp __DTOR_LIST_END__[] ++ __attribute__((section(".dtors"), visibility("hidden"), used)) = {0}; ++#endif +Index: compiler-rt/test/CMakeLists.txt +=================================================================== +--- compiler-rt/test/CMakeLists.txt ++++ compiler-rt/test/CMakeLists.txt +@@ -73,6 +73,9 @@ + if(COMPILER_RT_BUILD_XRAY) + compiler_rt_test_runtime(xray) + endif() ++ if(COMPILER_RT_HAS_CRT) ++ add_subdirectory(crt) ++ endif() + # ShadowCallStack does not yet provide a runtime with compiler-rt, the tests + # include their own minimal runtime + add_subdirectory(shadowcallstack) +Index: compiler-rt/test/crt/CMakeLists.txt +=================================================================== +--- /dev/null ++++ compiler-rt/test/crt/CMakeLists.txt +@@ -0,0 +1,31 @@ ++set(CRT_LIT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) ++ ++set(CRT_TESTSUITES) ++ ++set(CRT_TEST_DEPS "") ++ ++if(NOT COMPILER_RT_STANDALONE_BUILD AND COMPILER_RT_BUILD_CRT AND ++ COMPILER_RT_HAS_CRT) ++ list(APPEND CRT_TEST_DEPS crt) ++endif() ++ ++set(CRT_TEST_ARCH ${CRT_SUPPORTED_ARCH}) ++if (COMPILER_RT_BUILD_CRT AND COMPILER_RT_HAS_CRT) ++ foreach(arch ${CRT_TEST_ARCH}) ++ set(CRT_TEST_TARGET_ARCH ${arch}) ++ string(TOLOWER "-${arch}-${OS_NAME}" CRT_TEST_CONFIG_SUFFIX) ++ get_test_cc_for_arch(${arch} CRT_TEST_TARGET_CC CRT_TEST_TARGET_CFLAGS) ++ string(TOUPPER ${arch} ARCH_UPPER_CASE) ++ set(CONFIG_NAME ${ARCH_UPPER_CASE}${OS_NAME}Config) ++ ++ configure_lit_site_cfg( ++ ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in ++ ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/lit.site.cfg) ++ list(APPEND CRT_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}) ++ endforeach() ++endif() ++ ++add_lit_testsuite(check-crt "Running the CRT tests" ++ ${CRT_TESTSUITES} ++ DEPENDS ${CRT_TEST_DEPS}) ++set_target_properties(check-crt PROPERTIES FOLDER "Compiler-RT Misc") +Index: compiler-rt/test/crt/dso_handle.cpp +=================================================================== +--- /dev/null ++++ compiler-rt/test/crt/dso_handle.cpp +@@ -0,0 +1,33 @@ ++// RUN: %clangxx -g -DCRT_SHARED -c %s -fPIC -o %tshared.o ++// RUN: %clangxx -g -c %s -fPIC -o %t.o ++// RUN: %clangxx -g -shared -o %t.so -nostdlib %crti %shared_crtbegin %tshared.o %libstdcxx -lc -lm -lgcc_s %shared_crtend %crtn ++// RUN: %clangxx -g -o %t -nostdlib %crt1 %crti %crtbegin %t.o %libstdcxx -lc -lm %libgcc %t.so %crtend %crtn ++// RUN: %run %t 2>&1 | FileCheck %s ++ ++#include <stdio.h> ++ ++// CHECK: 1 ++// CHECK-NEXT: ~A() ++ ++#ifdef CRT_SHARED ++bool G; ++void C() { ++ printf("%d\n", G); ++} ++ ++struct A { ++ A() { G = true; } ++ ~A() { ++ printf("~A()\n"); ++ } ++}; ++ ++A a; ++#else ++void C(); ++ ++int main() { ++ C(); ++ return 0; ++} ++#endif +Index: compiler-rt/test/crt/lit.cfg +=================================================================== +--- /dev/null ++++ compiler-rt/test/crt/lit.cfg +@@ -0,0 +1,80 @@ ++# -*- Python -*- ++ ++import os ++import subprocess ++ ++# Setup config name. ++config.name = 'CRT' + config.name_suffix ++ ++# Setup source root. ++config.test_source_root = os.path.dirname(__file__) ++ ++ ++def get_library_path(file): ++ cmd = subprocess.Popen([config.clang.strip(), ++ config.target_cflags.strip(), ++ '-print-file-name=%s' % file], ++ stdout=subprocess.PIPE, ++ env=config.environment) ++ if not cmd.stdout: ++ lit_config.fatal("Couldn't find the library path for '%s'" % file) ++ dir = cmd.stdout.read().strip() ++ if sys.platform in ['win32'] and execute_external: ++ # Don't pass dosish path separator to msys bash.exe. ++ dir = dir.replace('\\', '/') ++ # Ensure the result is an ascii string, across Python2.5+ - Python3. ++ return str(dir.decode('ascii')) ++ ++ ++def get_libgcc_file_name(): ++ cmd = subprocess.Popen([config.clang.strip(), ++ config.target_cflags.strip(), ++ '-print-libgcc-file-name'], ++ stdout=subprocess.PIPE, ++ env=config.environment) ++ if not cmd.stdout: ++ lit_config.fatal("Couldn't find the library path for '%s'" % file) ++ dir = cmd.stdout.read().strip() ++ if sys.platform in ['win32'] and execute_external: ++ # Don't pass dosish path separator to msys bash.exe. ++ dir = dir.replace('\\', '/') ++ # Ensure the result is an ascii string, across Python2.5+ - Python3. ++ return str(dir.decode('ascii')) ++ ++ ++def build_invocation(compile_flags): ++ return ' ' + ' '.join([config.clang] + compile_flags) + ' ' ++ ++ ++# Setup substitutions. ++config.substitutions.append( ++ ('%clang ', build_invocation([config.target_cflags]))) ++config.substitutions.append( ++ ('%clangxx ', ++ build_invocation(config.cxx_mode_flags + [config.target_cflags]))) ++ ++base_lib = os.path.join( ++ config.compiler_rt_libdir, "clang_rt.%%s-%s.o" % config.target_arch) ++config.substitutions.append(('%crtbegin', base_lib % "crtbegin")) ++config.substitutions.append(('%shared_crtbegin', base_lib % "crtbegin_shared")) ++config.substitutions.append(('%crtend', base_lib % "crtend")) ++config.substitutions.append(('%shared_crtend', base_lib % "crtend_shared")) ++ ++config.substitutions.append( ++ ('%crt1', get_library_path('crt1.o'))) ++config.substitutions.append( ++ ('%crti', get_library_path('crti.o'))) ++config.substitutions.append( ++ ('%crtn', get_library_path('crtn.o'))) ++ ++config.substitutions.append( ++ ('%libgcc', get_libgcc_file_name())) ++ ++config.substitutions.append( ++ ('%libstdcxx', '-l' + config.sanitizer_cxx_lib.lstrip('lib'))) ++ ++# Default test suffixes. ++config.suffixes = ['.c', '.cc', '.cpp'] ++ ++if config.host_os not in ['Linux']: ++ config.unsupported = True +Index: compiler-rt/test/crt/lit.site.cfg.in +=================================================================== +--- /dev/null ++++ compiler-rt/test/crt/lit.site.cfg.in +@@ -0,0 +1,14 @@ ++@LIT_SITE_CFG_IN_HEADER@ ++ ++# Tool-specific config options. ++config.name_suffix = "@CRT_TEST_CONFIG_SUFFIX@" ++config.crt_lit_source_dir = "@CRT_LIT_SOURCE_DIR@" ++config.target_cflags = "@CRT_TEST_TARGET_CFLAGS@" ++config.target_arch = "@CRT_TEST_TARGET_ARCH@" ++config.sanitizer_cxx_lib = "@SANITIZER_TEST_CXX_LIBNAME@" ++ ++# Load common config for all compiler-rt lit tests ++lit_config.load_config(config, "@COMPILER_RT_BINARY_DIR@/test/lit.common.configured") ++ ++# Load tool-specific config that would do the real work. ++lit_config.load_config(config, "@CRT_LIT_SOURCE_DIR@/lit.cfg") diff --git a/nixpkgs/pkgs/development/compilers/llvm/8/default.nix b/nixpkgs/pkgs/development/compilers/llvm/8/default.nix new file mode 100644 index 000000000000..48cf9e5e589c --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/8/default.nix @@ -0,0 +1,197 @@ +{ lowPrio, newScope, pkgs, stdenv, cmake, libstdcxxHook +, libxml2, python, isl, fetchurl, overrideCC, wrapCCWith, wrapBintoolsWith +, buildLlvmTools # tools, but from the previous stage, for cross +, targetLlvmLibraries # libraries, but from the next stage, for cross +}: + +let + release_version = "8.0.0"; + version = release_version; # differentiating these is important for rc's + + fetch = name: sha256: fetchurl { + url = "https://releases.llvm.org/${release_version}/${name}-${version}.src.tar.xz"; + inherit sha256; + }; + + clang-tools-extra_src = fetch "clang-tools-extra" "0jwx6nnshp92pd5852y7ip7qhaqdf8az5g0440pli9q8whmi402g"; + + tools = stdenv.lib.makeExtensible (tools: let + callPackage = newScope (tools // { inherit stdenv cmake libxml2 python isl release_version version fetch; }); + mkExtraBuildCommands = cc: '' + rsrc="$out/resource-root" + mkdir "$rsrc" + ln -s "${cc}/lib/clang/${release_version}/include" "$rsrc" + ln -s "${targetLlvmLibraries.compiler-rt.out}/lib" "$rsrc/lib" + echo "-resource-dir=$rsrc" >> $out/nix-support/cc-cflags + '' + stdenv.lib.optionalString (stdenv.targetPlatform.isLinux && tools.clang-unwrapped ? gcc && !(stdenv.targetPlatform.useLLVM or false)) '' + echo "--gcc-toolchain=${tools.clang-unwrapped.gcc}" >> $out/nix-support/cc-cflags + ''; + in { + + llvm = callPackage ./llvm.nix { }; + llvm-polly = callPackage ./llvm.nix { enablePolly = true; }; + + clang-unwrapped = callPackage ./clang { + inherit clang-tools-extra_src; + }; + clang-polly-unwrapped = callPackage ./clang { + inherit clang-tools-extra_src; + llvm = tools.llvm-polly; + enablePolly = true; + }; + + llvm-manpages = lowPrio (tools.llvm.override { + enableManpages = true; + python = pkgs.python; # don't use python-boot + }); + + clang-manpages = lowPrio (tools.clang-unwrapped.override { + enableManpages = true; + python = pkgs.python; # don't use python-boot + }); + + libclang = tools.clang-unwrapped.lib; + + clang = if stdenv.cc.isGNU then tools.libstdcxxClang else tools.libcxxClang; + + libstdcxxClang = wrapCCWith rec { + cc = tools.clang-unwrapped; + extraPackages = [ + libstdcxxHook + targetLlvmLibraries.compiler-rt + ]; + extraBuildCommands = mkExtraBuildCommands cc; + }; + + libcxxClang = wrapCCWith rec { + cc = tools.clang-unwrapped; + libcxx = targetLlvmLibraries.libcxx; + extraPackages = [ + targetLlvmLibraries.libcxx + targetLlvmLibraries.libcxxabi + targetLlvmLibraries.compiler-rt + ]; + extraBuildCommands = mkExtraBuildCommands cc; + }; + + lld = callPackage ./lld.nix {}; + + lldb = callPackage ./lldb.nix {}; + + # Below, is the LLVM bootstrapping logic. It handles building a + # fully LLVM toolchain from scratch. No GCC toolchain should be + # pulled in. As a consequence, it is very quick to build different + # targets provided by LLVM and we can also build for what GCC + # doesn’t support like LLVM. Probably we should move to some other + # file. + + bintools = callPackage ./bintools.nix {}; + + lldClang = wrapCCWith rec { + cc = tools.clang-unwrapped; + libcxx = targetLlvmLibraries.libcxx; + bintools = wrapBintoolsWith { + inherit (tools) bintools; + }; + extraPackages = [ + targetLlvmLibraries.libcxx + targetLlvmLibraries.libcxxabi + targetLlvmLibraries.compiler-rt + ] ++ stdenv.lib.optionals (!stdenv.targetPlatform.isWasm) [ + targetLlvmLibraries.libunwind + ]; + extraBuildCommands = '' + echo "-target ${stdenv.targetPlatform.config}" >> $out/nix-support/cc-cflags + echo "-rtlib=compiler-rt -Wno-unused-command-line-argument" >> $out/nix-support/cc-cflags + echo "-B${targetLlvmLibraries.compiler-rt}/lib" >> $out/nix-support/cc-cflags + '' + stdenv.lib.optionalString (!stdenv.targetPlatform.isWasm) '' + echo "--unwindlib=libunwind" >> $out/nix-support/cc-cflags + '' + stdenv.lib.optionalString stdenv.targetPlatform.isWasm '' + echo "-fno-exceptions" >> $out/nix-support/cc-cflags + '' + mkExtraBuildCommands cc; + }; + + lldClangNoLibcxx = wrapCCWith rec { + cc = tools.clang-unwrapped; + libcxx = null; + bintools = wrapBintoolsWith { + inherit (tools) bintools; + }; + extraPackages = [ + targetLlvmLibraries.compiler-rt + ]; + extraBuildCommands = '' + echo "-target ${stdenv.targetPlatform.config}" >> $out/nix-support/cc-cflags + echo "-rtlib=compiler-rt" >> $out/nix-support/cc-cflags + echo "-B${targetLlvmLibraries.compiler-rt}/lib" >> $out/nix-support/cc-cflags + echo "-nostdlib++" >> $out/nix-support/cc-cflags + '' + mkExtraBuildCommands cc; + }; + + lldClangNoLibc = wrapCCWith rec { + cc = tools.clang-unwrapped; + libcxx = null; + bintools = wrapBintoolsWith { + inherit (tools) bintools; + libc = null; + }; + extraPackages = [ + targetLlvmLibraries.compiler-rt + ]; + extraBuildCommands = '' + echo "-target ${stdenv.targetPlatform.config}" >> $out/nix-support/cc-cflags + echo "-rtlib=compiler-rt" >> $out/nix-support/cc-cflags + echo "-B${targetLlvmLibraries.compiler-rt}/lib" >> $out/nix-support/cc-cflags + '' + mkExtraBuildCommands cc; + }; + + lldClangNoCompilerRt = wrapCCWith rec { + cc = tools.clang-unwrapped; + libcxx = null; + bintools = wrapBintoolsWith { + inherit (tools) bintools; + libc = null; + }; + extraPackages = [ ]; + extraBuildCommands = '' + echo "-nostartfiles" >> $out/nix-support/cc-cflags + echo "-target ${stdenv.targetPlatform.config}" >> $out/nix-support/cc-cflags + ''; + }; + + }); + + libraries = stdenv.lib.makeExtensible (libraries: let + callPackage = newScope (libraries // buildLlvmTools // { inherit stdenv cmake libxml2 python isl release_version version fetch; }); + in { + + compiler-rt = callPackage ./compiler-rt.nix ({} // + (stdenv.lib.optionalAttrs (stdenv.hostPlatform.useLLVM or false) { + stdenv = overrideCC stdenv buildLlvmTools.lldClangNoCompilerRt; + })); + + stdenv = overrideCC stdenv buildLlvmTools.clang; + + libcxxStdenv = overrideCC stdenv buildLlvmTools.libcxxClang; + + libcxx = callPackage ./libc++ ({} // + (stdenv.lib.optionalAttrs (stdenv.hostPlatform.useLLVM or false) { + stdenv = overrideCC stdenv buildLlvmTools.lldClangNoLibcxx; + })); + + libcxxabi = callPackage ./libc++abi.nix ({} // + (stdenv.lib.optionalAttrs (stdenv.hostPlatform.useLLVM or false) { + stdenv = overrideCC stdenv buildLlvmTools.lldClangNoLibcxx; + libunwind = libraries.libunwind; + })); + + openmp = callPackage ./openmp.nix {}; + + libunwind = callPackage ./libunwind.nix ({} // + (stdenv.lib.optionalAttrs (stdenv.hostPlatform.useLLVM or false) { + stdenv = overrideCC stdenv buildLlvmTools.lldClangNoLibcxx; + })); + + }); + +in { inherit tools libraries; } // libraries // tools diff --git a/nixpkgs/pkgs/development/compilers/llvm/8/libc++/default.nix b/nixpkgs/pkgs/development/compilers/llvm/8/libc++/default.nix new file mode 100644 index 000000000000..3d67c37dcdd7 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/8/libc++/default.nix @@ -0,0 +1,58 @@ +{ lib, stdenv, fetch, cmake, python, libcxxabi, fixDarwinDylibNames, version +, enableShared ? true }: + +stdenv.mkDerivation rec { + name = "libc++-${version}"; + + src = fetch "libcxx" "1qlx3wlxrnc5cwc1fcfc2vhfsl7j4294hi8y5kxj8hy8wxsjd462"; + + postUnpack = '' + unpackFile ${libcxxabi.src} + export LIBCXXABI_INCLUDE_DIR="$PWD/$(ls -d libcxxabi-${version}*)/include" + ''; + + patches = stdenv.lib.optional stdenv.hostPlatform.isMusl ../../libcxx-0001-musl-hacks.patch; + + prePatch = '' + substituteInPlace lib/CMakeLists.txt --replace "/usr/lib/libc++" "\''${LIBCXX_LIBCXXABI_LIB_PATH}/libc++" + ''; + + preConfigure = '' + # Get headers from the cxxabi source so we can see private headers not installed by the cxxabi package + cmakeFlagsArray=($cmakeFlagsArray -DLIBCXX_CXX_ABI_INCLUDE_PATHS="$LIBCXXABI_INCLUDE_DIR") + '' + lib.optionalString stdenv.hostPlatform.isMusl '' + patchShebangs utils/cat_files.py + ''; + nativeBuildInputs = [ cmake ] + ++ stdenv.lib.optional (stdenv.hostPlatform.isMusl || stdenv.hostPlatform.isWasi) python; + + buildInputs = [ libcxxabi ] ++ lib.optional stdenv.isDarwin fixDarwinDylibNames; + + cmakeFlags = [ + "-DLIBCXX_LIBCXXABI_LIB_PATH=${libcxxabi}/lib" + "-DLIBCXX_LIBCPPABI_VERSION=2" + "-DLIBCXX_CXX_ABI=libcxxabi" + ] ++ stdenv.lib.optional (stdenv.hostPlatform.isMusl || stdenv.hostPlatform.isWasi) "-DLIBCXX_HAS_MUSL_LIBC=1" + ++ stdenv.lib.optional (stdenv.hostPlatform.useLLVM or false) "-DLIBCXX_USE_COMPILER_RT=ON" + ++ stdenv.lib.optional stdenv.hostPlatform.isWasm [ + "-DLIBCXX_ENABLE_THREADS=OFF" + "-DLIBCXX_ENABLE_FILESYSTEM=OFF" + "-DLIBCXX_ENABLE_EXCEPTIONS=OFF" + ] ++ stdenv.lib.optional (!enableShared) "-DLIBCXX_ENABLE_SHARED=OFF"; + + enableParallelBuilding = true; + + linkCxxAbi = stdenv.isLinux; + + setupHooks = [ + ../../../../../build-support/setup-hooks/role.bash + ./setup-hook.sh + ]; + + meta = { + homepage = http://libcxx.llvm.org/; + description = "A new implementation of the C++ standard library, targeting C++11"; + license = with stdenv.lib.licenses; [ ncsa mit ]; + platforms = stdenv.lib.platforms.all; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/llvm/8/libc++/setup-hook.sh b/nixpkgs/pkgs/development/compilers/llvm/8/libc++/setup-hook.sh new file mode 100644 index 000000000000..6611259165ae --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/8/libc++/setup-hook.sh @@ -0,0 +1,6 @@ +# See pkgs/build-support/setup-hooks/role.bash +getHostRole + +linkCxxAbi="@linkCxxAbi@" +export NIX_${role_pre}CXXSTDLIB_COMPILE+=" -isystem @out@/include/c++/v1" +export NIX_${role_pre}CXXSTDLIB_LINK=" -stdlib=libc++${linkCxxAbi:+" -lc++abi"}" diff --git a/nixpkgs/pkgs/development/compilers/llvm/8/libc++abi.nix b/nixpkgs/pkgs/development/compilers/llvm/8/libc++abi.nix new file mode 100644 index 000000000000..bb5b368267f2 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/8/libc++abi.nix @@ -0,0 +1,66 @@ +{ stdenv, cmake, fetch, libcxx, libunwind, llvm, version +, enableShared ? true }: + +stdenv.mkDerivation { + name = "libc++abi-${version}"; + + src = fetch "libcxxabi" "1k875f977ybdkpdnr9105wa6hccy9qvpd9xd42n75h7p56bdxmn2"; + + nativeBuildInputs = [ cmake ]; + buildInputs = stdenv.lib.optional (!stdenv.isDarwin && !stdenv.isFreeBSD && !stdenv.hostPlatform.isWasm) libunwind; + + cmakeFlags = stdenv.lib.optionals (stdenv.hostPlatform.useLLVM or false) [ + "-DLLVM_ENABLE_LIBCXX=ON" + "-DLIBCXXABI_USE_LLVM_UNWINDER=ON" + ] ++ stdenv.lib.optionals stdenv.hostPlatform.isWasm [ + "-DLIBCXXABI_ENABLE_THREADS=OFF" + "-DLIBCXXABI_ENABLE_EXCEPTIONS=OFF" + ] ++ stdenv.lib.optionals (!enableShared) [ + "-DLIBCXXABI_ENABLE_SHARED=OFF" + ]; + + patches = [ ./libcxxabi-no-threads.patch ]; + + postUnpack = '' + unpackFile ${libcxx.src} + unpackFile ${llvm.src} + cmakeFlags+=" -DLLVM_PATH=$PWD/$(ls -d llvm-*) -DLIBCXXABI_LIBCXX_PATH=$PWD/$(ls -d libcxx-*)" + '' + stdenv.lib.optionalString stdenv.isDarwin '' + export TRIPLE=x86_64-apple-darwin + '' + stdenv.lib.optionalString stdenv.hostPlatform.isMusl '' + patch -p1 -d $(ls -d libcxx-*) -i ${../libcxx-0001-musl-hacks.patch} + '' + stdenv.lib.optionalString stdenv.hostPlatform.isWasm '' + patch -p1 -d $(ls -d llvm-*) -i ${./libcxxabi-wasm.patch} + ''; + + installPhase = if stdenv.isDarwin + then '' + for file in lib/*.dylib; do + # this should be done in CMake, but having trouble figuring out + # the magic combination of necessary CMake variables + # if you fancy a try, take a look at + # http://www.cmake.org/Wiki/CMake_RPATH_handling + install_name_tool -id $out/$file $file + done + make install + install -d 755 $out/include + install -m 644 ../include/*.h $out/include + '' + else '' + install -d -m 755 $out/include $out/lib + install -m 644 lib/libc++abi.a $out/lib + install -m 644 ../include/cxxabi.h $out/include + '' + stdenv.lib.optionalString enableShared '' + install -m 644 lib/libc++abi.so.1.0 $out/lib + ln -s libc++abi.so.1.0 $out/lib/libc++abi.so + ln -s libc++abi.so.1.0 $out/lib/libc++abi.so.1 + ''; + + meta = { + homepage = http://libcxxabi.llvm.org/; + description = "A new implementation of low level support for a standard C++ library"; + license = with stdenv.lib.licenses; [ ncsa mit ]; + maintainers = with stdenv.lib.maintainers; [ vlstill ]; + platforms = stdenv.lib.platforms.all; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/llvm/8/libcxxabi-no-threads.patch b/nixpkgs/pkgs/development/compilers/llvm/8/libcxxabi-no-threads.patch new file mode 100644 index 000000000000..787f3e16500e --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/8/libcxxabi-no-threads.patch @@ -0,0 +1,12 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 4138acf..41b4763 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -362,6 +362,7 @@ if (NOT LIBCXXABI_ENABLE_THREADS) + " is also set to ON.") + endif() + add_definitions(-D_LIBCXXABI_HAS_NO_THREADS) ++ add_definitions(-D_LIBCPP_HAS_NO_THREADS) + endif() + + if (LIBCXXABI_HAS_EXTERNAL_THREAD_API) diff --git a/nixpkgs/pkgs/development/compilers/llvm/8/libcxxabi-wasm.patch b/nixpkgs/pkgs/development/compilers/llvm/8/libcxxabi-wasm.patch new file mode 100644 index 000000000000..4ebfe46aa813 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/8/libcxxabi-wasm.patch @@ -0,0 +1,16 @@ +diff --git a/cmake/modules/HandleLLVMOptions.cmake b/cmake/modules/HandleLLVMOptions.cmake +index 15497d405e0..33f7f18193a 100644 +--- a/cmake/modules/HandleLLVMOptions.cmake ++++ b/cmake/modules/HandleLLVMOptions.cmake +@@ -127,7 +127,10 @@ else(WIN32) + set(LLVM_HAVE_LINK_VERSION_SCRIPT 1) + endif() + else(FUCHSIA OR UNIX) +- MESSAGE(SEND_ERROR "Unable to determine platform") ++ if(${CMAKE_SYSTEM_NAME} MATCHES "Wasi") ++ else() ++ MESSAGE(SEND_ERROR "Unable to determine platform") ++ endif() + endif(FUCHSIA OR UNIX) + endif(WIN32) + diff --git a/nixpkgs/pkgs/development/compilers/llvm/8/libunwind.nix b/nixpkgs/pkgs/development/compilers/llvm/8/libunwind.nix new file mode 100644 index 000000000000..a187d0adc994 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/8/libunwind.nix @@ -0,0 +1,22 @@ +{ stdenv, version, fetch, cmake, libcxx, fetchpatch }: + +stdenv.mkDerivation { + name = "libunwind-${version}"; + + src = fetch "libunwind" "0q7ndlldid9wchnny0a936llwxj7zgb9gxp46wjjxvwwkik3l97z"; + + nativeBuildInputs = [ cmake ]; + + patches = [ + (fetchpatch { + url = "https://github.com/llvm-mirror/libunwind/commit/34a45c630d4c79af403661d267db42fbe7de1178.patch"; + sha256 = "0n0pv6jvcky8pn3srhrf9x5kbnd0d2kia9xlx2g590f5q0bgwfhv"; + }) + (fetchpatch { + url = "https://github.com/llvm-mirror/libunwind/commit/e050272d2eb57eb4e56a37b429a61df2ebb8aa3e.patch"; + sha256 = "1sxyx5xnax8k713jjcxgq3jq3cpnxygs2rcdf5vfja0f2k9jzldl"; + }) + ]; + + enableParallelBuilding = true; +} diff --git a/nixpkgs/pkgs/development/compilers/llvm/8/lld.nix b/nixpkgs/pkgs/development/compilers/llvm/8/lld.nix new file mode 100644 index 000000000000..7fff6843c5f4 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/8/lld.nix @@ -0,0 +1,32 @@ +{ stdenv +, fetch +, cmake +, libxml2 +, llvm +, version +}: + +stdenv.mkDerivation { + name = "lld-${version}"; + + src = fetch "lld" "0dvf38pbm7jy88g66mz7ikkdfhm2qpj0iyzh62hzycifjbnciblw"; + + nativeBuildInputs = [ cmake ]; + buildInputs = [ llvm libxml2 ]; + + outputs = [ "out" "dev" ]; + + enableParallelBuilding = true; + + postInstall = '' + moveToOutput include "$dev" + moveToOutput lib "$dev" + ''; + + meta = { + description = "The LLVM Linker"; + homepage = http://lld.llvm.org/; + license = stdenv.lib.licenses.ncsa; + platforms = stdenv.lib.platforms.all; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/llvm/8/lldb.nix b/nixpkgs/pkgs/development/compilers/llvm/8/lldb.nix new file mode 100644 index 000000000000..ae9198e99d27 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/8/lldb.nix @@ -0,0 +1,60 @@ +{ stdenv +, fetch +, cmake +, zlib +, ncurses +, swig +, which +, libedit +, libxml2 +, llvm +, clang-unwrapped +, python +, version +, darwin +}: + +stdenv.mkDerivation { + name = "lldb-${version}"; + + src = fetch "lldb" "0wq3mi76fk86g2g2bcsr0yhagh1dlf2myk641ai58rc116gqp4a9"; + + postPatch = '' + # Fix up various paths that assume llvm and clang are installed in the same place + sed -i 's,".*ClangConfig.cmake","${clang-unwrapped}/lib/cmake/clang/ClangConfig.cmake",' \ + cmake/modules/LLDBStandalone.cmake + sed -i 's,".*tools/clang/include","${clang-unwrapped}/include",' \ + cmake/modules/LLDBStandalone.cmake + sed -i 's,"$.LLVM_LIBRARY_DIR.",${llvm}/lib ${clang-unwrapped}/lib,' \ + cmake/modules/LLDBStandalone.cmake + ''; + + nativeBuildInputs = [ cmake python which swig ]; + buildInputs = [ ncurses zlib libedit libxml2 llvm ] + ++ stdenv.lib.optionals stdenv.isDarwin [ darwin.libobjc darwin.apple_sdk.libs.xpc darwin.apple_sdk.frameworks.Foundation darwin.bootstrap_cmds darwin.apple_sdk.frameworks.Carbon darwin.apple_sdk.frameworks.Cocoa darwin.cf-private ]; + + CXXFLAGS = "-fno-rtti"; + hardeningDisable = [ "format" ]; + + cmakeFlags = [ + "-DLLDB_CODESIGN_IDENTITY=" # codesigning makes nondeterministic + ]; + + enableParallelBuilding = true; + + postInstall = '' + mkdir -p $out/share/man/man1 + cp ../docs/lldb.1 $out/share/man/man1/ + + install -D ../tools/lldb-vscode/package.json $out/share/vscode/extensions/llvm-org.lldb-vscode-0.1.0/package.json + mkdir $out/share/vscode/extensions/llvm-org.lldb-vscode-0.1.0/bin + ln -s $out/bin/lldb-vscode $out/share/vscode/extensions/llvm-org.lldb-vscode-0.1.0/bin + ''; + + meta = with stdenv.lib; { + description = "A next-generation high-performance debugger"; + homepage = http://llvm.org/; + license = licenses.ncsa; + platforms = platforms.all; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/llvm/8/llvm-outputs.patch b/nixpkgs/pkgs/development/compilers/llvm/8/llvm-outputs.patch new file mode 100644 index 000000000000..40096fa3497f --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/8/llvm-outputs.patch @@ -0,0 +1,26 @@ +diff --git a/tools/llvm-config/llvm-config.cpp b/tools/llvm-config/llvm-config.cpp +index 94d426b..37f7794 100644 +--- a/tools/llvm-config/llvm-config.cpp ++++ b/tools/llvm-config/llvm-config.cpp +@@ -333,6 +333,21 @@ int main(int argc, char **argv) { + ActiveIncludeOption = "-I" + ActiveIncludeDir; + } + ++ /// Nix-specific multiple-output handling: override ActiveLibDir if --link-shared ++ if (!IsInDevelopmentTree) { ++ bool WantShared = true; ++ for (int i = 1; i < argc; ++i) { ++ StringRef Arg = argv[i]; ++ if (Arg == "--link-shared") ++ WantShared = true; ++ else if (Arg == "--link-static") ++ WantShared = false; // the last one wins ++ } ++ ++ if (WantShared) ++ ActiveLibDir = std::string("@lib@") + "/lib" + LLVM_LIBDIR_SUFFIX; ++ } ++ + /// We only use `shared library` mode in cases where the static library form + /// of the components provided are not available; note however that this is + /// skipped if we're run from within the build dir. However, once installed, diff --git a/nixpkgs/pkgs/development/compilers/llvm/8/llvm.nix b/nixpkgs/pkgs/development/compilers/llvm/8/llvm.nix new file mode 100644 index 000000000000..5d8d08167298 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/8/llvm.nix @@ -0,0 +1,174 @@ +{ stdenv +, fetch +, fetchpatch +, cmake +, python +, libffi +, libbfd +, libpfm +, libxml2 +, ncurses +, version +, release_version +, zlib +, buildPackages +, debugVersion ? false +, enableManpages ? false +, enableSharedLibraries ? true +, enablePFM ? !stdenv.isDarwin +, enablePolly ? false +}: + +let + inherit (stdenv.lib) optional optionals optionalString; + + src = fetch "llvm" "0k124sxkfhfi1rca6kzkdraf4axhx99x3cw2rk55056628dvwwl8"; + polly_src = fetch "polly" "1x4xv3j226rqdddp7b61d71wsx2b8vmmri02ycx27y2fg7ba7xg3"; + + # Used when creating a version-suffixed symlink of libLLVM.dylib + shortVersion = with stdenv.lib; + concatStringsSep "." (take 1 (splitString "." release_version)); + +in stdenv.mkDerivation (rec { + name = "llvm-${version}"; + + unpackPhase = '' + unpackFile ${src} + mv llvm-${version}* llvm + sourceRoot=$PWD/llvm + '' + optionalString enablePolly '' + unpackFile ${polly_src} + mv polly-* $sourceRoot/tools/polly + ''; + + outputs = [ "out" "python" ] + ++ optional enableSharedLibraries "lib"; + + nativeBuildInputs = [ cmake python ] + ++ optionals enableManpages [ python.pkgs.sphinx python.pkgs.recommonmark ]; + + buildInputs = [ libxml2 libffi ] + ++ optional enablePFM libpfm; # exegesis + + propagatedBuildInputs = [ ncurses zlib ]; + + postPatch = optionalString stdenv.isDarwin '' + substituteInPlace cmake/modules/AddLLVM.cmake \ + --replace 'set(_install_name_dir INSTALL_NAME_DIR "@rpath")' "set(_install_name_dir)" \ + --replace 'set(_install_rpath "@loader_path/../lib" ''${extra_libdir})' "" + '' + # Patch llvm-config to return correct library path based on --link-{shared,static}. + + optionalString (enableSharedLibraries) '' + substitute '${./llvm-outputs.patch}' ./llvm-outputs.patch --subst-var lib + patch -p1 < ./llvm-outputs.patch + '' + '' + # FileSystem permissions tests fail with various special bits + substituteInPlace unittests/Support/CMakeLists.txt \ + --replace "Path.cpp" "" + rm unittests/Support/Path.cpp + '' + optionalString stdenv.hostPlatform.isMusl '' + patch -p1 -i ${../TLI-musl.patch} + substituteInPlace unittests/Support/CMakeLists.txt \ + --replace "add_subdirectory(DynamicLibrary)" "" + rm unittests/Support/DynamicLibrary/DynamicLibraryTest.cpp + # valgrind unhappy with musl or glibc, but fails w/musl only + rm test/CodeGen/AArch64/wineh4.mir + '' + '' + patchShebangs test/BugPoint/compile-custom.ll.py + ''; + + # hacky fix: created binaries need to be run before installation + preBuild = '' + mkdir -p $out/ + ln -sv $PWD/lib $out + ''; + + cmakeFlags = with stdenv; [ + "-DCMAKE_BUILD_TYPE=${if debugVersion then "Debug" else "Release"}" + "-DLLVM_INSTALL_UTILS=ON" # Needed by rustc + "-DLLVM_BUILD_TESTS=ON" + "-DLLVM_ENABLE_FFI=ON" + "-DLLVM_ENABLE_RTTI=ON" + "-DLLVM_HOST_TRIPLE=${stdenv.hostPlatform.config}" + "-DLLVM_DEFAULT_TARGET_TRIPLE=${stdenv.hostPlatform.config}" + "-DLLVM_ENABLE_DUMP=ON" + ] ++ optionals enableSharedLibraries [ + "-DLLVM_LINK_LLVM_DYLIB=ON" + ] ++ optionals enableManpages [ + "-DLLVM_BUILD_DOCS=ON" + "-DLLVM_ENABLE_SPHINX=ON" + "-DSPHINX_OUTPUT_MAN=ON" + "-DSPHINX_OUTPUT_HTML=OFF" + "-DSPHINX_WARNINGS_AS_ERRORS=OFF" + ] ++ optionals (!isDarwin) [ + "-DLLVM_BINUTILS_INCDIR=${libbfd.dev}/include" + ] ++ optionals (isDarwin) [ + "-DLLVM_ENABLE_LIBCXX=ON" + "-DCAN_TARGET_i386=false" + ] ++ optionals (stdenv.hostPlatform != stdenv.buildPlatform) [ + "-DCMAKE_CROSSCOMPILING=True" + "-DLLVM_TABLEGEN=${buildPackages.llvm_7}/bin/llvm-tblgen" + ]; + + postBuild = '' + rm -fR $out + ''; + + preCheck = '' + export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$PWD/lib + ''; + + postInstall = '' + mkdir -p $python/share + mv $out/share/opt-viewer $python/share/opt-viewer + '' + + optionalString enableSharedLibraries '' + moveToOutput "lib/libLLVM-*" "$lib" + moveToOutput "lib/libLLVM${stdenv.hostPlatform.extensions.sharedLibrary}" "$lib" + substituteInPlace "$out/lib/cmake/llvm/LLVMExports-${if debugVersion then "debug" else "release"}.cmake" \ + --replace "\''${_IMPORT_PREFIX}/lib/libLLVM-" "$lib/lib/libLLVM-" + '' + + optionalString (stdenv.isDarwin && enableSharedLibraries) '' + substituteInPlace "$out/lib/cmake/llvm/LLVMExports-${if debugVersion then "debug" else "release"}.cmake" \ + --replace "\''${_IMPORT_PREFIX}/lib/libLLVM.dylib" "$lib/lib/libLLVM.dylib" + ln -s $lib/lib/libLLVM.dylib $lib/lib/libLLVM-${shortVersion}.dylib + ln -s $lib/lib/libLLVM.dylib $lib/lib/libLLVM-${release_version}.dylib + ''; + + doCheck = stdenv.isLinux && (!stdenv.isx86_32); + + checkTarget = "check-all"; + + enableParallelBuilding = true; + + passthru.src = src; + + meta = { + description = "Collection of modular and reusable compiler and toolchain technologies"; + homepage = http://llvm.org/; + license = stdenv.lib.licenses.ncsa; + maintainers = with stdenv.lib.maintainers; [ lovek323 raskin dtzWill ]; + platforms = stdenv.lib.platforms.all; + }; +} // stdenv.lib.optionalAttrs enableManpages { + name = "llvm-manpages-${version}"; + + buildPhase = '' + make docs-llvm-man + ''; + + propagatedBuildInputs = []; + + installPhase = '' + make -C docs install + ''; + + postPatch = null; + postInstall = null; + + outputs = [ "out" ]; + + doCheck = false; + + meta.description = "man pages for LLVM ${version}"; +}) diff --git a/nixpkgs/pkgs/development/compilers/llvm/8/openmp.nix b/nixpkgs/pkgs/development/compilers/llvm/8/openmp.nix new file mode 100644 index 000000000000..bf85cae5abe7 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/8/openmp.nix @@ -0,0 +1,25 @@ +{ stdenv +, fetch +, cmake +, llvm +, perl +, version +}: + +stdenv.mkDerivation { + name = "openmp-${version}"; + + src = fetch "openmp" "1mf9cpgvix34xlpv0inkgl3qmdvgvp96f7sksqizri0n5xfp1cgp"; + + nativeBuildInputs = [ cmake perl ]; + buildInputs = [ llvm ]; + + enableParallelBuilding = true; + + meta = { + description = "Components required to build an executable OpenMP program"; + homepage = http://openmp.llvm.org/; + license = stdenv.lib.licenses.mit; + platforms = stdenv.lib.platforms.all; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/llvm/8/sanitizers-nongnu.patch b/nixpkgs/pkgs/development/compilers/llvm/8/sanitizers-nongnu.patch new file mode 100644 index 000000000000..1f2ac97818eb --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/8/sanitizers-nongnu.patch @@ -0,0 +1,412 @@ +From f7a253f8f85d0f49df6b73996737a3e84ac64236 Mon Sep 17 00:00:00 2001 +From: Will Dietz <w@wdtz.org> +Date: Mon, 24 Sep 2018 11:17:25 -0500 +Subject: [PATCH] Ported to 7.0, taken from gentoo-musl project. + +------ +Ported to compiler-rt-sanitizers-5.0.0. Taken from + +https://gist.githubusercontent.com/pwaller/2337f3290f12634cad3e3730cff0a6c1/raw/83c87a8585e2f9662494db5662e5361beb093c26/nongnu.patch +Signed-off-by: Jory A. Pratt <anarchy@gentoo.org> + +Taken from gentoo-musl project, with a few additional minor fixes. +--- + lib/asan/asan_linux.cc | 4 +- + lib/interception/interception_linux.cc | 2 +- + lib/interception/interception_linux.h | 2 +- + lib/msan/msan_linux.cc | 2 +- + lib/sanitizer_common/sanitizer_allocator.cc | 2 +- + .../sanitizer_common_interceptors_ioctl.inc | 4 +- + .../sanitizer_common_syscalls.inc | 2 +- + lib/sanitizer_common/sanitizer_linux.cc | 8 +++- + .../sanitizer_linux_libcdep.cc | 10 ++--- + lib/sanitizer_common/sanitizer_platform.h | 6 +++ + .../sanitizer_platform_interceptors.h | 4 +- + .../sanitizer_platform_limits_posix.cc | 37 +++++++++++-------- + lib/tsan/rtl/tsan_platform_linux.cc | 2 +- + 13 files changed, 51 insertions(+), 34 deletions(-) + +diff --git a/lib/asan/asan_linux.cc b/lib/asan/asan_linux.cc +index 625f32d40..73cf77aca 100644 +--- a/lib/asan/asan_linux.cc ++++ b/lib/asan/asan_linux.cc +@@ -46,7 +46,7 @@ + #include <link.h> + #endif + +-#if SANITIZER_ANDROID || SANITIZER_FREEBSD || SANITIZER_SOLARIS ++#if SANITIZER_ANDROID || SANITIZER_FREEBSD || SANITIZER_SOLARIS || SANITIZER_NONGNU + #include <ucontext.h> + extern "C" void* _DYNAMIC; + #elif SANITIZER_NETBSD +@@ -139,7 +139,7 @@ void AsanApplyToGlobals(globals_op_fptr op, const void *needle) { + UNIMPLEMENTED(); + } + +-#if SANITIZER_ANDROID ++#if SANITIZER_ANDROID || SANITIZER_NONGNU + // FIXME: should we do anything for Android? + void AsanCheckDynamicRTPrereqs() {} + void AsanCheckIncompatibleRT() {} +diff --git a/lib/interception/interception_linux.cc b/lib/interception/interception_linux.cc +index 26bfcd8f6..529b234f7 100644 +--- a/lib/interception/interception_linux.cc ++++ b/lib/interception/interception_linux.cc +@@ -43,7 +43,7 @@ bool GetRealFunctionAddress(const char *func_name, uptr *func_addr, + } + + // Android and Solaris do not have dlvsym +-#if !SANITIZER_ANDROID && !SANITIZER_SOLARIS && !SANITIZER_OPENBSD ++#if !SANITIZER_ANDROID && !SANITIZER_SOLARIS && !SANITIZER_OPENBSD && !SANITIZER_NONGNU + void *GetFuncAddrVer(const char *func_name, const char *ver) { + return dlvsym(RTLD_NEXT, func_name, ver); + } +diff --git a/lib/interception/interception_linux.h b/lib/interception/interception_linux.h +index 942c25609..24a4d5080 100644 +--- a/lib/interception/interception_linux.h ++++ b/lib/interception/interception_linux.h +@@ -36,7 +36,7 @@ void *GetFuncAddrVer(const char *func_name, const char *ver); + (::__interception::uptr) & WRAP(func)) + + // Android, Solaris and OpenBSD do not have dlvsym +-#if !SANITIZER_ANDROID && !SANITIZER_SOLARIS && !SANITIZER_OPENBSD ++#if !SANITIZER_ANDROID && !SANITIZER_SOLARIS && !SANITIZER_OPENBSD && !SANITIZER_NONGNU + #define INTERCEPT_FUNCTION_VER_LINUX_OR_FREEBSD(func, symver) \ + (::__interception::real_##func = (func##_f)( \ + unsigned long)::__interception::GetFuncAddrVer(#func, symver)) +diff --git a/lib/msan/msan_linux.cc b/lib/msan/msan_linux.cc +index 385a650c4..6e30a8ce9 100644 +--- a/lib/msan/msan_linux.cc ++++ b/lib/msan/msan_linux.cc +@@ -13,7 +13,7 @@ + //===----------------------------------------------------------------------===// + + #include "sanitizer_common/sanitizer_platform.h" +-#if SANITIZER_FREEBSD || SANITIZER_LINUX || SANITIZER_NETBSD ++#if SANITIZER_FREEBSD || (SANITIZER_LINUX && !SANITIZER_NONGNU) || SANITIZER_NETBSD + + #include "msan.h" + #include "msan_report.h" +diff --git a/lib/sanitizer_common/sanitizer_allocator.cc b/lib/sanitizer_common/sanitizer_allocator.cc +index 6bfd5e5ee..048f6154f 100644 +--- a/lib/sanitizer_common/sanitizer_allocator.cc ++++ b/lib/sanitizer_common/sanitizer_allocator.cc +@@ -27,7 +27,7 @@ const char *SecondaryAllocatorName = "LargeMmapAllocator"; + + // ThreadSanitizer for Go uses libc malloc/free. + #if SANITIZER_GO || defined(SANITIZER_USE_MALLOC) +-# if SANITIZER_LINUX && !SANITIZER_ANDROID ++# if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU + extern "C" void *__libc_malloc(uptr size); + # if !SANITIZER_GO + extern "C" void *__libc_memalign(uptr alignment, uptr size); +diff --git a/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc b/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc +index 2d633c173..b6eb23116 100644 +--- a/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc ++++ b/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc +@@ -104,7 +104,7 @@ static void ioctl_table_fill() { + _(SIOCGETVIFCNT, WRITE, struct_sioc_vif_req_sz); + #endif + +-#if SANITIZER_LINUX ++#if SANITIZER_LINUX && !SANITIZER_NONGNU + // Conflicting request ids. + // _(CDROMAUDIOBUFSIZ, NONE, 0); + // _(SNDCTL_TMR_CONTINUE, NONE, 0); +@@ -365,7 +365,7 @@ static void ioctl_table_fill() { + _(VT_WAITACTIVE, NONE, 0); + #endif + +-#if SANITIZER_LINUX && !SANITIZER_ANDROID ++#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU + // _(SIOCDEVPLIP, WRITE, struct_ifreq_sz); // the same as EQL_ENSLAVE + _(CYGETDEFTHRESH, WRITE, sizeof(int)); + _(CYGETDEFTIMEOUT, WRITE, sizeof(int)); +diff --git a/lib/sanitizer_common/sanitizer_common_syscalls.inc b/lib/sanitizer_common/sanitizer_common_syscalls.inc +index 469c8eb7e..24f87867d 100644 +--- a/lib/sanitizer_common/sanitizer_common_syscalls.inc ++++ b/lib/sanitizer_common/sanitizer_common_syscalls.inc +@@ -2038,7 +2038,7 @@ POST_SYSCALL(setrlimit)(long res, long resource, void *rlim) { + } + } + +-#if !SANITIZER_ANDROID ++#if !SANITIZER_ANDROID && !SANITIZER_NONGNU + PRE_SYSCALL(prlimit64)(long pid, long resource, const void *new_rlim, + void *old_rlim) { + if (new_rlim) PRE_READ(new_rlim, struct_rlimit64_sz); +diff --git a/lib/sanitizer_common/sanitizer_linux.cc b/lib/sanitizer_common/sanitizer_linux.cc +index 96d6c1eff..9e2b7fb9d 100644 +--- a/lib/sanitizer_common/sanitizer_linux.cc ++++ b/lib/sanitizer_common/sanitizer_linux.cc +@@ -541,13 +541,13 @@ const char *GetEnv(const char *name) { + #endif + } + +-#if !SANITIZER_FREEBSD && !SANITIZER_NETBSD && !SANITIZER_OPENBSD ++#if !SANITIZER_FREEBSD && !SANITIZER_NETBSD && !SANITIZER_OPENBSD && !SANITIZER_NONGNU + extern "C" { + SANITIZER_WEAK_ATTRIBUTE extern void *__libc_stack_end; + } + #endif + +-#if !SANITIZER_GO && !SANITIZER_FREEBSD && !SANITIZER_NETBSD && \ ++#if (!SANITIZER_GO || SANITIZER_NONGNU) && !SANITIZER_FREEBSD && !SANITIZER_NETBSD && \ + !SANITIZER_OPENBSD + static void ReadNullSepFileToArray(const char *path, char ***arr, + int arr_size) { +@@ -590,6 +590,10 @@ static void GetArgsAndEnv(char ***argv, char ***envp) { + #elif SANITIZER_NETBSD + *argv = __ps_strings->ps_argvstr; + *envp = __ps_strings->ps_envstr; ++#elif SANITIZER_NONGNU ++ static const int kMaxArgv = 2000, kMaxEnvp = 2000; ++ ReadNullSepFileToArray("/proc/self/cmdline", argv, kMaxArgv); ++ ReadNullSepFileToArray("/proc/self/environ", envp, kMaxEnvp); + #else // SANITIZER_FREEBSD + #if !SANITIZER_GO + if (&__libc_stack_end) { +diff --git a/lib/sanitizer_common/sanitizer_linux_libcdep.cc b/lib/sanitizer_common/sanitizer_linux_libcdep.cc +index 4962ff832..438f94dbe 100644 +--- a/lib/sanitizer_common/sanitizer_linux_libcdep.cc ++++ b/lib/sanitizer_common/sanitizer_linux_libcdep.cc +@@ -179,7 +179,7 @@ __attribute__((unused)) static bool GetLibcVersion(int *major, int *minor, + } + + #if !SANITIZER_FREEBSD && !SANITIZER_ANDROID && !SANITIZER_GO && \ +- !SANITIZER_NETBSD && !SANITIZER_OPENBSD && !SANITIZER_SOLARIS ++ !SANITIZER_NETBSD && !SANITIZER_OPENBSD && !SANITIZER_SOLARIS && !SANITIZER_NONGNU + static uptr g_tls_size; + + #ifdef __i386__ +@@ -261,7 +261,7 @@ void InitTlsSize() { } + #if (defined(__x86_64__) || defined(__i386__) || defined(__mips__) || \ + defined(__aarch64__) || defined(__powerpc64__) || defined(__s390__) || \ + defined(__arm__)) && \ +- SANITIZER_LINUX && !SANITIZER_ANDROID ++ SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU + // sizeof(struct pthread) from glibc. + static atomic_uintptr_t thread_descriptor_size; + +@@ -426,7 +426,7 @@ int GetSizeFromHdr(struct dl_phdr_info *info, size_t size, void *data) { + + #if !SANITIZER_GO + static void GetTls(uptr *addr, uptr *size) { +-#if SANITIZER_LINUX && !SANITIZER_ANDROID ++#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU + # if defined(__x86_64__) || defined(__i386__) || defined(__s390__) + *addr = ThreadSelf(); + *size = GetTlsSize(); +@@ -470,7 +470,7 @@ static void GetTls(uptr *addr, uptr *size) { + #elif SANITIZER_OPENBSD + *addr = 0; + *size = 0; +-#elif SANITIZER_ANDROID ++#elif SANITIZER_ANDROID || SANITIZER_NONGNU + *addr = 0; + *size = 0; + #elif SANITIZER_SOLARIS +@@ -486,7 +486,7 @@ static void GetTls(uptr *addr, uptr *size) { + #if !SANITIZER_GO + uptr GetTlsSize() { + #if SANITIZER_FREEBSD || SANITIZER_ANDROID || SANITIZER_NETBSD || \ +- SANITIZER_OPENBSD || SANITIZER_SOLARIS ++ SANITIZER_OPENBSD || SANITIZER_SOLARIS || SANITIZER_NONGNU + uptr addr, size; + GetTls(&addr, &size); + return size; +diff --git a/lib/sanitizer_common/sanitizer_platform.h b/lib/sanitizer_common/sanitizer_platform.h +index d81e25580..e10680ac8 100644 +--- a/lib/sanitizer_common/sanitizer_platform.h ++++ b/lib/sanitizer_common/sanitizer_platform.h +@@ -208,6 +208,12 @@ + # define SANITIZER_SOLARIS32 0 + #endif + ++#if defined(__linux__) && !defined(__GLIBC__) ++# define SANITIZER_NONGNU 1 ++#else ++# define SANITIZER_NONGNU 0 ++#endif ++ + #if defined(__myriad2__) + # define SANITIZER_MYRIAD2 1 + #else +diff --git a/lib/sanitizer_common/sanitizer_platform_interceptors.h b/lib/sanitizer_common/sanitizer_platform_interceptors.h +index f95539a73..6c53b3415 100644 +--- a/lib/sanitizer_common/sanitizer_platform_interceptors.h ++++ b/lib/sanitizer_common/sanitizer_platform_interceptors.h +@@ -39,7 +39,7 @@ + # include "sanitizer_platform_limits_solaris.h" + #endif + +-#if SANITIZER_LINUX && !SANITIZER_ANDROID ++#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU + # define SI_LINUX_NOT_ANDROID 1 + #else + # define SI_LINUX_NOT_ANDROID 0 +@@ -322,7 +322,7 @@ + #define SANITIZER_INTERCEPT_ETHER_R (SI_FREEBSD || SI_LINUX_NOT_ANDROID) + #define SANITIZER_INTERCEPT_SHMCTL \ + (SI_NETBSD || SI_OPENBSD || SI_SOLARIS || \ +- ((SI_FREEBSD || SI_LINUX_NOT_ANDROID) && \ ++ ((SI_FREEBSD || SI_LINUX_NOT_ANDROID || SANITIZER_NONGNU) && \ + SANITIZER_WORDSIZE == 64)) // NOLINT + #define SANITIZER_INTERCEPT_RANDOM_R SI_LINUX_NOT_ANDROID + #define SANITIZER_INTERCEPT_PTHREAD_ATTR_GET SI_POSIX +diff --git a/lib/sanitizer_common/sanitizer_platform_limits_posix.cc b/lib/sanitizer_common/sanitizer_platform_limits_posix.cc +index 54da635d7..2f6ff69c3 100644 +--- a/lib/sanitizer_common/sanitizer_platform_limits_posix.cc ++++ b/lib/sanitizer_common/sanitizer_platform_limits_posix.cc +@@ -14,6 +14,9 @@ + + #include "sanitizer_platform.h" + ++// Workaround musl <--> linux conflicting definition of 'struct sysinfo' ++#define _LINUX_SYSINFO_H ++ + #if SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_MAC + // Tests in this file assume that off_t-dependent data structures match the + // libc ABI. For example, struct dirent here is what readdir() function (as +@@ -138,12 +141,14 @@ typedef struct user_fpregs elf_fpregset_t; + + #if SANITIZER_LINUX && !SANITIZER_ANDROID + #include <glob.h> +-#include <obstack.h> ++# if !SANITIZER_NONGNU ++# include <obstack.h> ++# endif + #include <mqueue.h> +-#include <net/if_ppp.h> +-#include <netax25/ax25.h> +-#include <netipx/ipx.h> +-#include <netrom/netrom.h> ++#include <linux/if_ppp.h> ++#include <linux/ax25.h> ++#include <linux/ipx.h> ++#include <linux/netrom.h> + #if HAVE_RPC_XDR_H + # include <rpc/xdr.h> + #elif HAVE_TIRPC_RPC_XDR_H +@@ -251,7 +256,7 @@ namespace __sanitizer { + unsigned struct_itimerspec_sz = sizeof(struct itimerspec); + #endif // SANITIZER_LINUX || SANITIZER_FREEBSD + +-#if SANITIZER_LINUX && !SANITIZER_ANDROID ++#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU + // Use pre-computed size of struct ustat to avoid <sys/ustat.h> which + // has been removed from glibc 2.28. + #if defined(__aarch64__) || defined(__s390x__) || defined (__mips64) \ +@@ -322,7 +327,7 @@ unsigned struct_ElfW_Phdr_sz = sizeof(ElfW(Phdr)); + unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr); + #endif + +-#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID ++#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID && !SANITIZER_NONGNU + int glob_nomatch = GLOB_NOMATCH; + int glob_altdirfunc = GLOB_ALTDIRFUNC; + #endif +@@ -416,7 +421,7 @@ unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr); + unsigned struct_termios_sz = sizeof(struct termios); + unsigned struct_winsize_sz = sizeof(struct winsize); + +-#if SANITIZER_LINUX ++#if SANITIZER_LINUX && !SANITIZER_NONGNU + unsigned struct_arpreq_sz = sizeof(struct arpreq); + unsigned struct_cdrom_msf_sz = sizeof(struct cdrom_msf); + unsigned struct_cdrom_multisession_sz = sizeof(struct cdrom_multisession); +@@ -466,7 +471,7 @@ unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr); + unsigned struct_vt_mode_sz = sizeof(struct vt_mode); + #endif // SANITIZER_LINUX || SANITIZER_FREEBSD + +-#if SANITIZER_LINUX && !SANITIZER_ANDROID ++#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU + unsigned struct_ax25_parms_struct_sz = sizeof(struct ax25_parms_struct); + unsigned struct_cyclades_monitor_sz = sizeof(struct cyclades_monitor); + #if EV_VERSION > (0x010000) +@@ -834,7 +839,7 @@ unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr); + unsigned IOCTL_VT_WAITACTIVE = VT_WAITACTIVE; + #endif // SANITIZER_LINUX || SANITIZER_FREEBSD + +-#if SANITIZER_LINUX && !SANITIZER_ANDROID ++#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU + unsigned IOCTL_CYGETDEFTHRESH = CYGETDEFTHRESH; + unsigned IOCTL_CYGETDEFTIMEOUT = CYGETDEFTIMEOUT; + unsigned IOCTL_CYGETMON = CYGETMON; +@@ -989,7 +994,7 @@ CHECK_SIZE_AND_OFFSET(dl_phdr_info, dlpi_phdr); + CHECK_SIZE_AND_OFFSET(dl_phdr_info, dlpi_phnum); + #endif // SANITIZER_LINUX || SANITIZER_FREEBSD + +-#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID ++#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID && !SANITIZER_NONGNU + CHECK_TYPE_SIZE(glob_t); + CHECK_SIZE_AND_OFFSET(glob_t, gl_pathc); + CHECK_SIZE_AND_OFFSET(glob_t, gl_pathv); +@@ -1023,6 +1028,7 @@ CHECK_TYPE_SIZE(iovec); + CHECK_SIZE_AND_OFFSET(iovec, iov_base); + CHECK_SIZE_AND_OFFSET(iovec, iov_len); + ++#if !SANITIZER_NONGNU + CHECK_TYPE_SIZE(msghdr); + CHECK_SIZE_AND_OFFSET(msghdr, msg_name); + CHECK_SIZE_AND_OFFSET(msghdr, msg_namelen); +@@ -1036,6 +1042,7 @@ CHECK_TYPE_SIZE(cmsghdr); + CHECK_SIZE_AND_OFFSET(cmsghdr, cmsg_len); + CHECK_SIZE_AND_OFFSET(cmsghdr, cmsg_level); + CHECK_SIZE_AND_OFFSET(cmsghdr, cmsg_type); ++#endif + + #ifndef __GLIBC_PREREQ + #define __GLIBC_PREREQ(x, y) 0 +@@ -1145,7 +1152,7 @@ CHECK_SIZE_AND_OFFSET(mntent, mnt_passno); + + CHECK_TYPE_SIZE(ether_addr); + +-#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID ++#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID && !SANITIZER_NONGNU + CHECK_TYPE_SIZE(ipc_perm); + # if SANITIZER_FREEBSD + CHECK_SIZE_AND_OFFSET(ipc_perm, key); +@@ -1206,7 +1213,7 @@ CHECK_SIZE_AND_OFFSET(ifaddrs, ifa_dstaddr); + CHECK_SIZE_AND_OFFSET(ifaddrs, ifa_data); + #endif + +-#if SANITIZER_LINUX ++#if SANITIZER_LINUX && !SANITIZER_NONGNU + COMPILER_CHECK(sizeof(__sanitizer_mallinfo) == sizeof(struct mallinfo)); + #endif + +@@ -1256,7 +1263,7 @@ COMPILER_CHECK(__sanitizer_XDR_DECODE == XDR_DECODE); + COMPILER_CHECK(__sanitizer_XDR_FREE == XDR_FREE); + #endif + +-#if SANITIZER_LINUX && !SANITIZER_ANDROID ++#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU + COMPILER_CHECK(sizeof(__sanitizer_FILE) <= sizeof(FILE)); + CHECK_SIZE_AND_OFFSET(FILE, _flags); + CHECK_SIZE_AND_OFFSET(FILE, _IO_read_ptr); +@@ -1275,7 +1282,7 @@ CHECK_SIZE_AND_OFFSET(FILE, _chain); + CHECK_SIZE_AND_OFFSET(FILE, _fileno); + #endif + +-#if SANITIZER_LINUX && !SANITIZER_ANDROID ++#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU + COMPILER_CHECK(sizeof(__sanitizer__obstack_chunk) <= sizeof(_obstack_chunk)); + CHECK_SIZE_AND_OFFSET(_obstack_chunk, limit); + CHECK_SIZE_AND_OFFSET(_obstack_chunk, prev); +diff --git a/lib/tsan/rtl/tsan_platform_linux.cc b/lib/tsan/rtl/tsan_platform_linux.cc +index de989b780..51a97b554 100644 +--- a/lib/tsan/rtl/tsan_platform_linux.cc ++++ b/lib/tsan/rtl/tsan_platform_linux.cc +@@ -294,7 +294,7 @@ void InitializePlatform() { + // This is required to properly "close" the fds, because we do not see internal + // closes within glibc. The code is a pure hack. + int ExtractResolvFDs(void *state, int *fds, int nfd) { +-#if SANITIZER_LINUX && !SANITIZER_ANDROID ++#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU + int cnt = 0; + struct __res_state *statp = (struct __res_state*)state; + for (int i = 0; i < MAXNS && cnt < nfd; i++) { +-- +2.19.0 + diff --git a/nixpkgs/pkgs/development/compilers/llvm/TLI-musl.patch b/nixpkgs/pkgs/development/compilers/llvm/TLI-musl.patch new file mode 100644 index 000000000000..1a6908086637 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/TLI-musl.patch @@ -0,0 +1,35 @@ +From 5c571082fdaf61f6df19d9b7137dc26d71334058 Mon Sep 17 00:00:00 2001 +From: Natanael Copa <ncopa@alpinelinux.org> +Date: Thu, 18 Feb 2016 10:33:04 +0100 +Subject: [PATCH 2/3] Fix build with musl libc + +On musl libc the fopen64 and fopen are the same thing, but for +compatibility they have a `#define fopen64 fopen`. Same applies for +fseek64, fstat64, fstatvfs64, ftello64, lstat64, stat64 and tmpfile64. +--- + include/llvm/Analysis/TargetLibraryInfo.h | 9 +++++++++ + 1 file changed, 9 insertions(+) + +diff --git a/include/llvm/Analysis/TargetLibraryInfo.h b/include/llvm/Analysis/TargetLibraryInfo.h +index 7becdf0..7f14427 100644 +--- a/include/llvm/Analysis/TargetLibraryInfo.h ++++ b/include/llvm/Analysis/TargetLibraryInfo.h +@@ -18,6 +18,15 @@ + #include "llvm/IR/Module.h" + #include "llvm/Pass.h" + ++#undef fopen64 ++#undef fseeko64 ++#undef fstat64 ++#undef fstatvfs64 ++#undef ftello64 ++#undef lstat64 ++#undef stat64 ++#undef tmpfile64 ++ + namespace llvm { + /// VecDesc - Describes a possible vectorization of a function. + /// Function 'VectorFnName' is equivalent to 'ScalarFnName' vectorized +-- +2.7.3 + diff --git a/nixpkgs/pkgs/development/compilers/llvm/aarch64.patch b/nixpkgs/pkgs/development/compilers/llvm/aarch64.patch new file mode 100644 index 000000000000..205074e48e4e --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/aarch64.patch @@ -0,0 +1,51 @@ +--- lib/Support/Unix/Memory.inc ++++ lib/Support/Unix/Memory.inc +@@ -126,8 +126,12 @@ + Result.Address = Addr; + Result.Size = NumPages*PageSize; + +- if (PFlags & MF_EXEC) +- Memory::InvalidateInstructionCache(Result.Address, Result.Size); ++ // Rely on protectMappedMemory to invalidate instruction cache. ++ if (PFlags & MF_EXEC) { ++ EC = Memory::protectMappedMemory (Result, PFlags); ++ if (EC != std::error_code()) ++ return MemoryBlock(); ++ } + + return Result; + } +@@ -156,15 +160,31 @@ + return std::error_code(EINVAL, std::generic_category()); + + int Protect = getPosixProtectionFlags(Flags); +- + uintptr_t Start = alignAddr((uint8_t *)M.Address - PageSize + 1, PageSize); + uintptr_t End = alignAddr((uint8_t *)M.Address + M.Size, PageSize); ++ ++ bool InvalidateCache = (Flags & MF_EXEC); ++ ++#if defined(__arm__) || defined(__aarch64__) ++ // Certain ARM implementations treat icache clear instruction as a memory read, ++ // and CPU segfaults on trying to clear cache on !PROT_READ page. Therefore we need ++ // to temporarily add PROT_READ for the sake of flushing the instruction caches. ++ if (InvalidateCache && !(Protect & PROT_READ)) { ++ int Result = ::mprotect((void *)Start, End - Start, Protect | PROT_READ); ++ if (Result != 0) ++ return std::error_code(errno, std::generic_category()); ++ ++ Memory::InvalidateInstructionCache(M.Address, M.Size); ++ InvalidateCache = false; ++ } ++#endif ++ + int Result = ::mprotect((void *)Start, End - Start, Protect); + + if (Result != 0) + return std::error_code(errno, std::generic_category()); + +- if (Flags & MF_EXEC) ++ if (InvalidateCache) + Memory::InvalidateInstructionCache(M.Address, M.Size); + + return std::error_code(); diff --git a/nixpkgs/pkgs/development/compilers/llvm/dynamiclibrary-musl.patch b/nixpkgs/pkgs/development/compilers/llvm/dynamiclibrary-musl.patch new file mode 100644 index 000000000000..d5d7f07b5e11 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/dynamiclibrary-musl.patch @@ -0,0 +1,33 @@ +From d12ecb83d01dcb580dd94f4d57828f33d3eb4c35 Mon Sep 17 00:00:00 2001 +From: Natanael Copa <ncopa@alpinelinux.org> +Date: Thu, 18 Feb 2016 15:33:21 +0100 +Subject: [PATCH 3/3] Fix DynamicLibrary to build with musl libc + +stdin/out/err is part of the libc and not the kernel so we check for the +specific libc that does the unexpected instead of linux. + +This is needed for making it build with musl libc. +--- + lib/Support/DynamicLibrary.cpp | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/lib/Support/DynamicLibrary.cpp b/lib/Support/DynamicLibrary.cpp +index 9a7aeb5..0c1c8f8 100644 +--- a/lib/Support/DynamicLibrary.cpp ++++ b/lib/Support/DynamicLibrary.cpp +@@ -140,10 +140,10 @@ void* DynamicLibrary::SearchForAddressOfSymbol(const char *symbolName) { + #define EXPLICIT_SYMBOL(SYM) \ + if (!strcmp(symbolName, #SYM)) return &SYM + +-// On linux we have a weird situation. The stderr/out/in symbols are both ++// On GNU libc we have a weird situation. The stderr/out/in symbols are both + // macros and global variables because of standards requirements. So, we + // boldly use the EXPLICIT_SYMBOL macro without checking for a #define first. +-#if defined(__linux__) and !defined(__ANDROID__) ++#if defined(__GLIBC__) + { + EXPLICIT_SYMBOL(stderr); + EXPLICIT_SYMBOL(stdout); +-- +2.7.3 + diff --git a/nixpkgs/pkgs/development/compilers/llvm/fix-llvm-config.patch b/nixpkgs/pkgs/development/compilers/llvm/fix-llvm-config.patch new file mode 100644 index 000000000000..772c49609275 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/fix-llvm-config.patch @@ -0,0 +1,13 @@ +diff --git a/utils/llvm-build/llvmbuild/main.py b/utils/llvm-build/llvmbuild/main.py +index eacefdf60bf..40d25f5cef8 100644 +--- a/utils/llvm-build/llvmbuild/main.py ++++ b/utils/llvm-build/llvmbuild/main.py +@@ -412,7 +412,7 @@ subdirectories = %s + if library_name is None: + library_name_as_cstr = '0' + else: +- library_name_as_cstr = '"lib%s.a"' % library_name ++ library_name_as_cstr = '"lib%s.so"' % library_name + f.write(' { "%s", %s, %d, { %s } },\n' % ( + name, library_name_as_cstr, is_installed, + ', '.join('"%s"' % dep diff --git a/nixpkgs/pkgs/development/compilers/llvm/libcxx-0001-musl-hacks.patch b/nixpkgs/pkgs/development/compilers/llvm/libcxx-0001-musl-hacks.patch new file mode 100644 index 000000000000..bcb5ad8cfb87 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/libcxx-0001-musl-hacks.patch @@ -0,0 +1,39 @@ +From 1c936d7fda3275265e37f93697232a1ed652390f Mon Sep 17 00:00:00 2001 +From: Will Dietz <w@wdtz.org> +Date: Sat, 9 Jul 2016 19:22:54 -0500 +Subject: [PATCH] musl fixes/hacks + +Conflicts: + + include/__config + include/locale + src/locale.cpp +--- + include/locale | 4 ++-- + 1 files changed, 2 insertions(+), 2 deletions(-) + +diff --git a/include/locale b/include/locale +index 3d804e8..9b01f5b 100644 +--- a/include/locale ++++ b/include/locale +@@ -695,7 +695,7 @@ __num_get_signed_integral(const char* __a, const char* __a_end, + typename remove_reference<decltype(errno)>::type __save_errno = errno; + errno = 0; + char *__p2; +- long long __ll = strtoll_l(__a, &__p2, __base, _LIBCPP_GET_C_LOCALE); ++ long long __ll = strtoll(__a, &__p2, __base); + typename remove_reference<decltype(errno)>::type __current_errno = errno; + if (__current_errno == 0) + errno = __save_errno; +@@ -735,7 +735,7 @@ __num_get_unsigned_integral(const char* __a, const char* __a_end, + typename remove_reference<decltype(errno)>::type __save_errno = errno; + errno = 0; + char *__p2; +- unsigned long long __ll = strtoull_l(__a, &__p2, __base, _LIBCPP_GET_C_LOCALE); ++ unsigned long long __ll = strtoull(__a, &__p2, __base); + typename remove_reference<decltype(errno)>::type __current_errno = errno; + if (__current_errno == 0) + errno = __save_errno; +-- +1.7.1 + diff --git a/nixpkgs/pkgs/development/compilers/llvm/libcxx-max_align_t.patch b/nixpkgs/pkgs/development/compilers/llvm/libcxx-max_align_t.patch new file mode 100644 index 000000000000..060be5b23de8 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/libcxx-max_align_t.patch @@ -0,0 +1,54 @@ +From 917331c88bd2afce0cf0fdbcab55a64541b5bcf0 Mon Sep 17 00:00:00 2001 +From: "David L. Jones" <dlj@google.com> +Date: Fri, 10 Feb 2017 01:27:42 +0000 +Subject: [PATCH] Check for musl-libc's max_align_t in addition to other + variants. + +Summary: +Libcxx will define its own max_align_t when it is not available. However, the +availability checks today only check for Clang's definition and GCC's +definition. In particular, it does not check for musl's definition, which is the +same as GCC's but guarded with a different macro. + +Reviewers: mclow.lists, EricWF + +Reviewed By: EricWF + +Subscribers: chandlerc, cfe-commits + +Differential Revision: https://reviews.llvm.org/D28478 + +git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@294683 91177308-0d34-0410-b5e6-96231b3b80d8 +--- + include/cstddef | 3 ++- + include/stddef.h | 3 ++- + 2 files changed, 4 insertions(+), 2 deletions(-) + +diff --git a/include/cstddef b/include/cstddef +index edd106c00..103898b7d 100644 +--- a/include/cstddef ++++ b/include/cstddef +@@ -48,7 +48,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD + using ::ptrdiff_t; + using ::size_t; + +-#if defined(__CLANG_MAX_ALIGN_T_DEFINED) || defined(_GCC_MAX_ALIGN_T) ++#if defined(__CLANG_MAX_ALIGN_T_DEFINED) || defined(_GCC_MAX_ALIGN_T) || \ ++ defined(__DEFINED_max_align_t) + // Re-use the compiler's <stddef.h> max_align_t where possible. + using ::max_align_t; + #else +diff --git a/include/stddef.h b/include/stddef.h +index 8841bbea2..faf8552d8 100644 +--- a/include/stddef.h ++++ b/include/stddef.h +@@ -53,7 +53,8 @@ using std::nullptr_t; + } + + // Re-use the compiler's <stddef.h> max_align_t where possible. +-#if !defined(__CLANG_MAX_ALIGN_T_DEFINED) && !defined(_GCC_MAX_ALIGN_T) ++#if !defined(__CLANG_MAX_ALIGN_T_DEFINED) && !defined(_GCC_MAX_ALIGN_T) && \ ++ !defined(__DEFINED_max_align_t) + typedef long double max_align_t; + #endif + diff --git a/nixpkgs/pkgs/development/compilers/llvm/multi.nix b/nixpkgs/pkgs/development/compilers/llvm/multi.nix new file mode 100644 index 000000000000..b4f2f8f9d6f6 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/llvm/multi.nix @@ -0,0 +1,48 @@ +{ runCommand, +clang, +gcc64, +gcc32, +glibc_multi +}: + +let + combine = basegcc: runCommand "combine-gcc-libc" {} '' + mkdir -p $out + cp -r ${basegcc.cc}/lib $out/lib + + chmod u+rw -R $out/lib + cp -r ${basegcc.libc}/lib/* $(ls -d $out/lib/gcc/*/*) + ''; + gcc_multi_sysroot = runCommand "gcc-multi-sysroot" {} '' + mkdir -p $out/lib/gcc + + ln -s ${combine gcc64}/lib/gcc/* $out/lib/gcc/ + ln -s ${combine gcc32}/lib/gcc/* $out/lib/gcc/ + # XXX: This shouldn't be needed, clang just doesn't look for "i686-unknown" + ln -s $out/lib/gcc/i686-unknown-linux-gnu $out/lib/gcc/i686-pc-linux-gnu + + + # includes + ln -s ${glibc_multi.dev}/include $out/ + + # dynamic linkers + mkdir -p $out/lib/32 + ln -s ${glibc_multi.out}/lib/ld-linux* $out/lib + ln -s ${glibc_multi.out}/lib/32/ld-linux* $out/lib/32/ + ''; + + clangMulti = clang.override { + # Only used for providing expected structure re:dynamic linkers, AFAIK + # Most of the magic is done by setting the --gcc-toolchain option below + libc = gcc_multi_sysroot; + + bintools = clang.bintools.override { + libc = gcc_multi_sysroot; + }; + + extraBuildCommands = '' + sed -e '$a --gcc-toolchain=${gcc_multi_sysroot}' -i $out/nix-support/libc-cflags + ''; + }; + +in clangMulti diff --git a/nixpkgs/pkgs/development/compilers/manticore/default.nix b/nixpkgs/pkgs/development/compilers/manticore/default.nix new file mode 100644 index 000000000000..efbf8561b7ff --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/manticore/default.nix @@ -0,0 +1,55 @@ +{ stdenv, fetchFromGitHub, coreutils, autoreconfHook, smlnj }: + +let + rev= "47273c463fc3c5d0a0ae655cf75a4700bdb020b4"; +in stdenv.mkDerivation rec { + name = "manticore-${version}"; + version = "2018.09.29"; + + src = fetchFromGitHub { + owner = "ManticoreProject"; + repo = "manticore"; + sha256 = "1prrgp7ldkdnrdbj224qqkirw8bj72460ix97c96fy264j9c97cn"; + inherit rev; + }; + + enableParallelBuilding = false; + + nativeBuildInputs = [ autoreconfHook ]; + + buildInputs = [ coreutils smlnj ]; + + autoreconfFlags = "-Iconfig -vfi"; + + unpackPhase = '' + mkdir -p $out + cd $out + unpackFile $src + mv source repo_checkout + cd repo_checkout + chmod u+w . -R + ''; + + postPatch = '' + patchShebangs . + substituteInPlace configure.ac --replace 'MANTICORE_ROOT=`pwd`' 'MANTICORE_ROOT=$out/repo_checkout' + ''; + + preInstall = "mkdir -p $out/bin"; + + meta = { + description = "A parallel, pure variant of Standard ML"; + + longDescription = '' + Manticore is a high-level parallel programming language aimed at + general-purpose applications running on multi-core + processors. Manticore supports parallelism at multiple levels: + explicit concurrency and coarse-grain parallelism via CML-style + constructs and fine-grain parallelism via various light-weight + notations, such as parallel tuple expressions and NESL/Nepal-style + parallel array comprehensions. + ''; + + homepage = http://manticore.cs.uchicago.edu/; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/matter-compiler/Gemfile b/nixpkgs/pkgs/development/compilers/matter-compiler/Gemfile new file mode 100644 index 000000000000..21ec23452055 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/matter-compiler/Gemfile @@ -0,0 +1,3 @@ +source "https://rubygems.org" + +gem 'matter_compiler' diff --git a/nixpkgs/pkgs/development/compilers/matter-compiler/Gemfile.lock b/nixpkgs/pkgs/development/compilers/matter-compiler/Gemfile.lock new file mode 100644 index 000000000000..ab1833b3cfe9 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/matter-compiler/Gemfile.lock @@ -0,0 +1,13 @@ +GEM + remote: https://rubygems.org/ + specs: + matter_compiler (0.5.1) + +PLATFORMS + ruby + +DEPENDENCIES + matter_compiler + +BUNDLED WITH + 1.17.2 diff --git a/nixpkgs/pkgs/development/compilers/matter-compiler/default.nix b/nixpkgs/pkgs/development/compilers/matter-compiler/default.nix new file mode 100644 index 000000000000..4b3ff844977e --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/matter-compiler/default.nix @@ -0,0 +1,18 @@ +{ lib, bundlerApp }: + +bundlerApp { + pname = "matter_compiler"; + gemdir = ./.; + exes = [ "matter_compiler" ]; + + meta = with lib; { + description = '' + Matter Compiler is a API Blueprint AST Media Types to API Blueprint conversion tool. + It composes an API blueprint from its serialzed AST media-type. + ''; + homepage = https://github.com/apiaryio/matter_compiler/; + license = licenses.mit; + maintainers = with maintainers; [ rvlander manveru ]; + platforms = platforms.unix; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/matter-compiler/gemset.nix b/nixpkgs/pkgs/development/compilers/matter-compiler/gemset.nix new file mode 100644 index 000000000000..014fc226607a --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/matter-compiler/gemset.nix @@ -0,0 +1,12 @@ +{ + matter_compiler = { + groups = ["default"]; + platforms = []; + source = { + remotes = ["https://rubygems.org"]; + sha256 = "16501zdiqxk34v2d0nlbwrcrjm6g57hrsmsw0crwssn29v5zbykf"; + type = "gem"; + }; + version = "0.5.1"; + }; +} \ No newline at end of file diff --git a/nixpkgs/pkgs/development/compilers/mcpp/default.nix b/nixpkgs/pkgs/development/compilers/mcpp/default.nix new file mode 100644 index 000000000000..9ce7c9166bca --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/mcpp/default.nix @@ -0,0 +1,19 @@ +{ stdenv, fetchurl }: + +stdenv.mkDerivation rec { + name = "mcpp-2.7.2"; + + src = fetchurl { + url = "mirror://sourceforge/mcpp/${name}.tar.gz"; + sha256 = "0r48rfghjm90pkdyr4khxg783g9v98rdx2n69xn8f6c5i0hl96rv"; + }; + + configureFlags = [ "--enable-mcpplib" ]; + + meta = with stdenv.lib; { + homepage = http://mcpp.sourceforge.net/; + description = "A portable c preprocessor"; + license = licenses.bsd2; + platforms = platforms.unix; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/mercury/default.nix b/nixpkgs/pkgs/development/compilers/mercury/default.nix new file mode 100644 index 000000000000..b7fc3e4dd772 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/mercury/default.nix @@ -0,0 +1,62 @@ +{ stdenv, fetchurl, gcc, flex, bison, texinfo, jdk, erlang, makeWrapper +, readline }: + +stdenv.mkDerivation rec { + name = "mercury-${version}"; + version = "14.01.1"; + + src = fetchurl { + url = "https://dl.mercurylang.org/release/mercury-srcdist-${version}.tar.gz"; + sha256 = "12z8qi3da8q50mcsjsy5bnr4ia6ny5lkxvzy01a3c9blgbgcpxwq"; + }; + + buildInputs = [ gcc flex bison texinfo jdk erlang makeWrapper + readline ]; + + patchPhase = '' + # Fix calls to programs in /bin + for p in uname pwd ; do + for f in $(egrep -lr /bin/$p *) ; do + sed -i 's@/bin/'$p'@'$p'@g' $f ; + done + done + ''; + + preConfigure = '' + mkdir -p $out/lib/mercury/cgi-bin ; + configureFlags="--enable-deep-profiler=$out/lib/mercury/cgi-bin"; + ''; + + preBuild = '' + # Mercury buildsystem does not take -jN directly. + makeFlags="PARALLEL=-j$NIX_BUILD_CORES" ; + ''; + + postInstall = '' + # Wrap with compilers for the different targets. + for e in $(ls $out/bin) ; do + wrapProgram $out/bin/$e \ + --prefix PATH ":" "${gcc}/bin" \ + --prefix PATH ":" "${jdk}/bin" \ + --prefix PATH ":" "${erlang}/bin" + done + ''; + + meta = { + description = "A pure logic programming language"; + longDescription = '' + Mercury is a logic/functional programming language which combines the + clarity and expressiveness of declarative programming with advanced + static analysis and error detection features. Its highly optimized + execution algorithm delivers efficiency far in excess of existing logic + programming systems, and close to conventional programming systems. + Mercury addresses the problems of large-scale program development, + allowing modularity, separate compilation, and numerous optimization/time + trade-offs. + ''; + homepage = "http://mercurylang.org"; + license = stdenv.lib.licenses.gpl2; + platforms = stdenv.lib.platforms.linux ++ stdenv.lib.platforms.darwin; + maintainers = [ ]; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/meta-environment/meta-build-env/default.nix b/nixpkgs/pkgs/development/compilers/meta-environment/meta-build-env/default.nix new file mode 100644 index 000000000000..3869bdad84f6 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/meta-environment/meta-build-env/default.nix @@ -0,0 +1,11 @@ +{stdenv, fetchurl}: stdenv.mkDerivation { + name = "meta-build-env-0.1"; + src = fetchurl { + url = http://www.meta-environment.org/releases/meta-build-env-0.1.tar.gz ; + sha256 = "1imn1gaan4fv73v8w3k3lgyjzkcn7bdp69k6hlz0vqdg17ysd1x3"; + }; + + meta = { + platforms = stdenv.lib.platforms.unix; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/mezzo/default.nix b/nixpkgs/pkgs/development/compilers/mezzo/default.nix new file mode 100644 index 000000000000..c0b535747133 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/mezzo/default.nix @@ -0,0 +1,47 @@ +{ stdenv, fetchFromGitHub, ocaml, findlib, ocamlbuild, menhir, yojson, ulex, pprint, fix, functory }: + +if stdenv.lib.versionAtLeast ocaml.version "4.06" +then throw "mezzo is not available for OCaml ${ocaml.version}" +else + +let + check-ocaml-version = with stdenv.lib; versionAtLeast (getVersion ocaml); +in + +assert check-ocaml-version "4"; + +stdenv.mkDerivation { + + name = "mezzo-0.0.m8"; + + src = fetchFromGitHub { + owner = "protz"; + repo = "mezzo"; + rev = "m8"; + sha256 = "0yck5r6di0935s3iy2mm9538jkf77ssr789qb06ms7sivd7g3ip6"; + }; + + buildInputs = [ ocaml findlib ocamlbuild yojson menhir ulex pprint fix functory ]; + + # Sets warning 3 as non-fatal + prePatch = stdenv.lib.optionalString (check-ocaml-version "4.02") '' + substituteInPlace myocamlbuild.pre.ml \ + --replace '@1..3' '@1..2+3' + ''; + + createFindlibDestdir = true; + + postInstall = '' + mkdir $out/bin + cp mezzo $out/bin/ + ''; + + meta = with stdenv.lib; { + homepage = http://protz.github.io/mezzo/; + description = "A programming language in the ML tradition, which places strong emphasis on the control of aliasing and access to mutable memory"; + license = licenses.gpl2; + platforms = ocaml.meta.platforms or []; + }; +} + + diff --git a/nixpkgs/pkgs/development/compilers/microscheme/default.nix b/nixpkgs/pkgs/development/compilers/microscheme/default.nix new file mode 100644 index 000000000000..f15a76243277 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/microscheme/default.nix @@ -0,0 +1,30 @@ +{ stdenv, fetchzip, vim, makeWrapper }: + +stdenv.mkDerivation rec { + name = "microscheme-${version}"; + version = "0.9.3"; + + src = fetchzip { + name = "${name}-src"; + url = "https://github.com/ryansuchocki/microscheme/archive/v${version}.tar.gz"; + sha256 = "1r3ng4pw1s9yy1h5rafra1rq19d3vmb5pzbpcz1913wz22qdd976"; + }; + + buildInputs = [ makeWrapper vim ]; + + installPhase = '' + make install PREFIX=$out + ''; + + meta = with stdenv.lib; { + homepage = http://microscheme.org; + description = "A Scheme subset for Atmel microcontrollers"; + longDescription = '' + Microscheme is a Scheme subset/variant designed for Atmel + microcontrollers, especially as found on Arduino boards. + ''; + license = licenses.mit; + platforms = platforms.linux; + maintainers = with maintainers; [ ardumont ]; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/mint/crystal2nix.cr b/nixpkgs/pkgs/development/compilers/mint/crystal2nix.cr new file mode 100644 index 000000000000..f608102a37b4 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/mint/crystal2nix.cr @@ -0,0 +1,42 @@ +require "yaml" +require "json" + +class PrefetchJSON + JSON.mapping(sha256: String) +end + +class ShardLock + YAML.mapping( + version: Float32, + shards: Hash(String, Hash(String, String)) + ) +end + +File.open "shards.nix", "w+" do |file| + file.puts %({) + yaml = ShardLock.from_yaml(File.read("shard.lock")) + yaml.shards.each do |key, value| + owner, repo = value["github"].split("/") + url = "https://github.com/#{value["github"]}" + rev = if value["version"]? + "v#{value["version"]}" + else + value["commit"] + end + + sha256 = "" + args = ["--url", url, "--rev", rev] + Process.run("nix-prefetch-git", args: args) do |x| + x.error.each_line { |e| puts e } + sha256 = PrefetchJSON.from_json(x.output).sha256 + end + + file.puts %( #{key} = {) + file.puts %( owner = "#{owner}";) + file.puts %( repo = "#{repo}";) + file.puts %( rev = "#{rev}";) + file.puts %( sha256 = "#{sha256}";) + file.puts %( };) + end + file.puts %(}) +end diff --git a/nixpkgs/pkgs/development/compilers/mint/default.nix b/nixpkgs/pkgs/development/compilers/mint/default.nix new file mode 100644 index 000000000000..1c8e9fb7eb20 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/mint/default.nix @@ -0,0 +1,64 @@ +# Updating the dependencies for this package: +# +# wget https://raw.githubusercontent.com/mint-lang/mint/0.3.1/shard.lock +# nix-shell -p crystal libyaml --run 'crystal run crystal2nix.cr' +# +{stdenv, lib, fetchFromGitHub, crystal, zlib, openssl, duktape, which, libyaml }: +let + crystalPackages = lib.mapAttrs (name: src: + stdenv.mkDerivation { + name = lib.replaceStrings ["/"] ["-"] name; + src = fetchFromGitHub src; + phases = "installPhase"; + installPhase = ''cp -r $src $out''; + passthru = { libName = name; }; + } + ) (import ./shards.nix); + + crystalLib = stdenv.mkDerivation { + name = "crystal-lib"; + src = lib.attrValues crystalPackages; + libNames = lib.mapAttrsToList (k: v: [k v]) crystalPackages; + phases = "buildPhase"; + buildPhase = '' + mkdir -p $out + linkup () { + while [ "$#" -gt 0 ]; do + ln -s $2 $out/$1 + shift; shift + done + } + linkup $libNames + ''; + }; +in +stdenv.mkDerivation rec { + version = "0.5.0"; + name = "mint-${version}"; + src = fetchFromGitHub { + owner = "mint-lang"; + repo = "mint"; + rev = version; + sha256 = "0vxbx38c390rd2ysvbwgh89v2232sh5rbsp3nk9wzb70jybpslvl"; + }; + + nativeBuildInputs = [ which crystal zlib openssl duktape libyaml ]; + + buildPhase = '' + mkdir -p $out/bin tmp + cd tmp + ln -s ${crystalLib} lib + cp -r $src/* . + crystal build src/mint.cr -o $out/bin/mint --verbose --progress --release --no-debug + ''; + + installPhase = ''true''; + + meta = { + description = "A refreshing language for the front-end web"; + homepage = https://mint-lang.com/; + license = stdenv.lib.licenses.bsd3; + maintainers = with stdenv.lib.maintainers; [ manveru ]; + platforms = [ "x86_64-linux" "i686-linux" "x86_64-darwin" ]; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/mint/shards.nix b/nixpkgs/pkgs/development/compilers/mint/shards.nix new file mode 100644 index 000000000000..dc6866e3af3d --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/mint/shards.nix @@ -0,0 +1,74 @@ +{ + admiral = { + owner = "jwaldrip"; + repo = "admiral.cr"; + rev = "v1.7.3"; + sha256 = "0b98qjy43wsrc08am7lkhcdsxc7gplf9hcmbvd4p3dw4g107rk91"; + }; + ameba = { + owner = "veelenga"; + repo = "ameba"; + rev = "v0.9.1"; + sha256 = "05q2ki9dpg23pllalv5p27f1m287kiicp97ziz0z7vv0vg1r8smj"; + }; + baked_file_system = { + owner = "schovi"; + repo = "baked_file_system"; + rev = "v0.9.7"; + sha256 = "1fi6zag1a6h4xwrfizy01dls3hhraqw0cmpwj7rjv1qcddjgig5z"; + }; + diff = { + owner = "MakeNowJust"; + repo = "crystal-diff"; + rev = "51962dc36f9bbb1b926d557f7cb8993a6c73cc63"; + sha256 = "1nwnsxm8srfw8jg0yfi2v19x6j3dadx62hq0xpxra40qcqz9dbnp"; + }; + dotenv = { + owner = "gdotdesign"; + repo = "cr-dotenv"; + rev = "v0.2.0"; + sha256 = "0zi2y1j2546xjhdzn7icmry0cjv82cx2cqmpgx5ml37c2pnb7kp7"; + }; + exception_page = { + owner = "crystal-loot"; + repo = "exception_page"; + rev = "v0.1.2"; + sha256 = "0j5ishhyriq9p339yaawrmawl9wgmp1paniq30a8d6a0568h3avq"; + }; + kemal = { + owner = "kemalcr"; + repo = "kemal"; + rev = "v0.25.1"; + sha256 = "1334i905xj6vlmp8acyybwwlaxsgmf90b59da7brzpnf28wci782"; + }; + kilt = { + owner = "jeromegn"; + repo = "kilt"; + rev = "v0.4.0"; + sha256 = "1w9ib6j4xhwxdxx58nzc06gw7ci7vga03vgj1z1bnklamb0b0l0k"; + }; + radix = { + owner = "luislavena"; + repo = "radix"; + rev = "v0.3.9"; + sha256 = "19pksfr7ddc31hvikb433jg0zav1ar93k6zmsgaf3vsrjnvia3ix"; + }; + string_inflection = { + owner = "mosop"; + repo = "string_inflection"; + rev = "v0.2.1"; + sha256 = "10vkr28h7n53ijjv57ldxhh473086qg313lzs55a7wsh0zgc104m"; + }; + time_format = { + owner = "vladfaust"; + repo = "time_format.cr"; + rev = "v0.1.1"; + sha256 = "0mmssnabf476i07sajm7s3rlvfcav4lkh0n8g12rybxr6c9f683v"; + }; + tree_template = { + owner = "anykeyh"; + repo = "tree_template"; + rev = "3fcb71ee6852040077dd1a2c8c55c67f4a95ba4e"; + sha256 = "04w89wpnkna4ipyy3pxshqqwgk965hz1d31vqp0mrb0ilmpsywdk"; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/mit-scheme/default.nix b/nixpkgs/pkgs/development/compilers/mit-scheme/default.nix new file mode 100644 index 000000000000..ef7ad9b32669 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/mit-scheme/default.nix @@ -0,0 +1,92 @@ +{ fetchurl, stdenv, makeWrapper, gnum4, texinfo, texLive, automake, + enableX11 ? false, xlibsWrapper ? null }: + +let + version = "9.2"; + bootstrapFromC = ! (stdenv.isi686 || stdenv.isx86_64); + + arch = if stdenv.isi686 then "-i386" + else if stdenv.isx86_64 then "-x86-64" + else ""; +in +stdenv.mkDerivation { + name = if enableX11 then "mit-scheme-x11-${version}" else "mit-scheme-${version}"; + + # MIT/GNU Scheme is not bootstrappable, so it's recommended to compile from + # the platform-specific tarballs, which contain pre-built binaries. It + # leads to more efficient code than when building the tarball that contains + # generated C code instead of those binaries. + src = + if stdenv.isi686 + then fetchurl { + url = "mirror://gnu/mit-scheme/stable.pkg/${version}/mit-scheme-${version}-i386.tar.gz"; + sha256 = "1fmlpnhf5a75db93phajh4ysbdgrgl72v45lk3kznriprl0a7jc6"; + } else if stdenv.isx86_64 + then fetchurl { + url = "mirror://gnu/mit-scheme/stable.pkg/${version}/mit-scheme-${version}-x86-64.tar.gz"; + sha256 = "1skzxxhr0iq96bf0j5m7mvf3i4sppfyfa6gpqn34mwgkw1fx8274"; + } else fetchurl { + url = "mirror://gnu/mit-scheme/stable.pkg/${version}/mit-scheme-c-${version}.tar.gz"; + sha256 = "0w5ib5vsidihb4hb6fma3sp596ykr8izagm57axvgd6lqzwicsjg"; + }; + + buildInputs = if enableX11 then [xlibsWrapper] else []; + + configurePhase = + '' (cd src && ./configure) + (cd doc && ./configure) + ''; + + buildPhase = + '' cd src + ${if bootstrapFromC + then "./etc/make-liarc.sh --prefix=$out" + else "make compile-microcode"} + + cd ../doc + + # Provide a `texinfo.tex'. + export TEXINPUTS="$(echo ${automake}/share/automake-*)" + echo "\$TEXINPUTS is \`$TEXINPUTS'" + make + + cd .. + ''; + + installPhase = + '' make prefix=$out install -C src + make prefix=$out install -C doc + ''; + + fixupPhase = + '' wrapProgram $out/bin/mit-scheme${arch} --set MITSCHEME_LIBRARY_PATH \ + $out/lib/mit-scheme${arch} + ''; + + nativeBuildInputs = [ makeWrapper gnum4 texinfo texLive automake ]; + + # XXX: The `check' target doesn't exist. + doCheck = false; + + meta = with stdenv.lib; { + description = "MIT/GNU Scheme, a native code Scheme compiler"; + + longDescription = + '' MIT/GNU Scheme is an implementation of the Scheme programming + language, providing an interpreter, compiler, source-code debugger, + integrated Emacs-like editor, and a large runtime library. MIT/GNU + Scheme is best suited to programming large applications with a rapid + development cycle. + ''; + + homepage = https://www.gnu.org/software/mit-scheme/; + + license = licenses.gpl2Plus; + + maintainers = [ ]; + + # Build fails on Cygwin and Darwin: + # <http://article.gmane.org/gmane.lisp.scheme.mit-scheme.devel/489>. + platforms = platforms.gnu ++ platforms.linux ++ platforms.freebsd; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/mkcl/default.nix b/nixpkgs/pkgs/development/compilers/mkcl/default.nix new file mode 100644 index 000000000000..8ec249ed360a --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/mkcl/default.nix @@ -0,0 +1,48 @@ +{ stdenv, fetchFromGitHub, makeWrapper, gmp, gcc }: + +with stdenv.lib; stdenv.mkDerivation rec { + name = "mkcl-${version}"; + version = "1.1.10.2017-11-14"; + + src = fetchFromGitHub { + owner = "jcbeaudoin"; + repo = "mkcl"; + rev = "d3f5afe945907153db2be5a17a419966f83d7653"; + sha256 = "1jfmnh96b5dy1874a9y843vihd14ya4by46rb4h5izldp6x3j3kl"; + }; + + nativeBuildInputs = [ makeWrapper ]; + + propagatedBuildInputs = [ gmp ]; + + hardeningDisable = [ "format" ]; + + configureFlags = [ + "GMP_CFLAGS=-I${gmp.dev}/include" + "GMP_LDFLAGS=-L${gmp.out}/lib" + ]; + + # tinycc configure flags copied from the tinycc derivation. + postConfigure = ''( + cd contrib/tinycc + ./configure --cc=cc \ + --elfinterp=$(< $NIX_CC/nix-support/dynamic-linker) \ + --crtprefix=${getLib stdenv.cc.libc}/lib \ + --sysincludepaths=${getDev stdenv.cc.libc}/include:{B}/include \ + --libpaths=${getLib stdenv.cc.libc}/lib + )''; + + postInstall = '' + wrapProgram $out/bin/mkcl --prefix PATH : "${gcc}/bin" + ''; + + enableParallelBuilding = true; + + meta = { + description = "ANSI Common Lisp Implementation"; + homepage = https://common-lisp.net/project/mkcl/; + license = licenses.lgpl2Plus; + platforms = platforms.linux; + maintainers = with maintainers; [ tohl ]; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/mlton/20130715.nix b/nixpkgs/pkgs/development/compilers/mlton/20130715.nix new file mode 100644 index 000000000000..f495be8a93e4 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/mlton/20130715.nix @@ -0,0 +1,118 @@ +{ stdenv, fetchurl, patchelf, gmp }: + +let + version = "20130715"; + + usr_prefix = if stdenv.isDarwin then "usr/local" else "usr"; + + dynamic_linker = stdenv.cc.bintools.dynamicLinker; +in + +stdenv.mkDerivation rec { + name = "mlton-${version}"; + + binSrc = + if stdenv.hostPlatform.system == "i686-linux" then (fetchurl { + url = "mirror://sourceforge/project/mlton/mlton/${version}/${name}-1.x86-linux.tgz"; + sha256 = "1kxjjmnw4xk2d9hpvz43w9dvyhb3025k4zvjx785c33nrwkrdn4j"; + }) + else if stdenv.hostPlatform.system == "x86_64-linux" then (fetchurl { + url = "mirror://sourceforge/project/mlton/mlton/${version}/${name}-1.amd64-linux.tgz"; + sha256 = "0fyhwxb4nmpirjbjcvk9f6w67gmn2gkz7xcgz0xbfih9kc015ygn"; + }) + else if stdenv.hostPlatform.system == "x86_64-darwin" then (fetchurl { + url = "mirror://sourceforge/project/mlton/mlton/${version}/${name}-1.amd64-darwin.gmp-macports.tgz"; + sha256 = "044wnh9hhg6if886xy805683k0as347xd37r0r1yi4x7qlxzzgx9"; + }) + else throw "Architecture not supported"; + + codeSrc = + fetchurl { + url = "mirror://sourceforge/project/mlton/mlton/${version}/${name}.src.tgz"; + sha256 = "0v1x2hrh9hiqkvnbq11kf34v4i5a2x0ffxbzqaa8skyl26nmfn11"; + }; + + srcs = [ binSrc codeSrc ]; + + sourceRoot = name; + + buildInputs = [ gmp ]; + nativeBuildInputs = stdenv.lib.optional stdenv.isLinux patchelf; + + makeFlags = [ "all-no-docs" ]; + + configurePhase = '' + # Fix paths in the source. + find . -type f | grep -v -e '\.tgz''$' | xargs sed -i "s@/usr/bin/env bash@$(type -p bash)@" + + substituteInPlace $(pwd)/Makefile --replace '/bin/cp' $(type -p cp) + substituteInPlace bin/mlton-script --replace gcc cc + substituteInPlace bin/regression --replace gcc cc + substituteInPlace lib/mlnlffi-lib/Makefile --replace gcc cc + substituteInPlace mlnlffigen/gen-cppcmd --replace gcc cc + substituteInPlace runtime/Makefile --replace gcc cc + substituteInPlace ../${usr_prefix}/bin/mlton --replace gcc cc + + # Fix paths in the binary distribution. + BIN_DIST_DIR="$(pwd)/../${usr_prefix}" + for f in "bin/mlton" "lib/mlton/platform" "lib/mlton/static-library" ; do + substituteInPlace "$BIN_DIST_DIR/$f" --replace '/${usr_prefix}/bin/env bash' $(type -p bash) + done + + substituteInPlace $(pwd)/../${usr_prefix}/bin/mlton --replace '/${usr_prefix}/lib/mlton' $(pwd)/../${usr_prefix}/lib/mlton + '' + stdenv.lib.optionalString stdenv.cc.isClang '' + sed -i "s_ patch -s -p0 <gdtoa.hide-public-fns.patch_ patch -s -p0 <gdtoa.hide-public-fns.patch\n\tsed -i 's|printf(emptyfmt|printf(\"\"|g' ./gdtoa/arithchk.c_" ./runtime/Makefile + '' + stdenv.lib.optionalString stdenv.isDarwin '' + sed -i 's|XCFLAGS += -I/usr/local/include -I/sw/include -I/opt/local/include||' ./runtime/Makefile + ''; + + preBuild = '' + # To build the source we have to put the binary distribution in the $PATH. + export PATH="$PATH:$(pwd)/../${usr_prefix}/bin/" + + # Let the builder execute the binary distribution. + chmod u+x $(pwd)/../${usr_prefix}/bin/mllex + chmod u+x $(pwd)/../${usr_prefix}/bin/mlyacc + chmod u+x $(pwd)/../${usr_prefix}/bin/mlton + + # So the builder runs the binary compiler with gmp. + export LD_LIBRARY_PATH=${gmp.out}/lib:$LD_LIBRARY_PATH + + '' + stdenv.lib.optionalString stdenv.isLinux '' + # Patch ELF interpreter. + patchelf --set-interpreter ${dynamic_linker} $(pwd)/../${usr_prefix}/lib/mlton/mlton-compile + for e in mllex mlyacc ; do + patchelf --set-interpreter ${dynamic_linker} $(pwd)/../${usr_prefix}/bin/$e + done + '' + stdenv.lib.optionalString stdenv.isDarwin '' + # Patch libgmp linking + install_name_tool -change /opt/local/lib/libgmp.10.dylib ${gmp}/lib/libgmp.10.dylib $(pwd)/../${usr_prefix}/lib/mlton/mlton-compile + install_name_tool -change /opt/local/lib/libgmp.10.dylib ${gmp}/lib/libgmp.10.dylib $(pwd)/../${usr_prefix}/bin/mlyacc + install_name_tool -change /opt/local/lib/libgmp.10.dylib ${gmp}/lib/libgmp.10.dylib $(pwd)/../${usr_prefix}/bin/mllex + ''; + + doCheck = true; + + installTargets = [ "install-no-docs" ]; + + postInstall = '' + # Fix path to mlton libraries. + substituteInPlace $(pwd)/install/${usr_prefix}/bin/mlton --replace '/${usr_prefix}/lib/mlton' $out/lib/mlton + + # Path to libgmp. + substituteInPlace $(pwd)/install/${usr_prefix}/bin/mlton --replace "-link-opt '-lm -lgmp'" "-link-opt '-lm -lgmp -L${gmp.out}/lib'" + + # Path to gmp.h. + substituteInPlace $(pwd)/install/${usr_prefix}/bin/mlton --replace "-cc-opt '-O1 -fno-common'" "-cc-opt '-O1 -fno-common -I${gmp.dev}/include'" + + # Path to the same cc used in the build; needed at runtime. + substituteInPlace $(pwd)/install/${usr_prefix}/bin/mlton --replace "gcc='gcc'" "gcc='"$(type -p cc)"'" + + # Copy files to final positions. + cp -r $(pwd)/install/${usr_prefix}/bin $out + cp -r $(pwd)/install/${usr_prefix}/lib $out + cp -r $(pwd)/install/${usr_prefix}/man $out + ''; + + meta = import ./meta.nix; +} diff --git a/nixpkgs/pkgs/development/compilers/mlton/20180207-binary.nix b/nixpkgs/pkgs/development/compilers/mlton/20180207-binary.nix new file mode 100644 index 000000000000..0589733cb3c6 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/mlton/20180207-binary.nix @@ -0,0 +1,57 @@ +{ stdenv, fetchurl, patchelf, gmp }: +let + dynamic-linker = stdenv.cc.bintools.dynamicLinker; +in +stdenv.mkDerivation rec { + name = "mlton-${version}"; + version = "20180207"; + + src = if stdenv.hostPlatform.system == "x86_64-linux" then (fetchurl { + url = "https://github.com/MLton/mlton/releases/download/on-${version}-release/${name}-1.amd64-linux.tgz"; + sha256 = "0f4q575yfm5dpg4a2wsnqn4l2zrar96p6rlsk0dw10ggyfwvsjlf"; + }) + else if stdenv.hostPlatform.system == "x86_64-darwin" then (fetchurl { + url = "https://github.com/MLton/mlton/releases/download/on-${version}-release/${name}-1.amd64-darwin.gmp-static.tgz"; + sha256 = "1cw7yhw48qp12q0adwf8srpjzrgkp84kmlkqw3pz8vkxz4p9hbdv"; + }) + else + throw "Architecture not supported"; + + buildInputs = [ gmp ]; + nativeBuildInputs = stdenv.lib.optional stdenv.isLinux patchelf; + + buildPhase = '' + make update \ + CC="$(type -p cc)" \ + WITH_GMP_INC_DIR="${gmp.dev}/include" \ + WITH_GMP_LIB_DIR="${gmp}/lib" + ''; + + installPhase = '' + make install PREFIX=$out + ''; + + postFixup = stdenv.lib.optionalString stdenv.isLinux '' + patchelf --set-interpreter ${dynamic-linker} $out/lib/mlton/mlton-compile + patchelf --set-rpath ${gmp}/lib $out/lib/mlton/mlton-compile + + for e in mllex mlnlffigen mlprof mlyacc; do + patchelf --set-interpreter ${dynamic-linker} $out/bin/$e + patchelf --set-rpath ${gmp}/lib $out/bin/$e + done + '' + stdenv.lib.optionalString stdenv.isDarwin '' + install_name_tool -change \ + /opt/local/lib/libgmp.10.dylib \ + ${gmp}/lib/libgmp.10.dylib \ + $out/lib/mlton/mlton-compile + + for e in mllex mlnlffigen mlprof mlyacc; do + install_name_tool -change \ + /opt/local/lib/libgmp.10.dylib \ + ${gmp}/lib/libgmp.10.dylib \ + $out/bin/$e + done + ''; + + meta = import ./meta.nix; +} diff --git a/nixpkgs/pkgs/development/compilers/mlton/default.nix b/nixpkgs/pkgs/development/compilers/mlton/default.nix new file mode 100644 index 000000000000..aaf588851402 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/mlton/default.nix @@ -0,0 +1,26 @@ +{ stdenv, fetchurl, fetchgit, patchelf, gmp }: +rec { + mlton20130715 = import ./20130715.nix { + inherit stdenv fetchurl patchelf gmp; + }; + + mlton20180207Binary = import ./20180207-binary.nix { + inherit stdenv fetchurl patchelf gmp; + }; + + mlton20180207 = import ./from-git-source.nix { + mltonBootstrap = mlton20180207Binary; + version = "20180207"; + rev = "on-20180207-release"; + sha256 = "00rdd2di5x1dzac64il9z05m3fdzicjd3226wwjyynv631jj3q2a"; + inherit stdenv fetchgit gmp; + }; + + mltonHEAD = import ./from-git-source.nix { + mltonBootstrap = mlton20180207Binary; + version = "HEAD"; + rev = "e149c9917cfbfe6aba5c986a958ed76d5cc6cfde"; + sha256 = "0a0j1i0f0fxw2my1309srq5j3vz0kawrrln01gxms2m5hy5dl50d"; + inherit stdenv fetchgit gmp; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/mlton/from-git-source.nix b/nixpkgs/pkgs/development/compilers/mlton/from-git-source.nix new file mode 100644 index 000000000000..3a3538a7ea42 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/mlton/from-git-source.nix @@ -0,0 +1,35 @@ +{ fetchgit +, gmp +, mltonBootstrap +, url ? "https://github.com/mlton/mlton" +, rev +, sha256 +, stdenv +, version +}: + +stdenv.mkDerivation { + name = "mlton-${version}"; + + src = fetchgit { + inherit url rev sha256; + }; + + buildInputs = [mltonBootstrap gmp]; + + preBuild = '' + find . -type f | grep -v -e '\.tgz''$' | xargs sed -i "s@/usr/bin/env bash@$(type -p bash)@" + + makeFlagsArray=( + MLTON_VERSION="${version} ${rev}" + CC="$(type -p cc)" + PREFIX="$out" + WITH_GMP_INC_DIR="${gmp.dev}/include" + WITH_GMP_LIB_DIR="${gmp}/lib" + ) + ''; + + doCheck = true; + + meta = import ./meta.nix; +} diff --git a/nixpkgs/pkgs/development/compilers/mlton/meta.nix b/nixpkgs/pkgs/development/compilers/mlton/meta.nix new file mode 100644 index 000000000000..c4dc9c430bc2 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/mlton/meta.nix @@ -0,0 +1,15 @@ +{ + description = "Open-source, whole-program, optimizing Standard ML compiler"; + longDescription = '' + MLton is an open source, whole-program optimizing compiler for the Standard ML programming language. + MLton aims to produce fast executables, and to encourage rapid prototyping and modular programming + by eliminating performance penalties often associated with the use of high-level language features. + MLton development began in 1997, and continues to this day with a growing worldwide community of + developers and users, who have helped to port MLton to a number of platforms. + Description taken from http://en.wikipedia.org/wiki/Mlton . + ''; + + homepage = http://mlton.org/; + license = "bsd"; + platforms = [ "i686-linux" "x86_64-linux" "x86_64-darwin"]; +} diff --git a/nixpkgs/pkgs/development/compilers/mono/4.nix b/nixpkgs/pkgs/development/compilers/mono/4.nix new file mode 100644 index 000000000000..3c748e2dff7d --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/mono/4.nix @@ -0,0 +1,8 @@ +{ callPackage, Foundation, libobjc }: + +callPackage ./generic.nix (rec { + inherit Foundation libobjc; + version = "4.8.1.0"; + sha256 = "1vyvp2g28ihcgxgxr8nhzyzdmzicsh5djzk8dk1hj5p5f2k3ijqq"; + enableParallelBuilding = false; # #32386, https://hydra.nixos.org/build/65600645 +}) diff --git a/nixpkgs/pkgs/development/compilers/mono/5.nix b/nixpkgs/pkgs/development/compilers/mono/5.nix new file mode 100644 index 000000000000..0db13308a5af --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/mono/5.nix @@ -0,0 +1,8 @@ +{ callPackage, Foundation, libobjc }: + +callPackage ./generic.nix (rec { + inherit Foundation libobjc; + version = "5.20.1.27"; + sha256 = "15rpwxw642ad1na93k5nj7d2lb24f21kncr924gxr00178a9x0jy"; + enableParallelBuilding = true; +}) diff --git a/nixpkgs/pkgs/development/compilers/mono/generic.nix b/nixpkgs/pkgs/development/compilers/mono/generic.nix new file mode 100644 index 000000000000..43ef5d4b62d1 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/mono/generic.nix @@ -0,0 +1,89 @@ +{ stdenv, fetchurl, bison, pkgconfig, glib, gettext, perl, libgdiplus, libX11, callPackage, ncurses, zlib, withLLVM ? false, cacert, Foundation, libobjc, python, version, sha256, autoconf, libtool, automake, cmake, which, enableParallelBuilding ? true }: + +let + llvm = callPackage ./llvm.nix { }; +in +stdenv.mkDerivation rec { + name = "mono-${version}"; + + src = fetchurl { + inherit sha256; + url = "https://download.mono-project.com/sources/mono/${name}.tar.bz2"; + }; + + buildInputs = + [ bison pkgconfig glib gettext perl libgdiplus libX11 ncurses zlib python autoconf libtool automake cmake which + ] + ++ (stdenv.lib.optionals stdenv.isDarwin [ Foundation libobjc ]); + + propagatedBuildInputs = [glib]; + + NIX_LDFLAGS = if stdenv.isDarwin then "" else "-lgcc_s" ; + + # To overcome the bug https://bugzilla.novell.com/show_bug.cgi?id=644723 + dontDisableStatic = true; + + configureFlags = [ + "--x-includes=${libX11.dev}/include" + "--x-libraries=${libX11.out}/lib" + "--with-libgdiplus=${libgdiplus}/lib/libgdiplus.so" + ] + ++ stdenv.lib.optionals withLLVM [ + "--enable-llvm" + "--with-llvm=${llvm}" + ]; + + configurePhase = '' + patchShebangs ./ + ./autogen.sh --prefix $out $configureFlags + ''; + + # Attempt to fix this error when running "mcs --version": + # The file /nix/store/xxx-mono-2.4.2.1/lib/mscorlib.dll is an invalid CIL image + dontStrip = true; + + # We want pkg-config to take priority over the dlls in the Mono framework and the GAC + # because we control pkg-config + patches = [ ./pkgconfig-before-gac.patch ]; + + # Patch all the necessary scripts. Also, if we're using LLVM, we fix the default + # LLVM path to point into the Mono LLVM build, since it's private anyway. + preBuild = '' + makeFlagsArray=(INSTALL=`type -tp install`) + substituteInPlace mcs/class/corlib/System/Environment.cs --replace /usr/share "$out/share" + '' + stdenv.lib.optionalString withLLVM '' + substituteInPlace mono/mini/aot-compiler.c --replace "llvm_path = g_strdup (\"\")" "llvm_path = g_strdup (\"${llvm}/bin/\")" + ''; + + # Fix mono DLLMap so it can find libX11 to run winforms apps + # libgdiplus is correctly handled by the --with-libgdiplus configure flag + # Other items in the DLLMap may need to be pointed to their store locations, I don't think this is exhaustive + # https://www.mono-project.com/Config_DllMap + postBuild = '' + find . -name 'config' -type f | xargs \ + sed -i -e "s@libX11.so.6@${libX11.out}/lib/libX11.so.6@g" + ''; + + # Without this, any Mono application attempting to open an SSL connection will throw with + # The authentication or decryption has failed. + # ---> Mono.Security.Protocol.Tls.TlsException: Invalid certificate received from server. + postInstall = '' + echo "Updating Mono key store" + $out/bin/cert-sync ${cacert}/etc/ssl/certs/ca-bundle.crt + '' + # According to [1], gmcs is just mcs + # [1] https://github.com/mono/mono/blob/master/scripts/gmcs.in + + '' + ln -s $out/bin/mcs $out/bin/gmcs + ''; + + inherit enableParallelBuilding; + + meta = with stdenv.lib; { + homepage = https://mono-project.com/; + description = "Cross platform, open source .NET development framework"; + platforms = with platforms; darwin ++ linux; + maintainers = with maintainers; [ thoughtpolice obadz vrthra ]; + license = licenses.free; # Combination of LGPL/X11/GPL ? + }; +} diff --git a/nixpkgs/pkgs/development/compilers/mono/llvm.nix b/nixpkgs/pkgs/development/compilers/mono/llvm.nix new file mode 100644 index 000000000000..616ec420d2d0 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/mono/llvm.nix @@ -0,0 +1,52 @@ +{ stdenv +, lib +, fetchFromGitHub +, groff +, cmake +, python2 +, perl +, libffi +, libbfd +, libxml2 +, valgrind +, ncurses +, zlib +}: + +stdenv.mkDerivation rec { + name = "llvm-${version}"; + version = "3.6-mono-2017-02-15"; + + src = fetchFromGitHub { + owner = "mono"; + repo = "llvm"; + rev = "dbb6fdffdeb780d11851a6be77c209bd7ada4bd3"; + sha256 = "07wd1cs3fdvzb1lv41b655z5zk34f47j8fgd9ljjimi5j9pj71f7"; + }; + + buildInputs = [ perl groff cmake libxml2 python2 libffi ] ++ lib.optional stdenv.isLinux valgrind; + + propagatedBuildInputs = [ ncurses zlib ]; + + # hacky fix: created binaries need to be run before installation + preBuild = '' + mkdir -p $out/ + ln -sv $PWD/lib $out + ''; + postBuild = "rm -fR $out"; + + cmakeFlags = with stdenv; [ + "-DLLVM_ENABLE_FFI=ON" + "-DLLVM_BINUTILS_INCDIR=${libbfd.dev}/include" + ] ++ stdenv.lib.optional (!isDarwin) "-DBUILD_SHARED_LIBS=ON"; + + enableParallelBuilding = true; + + meta = { + description = "Collection of modular and reusable compiler and toolchain technologies - Mono build"; + homepage = http://llvm.org/; + license = stdenv.lib.licenses.bsd3; + maintainers = with stdenv.lib.maintainers; [ thoughtpolice ]; + platforms = stdenv.lib.platforms.all; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/mono/pkgconfig-before-gac.patch b/nixpkgs/pkgs/development/compilers/mono/pkgconfig-before-gac.patch new file mode 100644 index 000000000000..7632d850391e --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/mono/pkgconfig-before-gac.patch @@ -0,0 +1,65 @@ +diff -Naur mono-4.0.1.old/mcs/tools/xbuild/data/12.0/Microsoft.Common.targets mono-4.0.1/mcs/tools/xbuild/data/12.0/Microsoft.Common.targets +--- mono-4.0.1.old/mcs/tools/xbuild/data/12.0/Microsoft.Common.targets 2015-04-24 02:26:18.000000000 +0100 ++++ mono-4.0.1/mcs/tools/xbuild/data/12.0/Microsoft.Common.targets 2015-05-26 00:52:33.997847464 +0100 +@@ -229,8 +229,8 @@ + $(ReferencePath); + @(AdditionalReferencePath); + {HintPathFromItem}; +- {TargetFrameworkDirectory}; + {PkgConfig}; ++ {TargetFrameworkDirectory}; + {GAC}; + {RawFileName}; + $(OutDir) +diff -Naur mono-4.0.1.old/mcs/tools/xbuild/data/14.0/Microsoft.Common.targets mono-4.0.1/mcs/tools/xbuild/data/14.0/Microsoft.Common.targets +--- mono-4.0.1.old/mcs/tools/xbuild/data/14.0/Microsoft.Common.targets 2015-04-24 02:26:18.000000000 +0100 ++++ mono-4.0.1/mcs/tools/xbuild/data/14.0/Microsoft.Common.targets 2015-05-26 00:52:41.832612748 +0100 +@@ -214,8 +214,8 @@ + $(ReferencePath); + @(AdditionalReferencePath); + {HintPathFromItem}; +- {TargetFrameworkDirectory}; + {PkgConfig}; ++ {TargetFrameworkDirectory}; + {GAC}; + {RawFileName}; + $(OutDir) +diff -Naur mono-4.0.1.old/mcs/tools/xbuild/data/2.0/Microsoft.Common.targets mono-4.0.1/mcs/tools/xbuild/data/2.0/Microsoft.Common.targets +--- mono-4.0.1.old/mcs/tools/xbuild/data/2.0/Microsoft.Common.targets 2015-04-24 02:26:18.000000000 +0100 ++++ mono-4.0.1/mcs/tools/xbuild/data/2.0/Microsoft.Common.targets 2015-05-26 00:52:46.298478961 +0100 +@@ -139,8 +139,8 @@ + $(ReferencePath); + @(AdditionalReferencePath); + {HintPathFromItem}; +- {TargetFrameworkDirectory}; + {PkgConfig}; ++ {TargetFrameworkDirectory}; + {GAC}; + {RawFileName}; + $(OutDir) +diff -Naur mono-4.0.1.old/mcs/tools/xbuild/data/3.5/Microsoft.Common.targets mono-4.0.1/mcs/tools/xbuild/data/3.5/Microsoft.Common.targets +--- mono-4.0.1.old/mcs/tools/xbuild/data/3.5/Microsoft.Common.targets 2015-04-24 02:26:18.000000000 +0100 ++++ mono-4.0.1/mcs/tools/xbuild/data/3.5/Microsoft.Common.targets 2015-05-26 00:52:52.119304583 +0100 +@@ -167,8 +167,8 @@ + $(ReferencePath); + @(AdditionalReferencePath); + {HintPathFromItem}; +- {TargetFrameworkDirectory}; + {PkgConfig}; ++ {TargetFrameworkDirectory}; + {GAC}; + {RawFileName}; + $(OutDir) +diff -Naur mono-4.0.1.old/mcs/tools/xbuild/data/4.0/Microsoft.Common.targets mono-4.0.1/mcs/tools/xbuild/data/4.0/Microsoft.Common.targets +--- mono-4.0.1.old/mcs/tools/xbuild/data/4.0/Microsoft.Common.targets 2015-04-24 02:26:18.000000000 +0100 ++++ mono-4.0.1/mcs/tools/xbuild/data/4.0/Microsoft.Common.targets 2015-05-26 00:52:56.519172776 +0100 +@@ -229,8 +229,8 @@ + $(ReferencePath); + @(AdditionalReferencePath); + {HintPathFromItem}; +- {TargetFrameworkDirectory}; + {PkgConfig}; ++ {TargetFrameworkDirectory}; + {GAC}; + {RawFileName}; + $(OutDir) diff --git a/nixpkgs/pkgs/development/compilers/mosml/default.nix b/nixpkgs/pkgs/development/compilers/mosml/default.nix new file mode 100644 index 000000000000..89726f20c6b8 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/mosml/default.nix @@ -0,0 +1,29 @@ +{ stdenv, fetchurl, gmp, perl }: + +stdenv.mkDerivation rec { + name = "mosml-${version}"; + version = "2.10.1"; + + buildInputs = [ gmp perl ]; + + makeFlags = "PREFIX=$(out)"; + + src = fetchurl { + url = "https://github.com/kfl/mosml/archive/ver-${version}.tar.gz"; + sha256 = "13x7wj94p0inn84pzpj52dch5s9lznqrj287bd3nk3dqd0v3kmgy"; + }; + + setSourceRoot = ''export sourceRoot="$(echo */src)"''; + + meta = with stdenv.lib; { + description = "A light-weight implementation of Standard ML"; + longDescription = '' + Moscow ML is a light-weight implementation of Standard ML (SML), a strict + functional language used in teaching and research. + ''; + homepage = https://mosml.org/; + license = licenses.gpl2; + platforms = platforms.linux; + maintainers = with maintainers; [ vaibhavsagar ]; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/mozart/binary.nix b/nixpkgs/pkgs/development/compilers/mozart/binary.nix new file mode 100644 index 000000000000..ef6cd1160b33 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/mozart/binary.nix @@ -0,0 +1,79 @@ +{ stdenv, fetchurl, makeWrapper +, boost, gmp +, tcl-8_5, tk-8_5 +, emacs +}: + +let + version = "2.0.0"; + + binaries = { + "x86_64-linux" = fetchurl { + url = "mirror://sourceforge/project/mozart-oz/v${version}-alpha.0/mozart2-${version}-alpha.0+build.4105.5c06ced-x86_64-linux.tar.gz"; + sha256 = "0rsfrjimjxqbwprpzzlmydl3z3aiwg5qkb052jixdxjyad7gyh5z"; + }; + }; +in + +stdenv.mkDerivation { + name = "mozart-binary-${version}"; + + preferLocalBuild = true; + + src = binaries."${stdenv.hostPlatform.system}" or (throw "unsupported system: ${stdenv.hostPlatform.system}"); + + libPath = stdenv.lib.makeLibraryPath + [ stdenv.cc.cc + boost + gmp + tcl-8_5 + tk-8_5 + ]; + + TK_LIBRARY = "${tk-8_5}/lib/tk8.5"; + + buildInputs = [ makeWrapper ]; + + buildCommand = '' + mkdir $out + tar xvf $src -C $out --strip-components=1 + + for exe in $out/bin/{ozemulator,ozwish} ; do + patchelf --set-interpreter $(< $NIX_CC/nix-support/dynamic-linker) \ + --set-rpath $libPath \ + $exe + done + + wrapProgram $out/bin/ozwish \ + --set OZHOME $out \ + --set TK_LIBRARY $TK_LIBRARY + + wrapProgram $out/bin/ozemulator --set OZHOME $out + + ${stdenv.lib.optionalString (emacs != null) '' + wrapProgram $out/bin/oz --suffix PATH ":" ${stdenv.lib.makeBinPath [ emacs ]} + ''} + + sed -i $out/share/applications/oz.desktop \ + -e "s,Exec=oz %u,Exec=$out/bin/oz %u," + + gzip -9n $out/share/mozart/elisp"/"*.elc + + patchShebangs $out + ''; + + meta = with stdenv.lib; { + homepage = http://www.mozart-oz.org/; + description = "Multiplatform implementation of the Oz programming language"; + longDescription = '' + The Mozart Programming System combines ongoing research in + programming language design and implementation, constraint logic + programming, distributed computing, and human-computer + interfaces. Mozart implements the Oz language and provides both + expressive power and advanced functionality. + ''; + license = licenses.mit; + platforms = attrNames binaries; + hydraPlatforms = []; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/mruby/0001-Disables-IO-isatty-test-for-sandboxed-builds.patch b/nixpkgs/pkgs/development/compilers/mruby/0001-Disables-IO-isatty-test-for-sandboxed-builds.patch new file mode 100644 index 000000000000..779391fc62a9 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/mruby/0001-Disables-IO-isatty-test-for-sandboxed-builds.patch @@ -0,0 +1,36 @@ +From f3db284516105fd30b5513a5528104574a7b8545 Mon Sep 17 00:00:00 2001 +From: Samuel Dionne-Riel <samuel@dionne-riel.com> +Date: Thu, 9 Aug 2018 19:07:45 -0400 +Subject: [PATCH] Disables `IO#isatty` test for sandboxed builds. + +--- + mrbgems/mruby-io/test/io.rb | 13 ------------- + 1 file changed, 13 deletions(-) + +diff --git a/mrbgems/mruby-io/test/io.rb b/mrbgems/mruby-io/test/io.rb +index e06b1499..e8a54736 100644 +--- a/mrbgems/mruby-io/test/io.rb ++++ b/mrbgems/mruby-io/test/io.rb +@@ -342,19 +342,6 @@ assert('IO#_read_buf') do + io.closed? + end + +-assert('IO#isatty') do +- skip "isatty is not supported on this platform" if MRubyIOTestUtil.win? +- f1 = File.open("/dev/tty") +- f2 = File.open($mrbtest_io_rfname) +- +- assert_true f1.isatty +- assert_false f2.isatty +- +- f1.close +- f2.close +- true +-end +- + assert('IO#pos=, IO#seek') do + fd = IO.sysopen $mrbtest_io_rfname + io = IO.new fd +-- +2.16.4 + diff --git a/nixpkgs/pkgs/development/compilers/mruby/default.nix b/nixpkgs/pkgs/development/compilers/mruby/default.nix new file mode 100644 index 000000000000..cfc1f00a8036 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/mruby/default.nix @@ -0,0 +1,38 @@ +{ stdenv, ruby, bison, fetchFromGitHub }: + +stdenv.mkDerivation rec { + name = "mruby-${version}"; + version = "2.0.0"; + + src = fetchFromGitHub { + owner = "mruby"; + repo = "mruby"; + rev = version; + sha256 = "1r6w1asjshff43ymdwa6xmrkggza99mi2kw88k7ic6ag2j81hcj5"; + }; + + patches = [ + ./0001-Disables-IO-isatty-test-for-sandboxed-builds.patch + ]; + + nativeBuildInputs = [ ruby bison ]; + + # Necessary so it uses `gcc` instead of `ld` for linking. + # https://github.com/mruby/mruby/blob/35be8b252495d92ca811d76996f03c470ee33380/tasks/toolchains/gcc.rake#L25 + preBuild = if stdenv.isLinux then "unset LD" else null; + + installPhase = '' + mkdir $out + cp -R build/host/{bin,lib} $out + ''; + + doCheck = true; + + meta = with stdenv.lib; { + description = "An embeddable implementation of the Ruby language"; + homepage = https://mruby.org; + maintainers = [ maintainers.nicknovitski ]; + license = licenses.mit; + platforms = platforms.unix; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/nasm/default.nix b/nixpkgs/pkgs/development/compilers/nasm/default.nix new file mode 100644 index 000000000000..bfb3c154a3c7 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/nasm/default.nix @@ -0,0 +1,30 @@ +{ stdenv, fetchFromRepoOrCz, autoreconfHook, perl, asciidoc, xmlto, docbook_xml_dtd_45, docbook_xsl }: + +stdenv.mkDerivation rec { + name = "nasm-${version}"; + version = "2.14.02"; + + src = fetchFromRepoOrCz { + repo = "nasm"; + rev = name; + sha256 = "15z6ybnzlsrqs2964h6czqhpmr7vc3ln4y4h0z9vrznk4mqcwbsa"; + }; + + nativeBuildInputs = [ autoreconfHook perl asciidoc xmlto docbook_xml_dtd_45 docbook_xsl ]; + + postBuild = "make manpages"; + + doCheck = true; + + checkPhase = '' + make golden && make test + ''; + + meta = with stdenv.lib; { + homepage = https://www.nasm.us/; + description = "An 80x86 and x86-64 assembler designed for portability and modularity"; + platforms = platforms.unix; + maintainers = with maintainers; [ pSub willibutz ]; + license = licenses.bsd2; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/neko/default.nix b/nixpkgs/pkgs/development/compilers/neko/default.nix new file mode 100644 index 000000000000..e2aa5736c7a3 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/neko/default.nix @@ -0,0 +1,38 @@ +{ stdenv, fetchurl, boehmgc, zlib, sqlite, pcre, cmake, pkgconfig +, git, apacheHttpd, apr, aprutil, mysql, mbedtls, openssl, pkgs, gtk2, libpthreadstubs +}: + +stdenv.mkDerivation rec { + name = "neko-${version}"; + version = "2.2.0"; + + src = fetchurl { + url = "https://nekovm.org/media/neko-${version}-src.tar.gz"; + sha256 = "1qv47zaa0vzhjlq5wb71627n7dbsxpc1gqpg0hsngjxnbnh1q46g"; + }; + + nativeBuildInputs = [ cmake pkgconfig git ]; + buildInputs = + [ boehmgc zlib sqlite pcre apacheHttpd apr aprutil + mysql.connector-c mbedtls openssl libpthreadstubs ] + ++ stdenv.lib.optional stdenv.isLinux gtk2 + ++ stdenv.lib.optionals stdenv.isDarwin [ pkgs.darwin.apple_sdk.frameworks.Security + pkgs.darwin.apple_sdk.frameworks.Carbon]; + cmakeFlags = [ "-DRUN_LDCONFIG=OFF" ]; + + installCheckPhase = '' + bin/neko bin/test.n + ''; + + doInstallCheck = true; + dontPatchELF = true; + dontStrip = true; + + meta = with stdenv.lib; { + description = "A high-level dynamically typed programming language"; + homepage = https://nekovm.org; + license = licenses.lgpl21; + maintainers = [ maintainers.marcweber ]; + platforms = platforms.linux ++ platforms.darwin; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/nextpnr/default.nix b/nixpkgs/pkgs/development/compilers/nextpnr/default.nix new file mode 100644 index 000000000000..ec5deb4e22aa --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/nextpnr/default.nix @@ -0,0 +1,75 @@ +{ stdenv, fetchFromGitHub, cmake, makeWrapper +, boost, python3, eigen +, icestorm, trellis + +# TODO(thoughtpolice) Currently the GUI build seems broken at runtime on my +# laptop (and over a remote X server on my server...), so mark it broken for +# now, with intent to fix later. +, enableGui ? false +, qtbase +}: + +let + boostPython = boost.override { python = python3; enablePython = true; }; + + # This is a massive hack. For now, Trellis doesn't really support + # installation through an already-built package; you have to build it once to + # get the tools, then reuse the build directory to build nextpnr -- the + # 'install' phase doesn't install everything it needs. This will be fixed in + # the future but for now we can do this horrific thing. + trellisRoot = trellis.overrideAttrs (_: { + installPhase = '' + mkdir -p $out + cp *.so .. + cd ../../.. && cp -R trellis database $out/ + ''; + }); +in +stdenv.mkDerivation rec { + name = "nextpnr-${version}"; + version = "2019.04.19"; + + src = fetchFromGitHub { + owner = "yosyshq"; + repo = "nextpnr"; + rev = "5344bc3b65f4e06f983db781e9a82d30b3f1512b"; + sha256 = "1y14jpa948cwk0i19bsfqh7yxsxkgskm4xym4z179sjcvcdvrn3a"; + }; + + nativeBuildInputs = [ cmake makeWrapper ]; + buildInputs + = [ boostPython python3 eigen ] + ++ (stdenv.lib.optional enableGui qtbase); + + enableParallelBuilding = true; + cmakeFlags = + [ "-DARCH=generic;ice40;ecp5" + "-DICEBOX_ROOT=${icestorm}/share/icebox" + "-DTRELLIS_ROOT=${trellisRoot}/trellis" + "-DUSE_OPENMP=ON" + ] ++ (stdenv.lib.optional (!enableGui) "-DBUILD_GUI=OFF"); + + # Fix the version number. This is a bit stupid (and fragile) in practice + # but works ok. We should probably make this overrideable upstream. + patchPhase = with builtins; '' + substituteInPlace ./CMakeLists.txt \ + --replace 'git log -1 --format=%h' 'echo ${substring 0 11 src.rev}' + ''; + + postInstall = stdenv.lib.optionalString enableGui '' + for x in generic ice40 ecp5; do + wrapProgram $out/bin/nextpnr-$x \ + --prefix QT_PLUGIN_PATH : "${qtbase}/${qtbase.qtPluginPrefix}" + done + ''; + + meta = with stdenv.lib; { + description = "Place and route tool for FPGAs"; + homepage = https://github.com/yosyshq/nextpnr; + license = licenses.isc; + platforms = platforms.linux; + maintainers = with maintainers; [ thoughtpolice ]; + + broken = enableGui; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/nim/default.nix b/nixpkgs/pkgs/development/compilers/nim/default.nix new file mode 100644 index 000000000000..0d319d235fd3 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/nim/default.nix @@ -0,0 +1,90 @@ +# based on https://github.com/nim-lang/Nim/blob/v0.18.0/.travis.yml + +{ stdenv, lib, fetchurl, makeWrapper, nodejs-slim-10_x, openssl, pcre, readline, boehmgc, sfml, tzdata, coreutils }: + +stdenv.mkDerivation rec { + name = "nim-${version}"; + version = "0.19.4"; + + src = fetchurl { + url = "https://nim-lang.org/download/${name}.tar.xz"; + sha256 = "0k59dhfsg5wnkc3nxg5a336pjd9jnfxabns63bl9n28iwdg16hgl"; + }; + + doCheck = !stdenv.isDarwin; + + enableParallelBuilding = true; + + NIX_LDFLAGS = [ + "-lcrypto" + "-lpcre" + "-lreadline" + "-lgc" + ]; + + # 1. nodejs is only needed for tests + # 2. we could create a separate derivation for the "written in c" version of nim + # used for bootstrapping, but koch insists on moving the nim compiler around + # as part of building it, so it cannot be read-only + + nativeBuildInputs = [ + makeWrapper nodejs-slim-10_x tzdata coreutils + ]; + + buildInputs = [ + openssl pcre readline boehmgc sfml + ]; + + phases = [ "unpackPhase" "patchPhase" "buildPhase" "installPhase" "checkPhase" ]; + + buildPhase = '' + # use $CC to trigger the linker since calling ld in build.sh causes an error + LD=$CC + # build.sh wants to write to $HOME/.cache + HOME=$TMPDIR + sh build.sh + ./bin/nim c koch + ./koch boot -d:release \ + -d:useGnuReadline \ + ${lib.optionals (stdenv.isDarwin || stdenv.isLinux) "-d:nativeStacktrace"} + ./koch tools -d:release + ''; + + installPhase = '' + install -Dt $out/bin bin/* koch + ./koch install $out + mv $out/nim/bin/* $out/bin/ && rmdir $out/nim/bin + mv $out/nim/* $out/ && rmdir $out/nim + wrapProgram $out/bin/nim \ + --suffix PATH : ${lib.makeBinPath [ stdenv.cc ]} + ''; + + patchPhase = + let disableTest = ''sed -i '1i discard \"\"\"\n disabled: true\n\"\"\"\n\n' ''; + disableStdLibTest = ''sed -i -e '/^when isMainModule/,/^END$/{s/^/#/}' ''; + disableCompile = ''sed -i -e 's/^/#/' ''; + in '' + substituteInPlace ./tests/async/tioselectors.nim --replace "/bin/sleep" "sleep" + substituteInPlace ./tests/osproc/tworkingdir.nim --replace "/usr/bin" "${coreutils}/bin" + substituteInPlace ./tests/stdlib/ttimes.nim --replace "/usr/share/zoneinfo" "${tzdata}/share/zoneinfo" + + # disable tests requiring network access (not available in the build container) + ${disableTest} ./tests/stdlib/thttpclient.nim + '' + lib.optionalString stdenv.isAarch64 '' + # disable test supposedly broken on aarch64 + ${disableStdLibTest} ./lib/pure/stats.nim + ''; + + checkPhase = '' + PATH=$PATH:$out/bin + ./koch tests + ''; + + meta = with stdenv.lib; { + description = "Statically typed, imperative programming language"; + homepage = https://nim-lang.org/; + license = licenses.mit; + maintainers = with maintainers; [ ehmry peterhoeg ]; + platforms = with platforms; linux ++ darwin; # arbitrary + }; +} diff --git a/nixpkgs/pkgs/development/compilers/nvidia-cg-toolkit/default.nix b/nixpkgs/pkgs/development/compilers/nvidia-cg-toolkit/default.nix new file mode 100644 index 000000000000..b6e2aea7eca5 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/nvidia-cg-toolkit/default.nix @@ -0,0 +1,46 @@ +{ lib, stdenv, fetchurl }: + +assert stdenv ? glibc; + +stdenv.mkDerivation rec { + version = "3.1"; + + date = "April2012"; + + name = "nvidia-cg-toolkit-${version}"; + + src = + if stdenv.hostPlatform.system == "x86_64-linux" then + fetchurl { + url = "https://developer.download.nvidia.com/cg/Cg_${version}/Cg-${version}_${date}_x86_64.tgz"; + sha256 = "e8ff01e6cc38d1b3fd56a083f5860737dbd2f319a39037528fb1a74a89ae9878"; + } + else if stdenv.hostPlatform.system == "i686-linux" then + fetchurl { + url = "http://developer.download.nvidia.com/cg/Cg_${version}/Cg-${version}_${date}_x86.tgz"; + sha256 = "cef3591e436f528852db0e8c145d3842f920e0c89bcfb219c466797cb7b18879"; + } + else throw "nvidia-cg-toolkit does not support platform ${stdenv.hostPlatform.system}"; + + installPhase = '' + for b in cgc cgfxcat cginfo + do + patchelf --set-interpreter ${stdenv.glibc.out}/lib/ld-linux*.so.? "bin/$b" + done + # FIXME: cgfxcat and cginfo need more patchelf + mkdir -p "$out/bin/" + cp -v bin/* "$out/bin/" + mkdir -p "$out/include/" + cp -v -r include/Cg/ "$out/include/" + mkdir -p "$out/lib/" + [ "$system" == "x86_64-linux" ] && cp -v lib64/* "$out/lib/" + [ "$system" == "i686-linux" ] && cp -v lib/* "$out/lib/" + mkdir -p "$out/share/doc/$name/" + cp -v -r local/Cg/* "$out/share/doc/$name/" + ''; + + meta = { + homepage = http://developer.nvidia.com/cg-toolkit; + license = lib.licenses.unfreeRedistributable; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/obliv-c/default.nix b/nixpkgs/pkgs/development/compilers/obliv-c/default.nix new file mode 100644 index 000000000000..0d171a474a20 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/obliv-c/default.nix @@ -0,0 +1,42 @@ +{ stdenv, libgcrypt, fetchFromGitHub, ocamlPackages, perl }: +stdenv.mkDerivation rec { + name = "obliv-c-${version}"; + version = "0.0pre20180624"; + buildInputs = [ perl ] + ++ (with ocamlPackages; [ ocaml findlib ocamlbuild ]); + propagatedBuildInputs = [ libgcrypt ]; + src = fetchFromGitHub { + owner = "samee"; + repo = "obliv-c"; + rev = "3d6804ca0fd85868207a0ccbd2509ec064723ac2"; + sha256 = "1ib21ngn7zr58xxq4sjigrpaxb0wx35x3k9l4qvwflzrmvnman20"; + }; + + patches = [ ./ignore-complex-float128.patch ]; + + preBuild = '' + patchShebangs . + ''; + + preInstall = '' + mkdir -p "$out/bin" + cp bin/* "$out/bin" + mkdir -p "$out/share/doc/obliv-c" + cp -r doc/* README* CHANGE* Change* LICEN* TODO* "$out/share/doc/obliv-c" + mkdir -p "$out/share/obliv-c" + cp -r test "$out/share/obliv-c" + mkdir -p "$out/include" + cp src/ext/oblivc/*.h "$out/include" + mkdir -p "$out/lib" + gcc $(ar t _build/libobliv.a | sed -e 's@^@_build/@') --shared -o _build/libobliv.so + cp _build/lib*.a _build/lib*.so* "$out/lib" + ''; + + meta = { + inherit version; + description = ''A GCC wrapper that makes it easy to embed secure computation protocols inside regular C programs''; + license = stdenv.lib.licenses.bsd3; + maintainers = [stdenv.lib.maintainers.raskin]; + platforms = stdenv.lib.platforms.linux; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/obliv-c/ignore-complex-float128.patch b/nixpkgs/pkgs/development/compilers/obliv-c/ignore-complex-float128.patch new file mode 100644 index 000000000000..e3a5b74a9cb2 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/obliv-c/ignore-complex-float128.patch @@ -0,0 +1,37 @@ +--- a/src/frontc/clexer.mll ++++ b/src/frontc/clexer.mll +@@ -134,9 +134,11 @@ let init_lexicon _ = + (* WW: see /usr/include/sys/cdefs.h for why __signed and __volatile + * are accepted GCC-isms *) + ("_Bool", fun loc -> BOOL loc); ++ ("_Complex", fun loc -> COMPLEX loc); + ("char", fun loc -> CHAR loc); + ("int", fun loc -> INT loc); + ("float", fun loc -> FLOAT loc); ++ ("__float128", fun loc -> FLOAT128 loc); + ("double", fun loc -> DOUBLE loc); + ("void", fun loc -> VOID loc); + ("enum", fun loc -> ENUM loc); +--- a/src/frontc/cparser.mly ++++ b/src/frontc/cparser.mly +@@ -269,6 +269,8 @@ let oblivState (s:statement): statement = + %token<Cabs.cabsloc> VOLATILE EXTERN STATIC CONST RESTRICT AUTO REGISTER FROZEN + %token<Cabs.cabsloc> THREAD + ++%token<Cabs.cabsloc> COMPLEX FLOAT128 ++ + %token<Cabs.cabsloc> SIZEOF ALIGNOF + + %token EQ PLUS_EQ MINUS_EQ STAR_EQ SLASH_EQ PERCENT_EQ +@@ -1002,7 +1004,11 @@ type_spec: /* ISO 6.7.2 */ + | LONG { Tlong, $1 } + | INT64 { Tint64, $1 } + | FLOAT { Tfloat, $1 } ++| FLOAT128 { Tfloat, $1 } + | DOUBLE { Tdouble, $1 } ++| COMPLEX FLOAT { Tfloat, $2 } ++| COMPLEX FLOAT128{ Tfloat, $2 } ++| COMPLEX DOUBLE { Tdouble, $2 } + | SIGNED { Tsigned, $1 } + | UNSIGNED { Tunsigned, $1 } + | STRUCT id_or_typename diff --git a/nixpkgs/pkgs/development/compilers/ocaml/3.08.0.nix b/nixpkgs/pkgs/development/compilers/ocaml/3.08.0.nix new file mode 100644 index 000000000000..4337de702e16 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/ocaml/3.08.0.nix @@ -0,0 +1,21 @@ +{ stdenv, fetchurl, xlibsWrapper }: + +stdenv.mkDerivation rec { + name = "ocaml-${version}"; + version = "3.08.0"; + + builder = ./builder.sh; + src = fetchurl { + url = "http://tarballs.nixos.org/${name}.tar.gz"; + sha256 = "135g5waj7djzrj0dbc8z1llasfs2iv5asq41jifhldxb4l2b97mx"; + }; + configureScript = ./configure-3.08.0; + dontAddPrefix = "True"; + configureFlags = ["-no-tk" "-x11lib" xlibsWrapper]; + buildFlags = ["world" "bootstrap" "opt"]; + checkTarget = ["opt.opt"]; + + meta = { + platforms = stdenv.lib.platforms.linux; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/ocaml/3.10.0.nix b/nixpkgs/pkgs/development/compilers/ocaml/3.10.0.nix new file mode 100644 index 000000000000..99a65dec1501 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/ocaml/3.10.0.nix @@ -0,0 +1,34 @@ +{ stdenv, fetchurl, xlibsWrapper, ncurses }: + +stdenv.mkDerivation (rec { + + name = "ocaml-${version}"; + version = "3.10.0"; + + src = fetchurl { + url = "https://caml.inria.fr/pub/distrib/ocaml-3.10/${name}.tar.bz2"; + sha256 = "1ihmx1civ78s7k2hfc05z1s9vbyx2qw7fg8lnbxnfd6zxkk8878d"; + }; + + prefixKey = "-prefix "; + configureFlags = ["-no-tk" "-x11lib" xlibsWrapper]; + buildFlags = "world bootstrap world.opt"; + buildInputs = [xlibsWrapper ncurses]; + installTargets = "install installopt"; + patchPhase = '' + CAT=$(type -tp cat) + sed -e "s@/bin/cat@$CAT@" -i config/auto-aux/sharpbang + ''; + postBuild = '' + mkdir -p $out/include + ln -sv $out/lib/ocaml/caml $out/include/caml + ''; + + meta = { + homepage = http://caml.inria.fr/ocaml; + license = with stdenv.lib.licenses; [ qpl lgpl2 ]; + description = "Most popular variant of the Caml language"; + platforms = stdenv.lib.platforms.linux; + }; + +}) diff --git a/nixpkgs/pkgs/development/compilers/ocaml/3.11.2.nix b/nixpkgs/pkgs/development/compilers/ocaml/3.11.2.nix new file mode 100644 index 000000000000..e65510c172e6 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/ocaml/3.11.2.nix @@ -0,0 +1,75 @@ +{ stdenv, fetchurl, ncurses, xlibsWrapper }: + +let + useX11 = stdenv.isi686 || stdenv.isx86_64; + useNativeCompilers = stdenv.isi686 || stdenv.isx86_64 || stdenv.isMips; + inherit (stdenv.lib) optionals optionalString; +in + +stdenv.mkDerivation rec { + + name = "ocaml-${version}"; + version = "3.11.2"; + + src = fetchurl { + url = "https://caml.inria.fr/pub/distrib/ocaml-3.11/${name}.tar.bz2"; + sha256 = "86f3387a0d7e7c8be2a3c53af083a5a726e333686208d5ea0dd6bb5ac3f58143"; + }; + + # Needed to avoid a SIGBUS on the final executable on mips + NIX_CFLAGS_COMPILE = if stdenv.isMips then "-fPIC" else ""; + + patches = optionals stdenv.isDarwin [ ./gnused-on-osx-fix.patch ] ++ + [ (fetchurl { + name = "0007-Fix-ocamlopt-w.r.t.-binutils-2.21.patch"; + url = "http://caml.inria.fr/mantis/file_download.php?file_id=418&type=bug"; + sha256 = "612a9ac108bbfce2238aa5634123da162f0315dedb219958be705e0d92dcdd8e"; + }) + ]; + + prefixKey = "-prefix "; + configureFlags = ["-no-tk"] ++ optionals useX11 [ "-x11lib" xlibsWrapper ]; + buildFlags = "world" + optionalString useNativeCompilers " bootstrap world.opt"; + buildInputs = [ncurses] ++ optionals useX11 [ xlibsWrapper ]; + installTargets = "install" + optionalString useNativeCompilers " installopt"; + prePatch = '' + CAT=$(type -tp cat) + sed -e "s@/bin/cat@$CAT@" -i config/auto-aux/sharpbang + patch -p0 < ${./mips64.patch} + ''; + postBuild = '' + mkdir -p $out/include + ln -sv $out/lib/ocaml/caml $out/include/caml + ''; + + meta = with stdenv.lib; { + homepage = http://caml.inria.fr/ocaml; + license = with licenses; [ + qpl /* compiler */ + lgpl2 /* library */ + ]; + description = "Most popular variant of the Caml language"; + + longDescription = + '' Objective Caml is the most popular variant of the Caml language. + From a language standpoint, it extends the core Caml language with a + fully-fledged object-oriented layer, as well as a powerful module + system, all connected by a sound, polymorphic type system featuring + type inference. + + The Objective Caml system is an industrial-strength implementation + of this language, featuring a high-performance native-code compiler + (ocamlopt) for 9 processor architectures (IA32, PowerPC, AMD64, + Alpha, Sparc, Mips, IA64, HPPA, StrongArm), as well as a bytecode + compiler (ocamlc) and an interactive read-eval-print loop (ocaml) + for quick development and portability. The Objective Caml + distribution includes a comprehensive standard library, a replay + debugger (ocamldebug), lexer (ocamllex) and parser (ocamlyacc) + generators, a pre-processor pretty-printer (camlp4) and a + documentation generator (ocamldoc). + ''; + + platforms = with platforms; linux ++ darwin; + }; + +} diff --git a/nixpkgs/pkgs/development/compilers/ocaml/3.12.1-darwin-fix-configure.patch b/nixpkgs/pkgs/development/compilers/ocaml/3.12.1-darwin-fix-configure.patch new file mode 100644 index 000000000000..4b867bbb1e6f --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/ocaml/3.12.1-darwin-fix-configure.patch @@ -0,0 +1,32 @@ +diff -Nuar ocaml-3.12.1/configure ocaml-3.12.1-fix-configure/configure +--- ocaml-3.12.1/configure 2011-07-04 23:15:01.000000000 +0200 ++++ ocaml-3.12.1-fix-configure/configure 2012-06-06 22:20:40.000000000 +0200 +@@ -259,7 +259,7 @@ + bytecccompopts="-fno-defer-pop $gcc_warnings -DSHRINKED_GNUC" + mathlib="";; + *,*-*-darwin*) +- bytecccompopts="-fno-defer-pop -no-cpp-precomp $gcc_warnings" ++ bytecccompopts="-fno-defer-pop $gcc_warnings" + mathlib="" + # Tell gcc that we can use 32-bit code addresses for threaded code + # unless we are compiled for a shared library (-fPIC option) +@@ -739,7 +739,7 @@ + *,*,rhapsody,*) nativecccompopts="$gcc_warnings -DDARWIN_VERSION_6 $dl_defs" + if $arch64; then partialld="ld -r -arch ppc64"; fi;; + *,gcc*,cygwin,*) nativecccompopts="$gcc_warnings -U_WIN32";; +- amd64,gcc*,macosx,*) partialld="ld -r -arch x86_64";; ++ amd64,gcc*,macosx,*) partialld="ld -r";; + amd64,gcc*,solaris,*) partialld="ld -r -m elf_x86_64";; + *,gcc*,*,*) nativecccompopts="$gcc_warnings";; + esac +@@ -752,8 +752,8 @@ + asppprofflags='-pg -DPROFILING';; + alpha,*,*) as='as' + aspp='gcc -c';; +- amd64,*,macosx) as='as -arch x86_64' +- aspp='gcc -arch x86_64 -c';; ++ amd64,*,macosx) as='as' ++ aspp='gcc -c';; + amd64,*,solaris) as='as --64' + aspp='gcc -m64 -c';; + amd64,*,*) as='as' diff --git a/nixpkgs/pkgs/development/compilers/ocaml/3.12.1.nix b/nixpkgs/pkgs/development/compilers/ocaml/3.12.1.nix new file mode 100644 index 000000000000..8636f670059c --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/ocaml/3.12.1.nix @@ -0,0 +1,69 @@ +{ stdenv, fetchurl, ncurses, xlibsWrapper }: + +let + useX11 = !stdenv.isAarch32 && !stdenv.isMips; + useNativeCompilers = !stdenv.isMips; + inherit (stdenv.lib) optionals optionalString; +in + +stdenv.mkDerivation rec { + + name = "ocaml-${version}"; + version = "3.12.1"; + + src = fetchurl { + url = "https://caml.inria.fr/pub/distrib/ocaml-3.12/${name}.tar.bz2"; + sha256 = "13cmhkh7s6srnlvhg3s9qzh3a5dbk2m9qr35jzq922sylwymdkzd"; + }; + + prefixKey = "-prefix "; + configureFlags = ["-no-tk"] ++ optionals useX11 [ "-x11lib" xlibsWrapper ]; + buildFlags = "world" + optionalString useNativeCompilers " bootstrap world.opt"; + buildInputs = [ncurses] ++ optionals useX11 [ xlibsWrapper ]; + installTargets = "install" + optionalString useNativeCompilers " installopt"; + patches = optionals stdenv.isDarwin [ ./3.12.1-darwin-fix-configure.patch ]; + preConfigure = '' + CAT=$(type -tp cat) + sed -e "s@/bin/cat@$CAT@" -i config/auto-aux/sharpbang + ''; + postBuild = '' + mkdir -p $out/include + ln -sv $out/lib/ocaml/caml $out/include/caml + ''; + + passthru = { + nativeCompilers = useNativeCompilers; + }; + + meta = with stdenv.lib; { + homepage = http://caml.inria.fr/ocaml; + branch = "3.12"; + license = with licenses; [ + qpl /* compiler */ + lgpl2 /* library */ + ]; + description = "Most popular variant of the Caml language"; + + longDescription = + '' + OCaml is the most popular variant of the Caml language. From a + language standpoint, it extends the core Caml language with a + fully-fledged object-oriented layer, as well as a powerful module + system, all connected by a sound, polymorphic type system featuring + type inference. + + The OCaml system is an industrial-strength implementation of this + language, featuring a high-performance native-code compiler (ocamlopt) + for 9 processor architectures (IA32, PowerPC, AMD64, Alpha, Sparc, + Mips, IA64, HPPA, StrongArm), as well as a bytecode compiler (ocamlc) + and an interactive read-eval-print loop (ocaml) for quick development + and portability. The OCaml distribution includes a comprehensive + standard library, a replay debugger (ocamldebug), lexer (ocamllex) and + parser (ocamlyacc) generators, a pre-processor pretty-printer (camlp4) + and a documentation generator (ocamldoc). + ''; + + platforms = with platforms; linux; + }; + +} diff --git a/nixpkgs/pkgs/development/compilers/ocaml/4.00.1.nix b/nixpkgs/pkgs/development/compilers/ocaml/4.00.1.nix new file mode 100644 index 000000000000..0a30ef1352c4 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/ocaml/4.00.1.nix @@ -0,0 +1,67 @@ +{ stdenv, fetchurl, ncurses, xlibsWrapper }: + +let + useX11 = !stdenv.isAarch32 && !stdenv.isMips; + useNativeCompilers = !stdenv.isMips; + inherit (stdenv.lib) optionals optionalString; +in + +stdenv.mkDerivation rec { + name = "ocaml-${version}"; + version = "4.00.1"; + + src = fetchurl { + url = "https://caml.inria.fr/pub/distrib/ocaml-4.00/${name}.tar.bz2"; + sha256 = "33c3f4acff51685f5bfd7c260f066645e767d4e865877bf1613c176a77799951"; + }; + + prefixKey = "-prefix "; + configureFlags = ["-no-tk"] ++ optionals useX11 [ "-x11lib" xlibsWrapper ]; + buildFlags = "world" + optionalString useNativeCompilers " bootstrap world.opt"; + buildInputs = [ncurses] ++ optionals useX11 [ xlibsWrapper ]; + installTargets = "install" + optionalString useNativeCompilers " installopt"; + preConfigure = '' + CAT=$(type -tp cat) + sed -e "s@/bin/cat@$CAT@" -i config/auto-aux/sharpbang + ''; + postBuild = '' + mkdir -p $out/include + ln -sv $out/lib/ocaml/caml $out/include/caml + ''; + + passthru = { + nativeCompilers = useNativeCompilers; + }; + + meta = with stdenv.lib; { + homepage = http://caml.inria.fr/ocaml; + branch = "4.00"; + license = with licenses; [ + qpl /* compiler */ + lgpl2 /* library */ + ]; + description = "Most popular variant of the Caml language"; + + longDescription = + '' + OCaml is the most popular variant of the Caml language. From a + language standpoint, it extends the core Caml language with a + fully-fledged object-oriented layer, as well as a powerful module + system, all connected by a sound, polymorphic type system featuring + type inference. + + The OCaml system is an industrial-strength implementation of this + language, featuring a high-performance native-code compiler (ocamlopt) + for 9 processor architectures (IA32, PowerPC, AMD64, Alpha, Sparc, + Mips, IA64, HPPA, StrongArm), as well as a bytecode compiler (ocamlc) + and an interactive read-eval-print loop (ocaml) for quick development + and portability. The OCaml distribution includes a comprehensive + standard library, a replay debugger (ocamldebug), lexer (ocamllex) and + parser (ocamlyacc) generators, a pre-processor pretty-printer (camlp4) + and a documentation generator (ocamldoc). + ''; + + platforms = with platforms; linux; + }; + +} diff --git a/nixpkgs/pkgs/development/compilers/ocaml/4.01.0.nix b/nixpkgs/pkgs/development/compilers/ocaml/4.01.0.nix new file mode 100644 index 000000000000..aa6cf68d2c96 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/ocaml/4.01.0.nix @@ -0,0 +1,7 @@ +import ./generic.nix rec { + major_version = "4"; + minor_version = "01"; + patch_version = "0"; + patches = [ ./fix-clang-build-on-osx.diff ]; + sha256 = "03d7ida94s1gpr3gadf4jyhmh5rrszd5s4m4z59daaib25rvfyv7"; +} diff --git a/nixpkgs/pkgs/development/compilers/ocaml/4.02.nix b/nixpkgs/pkgs/development/compilers/ocaml/4.02.nix new file mode 100644 index 000000000000..9ac53f567909 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/ocaml/4.02.nix @@ -0,0 +1,7 @@ +import ./generic.nix rec { + major_version = "4"; + minor_version = "02"; + patch_version = "3"; + patches = [ ./ocamlbuild.patch ]; + sha256 = "1qwwvy8nzd87hk8rd9sm667nppakiapnx4ypdwcrlnav2dz6kil3"; +} diff --git a/nixpkgs/pkgs/development/compilers/ocaml/4.03.nix b/nixpkgs/pkgs/development/compilers/ocaml/4.03.nix new file mode 100644 index 000000000000..c9536c487d05 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/ocaml/4.03.nix @@ -0,0 +1,6 @@ +import ./generic.nix rec { + major_version = "4"; + minor_version = "03"; + patch_version = "0"; + sha256 = "09p3iwwi55r6rbrpyp8f0wmkb0ppcgw67yxw6yfky60524wayp39"; +} diff --git a/nixpkgs/pkgs/development/compilers/ocaml/4.04.nix b/nixpkgs/pkgs/development/compilers/ocaml/4.04.nix new file mode 100644 index 000000000000..4f49bcf80728 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/ocaml/4.04.nix @@ -0,0 +1,9 @@ +import ./generic.nix { + major_version = "4"; + minor_version = "04"; + patch_version = "2"; + sha256 = "0bhgjzi78l10824qga85nlh18jg9lb6aiamf9dah1cs6jhzfsn6i"; + + # If the executable is stipped it does not work + dontStrip = true; +} diff --git a/nixpkgs/pkgs/development/compilers/ocaml/4.05.nix b/nixpkgs/pkgs/development/compilers/ocaml/4.05.nix new file mode 100644 index 000000000000..a63b06a9f628 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/ocaml/4.05.nix @@ -0,0 +1,9 @@ +import ./generic.nix { + major_version = "4"; + minor_version = "05"; + patch_version = "0"; + sha256 = "1y9fw1ci9pwnbbrr9nwr8cq8vypcxwdf4akvxard3mxl2jx2g984"; + + # If the executable is stipped it does not work + dontStrip = true; +} diff --git a/nixpkgs/pkgs/development/compilers/ocaml/4.06.nix b/nixpkgs/pkgs/development/compilers/ocaml/4.06.nix new file mode 100644 index 000000000000..b54b8a6288fe --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/ocaml/4.06.nix @@ -0,0 +1,9 @@ +import ./generic.nix { + major_version = "4"; + minor_version = "06"; + patch_version = "1"; + sha256 = "1n3pygfssd6nkrq876wszm5nm3v4605q4k16a66h1nmq9wvf01vg"; + + # If the executable is stipped it does not work + dontStrip = true; +} diff --git a/nixpkgs/pkgs/development/compilers/ocaml/4.07.nix b/nixpkgs/pkgs/development/compilers/ocaml/4.07.nix new file mode 100644 index 000000000000..c1952f30ba68 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/ocaml/4.07.nix @@ -0,0 +1,9 @@ +import ./generic.nix { + major_version = "4"; + minor_version = "07"; + patch_version = "1"; + sha256 = "1f07hgj5k45cylj1q3k5mk8yi02cwzx849b1fwnwia8xlcfqpr6z"; + + # If the executable is stripped it does not work + dontStrip = true; +} diff --git a/nixpkgs/pkgs/development/compilers/ocaml/4.08.nix b/nixpkgs/pkgs/development/compilers/ocaml/4.08.nix new file mode 100644 index 000000000000..53d4ceef92a7 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/ocaml/4.08.nix @@ -0,0 +1,12 @@ +import ./generic.nix { + major_version = "4"; + minor_version = "08"; + patch_version = "0+beta3"; + sha256 = "02pk4bxrgqb12hvpbxyqnl4nwr4g2h96wsfzfd1k8vj8h0jmxzc4"; + + # If the executable is stripped it does not work + dontStrip = true; + + # Breaks build with Clang + hardeningDisable = [ "strictoverflow" ]; +} diff --git a/nixpkgs/pkgs/development/compilers/ocaml/ber-metaocaml.nix b/nixpkgs/pkgs/development/compilers/ocaml/ber-metaocaml.nix new file mode 100644 index 000000000000..a933151de12a --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/ocaml/ber-metaocaml.nix @@ -0,0 +1,96 @@ +{ stdenv, fetchurl +, ncurses +, libX11, xorgproto, buildEnv +}: + +let + useX11 = stdenv.isi686 || stdenv.isx86_64; + x11deps = [ libX11 xorgproto ]; + inherit (stdenv.lib) optionals; + + baseOcamlBranch = "4.07"; + baseOcamlVersion = "${baseOcamlBranch}.1"; + metaocamlPatch = "107"; +in + +stdenv.mkDerivation rec { + name = "ber-metaocaml-${version}"; + version = metaocamlPatch; + + src = fetchurl { + url = "https://caml.inria.fr/pub/distrib/ocaml-${baseOcamlBranch}/ocaml-${baseOcamlVersion}.tar.gz"; + sha256 = "1x4sln131mcspisr22qc304590rvg720rbl7g2i4xiymgvhkpm1a"; + }; + + metaocaml = fetchurl { + url = "http://okmij.org/ftp/ML/ber-metaocaml-107.tar.gz"; + sha256 = "0xy6n0yj1f53pk612zfmn49pn04bd75qa40xgmr0w0lzx6dqsfmm"; + }; + + x11env = buildEnv { name = "x11env"; paths = x11deps; }; + x11lib = "${x11env}/lib"; + x11inc = "${x11env}/include"; + + prefixKey = "-prefix "; + configureFlags = optionals useX11 + [ "-x11lib" x11lib + "-x11include" x11inc + "-flambda" + ]; + + dontStrip = true; + buildInputs = [ ncurses ] ++ optionals useX11 x11deps; + + postConfigure = '' + tar -xvzf $metaocaml + cd ${name} + make patch + cd .. + ''; + + buildPhase = '' + make world + make -i install + + make bootstrap + make opt.opt + make installopt + mkdir -p $out/include + ln -sv $out/lib/ocaml/caml $out/include/caml + cd ${name} + make all + ''; + + installPhase = '' + make install + make install.opt + ''; + + checkPhase = '' + cd ${name} + make test + make test-compile + make test-native + cd .. + ''; + + passthru = { + nativeCompilers = true; + }; + + meta = with stdenv.lib; { + description = "Multi-Stage Programming extension for OCaml"; + homepage = http://okmij.org/ftp/ML/MetaOCaml.html; + license = with licenses; [ /* compiler */ qpl /* library */ lgpl2 ]; + maintainers = with maintainers; [ thoughtpolice ]; + + branch = baseOcamlBranch; + platforms = with platforms; linux ++ darwin; + broken = stdenv.isAarch64 || stdenv.isMips; + + longDescription = '' + A simple extension of OCaml with the primitive type of code values, and + three basic multi-stage expression forms: Brackets, Escape, and Run. + ''; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/ocaml/builder.sh b/nixpkgs/pkgs/development/compilers/ocaml/builder.sh new file mode 100644 index 000000000000..a1807682d867 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/ocaml/builder.sh @@ -0,0 +1,8 @@ +source $stdenv/setup + +configureFlags="-prefix $out $configureFlags" +genericBuild + +#cd emacs/ +#mkdir -p $out/share/ocaml/emacs +#make EMACSDIR=$out/share/ocaml/emacs install diff --git a/nixpkgs/pkgs/development/compilers/ocaml/configure-3.08.0 b/nixpkgs/pkgs/development/compilers/ocaml/configure-3.08.0 new file mode 100755 index 000000000000..9c8705855120 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/ocaml/configure-3.08.0 @@ -0,0 +1,1482 @@ +#! /bin/sh + +######################################################################### +# # +# Objective Caml # +# # +# Xavier Leroy, projet Cristal, INRIA Rocquencourt # +# # +# Copyright 1999 Institut National de Recherche en Informatique et # +# en Automatique. All rights reserved. This file is distributed # +# under the terms of the GNU Library General Public License, with # +# the special exception on linking described in file LICENSE. # +# # +######################################################################### + +# $Id: configure,v 1.215.2.3 2004/07/09 15:08:51 doligez Exp $ + +configure_options="$*" +prefix=/usr/local +bindir='' +libdir='' +mandir='' +manext=1 +host_type=unknown +ccoption='' +cclibs='' +curseslibs='' +mathlib='-lm' +dllib='' +x11_include_dir='' +x11_lib_dir='' +tk_wanted=yes +pthread_wanted=yes +tk_defs='' +tk_libs='' +tk_x11=yes +dl_defs='' +verbose=no +withcurses=yes +withsharedlibs=yes +binutils_dir='' +gcc_warnings="-Wall" + +# Try to turn internationalization off, can cause config.guess to malfunction! +unset LANG +unset LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES LC_MONETARY LC_NUMERIC LC_TIME + +# Turn off some macOS debugging stuff, same reason +unset RC_TRACE_ARCHIVES RC_TRACE_DYLIBS RC_TRACE_PREBINDING_DISABLED + +# Parse command-line arguments + +while : ; do + case "$1" in + "") break;; + -prefix|--prefix) + prefix=$2; shift;; + -bindir|--bindir) + bindir=$2; shift;; + -libdir|--libdir) + libdir=$2; shift;; + -mandir|--mandir) + case "$2" in + */man[1-9ln]) + mandir=`echo $2 | sed -e 's|^\(.*\)/man.$|\1|'` + manext=`echo $2 | sed -e 's/^.*\(.\)$/\1/'`;; + *) + mandir=$2 + manext=1;; + esac + shift;; + -host*|--host*) + host_type=$2; shift;; + -cc*) + ccoption="$2"; shift;; + -lib*) + cclibs="$2 $cclibs"; shift;; + -no-curses) + withcurses=no;; + -no-shared-libs) + withsharedlibs=no;; + -x11include*|--x11include*) + x11_include_dir=$2; shift;; + -x11lib*|--x11lib*) + x11_lib_dir=$2; shift;; + -with-pthread*|--with-pthread*) + ;; # Ignored for backward compatibility + -no-pthread*|--no-pthread*) + pthread_wanted=no;; + -no-tk|--no-tk) + tk_wanted=no;; + -tkdefs*|--tkdefs*) + tk_defs=$2; shift;; + -tklibs*|--tklibs*) + tk_libs=$2; shift;; + -tk-no-x11|--tk-no-x11) + tk_x11=no;; + -dldefs*|--dldefs*) + dl_defs="$2"; shift;; + -dllibs*|--dllibs*) + dllib="$2"; shift;; + -binutils*|--binutils*) + binutils_dir=$2; shift;; + -verbose|--verbose) + verbose=yes;; + *) echo "Unknown option \"$1\"." 1>&2; exit 2;; + esac + shift +done + +# Sanity checks + +case "$prefix" in + /*) ;; + *) echo "The -prefix directory must be absolute." 1>&2; exit 2;; +esac +case "$bindir" in + /*) ;; + "") ;; + *) echo "The -bindir directory must be absolute." 1>&2; exit 2;; +esac +case "$libdir" in + /*) ;; + "") ;; + *) echo "The -libdir directory must be absolute." 1>&2; exit 2;; +esac +case "$mandir" in + /*) ;; + "") ;; + *) echo "The -mandir directory must be absolute." 1>&2; exit 2;; +esac + +# Generate the files + +cd config/auto-aux +rm -f s.h m.h Makefile +touch s.h m.h Makefile + +# Write options to Makefile + +echo "# generated by ./configure $configure_options" >> Makefile + +# Where to install + +echo "PREFIX=$prefix" >> Makefile +case "$bindir" in + "") echo 'BINDIR=$(PREFIX)/bin' >> Makefile + bindir="$prefix/bin";; + *) echo "BINDIR=$bindir" >> Makefile;; +esac +case "$libdir" in + "") echo 'LIBDIR=$(PREFIX)/lib/ocaml' >> Makefile + libdir="$prefix/lib/ocaml";; + *) echo "LIBDIR=$libdir" >> Makefile;; +esac +echo 'STUBLIBDIR=$(LIBDIR)/stublibs' >> Makefile +case "$mandir" in + "") echo 'MANDIR=$(PREFIX)/man' >> Makefile + mandir="$prefix/man";; + *) echo "MANDIR=$mandir" >> Makefile;; +esac +echo "MANEXT=$manext" >> Makefile + +# Determine the system type + +if test "$host_type" = "unknown"; then + if host_type=`../gnu/config.guess`; then :; else + echo "Cannot guess host type" + echo "You must specify one with the -host option" + exit 2 + fi +fi +if host=`../gnu/config.sub $host_type`; then :; else + echo "Please specify the correct host type with the -host option" + exit 2 +fi +echo "Configuring for a $host ..." + +# Do we have gcc? + +if test -z "$ccoption"; then + if sh ./searchpath gcc; then + echo "gcc found" + cc=gcc + else + cc=cc + fi +else + cc="$ccoption" +fi + +# Check for buggy versions of GCC + +buggycc="no" + +case "$host,$cc" in + i[3456]86-*-*,gcc*) + case `$cc --version` in + 2.7.2.1) cat <<'EOF' + +WARNING: you are using gcc version 2.7.2.1 on an Intel x86 processor. +This version of gcc is known to generate incorrect code for the +Objective Caml runtime system on some Intel x86 machines. (The symptom +is a crash of boot/ocamlc when compiling stdlib/pervasives.mli.) +In particular, the version of gcc 2.7.2.1 that comes with +Linux RedHat 4.x / Intel is affected by this problem. +Other Linux distributions might also be affected. +If you are using one of these configurations, you are strongly advised +to use another version of gcc, such as 2.95, which are +known to work well with Objective Caml. + +Press <enter> to proceed or <interrupt> to stop. +EOF + read reply;; + 2.96*) cat <<'EOF' + +WARNING: you are using gcc version 2.96 on an Intel x86 processor. +Certain patched versions of gcc 2.96 are known to generate incorrect +code for the Objective Caml runtime system. (The symptom is a segmentation +violation on boot/ocamlc.) Those incorrectly patched versions can be found +in RedHat 7.2 and Mandrake 8.0 and 8.1; other Linux distributions +might also be affected. (See bug #57760 on bugzilla.redhat.com) + +Auto-configuration will now select gcc compiler flags that work around +the problem. Still, if you observe segmentation faults while running +ocamlc or ocamlopt, you are advised to try another version of gcc, +such as 2.95.3 or 3.2. + +EOF + buggycc="gcc.2.96";; + + esac;; +esac + +# Configure the bytecode compiler + +bytecc="$cc" +bytecccompopts="" +bytecclinkopts="" +ostype="Unix" +exe="" + +case "$bytecc,$host" in + cc,*-*-nextstep*) + # GNU C extensions disabled, but __GNUC__ still defined! + bytecccompopts="-fno-defer-pop $gcc_warnings -U__GNUC__ -posix" + bytecclinkopts="-posix";; + *,*-*-rhapsody*) + # Almost the same as NeXTStep + bytecccompopts="-fno-defer-pop $gcc_warnings -DSHRINKED_GNUC" + mathlib="";; + *,*-*-darwin*) + # Almost the same as rhapsody + bytecccompopts="-fno-defer-pop -no-cpp-precomp $gcc_warnings" + mathlib="";; + *,*-*-beos*) + bytecccompopts="-fno-defer-pop $gcc_warnings" + # No -lm library + mathlib="";; + gcc,alpha*-*-osf*) + bytecccompopts="-fno-defer-pop $gcc_warnings" + if cc="$bytecc" sh ./hasgot -mieee; then + bytecccompopts="-mieee $bytecccompopts"; + fi + # Put code and static data in lower 4GB + bytecclinkopts="-Wl,-T,12000000 -Wl,-D,14000000" + # Tell gcc that we can use 32-bit code addresses for threaded code + echo "#define ARCH_CODE32" >> m.h;; + cc,alpha*-*-osf*) + bytecccompopts="-std1 -ieee";; + gcc,alpha*-*-linux*) + if cc="$bytecc" sh ./hasgot -mieee; then + bytecccompopts="-mieee $bytecccompopts"; + fi;; + cc,mips-*-irix6*) + # Add -n32 flag to ensure compatibility with native-code compiler + bytecccompopts="-n32" + # Turn off warning "unused library" + bytecclinkopts="-n32 -Wl,-woff,84";; + cc*,mips-*-irix6*) + # (For those who want to force "cc -64") + # Turn off warning "unused library" + bytecclinkopts="-Wl,-woff,84";; + *,alpha*-*-unicos*) + # For the Cray T3E + bytecccompopts="-DUMK";; + gcc*,powerpc-*-aix4.3*) + # Avoid name-space pollution by requiring Unix98-conformant includes + bytecccompopts="-fno-defer-pop $gcc_warnings -D_XOPEN_SOURCE=500";; + *,powerpc-*-aix4.3*) + bytecccompopts="-D_XOPEN_SOURCE=500";; + gcc*,*-*-cygwin*) + bytecccompopts="-fno-defer-pop $gcc_warnings -U_WIN32" + exe=".exe" + ostype="Cygwin";; + gcc*,x86_64-*-linux*) + bytecccompopts="-fno-defer-pop $gcc_warnings" + # Tell gcc that we can use 32-bit code addresses for threaded code + echo "#define ARCH_CODE32" >> m.h;; + gcc*) + bytecccompopts="-fno-defer-pop $gcc_warnings";; +esac + +# Configure compiler to use in further tests + +cc="$bytecc -O $bytecclinkopts" +export cc cclibs verbose + +# Check C compiler + +sh ./runtest ansi.c +case $? in + 0) echo "The C compiler is ANSI-compliant.";; + 1) echo "The C compiler $cc is not ANSI-compliant." + echo "You need an ANSI C compiler to build Objective Caml." + exit 2;; + *) echo "Unable to compile the test program." + echo "Make sure the C compiler $cc is properly installed." + exit 2;; +esac + +# Check the sizes of data types + +echo "Checking the sizes of integers and pointers..." +set `sh ./runtest sizes.c` +case "$2,$3" in + 4,4) echo "OK, this is a regular 32 bit architecture." + echo "#undef ARCH_SIXTYFOUR" >> m.h;; + 8,8) echo "Wow! A 64 bit architecture!" + echo "#define ARCH_SIXTYFOUR" >> m.h;; + *,8) echo "Wow! A 64 bit architecture!" + echo "Unfortunately, Objective Caml cannot work in the case" + echo "sizeof(long) != sizeof(long *)." + echo "Objective Caml won't run on this architecture." + exit 2;; + *,*) echo "This architecture seems to be neither 32 bits nor 64 bits." + echo "Objective Caml won't run on this architecture." + exit 2;; + *) echo "Unable to compile the test program." + echo "Make sure the C compiler $cc is properly installed." + exit 2;; +esac +if test $1 != 4 && test $2 != 4 && test $4 != 4; then + echo "Sorry, we can't find a 32-bit integer type" + echo "(sizeof(short) = $4, sizeof(int) = $1, sizeof(long) = $2)" + echo "Objective Caml won't run on this architecture." + exit 2 +fi + +echo "#define SIZEOF_INT $1" >> m.h +echo "#define SIZEOF_LONG $2" >> m.h +echo "#define SIZEOF_SHORT $4" >> m.h + +if test $2 = 8; then + echo "#define ARCH_INT64_TYPE long" >> m.h + echo "#define ARCH_UINT64_TYPE unsigned long" >> m.h + echo '#define ARCH_INT64_PRINTF_FORMAT "l"' >> m.h + int64_native=true +else + sh ./runtest longlong.c + case $? in + 0) echo "64-bit \"long long\" integer type found (printf with \"%ll\")." + echo "#define ARCH_INT64_TYPE long long" >> m.h + echo "#define ARCH_UINT64_TYPE unsigned long long" >> m.h + echo '#define ARCH_INT64_PRINTF_FORMAT "ll"' >> m.h + int64_native=true;; + 1) echo "64-bit \"long long\" integer type found (printf with \"%q\")." + echo "#define ARCH_INT64_TYPE long long" >> m.h + echo "#define ARCH_UINT64_TYPE unsigned long long" >> m.h + echo '#define ARCH_INT64_PRINTF_FORMAT "q"' >> m.h + int64_native=true;; + 2) echo "64-bit \"long long\" integer type found (but no printf)." + echo "#define ARCH_INT64_TYPE long long" >> m.h + echo "#define ARCH_UINT64_TYPE unsigned long long" >> m.h + echo '#undef ARCH_INT64_PRINTF_FORMAT' >> m.h + int64_native=true;; + *) echo "No suitable 64-bit integer type found, will use software emulation." + echo "#undef ARCH_INT64_TYPE" >> m.h + echo "#undef ARCH_UINT64_TYPE" >> m.h + echo '#undef ARCH_INT64_PRINTF_FORMAT' >> m.h + int64_native=false;; + esac +fi + +# Determine endianness + +sh ./runtest endian.c +case $? in + 0) echo "This is a big-endian architecture." + echo "#define ARCH_BIG_ENDIAN" >> m.h;; + 1) echo "This is a little-endian architecture." + echo "#undef ARCH_BIG_ENDIAN" >> m.h;; + 2) echo "This architecture seems to be neither big endian nor little endian." + echo "Objective Caml won't run on this architecture." + exit 2;; + *) echo "Something went wrong during endianness determination." + echo "You'll have to figure out endianness yourself" + echo "(option ARCH_BIG_ENDIAN in m.h).";; +esac + +# Determine alignment constraints + +case "$host" in + sparc-*-*|hppa*-*-*) + # On Sparc V9 with certain versions of gcc, determination of double + # alignment is not reliable (PR#1521), hence force it. + # Same goes for hppa. + # But there's a knack (PR#2572): + # if we're in 64-bit mode (sizeof(long) == 8), + # we must not doubleword-align floats... + if test $2 = 8; then + echo "Doubles can be word-aligned." + echo "#undef ARCH_ALIGN_DOUBLE" >> m.h + else + echo "Doubles must be doubleword-aligned." + echo "#define ARCH_ALIGN_DOUBLE" >> m.h + fi;; + *) + sh ./runtest dblalign.c + case $? in + 0) echo "Doubles can be word-aligned." + echo "#undef ARCH_ALIGN_DOUBLE" >> m.h;; + 1) echo "Doubles must be doubleword-aligned." + echo "#define ARCH_ALIGN_DOUBLE" >> m.h;; + *) echo "Something went wrong during alignment determination for doubles." + echo "I'm going to assume this architecture has alignment constraints over doubles." + echo "That's a safe bet: Objective Caml will work even if" + echo "this architecture has actually no alignment constraints." + echo "#define ARCH_ALIGN_DOUBLE" >> m.h;; + esac;; +esac + +if $int64_native; then + case "$host" in + hppa*-*-*) + if test $2 = 8; then + echo "64-bit integers can be word-aligned." + echo "#undef ARCH_ALIGN_INT64" >> m.h + else + echo "64-bit integers must be doubleword-aligned." + echo "#define ARCH_ALIGN_INT64" >> m.h + fi;; + *) + sh ./runtest int64align.c + case $? in + 0) echo "64-bit integers can be word-aligned." + echo "#undef ARCH_ALIGN_INT64" >> m.h;; + 1) echo "64-bit integers must be doubleword-aligned." + echo "#define ARCH_ALIGN_INT64" >> m.h;; + *) echo "Something went wrong during alignment determination for 64-bit integers." + echo "I'm going to assume this architecture has alignment constraints." + echo "That's a safe bet: Objective Caml will work even if" + echo "this architecture has actually no alignment constraints." + echo "#define ARCH_ALIGN_INT64" >> m.h;; + esac + esac +else + echo "#undef ARCH_ALIGN_INT64" >> m.h +fi + +# Check semantics of division and modulus + +sh ./runtest divmod.c +case $? in + 0) echo "Native division and modulus have round-towards-zero semantics, will use them." + echo "#undef NONSTANDARD_DIV_MOD" >> m.h;; + 1) echo "Native division and modulus do not have round-towards-zero semantics, will use software emulation." + echo "#define NONSTANDARD_DIV_MOD" >> m.h;; + *) echo "Something went wrong while checking native division and modulus, please report it." + echo "#define NONSTANDARD_DIV_MOD" >> m.h;; +esac + +# Shared library support + +shared_libraries_supported=false +dl_needs_underscore=false +sharedcccompopts='' +mksharedlib='' +byteccrpath='' +mksharedlibrpath='' + +if test $withsharedlibs = "yes"; then + case "$host" in + *-*-linux-gnu|*-*-linux|*-*-freebsd[3-9]*) + sharedcccompopts="-fPIC" + mksharedlib="$bytecc -shared -o" + bytecclinkopts="$bytecclinkopts -Wl,-E" + byteccrpath="-Wl,-rpath," + mksharedlibrpath="-Wl,-rpath," + shared_libraries_supported=true;; + alpha*-*-osf*) + case "$bytecc" in + gcc*) + sharedcccompopts="-fPIC" + mksharedlib="$bytecc -shared -o" + byteccrpath="-Wl,-rpath," + mksharedlibrpath="-Wl,-rpath," + shared_libraries_supported=true;; + cc*) + sharedcccompopts="" + mksharedlib="ld -shared -expect_unresolved '*' -o" + byteccrpath="-Wl,-rpath," + mksharedlibrpath="-rpath " + shared_libraries_supported=true;; + esac;; + *-*-solaris2*) + case "$bytecc" in + gcc*) + sharedcccompopts="-fPIC" + if sh ./solaris-ld; then + mksharedlib="$bytecc -shared -o" + byteccrpath="-R" + mksharedlibrpath="-R" + else + mksharedlib="$bytecc -shared -o" + bytecclinkopts="$bytecclinkopts -Wl,-E" + byteccrpath="-Wl,-rpath," + mksharedlibrpath="-Wl,-rpath," + fi + shared_libraries_supported=true;; + *) + sharedcccompopts="-KPIC" + byteccrpath="-R" + mksharedlibrpath="-R" + mksharedlib="/usr/ccs/bin/ld -G -o" + shared_libraries_supported=true;; + esac;; + mips*-*-irix[56]*) + case "$bytecc" in + cc*) sharedcccompopts="";; + gcc*) sharedcccompopts="-fPIC";; + esac + mksharedlib="ld -shared -rdata_shared -o" + byteccrpath="-Wl,-rpath," + mksharedlibrpath="-rpath " + shared_libraries_supported=true;; + powerpc-apple-darwin*) + mksharedlib="cc -bundle -flat_namespace -undefined suppress -o" + bytecccompopts="$dl_defs $bytecccompopts" + #sharedcccompopts="-fnocommon" + dl_needs_underscore=true + shared_libraries_supported=true;; + esac +fi + +# Further machine-specific hacks + +case "$host" in + ia64-*-linux*|alpha*-*-linux*|x86_64-*-linux*) + echo "Will use mmap() instead of malloc() for allocation of major heap chunks." + echo "#define USE_MMAP_INSTEAD_OF_MALLOC" >> s.h;; +esac + +# Configure the native-code compiler + +arch=none +model=default +system=unknown + +case "$host" in + alpha*-*-osf*) arch=alpha; system=digital;; + alpha*-*-linux*) arch=alpha; system=linux;; + alpha*-*-freebsd*) arch=alpha; system=freebsd;; + alpha*-*-netbsd*) arch=alpha; system=netbsd;; + alpha*-*-openbsd*) arch=alpha; system=openbsd;; + sparc*-*-sunos4.*) arch=sparc; system=sunos;; + sparc*-*-solaris2.*) arch=sparc; system=solaris;; + sparc*-*-*bsd*) arch=sparc; system=bsd;; + sparc*-*-linux*) arch=sparc; system=linux;; + i[3456]86-*-linux*) arch=i386; system=linux_`sh ./runtest elf.c`;; + i[3456]86-*-*bsd*) arch=i386; system=bsd_`sh ./runtest elf.c`;; + i[3456]86-*-nextstep*) arch=i386; system=nextstep;; + i[3456]86-*-solaris*) arch=i386; system=solaris;; + i[3456]86-*-beos*) arch=i386; system=beos;; + i[3456]86-*-cygwin*) arch=i386; system=cygwin;; + mips-*-irix6*) arch=mips; system=irix;; + hppa1.1-*-hpux*) arch=hppa; system=hpux;; + hppa2.0*-*-hpux*) arch=hppa; system=hpux;; + hppa*-*-linux*) arch=hppa; system=linux;; + powerpc-*-linux*) arch=power; model=ppc; system=elf;; + powerpc-*-netbsd*) arch=power; model=ppc; system=bsd;; + powerpc-*-rhapsody*) arch=power; model=ppc; system=rhapsody;; + powerpc-*-darwin*) arch=power; model=ppc; system=rhapsody;; + arm*-*-linux*) arch=arm; system=linux;; + ia64-*-linux*) arch=ia64; system=linux;; + ia64-*-freebsd*) arch=ia64; system=freebsd;; + x86_64-*-linux*) arch=amd64; system=linux;; + x86_64-*-freebsd*) arch=amd64; system=freebsd;; + x86_64-*-openbsd*) arch=amd64; system=openbsd;; +esac + +if test -z "$ccoption"; then + case "$arch,$system,$cc" in + alpha,digital,gcc*) nativecc=cc;; + mips,*,gcc*) nativecc=cc;; + *) nativecc="$bytecc";; + esac +else + nativecc="$ccoption" +fi + +nativecccompopts='' +nativecclinkopts='' +nativeccrpath="$byteccrpath" + +case "$arch,$nativecc,$system,$host_type" in + alpha,cc*,digital,*) nativecccompopts=-std1;; + mips,cc*,irix,*) nativecccompopts=-n32 + nativecclinkopts="-n32 -Wl,-woff,84";; + *,*,nextstep,*) nativecccompopts="$gcc_warnings -U__GNUC__ -posix" + nativecclinkopts="-posix";; + *,*,rhapsody,*darwin[1-5].*) + nativecccompopts="$gcc_warnings -DSHRINKED_GNUC";; + *,*,rhapsody,*) + nativecccompopts="$gcc_warnings -DDARWIN_VERSION_6 $dl_defs";; + *,gcc*,cygwin,*) nativecccompopts="$gcc_warnings -U_WIN32";; + *,gcc*,*,*) nativecccompopts="$gcc_warnings";; +esac + +asflags='' +aspp='$(AS)' +asppflags='' +asppprofflags='-DPROFILING' + +case "$arch,$model,$system" in + alpha,*,digital) asflags='-O2'; asppflags='-O2 -DSYS_$(SYSTEM)'; + asppprofflags='-pg -DPROFILING';; + alpha,*,linux) aspp='gcc'; asppflags='-c -DSYS_$(SYSTEM)';; + alpha,*,freebsd) aspp='gcc'; asppflags='-c -DSYS_$(SYSTEM)';; + alpha,*,netbsd) aspp='gcc'; asppflags='-c -DSYS_$(SYSTEM)';; + alpha,*,openbsd) aspp='gcc'; asppflags='-c -DSYS_$(SYSTEM)';; + mips,*,irix) asflags='-n32 -O2'; asppflags="$asflags";; + sparc,*,bsd) aspp='gcc'; asppflags='-c -DSYS_$(SYSTEM)';; + sparc,*,linux) aspp='gcc'; asppflags='-c -DSYS_$(SYSTEM)';; + sparc,*,*) case "$cc" in + gcc*) aspp='gcc'; asppflags='-c -DSYS_$(SYSTEM)';; + *) asppflags='-P -DSYS_$(SYSTEM)';; + esac;; + i386,*,solaris) aspp='/usr/ccs/bin/as'; asppflags='-P -DSYS_$(SYSTEM)';; + i386,*,*) aspp='gcc'; asppflags='-c -DSYS_$(SYSTEM)';; + hppa,*,*) aspp="$cc"; asppflags='-traditional -c -DSYS_$(SYSTEM)';; + power,*,elf) aspp='gcc'; asppflags='-c';; + power,*,bsd) aspp='gcc'; asppflags='-c -DSYS_$(SYSTEM)';; + power,*,rhapsody) ;; + arm,*,linux) aspp='gcc'; asppflags='-c -DSYS_$(SYSTEM)';; + ia64,*,*) asflags=-xexplicit + aspp='gcc'; asppflags='-c -DSYS_$(SYSTEM) -Wa,-xexplicit';; + amd64,*,*) aspp='gcc'; asppflags='-c -DSYS_$(SYSTEM)';; +esac + +cc_profile='-pg' +case "$arch,$model,$system" in + alpha,*,digital) profiling='prof';; + i386,*,linux_elf) profiling='prof';; + i386,*,bsd_elf) profiling='prof';; + sparc,*,solaris) + profiling='prof' + case "$nativecc" in gcc*) ;; *) cc_profile='-xpg';; esac;; + amd64,*,linux) profiling='prof';; + *) profiling='noprof';; +esac + +# Where are GNU binutils? + +binutils_objcopy='' +binutils_nm='' + +if test "$arch" != "none"; then + binutils_path="${binutils_dir}:${PATH}:/usr/libexec/binutils" + old_IFS="$IFS" + IFS=':' + for d in ${binutils_path}; do + if test -z "$d"; then continue; fi + if test -f "$d/objcopy" && test -f "$d/nm"; then + echo "objcopy and nm found in $d" + if test `$d/objcopy --help | grep -s -c 'redefine-sym'` -eq 0; then + echo "$d/objcopy does not support option --redefine-sym, discarded" + continue; + fi + if test `$d/nm --version | grep -s -c 'GNU nm'` -eq 0; then + echo "$d/nm is not from GNU binutils, discarded" + continue; + fi + binutils_objcopy="$d/objcopy" + binutils_nm="$d/nm" + break + fi + done + IFS="$old_IFS" +fi + +# Where is ranlib? + +if sh ./searchpath ranlib; then + echo "ranlib found" + echo "RANLIB=ranlib" >> Makefile + echo "RANLIBCMD=ranlib" >> Makefile +else + echo "ranlib not used" + echo "RANLIB=ar rs" >> Makefile + echo "RANLIBCMD=" >> Makefile +fi + +# Do #! scripts work? + +if (SHELL=/bin/sh; export SHELL; (./sharpbang || ./sharpbang2) >/dev/null); then + echo "#! appears to work in shell scripts" + case "$host" in + *-*-sunos*|*-*-unicos*) + echo "We won't use it, though, because under SunOS and Unicos it breaks" + echo "on pathnames longer than 30 characters" + echo "SHARPBANGSCRIPTS=false" >> Makefile;; + *-*-cygwin*) + echo "We won't use it, though, because of conflicts with .exe extension" + echo "under Cygwin" + echo "SHARPBANGSCRIPTS=false" >> Makefile;; + *) + echo "SHARPBANGSCRIPTS=true" >> Makefile;; + esac +else + echo "No support for #! in shell scripts" + echo "SHARPBANGSCRIPTS=false" >> Makefile +fi + +# Write the OS type (Unix or Cygwin) + +echo "#define OCAML_OS_TYPE \"$ostype\"" >> s.h +echo "#define OCAML_STDLIB_DIR \"$libdir\"" >> s.h + +# Use 64-bit file offset if possible + +bytecccompopts="$bytecccompopts -D_FILE_OFFSET_BITS=64" +nativecccompopts="$nativecccompopts -D_FILE_OFFSET_BITS=64" + +# Check the semantics of signal handlers + +if sh ./hasgot sigaction sigprocmask; then + echo "POSIX signal handling found." + echo "#define POSIX_SIGNALS" >> s.h +else + if sh ./runtest signals.c; then + echo "Signals have the BSD semantics." + echo "#define BSD_SIGNALS" >> s.h + else + echo "Signals have the System V semantics." + fi + if sh ./hasgot sigsetmask; then + echo "sigsetmask() found" + echo "#define HAS_SIGSETMASK" >> s.h + fi +fi + +# For the sys module + +if sh ./hasgot times; then + echo "times() found." + echo "#define HAS_TIMES" >> s.h +fi + +# For the terminfo module + +if test "$withcurses" = "yes"; then + for libs in "" "-lcurses" "-ltermcap" "-lcurses -ltermcap" "-lncurses"; do + if sh ./hasgot $libs tgetent tgetstr tgetnum tputs; then + echo "termcap functions found (with libraries '$libs')" + echo "#define HAS_TERMCAP" >> s.h + curseslibs="${libs}" + break + fi + done +fi + +# Configuration for the libraries + +otherlibraries="unix str num dynlink bigarray" + +# For the Unix library + +has_sockets=no +if sh ./hasgot socket socketpair bind listen accept connect; then + echo "You have BSD sockets." + echo "#define HAS_SOCKETS" >> s.h + has_sockets=yes +elif sh ./hasgot -lnsl -lsocket socket socketpair bind listen accept connect; then + echo "You have BSD sockets (with libraries '-lnsl -lsocket')" + cclibs="$cclibs -lnsl -lsocket" + echo "#define HAS_SOCKETS" >> s.h + has_sockets=yes +fi + +if sh ./hasgot -i sys/socket.h -t socklen_t; then + echo "socklen_t is defined in <sys/socket.h>" + echo "#define HAS_SOCKLEN_T" >> s.h +fi + +if sh ./hasgot inet_aton; then + echo "inet_aton() found." + echo "#define HAS_INET_ATON" >> s.h +fi + +if sh ./hasgot -i sys/types.h -i sys/socket.h -i netinet/in.h \ + -t 'struct sockaddr_in6' \ +&& sh ./hasgot getaddrinfo getnameinfo inet_pton inet_ntop; then + echo "IPv6 is supported." + echo "#define HAS_IPV6" >> s.h +fi + +if sh ./hasgot -i unistd.h; then + echo "unistd.h found." + echo "#define HAS_UNISTD" >> s.h +fi + +if sh ./hasgot -i sys/types.h -t off_t; then + echo "off_t is defined in <sys/types.h>" + echo "#define HAS_OFF_T" >> s.h +fi + +if sh ./hasgot -i sys/types.h -i dirent.h; then + echo "dirent.h found." + echo "#define HAS_DIRENT" >> s.h +fi + +if sh ./hasgot rewinddir; then + echo "rewinddir() found." + echo "#define HAS_REWINDDIR" >> s.h +fi + +if sh ./hasgot lockf; then + echo "lockf() found." + echo "#define HAS_LOCKF" >> s.h +fi + +if sh ./hasgot mkfifo; then + echo "mkfifo() found." + echo "#define HAS_MKFIFO" >> s.h +fi + +if sh ./hasgot getcwd; then + echo "getcwd() found." + echo "#define HAS_GETCWD" >> s.h +fi + +if sh ./hasgot getwd; then + echo "getwd() found." + echo "#define HAS_GETWD" >> s.h +fi + +if sh ./hasgot getpriority setpriority; then + echo "getpriority() found." + echo "#define HAS_GETPRIORITY" >> s.h +fi + +if sh ./hasgot -i sys/types.h -i utime.h && sh ./hasgot utime; then + echo "utime() found." + echo "#define HAS_UTIME" >> s.h +fi + +if sh ./hasgot utimes; then + echo "utimes() found." + echo "#define HAS_UTIMES" >> s.h +fi + +if sh ./hasgot dup2; then + echo "dup2() found." + echo "#define HAS_DUP2" >> s.h +fi + +if sh ./hasgot fchmod fchown; then + echo "fchmod() found." + echo "#define HAS_FCHMOD" >> s.h +fi + +if sh ./hasgot truncate ftruncate; then + echo "truncate() found." + echo "#define HAS_TRUNCATE" >> s.h +fi + +select_include='' +if sh ./hasgot -i sys/types.h -i sys/select.h; then + echo "sys/select.h found." + echo "#define HAS_SYS_SELECT_H" >> s.h + select_include='-i sys/select.h' +fi + +has_select=no +if sh ./hasgot select && \ + sh ./hasgot -i sys/types.h $select_include -t fd_set ; then + echo "select() found." + echo "#define HAS_SELECT" >> s.h + has_select=yes +fi + +if sh ./hasgot symlink readlink lstat; then + echo "symlink() found." + echo "#define HAS_SYMLINK" >> s.h +fi + +has_wait=no +if sh ./hasgot waitpid; then + echo "waitpid() found." + echo "#define HAS_WAITPID" >> s.h + has_wait=yes +fi + +if sh ./hasgot wait4; then + echo "wait4() found." + echo "#define HAS_WAIT4" >> s.h + has_wait=yes +fi + +if sh ./hasgot -i limits.h && sh ./runtest getgroups.c; then + echo "getgroups() found." + echo "#define HAS_GETGROUPS" >> s.h +fi + +if sh ./hasgot -i termios.h && + sh ./hasgot tcgetattr tcsetattr tcsendbreak tcflush tcflow; then + echo "POSIX termios found." + echo "#define HAS_TERMIOS" >> s.h +fi + +# Async I/O under OSF1 3.x are so buggy that the test program hangs... +testasyncio=true +if test -f /usr/bin/uname; then + case "`/usr/bin/uname -s -r`" in + "OSF1 V3."*) testasyncio=false;; + esac +fi +if $testasyncio && sh ./runtest async_io.c; then + echo "Asynchronous I/O are supported." + echo "#define HAS_ASYNC_IO" >> s.h +fi + +has_setitimer=no +if sh ./hasgot setitimer; then + echo "setitimer() found." + echo "#define HAS_SETITIMER" >> s.h + has_setitimer="yes" +fi + +if sh ./hasgot gethostname; then + echo "gethostname() found." + echo "#define HAS_GETHOSTNAME" >> s.h +fi + +if sh ./hasgot -i sys/utsname.h && sh ./hasgot uname; then + echo "uname() found." + echo "#define HAS_UNAME" >> s.h +fi + +has_gettimeofday=no +if sh ./hasgot gettimeofday; then + echo "gettimeofday() found." + echo "#define HAS_GETTIMEOFDAY" >> s.h + has_gettimeofday="yes" +fi + +if sh ./hasgot mktime; then + echo "mktime() found." + echo "#define HAS_MKTIME" >> s.h +fi + +case "$host" in + *-*-cygwin*) ;; # setsid emulation under Cygwin breaks the debugger + *) if sh ./hasgot setsid; then + echo "setsid() found." + echo "#define HAS_SETSID" >> s.h + fi;; +esac + +if sh ./hasgot putenv; then + echo "putenv() found." + echo "#define HAS_PUTENV" >> s.h +fi + +if sh ./hasgot -i locale.h && sh ./hasgot setlocale; then + echo "setlocale() and <locale.h> found." + echo "#define HAS_LOCALE" >> s.h +fi + +if sh ./hasgot -i mach-o/dyld.h && sh ./hasgot NSLinkModule; then + echo "NSLinkModule() found. Using darwin dynamic loading." + echo "#define HAS_NSLINKMODULE" >> s.h +elif sh ./hasgot $dllib dlopen; then + echo "dlopen() found." +elif sh ./hasgot $dllib -ldl dlopen; then + echo "dlopen() found in -ldl." + dllib="$dllib -ldl" +else + shared_libraries_supported=no +fi + +if $shared_libraries_supported; then + echo "Dynamic loading of shared libraries is supported." + echo "#define SUPPORT_DYNAMIC_LINKING" >> s.h + if $dl_needs_underscore; then + echo '#define DL_NEEDS_UNDERSCORE' >>s.h + fi +fi + +if sh ./hasgot -i sys/types.h -i sys/mman.h && sh ./hasgot mmap munmap; then + echo "mmap() found." + echo "#define HAS_MMAP" >> s.h +fi + +nargs=none +for i in 5 6; do + if sh ./trycompile -DNUM_ARGS=${i} gethostbyname.c; then nargs=$i; break; fi +done +if test $nargs != "none"; then + echo "gethostbyname_r() found (with ${nargs} arguments)." + echo "#define HAS_GETHOSTBYNAME_R $nargs" >> s.h +fi + +nargs=none +for i in 7 8; do + if sh ./trycompile -DNUM_ARGS=${i} gethostbyaddr.c; then nargs=$i; break; fi +done +if test $nargs != "none"; then + echo "gethostbyaddr_r() found (with ${nargs} arguments)." + echo "#define HAS_GETHOSTBYADDR_R $nargs" >> s.h +fi + +# Determine if the debugger is supported + +if test "$has_sockets" = "yes"; then + echo "Replay debugger supported." + debugger="ocamldebugger" +else + echo "No replay debugger (missing system calls)" + debugger="" +fi + + +# Determine if system stack overflows can be detected + +case "$arch,$system" in + i386,linux_elf) + echo "System stack overflow can be detected." + echo "#define HAS_STACK_OVERFLOW_DETECTION" >> s.h;; + *) + echo "Cannot detect system stack overflow.";; +esac + +# Determine the target architecture for the "num" library + +case "$host" in + alpha*-*-*) bng_arch=alpha; bng_asm_level=1;; + i[3456]86-*-*) bng_arch=ia32 + if sh ./trycompile ia32sse2.c + then bng_asm_level=2 + else bng_asm_level=1 + fi;; + mips-*-*) bng_arch=mips; bng_asm_level=1;; + powerpc-*-*) bng_arch=ppc; bng_asm_level=1;; + sparc*-*-*) bng_arch=sparc; bng_asm_level=1;; + x86_64-*-*) bng_arch=amd64; bng_asm_level=1;; + *) bng_arch=generic; bng_asm_level=0;; +esac + +echo "BNG_ARCH=$bng_arch" >> Makefile +echo "BNG_ASM_LEVEL=$bng_asm_level" >> Makefile + +# Determine if the POSIX threads library is supported + +if test "$pthread_wanted" = "yes"; then + case "$host" in + *-*-solaris*) pthread_link="-lpthread -lposix4";; + *-*-freebsd*) pthread_link="-pthread";; + *-*-openbsd*) pthread_link="-pthread";; + *) pthread_link="-lpthread";; + esac + if ./hasgot -i pthread.h $pthread_link pthread_self; then + echo "POSIX threads library supported." + otherlibraries="$otherlibraries systhreads" + bytecccompopts="$bytecccompopts -D_REENTRANT" + nativecccompopts="$nativecccompopts -D_REENTRANT" + case "$host" in + *-*-freebsd*) + bytecccompopts="$bytecccompopts -D_THREAD_SAFE" + nativecccompopts="$nativecccompopts -D_THREAD_SAFE";; + *-*-openbsd*) + bytecccompopts="$bytecccompopts -pthread" + asppflags="$asppflags -pthread" + nativecccompopts="$nativecccompopts -pthread";; + esac + echo "Options for linking with POSIX threads: $pthread_link" + echo "PTHREAD_LINK=$pthread_link" >> Makefile + if sh ./hasgot $pthread_link sigwait; then + echo "sigwait() found" + echo "#define HAS_SIGWAIT" >> s.h + fi + else + echo "POSIX threads not found." + pthread_link="" + fi +fi + +# Determine if the bytecode thread library is supported + +if test "$has_select" = "yes" \ +&& test "$has_setitimer" = "yes" \ +&& test "$has_gettimeofday" = "yes" \ +&& test "$has_wait" = "yes"; then + echo "Bytecode threads library supported." + otherlibraries="$otherlibraries threads" +else + echo "Bytecode threads library not supported (missing system calls)" +fi + +# Determine the location of X include files and libraries + +x11_include="not found" +x11_link="not found" + +for dir in \ + $x11_include_dir \ + ; \ +do + if test -f $dir/X11/X.h; then + x11_include=$dir + break + fi +done + +if test "$x11_include" = "not found"; then + x11_try_lib_dir='' +else + x11_try_lib_dir=`echo $x11_include | sed -e 's|include|lib|'` +fi + +for dir in \ + $x11_lib_dir \ + $x11_try_lib_dir \ + ; \ +do + if test -f $dir/libX11.a || \ + test -f $dir/libX11.so || \ + test -f $dir/libX11.dll.a || \ + test -f $dir/libX11.sa; then + if test $dir = /usr/lib; then + x11_link="-lX11" + else + x11_link="-L$dir -lX11" + x11_libs="-L$dir" + fi + break + fi +done + + +if test "$x11_include" = "not found" || test "$x11_link" = "not found" +then + echo "X11 not found, the \"graph\" library will not be supported." + x11_include="" +else + echo "Location of X11 include files: $x11_include/X11" + echo "Options for linking with X11: $x11_link" + otherlibraries="$otherlibraries graph" + if test "$x11_include" = "/usr/include"; then + x11_include="" + else + x11_include="-I$x11_include" + fi + echo "X11_INCLUDES=$x11_include" >> Makefile + echo "X11_LINK=$x11_link" >> Makefile +fi + +# See if we can compile the dbm library + +dbm_include="not found" +dbm_link="not found" +use_gdbm_ndbm=no + +for dir in ; do + if test -f $dir/ndbm.h; then + dbm_include=$dir + if sh ./hasgot dbm_open; then + dbm_link="" + elif sh ./hasgot -lndbm dbm_open; then + dbm_link="-lndbm" + elif sh ./hasgot -ldb1 dbm_open; then + dbm_link="-ldb1" + elif sh ./hasgot -lgdbm dbm_open; then + dbm_link="-lgdbm" + elif sh ./hasgot -lgdbm_compat -lgdbm dbm_open; then + dbm_link="-lgdbm_compat -lgdbm" + fi + break + fi + if test -f $dir/gdbm-ndbm.h; then + dbm_include=$dir + use_gdbm_ndbm=yes + if sh ./hasgot -lgdbm_compat -lgdbm dbm_open; then + dbm_link="-lgdbm_compat -lgdbm" + fi + break + fi +done +if test "$dbm_include" = "not found" || test "$dbm_link" = "not found"; then + echo "NDBM not found, the \"dbm\" library will not be supported." +else + echo "NDBM found (in $dbm_include)" + if test "$dbm_include" = "/usr/include"; then + dbm_include="" + else + dbm_include="-I$dbm_include" + fi + echo "DBM_INCLUDES=$dbm_include" >> Makefile + echo "DBM_LINK=$dbm_link" >> Makefile + if test "$use_gdbm_ndbm" = "yes"; then + echo "#define DBM_USES_GDBM_NDBM" >> s.h + fi + otherlibraries="$otherlibraries dbm" +fi + +# Look for tcl/tk + +echo "Configuring LablTk..." + +if test $tk_wanted = no; then + has_tk=false +elif test $tk_x11 = no; then + has_tk=true +elif test "$x11_include" = "not found" || test "$x11_link" = "not found"; then + echo "X11 not found." + has_tk=false +else + tk_x11_include="$x11_include" + tk_x11_libs="$x11_libs -lX11" + has_tk=true +fi + +if test $has_tk = true; then + tcl_version='' + tcl_version=`sh ./runtest $tk_defs $tk_x11_include tclversion.c` + if test -z "$tcl_version" && test -z "$tk_defs"; then + tk_defs=-I/usr/local/include + tcl_version=`sh ./runtest $tk_defs $tk_x11_include tclversion.c` + fi + if test -z "$tcl_version"; then + tk_defs="-I/usr/local/include/tcl8.2 -I/usr/local/include/tk8.2" + tcl_version=`sh ./runtest $tk_defs $tk_x11_include tclversion.c` + fi + if test -z "$tcl_version"; then + tk_defs="-I/usr/local/include/tcl8.3 -I/usr/local/include/tk8.3" + tcl_version=`sh ./runtest $tk_defs $tk_x11_include tclversion.c` + fi + if test -z "$tcl_version"; then + tk_defs="-I/usr/local/include/tcl8.4 -I/usr/local/include/tk8.4" + tcl_version=`sh ./runtest $tk_defs $tk_x11_include tclversion.c` + fi + if test -z "$tcl_version"; then + tk_defs="-I/usr/include/tcl8.2 -I/usr/include/tk8.2" + tcl_version=`sh ./runtest $tk_defs $tk_x11_include tclversion.c` + fi + if test -z "$tcl_version"; then + tk_defs="-I/usr/include/tcl8.3 -I/usr/include/tk8.3" + tcl_version=`sh ./runtest $tk_defs $tk_x11_include tclversion.c` + fi + if test -z "$tcl_version"; then + tk_defs="-I/usr/include/tcl8.4 -I/usr/include/tk8.4" + tcl_version=`sh ./runtest $tk_defs $tk_x11_include tclversion.c` + fi + if test -z "$tcl_version"; then + tk_defs="-I/sw/include" + tcl_version=`sh ./runtest $tk_defs $tk_x11_include tclversion.c` + fi + if test -n "$tcl_version"; then + echo "tcl.h version $tcl_version found with \"$tk_defs\"." + case $tcl_version in + 7.5) tclmaj=7 tclmin=5 tkmaj=4 tkmin=1 ;; + 7.6) tclmaj=7 tclmin=6 tkmaj=4 tkmin=2 ;; + 8.0) tclmaj=8 tclmin=0 tkmaj=8 tkmin=0 ;; + 8.1) tclmaj=8 tclmin=1 tkmaj=8 tkmin=1 ;; + 8.2) tclmaj=8 tclmin=2 tkmaj=8 tkmin=2 ;; + 8.3) tclmaj=8 tclmin=3 tkmaj=8 tkmin=3 ;; + 8.4) tclmaj=8 tclmin=4 tkmaj=8 tkmin=4 ;; + *) echo "This version is not known."; has_tk=false ;; + esac + else + echo "tcl.h not found." + has_tk=false + fi +fi + +if test $has_tk = true; then + if sh ./hasgot $tk_x11_include $tk_defs -i tk.h; then + echo "tk.h found." + else + echo "tk.h not found." + has_tk=false + fi +fi + +tkauxlibs="$mathlib $dllib" +tcllib='' +tklib='' +if test $has_tk = true; then + if sh ./hasgot $tk_libs $tk_x11_libs $tkauxlibs Tcl_DoOneEvent + then tk_libs="$tk_libs $dllib" + elif sh ./hasgot $tk_libs -ltcl$tclmaj.$tclmin $tkauxlibs Tcl_DoOneEvent + then + tk_libs="$tk_libs -ltk$tkmaj.$tkmin -ltcl$tclmaj.$tclmin $dllib" + elif sh ./hasgot $tk_libs -ltcl$tclmaj$tclmin $tkauxlibs Tcl_DoOneEvent + then + tk_libs="$tk_libs -ltk$tkmaj$tkmin -ltcl$tclmaj$tclmin $dllib" + elif test -z "$tk_libs" && tk_libs=-L/usr/local/lib && \ + sh ./hasgot $tk_libs -ltcl$tclmaj.$tclmin $tkauxlibs Tcl_DoOneEvent + then + tk_libs="$tk_libs -ltk$tkmaj.$tkmin -ltcl$tclmaj.$tclmin $dllib" + elif sh ./hasgot $tk_libs -ltcl$tclmaj$tclmin $tkauxlibs Tcl_DoOneEvent + then + tk_libs="$tk_libs -ltk$tkmaj$tkmin -ltcl$tclmaj$tclmin $dllib" +# elif sh ./hasgot $tk_libs -ltcl $tkauxlibs Tcl_DoOneEvent; then +# tk_libs="$tk_libs -ltk -ltcl" + elif sh ./hasgot -L/sw/lib $tk_libs -ltcl$tclmaj.$tclmin $tkauxlibs \ + Tcl_DoOneEvent + then tk_libs="-L/sw/lib -ltk$tkmaj.$tkmin -ltcl$tclmaj.$tclmin $dllib" + else + echo "Tcl library not found." + has_tk=false + fi +fi +if test $has_tk = true; then + if sh ./hasgot $tk_libs $tk_x11_libs $tkauxlibs Tk_SetGrid; then + echo "Tcl/Tk libraries found." + elif sh ./hasgot -L/sw/lib $tk_libs $tk_x11_libs $tkauxlibs Tk_SetGrid; then + tk_libs="-L/sw/lib $tk_libs" + echo "Tcl/Tk libraries found." + else + echo "Tcl library found." + echo "Tk library not found." + has_tk=false + fi +fi + +if test $has_tk = true; then + if test $tk_x11 = yes; then + echo "TK_DEFS=$tk_defs "'$(X11_INCLUDES)' >> Makefile + echo "TK_LINK=$tk_libs "'$(X11_LINK)' >> Makefile + else + echo "TK_DEFS=$tk_defs" >> Makefile + echo "TK_LINK=$tk_libs" >> Makefile + fi + otherlibraries="$otherlibraries labltk" +else + echo "Configuration failed, LablTk will not be built." +fi + +# Camlp4 + +( +cd ../../camlp4/config +EXE=$exe ./configure_batch -bindir "$bindir" -libdir "$libdir" -mandir "$mandir" -ocaml-top ../.. > /dev/null +) + +# Final twiddling of compiler options to work around known bugs + +nativeccprofopts="$nativecccompopts" +case "$buggycc" in + gcc.2.96) + bytecccompopts="$bytecccompopts -fomit-frame-pointer" + nativecccompopts="$nativecccompopts -fomit-frame-pointer";; +esac + +# Finish generated files + +cclibs="$cclibs $mathlib" + +echo "BYTECC=$bytecc" >> Makefile +echo "BYTECCCOMPOPTS=$bytecccompopts" >> Makefile +echo "BYTECCLINKOPTS=$bytecclinkopts" >> Makefile +echo "BYTECCLIBS=$cclibs $dllib $curseslibs $pthread_link" >> Makefile +echo "BYTECCRPATH=$byteccrpath" >> Makefile +echo "EXE=$exe" >> Makefile +echo "SUPPORTS_SHARED_LIBRARIES=$shared_libraries_supported" >> Makefile +echo "SHAREDCCCOMPOPTS=$sharedcccompopts" >> Makefile +echo "MKSHAREDLIB=$mksharedlib" >> Makefile +echo "MKSHAREDLIBRPATH=$mksharedlibrpath" >> Makefile +echo "ARCH=$arch" >> Makefile +echo "MODEL=$model" >> Makefile +echo "SYSTEM=$system" >> Makefile +echo "NATIVECC=$nativecc" >> Makefile +echo "NATIVECCCOMPOPTS=$nativecccompopts" >> Makefile +echo "NATIVECCPROFOPTS=$nativeccprofopts" >> Makefile +echo "NATIVECCLINKOPTS=$nativecclinkopts" >> Makefile +echo "NATIVECCRPATH=$nativeccrpath" >> Makefile +echo "NATIVECCLIBS=$cclibs $dllib" >> Makefile +echo "ASFLAGS=$asflags" >> Makefile +echo "ASPP=$aspp" >> Makefile +echo "ASPPFLAGS=$asppflags" >> Makefile +echo "ASPPPROFFLAGS=$asppprofflags" >> Makefile +echo "PROFILING=$profiling" >> Makefile +echo "BINUTILS_OBJCOPY=$binutils_objcopy" >> Makefile +echo "BINUTILS_NM=$binutils_nm" >> Makefile +echo "DYNLINKOPTS=$dllib" >> Makefile +echo "OTHERLIBRARIES=$otherlibraries" >> Makefile +echo "DEBUGGER=$debugger" >> Makefile +echo "CC_PROFILE=$cc_profile" >> Makefile + +rm -f tst hasgot.c +rm -f ../m.h ../s.h ../Makefile +mv m.h s.h Makefile .. + +# Print a summary + +echo +echo "** Configuration summary **" +echo +echo "Directories where Objective Caml will be installed:" +echo " binaries.................. $bindir" +echo " standard library.......... $libdir" +echo " manual pages.............. $mandir (with extension .$manext)" + +echo "Configuration for the bytecode compiler:" +echo " C compiler used........... $bytecc" +echo " options for compiling..... $bytecccompopts" +echo " options for linking....... $bytecclinkopts $cclibs $dllib $curseslibs $pthread_link" +if $shared_libraries_supported; then +echo " shared libraries are supported" +echo " options for compiling..... $sharedcccompopts $bytecccompopts" +echo " command for building...... $mksharedlib lib.so $mksharedlibrpath/a/path objs" +else +echo " shared libraries not supported" +fi + +echo "Configuration for the native-code compiler:" +if test "$arch" = "none"; then + echo " (not supported on this platform)" +else + if test "$model" = "default"; then + echo " hardware architecture..... $arch" + else + echo " hardware architecture..... $arch ($model)" + fi + if test "$system" = "unknown"; then : ; else + echo " OS variant................ $system" + fi + echo " C compiler used........... $nativecc" + echo " options for compiling..... $nativecccompopts" + echo " options for linking....... $nativecclinkopts $cclibs" + echo " assembler ................ \$(AS) $asflags" + echo " preprocessed assembler ... $aspp $asppflags" + if test "$profiling" = "prof"; then + echo " profiling with gprof ..... supported" + else + echo " profiling with gprof ..... not supported" + fi + if test -n "$binutils_objcopy" && test -n "$binutils_nm"; then + echo " ocamlopt -pack ........... supported" + else + echo " ocamlopt -pack ........... not supported (no binutils)" + fi +fi + +if test "$debugger" = "ocamldebugger"; then + echo "Source-level replay debugger: supported" +else + echo "Source-level replay debugger: not supported" +fi + +echo "Additional libraries supported:" +echo " $otherlibraries" + +echo "Configuration for the \"num\" library:" +echo " target architecture ...... $bng_arch (asm level $bng_asm_level)" + +if test "$x11_include" != "not found" && test "$x11_lib" != "not found"; then +echo "Configuration for the \"graph\" library:" +echo " options for compiling .... $x11_include" +echo " options for linking ...... $x11_link" +fi + +if test $has_tk = true; then +echo "Configuration for the \"labltk\" library:" +echo " use tcl/tk version ....... $tcl_version" +echo " options for compiling .... $tk_defs" +echo " options for linking ...... $tk_libs" +else +echo "The \"labltk\" library: not found" +fi diff --git a/nixpkgs/pkgs/development/compilers/ocaml/fix-clang-build-on-osx.diff b/nixpkgs/pkgs/development/compilers/ocaml/fix-clang-build-on-osx.diff new file mode 100644 index 000000000000..d7d9c863858f --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/ocaml/fix-clang-build-on-osx.diff @@ -0,0 +1,20 @@ +diff --git a/configure b/configure +index d45e88f..25d872b 100755 +--- a/configure ++++ b/configure +@@ -322,7 +322,14 @@ case "$bytecc,$target" in + bytecccompopts="-fno-defer-pop $gcc_warnings -DSHRINKED_GNUC" + mathlib="";; + *,*-*-darwin*) +- bytecccompopts="-fno-defer-pop $gcc_warnings" ++ # On recent version of OSX, gcc is a symlink to clang ++ if $bytecc --version | grep -q clang; then ++ # -fno-defer-pop is not supported by clang, and make recent ++ # versions of clang to fail ++ bytecccompopts="$gcc_warnings" ++ else ++ bytecccompopts="-fno-defer-pop $gcc_warnings" ++ fi + mathlib="" + mkexe="$mkexe -Wl,-no_compact_unwind" + # Tell gcc that we can use 32-bit code addresses for threaded code diff --git a/nixpkgs/pkgs/development/compilers/ocaml/generic.nix b/nixpkgs/pkgs/development/compilers/ocaml/generic.nix new file mode 100644 index 000000000000..0085739147bf --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/ocaml/generic.nix @@ -0,0 +1,102 @@ +{ minor_version, major_version, patch_version +, url ? null +, sha256, ...}@args: +let + versionNoPatch = "${toString major_version}.${toString minor_version}"; + version = "${versionNoPatch}.${toString patch_version}"; + real_url = if url == null then + "http://caml.inria.fr/pub/distrib/ocaml-${versionNoPatch}/ocaml-${version}.tar.xz" + else url; + safeX11 = stdenv: !(stdenv.isAarch32 || stdenv.isMips); +in + +{ stdenv, fetchurl, ncurses, buildEnv +, libX11, xorgproto, useX11 ? safeX11 stdenv +, flambdaSupport ? false +}: + +assert useX11 -> !stdenv.isAarch32 && !stdenv.isMips; +assert flambdaSupport -> stdenv.lib.versionAtLeast version "4.03"; + +let + useNativeCompilers = !stdenv.isMips; + inherit (stdenv.lib) optional optionals optionalString; + name = "ocaml${optionalString flambdaSupport "+flambda"}-${version}"; +in + +let + x11env = buildEnv { name = "x11env"; paths = [libX11 xorgproto]; }; + x11lib = x11env + "/lib"; + x11inc = x11env + "/include"; +in + +stdenv.mkDerivation (args // rec { + + inherit name; + inherit version; + + src = fetchurl { + url = real_url; + inherit sha256; + }; + + prefixKey = "-prefix "; + configureFlags = optionals useX11 ( + if stdenv.lib.versionAtLeast version "4.08" + then [ "--x-libraries=${x11lib}" "--x-includes=${x11inc}"] + else [ "-x11lib" x11lib "-x11include" x11inc ]) + ++ optional flambdaSupport "-flambda" + ; + + buildFlags = "world" + optionalString useNativeCompilers " bootstrap world.opt"; + buildInputs = optional (!stdenv.lib.versionAtLeast version "4.07") ncurses + ++ optionals useX11 [ libX11 xorgproto ]; + installTargets = "install" + optionalString useNativeCompilers " installopt"; + preConfigure = optionalString (!stdenv.lib.versionAtLeast version "4.04") '' + CAT=$(type -tp cat) + sed -e "s@/bin/cat@$CAT@" -i config/auto-aux/sharpbang + ''; + postBuild = '' + mkdir -p $out/include + ln -sv $out/lib/ocaml/caml $out/include/caml + ''; + + passthru = { + nativeCompilers = useNativeCompilers; + }; + + meta = with stdenv.lib; { + homepage = http://caml.inria.fr/ocaml; + branch = versionNoPatch; + license = with licenses; [ + qpl /* compiler */ + lgpl2 /* library */ + ]; + description = "Most popular variant of the Caml language"; + + longDescription = + '' + OCaml is the most popular variant of the Caml language. From a + language standpoint, it extends the core Caml language with a + fully-fledged object-oriented layer, as well as a powerful module + system, all connected by a sound, polymorphic type system featuring + type inference. + + The OCaml system is an industrial-strength implementation of this + language, featuring a high-performance native-code compiler (ocamlopt) + for 9 processor architectures (IA32, PowerPC, AMD64, Alpha, Sparc, + Mips, IA64, HPPA, StrongArm), as well as a bytecode compiler (ocamlc) + and an interactive read-eval-print loop (ocaml) for quick development + and portability. The OCaml distribution includes a comprehensive + standard library, a replay debugger (ocamldebug), lexer (ocamllex) and + parser (ocamlyacc) generators, a pre-processor pretty-printer (camlp4) + and a documentation generator (ocamldoc). + ''; + + platforms = with platforms; linux ++ darwin; + broken = stdenv.isAarch64 && !stdenv.lib.versionAtLeast version "4.06"; + }; + +}) + + diff --git a/nixpkgs/pkgs/development/compilers/ocaml/gnused-on-osx-fix.patch b/nixpkgs/pkgs/development/compilers/ocaml/gnused-on-osx-fix.patch new file mode 100644 index 000000000000..dc2bcb869766 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/ocaml/gnused-on-osx-fix.patch @@ -0,0 +1,9 @@ +diff -Nuar ocaml-3.11.1/ocamldoc/remove_DEBUG ocaml-3.11.1-nixpkgs/ocamldoc/remove_DEBUG +--- ocaml-3.11.1/ocamldoc/remove_DEBUG 2004-04-15 18:18:52.000000000 +0200 ++++ ocaml-3.11.1-nixpkgs/ocamldoc/remove_DEBUG 2011-01-01 17:37:07.000000000 +0100 +@@ -18,4 +18,4 @@ + # respecting the cpp # line annotation conventions + + echo "# 1 \"$1\"" +-LC_ALL=C sed -e '/DEBUG/s/.*//' "$1" ++grep -v 'DEBUG' "$1" diff --git a/nixpkgs/pkgs/development/compilers/ocaml/metaocaml-3.09.nix b/nixpkgs/pkgs/development/compilers/ocaml/metaocaml-3.09.nix new file mode 100644 index 000000000000..e9adbeff4904 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/ocaml/metaocaml-3.09.nix @@ -0,0 +1,34 @@ +{ stdenv, fetchurl, xlibsWrapper, ncurses }: + +stdenv.mkDerivation (rec { + + name = "metaocaml-${version}"; + version = "3.09-alpha-30"; + + src = fetchurl { + url = "http://www.metaocaml.org/dist/old/MetaOCaml_309_alpha_030.tar.gz"; + sha256 = "0migbn0zwfb7yb24dy7qfqi19sv3drqcv4369xi7xzpds2cs35fd"; + }; + + prefixKey = "-prefix "; + configureFlags = ["-no-tk" "-x11lib" xlibsWrapper]; + buildFlags = "world bootstrap world.opt"; + buildInputs = [xlibsWrapper ncurses]; + installTargets = "install installopt"; + patchPhase = '' + CAT=$(type -tp cat) + sed -e "s@/bin/cat@$CAT@" -i config/auto-aux/sharpbang + ''; + postBuild = '' + mkdir -p $out/include + ln -sv $out/lib/ocaml/caml $out/include/caml + ''; + + meta = { + homepage = http://www.metaocaml.org/; + license = with stdenv.lib.licenses; [ qpl lgpl2 ]; + description = "A compiled, type-safe, multi-stage programming language"; + broken = true; + }; + +}) diff --git a/nixpkgs/pkgs/development/compilers/ocaml/mips64.patch b/nixpkgs/pkgs/development/compilers/ocaml/mips64.patch new file mode 100644 index 000000000000..cdef9cafb932 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/ocaml/mips64.patch @@ -0,0 +1,240 @@ +http://caml.inria.fr/mantis/view.php?id=4849 + +diff -bur ocaml-3.11.1/asmcomp/mips/arch.ml my_ocaml/asmcomp/mips/arch.ml +--- asmcomp/mips/arch.ml 2002-11-29 16:03:36.000000000 +0100 ++++ asmcomp/mips/arch.ml 2009-08-09 23:18:31.000000000 +0200 +@@ -35,7 +35,7 @@ + + let big_endian = + match Config.system with +- "ultrix" -> false ++ "ultrix" | "gnu" -> false + | "irix" -> true + | _ -> fatal_error "Arch_mips.big_endian" + +diff -bur ocaml-3.11.1/asmcomp/mips/emit.mlp my_ocaml/asmcomp/mips/emit.mlp +--- asmcomp/mips/emit.mlp 2004-01-05 21:25:56.000000000 +0100 ++++ asmcomp/mips/emit.mlp 2009-08-23 12:11:58.000000000 +0200 +@@ -58,7 +58,7 @@ + !stack_offset + + 4 * num_stack_slots.(0) + 8 * num_stack_slots.(1) + + (if !contains_calls then if !uses_gp then 8 else 4 else 0) in +- Misc.align size 16 ++ Misc.align size 16 (* n32 require quadword alignment *) + + let slot_offset loc cl = + match loc with +@@ -252,7 +252,7 @@ + | Lop(Icall_ind) -> + ` move $25, {emit_reg i.arg.(0)}\n`; + liveregs i live_25; +- ` jal {emit_reg i.arg.(0)}\n`; ++ ` jal $25\n`; (* {emit_reg i.arg.(0)}\n; Equivalent but avoids "Warning: MIPS PIC call to register other than $25" on GNU as *) + `{record_frame i.live}\n` + | Lop(Icall_imm s) -> + liveregs i 0; +@@ -269,7 +269,7 @@ + liveregs i 0; + ` move $25, {emit_reg i.arg.(0)}\n`; + liveregs i live_25; +- ` j {emit_reg i.arg.(0)}\n` ++ ` j $25\n` + | Lop(Itailcall_imm s) -> + if s = !function_name then begin + ` b {emit_label !tailrec_entry_point}\n` +@@ -277,11 +277,11 @@ + let n = frame_size() in + if !contains_calls then + ` lw $31, {emit_int(n - 4)}($sp)\n`; ++ ` la $25, {emit_symbol s}\n`; (* Rxd: put before gp restore *) + if !uses_gp then + ` lw $gp, {emit_int(n - 8)}($sp)\n`; + if n > 0 then + ` addu $sp, $sp, {emit_int n}\n`; +- ` la $25, {emit_symbol s}\n`; + liveregs i live_25; + ` j $25\n` + end +@@ -305,8 +305,13 @@ + begin match chunk with + Double_u -> + (* Destination is not 8-aligned, hence cannot use l.d *) ++ if big_endian then begin + ` ldl $24, {emit_addressing addr i.arg 0}\n`; +- ` ldr $24, {emit_addressing (offset_addressing addr 7) i.arg 0}\n`; ++ ` ldr $24, {emit_addressing (offset_addressing addr 7) i.arg 0}\n` ++ end else begin ++ ` ldl $24, {emit_addressing (offset_addressing addr 7) i.arg 0}\n`; ++ ` ldr $24, {emit_addressing addr i.arg 0}\n` ++ end; + ` dmtc1 $24, {emit_reg dest}\n` + | Single -> + ` l.s {emit_reg dest}, {emit_addressing addr i.arg 0}\n`; +@@ -328,8 +333,13 @@ + Double_u -> + (* Destination is not 8-aligned, hence cannot use l.d *) + ` dmfc1 $24, {emit_reg src}\n`; ++ if big_endian then begin + ` sdl $24, {emit_addressing addr i.arg 1}\n`; + ` sdr $24, {emit_addressing (offset_addressing addr 7) i.arg 1}\n` ++ end else begin ++ ` sdl $24, {emit_addressing (offset_addressing addr 7) i.arg 1}\n`; ++ ` sdr $24, {emit_addressing addr i.arg 1}\n` ++ end + | Single -> + ` cvt.s.d $f31, {emit_reg src}\n`; + ` s.s $f31, {emit_addressing addr i.arg 1}\n` +@@ -552,6 +562,7 @@ + (* There are really two groups of registers: + $sp and $30 always point to stack locations + $2 - $21 never point to stack locations. *) ++ if Config.system = "irix" then begin + ` .noalias $2,$sp; .noalias $2,$30; .noalias $3,$sp; .noalias $3,$30\n`; + ` .noalias $4,$sp; .noalias $4,$30; .noalias $5,$sp; .noalias $5,$30\n`; + ` .noalias $6,$sp; .noalias $6,$30; .noalias $7,$sp; .noalias $7,$30\n`; +@@ -561,7 +572,8 @@ + ` .noalias $14,$sp; .noalias $14,$30; .noalias $15,$sp; .noalias $15,$30\n`; + ` .noalias $16,$sp; .noalias $16,$30; .noalias $17,$sp; .noalias $17,$30\n`; + ` .noalias $18,$sp; .noalias $18,$30; .noalias $19,$sp; .noalias $19,$30\n`; +- ` .noalias $20,$sp; .noalias $20,$30; .noalias $21,$sp; .noalias $21,$30\n\n`; ++ ` .noalias $20,$sp; .noalias $20,$30; .noalias $21,$sp; .noalias $21,$30\n\n` ++ end; + let lbl_begin = Compilenv.make_symbol (Some "data_begin") in + ` .data\n`; + ` .globl {emit_symbol lbl_begin}\n`; +diff -bur ocaml-3.11.1/asmrun/mips.s my_ocaml/asmrun/mips.s +--- asmrun/mips.s 2004-07-13 14:18:53.000000000 +0200 ++++ asmrun/mips.s 2009-08-20 09:34:36.000000000 +0200 +@@ -187,7 +187,7 @@ + sw $30, caml_exception_pointer + /* Call C function */ + move $25, $24 +- jal $24 ++ jal $25 /* Rxd: $24 replaced by $25 to avoid this "Warning: MIPS PIC call to register other than $25" ? */ + /* Reload return address, alloc ptr, alloc limit */ + lw $31, 0($16) /* caml_last_return_address */ + lw $22, 0($17) /* caml_young_ptr */ +@@ -254,7 +254,7 @@ + sw $0, caml_last_return_address + /* Call the Caml code */ + move $25, $24 +- jal $24 ++ jal $25 /* Rxd: 24 replaced by 25 */ + $104: + /* Pop the trap frame, restoring caml_exception_pointer */ + lw $24, 0($sp) +@@ -384,3 +384,8 @@ + .word $104 /* return address into callback */ + .half -1 /* negative frame size => use callback link */ + .half 0 /* no roots here */ ++ ++#if defined(SYS_linux) ++ /* Mark stack as non-executable, PR#4564 */ ++ .section .note.GNU-stack,"",%progbits ++#endif +diff -bur ocaml-3.11.1/configure my_ocaml/configure +--- configure 2009-05-20 17:33:09.000000000 +0200 ++++ configure 2009-08-23 10:55:44.000000000 +0200 +@@ -40,7 +40,7 @@ + verbose=no + withcurses=yes + withsharedlibs=yes +-gcc_warnings="-Wall" ++gcc_warnings="-W -Wall" + partialld="ld -r" + + # Try to turn internationalization off, can cause config.guess to malfunction! +@@ -292,6 +292,9 @@ + # (For those who want to force "cc -64") + # Turn off warning "unused library" + bytecclinkopts="-Wl,-woff,84";; ++ gcc*,mips64el-*) ++ bytecccompopts="" ++ bytecclinkopts="-fno-defer-pop $gcc_warnings -Wl,-O1 -Wl,--as-needed";; + *,alpha*-*-unicos*) + # For the Cray T3E + bytecccompopts="-DUMK";; +@@ -468,6 +471,8 @@ + echo "64-bit integers must be doubleword-aligned." + echo "#define ARCH_ALIGN_INT64" >> m.h + fi;; ++ mips64el-*) ++ echo "#define ARCH_ALIGN_INT64" >> m.h;; + *) + sh ./runtest int64align.c + case $? in +@@ -636,6 +641,7 @@ + fi;; + i[3456]86-*-gnu*) arch=i386; system=gnu;; + mips-*-irix6*) arch=mips; system=irix;; ++ mips*-gnu*) arch=mips; system=gnu;; + hppa1.1-*-hpux*) arch=hppa; system=hpux;; + hppa2.0*-*-hpux*) arch=hppa; system=hpux;; + hppa*-*-linux*) arch=hppa; system=linux;; +@@ -672,7 +678,7 @@ + if test -z "$ccoption"; then + case "$arch,$system,$cc" in + alpha,digital,gcc*) nativecc=cc;; +- mips,*,gcc*) nativecc=cc;; ++ mips,irix,gcc*) nativecc=cc;; + *) nativecc="$bytecc";; + esac + else +@@ -687,6 +693,9 @@ + alpha,cc*,digital,*) nativecccompopts=-std1;; + mips,cc*,irix,*) nativecccompopts=-n32 + nativecclinkopts="-n32 -Wl,-woff,84";; ++ mips,gcc*,gnu,mips64el-*) ++ nativecccompopts="$gcc_warnings -fPIC" ++ nativecclinkopts="--as-needed";; + *,*,nextstep,*) nativecccompopts="$gcc_warnings -U__GNUC__ -posix" + nativecclinkopts="-posix";; + *,*,rhapsody,*darwin[1-5].*) +@@ -725,6 +734,8 @@ + aspp='gcc -c -Wa,-xexplicit';; + mips,*,irix) as='as -n32 -O2 -nocpp -g0' + aspp='as -n32 -O2';; ++ mips,*,gnu) as='as -KPIC' ++ aspp='gcc -c -fPIC';; # got bus error without fPIC ? + power,*,elf) as='as -u -m ppc' + aspp='gcc -c';; + power,*,bsd) as='as' +@@ -756,6 +767,7 @@ + case "$nativecc" in gcc*) ;; *) cc_profile='-xpg';; esac;; + amd64,*,linux) profiling='prof';; + amd64,*,gnu) profiling='prof';; ++ mips,*,gnu) profiling='prof';; + *) profiling='noprof';; + esac + +diff -bur ocaml-3.11.1/asmcomp/mips/proc.ml my_ocaml/asmcomp/mips/proc.ml +--- asmcomp/mips/proc.ml 2007-10-30 13:37:16.000000000 +0100 ++++ asmcomp/mips/proc.ml 2010-03-18 08:08:06.000000000 +0100 +@@ -114,7 +114,7 @@ + incr int + end else begin + loc.(i) <- stack_slot (make_stack !ofs) ty; +- ofs := !ofs + size_int ++ ofs := !ofs + 8 + end + | Float -> + if !float <= last_float then begin +@@ -143,7 +143,7 @@ + or float regs $f12...$f19. Each argument "consumes" both one slot + in the int register file and one slot in the float register file. + Extra arguments are passed on stack, in a 64-bits slot, right-justified +- (i.e. at +4 from natural address). *) ++ (i.e. at +4 from natural address for big endians). *) + + let loc_external_arguments arg = + let loc = Array.create (Array.length arg) Reg.dummy in +@@ -158,7 +158,7 @@ + end else begin + begin match arg.(i).typ with + Float -> loc.(i) <- stack_slot (Outgoing !ofs) Float +- | ty -> loc.(i) <- stack_slot (Outgoing (!ofs + 4)) ty ++ | ty -> loc.(i) <- stack_slot (Outgoing (!ofs + (if big_endian then 4 else 0))) ty + end; + ofs := !ofs + 8 + end + diff --git a/nixpkgs/pkgs/development/compilers/ocaml/ocamlbuild.patch b/nixpkgs/pkgs/development/compilers/ocaml/ocamlbuild.patch new file mode 100644 index 000000000000..d153fb67d419 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/ocaml/ocamlbuild.patch @@ -0,0 +1,45 @@ +Author: Vincent Laporte <Vincent.Laporte@gmail.com> +Date: Sun Feb 1 11:19:50 2015 +0100 + + ocamlbuild: use ocamlfind to discover camlp4 path + + and default to `+camlp4` + +diff --git a/ocamlbuild/ocaml_specific.ml b/ocamlbuild/ocaml_specific.ml +index b902810..a73b7a5 100644 +--- a/ocamlbuild/ocaml_specific.ml ++++ b/ocamlbuild/ocaml_specific.ml +@@ -698,15 +698,25 @@ ocaml_lib ~extern:true ~tag_name:"use_toplevel" "toplevellib";; + ocaml_lib ~extern:true ~dir:"+ocamldoc" "ocamldoc";; + ocaml_lib ~extern:true ~dir:"+ocamlbuild" ~tag_name:"use_ocamlbuild" "ocamlbuildlib";; + +-ocaml_lib ~extern:true ~dir:"+camlp4" ~tag_name:"use_camlp4" "camlp4lib";; +-ocaml_lib ~extern:true ~dir:"+camlp4" ~tag_name:"use_old_camlp4" "camlp4";; +-ocaml_lib ~extern:true ~dir:"+camlp4" ~tag_name:"use_camlp4_full" "camlp4fulllib";; ++let camlp4dir = ++ Findlib.( ++ try ++ if sys_command "sh -c 'ocamlfind list >/dev/null' 2>/dev/null" != 0 ++ then raise (Findlib_error Cannot_run_ocamlfind); ++ (query "camlp4").location ++ with Findlib_error _ -> ++ "+camlp4" ++ );; ++ ++ocaml_lib ~extern:true ~dir:camlp4dir ~tag_name:"use_camlp4" "camlp4lib";; ++ocaml_lib ~extern:true ~dir:camlp4dir ~tag_name:"use_old_camlp4" "camlp4";; ++ocaml_lib ~extern:true ~dir:camlp4dir ~tag_name:"use_camlp4_full" "camlp4fulllib";; + flag ["ocaml"; "compile"; "use_camlp4_full"] +- (S[A"-I"; A"+camlp4/Camlp4Parsers"; +- A"-I"; A"+camlp4/Camlp4Printers"; +- A"-I"; A"+camlp4/Camlp4Filters"]);; +-flag ["ocaml"; "use_camlp4_bin"; "link"; "byte"] (A"+camlp4/Camlp4Bin.cmo");; +-flag ["ocaml"; "use_camlp4_bin"; "link"; "native"] (A"+camlp4/Camlp4Bin.cmx");; ++ (S[A"-I"; A(camlp4dir^"/Camlp4Parsers"); ++ A"-I"; A(camlp4dir^"/Camlp4Printers"); ++ A"-I"; A(camlp4dir^"/Camlp4Filters")]);; ++flag ["ocaml"; "use_camlp4_bin"; "link"; "byte"] (A(camlp4dir^"/Camlp4Bin.cmo"));; ++flag ["ocaml"; "use_camlp4_bin"; "link"; "native"] (A(camlp4dir^"/Camlp4Bin.cmx"));; + + flag ["ocaml"; "debug"; "compile"; "byte"] (A "-g");; + flag ["ocaml"; "debug"; "link"; "byte"; "program"] (A "-g");; diff --git a/nixpkgs/pkgs/development/compilers/opa/default.nix b/nixpkgs/pkgs/development/compilers/opa/default.nix new file mode 100644 index 000000000000..06ed7c51e9ab --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/opa/default.nix @@ -0,0 +1,75 @@ +{ stdenv, fetchFromGitHub, which, perl, jdk +, ocamlPackages, openssl +, coreutils, zlib, ncurses, makeWrapper +, gcc, binutils, gnumake, nodejs +}: + +stdenv.mkDerivation rec { + pname = "opa"; + version = "4310"; + name = "${pname}-${version}"; + + src = fetchFromGitHub { + owner = "MLstate"; + repo = "opalang"; + rev = "a13d45af30bc955c40c4b320353fb21e4ecacbc5"; + sha256 = "1qs91rq9xrafv2mf2v415k8lv91ab3ycz0xkpjh1mng5ca3pjlf3"; + }; + + # Paths so the opa compiler code generation will use the same programs as were + # used to build opa. + codeGeneratorPaths = stdenv.lib.makeBinPath [ ocamlPackages.ocaml gcc binutils gnumake nodejs ]; + + preConfigure = '' + patchShebangs . + ( + cat ./compiler/buildinfos/buildInfos.ml.pre + ./compiler/buildinfos/generate_buildinfos.sh . --release --version ./compiler/buildinfos/version_major.txt + echo let opa_git_version = ${version} + echo 'let opa_git_sha = "xxxx"' + cat ./compiler/buildinfos/buildInfos.ml.post + )> ./compiler/buildinfos/buildInfos.ml + for p in configure tools/platform_helper.sh + do + substituteInPlace $p --replace 'IS_MAC=1' 'IS_LINUX=1' + done + export CAMLP4O=${ocamlPackages.camlp4}/bin/camlp4o + export CAMLP4ORF=${ocamlPackages.camlp4}/bin/camlp4orf + ''; + + prefixKey = "-prefix "; + + configureFlags = [ "-ocamlfind ${ocamlPackages.findlib}/bin/ocamlfind" ]; + + buildInputs = [ which perl jdk openssl coreutils zlib ncurses + makeWrapper gcc binutils gnumake nodejs + ] ++ (with ocamlPackages; [ + ocaml findlib ssl cryptokit camlzip ulex ocamlgraph camlp4 + ]); + + NIX_LDFLAGS = stdenv.lib.optionalString (!stdenv.isDarwin) "-lgcc_s"; + + postInstall = '' + # Have compiler use same tools for code generation as used to build it. + for p in $out/bin/opa ; do + wrapProgram $p --prefix PATH ":" "${codeGeneratorPaths}" ; + done + + # Install emacs mode. + mkdir -p $out/share/emacs/site-lisp/opa + install -m 0644 -v ./tools/editors/emacs/{opa-mode.el,site-start.el} $out/share/emacs/site-lisp/opa + ''; + + meta = { + description = "A concise and elegant language for writing distributed web applications"; + longDescription = '' + Opa is a new generation of web development platform that lets you write distributed + web applications using a single technology. Among the the many features of Opa are these: + Opa is concise, simple, concurrent, dynamically distributed, and secure. + ''; + homepage = http://opalang.org/; + license = stdenv.lib.licenses.gpl3; + maintainers = [ stdenv.lib.maintainers.kkallio ]; + platforms = with stdenv.lib.platforms; unix; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/opendylan/bin.nix b/nixpkgs/pkgs/development/compilers/opendylan/bin.nix new file mode 100644 index 000000000000..e11bb7251a60 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/opendylan/bin.nix @@ -0,0 +1,42 @@ +# Binaries provided by Open Dylan to be used to bootstrap from source. +# The binaries can also be used as is. +{stdenv, fetchurl, patchelf, boehmgc, gnused, gcc, makeWrapper}: + +stdenv.mkDerivation { + name = "opendylan-2013.2"; + + src = if stdenv.hostPlatform.system == "x86_64-linux" then fetchurl { + url = https://opendylan.org/downloads/opendylan/2013.2/opendylan-2013.2-x86_64-linux.tar.bz2; + sha256 = "035brbw3hm7zrs593q4zc42yglj1gmmkw3b1r7zzlw3ks4i2lg7h"; + } + else if stdenv.hostPlatform.system == "i686-linux" then fetchurl { + url = https://opendylan.org/downloads/opendylan/2013.2/opendylan-2013.2-x86-linux.tar.bz2; + sha256 = "0c61ihvblcsjrw6ncr8x8ylhskcrqs8pajs4mg5di36cvqw12nq5"; + } + else throw "platform ${stdenv.hostPlatform.system} not supported."; + + nativeBuildInputs = [ patchelf boehmgc gnused makeWrapper ]; + + buildCommand = '' + mkdir -p "$out" + tar --strip-components=1 -xjf "$src" -C "$out" + + interpreter="$(cat "$NIX_CC"/nix-support/dynamic-linker)" + for a in "$out"/bin/*; do + patchelf --set-interpreter "$interpreter" "$a" + patchelf --set-rpath "$out/lib:${boehmgc.out}/lib" "$a" + done + for a in "$out"/lib/*.so; do + patchelf --set-rpath "$out/lib:${boehmgc.out}/lib" "$a" + done + sed -i -e "s|\-lgc|\-L${boehmgc.out}\/lib -lgc|" $out/lib/config.jam + wrapProgram $out/bin/dylan-compiler --suffix PATH : ${gcc}/bin + ''; + + meta = { + homepage = https://opendylan.org; + description = "A multi-paradigm functional and object-oriented programming language"; + license = stdenv.lib.licenses.mit; + platforms = stdenv.lib.platforms.linux; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/opendylan/default.nix b/nixpkgs/pkgs/development/compilers/opendylan/default.nix new file mode 100644 index 000000000000..8e732d7d8bf4 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/opendylan/default.nix @@ -0,0 +1,40 @@ +# Build Open Dylan from source using the binary builds to bootstrap. +{stdenv, fetchgit, boehmgc, mps, gnused, opendylan-bootstrap, autoconf, automake, perl, makeWrapper, gcc }: + +stdenv.mkDerivation { + name = "opendylan-2016.1pre"; + + src = fetchgit { + url = https://github.com/dylan-lang/opendylan; + rev = "cd9a8395586d33cc43a8611c1dc0513e69ee82dd"; + sha256 = "00r1dm7mjy5p4hfm13vc4b6qryap40zinia3y15rhvalc3i2np4b"; + fetchSubmodules = true; + }; + + buildInputs = (if stdenv.hostPlatform.system == "i686-linux" then [ mps ] else [ boehmgc ]) ++ [ + opendylan-bootstrap boehmgc gnused autoconf automake perl makeWrapper + ]; + + preConfigure = if stdenv.hostPlatform.system == "i686-linux" then '' + mkdir -p $TMPDIR/mps + tar --strip-components=1 -xf ${mps.src} -C $TMPDIR/mps + ./autogen.sh + '' + else '' + ./autogen.sh + ''; + + configureFlags = [ + (if stdenv.hostPlatform.system == "i686-linux" then "--with-mps=$(TMPDIR)/mps" else "--with-gc=${boehmgc.out}") + ]; + buildPhase = "make 3-stage-bootstrap"; + + postInstall = "wrapProgram $out/bin/dylan-compiler --suffix PATH : ${gcc}/bin"; + + meta = { + homepage = https://opendylan.org; + description = "A multi-paradigm functional and object-oriented programming language"; + license = stdenv.lib.licenses.mit; + platforms = stdenv.lib.platforms.linux; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/openjdk/004_add-fontconfig.patch b/nixpkgs/pkgs/development/compilers/openjdk/004_add-fontconfig.patch new file mode 100644 index 000000000000..8172bc821905 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/openjdk/004_add-fontconfig.patch @@ -0,0 +1,14 @@ +This patch was downloaded from https://aur.archlinux.org/cgit/aur.git/tree/?h=java8-openjdk +More info can be found at http://www.infinality.net/forum/viewtopic.php?f=2&t=275 +diff -ur a/jdk/make/lib/Awt2dLibraries.gmk b/jdk/make/lib/Awt2dLibraries.gmk +--- a/jdk/make/lib/Awt2dLibraries.gmk 2015-07-13 20:50:59.000000000 +0300 ++++ b/jdk/make/lib/Awt2dLibraries.gmk 2015-08-24 12:12:22.930330643 +0300 +@@ -824,7 +824,7 @@ + LDFLAGS := $(subst -Xlinker -z -Xlinker defs,,$(LDFLAGS_JDKLIB)) $(LDFLAGS_CXX_JDK) \ + $(call SET_SHARED_LIBRARY_ORIGIN), \ + LDFLAGS_SUFFIX := $(BUILD_LIBFONTMANAGER_FONTLIB), \ +- LDFLAGS_SUFFIX_linux := -lawt $(LIBM) $(LIBCXX) -ljava -ljvm -lc, \ ++ LDFLAGS_SUFFIX_linux := -lfontconfig -lawt $(LIBM) $(LIBCXX) -ljava -ljvm -lc, \ + LDFLAGS_SUFFIX_solaris := -lawt -lawt_headless -lc $(LIBM) $(LIBCXX) -ljava -ljvm, \ + LDFLAGS_SUFFIX_aix := -lawt -lawt_headless $(LIBM) $(LIBCXX) -ljava -ljvm,\ + LDFLAGS_SUFFIX_macosx := -lawt $(LIBM) $(LIBCXX) -undefined dynamic_lookup \ diff --git a/nixpkgs/pkgs/development/compilers/openjdk/005_enable-infinality.patch b/nixpkgs/pkgs/development/compilers/openjdk/005_enable-infinality.patch new file mode 100644 index 000000000000..f8de96989967 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/openjdk/005_enable-infinality.patch @@ -0,0 +1,261 @@ +This patch was downloaded from https://aur.archlinux.org/cgit/aur.git/tree/?h=java8-openjdk +More info can be found at http://www.infinality.net/forum/viewtopic.php?f=2&t=275 +diff -ur a/jdk/src/share/native/sun/font/freetypeScaler.c b/jdk/src/share/native/sun/font/freetypeScaler.c +--- a/jdk/src/share/native/sun/font/freetypeScaler.c 2014-09-14 16:28:06.108295959 +0200 ++++ b/jdk/src/share/native/sun/font/freetypeScaler.c 2014-09-14 16:28:45.569693174 +0200 +@@ -23,6 +23,9 @@ + * questions. + */ + ++/* Use Infinality patches as default */ ++#define INFINALITY ++ + #include "jni.h" + #include "jni_util.h" + #include "jlong.h" +@@ -38,6 +41,10 @@ + #include FT_SIZES_H + #include FT_OUTLINE_H + #include FT_SYNTHESIS_H ++#ifdef INFINALITY ++#include FT_LCD_FILTER_H ++#include <fontconfig/fontconfig.h> ++#endif + + #include "fontscaler.h" + +@@ -676,6 +683,147 @@ static void CopyFTSubpixelVToSubpixel(co + } + } + ++#ifdef INFINALITY ++typedef struct { ++ FT_Render_Mode ftRenderMode; ++ int ftLoadFlags; ++ FT_LcdFilter ftLcdFilter; ++} RenderingProperties; ++ ++static FcPattern* matchedPattern(const FcChar8* family, double ptSize) { ++ /* ++ we will create pattern to find our family and size in ++ fontconfig configuration, and then will return it's ++ properties: ++ */ ++ FcPattern* fcPattern = 0; ++ fcPattern = FcPatternCreate(); ++ FcValue fcValue; ++ fcValue.type = FcTypeString; ++ fcValue.u.s = family; ++ FcPatternAdd(fcPattern, FC_FAMILY, fcValue, FcTrue); ++ FcPatternAddBool(fcPattern, FC_SCALABLE, FcTrue); ++ FcPatternAddDouble(fcPattern, FC_SIZE, ptSize); ++ // TODO FcPatternAddInteger(pattern, FC_WEIGHT, weight_value); ++ // TODO FcPatternAddInteger(pattern, FC_SLANT, slant_value); ++ // TODO FcPatternAddDouble(pattern, FC_PIXEL_SIZE, size_value); ++ // TODO FcPatternAddInteger(pattern, FC_WIDTH, stretch); 100 in most cases ++ FcConfigSubstitute(0, fcPattern, FcMatchPattern); ++ FcConfigSubstitute(0, fcPattern, FcMatchFont); ++ FcDefaultSubstitute(fcPattern); ++ FcResult res; ++ ++ FcPattern *pattern = 0; ++ pattern = FcFontMatch(0, fcPattern, &res); ++ FcPatternDestroy(fcPattern); ++ return pattern; ++} ++ ++static void readFontconfig(const FcChar8* family, double ptSize, jint aaType, RenderingProperties* rp) { ++ ++ FcPattern *pattern = matchedPattern(family, ptSize); ++ ++ int ftLoadFalgs = FT_LOAD_DEFAULT; ++ FT_Render_Mode ftRenderMode; ++ FT_LcdFilter ftLcdFilter; ++ char horizontal = 1; ++ FcBool b; ++ ++ // subpixel order: ++ if (aaType == TEXT_AA_ON) ++ ftRenderMode = FT_RENDER_MODE_NORMAL; ++ else if (aaType == TEXT_AA_OFF) ++ ftRenderMode = FT_RENDER_MODE_MONO; ++ else if (FcPatternGetBool(pattern, FC_ANTIALIAS, 0, &b) == FcResultMatch) ++ if (b) { ++ int subpixel = FC_RGBA_UNKNOWN; ++ FcPatternGetInteger(pattern, FC_RGBA, 0, &subpixel); ++ if (subpixel == FC_RGBA_UNKNOWN) ++ subpixel = FC_RGBA_NONE; ++ switch (subpixel) { ++ case FC_RGBA_NONE: ++ ftRenderMode = FT_RENDER_MODE_NORMAL; ++ break; ++ case FC_RGBA_RGB: ++ case FC_RGBA_BGR: ++ ftRenderMode = FT_RENDER_MODE_LCD; ++ horizontal = 1; ++ break; ++ case FC_RGBA_VRGB: ++ case FC_RGBA_VBGR: ++ ftRenderMode = FT_RENDER_MODE_LCD_V; ++ horizontal = 0; ++ break; ++ default: ++ break; ++ } ++ } else { ++ ftRenderMode = FT_RENDER_MODE_NORMAL; ++ } ++ ++ // loading mode: ++ if (aaType == TEXT_AA_OFF) ++ ftLoadFalgs |= FT_LOAD_TARGET_MONO; ++ else { ++ int hint_style = FC_HINT_NONE; ++ FcPatternGetInteger(pattern, FC_HINT_STYLE, 0, &hint_style); ++ switch (hint_style) { ++ case FC_HINT_NONE: ++ ftLoadFalgs |= FT_LOAD_NO_HINTING; ++ break; ++ case FC_HINT_SLIGHT: ++ ftLoadFalgs |= FT_LOAD_TARGET_LIGHT; ++ break; ++ case FC_HINT_MEDIUM: ++ ftLoadFalgs |= FT_LOAD_TARGET_NORMAL; ++ break; ++ case FC_HINT_FULL: ++ if (aaType == TEXT_AA_ON) ++ ftLoadFalgs |= FT_LOAD_TARGET_NORMAL; ++ else ++ ftLoadFalgs |= horizontal ? FT_LOAD_TARGET_LCD : FT_LOAD_TARGET_LCD_V; ++ break; ++ default: ++ // what else to use as default? ++ ftLoadFalgs |= FT_LOAD_TARGET_NORMAL; ++ break; ++ } ++ } ++ ++ // autohinting: ++ if (FcPatternGetBool(pattern, FC_AUTOHINT, 0, &b) == FcResultMatch) ++ if (b) ++ ftLoadFalgs |= FT_LOAD_FORCE_AUTOHINT; ++ ++ // LCD filter: ++ int filter = FC_LCD_DEFAULT; ++ FcPatternGetInteger(pattern, FC_LCD_FILTER, 0, &filter); ++ switch (filter) { ++ case FC_LCD_NONE: ++ ftLcdFilter = FT_LCD_FILTER_NONE; ++ break; ++ case FC_LCD_DEFAULT: ++ ftLcdFilter = FT_LCD_FILTER_DEFAULT; ++ break; ++ case FC_LCD_LIGHT: ++ ftLcdFilter = FT_LCD_FILTER_LIGHT; ++ break; ++ case FC_LCD_LEGACY: ++ ftLcdFilter = FT_LCD_FILTER_LEGACY; ++ break; ++ default: ++ // new unknown lcd filter type?! will use default one: ++ ftLcdFilter = FT_LCD_FILTER_DEFAULT; ++ break; ++ } ++ ++ FcPatternDestroy(pattern); ++ ++ rp->ftRenderMode = ftRenderMode; ++ rp->ftLoadFlags = ftLoadFalgs; ++ rp->ftLcdFilter = ftLcdFilter; ++} ++#endif + + /* + * Class: sun_font_FreetypeFontScaler +@@ -691,7 +839,9 @@ Java_sun_font_FreetypeFontScaler_getGlyp + UInt16 width, height; + GlyphInfo *glyphInfo; + int glyph_index; ++#ifndef INFINALITY + int renderFlags = FT_LOAD_RENDER, target; ++#endif + FT_GlyphSlot ftglyph; + + FTScalerContext* context = +@@ -709,6 +859,11 @@ Java_sun_font_FreetypeFontScaler_getGlyp + return ptr_to_jlong(getNullGlyphImage()); + } + ++#ifdef INFINALITY ++ RenderingProperties renderingProperties; ++ readFontconfig((const FcChar8 *) scalerInfo->face->family_name, ++ context->ptsz, context->aaType, &renderingProperties); ++#else + /* if algorithmic styling is required then we do not request bitmap */ + if (context->doBold || context->doItalize) { + renderFlags = FT_LOAD_DEFAULT; +@@ -731,10 +886,17 @@ Java_sun_font_FreetypeFontScaler_getGlyp + target = FT_LOAD_TARGET_LCD_V; + } + renderFlags |= target; ++#endif + + glyph_index = FT_Get_Char_Index(scalerInfo->face, glyphCode); + ++#ifdef INFINALITY ++ FT_Library_SetLcdFilter(scalerInfo->library, renderingProperties.ftLcdFilter); ++ error = FT_Load_Glyph(scalerInfo->face, glyphCode, renderingProperties.ftLoadFlags); ++#else + error = FT_Load_Glyph(scalerInfo->face, glyphCode, renderFlags); ++#endif ++ + if (error) { + //do not destroy scaler yet. + //this can be problem of particular context (e.g. with bad transform) +@@ -753,9 +915,13 @@ Java_sun_font_FreetypeFontScaler_getGlyp + + /* generate bitmap if it is not done yet + e.g. if algorithmic styling is performed and style was added to outline */ ++#ifdef INFINALITY ++ FT_Render_Glyph(ftglyph, renderingProperties.ftRenderMode); ++#else + if (ftglyph->format == FT_GLYPH_FORMAT_OUTLINE) { + FT_Render_Glyph(ftglyph, FT_LOAD_TARGET_MODE(target)); + } ++#endif + + width = (UInt16) ftglyph->bitmap.width; + height = (UInt16) ftglyph->bitmap.rows; +@@ -969,7 +1135,9 @@ Java_sun_font_FreetypeFontScaler_getGlyp + static FT_Outline* getFTOutline(JNIEnv* env, jobject font2D, + FTScalerContext *context, FTScalerInfo* scalerInfo, + jint glyphCode, jfloat xpos, jfloat ypos) { ++#ifndef INFINALITY + int renderFlags; ++#endif + int glyph_index; + FT_Error error; + FT_GlyphSlot ftglyph; +@@ -984,11 +1152,22 @@ static FT_Outline* getFTOutline(JNIEnv* + return NULL; + } + ++#ifdef INFINALITY ++ RenderingProperties renderingProperties; ++ readFontconfig((const FcChar8 *) scalerInfo->face->family_name, ++ context->ptsz, context->aaType, &renderingProperties); ++#else + renderFlags = FT_LOAD_NO_HINTING | FT_LOAD_NO_BITMAP; ++#endif + + glyph_index = FT_Get_Char_Index(scalerInfo->face, glyphCode); + ++#ifdef INFINALITY ++ error = FT_Load_Glyph(scalerInfo->face, glyphCode, renderingProperties.ftLoadFlags); ++#else + error = FT_Load_Glyph(scalerInfo->face, glyphCode, renderFlags); ++#endif ++ + if (error) { + return NULL; + } diff --git a/nixpkgs/pkgs/development/compilers/openjdk/11.nix b/nixpkgs/pkgs/development/compilers/openjdk/11.nix new file mode 100644 index 000000000000..5840061ed53e --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/openjdk/11.nix @@ -0,0 +1,164 @@ +{ stdenv, lib, fetchurl, bash, cpio, autoconf, pkgconfig, file, which, unzip, zip, cups, freetype +, alsaLib, bootjdk, perl, liberation_ttf, fontconfig, zlib, lndir +, libX11, libICE, libXrender, libXext, libXt, libXtst, libXi, libXinerama, libXcursor, libXrandr +, libjpeg, giflib +, setJavaClassPath +, minimal ? false +, enableGnome2 ? true, gtk3, gnome_vfs, glib, GConf +}: + +let + + /** + * The JDK libraries are in directories that depend on the CPU. + */ + architecture = + if stdenv.hostPlatform.system == "i686-linux" then + "i386" + else "amd64"; + + major = "11"; + update = ".0.3"; + build = "ga"; + repover = "jdk-${major}${update}-${build}"; + + openjdk = stdenv.mkDerivation { + name = "openjdk-${major}${update}-${build}"; + + src = fetchurl { + url = "http://hg.openjdk.java.net/jdk-updates/jdk${major}u/archive/${repover}.tar.gz"; + sha256 = "1v6pam38iidlhz46046h17hf5kki6n3kl302awjcyxzk7bmkvb8x"; + }; + + nativeBuildInputs = [ pkgconfig ]; + buildInputs = [ + autoconf cpio file which unzip zip perl bootjdk zlib cups freetype alsaLib + libjpeg giflib libX11 libICE libXext libXrender libXtst libXt libXtst + libXi libXinerama libXcursor libXrandr lndir fontconfig + ] ++ lib.optionals (!minimal && enableGnome2) [ + gtk3 gnome_vfs GConf glib + ]; + + patches = [ + ./fix-java-home-jdk10.patch + ./read-truststore-from-env-jdk10.patch + ./currency-date-range-jdk10.patch + ] ++ lib.optionals (!minimal && enableGnome2) [ + ./swing-use-gtk-jdk10.patch + ]; + + preConfigure = '' + chmod +x configure + substituteInPlace configure --replace /bin/bash "${bash}/bin/bash" + + configureFlagsArray=( + "--with-boot-jdk=${bootjdk.home}" + "--with-update-version=${major}${update}" + "--with-build-number=${build}" + "--with-milestone=fcs" + "--enable-unlimited-crypto" + "--disable-debug-symbols" + "--with-zlib=system" + "--with-giflib=system" + "--with-stdc++lib=dynamic" + + # glibc 2.24 deprecated readdir_r so we need this + # See https://www.mail-archive.com/openembedded-devel@lists.openembedded.org/msg49006.html + "--with-extra-cflags=-Wno-error=deprecated-declarations -Wno-error=format-contains-nul -Wno-error=unused-result" + '' + + lib.optionalString (architecture == "amd64") " \"--with-jvm-features=zgc\"" + + lib.optionalString minimal " \"--enable-headless-only\"" + + ");" + # https://bugzilla.redhat.com/show_bug.cgi?id=1306558 + # https://github.com/JetBrains/jdk8u/commit/eaa5e0711a43d64874111254d74893fa299d5716 + + stdenv.lib.optionalString stdenv.cc.isGNU '' + NIX_CFLAGS_COMPILE+=" -fno-lifetime-dse -fno-delete-null-pointer-checks -std=gnu++98 -Wno-error" + ''; + + NIX_LDFLAGS= lib.optionals (!minimal) [ + "-lfontconfig" "-lcups" "-lXinerama" "-lXrandr" "-lmagic" + ] ++ lib.optionals (!minimal && enableGnome2) [ + "-lgtk-3" "-lgio-2.0" "-lgnomevfs-2" "-lgconf-2" + ]; + + buildFlags = [ "all" ]; + + installPhase = '' + mkdir -p $out/lib/openjdk $out/share + + cp -av build/*/images/jdk/* $out/lib/openjdk + + # Remove some broken manpages. + rm -rf $out/lib/openjdk/man/ja* + + # Mirror some stuff in top-level. + mkdir $out/include $out/share/man + ln -s $out/lib/openjdk/include/* $out/include/ + ln -s $out/lib/openjdk/man/* $out/share/man/ + + # jni.h expects jni_md.h to be in the header search path. + ln -s $out/include/linux/*_md.h $out/include/ + + # Remove crap from the installation. + rm -rf $out/lib/openjdk/demo + ${lib.optionalString minimal '' + rm $out/lib/openjdk/lib/{libjsound,libfontmanager}.so + ''} + + ln -s $out/lib/openjdk/bin $out/bin + ''; + + preFixup = '' + # Propagate the setJavaClassPath setup hook so that any package + # that depends on the JDK has $CLASSPATH set up properly. + mkdir -p $out/nix-support + #TODO or printWords? cf https://github.com/NixOS/nixpkgs/pull/27427#issuecomment-317293040 + echo -n "${setJavaClassPath}" > $out/nix-support/propagated-build-inputs + + # Set JAVA_HOME automatically. + mkdir -p $out/nix-support + cat <<EOF > $out/nix-support/setup-hook + if [ -z "\$JAVA_HOME" ]; then export JAVA_HOME=$out/lib/openjdk; fi + EOF + ''; + + postFixup = '' + # Build the set of output library directories to rpath against + LIBDIRS="" + for output in $outputs; do + LIBDIRS="$(find $(eval echo \$$output) -name \*.so\* -exec dirname {} \+ | sort | uniq | tr '\n' ':'):$LIBDIRS" + done + + # Add the local library paths to remove dependencies on the bootstrap + for output in $outputs; do + OUTPUTDIR=$(eval echo \$$output) + BINLIBS=$(find $OUTPUTDIR/bin/ -type f; find $OUTPUTDIR -name \*.so\*) + echo "$BINLIBS" | while read i; do + patchelf --set-rpath "$LIBDIRS:$(patchelf --print-rpath "$i")" "$i" || true + patchelf --shrink-rpath "$i" || true + done + done + + # Test to make sure that we don't depend on the bootstrap + for output in $outputs; do + if grep -q -r '${bootjdk}' $(eval echo \$$output); then + echo "Extraneous references to ${bootjdk} detected" + exit 1 + fi + done + ''; + + meta = with stdenv.lib; { + homepage = http://openjdk.java.net/; + license = licenses.gpl2; + description = "The open-source Java Development Kit"; + maintainers = with maintainers; [ edwtjo ]; + platforms = ["i686-linux" "x86_64-linux"]; + }; + + passthru = { + inherit architecture; + home = "${openjdk}/lib/openjdk"; + }; + }; +in openjdk diff --git a/nixpkgs/pkgs/development/compilers/openjdk/8.nix b/nixpkgs/pkgs/development/compilers/openjdk/8.nix new file mode 100644 index 000000000000..952c5d1bf6ae --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/openjdk/8.nix @@ -0,0 +1,259 @@ +{ stdenv, lib, fetchurl, bash, cpio, pkgconfig, file, which, unzip, zip, cups, freetype +, alsaLib, bootjdk, cacert, perl, liberation_ttf, fontconfig, zlib, lndir +, libX11, libICE, libXrender, libXext, libXt, libXtst, libXi, libXinerama, libXcursor, libXrandr +, libjpeg, giflib +, setJavaClassPath +, minimal ? false +, enableInfinality ? true # font rendering patch +, enableGnome2 ? true, gtk2, gnome_vfs, glib, GConf +}: + +let + + /** + * The JRE libraries are in directories that depend on the CPU. + */ + architecture = + if stdenv.hostPlatform.system == "i686-linux" then + "i386" + else if stdenv.hostPlatform.system == "x86_64-linux" then + "amd64" + else + throw "openjdk requires i686-linux or x86_64 linux"; + + update = "212"; + build = "ga"; + baseurl = "http://hg.openjdk.java.net/jdk8u/jdk8u"; + repover = "jdk8u${update}-${build}"; + jdk8 = fetchurl { + url = "${baseurl}/archive/${repover}.tar.gz"; + sha256 = "00rl33h4cl4b4p3hcid765h38x2jdkb14ylh8k1zhnd0ka76crgg"; + }; + langtools = fetchurl { + url = "${baseurl}/langtools/archive/${repover}.tar.gz"; + sha256 = "0va6g2dccf1ph6mpwxswbks5axp7zz258cl89qq9r8jn4ni04agw"; + }; + hotspot = fetchurl { + url = "${baseurl}/hotspot/archive/${repover}.tar.gz"; + sha256 = "0sgr9df10hs49pjld6c6kr374v4zwd9s52pc3drz68zrlk71ja4s"; + }; + corba = fetchurl { + url = "${baseurl}/corba/archive/${repover}.tar.gz"; + sha256 = "1hq0sr4k4k4iv815kg72i9lvd7n7mn5pmw96ckk9p1rnyagn9z03"; + }; + jdk = fetchurl { + url = "${baseurl}/jdk/archive/${repover}.tar.gz"; + sha256 = "1fc59jrbfq8l067mggzy5dnrvni7lwaqd7hahs4nqv87kyrfg545"; + }; + jaxws = fetchurl { + url = "${baseurl}/jaxws/archive/${repover}.tar.gz"; + sha256 = "1ka2fvyxdmpfhk814s314gx53yvdr19vpsqygx283v9nbq90l1yg"; + }; + jaxp = fetchurl { + url = "${baseurl}/jaxp/archive/${repover}.tar.gz"; + sha256 = "15vlgs5v2ax8sqwh7bg50fnlrwlpnkp0myzrvpqs1mcza8pyasp8"; + }; + nashorn = fetchurl { + url = "${baseurl}/nashorn/archive/${repover}.tar.gz"; + sha256 = "1jzn0yi0v6lda5y8ib07g1p6zymnbcx9yy6iz8niggpm7205y93h"; + }; + openjdk8 = stdenv.mkDerivation { + name = "openjdk-8u${update}-${build}"; + + srcs = [ jdk8 langtools hotspot corba jdk jaxws jaxp nashorn ]; + sourceRoot = "."; + + outputs = [ "out" "jre" ]; + + nativeBuildInputs = [ pkgconfig ]; + buildInputs = [ + cpio file which unzip zip perl bootjdk zlib cups freetype alsaLib + libjpeg giflib libX11 libICE libXext libXrender libXtst libXt libXtst + libXi libXinerama libXcursor libXrandr lndir fontconfig + ] ++ lib.optionals (!minimal && enableGnome2) [ + gtk2 gnome_vfs GConf glib + ]; + + #move the seven other source dirs under the main jdk8u directory, + #with version suffixes removed, as the remainder of the build will expect + prePatch = '' + mainDir=$(find . -maxdepth 1 -name jdk8u\*); + find . -maxdepth 1 -name \*jdk\* -not -name jdk8u\* | awk -F- '{print $1}' | while read p; do + mv $p-* $mainDir/$p + done + cd $mainDir + ''; + + patches = [ + ./fix-java-home-jdk8.patch + ./read-truststore-from-env-jdk8.patch + ./currency-date-range-jdk8.patch + ] ++ lib.optionals (!minimal && enableInfinality) [ + ./004_add-fontconfig.patch + ./005_enable-infinality.patch + ] ++ lib.optionals (!minimal && enableGnome2) [ + ./swing-use-gtk-jdk8.patch + ]; + + # Hotspot cares about the host(!) version otherwise + DISABLE_HOTSPOT_OS_VERSION_CHECK = "ok"; + + preConfigure = '' + chmod +x configure + substituteInPlace configure --replace /bin/bash "${bash}/bin/bash" + substituteInPlace hotspot/make/linux/adlc_updater --replace /bin/sh "${stdenv.shell}" + substituteInPlace hotspot/make/linux/makefiles/dtrace.make --replace /usr/include/sys/sdt.h "/no-such-path" + '' + # https://bugzilla.redhat.com/show_bug.cgi?id=1306558 + # https://github.com/JetBrains/jdk8u/commit/eaa5e0711a43d64874111254d74893fa299d5716 + + stdenv.lib.optionalString stdenv.cc.isGNU '' + NIX_CFLAGS_COMPILE+=" -fno-lifetime-dse -fno-delete-null-pointer-checks -std=gnu++98 -Wno-error" + ''; + + configureFlags = [ + "--with-boot-jdk=${bootjdk.home}" + "--with-update-version=${update}" + "--with-build-number=${build}" + "--with-milestone=fcs" + "--enable-unlimited-crypto" + "--disable-debug-symbols" + "--disable-freetype-bundling" + "--with-zlib=system" + "--with-giflib=system" + "--with-stdc++lib=dynamic" + + # glibc 2.24 deprecated readdir_r so we need this + # See https://www.mail-archive.com/openembedded-devel@lists.openembedded.org/msg49006.html + "--with-extra-cflags=\"-Wno-error=deprecated-declarations\"" + ] ++ lib.optional minimal "--disable-headful"; + + NIX_LDFLAGS= lib.optionals (!minimal) [ + "-lfontconfig" "-lcups" "-lXinerama" "-lXrandr" "-lmagic" + ] ++ lib.optionals (!minimal && enableGnome2) [ + "-lgtk-x11-2.0" "-lgio-2.0" "-lgnomevfs-2" "-lgconf-2" + ]; + + buildFlags = [ "all" ]; + + doCheck = false; # fails with "No rule to make target 'y'." + + installPhase = '' + mkdir -p $out/lib/openjdk $out/share $jre/lib/openjdk + + cp -av build/*/images/j2sdk-image/* $out/lib/openjdk + + # Remove some broken manpages. + rm -rf $out/lib/openjdk/man/ja* + + # Mirror some stuff in top-level. + mkdir $out/include $out/share/man + ln -s $out/lib/openjdk/include/* $out/include/ + ln -s $out/lib/openjdk/man/* $out/share/man/ + + # jni.h expects jni_md.h to be in the header search path. + ln -s $out/include/linux/*_md.h $out/include/ + + # Remove crap from the installation. + rm -rf $out/lib/openjdk/demo $out/lib/openjdk/sample + ${lib.optionalString minimal '' + rm $out/lib/openjdk/jre/lib/${architecture}/{libjsound,libjsoundalsa,libsplashscreen,libawt*,libfontmanager}.so + rm $out/lib/openjdk/jre/bin/policytool + rm $out/lib/openjdk/bin/{policytool,appletviewer} + ''} + + # Move the JRE to a separate output and setup fallback fonts + mv $out/lib/openjdk/jre $jre/lib/openjdk/ + mkdir $out/lib/openjdk/jre + ${lib.optionalString (!minimal) '' + mkdir -p $jre/lib/openjdk/jre/lib/fonts/fallback + lndir ${liberation_ttf}/share/fonts/truetype $jre/lib/openjdk/jre/lib/fonts/fallback + ''} + lndir $jre/lib/openjdk/jre $out/lib/openjdk/jre + + rm -rf $out/lib/openjdk/jre/bina + ln -s $out/lib/openjdk/bin $out/lib/openjdk/jre/bin + + # Make sure cmm/*.pf are not symlinks: + # https://youtrack.jetbrains.com/issue/IDEA-147272 + rm -rf $out/lib/openjdk/jre/lib/cmm + ln -s {$jre,$out}/lib/openjdk/jre/lib/cmm + + # Remove duplicate binaries. + for i in $(cd $out/lib/openjdk/bin && echo *); do + if [ "$i" = java ]; then continue; fi + if cmp -s $out/lib/openjdk/bin/$i $jre/lib/openjdk/jre/bin/$i; then + ln -sfn $jre/lib/openjdk/jre/bin/$i $out/lib/openjdk/bin/$i + fi + done + + # Generate certificates. + ( + cd $jre/lib/openjdk/jre/lib/security + rm cacerts + perl ${./generate-cacerts.pl} $jre/lib/openjdk/jre/bin/keytool ${cacert}/etc/ssl/certs/ca-bundle.crt + ) + + ln -s $out/lib/openjdk/bin $out/bin + ln -s $jre/lib/openjdk/jre/bin $jre/bin + ln -s $jre/lib/openjdk/jre $out/jre + ''; + + # FIXME: this is unnecessary once the multiple-outputs branch is merged. + preFixup = '' + prefix=$jre stripDirs "$STRIP" "$stripDebugList" "''${stripDebugFlags:--S}" + patchELF $jre + propagatedBuildInputs+=" $jre" + + # Propagate the setJavaClassPath setup hook from the JRE so that + # any package that depends on the JRE has $CLASSPATH set up + # properly. + mkdir -p $jre/nix-support + printWords ${setJavaClassPath} > $jre/nix-support/propagated-build-inputs + + # Set JAVA_HOME automatically. + mkdir -p $out/nix-support + cat <<EOF > $out/nix-support/setup-hook + if [ -z "\$JAVA_HOME" ]; then export JAVA_HOME=$out/lib/openjdk; fi + EOF + ''; + + postFixup = '' + # Build the set of output library directories to rpath against + LIBDIRS="" + for output in $outputs; do + LIBDIRS="$(find $(eval echo \$$output) -name \*.so\* -exec dirname {} \+ | sort | uniq | tr '\n' ':'):$LIBDIRS" + done + + # Add the local library paths to remove dependencies on the bootstrap + for output in $outputs; do + OUTPUTDIR=$(eval echo \$$output) + BINLIBS=$(find $OUTPUTDIR/bin/ -type f; find $OUTPUTDIR -name \*.so\*) + echo "$BINLIBS" | while read i; do + patchelf --set-rpath "$LIBDIRS:$(patchelf --print-rpath "$i")" "$i" || true + patchelf --shrink-rpath "$i" || true + done + done + + # Test to make sure that we don't depend on the bootstrap + for output in $outputs; do + if grep -q -r '${bootjdk}' $(eval echo \$$output); then + echo "Extraneous references to ${bootjdk} detected" + exit 1 + fi + done + ''; + + meta = with stdenv.lib; { + homepage = http://openjdk.java.net/; + license = licenses.gpl2; + description = "The open-source Java Development Kit"; + maintainers = with maintainers; [ edwtjo nequissimus ]; + platforms = platforms.linux; + }; + + passthru = { + inherit architecture; + home = "${openjdk8}/lib/openjdk"; + }; + }; +in openjdk8 diff --git a/nixpkgs/pkgs/development/compilers/openjdk/bootstrap.nix b/nixpkgs/pkgs/development/compilers/openjdk/bootstrap.nix new file mode 100644 index 000000000000..e58888cc9ed8 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/openjdk/bootstrap.nix @@ -0,0 +1,40 @@ +{ stdenv +, runCommand, fetchurl, zlib + +, version +}: + +assert stdenv.hostPlatform.libc == "glibc"; + +let + fetchboot = version: arch: sha256: fetchurl { + name = "openjdk${version}-bootstrap-${arch}-linux.tar.xz"; + url = "http://tarballs.nixos.org/openjdk/2018-03-31/${version}/${arch}-linux.tar.xz"; + inherit sha256; + }; + + src = if stdenv.hostPlatform.system == "x86_64-linux" then + (if version == "10" then fetchboot "10" "x86_64" "08085fsxc1qhqiv3yi38w8lrg3vm7s0m2yvnwr1c92v019806yq2" + else if version == "8" then fetchboot "8" "x86_64" "18zqx6jhm3lizn9hh6ryyqc9dz3i96pwaz8f6nxfllk70qi5gvks" + else throw "No bootstrap jdk for version ${version}") + else if stdenv.hostPlatform.system == "i686-linux" then + (if version == "10" then fetchboot "10" "i686" "1blb9gyzp8gfyggxvggqgpcgfcyi00ndnnskipwgdm031qva94p7" + else if version == "8" then fetchboot "8" "i686" "1yx04xh8bqz7amg12d13rw5vwa008rav59mxjw1b9s6ynkvfgqq9" + else throw "No bootstrap for version") + else throw "No bootstrap jdk for system ${stdenv.hostPlatform.system}"; + + bootstrap = runCommand "openjdk-bootstrap" { + passthru.home = "${bootstrap}/lib/openjdk"; + } '' + tar xvf ${src} + mv openjdk-bootstrap $out + + LIBDIRS="$(find $out -name \*.so\* -exec dirname {} \; | sort | uniq | tr '\n' ':')" + + find "$out" -type f -print0 | while IFS= read -r -d "" elf; do + isELF "$elf" || continue + patchelf --set-interpreter $(cat "${stdenv.cc}/nix-support/dynamic-linker") "$elf" || true + patchelf --set-rpath "${stdenv.cc.libc}/lib:${stdenv.cc.cc.lib}/lib:${zlib}/lib:$LIBDIRS" "$elf" || true + done + ''; +in bootstrap diff --git a/nixpkgs/pkgs/development/compilers/openjdk/currency-date-range-jdk10.patch b/nixpkgs/pkgs/development/compilers/openjdk/currency-date-range-jdk10.patch new file mode 100644 index 000000000000..e058eff07466 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/openjdk/currency-date-range-jdk10.patch @@ -0,0 +1,13 @@ +--- ./make/jdk/src/classes/build/tools/generatecurrencydata/GenerateCurrencyData.java ++++ ./make/jdk/src/classes/build/tools/generatecurrencydata/GenerateCurrencyData.java +@@ -281,8 +281,8 @@ + checkCurrencyCode(newCurrency); + String timeString = currencyInfo.substring(4, length - 4); + long time = format.parse(timeString).getTime(); +- if (Math.abs(time - System.currentTimeMillis()) > ((long) 10) * 365 * 24 * 60 * 60 * 1000) { +- throw new RuntimeException("time is more than 10 years from present: " + time); ++ if (Math.abs(time - System.currentTimeMillis()) > ((long) 20) * 365 * 24 * 60 * 60 * 1000) { ++ throw new RuntimeException("time is more than 20 years from present: " + time); + } + specialCaseCutOverTimes[specialCaseCount] = time; + specialCaseOldCurrencies[specialCaseCount] = oldCurrency; diff --git a/nixpkgs/pkgs/development/compilers/openjdk/currency-date-range-jdk8.patch b/nixpkgs/pkgs/development/compilers/openjdk/currency-date-range-jdk8.patch new file mode 100644 index 000000000000..2ff0fcc3d411 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/openjdk/currency-date-range-jdk8.patch @@ -0,0 +1,14 @@ +diff -Naur openjdk-7u65-b32-upstream/jdk/make/tools/src/build/tools/generatecurrencydata/GenerateCurrencyData.java openjdk-7u65-b32/jdk/make/tools/src/build/tools/generatecurrencydata/GenerateCurrencyData.java +--- openjdk-7u65-b32-upstream/jdk/make/src/classes/build/tools/generatecurrencydata/GenerateCurrencyData.java 2014-07-17 05:42:14.000000000 -0430 ++++ openjdk-7u65-b32/jdk/make/src/classes/build/tools/generatecurrencydata/GenerateCurrencyData.java 2014-12-30 10:15:50.327905933 -0430 +@@ -281,8 +281,8 @@ + checkCurrencyCode(newCurrency); + String timeString = currencyInfo.substring(4, length - 4); + long time = format.parse(timeString).getTime(); +- if (Math.abs(time - System.currentTimeMillis()) > ((long) 10) * 365 * 24 * 60 * 60 * 1000) { +- throw new RuntimeException("time is more than 10 years from present: " + time); ++ if (Math.abs(time - System.currentTimeMillis()) > ((long) 20) * 365 * 24 * 60 * 60 * 1000) { ++ throw new RuntimeException("time is more than 20 years from present: " + time); + } + specialCaseCutOverTimes[specialCaseCount] = time; + specialCaseOldCurrencies[specialCaseCount] = oldCurrency; diff --git a/nixpkgs/pkgs/development/compilers/openjdk/darwin/11.nix b/nixpkgs/pkgs/development/compilers/openjdk/darwin/11.nix new file mode 100644 index 000000000000..61c2d57423e4 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/openjdk/darwin/11.nix @@ -0,0 +1,58 @@ +{ stdenv, fetchurl, unzip, setJavaClassPath, freetype }: +let + jce-policies = fetchurl { + # Ugh, unversioned URLs... I hope this doesn't change often enough to cause pain before we move to a Darwin source build of OpenJDK! + url = "http://cdn.azul.com/zcek/bin/ZuluJCEPolicies.zip"; + sha256 = "0nk7m0lgcbsvldq2wbfni2pzq8h818523z912i7v8hdcij5s48c0"; + }; + + jdk = stdenv.mkDerivation rec { + name = "zulu11.2.3-jdk11.0.1"; + + src = fetchurl { + url = "https://cdn.azul.com/zulu/bin/${name}-macosx_x64.tar.gz"; + sha256 = "1jxnxmy79inwf3146ygry1mzv3dj6yrzqll16j7dpr91x1p3dpqy"; + curlOpts = "-H Referer:https://www.azul.com/downloads/zulu/zulu-mac/"; + }; + + buildInputs = [ unzip freetype ]; + + installPhase = '' + mkdir -p $out + mv * $out + + unzip ${jce-policies} + mv -f ZuluJCEPolicies/*.jar $out/lib/security/ + + # jni.h expects jni_md.h to be in the header search path. + ln -s $out/include/darwin/*_md.h $out/include/ + + if [ -f $out/LICENSE ]; then + install -D $out/LICENSE $out/share/zulu/LICENSE + rm $out/LICENSE + fi + ''; + + preFixup = '' + # Propagate the setJavaClassPath setup hook from the JDK so that + # any package that depends on the JDK has $CLASSPATH set up + # properly. + mkdir -p $out/nix-support + printWords ${setJavaClassPath} > $out/nix-support/propagated-build-inputs + + install_name_tool -change /usr/X11/lib/libfreetype.6.dylib ${freetype}/lib/libfreetype.6.dylib $out/lib/libfontmanager.dylib + + # Set JAVA_HOME automatically. + cat <<EOF >> $out/nix-support/setup-hook + if [ -z "\$JAVA_HOME" ]; then export JAVA_HOME=$out; fi + EOF + ''; + + passthru = { + home = jdk; + }; + + meta.platforms = stdenv.lib.platforms.darwin; + + }; +in jdk diff --git a/nixpkgs/pkgs/development/compilers/openjdk/darwin/8.nix b/nixpkgs/pkgs/development/compilers/openjdk/darwin/8.nix new file mode 100644 index 000000000000..7457ffceab1f --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/openjdk/darwin/8.nix @@ -0,0 +1,59 @@ +{ stdenv, fetchurl, unzip, setJavaClassPath, freetype }: +let + jce-policies = fetchurl { + # Ugh, unversioned URLs... I hope this doesn't change often enough to cause pain before we move to a Darwin source build of OpenJDK! + url = "http://cdn.azul.com/zcek/bin/ZuluJCEPolicies.zip"; + sha256 = "0nk7m0lgcbsvldq2wbfni2pzq8h818523z912i7v8hdcij5s48c0"; + }; + + jdk = stdenv.mkDerivation { + name = "zulu1.8.0_121-8.20.0.5"; + + src = fetchurl { + url = "http://cdn.azul.com/zulu/bin/zulu8.20.0.5-jdk8.0.121-macosx_x64.zip"; + sha256 = "2a58bd1d9b0cbf0b3d8d1bcdd117c407e3d5a0ec01e2f53565c9bec5cf9ea78b"; + curlOpts = "-H Referer:https://www.azul.com/downloads/zulu/zulu-linux/"; + }; + + buildInputs = [ unzip freetype ]; + + installPhase = '' + mkdir -p $out + mv * $out + + unzip ${jce-policies} + mv -f ZuluJCEPolicies/*.jar $out/jre/lib/security/ + + # jni.h expects jni_md.h to be in the header search path. + ln -s $out/include/darwin/*_md.h $out/include/ + + if [ -f $out/LICENSE ]; then + install -D $out/LICENSE $out/share/zulu/LICENSE + rm $out/LICENSE + fi + ''; + + preFixup = '' + # Propagate the setJavaClassPath setup hook from the JRE so that + # any package that depends on the JRE has $CLASSPATH set up + # properly. + mkdir -p $out/nix-support + printWords ${setJavaClassPath} > $out/nix-support/propagated-build-inputs + + install_name_tool -change /usr/X11/lib/libfreetype.6.dylib ${freetype}/lib/libfreetype.6.dylib $out/jre/lib/libfontmanager.dylib + + # Set JAVA_HOME automatically. + cat <<EOF >> $out/nix-support/setup-hook + if [ -z "\$JAVA_HOME" ]; then export JAVA_HOME=$out; fi + EOF + ''; + + passthru = { + jre = jdk; + home = jdk; + }; + + meta.platforms = stdenv.lib.platforms.darwin; + + }; +in jdk diff --git a/nixpkgs/pkgs/development/compilers/openjdk/darwin/default.nix b/nixpkgs/pkgs/development/compilers/openjdk/darwin/default.nix new file mode 100644 index 000000000000..54239e58002f --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/openjdk/darwin/default.nix @@ -0,0 +1,49 @@ +{ stdenv, fetchurl, unzip, setJavaClassPath, freetype }: +let + jdk = stdenv.mkDerivation { + name = "openjdk-7u60b30"; + + # From https://github.com/alexkasko/openjdk-unofficial-builds + src = fetchurl { + url = https://bitbucket.org/alexkasko/openjdk-unofficial-builds/downloads/openjdk-1.7.0-u60-unofficial-macosx-x86_64-bundle.zip; + sha256 = "af510a4d566712d82c17054bb39f91d98c69a85586e244c6123669a0bd4b7401"; + }; + + buildInputs = [ unzip freetype ]; + + installPhase = '' + mv */Contents/Home $out + + # jni.h expects jni_md.h to be in the header search path. + ln -s $out/include/darwin/*_md.h $out/include/ + + if [ -f $out/LICENSE ]; then + install -D $out/LICENSE $out/share/zulu/LICENSE + rm $out/LICENSE + fi + ''; + + preFixup = '' + # Propagate the setJavaClassPath setup hook from the JRE so that + # any package that depends on the JRE has $CLASSPATH set up + # properly. + mkdir -p $out/nix-support + printWords ${setJavaClassPath} > $out/nix-support/propagated-build-inputs + + install_name_tool -change /usr/X11/lib/libfreetype.6.dylib ${freetype}/lib/libfreetype.6.dylib $out/jre/lib/libfontmanager.dylib + + # Set JAVA_HOME automatically. + cat <<EOF >> $out/nix-support/setup-hook + if [ -z "\$JAVA_HOME" ]; then export JAVA_HOME=$out; fi + EOF + ''; + + passthru = { + jre = jdk; + home = jdk; + }; + + meta.platforms = stdenv.lib.platforms.darwin; + + }; +in jdk diff --git a/nixpkgs/pkgs/development/compilers/openjdk/fix-java-home-jdk10.patch b/nixpkgs/pkgs/development/compilers/openjdk/fix-java-home-jdk10.patch new file mode 100644 index 000000000000..c037fde29722 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/openjdk/fix-java-home-jdk10.patch @@ -0,0 +1,14 @@ +--- a/src/hotspot/os/linux/os_linux.cpp 2017-07-04 23:09:02.533972226 -0400 ++++ b/src/hotspot/os/linux/os_linux.cpp 2017-07-04 23:07:52.118338845 -0400 +@@ -2270,8 +2270,5 @@ + assert(ret, "cannot locate libjvm"); + char *rp = NULL; + if (ret && dli_fname[0] != '\0') { +- rp = os::Posix::realpath(dli_fname, buf, buflen); +- } +- if (rp == NULL) { +- return; ++ snprintf(buf, buflen, "%s", dli_fname); + } + + if (Arguments::sun_java_launcher_is_altjvm()) { diff --git a/nixpkgs/pkgs/development/compilers/openjdk/fix-java-home-jdk8.patch b/nixpkgs/pkgs/development/compilers/openjdk/fix-java-home-jdk8.patch new file mode 100644 index 000000000000..6189412c999c --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/openjdk/fix-java-home-jdk8.patch @@ -0,0 +1,15 @@ +--- a/hotspot/src/os/linux/vm/os_linux.cpp 2015-02-04 21:14:39.000000000 +0100 ++++ b/hotspot/src/os/linux/vm/os_linux.cpp 2015-05-19 16:17:29.960107613 +0200 +@@ -2304,10 +2304,8 @@ + assert(ret, "cannot locate libjvm"); + char *rp = NULL; + if (ret && dli_fname[0] != '\0') { +- rp = realpath(dli_fname, buf); ++ snprintf(buf, buflen, "%s", dli_fname); + } +- if (rp == NULL) +- return; + + if (Arguments::created_by_gamma_launcher()) { + // Support for the gamma launcher. Typical value for buf is + diff --git a/nixpkgs/pkgs/development/compilers/openjdk/generate-cacerts.pl b/nixpkgs/pkgs/development/compilers/openjdk/generate-cacerts.pl new file mode 100644 index 000000000000..3bdd42f7274f --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/openjdk/generate-cacerts.pl @@ -0,0 +1,366 @@ +#!/usr/bin/perl + +# Copyright (C) 2007, 2008 Red Hat, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# generate-cacerts.pl generates a JKS keystore named 'cacerts' from +# OpenSSL's certificate bundle using OpenJDK's keytool. + +# First extract each of OpenSSL's bundled certificates into its own +# aliased filename. + +# Downloaded from http://cvs.fedoraproject.org/viewvc/rpms/ca-certificates/F-12/generate-cacerts.pl?revision=1.2 +# Check and prevention of duplicate aliases added by Vlastimil Babka <caster@gentoo.org> + +$file = $ARGV[1]; +open(CERTS, $file); +@certs = <CERTS>; +close(CERTS); + +$pem_file_count = 0; +$in_cert_block = 0; +$write_current_cert = 1; +foreach $cert (@certs) +{ + if ($cert =~ /Issuer: /) + { + $_ = $cert; + if ($cert =~ /personal-freemail/) + { + $cert_alias = "thawtepersonalfreemailca"; + } + elsif ($cert =~ /personal-basic/) + { + $cert_alias = "thawtepersonalbasicca"; + } + elsif ($cert =~ /personal-premium/) + { + $cert_alias = "thawtepersonalpremiumca"; + } + elsif ($cert =~ /server-certs/) + { + $cert_alias = "thawteserverca"; + } + elsif ($cert =~ /premium-server/) + { + $cert_alias = "thawtepremiumserverca"; + } + elsif ($cert =~ /Class 1 Public Primary Certification Authority$/) + { + $cert_alias = "verisignclass1ca"; + } + elsif ($cert =~ /Class 1 Public Primary Certification Authority - G2/) + { + $cert_alias = "verisignclass1g2ca"; + } + elsif ($cert =~ + /VeriSign Class 1 Public Primary Certification Authority - G3/) + { + $cert_alias = "verisignclass1g3ca"; + } + elsif ($cert =~ /Class 2 Public Primary Certification Authority$/) + { + $cert_alias = "verisignclass2ca"; + } + elsif ($cert =~ /Class 2 Public Primary Certification Authority - G2/) + { + $cert_alias = "verisignclass2g2ca"; + } + elsif ($cert =~ + /VeriSign Class 2 Public Primary Certification Authority - G3/) + { + $cert_alias = "verisignclass2g3ca"; + } + elsif ($cert =~ /Class 3 Public Primary Certification Authority$/) + { + $cert_alias = "verisignclass3ca"; + } + # Version 1 of Class 3 Public Primary Certification Authority + # - G2 is added. Version 3 is excluded. See below. + elsif ($cert =~ + /VeriSign Class 3 Public Primary Certification Authority - G3/) + { + $cert_alias = "verisignclass3g3ca"; + } + elsif ($cert =~ + /RSA Data Security.*Secure Server Certification Authority/) + { + $cert_alias = "verisignserverca"; + } + elsif ($cert =~ /GTE CyberTrust Global Root/) + { + $cert_alias = "gtecybertrustglobalca"; + } + elsif ($cert =~ /Baltimore CyberTrust Root/) + { + $cert_alias = "baltimorecybertrustca"; + } + elsif ($cert =~ /www.entrust.net\/Client_CA_Info\/CPS/) + { + $cert_alias = "entrustclientca"; + } + elsif ($cert =~ /www.entrust.net\/GCCA_CPS/) + { + $cert_alias = "entrustglobalclientca"; + } + elsif ($cert =~ /www.entrust.net\/CPS_2048/) + { + $cert_alias = "entrust2048ca"; + } + elsif ($cert =~ /www.entrust.net\/CPS /) + { + $cert_alias = "entrustsslca"; + } + elsif ($cert =~ /www.entrust.net\/SSL_CPS/) + { + $cert_alias = "entrustgsslca"; + } + elsif ($cert =~ /The Go Daddy Group/) + { + $cert_alias = "godaddyclass2ca"; + } + elsif ($cert =~ /Starfield Class 2 Certification Authority/) + { + $cert_alias = "starfieldclass2ca"; + } + elsif ($cert =~ /ValiCert Class 2 Policy Validation Authority/) + { + $cert_alias = "valicertclass2ca"; + } + elsif ($cert =~ /GeoTrust Global CA$/) + { + $cert_alias = "geotrustglobalca"; + } + elsif ($cert =~ /Equifax Secure Certificate Authority/) + { + $cert_alias = "equifaxsecureca"; + } + elsif ($cert =~ /Equifax Secure eBusiness CA-1/) + { + $cert_alias = "equifaxsecureebusinessca1"; + } + elsif ($cert =~ /Equifax Secure eBusiness CA-2/) + { + $cert_alias = "equifaxsecureebusinessca2"; + } + elsif ($cert =~ /Equifax Secure Global eBusiness CA-1/) + { + $cert_alias = "equifaxsecureglobalebusinessca1"; + } + elsif ($cert =~ /Sonera Class1 CA/) + { + $cert_alias = "soneraclass1ca"; + } + elsif ($cert =~ /Sonera Class2 CA/) + { + $cert_alias = "soneraclass2ca"; + } + elsif ($cert =~ /AAA Certificate Services/) + { + $cert_alias = "comodoaaaca"; + } + elsif ($cert =~ /AddTrust Class 1 CA Root/) + { + $cert_alias = "addtrustclass1ca"; + } + elsif ($cert =~ /AddTrust External CA Root/) + { + $cert_alias = "addtrustexternalca"; + } + elsif ($cert =~ /AddTrust Qualified CA Root/) + { + $cert_alias = "addtrustqualifiedca"; + } + elsif ($cert =~ /UTN-USERFirst-Hardware/) + { + $cert_alias = "utnuserfirsthardwareca"; + } + elsif ($cert =~ /UTN-USERFirst-Client Authentication and Email/) + { + $cert_alias = "utnuserfirstclientauthemailca"; + } + elsif ($cert =~ /UTN - DATACorp SGC/) + { + $cert_alias = "utndatacorpsgcca"; + } + elsif ($cert =~ /UTN-USERFirst-Object/) + { + $cert_alias = "utnuserfirstobjectca"; + } + elsif ($cert =~ /America Online Root Certification Authority 1/) + { + $cert_alias = "aolrootca1"; + } + elsif ($cert =~ /DigiCert Assured ID Root CA/) + { + $cert_alias = "digicertassuredidrootca"; + } + elsif ($cert =~ /DigiCert Global Root CA/) + { + $cert_alias = "digicertglobalrootca"; + } + elsif ($cert =~ /DigiCert High Assurance EV Root CA/) + { + $cert_alias = "digicerthighassuranceevrootca"; + } + elsif ($cert =~ /GlobalSign Root CA$/) + { + $cert_alias = "globalsignca"; + } + elsif ($cert =~ /GlobalSign Root CA - R2/) + { + $cert_alias = "globalsignr2ca"; + } + elsif ($cert =~ /Elektronik.*Kas.*2005/) + { + $cert_alias = "extra-elektronikkas2005"; + } + elsif ($cert =~ /Elektronik/) + { + $cert_alias = "extra-elektronik2005"; + } + # Mozilla does not provide these certificates: + # baltimorecodesigningca + # gtecybertrust5ca + # trustcenterclass2caii + # trustcenterclass4caii + # trustcenteruniversalcai + else + { + # Generate an alias using the OU and CN attributes of the + # Issuer field if both are present, otherwise use only the + # CN attribute. The Issuer field must have either the OU + # or the CN attribute. + $_ = $cert; + if ($cert =~ /OU=/) + { + s/Issuer:.*?OU=//; + # Remove other occurrences of OU=. + s/OU=.*CN=//; + # Remove CN= if there were not other occurrences of OU=. + s/CN=//; + s/\/emailAddress.*//; + s/Certificate Authority/ca/g; + s/Certification Authority/ca/g; + } + elsif ($cert =~ /CN=/) + { + s/Issuer:.*CN=//; + s/\/emailAddress.*//; + s/Certificate Authority/ca/g; + s/Certification Authority/ca/g; + } + s/\W//g; + tr/A-Z/a-z/; + $cert_alias = "extra-$_"; + + } + while (-e "$cert_alias.pem") + { + $cert_alias = "$cert_alias" . "_"; + } + } + # When it attempts to parse: + # + # Class 3 Public Primary Certification Authority - G2, Version 3 + # + # keytool says: + # + # #2: ObjectId: 1.3.6.1.5.5.7.1.1 Criticality=false + # Unparseable AuthorityInfoAccess extension due to + # java.io.IOException: Invalid encoding of URI + # + # If we do not exclude this file + # openjdk/jdk/test/lib/security/cacerts/VerifyCACerts.java fails + # on this cert, printing: + # + # Couldn't verify: java.security.SignatureException: Signature + # does not match. + # + elsif ($cert =~ + /A6:0F:34:C8:62:6C:81:F6:8B:F7:7D:A9:F6:67:58:8A:90:3F:7D:36/) + { + $write_current_cert = 0; + $pem_file_count--; + } + elsif ($cert eq "-----BEGIN CERTIFICATE-----\n") + { + $_ = $cert; + s/\W//g; + tr/A-Z/a-z/; + $cert_alias = "extra-$_"; + while (-e "$cert_alias.pem") + { + $cert_alias = "$cert_alias" . "_"; + } + if ($in_cert_block != 0) + { + die "$file is malformed."; + } + $in_cert_block = 1; + if ($write_current_cert == 1) + { + $pem_file_count++; + if (-e "$cert_alias.pem") + { + print "$cert_alias"; + die "already exists" + } + open(PEM, ">$cert_alias.pem"); + print PEM $cert; + } + } + elsif ($cert eq "-----END CERTIFICATE-----\n") + { + $in_cert_block = 0; + if ($write_current_cert == 1) + { + print PEM $cert; + close(PEM); + } + $write_current_cert = 1 + } + else + { + if ($in_cert_block == 1 && $write_current_cert == 1) + { + print PEM $cert; + } + } +} + +# Check that the correct number of .pem files were produced. +@pem_files = <*.pem>; +if (@pem_files != $pem_file_count) +{ + print "$pem_file_count"; + die "Number of .pem files produced does not match". + " number of certs read from $file."; +} + +# Now store each cert in the 'cacerts' file using keytool. +$certs_written_count = 0; +foreach $pem_file (@pem_files) +{ + system "$ARGV[0] -noprompt -import". + " -alias `basename $pem_file .pem`". + " -keystore cacerts -storepass 'changeit' -file $pem_file"; + unlink($pem_file); + $certs_written_count++; +} + +# Check that the correct number of certs were added to the keystore. +if ($certs_written_count != $pem_file_count) +{ + die "Number of certs added to keystore does not match". + " number of certs read from $file."; +} diff --git a/nixpkgs/pkgs/development/compilers/openjdk/make-bootstrap.nix b/nixpkgs/pkgs/development/compilers/openjdk/make-bootstrap.nix new file mode 100644 index 000000000000..aac54417e2a8 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/openjdk/make-bootstrap.nix @@ -0,0 +1,31 @@ +{ runCommand, openjdk, nukeReferences }: + +runCommand "${openjdk.name}-bootstrap.tar.xz" {} '' + mkdir -pv openjdk-bootstrap/lib + + # Do a deep copy of the openjdk + cp -vrL ${openjdk.home} openjdk-bootstrap/lib + + # Includes are needed for building the native jvm + cp -vrL ${openjdk}/include openjdk-bootstrap + + # The binaries are actually stored in the openjdk lib + ln -sv lib/openjdk/bin openjdk-bootstrap/bin + find . -name libjli.so + (cd openjdk-bootstrap/lib; find . -name libjli.so -exec ln -sfv {} libjli.so \;) + + chmod -R +w openjdk-bootstrap + + # Remove components we don't need + find openjdk-bootstrap -name \*.diz -exec rm {} \; + find openjdk-bootstrap -name \*.ttf -exec rm {} \; + find openjdk-bootstrap -name \*.gif -exec rm {} \; + find openjdk-bootstrap -name src.zip -exec rm {} \; + rm -rf openjdk-bootstrap/lib/openjdk/jre/bin + + # Remove all of the references to the native nix store + find openjdk-bootstrap -print0 | xargs -0 ${nukeReferences}/bin/nuke-refs + + # Create the output tarball + tar cv openjdk-bootstrap | xz > $out +'' diff --git a/nixpkgs/pkgs/development/compilers/openjdk/read-truststore-from-env-jdk10.patch b/nixpkgs/pkgs/development/compilers/openjdk/read-truststore-from-env-jdk10.patch new file mode 100644 index 000000000000..6203064f5c06 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/openjdk/read-truststore-from-env-jdk10.patch @@ -0,0 +1,30 @@ +--- a/src/java.base/share/classes/sun/security/ssl/TrustStoreManager.java 2017-06-26 21:48:25.000000000 -0400 ++++ b/src/java.base/share/classes/sun/security/ssl/TrustStoreManager.java 2017-07-05 20:45:57.491295030 -0400 +@@ -71,6 +71,7 @@ + * + * The preference of the default trusted KeyStore is: + * javax.net.ssl.trustStore ++ * system environment variable JAVAX_NET_SSL_TRUSTSTORE + * jssecacerts + * cacerts + */ +@@ -132,7 +133,8 @@ + public TrustStoreDescriptor run() { + // Get the system properties for trust store. + String storePropName = System.getProperty( +- "javax.net.ssl.trustStore", jsseDefaultStore); ++ "javax.net.ssl.trustStore", ++ System.getenv("JAVAX_NET_SSL_TRUSTSTORE")); + String storePropType = System.getProperty( + "javax.net.ssl.trustStoreType", + KeyStore.getDefaultType()); +@@ -144,6 +146,9 @@ + String temporaryName = ""; + File temporaryFile = null; + long temporaryTime = 0L; ++ if (storePropName == null) { ++ storePropName = jsseDefaultStore; ++ } + if (!"NONE".equals(storePropName)) { + String[] fileNames = + new String[] {storePropName, defaultStore}; diff --git a/nixpkgs/pkgs/development/compilers/openjdk/read-truststore-from-env-jdk8.patch b/nixpkgs/pkgs/development/compilers/openjdk/read-truststore-from-env-jdk8.patch new file mode 100644 index 000000000000..4902b8e84011 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/openjdk/read-truststore-from-env-jdk8.patch @@ -0,0 +1,21 @@ +diff -ur openjdk-7u65-b32/jdk/src/share/classes/sun/security/ssl/TrustManagerFactoryImpl.java openjdk-7u65-b32.new/jdk/src/share/classes/sun/security/ssl/TrustManagerFactoryImpl.java +--- openjdk-7u65-b32/jdk/src/share/classes/sun/security/ssl/TrustManagerFactoryImpl.java 2014-07-17 12:12:14.000000000 +0200 ++++ openjdk-7u65-b32.new/jdk/src/share/classes/sun/security/ssl/TrustManagerFactoryImpl.java 2014-12-09 13:31:27.821960372 +0100 +@@ -161,6 +161,7 @@ + /* + * Try: + * javax.net.ssl.trustStore (if this variable exists, stop) ++ * system environment variable JAVAX_NET_SSL_TRUSTSTORE + * jssecacerts + * cacerts + * +@@ -169,6 +169,9 @@ + + try { + storeFileName = props.get("trustStore"); ++ if (storeFileName == null) { ++ storeFileName = System.getenv("JAVAX_NET_SSL_TRUSTSTORE"); ++ } + if (!"NONE".equals(storeFileName)) { + if (storeFileName != null) { + storeFile = new File(storeFileName); diff --git a/nixpkgs/pkgs/development/compilers/openjdk/swing-use-gtk-jdk10.patch b/nixpkgs/pkgs/development/compilers/openjdk/swing-use-gtk-jdk10.patch new file mode 100644 index 000000000000..b9258c500db4 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/openjdk/swing-use-gtk-jdk10.patch @@ -0,0 +1,24 @@ +--- a/src/java.desktop/share/classes/javax/swing/UIManager.java ++++ b/src/java.desktop/share/classes/javax/swing/UIManager.java +@@ -607,11 +607,9 @@ + if (osType == OSInfo.OSType.WINDOWS) { + return "com.sun.java.swing.plaf.windows.WindowsLookAndFeel"; + } else { +- String desktop = AccessController.doPrivileged(new GetPropertyAction("sun.desktop")); + Toolkit toolkit = Toolkit.getDefaultToolkit(); +- if ("gnome".equals(desktop) && +- toolkit instanceof SunToolkit && +- ((SunToolkit) toolkit).isNativeGTKAvailable()) { ++ if (toolkit instanceof SunToolkit && ++ ((SunToolkit) toolkit).isNativeGTKAvailable()) { + // May be set on Linux and Solaris boxs. + return "com.sun.java.swing.plaf.gtk.GTKLookAndFeel"; + } +@@ -1341,7 +1339,7 @@ + lafName = (String) lafData.remove("defaultlaf"); + } + if (lafName == null) { +- lafName = getCrossPlatformLookAndFeelClassName(); ++ lafName = getSystemLookAndFeelClassName(); + } + lafName = swingProps.getProperty(defaultLAFKey, lafName); diff --git a/nixpkgs/pkgs/development/compilers/openjdk/swing-use-gtk-jdk8.patch b/nixpkgs/pkgs/development/compilers/openjdk/swing-use-gtk-jdk8.patch new file mode 100644 index 000000000000..9538aade6726 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/openjdk/swing-use-gtk-jdk8.patch @@ -0,0 +1,26 @@ +diff -ru3 a/jdk/src/share/classes/javax/swing/UIManager.java b/jdk/src/share/classes/javax/swing/UIManager.java +--- a/jdk/src/share/classes/javax/swing/UIManager.java 2016-07-26 00:41:37.000000000 +0300 ++++ b/jdk/src/share/classes/javax/swing/UIManager.java 2016-10-02 22:46:01.890071761 +0300 +@@ -607,11 +607,9 @@ + if (osType == OSInfo.OSType.WINDOWS) { + return "com.sun.java.swing.plaf.windows.WindowsLookAndFeel"; + } else { +- String desktop = AccessController.doPrivileged(new GetPropertyAction("sun.desktop")); + Toolkit toolkit = Toolkit.getDefaultToolkit(); +- if ("gnome".equals(desktop) && +- toolkit instanceof SunToolkit && +- ((SunToolkit) toolkit).isNativeGTKAvailable()) { ++ if (toolkit instanceof SunToolkit && ++ ((SunToolkit) toolkit).isNativeGTKAvailable()) { + // May be set on Linux and Solaris boxs. + return "com.sun.java.swing.plaf.gtk.GTKLookAndFeel"; + } +@@ -1341,7 +1339,7 @@ + lafName = (String) lafData.remove("defaultlaf"); + } + if (lafName == null) { +- lafName = getCrossPlatformLookAndFeelClassName(); ++ lafName = getSystemLookAndFeelClassName(); + } + lafName = swingProps.getProperty(defaultLAFKey, lafName); + diff --git a/nixpkgs/pkgs/development/compilers/openspin/default.nix b/nixpkgs/pkgs/development/compilers/openspin/default.nix new file mode 100644 index 000000000000..71bda3e03d96 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/openspin/default.nix @@ -0,0 +1,26 @@ +{ stdenv, fetchurl, fetchFromGitHub }: + +stdenv.mkDerivation rec { + name = "openspin-${version}"; + version = "unstable-2018-10-02"; + + src = fetchFromGitHub { + owner = "parallaxinc"; + repo = "OpenSpin"; + rev = "f3a587ed3e4f6a50b3c8d2022bbec5676afecedb"; + sha256 = "1knkbzdanb60cwp7mggymkhd0167lh2sb1c00d1vhw7s0s1rj96n"; + }; + + installPhase = '' + mkdir -p $out/bin + mv build/openspin $out/bin/openspin + ''; + + meta = with stdenv.lib; { + description = "Compiler for SPIN/PASM languages for Parallax Propeller MCU"; + homepage = https://github.com/parallaxinc/OpenSpin; + license = licenses.mit; + maintainers = [ maintainers.redvers ]; + platforms = platforms.all; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/oraclejdk/dlj-bundle-builder.sh b/nixpkgs/pkgs/development/compilers/oraclejdk/dlj-bundle-builder.sh new file mode 100644 index 000000000000..459bfce50988 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/oraclejdk/dlj-bundle-builder.sh @@ -0,0 +1,60 @@ +source $stdenv/setup + +echo "Unpacking distribution" +unzip ${src} || true + +# set the dynamic linker of unpack200, necessary for construct script +echo "patching unpack200" +patchelf --interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" --set-rpath "" */bin/unpack200 + +echo "constructing JDK and JRE installations" +if test -z "$installjdk"; then + sh ${construct} . tmp-linux-jdk tmp-linux-jre + mkdir -p $out + cp -R tmp-linux-jre/* $out +else + sh ${construct} . $out tmp-linux-jre +fi + +echo "removing files at top level of installation" +for file in $out/* +do + if test -f $file ; then + rm $file + fi +done +rm -rf $out/docs + +# construct the rpath +rpath= +for i in $libraries; do + rpath=$rpath${rpath:+:}$i/lib +done + +if test -z "$installjdk"; then + jrePath=$out +else + jrePath=$out/jre +fi + +if test -n "$jce"; then + unzip $jce + cp -v jce/*.jar $jrePath/lib/security +fi + +rpath=$rpath${rpath:+:}$jrePath/lib/$architecture/jli + +# set all the dynamic linkers +find $out -type f -perm -0100 \ + -exec patchelf --interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \ + --set-rpath "$rpath" {} \; + +find $out -name "*.so" -exec patchelf --set-rpath "$rpath" {} \; + +if test -z "$pluginSupport"; then + rm -f $out/bin/javaws +fi + +mkdir $jrePath/lib/$architecture/plugins +ln -s $jrePath/lib/$architecture/libnpjp2.so $jrePath/lib/$architecture/plugins + diff --git a/nixpkgs/pkgs/development/compilers/oraclejdk/jdk-linux-base.nix b/nixpkgs/pkgs/development/compilers/oraclejdk/jdk-linux-base.nix new file mode 100644 index 000000000000..ea6b9d2a9fe7 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/oraclejdk/jdk-linux-base.nix @@ -0,0 +1,204 @@ +{ productVersion +, patchVersion +, buildVersion +, sha256 +, jceName +, releaseToken +, sha256JCE +}: + +{ swingSupport ? true +, stdenv +, fetchurl +, makeWrapper +, unzip +, file +, xorg ? null +, installjdk ? true +, pluginSupport ? true +, installjce ? false +, config +, licenseAccepted ? config.oraclejdk.accept_license or false +, glib +, libxml2 +, libav_0_8 +, ffmpeg +, libxslt +, libGL +, freetype +, fontconfig +, gtk2 +, pango +, cairo +, alsaLib +, atk +, gdk_pixbuf +, setJavaClassPath +}: + +assert swingSupport -> xorg != null; + +if !licenseAccepted then throw '' + You must accept the Oracle Binary Code License Agreement for Java SE at + https://www.oracle.com/technetwork/java/javase/terms/license/index.html + by setting nixpkgs config option 'oraclejdk.accept_license = true;' + '' +else assert licenseAccepted; + +let + + /** + * The JRE libraries are in directories that depend on the CPU. + */ + architecture = { + i686-linux = "i386"; + x86_64-linux = "amd64"; + armv7l-linux = "arm"; + aarch64-linux = "aarch64"; + }.${stdenv.hostPlatform.system}; + + jce = + if installjce then + fetchurl { + url = "http://download.oracle.com/otn-pub/java/jce/${productVersion}/${jceName}"; + sha256 = sha256JCE; + curlOpts = "-b oraclelicense=a"; + } + else + ""; + + rSubPaths = [ + "lib/${architecture}/jli" + "lib/${architecture}/server" + "lib/${architecture}/xawt" + "lib/${architecture}" + ]; + +in + +assert sha256 ? ${stdenv.hostPlatform.system}; + +let result = stdenv.mkDerivation rec { + name = + if installjdk then "oraclejdk-${productVersion}u${patchVersion}" else "oraclejre-${productVersion}u${patchVersion}"; + + src = let + platformName = { + i686-linux = "linux-i586"; + x86_64-linux = "linux-x64"; + armv7l-linux = "linux-arm32-vfp-hflt"; + aarch64-linux = "linux-arm64-vfp-hflt"; + }.${stdenv.hostPlatform.system}; + javadlPlatformName = "linux-i586"; + in fetchurl { + url = "http://javadl.oracle.com/webapps/download/GetFile/1.${productVersion}.0_${patchVersion}-b${buildVersion}/${releaseToken}/${javadlPlatformName}/jdk-${productVersion}u${patchVersion}-${platformName}.tar.gz"; + curlOpts = "-b oraclelicense=a"; + sha256 = sha256.${stdenv.hostPlatform.system}; + }; + + nativeBuildInputs = [ file ] + ++ stdenv.lib.optional installjce unzip; + + buildInputs = [ makeWrapper ]; + + # See: https://github.com/NixOS/patchelf/issues/10 + dontStrip = 1; + + installPhase = '' + cd .. + + if test -z "$installjdk"; then + mv $sourceRoot/jre $out + else + mv $sourceRoot $out + fi + + shopt -s extglob + for file in $out/!(*src.zip) + do + if test -f $file ; then + rm $file + fi + done + + if test -n "$installjdk"; then + for file in $out/jre/* + do + if test -f $file ; then + rm $file + fi + done + fi + + if test -z "$installjdk"; then + jrePath=$out + else + jrePath=$out/jre + fi + + if test -n "${jce}"; then + unzip ${jce} + cp -v UnlimitedJCEPolicy*/*.jar $jrePath/lib/security + fi + + if test -z "$pluginSupport"; then + rm -f $out/bin/javaws + if test -n "$installjdk"; then + rm -f $out/jre/bin/javaws + fi + fi + + mkdir $jrePath/lib/${architecture}/plugins + ln -s $jrePath/lib/${architecture}/libnpjp2.so $jrePath/lib/${architecture}/plugins + + mkdir -p $out/nix-support + printWords ${setJavaClassPath} > $out/nix-support/propagated-build-inputs + + # Set JAVA_HOME automatically. + cat <<EOF >> $out/nix-support/setup-hook + if [ -z "\$JAVA_HOME" ]; then export JAVA_HOME=$out; fi + EOF + ''; + + postFixup = '' + rpath+="''${rpath:+:}${stdenv.lib.concatStringsSep ":" (map (a: "$jrePath/${a}") rSubPaths)}" + + # set all the dynamic linkers + find $out -type f -perm -0100 \ + -exec patchelf --interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \ + --set-rpath "$rpath" {} \; + + find $out -name "*.so" -exec patchelf --set-rpath "$rpath" {} \; + + # Oracle Java Mission Control needs to know where libgtk-x11 and related is + if test -n "$installjdk" -a -x $out/bin/jmc; then + wrapProgram "$out/bin/jmc" \ + --suffix-each LD_LIBRARY_PATH ':' "$rpath" + fi + ''; + + inherit installjdk pluginSupport; + + /** + * libXt is only needed on amd64 + */ + libraries = + [stdenv.cc.libc glib libxml2 libav_0_8 ffmpeg libxslt libGL xorg.libXxf86vm alsaLib fontconfig freetype pango gtk2 cairo gdk_pixbuf atk] ++ + (if swingSupport then [xorg.libX11 xorg.libXext xorg.libXtst xorg.libXi xorg.libXp xorg.libXt xorg.libXrender stdenv.cc.cc] else []); + + rpath = stdenv.lib.strings.makeLibraryPath libraries; + + passthru.mozillaPlugin = if installjdk then "/jre/lib/${architecture}/plugins" else "/lib/${architecture}/plugins"; + + passthru.jre = result; # FIXME: use multiple outputs or return actual JRE package + + passthru.home = result; + + passthru.architecture = architecture; + + meta = with stdenv.lib; { + license = licenses.unfree; + platforms = [ "i686-linux" "x86_64-linux" "armv7l-linux" "aarch64-linux" ]; # some inherit jre.meta.platforms + }; + +}; in stdenv.lib.trivial.warn "Public updates for Oracle Java SE 8 released after January 2019 will not be available for business, commercial or production use without a commercial license. See https://java.com/en/download/release_notice.jsp for more information." result diff --git a/nixpkgs/pkgs/development/compilers/oraclejdk/jdk8cpu-linux.nix b/nixpkgs/pkgs/development/compilers/oraclejdk/jdk8cpu-linux.nix new file mode 100644 index 000000000000..d9ee5010f7cf --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/oraclejdk/jdk8cpu-linux.nix @@ -0,0 +1,14 @@ +# http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html; +# jce download url: http://www.oracle.com/technetwork/java/javase/downloads/jce8-download-2133166.html; +import ./jdk-linux-base.nix { + productVersion = "8"; + patchVersion = "211"; + buildVersion = "12"; + sha256.i686-linux = "0mdrljs0rw9s4pvaa3sn791nqgdrp8749z3qn80y7hhad74kvsnp"; + sha256.x86_64-linux = "13b6qk4sn8jdhxa22na9d2aazm4yjh6yxrlxr189gxy3619y9dy0"; + sha256.armv7l-linux = "1ij1x925k7lyp5f98gy8r0xfr41qhczf2rb74plwwmrccc1k00p5"; + sha256.aarch64-linux = "041r615qj9qy34a9gxm8968qlmf060ba2as5w97v86mbik4rca05"; + releaseToken = "478a62b7d4e34b78b671c754eaaf38ab"; + jceName = "jce_policy-8.zip"; + sha256JCE = "0n8b6b8qmwb14lllk2lk1q1ahd3za9fnjigz5xn65mpg48whl0pk"; +} diff --git a/nixpkgs/pkgs/development/compilers/oraclejdk/jdk8psu-linux.nix b/nixpkgs/pkgs/development/compilers/oraclejdk/jdk8psu-linux.nix new file mode 100644 index 000000000000..9fab02ab5361 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/oraclejdk/jdk8psu-linux.nix @@ -0,0 +1,14 @@ +# http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html; +# jce download url: http://www.oracle.com/technetwork/java/javase/downloads/jce8-download-2133166.html; +import ./jdk-linux-base.nix { + productVersion = "8"; + patchVersion = "212"; + buildVersion = "10"; + sha256.i686-linux = "03dj9q0bi3ib731f4zl9hylkrgw417h6qlg2wi7nw71b0fqhijn1"; + sha256.x86_64-linux = "1yzddxzfh6h14bpzis1abp52x4jjljg8a3zyqz483q6qm05caq1i"; + sha256.armv7l-linux = "0x333alkqdx8mmiirair7g5iiwif5v9ka4j3qr0f42ilvmk8csnx"; + sha256.aarch64-linux = "0vcbdvcsl8rm47i07s93jmrrs5laibf937d8vacjqqgh9bbhsr2c"; + releaseToken = "59066701cf1a433da9770636fbc4c9aa"; + jceName = "jce_policy-8.zip"; + sha256JCE = "0n8b6b8qmwb14lllk2lk1q1ahd3za9fnjigz5xn65mpg48whl0pk"; +} diff --git a/nixpkgs/pkgs/development/compilers/orc/default.nix b/nixpkgs/pkgs/development/compilers/orc/default.nix new file mode 100644 index 000000000000..1a81a5ec20a7 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/orc/default.nix @@ -0,0 +1,30 @@ +{ stdenv, fetchurl }: + +stdenv.mkDerivation rec { + name = "orc-0.4.28"; + + src = fetchurl { + url = "https://gstreamer.freedesktop.org/src/orc/${name}.tar.xz"; + sha256 = "bfcd7c6563b05672386c4eedfc4c0d4a0a12b4b4775b74ec6deb88fc2bcd83ce"; + }; + + outputs = [ "out" "dev" ]; + outputBin = "dev"; # compilation tools + + postInstall = '' + sed "/^toolsdir=/ctoolsdir=$dev/bin" -i "$dev"/lib/pkgconfig/orc*.pc + ''; + + # https://bugzilla.gnome.org/show_bug.cgi?id=728129#c15 + doCheck = stdenv.hostPlatform.system != "i686-linux"; # not sure about cross-compiling + + meta = with stdenv.lib; { + description = "The Oil Runtime Compiler"; + homepage = https://gstreamer.freedesktop.org/projects/orc.html; + # The source code implementing the Marsenne Twister algorithm is licensed + # under the 3-clause BSD license. The rest is 2-clause BSD license. + license = with licenses; [ bsd3 bsd2 ]; + platforms = platforms.unix; + maintainers = [ maintainers.fuuzetsu ]; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/osl/default.nix b/nixpkgs/pkgs/development/compilers/osl/default.nix new file mode 100644 index 000000000000..a498eafd4254 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/osl/default.nix @@ -0,0 +1,39 @@ +{ clangStdenv, stdenv, fetchFromGitHub, cmake, zlib, openexr, +openimageio, llvm, boost165, flex, bison, partio, pugixml, +utillinux, python +}: + +let boost_static = boost165.override { enableStatic = true; }; +in clangStdenv.mkDerivation rec { + # In theory this could use GCC + Clang rather than just Clang, + # but https://github.com/NixOS/nixpkgs/issues/29877 stops this + name = "openshadinglanguage-${version}"; + version = "1.10.4"; + + src = fetchFromGitHub { + owner = "imageworks"; + repo = "OpenShadingLanguage"; + rev = "Release-1.10.4"; + sha256 = "0qarxlm139y5sb9dd9rrljb2xnz8mvyfj497via6yqgwy90zr26g"; + }; + + cmakeFlags = [ "-DUSE_BOOST_WAVE=ON" "-DENABLERTTI=ON" ]; + enableParallelBuilding = true; + + preConfigure = '' patchShebangs src/liboslexec/serialize-bc.bash ''; + + buildInputs = [ + cmake zlib openexr openimageio llvm + boost_static flex bison partio pugixml + utillinux # needed just for hexdump + python # CMake doesn't check this? + ]; + # TODO: How important is partio? CMake doesn't seem to find it + meta = with stdenv.lib; { + description = "Advanced shading language for production GI renderers"; + homepage = http://opensource.imageworks.com/?p=osl; + maintainers = with maintainers; [ hodapp ]; + license = licenses.bsd3; + platforms = platforms.linux; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/owl-lisp/default.nix b/nixpkgs/pkgs/development/compilers/owl-lisp/default.nix new file mode 100644 index 000000000000..ccd149bbb404 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/owl-lisp/default.nix @@ -0,0 +1,33 @@ +{ stdenv, fetchFromGitHub, coreutils, which }: + +stdenv.mkDerivation rec { + name = "owl-lisp-${version}"; + version = "0.1.16"; + + src = fetchFromGitHub { + owner = "aoh"; + repo = "owl-lisp"; + rev = "v${version}"; + sha256 = "1qp6p48bmlyn83rqi6k3d098dg4cribavg5rd4x17z37i181vxvj"; + }; + + nativeBuildInputs = [ which ]; + + prePatch = '' + substituteInPlace Makefile --replace /usr $out + + for f in tests/run tests/exec.sh ; do + substituteInPlace $f --replace /bin/echo ${coreutils}/bin/echo + done + ''; + + # tests are run as part of the compilation process + doCheck = false; + + meta = with stdenv.lib; { + description = "A functional lisp"; + homepage = https://github.com/aoh/owl-lisp; + license = licenses.mit; + maintainers = with maintainers; [ peterhoeg ]; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/pakcs/curry-base.nix b/nixpkgs/pkgs/development/compilers/pakcs/curry-base.nix new file mode 100644 index 000000000000..2d98699d2836 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/pakcs/curry-base.nix @@ -0,0 +1,16 @@ +{ mkDerivation, base, Cabal, containers, directory, extra, filepath +, mtl, parsec, pretty, stdenv, time, transformers +}: +mkDerivation { + pname = "curry-base"; + version = "1.0.0"; + src = ./.; + libraryHaskellDepends = [ + base containers directory extra filepath mtl parsec pretty time + transformers + ]; + testHaskellDepends = [ base Cabal filepath mtl ]; + homepage = "http://curry-language.org"; + description = "Functions for manipulating Curry programs"; + license = stdenv.lib.licenses.bsd3; +} diff --git a/nixpkgs/pkgs/development/compilers/pakcs/curry-frontend.nix b/nixpkgs/pkgs/development/compilers/pakcs/curry-frontend.nix new file mode 100644 index 000000000000..d94bef9ec7f5 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/pakcs/curry-frontend.nix @@ -0,0 +1,24 @@ +{ mkDerivation, base, Cabal, containers, curry-base, directory +, extra, filepath, mtl, network-uri, pretty, process, set-extra +, stdenv, transformers +}: +mkDerivation { + pname = "curry-frontend"; + version = "1.0.2"; + src = ./.; + isLibrary = true; + isExecutable = true; + enableSeparateDataOutput = true; + libraryHaskellDepends = [ + base containers curry-base directory extra filepath mtl network-uri + pretty process set-extra transformers + ]; + executableHaskellDepends = [ + base containers curry-base directory extra filepath mtl network-uri + pretty process set-extra transformers + ]; + testHaskellDepends = [ base Cabal curry-base filepath ]; + homepage = "http://curry-language.org"; + description = "Compile the functional logic language Curry to several intermediate formats"; + license = stdenv.lib.licenses.bsd3; +} diff --git a/nixpkgs/pkgs/development/compilers/pakcs/default.nix b/nixpkgs/pkgs/development/compilers/pakcs/default.nix new file mode 100644 index 000000000000..a118e7ab73ba --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/pakcs/default.nix @@ -0,0 +1,94 @@ +{ stdenv, fetchurl, makeWrapper +, haskellPackages, haskell +, which, swiProlog, rlwrap, tk +, curl, git, unzip, gnutar, coreutils, sqlite }: + +let + name = "pakcs-2.1.1"; + + # Don't switch to development release without a reason, because its + # source updates without version bump. Prefer current release instead. + src = fetchurl { + url = "https://www.informatik.uni-kiel.de/~pakcs/download/${name}-src.tar.gz"; + sha256 = "112v9ynqfbbm4x770mcfrai9v5bh7c3zn7jka80pv6v4y65r778c"; + }; + + curry-frontend = (haskellPackages.override { + overrides = self: super: { + curry-base = haskell.lib.overrideCabal (super.callPackage ./curry-base.nix {}) (drv: { + inherit src; + postUnpack = "sourceRoot+=/frontend/curry-base"; + }); + curry-frontend = haskell.lib.overrideCabal (super.callPackage ./curry-frontend.nix {}) (drv: { + inherit src; + postUnpack = "sourceRoot+=/frontend/curry-frontend"; + }); + }; + }).curry-frontend; +in stdenv.mkDerivation { + inherit name src; + + buildInputs = [ swiProlog ]; + nativeBuildInputs = [ which makeWrapper ]; + + makeFlags = [ + "CURRYFRONTEND=${curry-frontend}/bin/curry-frontend" + "DISTPKGINSTALL=yes" + # Not needed, just to make script pass + "CURRYTOOLSDIR=0" + "CURRYLIBSDIR=0" + ]; + + preConfigure = '' + # Since we can't expand $out in `makeFlags` + #makeFlags="$makeFlags PAKCSINSTALLDIR=$out/pakcs" + + substituteInPlace currytools/cpm/src/CPM/Repository.curry \ + --replace "/bin/rm" "rm" + ''; + + # cypm new: EXISTENCE ERROR: source_sink + # "/tmp/nix-build-pakcs-2.0.2.drv-0/pakcs-2.0.2/currytools/cpm/templates/LICENSE" + # does not exist + buildPhase = '' + mkdir -p $out/pakcs + cp -r * $out/pakcs + (cd $out/pakcs ; make -j$NIX_BUILD_CORES $makeFlags) + ''; + + installPhase = '' + ln -s $out/pakcs/bin $out + + mkdir -p $out/share/emacs/site-lisp + ln -s $out/pakcs/tools/emacs $out/share/emacs/site-lisp/curry-pakcs + + wrapProgram $out/pakcs/bin/pakcs \ + --prefix PATH ":" "${rlwrap}/bin" \ + --prefix PATH ":" "${tk}/bin" + + # List of dependencies from currytools/cpm/src/CPM/Main.curry + wrapProgram $out/pakcs/bin/cypm \ + --prefix PATH ":" "${stdenv.lib.makeBinPath [ curl git unzip gnutar coreutils sqlite ]}" + ''; + + meta = with stdenv.lib; { + homepage = http://www.informatik.uni-kiel.de/~pakcs/; + description = "An implementation of the multi-paradigm declarative language Curry"; + license = licenses.bsd3; + + longDescription = '' + PAKCS is an implementation of the multi-paradigm declarative language + Curry jointly developed by the Portland State University, the Aachen + University of Technology, and the University of Kiel. Although this is + not a highly optimized implementation but based on a high-level + compilation of Curry programs into Prolog programs, it is not a toy + implementation but has been used for a variety of applications (e.g., + graphical programming environments, an object-oriented front-end for + Curry, partial evaluators, database applications, HTML programming + with dynamic web pages, prototyping embedded systems). + ''; + + maintainers = with maintainers; [ kkallio gnidorah ]; + platforms = platforms.linux; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/pforth/default.nix b/nixpkgs/pkgs/development/compilers/pforth/default.nix new file mode 100644 index 000000000000..7885582ad125 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/pforth/default.nix @@ -0,0 +1,28 @@ +{ stdenv, fetchFromGitHub }: + +stdenv.mkDerivation rec { + version = "28"; + pname = "pforth"; + src = fetchFromGitHub { + owner = "philburk"; + repo = "pforth"; + rev = "9190005e32c6151b76ac707b30eeb4d5d9dd1d36"; + sha256 = "0k3pmcgybsnwrxy75piyb2420r8d4ij190606js32j99062glr3x"; + }; + + makeFlags = [ "SRCDIR=." ]; + makefile = "build/unix/Makefile"; + + installPhase = '' + install -Dm755 pforth_standalone $out/bin/pforth + ''; + + + meta = { + description = "Portable ANSI style Forth written in ANSI C"; + homepage = http://www.softsynth.com/pforth/; + license = stdenv.lib.licenses.publicDomain; + platforms = stdenv.lib.platforms.unix; + maintainers = with stdenv.lib.maintainers; [ yrashk ]; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/picat/default.nix b/nixpkgs/pkgs/development/compilers/picat/default.nix new file mode 100644 index 000000000000..b520a5e703c8 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/picat/default.nix @@ -0,0 +1,38 @@ +{ stdenv, fetchurl }: + +stdenv.mkDerivation { + name = "picat-1.9-4"; + + src = fetchurl { + url = http://picat-lang.org/download/picat19_src.tar.gz; + sha256 = "0wvl95gf4pjs93632g4wi0mw1glzzhjp9g4xg93ll2zxggbxibli"; + }; + + ARCH = if stdenv.hostPlatform.system == "i686-linux" then "linux32" + else if stdenv.hostPlatform.system == "x86_64-linux" then "linux64" + else throw "Unsupported system"; + + hardeningDisable = [ "format" ]; + + buildPhase = '' + cd emu + make -f Makefile.picat.$ARCH + ''; + + installPhase = '' + mkdir -p $out/bin + cp picat_$ARCH $out/bin/picat + ''; + + meta = { + description = "Logic-based programming langage"; + longDescription = '' + Picat is a simple, and yet powerful, logic-based multi-paradigm + programming language aimed for general-purpose applications. + ''; + homepage = http://picat-lang.org/; + license = stdenv.lib.licenses.mpl20; + platforms = stdenv.lib.platforms.linux; + maintainers = [ stdenv.lib.maintainers.earldouglas ]; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/polyml/5.6.nix b/nixpkgs/pkgs/development/compilers/polyml/5.6.nix new file mode 100644 index 000000000000..7f22f4de6244 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/polyml/5.6.nix @@ -0,0 +1,33 @@ +{stdenv, fetchurl, autoreconfHook}: + +let + version = "5.6"; +in + +stdenv.mkDerivation { + name = "polyml-${version}"; + + prePatch = stdenv.lib.optionalString stdenv.isDarwin '' + substituteInPlace configure.ac --replace stdc++ c++ + ''; + + buildInputs = stdenv.lib.optional stdenv.isDarwin autoreconfHook; + + src = fetchurl { + url = "mirror://sourceforge/polyml/polyml.${version}.tar.gz"; + sha256 = "05d6l2a5m9jf32a8kahwg2p2ph4x9rjf1nsl83331q3gwn5bkmr0"; + }; + + meta = { + description = "Standard ML compiler and interpreter"; + longDescription = '' + Poly/ML is a full implementation of Standard ML. + ''; + homepage = https://www.polyml.org/; + license = stdenv.lib.licenses.lgpl21; + platforms = with stdenv.lib.platforms; linux; + maintainers = [ #Add your name here! + stdenv.lib.maintainers.z77z + ]; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/polyml/5.7.nix b/nixpkgs/pkgs/development/compilers/polyml/5.7.nix new file mode 100644 index 000000000000..b7feed84c37f --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/polyml/5.7.nix @@ -0,0 +1,38 @@ +{ stdenv, fetchFromGitHub, autoreconfHook, gmp, libffi }: + +stdenv.mkDerivation rec { + name = "polyml-${version}"; + version = "5.7.1"; + + prePatch = stdenv.lib.optionalString stdenv.isDarwin '' + substituteInPlace configure.ac --replace stdc++ c++ + ''; + + buildInputs = [ libffi gmp ]; + + nativeBuildInputs = stdenv.lib.optional stdenv.isDarwin autoreconfHook; + + configureFlags = [ + "--enable-shared" + "--with-system-libffi" + "--with-gmp" + ]; + + src = fetchFromGitHub { + owner = "polyml"; + repo = "polyml"; + rev = "v${version}"; + sha256 = "0j0wv3ijfrjkfngy7dswm4k1dchk3jak9chl5735dl8yrl8mq755"; + }; + + meta = with stdenv.lib; { + description = "Standard ML compiler and interpreter"; + longDescription = '' + Poly/ML is a full implementation of Standard ML. + ''; + homepage = https://www.polyml.org/; + license = licenses.lgpl21; + platforms = with platforms; (linux ++ darwin); + maintainers = with maintainers; [ z77z yurrriq ]; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/polyml/default.nix b/nixpkgs/pkgs/development/compilers/polyml/default.nix new file mode 100644 index 000000000000..91a3bb45352f --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/polyml/default.nix @@ -0,0 +1,38 @@ +{ stdenv, fetchFromGitHub, autoreconfHook, gmp, libffi }: + +stdenv.mkDerivation rec { + name = "polyml-${version}"; + version = "5.8"; + + prePatch = stdenv.lib.optionalString stdenv.isDarwin '' + substituteInPlace configure.ac --replace stdc++ c++ + ''; + + buildInputs = [ libffi gmp ]; + + nativeBuildInputs = stdenv.lib.optional stdenv.isDarwin autoreconfHook; + + configureFlags = [ + "--enable-shared" + "--with-system-libffi" + "--with-gmp" + ]; + + src = fetchFromGitHub { + owner = "polyml"; + repo = "polyml"; + rev = "v${version}"; + sha256 = "1s7q77bivppxa4vd7gxjj5dbh66qnirfxnkzh1ql69rfx1c057n3"; + }; + + meta = with stdenv.lib; { + description = "Standard ML compiler and interpreter"; + longDescription = '' + Poly/ML is a full implementation of Standard ML. + ''; + homepage = https://www.polyml.org/; + license = licenses.lgpl21; + platforms = with platforms; (linux ++ darwin); + maintainers = with maintainers; [ z77z yurrriq ]; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/ponyc/default.nix b/nixpkgs/pkgs/development/compilers/ponyc/default.nix new file mode 100644 index 000000000000..749fbcc2fafb --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/ponyc/default.nix @@ -0,0 +1,79 @@ +{ stdenv, fetchFromGitHub, llvm, makeWrapper, pcre2, coreutils, which, libressl, + cc ? stdenv.cc, lto ? !stdenv.isDarwin }: + +stdenv.mkDerivation ( rec { + pname = "ponyc"; + version = "0.28.0"; + + src = fetchFromGitHub { + owner = "ponylang"; + repo = pname; + rev = version; + sha256 = "011qxhiq75j6d37ws4nb6a8bdfw2cvlcsb2fgdkn1hx2xb81h6wc"; + }; + + buildInputs = [ llvm makeWrapper which ]; + propagatedBuildInputs = [ cc ]; + + # Disable problematic networking tests + patches = [ ./disable-tests.patch ]; + + preBuild = '' + # Fix tests + substituteInPlace packages/process/_test.pony \ + --replace '"/bin/' '"${coreutils}/bin/' + substituteInPlace packages/process/_test.pony \ + --replace '=/bin' "${coreutils}/bin" + + # Remove impure system refs + substituteInPlace src/libponyc/pkg/package.c \ + --replace "/usr/local/lib" "" \ + --replace "/opt/local/lib" "" + + for file in `grep -irl '/usr/local/opt/libressl/lib' ./*`; do + substituteInPlace $file --replace '/usr/local/opt/libressl/lib' "${stdenv.lib.getLib libressl}/lib" + done + + export LLVM_CONFIG=${llvm}/bin/llvm-config + '' + stdenv.lib.optionalString ((!stdenv.isDarwin) && (!cc.isClang) && lto) '' + export LTO_PLUGIN=`find ${cc.cc}/ -name liblto_plugin.so` + '' + stdenv.lib.optionalString ((!stdenv.isDarwin) && (cc.isClang) && lto) '' + export LTO_PLUGIN=`find ${cc.cc}/ -name LLVMgold.so` + ''; + + makeFlags = [ "config=release" ] ++ stdenv.lib.optionals stdenv.isDarwin [ "bits=64" ] + ++ stdenv.lib.optionals (stdenv.isDarwin && (!lto)) [ "lto=no" ]; + + enableParallelBuilding = true; + + doCheck = true; + + checkTarget = "test-ci"; + + preCheck = '' + export PONYPATH="$out/lib:${stdenv.lib.makeLibraryPath [ pcre2 libressl ]}" + ''; + + installPhase = '' + make config=release prefix=$out '' + + stdenv.lib.optionalString stdenv.isDarwin '' bits=64 '' + + stdenv.lib.optionalString (stdenv.isDarwin && (!lto)) '' lto=no '' + + '' install + + wrapProgram $out/bin/ponyc \ + --prefix PATH ":" "${stdenv.cc}/bin" \ + --set-default CC "$CC" \ + --prefix PONYPATH : "${stdenv.lib.makeLibraryPath [ pcre2 libressl (placeholder "out") ]}" + ''; + + # Stripping breaks linking for ponyc + dontStrip = true; + + meta = with stdenv.lib; { + description = "Pony is an Object-oriented, actor-model, capabilities-secure, high performance programming language"; + homepage = https://www.ponylang.org; + license = licenses.bsd2; + maintainers = with maintainers; [ doublec kamilchm patternspandemic ]; + platforms = [ "x86_64-linux" "x86_64-darwin" ]; + }; +}) diff --git a/nixpkgs/pkgs/development/compilers/ponyc/disable-tests.patch b/nixpkgs/pkgs/development/compilers/ponyc/disable-tests.patch new file mode 100644 index 000000000000..f8c996137af9 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/ponyc/disable-tests.patch @@ -0,0 +1,14 @@ +diff --git a/packages/net/_test.pony b/packages/net/_test.pony +index baf29e7..b63f368 100644 +--- a/packages/net/_test.pony ++++ b/packages/net/_test.pony +@@ -5,9 +5,6 @@ actor Main is TestList + new make() => None + + fun tag tests(test: PonyTest) => +- ifdef not osx then +- test(_TestBroadcast) +- end + test(_TestTCPWritev) + test(_TestTCPExpect) + test(_TestTCPMute) diff --git a/nixpkgs/pkgs/development/compilers/ponyc/pony-stable.nix b/nixpkgs/pkgs/development/compilers/ponyc/pony-stable.nix new file mode 100644 index 000000000000..821a9b8125cd --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/ponyc/pony-stable.nix @@ -0,0 +1,25 @@ +{stdenv, fetchFromGitHub, ponyc }: + +stdenv.mkDerivation rec { + name = "pony-stable-${version}"; + version = "0.2.0"; + + src = fetchFromGitHub { + owner = "ponylang"; + repo = "pony-stable"; + rev = version; + sha256 = "0zzcq0vsl6kcrsxwqzd3s9mq7aq5sg8si5c83rxyi9n6a06gnbh7"; + }; + + buildInputs = [ ponyc ]; + + installFlags = [ "prefix=${placeholder "out"}" "install" ]; + + meta = { + description = "A simple dependency manager for the Pony language."; + homepage = https://www.ponylang.org; + license = stdenv.lib.licenses.bsd2; + maintainers = with stdenv.lib.maintainers; [ dipinhora kamilchm patternspandemic ]; + platforms = stdenv.lib.platforms.unix; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/purescript/psc-package/default.nix b/nixpkgs/pkgs/development/compilers/purescript/psc-package/default.nix new file mode 100644 index 000000000000..68b676d5a3ef --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/purescript/psc-package/default.nix @@ -0,0 +1,27 @@ +{ haskellPackages, mkDerivation, fetchFromGitHub, lib }: + +with lib; + +mkDerivation rec { + pname = "psc-package"; + version = "0.5.1"; + + src = fetchFromGitHub { + owner = "purescript"; + repo = pname; + rev = "v${version}"; + sha256 = "1zadbph1vha3b5hvmjvs138dcwbab49f3v63air1l6r4cvpb6831"; + }; + + isLibrary = false; + isExecutable = true; + + executableHaskellDepends = with haskellPackages; [ + aeson aeson-pretty either errors optparse-applicative + system-filepath turtle + ]; + + description = "A package manager for PureScript based on package sets"; + license = licenses.bsd3; + maintainers = with lib.maintainers; [ Profpatsch ]; +} diff --git a/nixpkgs/pkgs/development/compilers/purescript/purescript/default.nix b/nixpkgs/pkgs/development/compilers/purescript/purescript/default.nix new file mode 100644 index 000000000000..67818bfa1dc9 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/purescript/purescript/default.nix @@ -0,0 +1,60 @@ +{ stdenv, fetchurl, zlib, gmp, ncurses5, lib }: + +# from justinwoo/easy-purescript-nix +# https://github.com/justinwoo/easy-purescript-nix/blob/d383972c82620a712ead4033db14110497bc2c9c/purs.nix + +let + dynamic-linker = stdenv.cc.bintools.dynamicLinker; + + patchelf = libPath : + if stdenv.isDarwin + then "" + else + '' + chmod u+w $PURS + patchelf --interpreter ${dynamic-linker} --set-rpath ${libPath} $PURS + chmod u-w $PURS + ''; + +in stdenv.mkDerivation rec { + pname = "purescript"; + version = "0.12.5"; + + src = + if stdenv.isDarwin + then + fetchurl { + url = "https://github.com/${pname}/${pname}/releases/download/v${version}/macos.tar.gz"; + sha256 = "15j9lkrl15dicx37bmh0199b3qdixig7w24wvdzi20jqbacz8nkn"; + } + else + fetchurl { + url = "https://github.com/${pname}/${pname}/releases/download/v${version}/linux64.tar.gz"; + sha256 = "07dva5gxq77g787krscv4dsz5088fzkvpmm9fwxw9a59jszzs7kq"; + }; + + + buildInputs = [ zlib + gmp + ncurses5 ]; + libPath = lib.makeLibraryPath buildInputs; + dontStrip = true; + + installPhase = '' + mkdir -p $out/bin + PURS="$out/bin/purs" + + install -D -m555 -T purs $PURS + ${patchelf libPath} + + mkdir -p $out/etc/bash_completion.d/ + $PURS --bash-completion-script $PURS > $out/etc/bash_completion.d/purs-completion.bash + ''; + meta = with stdenv.lib; { + description = "A strongly-typed functional programming language that compiles to JavaScript"; + homepage = http://www.purescript.org/; + license = licenses.bsd3; + maintainers = [ maintainers.justinwoo ]; + platforms = [ "x86_64-linux" "x86_64-darwin" ]; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/reason/default.nix b/nixpkgs/pkgs/development/compilers/reason/default.nix new file mode 100644 index 000000000000..1b84b9348520 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/reason/default.nix @@ -0,0 +1,39 @@ +{ stdenv, makeWrapper, fetchFromGitHub, ocaml, findlib, dune +, menhir, merlin_extend, ppx_tools_versioned, utop +}: + +stdenv.mkDerivation rec { + name = "ocaml${ocaml.version}-reason-${version}"; + version = "3.3.7"; + + src = fetchFromGitHub { + owner = "facebook"; + repo = "reason"; + rev = "4d20e5b535c29c5ef1283e65958b32996e449e5a"; + sha256 = "0f3pb61wg58g8f3wcnp1h4gpmnwmp7bq0cnqdfwldmh9cs0dqyfk"; + }; + + nativeBuildInputs = [ makeWrapper ]; + + propagatedBuildInputs = [ menhir merlin_extend ppx_tools_versioned ]; + + buildInputs = [ ocaml findlib dune utop menhir ]; + + buildFlags = [ "build" ]; # do not "make tests" before reason lib is installed + + inherit (dune) installPhase; + + postInstall = '' + wrapProgram $out/bin/rtop \ + --prefix PATH : "${utop}/bin" \ + --set OCAMLPATH $out/lib/ocaml/${ocaml.version}/site-lib:$OCAMLPATH + ''; + + meta = with stdenv.lib; { + homepage = https://reasonml.github.io/; + description = "Facebook's friendly syntax to OCaml"; + license = licenses.mit; + inherit (ocaml.meta) platforms; + maintainers = [ maintainers.volth ]; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/rgbds/default.nix b/nixpkgs/pkgs/development/compilers/rgbds/default.nix new file mode 100644 index 000000000000..f883500eeb9f --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/rgbds/default.nix @@ -0,0 +1,22 @@ +{stdenv, fetchFromGitHub, yacc}: + +stdenv.mkDerivation rec { + name = "rgbds-${version}"; + version = "0.2.4"; + src = fetchFromGitHub { + owner = "bentley"; + repo = "rgbds"; + rev = "v${version}"; + sha256 = "0dwq0p9g1lci8sm12a2rfk0g33z2vr75x78zdf1g84djwbz8ipc6"; + }; + nativeBuildInputs = [ yacc ]; + installFlags = "PREFIX=\${out}"; + + meta = with stdenv.lib; { + homepage = https://www.anjbe.name/rgbds/; + description = "An assembler/linker package that produces Game Boy programs"; + license = licenses.free; + maintainers = with maintainers; [ matthewbauer ]; + platforms = platforms.all; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/rust/binaryBuild.nix b/nixpkgs/pkgs/development/compilers/rust/binaryBuild.nix new file mode 100644 index 000000000000..77dba7f9e620 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/rust/binaryBuild.nix @@ -0,0 +1,115 @@ +{ stdenv, makeWrapper, bash, curl, darwin +, version +, src +, platform +, versionType +}: + +let + inherit (stdenv.lib) optionalString; + inherit (darwin.apple_sdk.frameworks) Security; + + bootstrapping = versionType == "bootstrap"; + + installComponents + = "rustc,rust-std-${platform}" + + (optionalString bootstrapping ",cargo") + ; +in + +rec { + rustc = stdenv.mkDerivation rec { + name = "rustc-${versionType}-${version}"; + + inherit version; + inherit src; + + meta = with stdenv.lib; { + homepage = http://www.rust-lang.org/; + description = "A safe, concurrent, practical language"; + maintainers = with maintainers; [ qknight ]; + license = [ licenses.mit licenses.asl20 ]; + }; + + buildInputs = [ bash ] ++ stdenv.lib.optional stdenv.isDarwin Security; + + postPatch = '' + patchShebangs . + ''; + + installPhase = '' + ./install.sh --prefix=$out \ + --components=${installComponents} + + ${optionalString (stdenv.isLinux && bootstrapping) '' + patchelf \ + --set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) \ + "$out/bin/rustc" + patchelf \ + --set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) \ + "$out/bin/rustdoc" + patchelf \ + --set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) \ + "$out/bin/cargo" + ''} + + ${optionalString (stdenv.isDarwin && bootstrapping) '' + install_name_tool -change /usr/lib/libresolv.9.dylib '${darwin.libresolv}/lib/libresolv.9.dylib' "$out/bin/rustc" + install_name_tool -change /usr/lib/libresolv.9.dylib '${darwin.libresolv}/lib/libresolv.9.dylib' "$out/bin/rustdoc" + install_name_tool -change /usr/lib/libiconv.2.dylib '${darwin.libiconv}/lib/libiconv.2.dylib' "$out/bin/cargo" + install_name_tool -change /usr/lib/libresolv.9.dylib '${darwin.libresolv}/lib/libresolv.9.dylib' "$out/bin/cargo" + install_name_tool -change /usr/lib/libcurl.4.dylib '${stdenv.lib.getLib curl}/lib/libcurl.4.dylib' "$out/bin/cargo" + for f in $out/lib/lib*.dylib; do + install_name_tool -change /usr/lib/libresolv.9.dylib '${darwin.libresolv}/lib/libresolv.9.dylib' "$f" + done + ''} + + # Do NOT, I repeat, DO NOT use `wrapProgram` on $out/bin/rustc + # (or similar) here. It causes strange effects where rustc loads + # the wrong libraries in a bootstrap-build causing failures that + # are very hard to track down. For details, see + # https://github.com/rust-lang/rust/issues/34722#issuecomment-232164943 + ''; + }; + + cargo = stdenv.mkDerivation rec { + name = "cargo-${versionType}-${version}"; + + inherit version; + inherit src; + + meta = with stdenv.lib; { + homepage = http://www.rust-lang.org/; + description = "A safe, concurrent, practical language"; + maintainers = with maintainers; [ qknight ]; + license = [ licenses.mit licenses.asl20 ]; + }; + + buildInputs = [ makeWrapper bash ] ++ stdenv.lib.optional stdenv.isDarwin Security; + + postPatch = '' + patchShebangs . + ''; + + installPhase = '' + patchShebangs ./install.sh + ./install.sh --prefix=$out \ + --components=cargo + + ${optionalString (stdenv.isLinux && bootstrapping) '' + patchelf \ + --set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) \ + "$out/bin/cargo" + ''} + + ${optionalString (stdenv.isDarwin && bootstrapping) '' + install_name_tool -change /usr/lib/libiconv.2.dylib '${darwin.libiconv}/lib/libiconv.2.dylib' "$out/bin/cargo" + install_name_tool -change /usr/lib/libresolv.9.dylib '${darwin.libresolv}/lib/libresolv.9.dylib' "$out/bin/cargo" + install_name_tool -change /usr/lib/libcurl.4.dylib '${stdenv.lib.getLib curl}/lib/libcurl.4.dylib' "$out/bin/cargo" + ''} + + wrapProgram "$out/bin/cargo" \ + --suffix PATH : "${rustc}/bin" + ''; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/rust/bootstrap.nix b/nixpkgs/pkgs/development/compilers/rust/bootstrap.nix new file mode 100644 index 000000000000..b3446436179d --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/rust/bootstrap.nix @@ -0,0 +1,41 @@ +{ stdenv, fetchurl, callPackage }: + +let + # Note: the version MUST be one version prior to the version we're + # building + version = "1.33.0"; + + # fetch hashes by running `print-hashes.sh 1.33.0` + hashes = { + i686-unknown-linux-gnu = "c379203687d98e60623aa88c4df4992dd5a9548bc30674b9fc8e671a979e9f3a"; + x86_64-unknown-linux-gnu = "6623168b9ee9de79deb0d9274c577d741ea92003768660aca184e04fe774393f"; + armv7-unknown-linux-gnueabihf = "f6f0ec0a98d922c4bfd79703bc9e9eef439ba347453f33608a87cd63c47e7245"; + aarch64-unknown-linux-gnu = "a308044e4076b62f637313ea803fa0a8f340b0f1b53136856f2c43afcabe5387"; + i686-apple-darwin = "ed20809d56bbaea041721ce6fc9f10f7ae7a720c5821587f01a537d07a5454b1"; + x86_64-apple-darwin = "864e7c074a0b88e38883c87c169513d072300bb52e1d320a067bd34cf14f66bd"; + }; + + platform = + if stdenv.hostPlatform.system == "i686-linux" + then "i686-unknown-linux-gnu" + else if stdenv.hostPlatform.system == "x86_64-linux" + then "x86_64-unknown-linux-gnu" + else if stdenv.hostPlatform.system == "armv7l-linux" + then "armv7-unknown-linux-gnueabihf" + else if stdenv.hostPlatform.system == "aarch64-linux" + then "aarch64-unknown-linux-gnu" + else if stdenv.hostPlatform.system == "i686-darwin" + then "i686-apple-darwin" + else if stdenv.hostPlatform.system == "x86_64-darwin" + then "x86_64-apple-darwin" + else throw "missing bootstrap url for platform ${stdenv.hostPlatform.system}"; + + src = fetchurl { + url = "https://static.rust-lang.org/dist/rust-${version}-${platform}.tar.gz"; + sha256 = hashes."${platform}"; + }; + +in callPackage ./binaryBuild.nix + { inherit version src platform; + versionType = "bootstrap"; + } diff --git a/nixpkgs/pkgs/development/compilers/rust/cargo.nix b/nixpkgs/pkgs/development/compilers/rust/cargo.nix new file mode 100644 index 000000000000..9f576042787a --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/rust/cargo.nix @@ -0,0 +1,63 @@ +{ stdenv, file, curl, pkgconfig, python, openssl, cmake, zlib +, makeWrapper, libiconv, cacert, rustPlatform, rustc, libgit2 +, CoreFoundation, Security +}: + +rustPlatform.buildRustPackage rec { + name = "cargo-${rustc.version}"; + inherit (rustc) version src; + + # the rust source tarball already has all the dependencies vendored, no need to fetch them again + cargoVendorDir = "vendor"; + preBuild = "pushd src/tools/cargo"; + postBuild = "popd"; + + passthru.rustc = rustc; + + # changes hash of vendor directory otherwise + dontUpdateAutotoolsGnuConfigScripts = true; + + nativeBuildInputs = [ pkgconfig cmake makeWrapper ]; + buildInputs = [ cacert file curl python openssl zlib libgit2 ] + ++ stdenv.lib.optionals stdenv.isDarwin [ CoreFoundation Security libiconv ]; + + LIBGIT2_SYS_USE_PKG_CONFIG = 1; + + # fixes: the cargo feature `edition` requires a nightly version of Cargo, but this is the `stable` channel + RUSTC_BOOTSTRAP = 1; + + # FIXME: Use impure version of CoreFoundation because of missing symbols. + # CFURLSetResourcePropertyForKey is defined in the headers but there's no + # corresponding implementation in the sources from opensource.apple.com. + preConfigure = stdenv.lib.optionalString stdenv.isDarwin '' + export NIX_CFLAGS_COMPILE="-F${CoreFoundation}/Library/Frameworks $NIX_CFLAGS_COMPILE" + ''; + + postInstall = '' + # NOTE: We override the `http.cainfo` option usually specified in + # `.cargo/config`. This is an issue when users want to specify + # their own certificate chain as environment variables take + # precedence + wrapProgram "$out/bin/cargo" \ + --suffix PATH : "${rustc}/bin" \ + --set CARGO_HTTP_CAINFO "${cacert}/etc/ssl/certs/ca-bundle.crt" \ + --set SSL_CERT_FILE "${cacert}/etc/ssl/certs/ca-bundle.crt" + ''; + + checkPhase = '' + # Disable cross compilation tests + export CFG_DISABLE_CROSS_TESTS=1 + cargo test + ''; + + # Disable check phase as there are failures (4 tests fail) + doCheck = false; + + meta = with stdenv.lib; { + homepage = https://crates.io; + description = "Downloads your Rust project's dependencies and builds your project"; + maintainers = with maintainers; [ wizeman retrry ]; + license = [ licenses.mit licenses.asl20 ]; + platforms = platforms.unix; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/rust/default.nix b/nixpkgs/pkgs/development/compilers/rust/default.nix new file mode 100644 index 000000000000..47df7e716dc1 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/rust/default.nix @@ -0,0 +1,62 @@ +{ stdenv, lib, overrideCC +, buildPackages +, newScope, callPackage +, CoreFoundation, Security +}: rec { + makeRustPlatform = { rustc, cargo, ... }: { + rust = { + inherit rustc cargo; + }; + + buildRustPackage = callPackage ../../../build-support/rust { + inherit rustc cargo; + + fetchcargo = buildPackages.callPackage ../../../build-support/rust/fetchcargo.nix { + inherit cargo; + }; + }; + + rustcSrc = callPackage ./rust-src.nix { + inherit rustc; + }; + }; + + # This just contains tools for now. But it would conceivably contain + # libraries too, say if we picked some default/recommended versions from + # `cratesIO` to build by Hydra and/or try to prefer/bias in Cargo.lock for + # all vendored Carnix-generated nix. + # + # In the end game, rustc, the rust standard library (`core`, `std`, etc.), + # and cargo would themselves be built with `buildRustCreate` like + # everything else. Tools and `build.rs` and procedural macro dependencies + # would be taken from `buildRustPackages` (and `bootstrapRustPackages` for + # anything provided prebuilt or their build-time dependencies to break + # cycles / purify builds). In this way, nixpkgs would be in control of all + # bootstrapping. + packages = { + prebuilt = callPackage ./bootstrap.nix {}; + stable = lib.makeScope newScope (self: let + # Like `buildRustPackages`, but may also contain prebuilt binaries to + # break cycle. Just like `bootstrapTools` for nixpkgs as a whole, + # nothing in the final package set should refer to this. + bootstrapRustPackages = self.buildRustPackages.overrideScope' (_: _: + lib.optionalAttrs (stdenv.buildPlatform == stdenv.hostPlatform) + buildPackages.rust.packages.prebuilt); + bootRustPlatform = makeRustPlatform bootstrapRustPackages; + in { + # Packages suitable for build-time, e.g. `build.rs`-type stuff. + buildRustPackages = buildPackages.rust.packages.stable; + # Analogous to stdenv + rustPlatform = makeRustPlatform self.buildRustPackages; + rustc = self.callPackage ./rustc.nix { + # Use boot package set to break cycle + rustPlatform = bootRustPlatform; + }; + cargo = self.callPackage ./cargo.nix { + # Use boot package set to break cycle + rustPlatform = bootRustPlatform; + inherit CoreFoundation Security; + }; + }); + }; +} diff --git a/nixpkgs/pkgs/development/compilers/rust/patches/net-tcp-disable-tests.patch b/nixpkgs/pkgs/development/compilers/rust/patches/net-tcp-disable-tests.patch new file mode 100644 index 000000000000..1bb9a98f7b6d --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/rust/patches/net-tcp-disable-tests.patch @@ -0,0 +1,96 @@ +diff --git a/src/libstd/net/tcp.rs b/src/libstd/net/tcp.rs +index 86ecb10edf..626be0a52d 100644 +--- a/src/libstd/net/tcp.rs ++++ b/src/libstd/net/tcp.rs +@@ -955,6 +955,7 @@ mod tests { + } + } + ++ #[cfg_attr(target_os = "macos", ignore)] + #[test] + fn listen_localhost() { + let socket_addr = next_test_ip4(); +@@ -1013,6 +1014,7 @@ mod tests { + }) + } + ++ #[cfg_attr(target_os = "macos", ignore)] + #[test] + fn read_eof() { + each_ip(&mut |addr| { +@@ -1032,6 +1034,7 @@ mod tests { + }) + } + ++ #[cfg_attr(target_os = "macos", ignore)] + #[test] + fn write_close() { + each_ip(&mut |addr| { +@@ -1058,6 +1061,7 @@ mod tests { + }) + } + ++ #[cfg_attr(target_os = "macos", ignore)] + #[test] + fn multiple_connect_serial() { + each_ip(&mut |addr| { +@@ -1080,6 +1084,7 @@ mod tests { + }) + } + ++ #[cfg_attr(target_os = "macos", ignore)] + #[test] + fn multiple_connect_interleaved_greedy_schedule() { + const MAX: usize = 10; +@@ -1116,6 +1121,7 @@ mod tests { + } + + #[test] ++ #[cfg_attr(target_os = "macos", ignore)] + fn multiple_connect_interleaved_lazy_schedule() { + const MAX: usize = 10; + each_ip(&mut |addr| { +@@ -1394,6 +1400,7 @@ mod tests { + } + + #[test] ++ #[cfg_attr(target_os = "macos", ignore)] + fn clone_while_reading() { + each_ip(&mut |addr| { + let accept = t!(TcpListener::bind(&addr)); +@@ -1504,7 +1511,10 @@ mod tests { + + // FIXME: re-enabled bitrig/openbsd tests once their socket timeout code + // no longer has rounding errors. +- #[cfg_attr(any(target_os = "bitrig", target_os = "netbsd", target_os = "openbsd"), ignore)] ++ #[cfg_attr(any(target_os = "bitrig", ++ target_os = "netbsd", ++ target_os = "openbsd", ++ target_os = "macos"), ignore)] + #[test] + fn timeouts() { + let addr = next_test_ip4(); +@@ -1591,6 +1601,7 @@ mod tests { + drop(listener); + } + ++ #[cfg_attr(target_os = "macos", ignore)] + #[test] + fn nodelay() { + let addr = next_test_ip4(); +@@ -1605,6 +1616,7 @@ mod tests { + assert_eq!(false, t!(stream.nodelay())); + } + ++ #[cfg_attr(target_os = "macos", ignore)] + #[test] + fn ttl() { + let ttl = 100; +@@ -1642,6 +1654,7 @@ mod tests { + } + } + ++ #[cfg_attr(target_os = "macos", ignore)] + #[test] + fn peek() { + each_ip(&mut |addr| { diff --git a/nixpkgs/pkgs/development/compilers/rust/patches/stdsimd-disable-doctest.patch b/nixpkgs/pkgs/development/compilers/rust/patches/stdsimd-disable-doctest.patch new file mode 100644 index 000000000000..6ef7fd0f7ce4 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/rust/patches/stdsimd-disable-doctest.patch @@ -0,0 +1,20 @@ +diff --git a/src/stdsimd/coresimd/x86/mod.rs b/src/stdsimd/coresimd/x86/mod.rs +index 32915c332..7cb54f31e 100644 +--- a/src/stdsimd/coresimd/x86/mod.rs ++++ b/src/stdsimd/coresimd/x86/mod.rs +@@ -279,7 +279,6 @@ types! { + /// + /// # Examples + /// +- /// ``` + /// # #![feature(cfg_target_feature, target_feature, stdsimd)] + /// # #![cfg_attr(not(dox), no_std)] + /// # #[cfg(not(dox))] +@@ -301,7 +300,6 @@ types! { + /// # } + /// # if is_x86_feature_detected!("sse") { unsafe { foo() } } + /// # } +- /// ``` + pub struct __m256(f32, f32, f32, f32, f32, f32, f32, f32); + + /// 256-bit wide set of four `f64` types, x86-specific diff --git a/nixpkgs/pkgs/development/compilers/rust/print-hashes.sh b/nixpkgs/pkgs/development/compilers/rust/print-hashes.sh new file mode 100755 index 000000000000..7eb00a30ad73 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/rust/print-hashes.sh @@ -0,0 +1,38 @@ +#!/usr/bin/env bash +set -euo pipefail + +# All rust-related downloads can be found at +# https://static.rust-lang.org/dist/index.html. To find the date on +# which a particular thing was last updated, look for the *-date.txt +# file, e.g. +# https://static.rust-lang.org/dist/channel-rust-beta-date.txt + +PLATFORMS=( + i686-unknown-linux-gnu + x86_64-unknown-linux-gnu + armv7-unknown-linux-gnueabihf + aarch64-unknown-linux-gnu + i686-apple-darwin + x86_64-apple-darwin +) +BASEURL=https://static.rust-lang.org/dist +VERSION=${1:-} +DATE=${2:-} + +if [[ -z $VERSION ]] +then + echo "No version supplied" + exit -1 +fi + +if [[ -n $DATE ]] +then + BASEURL=$BASEURL/$DATE +fi + +for PLATFORM in "${PLATFORMS[@]}" +do + URL="$BASEURL/rust-$VERSION-$PLATFORM.tar.gz.sha256" + SHA256=$(curl -sSfL $URL | cut -d ' ' -f 1) + echo "$PLATFORM = \"$SHA256\";" +done diff --git a/nixpkgs/pkgs/development/compilers/rust/rust-src.nix b/nixpkgs/pkgs/development/compilers/rust/rust-src.nix new file mode 100644 index 000000000000..1b819a7f6068 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/rust/rust-src.nix @@ -0,0 +1,11 @@ +{ stdenv, rustc }: + +stdenv.mkDerivation { + name = "rust-src"; + src = rustc.src; + phases = [ "unpackPhase" "installPhase" ]; + installPhase = '' + mv src $out + rm -rf $out/{ci,doc,driver,etc,grammar,llvm,rt,rtstartup,rustllvm,test,tools,vendor} + ''; +} diff --git a/nixpkgs/pkgs/development/compilers/rust/rustc.nix b/nixpkgs/pkgs/development/compilers/rust/rustc.nix new file mode 100644 index 000000000000..9b9800431005 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/rust/rustc.nix @@ -0,0 +1,218 @@ +{ stdenv, removeReferencesTo, pkgsBuildBuild, pkgsBuildHost, pkgsBuildTarget +, fetchurl, fetchgit, fetchzip, file, python2, tzdata, ps +, llvm_7, ncurses, darwin, git, cmake, curl, rustPlatform +, which, libffi, gdb +, withBundledLLVM ? false +}: + +let + inherit (stdenv.lib) optional optionalString; + inherit (darwin.apple_sdk.frameworks) Security; + + llvmSharedForBuild = pkgsBuildBuild.llvm_7.override { enableSharedLibraries = true; }; + llvmSharedForHost = pkgsBuildHost.llvm_7.override { enableSharedLibraries = true; }; + llvmSharedForTarget = pkgsBuildTarget.llvm_7.override { enableSharedLibraries = true; }; + + # For use at runtime + llvmShared = llvm_7.override { enableSharedLibraries = true; }; +in stdenv.mkDerivation rec { + pname = "rustc"; + version = "1.34.0"; + + src = fetchurl { + url = "https://static.rust-lang.org/dist/rustc-${version}-src.tar.gz"; + sha256 = "0n8z1wngkxab1rvixqg6w8b727hzpnm9wp9h8iy3mpbrzp7mmj3s"; + }; + + __darwinAllowLocalNetworking = true; + + # rustc complains about modified source files otherwise + dontUpdateAutotoolsGnuConfigScripts = true; + + # Running the default `strip -S` command on Darwin corrupts the + # .rlib files in "lib/". + # + # See https://github.com/NixOS/nixpkgs/pull/34227 + # + # Running `strip -S` when cross compiling can harm the cross rlibs. + # See: https://github.com/NixOS/nixpkgs/pull/56540#issuecomment-471624656 + stripDebugList = [ "bin" ]; + + + NIX_LDFLAGS = + # when linking stage1 libstd: cc: undefined reference to `__cxa_begin_catch' + optional (stdenv.isLinux && !withBundledLLVM) "--push-state --as-needed -lstdc++ --pop-state" + ++ optional (stdenv.isDarwin && !withBundledLLVM) "-lc++" + ++ optional stdenv.isDarwin "-rpath ${llvmSharedForHost}/lib"; + + # Enable nightly features in stable compiles (used for + # bootstrapping, see https://github.com/rust-lang/rust/pull/37265). + # This loosens the hard restrictions on bootstrapping-compiler + # versions. + RUSTC_BOOTSTRAP = "1"; + + # Increase codegen units to introduce parallelism within the compiler. + RUSTFLAGS = "-Ccodegen-units=10"; + + # We need rust to build rust. If we don't provide it, configure will try to download it. + # Reference: https://github.com/rust-lang/rust/blob/master/src/bootstrap/configure.py + configureFlags = let + setBuild = "--set=target.${stdenv.buildPlatform.config}"; + setHost = "--set=target.${stdenv.hostPlatform.config}"; + setTarget = "--set=target.${stdenv.targetPlatform.config}"; + ccForBuild = "${pkgsBuildBuild.targetPackages.stdenv.cc}/bin/${pkgsBuildBuild.targetPackages.stdenv.cc.targetPrefix}cc"; + cxxForBuild = "${pkgsBuildBuild.targetPackages.stdenv.cc}/bin/${pkgsBuildBuild.targetPackages.stdenv.cc.targetPrefix}c++"; + ccForHost = "${pkgsBuildHost.targetPackages.stdenv.cc}/bin/${pkgsBuildHost.targetPackages.stdenv.cc.targetPrefix}cc"; + cxxForHost = "${pkgsBuildHost.targetPackages.stdenv.cc}/bin/${pkgsBuildHost.targetPackages.stdenv.cc.targetPrefix}c++"; + ccForTarget = "${pkgsBuildTarget.targetPackages.stdenv.cc}/bin/${pkgsBuildTarget.targetPackages.stdenv.cc.targetPrefix}cc"; + cxxForTarget = "${pkgsBuildTarget.targetPackages.stdenv.cc}/bin/${pkgsBuildTarget.targetPackages.stdenv.cc.targetPrefix}c++"; + in [ + "--release-channel=stable" + "--set=build.rustc=${rustPlatform.rust.rustc}/bin/rustc" + "--set=build.cargo=${rustPlatform.rust.cargo}/bin/cargo" + "--enable-rpath" + "--enable-vendor" + "--build=${stdenv.buildPlatform.config}" + "--host=${stdenv.hostPlatform.config}" + "--target=${stdenv.targetPlatform.config}" + + "${setBuild}.cc=${ccForBuild}" + "${setHost}.cc=${ccForHost}" + "${setTarget}.cc=${ccForTarget}" + + "${setBuild}.linker=${ccForBuild}" + "${setHost}.linker=${ccForHost}" + "${setTarget}.linker=${ccForTarget}" + + "${setBuild}.cxx=${cxxForBuild}" + "${setHost}.cxx=${cxxForHost}" + "${setTarget}.cxx=${cxxForTarget}" + ] ++ optional (!withBundledLLVM) [ + "--enable-llvm-link-shared" + "${setBuild}.llvm-config=${llvmSharedForBuild}/bin/llvm-config" + "${setHost}.llvm-config=${llvmSharedForHost}/bin/llvm-config" + "${setTarget}.llvm-config=${llvmSharedForTarget}/bin/llvm-config" + ]; + + # The bootstrap.py will generated a Makefile that then executes the build. + # The BOOTSTRAP_ARGS used by this Makefile must include all flags to pass + # to the bootstrap builder. + postConfigure = '' + substituteInPlace Makefile \ + --replace 'BOOTSTRAP_ARGS :=' 'BOOTSTRAP_ARGS := --jobs $(NIX_BUILD_CORES)' + ''; + + patches = [ + ./patches/net-tcp-disable-tests.patch + + # Re-evaluate if this we need to disable this one + #./patches/stdsimd-disable-doctest.patch + + # Fails on hydra - not locally; the exact reason is unknown. + # Comments in the test suggest that some non-reproducible environment + # variables such $RANDOM can make it fail. + # ./patches/disable-test-inherit-env.patch + ]; + + # the rust build system complains that nix alters the checksums + dontFixLibtool = true; + + postPatch = '' + patchShebangs src/etc + + ${optionalString (!withBundledLLVM) ''rm -rf src/llvm''} + + # Fix the configure script to not require curl as we won't use it + sed -i configure \ + -e '/probe_need CFG_CURL curl/d' + + # On Hydra: `TcpListener::bind(&addr)`: Address already in use (os error 98)' + sed '/^ *fn fast_rebind()/i#[ignore]' -i src/libstd/net/tcp.rs + + # https://github.com/rust-lang/rust/issues/39522 + echo removing gdb-version-sensitive tests... + find src/test/debuginfo -type f -execdir grep -q ignore-gdb-version '{}' \; -print -delete + rm src/test/debuginfo/{borrowed-c-style-enum.rs,c-style-enum-in-composite.rs,gdb-pretty-struct-and-enums.rs,generic-enum-with-different-disr-sizes.rs} + + # Useful debugging parameter + # export VERBOSE=1 + '' + optionalString stdenv.isDarwin '' + # Disable all lldb tests. + # error: Can't run LLDB test because LLDB's python path is not set + rm -vr src/test/debuginfo/* + rm -v src/test/run-pass/backtrace-debuginfo.rs || true + + # error: No such file or directory + rm -v src/test/ui/run-pass/issues/issue-45731.rs || true + + # Disable tests that fail when sandboxing is enabled. + substituteInPlace src/libstd/sys/unix/ext/net.rs \ + --replace '#[test]' '#[test] #[ignore]' + substituteInPlace src/test/run-pass/env-home-dir.rs \ + --replace 'home_dir().is_some()' true + rm -v src/test/run-pass/fds-are-cloexec.rs || true # FIXME: pipes? + rm -v src/test/ui/run-pass/threads-sendsync/sync-send-in-std.rs || true # FIXME: ??? + ''; + + # rustc unfortunately needs cmake to compile llvm-rt but doesn't + # use it for the normal build. This disables cmake in Nix. + dontUseCmakeConfigure = true; + + # ps is needed for one of the test cases + nativeBuildInputs = [ + file python2 ps rustPlatform.rust.rustc git cmake + which libffi removeReferencesTo + ] # Only needed for the debuginfo tests + ++ optional (!stdenv.isDarwin) gdb; + + buildInputs = optional stdenv.isDarwin Security + ++ optional (!withBundledLLVM) llvmShared; + + outputs = [ "out" "man" "doc" ]; + setOutputFlags = false; + + # Disable codegen units and hardening for the tests. + preCheck = '' + export RUSTFLAGS= + export TZDIR=${tzdata}/share/zoneinfo + export hardeningDisable=all + '' + + # Ensure TMPDIR is set, and disable a test that removing the HOME + # variable from the environment falls back to another home + # directory. + optionalString stdenv.isDarwin '' + export TMPDIR=/tmp + sed -i '28s/home_dir().is_some()/true/' ./src/test/run-pass/env-home-dir.rs + ''; + + # 1. Upstream is not running tests on aarch64: + # see https://github.com/rust-lang/rust/issues/49807#issuecomment-380860567 + # So we do the same. + # 2. Tests run out of memory for i686 + #doCheck = !stdenv.isAarch64 && !stdenv.isi686; + + # Disabled for now; see https://github.com/NixOS/nixpkgs/pull/42348#issuecomment-402115598. + doCheck = false; + + # remove references to llvm-config in lib/rustlib/x86_64-unknown-linux-gnu/codegen-backends/librustc_codegen_llvm-llvm.so + # and thus a transitive dependency on ncurses + postInstall = '' + find $out/lib -name "*.so" -type f -exec remove-references-to -t ${llvmShared} '{}' '+' + ''; + + configurePlatforms = []; + + # https://github.com/NixOS/nixpkgs/pull/21742#issuecomment-272305764 + # https://github.com/rust-lang/rust/issues/30181 + # enableParallelBuilding = false; + + requiredSystemFeatures = [ "big-parallel" ]; + + meta = with stdenv.lib; { + homepage = https://www.rust-lang.org/; + description = "A safe, concurrent, practical language"; + maintainers = with maintainers; [ madjar cstrahan wizeman globin havvy ]; + license = [ licenses.mit licenses.asl20 ]; + platforms = platforms.linux ++ platforms.darwin; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/sbcl/bootstrap.nix b/nixpkgs/pkgs/development/compilers/sbcl/bootstrap.nix new file mode 100644 index 000000000000..056ad7454600 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/sbcl/bootstrap.nix @@ -0,0 +1,79 @@ +{ stdenv, fetchurl, makeWrapper }: + +let + options = rec { + x86_64-darwin = rec { + version = "1.2.11"; + system = "x86-64-darwin"; + sha256 = "0lh4gpvi8hl6g6b9321g5pwh8sk3218i7h4lx7p3vd9z0cf3lz85"; + }; + x86_64-linux = rec { + version = "1.3.16"; + system = "x86-64-linux"; + sha256 = "0sq2dylwwyqfwkbdvcgqwz3vay9v895zpb0fyzsiwy31d1x9pr2s"; + }; + i686-linux = rec { + version = "1.2.7"; + system = "x86-linux"; + sha256 = "07f3bz4br280qvn85i088vpzj9wcz8wmwrf665ypqx181pz2ai3j"; + }; + aarch64-linux = rec { + version = "1.3.16"; + system = "arm64-linux"; + sha256 = "0q1brz9c49xgdljzfx8rpxxnlwhadxkcy5kg0mcd9wnxygind1cl"; + }; + armv7l-linux = rec { + version = "1.2.14"; + system = "armhf-linux"; + sha256 = "0sp5445rbvms6qvzhld0kwwvydw51vq5iaf4kdqsf2d9jvaz3yx5"; + }; + armv6l-linux = armv7l-linux; + x86_64-freebsd = rec { + version = "1.2.7"; + system = "x86-64-freebsd"; + sha256 = "14k42xiqd2rrim4pd5k5pjcrpkac09qnpynha8j1v4jngrvmw7y6"; + }; + x86_64-solaris = rec { + version = "1.2.7"; + system = "x86-64-solaris"; + sha256 = "05c12fmac4ha72k1ckl6i780rckd7jh4g5s5hiic7fjxnf1kx8d0"; + }; + }; + cfg = options.${stdenv.hostPlatform.system}; +in +assert builtins.hasAttr stdenv.hostPlatform.system options; +stdenv.mkDerivation rec { + name = "sbcl-bootstrap-${version}"; + version = cfg.version; + + src = fetchurl { + url = "mirror://sourceforge/project/sbcl/sbcl/${version}/sbcl-${version}-${cfg.system}-binary.tar.bz2"; + sha256 = cfg.sha256; + }; + + buildInputs = [ makeWrapper ]; + + installPhase = '' + mkdir -p $out/bin + cp -p src/runtime/sbcl $out/bin + + mkdir -p $out/share/sbcl + cp -p src/runtime/sbcl $out/share/sbcl + cp -p output/sbcl.core $out/share/sbcl + mkdir -p $out/bin + makeWrapper $out/share/sbcl/sbcl $out/bin/sbcl \ + --add-flags "--core $out/share/sbcl/sbcl.core" + ''; + + postFixup = stdenv.lib.optionalString (!stdenv.isAarch32 && stdenv.isLinux) '' + patchelf --set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) $out/share/sbcl/sbcl + ''; + + meta = with stdenv.lib; { + description = "Lisp compiler"; + homepage = http://www.sbcl.org; + license = licenses.publicDomain; # and FreeBSD + maintainers = [maintainers.raskin maintainers.tohl]; + platforms = attrNames options; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/sbcl/default.nix b/nixpkgs/pkgs/development/compilers/sbcl/default.nix new file mode 100644 index 000000000000..469d7847409f --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/sbcl/default.nix @@ -0,0 +1,112 @@ +{ stdenv, fetchurl, writeText, sbclBootstrap +, sbclBootstrapHost ? "${sbclBootstrap}/bin/sbcl --disable-debugger --no-userinit --no-sysinit" +, threadSupport ? (stdenv.isi686 || stdenv.isx86_64 || "aarch64-linux" == stdenv.hostPlatform.system) + # Meant for sbcl used for creating binaries portable to non-NixOS via save-lisp-and-die. + # Note that the created binaries still need `patchelf --set-interpreter ...` + # to get rid of ${glibc} dependency. +, purgeNixReferences ? false +, texinfo +}: + +stdenv.mkDerivation rec { + name = "sbcl-${version}"; + version = "1.5.1"; + + src = fetchurl { + url = "mirror://sourceforge/project/sbcl/sbcl/${version}/${name}-source.tar.bz2"; + sha256 = "08z62qba0kmm15k93s2rq7ipi769895g8iwigcp20qjh6amwnwph"; + }; + + buildInputs = [texinfo]; + + patchPhase = '' + echo '"${version}.nixos"' > version.lisp-expr + echo " + (lambda (features) + (flet ((enable (x) + (pushnew x features)) + (disable (x) + (setf features (remove x features)))) + '' + + (if threadSupport then "(enable :sb-thread)" else "(disable :sb-thread)") + + stdenv.lib.optionalString stdenv.isAarch32 "(enable :arm)" + + '' + )) " > customize-target-features.lisp + + pwd + + # SBCL checks whether files are up-to-date in many places.. + # Unfortunately, same timestamp is not good enough + sed -e 's@> x y@>= x y@' -i contrib/sb-aclrepl/repl.lisp + #sed -e '/(date)/i((= date 2208988801) 2208988800)' -i contrib/asdf/asdf.lisp + sed -i src/cold/slam.lisp -e \ + '/file-write-date input/a)' + sed -i src/cold/slam.lisp -e \ + '/file-write-date output/i(or (and (= 2208988801 (file-write-date output)) (= 2208988801 (file-write-date input)))' + sed -i src/code/target-load.lisp -e \ + '/date defaulted-fasl/a)' + sed -i src/code/target-load.lisp -e \ + '/date defaulted-source/i(or (and (= 2208988801 (file-write-date defaulted-source-truename)) (= 2208988801 (file-write-date defaulted-fasl-truename)))' + + # Fix the tests + sed -e '5,$d' -i contrib/sb-bsd-sockets/tests.lisp + sed -e '5,$d' -i contrib/sb-simple-streams/*test*.lisp + + # Use whatever `cc` the stdenv provides + substituteInPlace src/runtime/Config.x86-64-darwin --replace gcc cc + + substituteInPlace src/runtime/Config.x86-64-darwin \ + --replace mmacosx-version-min=10.4 mmacosx-version-min=10.5 + '' + + (if purgeNixReferences + then + # This is the default location to look for the core; by default in $out/lib/sbcl + '' + sed 's@^\(#define SBCL_HOME\) .*$@\1 "/no-such-path"@' \ + -i src/runtime/runtime.c + '' + else + # Fix software version retrieval + '' + sed -e "s@/bin/uname@$(command -v uname)@g" -i src/code/*-os.lisp \ + src/code/run-program.lisp + '' + ); + + + preBuild = '' + export INSTALL_ROOT=$out + mkdir -p test-home + export HOME=$PWD/test-home + ''; + + buildPhase = '' + sh make.sh --prefix=$out --xc-host="${sbclBootstrapHost}" + (cd doc/manual ; make info) + ''; + + installPhase = '' + INSTALL_ROOT=$out sh install.sh + '' + + stdenv.lib.optionalString (!purgeNixReferences) '' + cp -r src $out/lib/sbcl + cp -r contrib $out/lib/sbcl + cat >$out/lib/sbcl/sbclrc <<EOF + (setf (logical-pathname-translations "SYS") + '(("SYS:SRC;**;*.*.*" #P"$out/lib/sbcl/src/**/*.*") + ("SYS:CONTRIB;**;*.*.*" #P"$out/lib/sbcl/contrib/**/*.*"))) + EOF + ''; + + setupHook = stdenv.lib.optional purgeNixReferences (writeText "setupHook.sh" '' + addEnvHooks "$targetOffset" _setSbclHome + _setSbclHome() { + export SBCL_HOME='@out@/lib/sbcl/' + } + ''); + + meta = sbclBootstrap.meta // { + inherit version; + updateWalker = true; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/scala/2.10.nix b/nixpkgs/pkgs/development/compilers/scala/2.10.nix new file mode 100644 index 000000000000..16e0389ad031 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/scala/2.10.nix @@ -0,0 +1,43 @@ +{ stdenv, fetchurl, makeWrapper, jre, gnugrep, coreutils }: + +stdenv.mkDerivation rec { + name = "scala-2.10.7"; + + src = fetchurl { + url = "https://www.scala-lang.org/files/archive/${name}.tgz"; + sha256 = "04gi55lzgrhsb78qw8jmnccqim92rw6898knw0a7gfzn2sci30wj"; + }; + + propagatedBuildInputs = [ jre ] ; + buildInputs = [ makeWrapper ] ; + + installPhase = '' + mkdir -p $out + rm bin/*.bat + mv * $out + + for p in $(ls $out/bin/) ; do + wrapProgram $out/bin/$p \ + --prefix PATH ":" ${coreutils}/bin \ + --prefix PATH ":" ${gnugrep}/bin \ + --prefix PATH ":" ${jre}/bin \ + --set JAVA_HOME ${jre} + done + ''; + + meta = { + description = "A general purpose programming language"; + longDescription = '' + Scala is a general purpose programming language designed to express + common programming patterns in a concise, elegant, and type-safe way. + It smoothly integrates features of object-oriented and functional + languages, enabling Java and other programmers to be more productive. + Code sizes are typically reduced by a factor of two to three when + compared to an equivalent Java application. + ''; + homepage = https://www.scala-lang.org/; + license = stdenv.lib.licenses.bsd3; + platforms = stdenv.lib.platforms.all; + branch = "2.10"; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/scala/2.11.nix b/nixpkgs/pkgs/development/compilers/scala/2.11.nix new file mode 100644 index 000000000000..a1f803b67193 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/scala/2.11.nix @@ -0,0 +1,43 @@ +{ stdenv, fetchurl, makeWrapper, jre, gnugrep, coreutils }: + +stdenv.mkDerivation rec { + name = "scala-2.11.12"; + + src = fetchurl { + url = "https://www.scala-lang.org/files/archive/${name}.tgz"; + sha256 = "1a4nc4qp9dm4rps47j92hlmxxqskv67qbdmjqc5zd94wd4rps7di"; + }; + + propagatedBuildInputs = [ jre ] ; + buildInputs = [ makeWrapper ] ; + + installPhase = '' + mkdir -p $out + rm "bin/"*.bat + mv * $out + + for p in $(ls $out/bin/) ; do + wrapProgram $out/bin/$p \ + --prefix PATH ":" ${coreutils}/bin \ + --prefix PATH ":" ${gnugrep}/bin \ + --prefix PATH ":" ${jre}/bin \ + --set JAVA_HOME ${jre} + done + ''; + + meta = { + description = "General purpose programming language"; + longDescription = '' + Scala is a general purpose programming language designed to express + common programming patterns in a concise, elegant, and type-safe way. + It smoothly integrates features of object-oriented and functional + languages, enabling Java and other programmers to be more productive. + Code sizes are typically reduced by a factor of two to three when + compared to an equivalent Java application. + ''; + homepage = https://www.scala-lang.org/; + license = stdenv.lib.licenses.bsd3; + platforms = stdenv.lib.platforms.all; + branch = "2.11"; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/scala/default.nix b/nixpkgs/pkgs/development/compilers/scala/default.nix new file mode 100644 index 000000000000..ce863ef9c915 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/scala/default.nix @@ -0,0 +1,46 @@ +{ stdenv, fetchurl, makeWrapper, jre, gnugrep, coreutils }: + +stdenv.mkDerivation rec { + name = "scala-2.12.8"; + + src = fetchurl { + url = "https://www.scala-lang.org/files/archive/${name}.tgz"; + sha256 = "18w0vdbsp0q5rxglgalwlgkggld926bqi1fxc598rn4gh46a03j4"; + }; + + propagatedBuildInputs = [ jre ] ; + buildInputs = [ makeWrapper ] ; + + installPhase = '' + mkdir -p $out + rm "bin/"*.bat + mv * $out + + # put docs in correct subdirectory + mkdir -p $out/share/doc + mv $out/doc $out/share/doc/scala + + for p in $(ls $out/bin/) ; do + wrapProgram $out/bin/$p \ + --prefix PATH ":" ${coreutils}/bin \ + --prefix PATH ":" ${gnugrep}/bin \ + --prefix PATH ":" ${jre}/bin \ + --set JAVA_HOME ${jre} + done + ''; + + meta = { + description = "General purpose programming language"; + longDescription = '' + Scala is a general purpose programming language designed to express + common programming patterns in a concise, elegant, and type-safe way. + It smoothly integrates features of object-oriented and functional + languages, enabling Java and other programmers to be more productive. + Code sizes are typically reduced by a factor of two to three when + compared to an equivalent Java application. + ''; + homepage = https://www.scala-lang.org/; + license = stdenv.lib.licenses.bsd3; + platforms = stdenv.lib.platforms.all; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/scala/dotty-bare.nix b/nixpkgs/pkgs/development/compilers/scala/dotty-bare.nix new file mode 100644 index 000000000000..ab42eae31a68 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/scala/dotty-bare.nix @@ -0,0 +1,40 @@ +{ stdenv, fetchurl, makeWrapper, jre, ncurses }: + +stdenv.mkDerivation rec { + version = "0.14.0-RC1"; + name = "dotty-bare-${version}"; + + src = fetchurl { + url = "https://github.com/lampepfl/dotty/releases/download/${version}/dotty-${version}.tar.gz"; + sha256 = "0nrgsyhqjlpvnjqgb18pryr8q7knq3dq25jhp98s4wh76nssm1zr"; + }; + + propagatedBuildInputs = [ jre ncurses.dev ] ; + buildInputs = [ makeWrapper ] ; + + installPhase = '' + mkdir -p $out + mv * $out + ''; + + fixupPhase = '' + bin_files=$(find $out/bin -type f ! -name common) + for f in $bin_files ; do + wrapProgram $f --set JAVA_HOME ${jre} --prefix PATH : '${ncurses.dev}/bin' + done + ''; + + meta = with stdenv.lib; { + description = "Research platform for new language concepts and compiler technologies for Scala."; + longDescription = '' + Dotty is a platform to try out new language concepts and compiler technologies for Scala. + The focus is mainly on simplification. We remove extraneous syntax (e.g. no XML literals), + and try to boil down Scala’s types into a smaller set of more fundamental constructs. + The theory behind these constructs is researched in DOT, a calculus for dependent object types. + ''; + homepage = http://dotty.epfl.ch/; + license = licenses.bsd3; + platforms = platforms.all; + maintainers = [maintainers.karolchmist]; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/scala/dotty.nix b/nixpkgs/pkgs/development/compilers/scala/dotty.nix new file mode 100644 index 000000000000..a999bd422e63 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/scala/dotty.nix @@ -0,0 +1,22 @@ +{ stdenv, fetchurl, makeWrapper, jre, callPackage }: + +let + dotty-bare = callPackage ./dotty-bare.nix { + inherit stdenv fetchurl makeWrapper jre; + }; +in + +stdenv.mkDerivation { + name = "dotty-${dotty-bare.version}"; + + unpackPhase = ":"; + + installPhase = '' + mkdir -p $out/bin + ln -s ${dotty-bare}/bin/dotc $out/bin/dotc + ln -s ${dotty-bare}/bin/dotd $out/bin/dotd + ln -s ${dotty-bare}/bin/dotr $out/bin/dotr + ''; + + inherit (dotty-bare) meta; +} diff --git a/nixpkgs/pkgs/development/compilers/sdcc/default.nix b/nixpkgs/pkgs/development/compilers/sdcc/default.nix new file mode 100644 index 000000000000..f74299334535 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/sdcc/default.nix @@ -0,0 +1,39 @@ +{ stdenv, fetchurl, autoconf, bison, boost, flex, texinfo, gputils ? null +, excludePorts ? [] }: + +with stdenv.lib; + +let + # choices: mcs51 z80 z180 r2k r3ka gbz80 tlcs90 ds390 ds400 pic14 pic16 hc08 s08 stm8 + excludedPorts = excludePorts ++ (optionals (gputils == null) [ "pic14" "pic16" ]); +in + +stdenv.mkDerivation rec { + name = "sdcc-${version}"; + version = "3.7.0"; + + src = fetchurl { + url = "mirror://sourceforge/sdcc/sdcc-src-${version}.tar.bz2"; + sha256 = "13llvx0j3v5qa7qd4fh7nix4j3alpd3ccprxvx163c4q8q4lfkc5"; + }; + + buildInputs = [ autoconf bison boost flex gputils texinfo ]; + + configureFlags = map (f: "--disable-${f}-port") excludedPorts; + + meta = { + description = "Small Device C Compiler"; + longDescription = '' + SDCC is a retargettable, optimizing ANSI - C compiler suite that targets + the Intel MCS51 based microprocessors (8031, 8032, 8051, 8052, etc.), Maxim + (formerly Dallas) DS80C390 variants, Freescale (formerly Motorola) HC08 based + (hc08, s08) and Zilog Z80 based MCUs (z80, z180, gbz80, Rabbit 2000/3000, + Rabbit 3000A). Work is in progress on supporting the Microchip PIC16 and + PIC18 targets. It can be retargeted for other microprocessors. + ''; + homepage = http://sdcc.sourceforge.net/; + license = with licenses; if (gputils == null) then gpl2 else unfreeRedistributable; + maintainers = with maintainers; [ bjornfor yorickvp ]; + platforms = platforms.linux; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/seexpr/default.nix b/nixpkgs/pkgs/development/compilers/seexpr/default.nix new file mode 100644 index 000000000000..a6abe6791d7e --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/seexpr/default.nix @@ -0,0 +1,23 @@ +{ stdenv, fetchFromGitHub, cmake, libpng, zlib, qt4, +bison, flex, libGLU, pythonPackages +}: + +stdenv.mkDerivation rec { + name = "seexpr-${version}"; + version = "2.11"; + src = fetchFromGitHub { + owner = "wdas"; + repo = "SeExpr"; + rev = "v2.11"; + sha256 = "0a44k56jf6dl36fwgg4zpc252wq5lf9cblg74mp73k82hxw439l4"; + }; + + buildInputs = [ cmake libGLU libpng zlib qt4 pythonPackages.pyqt4 bison flex ]; + meta = with stdenv.lib; { + description = "Embeddable expression evaluation engine from Disney Animation"; + homepage = https://www.disneyanimation.com/technology/seexpr.html; + maintainers = with maintainers; [ hodapp ]; + license = licenses.asl20; + platforms = platforms.linux; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/serpent/default.nix b/nixpkgs/pkgs/development/compilers/serpent/default.nix new file mode 100644 index 000000000000..e9c6b706e5ad --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/serpent/default.nix @@ -0,0 +1,38 @@ +{ stdenv, fetchFromGitHub, ... }: + +stdenv.mkDerivation rec { + name = "serpent-${version}"; + + # I can't find any version numbers, so we're just using the date + # of the last commit. + version = "2016-03-05"; + + src = fetchFromGitHub { + owner = "ethereum"; + repo = "serpent"; + rev = "51ee60857fe53c871fa916ef66fc1b4255bb9433"; + sha256 = "1bns9wgn5i1ahj19qx7v1wwdy8ca3q3pigxwznm5nywsw7s7lqxs"; + }; + + installPhase = '' + mkdir -p $out/bin + mv serpent $out/bin + ''; + + meta = with stdenv.lib; { + description = "Compiler for the Serpent language for Ethereum"; + longDescription = '' + Serpent is one of the high-level programming languages used to + write Ethereum contracts. The language, as suggested by its name, + is designed to be very similar to Python; it is intended to be + maximally clean and simple, combining many of the efficiency + benefits of a low-level language with ease-of-use in programming + style, and at the same time adding special domain-specific + features for contract programming. + ''; + homepage = https://github.com/ethereum/wiki/wiki/Serpent; + license = with licenses; [ wtfpl ]; + maintainers = with maintainers; [ chris-martin ]; + platforms = with platforms; linux; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/shaderc/default.nix b/nixpkgs/pkgs/development/compilers/shaderc/default.nix new file mode 100644 index 000000000000..7ce7f9cefe51 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/shaderc/default.nix @@ -0,0 +1,62 @@ +{ stdenv, fetchFromGitHub, cmake, python }: +# Like many google projects, shaderc doesn't gracefully support separately compiled dependencies, so we can't easily use +# the versions of glslang and spirv-tools used by vulkan-loader. Exact revisions are taken from +# https://github.com/google/shaderc/blob/known-good/known_good.json + +# Future work: extract and fetch all revisions automatically based on a revision of shaderc's known-good branch. +let + glslang = fetchFromGitHub { + owner = "KhronosGroup"; + repo = "glslang"; + rev = "712cd6618df2c77e126d68042ad7a81a69ee4a6f"; + sha256 = "0wncdj6q1hn40lc7cnz97mx5qjvb8p13mhxilnncgcmf0crsvblz"; + }; + spirv-tools = fetchFromGitHub { + owner = "KhronosGroup"; + repo = "SPIRV-Tools"; + rev = "df5bd2d05ac1fd3ec3024439f885ec21cc949b22"; + sha256 = "0l8ds4nn2qcfi8535ai8891i3547x35hscs2jxwwq6qjgw1sgkax"; + }; + spirv-headers = fetchFromGitHub { + owner = "KhronosGroup"; + repo = "SPIRV-Headers"; + rev = "79b6681aadcb53c27d1052e5f8a0e82a981dbf2f"; + sha256 = "0flng2rdmc4ndq3j71h6wk1ibcjvhjrg2rzd6rv445vcsf0jh2pj"; + }; +in stdenv.mkDerivation rec { + name = "shaderc-${version}"; + version = "2018.0"; + + outputs = [ "out" "lib" "bin" "dev" "static" ]; + + src = fetchFromGitHub { + owner = "google"; + repo = "shaderc"; + rev = "v${version}"; + sha256 = "0qigmj0riw43pgjn5f6kpvk72fajssz1lc2aiqib5qvmj9rqq3hl"; + }; + + patchPhase = '' + cp -r --no-preserve=mode ${glslang} third_party/glslang + cp -r --no-preserve=mode ${spirv-tools} third_party/spirv-tools + ln -s ${spirv-headers} third_party/spirv-tools/external/spirv-headers + ''; + + nativeBuildInputs = [ cmake python ]; + + postInstall = '' + moveToOutput "lib/*.a" $static + ''; + + preConfigure = ''cmakeFlags="$cmakeFlags -DCMAKE_INSTALL_BINDIR=$bin/bin"''; + + enableParallelBuilding = true; + + cmakeFlags = [ "-DSHADERC_SKIP_TESTS=ON" ]; + + meta = with stdenv.lib; { + inherit (src.meta) homepage; + description = "A collection of tools, libraries and tests for shader compilation."; + license = [ licenses.asl20 ]; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/smlnj/bootstrap.nix b/nixpkgs/pkgs/development/compilers/smlnj/bootstrap.nix new file mode 100644 index 000000000000..2fe1f1f3f5a6 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/smlnj/bootstrap.nix @@ -0,0 +1,43 @@ +{ stdenv, fetchurl, cpio, rsync, makeWrapper }: + +stdenv.mkDerivation rec { + name = "smlnj-bootstrap-${version}"; + + version = "110.84"; + + src = fetchurl { + url = "http://smlnj.cs.uchicago.edu/dist/working/${version}/smlnj-x86-${version}.pkg"; + sha256 = "17fpnlxcfwx2ysg6y9c5wwx6s3jca981nb0pawfcg6xg9wcapyfz"; + }; + + buildInputs = [ cpio rsync makeWrapper ]; + + unpackPhase = '' + /usr/bin/xar -xf $src + cd smlnj.pkg + ''; + + buildPhase = '' + cat Payload | gunzip -dc | cpio -i + ''; + + installPhase = '' + mkdir -p $out/bin + rsync -av bin/ $out/bin/ + + mkdir -p $out/lib + rsync -av lib/ $out/lib/ + ''; + + postInstall = '' + wrapProgram "$out/bin/sml" --set "SMLNJ_HOME" "$out" + ''; + + meta = { + description = "Compiler for the Standard ML '97 programming language"; + homepage = http://www.smlnj.org; + license = stdenv.lib.licenses.free; + platforms = stdenv.lib.platforms.darwin; + maintainers = [ stdenv.lib.maintainers.jwiegley ]; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/smlnj/default.nix b/nixpkgs/pkgs/development/compilers/smlnj/default.nix new file mode 100644 index 000000000000..b0ca96f23acf --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/smlnj/default.nix @@ -0,0 +1,80 @@ +{ stdenv, fetchurl, darwin }: +let + version = "110.85"; + baseurl = "http://smlnj.cs.uchicago.edu/dist/working/${version}"; + + sources = map fetchurl [ + { url = "${baseurl}/config.tgz"; sha256 = "1qlir3q0vi7f1wyz2jyaiqy3z72d0xngsa122ks5g0b7b0hcdgm1"; } + { url = "${baseurl}/cm.tgz"; sha256 = "0330jkmaxgy085hsgajqikm242gms650rks24mfxhgk11r4ks105"; } + { url = "${baseurl}/compiler.tgz"; sha256 = "1zrqqvi9332g3clrh01z19sl06g3zlnp6zzz5z8rvsfwbiqp929m"; } + { url = "${baseurl}/runtime.tgz"; sha256 = "1n9hd99s2i834yihx4n59gl1cnh7hiiz8im735bmifmv50vzfdf4"; } + { url = "${baseurl}/system.tgz"; sha256 = "17samia4lzcz3mk73i330bspap2ks937arx35n9dr7bws0appfm8"; } + { url = "${baseurl}/MLRISC.tgz"; sha256 = "039g6dwxy96bkvw1z19vwn8q150h7s8jlcmsg851bgz3j3h6vs18"; } + { url = "${baseurl}/smlnj-lib.tgz"; sha256 = "1wk4w1npipm6qqgwis2xrbdjamwmiwv6ci4y40nzryhb37yxfj6d"; } + { url = "${baseurl}/old-basis.tgz"; sha256 = "0lkhbkkglz7lk1c93hc1y1di5dx20fgfhybvsqjp1bcwz8jsd70y"; } + { url = "${baseurl}/ckit.tgz"; sha256 = "14qxgw2vhq4dfiv5zl2gdhvjp75s10dqw97mqxffmh3vayyad1fi"; } + { url = "${baseurl}/nlffi.tgz"; sha256 = "16l8iszkyh34dqdbplsxycipvbw61yjamgxllcq8axiq4h7spy7w"; } + { url = "${baseurl}/cml.tgz"; sha256 = "05dlqz4r3qa3rpqgjlx91fsfx7j6gk3dkw28zcgg5g32irmd1la3"; } + { url = "${baseurl}/eXene.tgz"; sha256 = "07mahzxns26hkfax9gc8cq4s8sfzj531wwnm47b8qkhd72d3ncn2"; } + { url = "${baseurl}/ml-lpt.tgz"; sha256 = "0073hfn98l61ryshhqw9855fb49vs9qcz9nplbg2pa2f7manqbk0"; } + { url = "${baseurl}/ml-lex.tgz"; sha256 = "106km17f4wyvhzkx62cfq2gp4ihya8l234550laqb50zf8vxyklq"; } + { url = "${baseurl}/ml-yacc.tgz"; sha256 = "1r0k7lz8xnir271pykbs4agadysbs35kkmg1p816kzfyz5bsrrq9"; } + { url = "${baseurl}/ml-burg.tgz"; sha256 = "10jqasplbxp50ryq74aazbnyaz8l492rhdij5mr1kzyfj79fysh9"; } + { url = "${baseurl}/pgraph.tgz"; sha256 = "1pxqddbrb7y9kp89gz8v8vfjmw4wajfy6757gb8c6x499jarxa60"; } + { url = "${baseurl}/trace-debug-profile.tgz"; sha256 = "0fkalpdzdrm1gmafn33ck4dw8s92p9iwm4fav4m9jcqyha9az3g7"; } + { url = "${baseurl}/heap2asm.tgz"; sha256 = "056gkmrylyrf0q0r3cpx76zx8mc62033jkn1bnjn0f8r31yhbipc"; } + { url = "${baseurl}/smlnj-c.tgz"; sha256 = "04c4jnylj5dnd4sjywzwnqlv9g7dkrilq6d4cy543dw03yhjdykw"; } + { url = "${baseurl}/doc.tgz"; sha256 = "1rpk9g1nhjpc2b4pmzmj8v80knrhljn17ghiwznnljv53hka7jzx"; } + { url = "${baseurl}/boot.x86-unix.tgz"; sha256 = "05rh1y74jvp6zs96mb7nkwbgwwbss0zy2iw4gicdkyf6in0nk4la"; } + { url = "${baseurl}/asdl.tgz"; sha256 = "1d465bncgy92ni6430dbq6isvnysfhvykjrxm98dz82iih7a6vqb"; } + ]; +in stdenv.mkDerivation { + name = "smlnj-${version}"; + + inherit sources; + + patchPhase = '' + sed -i '/PATH=/d' config/_arch-n-opsys base/runtime/config/gen-posix-names.sh + echo SRCARCHIVEURL="file:/$TMP" > config/srcarchiveurl + '' + stdenv.lib.optionalString stdenv.isDarwin (with darwin; '' + sed -i '/^[[:space:]]*\*x86-darwin\*)$/,/^[[:space:]]*\*) ;;/ c\ +\ \*x86-darwin\*)\ +\ INCLFILE=${stdenv.lib.getDev apple_sdk.sdk}/include/unistd.h\ +\ ;;\ +\ \*) ;; +' base/runtime/config/gen-posix-names.sh + sed -i 's|^AS =\([[:space:]]*\)/usr/bin/as|AS =\1as|' base/runtime/objs/mk.x86-darwin + ''); + + unpackPhase = '' + for s in $sources; do + b=$(basename $s) + cp $s ''${b#*-} + done + unpackFile config.tgz + mkdir base + ./config/unpack $TMP runtime + ''; + + buildPhase = '' + ./config/install.sh + ''; + + installPhase = '' + mkdir -pv $out + cp -rv bin lib $out + + cd $out/bin + for i in *; do + sed -i "2iSMLNJ_HOME=$out/" $i + done + ''; + + meta = with stdenv.lib; { + description = "Standard ML of New Jersey, a compiler"; + homepage = http://smlnj.org; + license = licenses.bsd3; + platforms = [ "i686-linux" ] ++ platforms.darwin; + maintainers = with maintainers; [ thoughtpolice ]; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/solc/default.nix b/nixpkgs/pkgs/development/compilers/solc/default.nix new file mode 100644 index 000000000000..8f005d475dc7 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/solc/default.nix @@ -0,0 +1,63 @@ +{ stdenv, fetchzip, fetchFromGitHub, boost, cmake +, z3Support ? true, z3 ? null +}: + +assert z3Support -> z3 != null; +assert z3Support -> stdenv.lib.versionAtLeast z3.version "4.6.0"; + +let + version = "0.5.7"; + rev = "6da8b019e4a155d1f70abe7a3acc0f9765480a9e"; + sha256 = "0ii868r0ra6brjnn453kxqvw76p4bwjbvdyqfcn6v1bl2h4s60ir"; + jsoncppURL = https://github.com/open-source-parsers/jsoncpp/archive/1.8.4.tar.gz; + jsoncpp = fetchzip { + url = jsoncppURL; + sha256 = "1z0gj7a6jypkijmpknis04qybs1hkd04d1arr3gy89lnxmp6qzlm"; + }; +in +stdenv.mkDerivation { + name = "solc-${version}"; + + src = fetchFromGitHub { + owner = "ethereum"; + repo = "solidity"; + inherit rev sha256; + }; + + patches = [ + ./patches/shared-libs-install.patch + ]; + + postPatch = '' + touch prerelease.txt + echo >commit_hash.txt "${rev}" + substituteInPlace cmake/jsoncpp.cmake \ + --replace "${jsoncppURL}" ${jsoncpp} + ''; + + cmakeFlags = [ + "-DBoost_USE_STATIC_LIBS=OFF" + "-DBUILD_SHARED_LIBS=ON" + ] ++ stdenv.lib.optionals (!z3Support) [ + "-DUSE_Z3=OFF" + ]; + + doCheck = stdenv.hostPlatform.isLinux && stdenv.hostPlatform == stdenv.buildPlatform; + checkPhase = "LD_LIBRARY_PATH=./libsolc:./libsolidity:./libevmasm:./libdevcore:./libyul:./liblangutil:./test/tools/yulInterpreter:$LD_LIBRARY_PATH " + + "./test/soltest -p true -- --no-ipc --no-smt --testpath ../test"; + + nativeBuildInputs = [ cmake ]; + buildInputs = [ boost ] + ++ stdenv.lib.optionals z3Support [ z3 ]; + + outputs = [ "out" "dev" ]; + + meta = with stdenv.lib; { + description = "Compiler for Ethereum smart contract language Solidity"; + homepage = https://github.com/ethereum/solidity; + license = licenses.gpl3; + platforms = with platforms; linux ++ darwin; + maintainers = with maintainers; [ dbrock akru lionello ]; + inherit version; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/solc/patches/shared-libs-install.patch b/nixpkgs/pkgs/development/compilers/solc/patches/shared-libs-install.patch new file mode 100644 index 000000000000..e106c9bbb742 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/solc/patches/shared-libs-install.patch @@ -0,0 +1,71 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 0c05208f..8893648e 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -48,6 +48,22 @@ add_subdirectory(libevmasm) + add_subdirectory(libsolidity) + add_subdirectory(libsolc) + ++install(DIRECTORY libdevcore/ ++ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/libdevcore ++ FILES_MATCHING PATTERN "*.h") ++install(DIRECTORY libevmasm/ ++ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/libevmasm ++ FILES_MATCHING PATTERN "*.h") ++install(DIRECTORY libsolidity/ ++ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/libsolidity ++ FILES_MATCHING PATTERN "*.h") ++install(DIRECTORY libyul/ ++ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/libyul ++ FILES_MATCHING PATTERN "*.h") ++install(DIRECTORY liblangutil/ ++ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/liblangutil ++ FILES_MATCHING PATTERN "*.h") ++ + if (NOT EMSCRIPTEN) + add_subdirectory(solc) + add_subdirectory(liblll) +diff --git a/libdevcore/CMakeLists.txt b/libdevcore/CMakeLists.txt +index fa7e3f48..1f9f52b4 100644 +--- a/libdevcore/CMakeLists.txt ++++ b/libdevcore/CMakeLists.txt +@@ -6,3 +6,4 @@ target_link_libraries(devcore PRIVATE jsoncpp ${Boost_FILESYSTEM_LIBRARIES} ${Bo + target_include_directories(devcore PUBLIC "${CMAKE_SOURCE_DIR}") + target_include_directories(devcore SYSTEM PUBLIC ${Boost_INCLUDE_DIRS}) + add_dependencies(devcore solidity_BuildInfo.h) ++install(TARGETS devcore LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) +diff --git a/libevmasm/CMakeLists.txt b/libevmasm/CMakeLists.txt +index 86192c1b..e7f15e93 100644 +--- a/libevmasm/CMakeLists.txt ++++ b/libevmasm/CMakeLists.txt +@@ -3,3 +3,4 @@ file(GLOB headers "*.h") + + add_library(evmasm ${sources} ${headers}) + target_link_libraries(evmasm PUBLIC devcore) ++install(TARGETS evmasm LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) +diff --git a/libsolidity/CMakeLists.txt b/libsolidity/CMakeLists.txt +index 0bdec4b4..e876177e 100644 +--- a/libsolidity/CMakeLists.txt ++++ b/libsolidity/CMakeLists.txt +@@ -29,6 +29,7 @@ endif() + + add_library(solidity ${sources} ${headers}) + target_link_libraries(solidity PUBLIC yul evmasm langutil devcore ${Boost_FILESYSTEM_LIBRARY} ${Boost_SYSTEM_LIBRARY}) ++install(TARGETS solidity LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) + + if (${Z3_FOUND}) + target_link_libraries(solidity PUBLIC ${Z3_LIBRARY}) +--- a/libyul/CMakeLists.txt ++++ b/libyul/CMakeLists.txt +@@ -43,3 +43,4 @@ endif() + optimiser/VarDeclPropagator.cpp + ) + target_link_libraries(yul PUBLIC evmasm devcore langutil) ++install(TARGETS yul LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) +--- a/liblangutil/CMakeLists.txt ++++ b/liblangutil/CMakeLists.txt +@@ -11,3 +11,4 @@ endif() + + add_library(langutil ${sources}) + target_link_libraries(langutil PUBLIC devcore) ++install(TARGETS langutil LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) diff --git a/nixpkgs/pkgs/development/compilers/souffle/default.nix b/nixpkgs/pkgs/development/compilers/souffle/default.nix new file mode 100644 index 000000000000..87eac5418625 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/souffle/default.nix @@ -0,0 +1,53 @@ +{ stdenv, fetchFromGitHub +, perl, ncurses, zlib, sqlite, libffi +, autoreconfHook, mcpp, bison, flex, doxygen, graphviz +, makeWrapper +}: + + +let + toolsPath = stdenv.lib.makeBinPath [ mcpp ]; +in +stdenv.mkDerivation rec { + name = "souffle-${version}"; + version = "1.5.1"; + + src = fetchFromGitHub { + owner = "souffle-lang"; + repo = "souffle"; + rev = version; + sha256 = "06sa250z3v8hs91p6cqdzlwwaq96j6zmfrrld1fzd1b620aa5iys"; + }; + + nativeBuildInputs = [ autoreconfHook bison flex mcpp doxygen graphviz makeWrapper perl ]; + buildInputs = [ ncurses zlib sqlite libffi ]; + + # these propagated inputs are needed for the compiled Souffle mode to work, + # since generated compiler code uses them. TODO: maybe write a g++ wrapper + # that adds these so we can keep the propagated inputs clean? + propagatedBuildInputs = [ ncurses zlib sqlite libffi ]; + + # see 565a8e73e80a1bedbb6cc037209c39d631fc393f and parent commits upstream for + # Wno-error fixes + patchPhase = '' + substituteInPlace ./src/Makefile.am \ + --replace '-Werror' '-Werror -Wno-error=deprecated -Wno-error=other' + + substituteInPlace configure.ac \ + --replace "m4_esyscmd([git describe --tags --always | tr -d '\n'])" "${version}" + ''; + + postInstall = '' + wrapProgram "$out/bin/souffle" --prefix PATH : "${toolsPath}" + ''; + + outputs = [ "out" ]; + + meta = with stdenv.lib; { + description = "A translator of declarative Datalog programs into the C++ language"; + homepage = "http://souffle-lang.github.io/"; + platforms = platforms.unix; + maintainers = with maintainers; [ thoughtpolice copumpkin wchresta ]; + license = licenses.upl; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/souper/cmake-fix.patch b/nixpkgs/pkgs/development/compilers/souper/cmake-fix.patch new file mode 100644 index 000000000000..5ef289f53e93 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/souper/cmake-fix.patch @@ -0,0 +1,14 @@ +--- souper-1be75fe6a96993b57dcba038798fe6d1c7d113eb-src/CMakeLists.txt.orig 2017-01-20 13:55:14.783632588 -0600 ++++ souper-1be75fe6a96993b57dcba038798fe6d1c7d113eb-src/CMakeLists.txt 2017-01-20 13:55:20.505728456 -0600 +@@ -33,7 +33,10 @@ + OUTPUT_VARIABLE LLVM_SYSTEM_LIBS + OUTPUT_STRIP_TRAILING_WHITESPACE + ) +-set(LLVM_LIBS "${LLVM_LIBS} ${LLVM_SYSTEM_LIBS}") ++ ++if (LLVM_SYSTEM_LIBS) ++ set(LLVM_LIBS "${LLVM_LIBS} ${LLVM_SYSTEM_LIBS}") ++endif() + + execute_process( + COMMAND ${LLVM_CONFIG_EXECUTABLE} --ldflags diff --git a/nixpkgs/pkgs/development/compilers/souper/default.nix b/nixpkgs/pkgs/development/compilers/souper/default.nix new file mode 100644 index 000000000000..2203dc980b13 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/souper/default.nix @@ -0,0 +1,59 @@ +{ stdenv, fetchFromGitHub, cmake, makeWrapper +, llvmPackages_4, hiredis, z3, gtest +}: + +let + klee = fetchFromGitHub { + owner = "rsas"; + repo = "klee"; + rev = "57cd3d43056b029d9da3c6b3c666c4153554c04f"; + sha256 = "197wb7nbirlfpx2jr3afpjjhcj7slc4dxxi02j3kmazz9kcqaygz"; + }; +in stdenv.mkDerivation rec { + name = "souper-unstable-${version}"; + version = "2017-03-23"; + + src = fetchFromGitHub { + owner = "google"; + repo = "souper"; + rev = "cf2911d2eb1e7c8ab465df5a722fa5cdac06e6fc"; + sha256 = "1kg08a1af4di729pn1pip2lzqzlvjign6av95214f5rr3cq2q0cl"; + }; + + nativeBuildInputs = [ + cmake + makeWrapper + ]; + + buildInputs = [ + llvmPackages_4.llvm + llvmPackages_4.clang-unwrapped + hiredis + gtest + ]; + + patches = [ ./cmake-fix.patch ]; + + enableParallelBuilding = true; + + preConfigure = '' + mkdir -pv third_party + cp -R "${klee}" third_party/klee + ''; + + installPhase = '' + mkdir -pv $out/bin + cp -v ./souper $out/bin/ + cp -v ./clang-souper $out/bin/ + wrapProgram "$out/bin/souper" \ + --add-flags "-z3-path=\"${z3}/bin/z3\"" + ''; + + meta = with stdenv.lib; { + description = "A superoptimizer for LLVM IR"; + homepage = "https://github.com/google/souper"; + license = licenses.asl20; + maintainers = with maintainers; [ taktoa ]; + platforms = with platforms; linux; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/squeak/default.nix b/nixpkgs/pkgs/development/compilers/squeak/default.nix new file mode 100644 index 000000000000..25ea47978fcd --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/squeak/default.nix @@ -0,0 +1,47 @@ +{ stdenv, fetchurl, cmake, coreutils, dbus, freetype, glib, gnused +, libpthreadstubs, pango, pkgconfig, libpulseaudio, which }: + +stdenv.mkDerivation rec { + name = "squeak-${version}"; + version = "4.10.2.2614"; + + src = fetchurl { + sha256 = "0bpwbnpy2sb4gylchfx50sha70z36bwgdxraym4vrr93l8pd3dix"; + url = "http://squeakvm.org/unix/release/Squeak-${version}-src.tar.gz"; + }; + + buildInputs = [ coreutils dbus freetype glib gnused libpthreadstubs + pango libpulseaudio which ]; + nativeBuildInputs = [ cmake pkgconfig ]; + + postPatch = '' + for i in squeak.in squeak.sh.in; do + substituteInPlace unix/cmake/$i --replace "PATH=" \ + "PATH=${stdenv.lib.makeBinPath [ coreutils gnused which ]} #" + done + ''; + + configurePhase = '' + unix/cmake/configure --prefix=$out --enable-mpg-{mmx,pthreads} + ''; + + enableParallelBuilding = true; + + hardeningDisable = [ "format" ]; + + meta = with stdenv.lib; { + description = "Smalltalk programming language and environment"; + longDescription = '' + Squeak is a full-featured implementation of the Smalltalk programming + language and environment based on (and largely compatible with) the + original Smalltalk-80 system. Squeak has very powerful 2- and 3-D + graphics, sound, video, MIDI, animation and other multimedia + capabilities. It also includes a customisable framework for creating + dynamic HTTP servers and interactively extensible Web sites. + ''; + homepage = http://squeakvm.org/; + downloadPage = http://squeakvm.org/unix/index.html; + license = with licenses; [ asl20 mit ]; + platforms = platforms.linux; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/stalin/default.nix b/nixpkgs/pkgs/development/compilers/stalin/default.nix new file mode 100644 index 000000000000..09045ee2c11e --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/stalin/default.nix @@ -0,0 +1,45 @@ +{ fetchurl, stdenv, ncompress, libX11 }: + +stdenv.mkDerivation rec { + name = "stalin-0.11"; + + src = fetchurl { + url = "ftp://ftp.ecn.purdue.edu/qobi/stalin.tar.Z"; + sha256 = "0lz8riccpigdixwf6dswwva6s4kxaz3dzxhkqhcxgwmffy30vw8s"; + }; + + buildInputs = [ ncompress libX11 ]; + + buildPhase = '' ./build ''; + + installPhase = '' + mkdir -p "$out/bin" + cp stalin "$out/bin" + + mkdir -p "$out/man/man1" + cp stalin.1 "$out/man/man1" + + mkdir -p "$out/share/emacs/site-lisp" + cp stalin.el "$out/share/emacs/site-lisp" + + mkdir -p "$out/doc/${name}" + cp README "$out/doc/${name}" + + mkdir -p "$out/share/${name}/include" + cp "include/"* "$out/share/${name}/include" + + substituteInPlace "$out/bin/stalin" \ + --replace "$PWD/include/stalin" "$out/share/${name}/include/stalin" + substituteInPlace "$out/bin/stalin" \ + --replace "$PWD/include" "$out/share/${name}/include" + ''; + + meta = { + homepage = http://www.ece.purdue.edu/~qobi/software.html; + license = stdenv.lib.licenses.gpl2Plus; + description = "Stalin, an optimizing Scheme compiler"; + + maintainers = [ ]; + platforms = ["i686-linux"]; # doesn't want to work on 64-bit platforms + }; +} diff --git a/nixpkgs/pkgs/development/compilers/swi-prolog/default.nix b/nixpkgs/pkgs/development/compilers/swi-prolog/default.nix new file mode 100644 index 000000000000..97b4a627540c --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/swi-prolog/default.nix @@ -0,0 +1,73 @@ +{ stdenv, fetchgit, jdk, gmp, readline, openssl, libjpeg, unixODBC, zlib +, libXinerama, libarchive, db, pcre, libedit, libossp_uuid, libXft, libXpm +, libSM, libXt, freetype, pkgconfig, fontconfig, makeWrapper ? stdenv.isDarwin +, git, cacert, cmake, libyaml +, extraLibraries ? [ jdk unixODBC libXpm libSM libXt freetype fontconfig ] +, extraPacks ? [] +}: + +let + version = "8.1.4"; + packInstall = swiplPath: pack: + ''${swiplPath}/bin/swipl -g "pack_install(${pack}, [package_directory(\"${swiplPath}/lib/swipl/pack\"), silent(true), interactive(false)])." -t "halt." + ''; +in +stdenv.mkDerivation { + name = "swi-prolog-${version}"; + + src = fetchgit { + url = "https://github.com/SWI-Prolog/swipl-devel"; + rev = "V${version}"; + sha256 = "0qxa6f5dypwczxajlf0l736adbjb17cbak3qsh5g04hpv2bxm6dh"; + }; + + buildInputs = [ cacert git cmake gmp readline openssl + libarchive libyaml db pcre libedit libossp_uuid + zlib pkgconfig ] + ++ extraLibraries + ++ stdenv.lib.optional stdenv.isDarwin makeWrapper; + + hardeningDisable = [ "format" ]; + + configureFlags = [ + "--with-world" + "--enable-gmp" + "--enable-shared" + ]; + + installPhase = '' + mkdir -p $out + mkdir build + cd build + ${cmake}/bin/cmake -DCMAKE_INSTALL_PREFIX=$out .. + cd ../ + make + make install + make clean + mkdir -p $out/lib/swipl/pack + '' + + builtins.concatStringsSep "\n" + ( builtins.map (packInstall "$out") extraPacks + ); + + # For macOS: still not fixed in upstream: "abort trap 6" when called + # through symlink, so wrap binary. + # We reinvent wrapProgram here but omit argv0 pass in order to not + # break PAKCS package build. This is also safe for SWI-Prolog, since + # there is no wrapping environment and hence no need to spoof $0 + postInstall = stdenv.lib.optionalString stdenv.isDarwin '' + local prog="$out/bin/swipl" + local hidden="$(dirname "$prog")/.$(basename "$prog")"-wrapped + mv $prog $hidden + makeWrapper $hidden $prog + ''; + + meta = { + homepage = http://www.swi-prolog.org/; + description = "A Prolog compiler and interpreter"; + license = "LGPL"; + + platforms = stdenv.lib.platforms.unix; + maintainers = [ stdenv.lib.maintainers.meditans ]; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/swift/default.nix b/nixpkgs/pkgs/development/compilers/swift/default.nix new file mode 100644 index 000000000000..91fb962f87cc --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/swift/default.nix @@ -0,0 +1,287 @@ +{ stdenv +, targetPackages +, cmake +, coreutils +, glibc +, which +, perl +, libedit +, ninja +, pkgconfig +, sqlite +, swig +, bash +, libxml2 +, clang +, python +, ncurses +, libuuid +, libbsd +, icu +, autoconf +, libtool +, automake +, libblocksruntime +, curl +, rsync +, git +, libgit2 +, fetchFromGitHub +, findutils +, makeWrapper +, gnumake +, file +}: + +let + v_base = "4.2.3"; + version = "${v_base}-RELEASE"; + version_friendly = "${v_base}"; + + tag = "refs/tags/swift-${version}"; + fetch = { repo, sha256, fetchSubmodules ? false }: + fetchFromGitHub { + owner = "apple"; + inherit repo sha256 fetchSubmodules; + rev = tag; + name = "${repo}-${version}-src"; + }; + + sources = { + # FYI: SourceKit probably would work but currently requires building everything twice + # For more inforation, see: https://github.com/apple/swift/pull/3594#issuecomment-234169759 + clang = fetch { + repo = "swift-clang"; + sha256 = "0l6w4xzpl3w2nax9a0b885nfzhfj38p2g99158nb5bzfd4s0man7"; + }; + llvm = fetch { + repo = "swift-llvm"; + sha256 = "1664zwxbq0a1cmxr9n5a0vw6vdk6ygr7rpglpdsfc7ki857vpsyv"; + }; + compilerrt = fetch { + repo = "swift-compiler-rt"; + sha256 = "19s6qxn4i0kxpf39xjp2i7zg427iinbmaxqkbb1p91g616y367sf"; + }; + cmark = fetch { + repo = "swift-cmark"; + sha256 = "1nmxp0fj749sgar682c5nsj7zxxigqwg973baxj2r656a7ybh325"; + }; + lldb = fetch { + repo = "swift-lldb"; + sha256 = "00kz0xhj1p6ckyandj2gs1yfl29kxv84x9pfph00r8crbkd2jz7b"; + }; + llbuild = fetch { + repo = "swift-llbuild"; + sha256 = "1mkkhydshhxr28igbldzr0hhqvb6ql43cpf3ba5vglfkbcz6wh6q"; + }; + pm = fetch { + repo = "swift-package-manager"; + sha256 = "1aqvmgq9g5zs4k2qnkvw3h3mar66d690hqq6g2dmrapsyb321j9l"; + }; + xctest = fetch { + repo = "swift-corelibs-xctest"; + sha256 = "1n4w7bfgy73vjzbvbphlwayy0dw73bbrayrpkqq8lbidg0x9lam8"; + }; + foundation = fetch { + repo = "swift-corelibs-foundation"; + sha256 = "11kwc5pcq4ibxkyglmqs7h7gka3xkzl9j856x1rq2xdvq756wq2s"; + }; + libdispatch = fetch { + repo = "swift-corelibs-libdispatch"; + sha256 = "09c15mn9s5lf2akzfhik70zk91h97nnm8pq1ppfqry2nn3vmib2i"; + fetchSubmodules = true; + }; + swift = fetch { + repo = "swift"; + sha256 = "09wksqad0w6pk3xdxc278w4mj300h48rvbvx0m4an7npkj6i7n9q"; + }; + }; + + devInputs = [ + curl + glibc + icu + libblocksruntime + libbsd + libedit + libuuid + libxml2 + ncurses + sqlite + swig + ]; + + cmakeFlags = [ + "-DGLIBC_INCLUDE_PATH=${stdenv.cc.libc.dev}/include" + "-DC_INCLUDE_DIRS=${stdenv.lib.makeSearchPathOutput "dev" "include" devInputs}:${libxml2.dev}/include/libxml2" + "-DGCC_INSTALL_PREFIX=${clang.cc.gcc}" + ]; + + builder = '' + # gcc-6.4.0/include/c++/6.4.0/cstdlib:75:15: fatal error: 'stdlib.h' file not found + NIX_CFLAGS_COMPILE="$( echo ${clang.default_cxx_stdlib_compile} ) $NIX_CFLAGS_COMPILE" + + $SWIFT_SOURCE_ROOT/swift/utils/build-script \ + --preset=buildbot_linux \ + installable_package=$INSTALLABLE_PACKAGE \ + install_prefix=$out \ + install_destdir=$SWIFT_INSTALL_DIR \ + extra_cmake_options="${stdenv.lib.concatStringsSep "," cmakeFlags}"''; + +in +stdenv.mkDerivation rec { + name = "swift-${version_friendly}"; + + buildInputs = devInputs ++ [ + autoconf + automake + bash + clang + cmake + coreutils + libtool + ninja + perl + pkgconfig + python + rsync + which + findutils + makeWrapper + gnumake + ]; + + # TODO: Revisit what's propagated and how + propagatedBuildInputs = [ + libgit2 + python + ]; + propagatedUserEnvPkgs = [ git pkgconfig ]; + + hardeningDisable = [ "format" ]; # for LLDB + + configurePhase = '' + cd .. + + export INSTALLABLE_PACKAGE=$PWD/swift.tar.gz + + mkdir build install + export SWIFT_BUILD_ROOT=$PWD/build + export SWIFT_INSTALL_DIR=$PWD/install + + cd $SWIFT_BUILD_ROOT + + unset CC + unset CXX + + export NIX_ENFORCE_PURITY= + ''; + + unpackPhase = '' + mkdir src + cd src + export sourceRoot=$PWD + export SWIFT_SOURCE_ROOT=$PWD + + cp -r ${sources.clang} clang + cp -r ${sources.llvm} llvm + cp -r ${sources.compilerrt} compiler-rt + cp -r ${sources.cmark} cmark + cp -r ${sources.lldb} lldb + cp -r ${sources.llbuild} llbuild + cp -r ${sources.pm} swiftpm + cp -r ${sources.xctest} swift-corelibs-xctest + cp -r ${sources.foundation} swift-corelibs-foundation + cp -r ${sources.libdispatch} swift-corelibs-libdispatch + cp -r ${sources.swift} swift + + chmod -R u+w . + ''; + + patchPhase = '' + # Just patch all the things for now, we can focus this later + patchShebangs $SWIFT_SOURCE_ROOT + + # TODO eliminate use of env. + find -type f -print0 | xargs -0 sed -i \ + -e 's|/usr/bin/env|${coreutils}/bin/env|g' \ + -e 's|/usr/bin/make|${gnumake}/bin/make|g' \ + -e 's|/bin/mkdir|${coreutils}/bin/mkdir|g' \ + -e 's|/bin/cp|${coreutils}/bin/cp|g' \ + -e 's|/usr/bin/file|${file}/bin/file|g' + + substituteInPlace swift/stdlib/public/Platform/CMakeLists.txt \ + --replace '/usr/include' "${stdenv.cc.libc.dev}/include" + substituteInPlace swift-corelibs-libdispatch/src/CMakeLists.txt \ + --replace '/usr/include' "${stdenv.cc.libc.dev}/include" + substituteInPlace swift/utils/build-script-impl \ + --replace '/usr/include/c++' "${clang.cc.gcc}/include/c++" + patch -p1 -d swift -i ${./patches/glibc-arch-headers.patch} + patch -p1 -d swift -i ${./patches/0001-build-presets-linux-don-t-require-using-Ninja.patch} + patch -p1 -d swift -i ${./patches/0002-build-presets-linux-allow-custom-install-prefix.patch} + patch -p1 -d swift -i ${./patches/0004-build-presets-linux-plumb-extra-cmake-options.patch} + + sed -i swift/utils/build-presets.ini \ + -e 's/^test-installable-package$/# \0/' \ + -e 's/^test$/# \0/' \ + -e 's/^validation-test$/# \0/' \ + -e 's/^long-test$/# \0/' \ + -e 's/^stress-test$/# \0/' \ + -e 's/^test-optimized$/# \0/' + + # https://bugs.swift.org/browse/SR-5779 + sed -i -e 's|"-latomic"|"-Wl,-rpath,${clang.cc.gcc.lib}/lib" "-L${clang.cc.gcc.lib}/lib" "-latomic"|' swift/cmake/modules/AddSwift.cmake + + substituteInPlace clang/lib/Driver/ToolChains/Linux.cpp \ + --replace 'SysRoot + "/usr/lib' '"${glibc}/lib" "' + patch -p1 -d clang -i ${./patches/llvm-include-dirs.patch} + patch -p1 -d clang -i ${./purity.patch} + + # Workaround hardcoded dep on "libcurses" (vs "libncurses"): + sed -i 's,curses,ncurses,' llbuild/*/*/CMakeLists.txt + + PREFIX=''${out/#\/} + substituteInPlace swift-corelibs-foundation/build.py \ + --replace usr/lib "$PREFIX/lib" + substituteInPlace swift-corelibs-xctest/build_script.py \ + --replace usr "$PREFIX" + substituteInPlace swiftpm/Utilities/bootstrap \ + --replace \"usr\" \"$PREFIX\" \ + --replace usr/lib "$PREFIX/lib" + ''; + + doCheck = false; + + buildPhase = builder; + + installPhase = '' + mkdir -p $out + + # Extract the generated tarball into the store + PREFIX=''${out/#\/} + tar xf $INSTALLABLE_PACKAGE -C $out --strip-components=3 $PREFIX + find $out -type d -empty -delete + + # TODO: Use wrappers to get these on the PATH for swift tools, instead + ln -s ${clang}/bin/* $out/bin/ + ln -s ${targetPackages.stdenv.cc.bintools.bintools_bin}/bin/ar $out/bin/ar + + wrapProgram $out/bin/swift \ + --suffix C_INCLUDE_PATH : $out/lib/swift/clang/include \ + --suffix CPLUS_INCLUDE_PATH : $out/lib/swift/clang/include + ''; + + # Hack to avoid TMPDIR in RPATHs. + preFixup = ''rm -rf "$(pwd)" ''; + + meta = with stdenv.lib; { + description = "The Swift Programming Language"; + homepage = https://github.com/apple/swift; + maintainers = with maintainers; [ dtzWill ]; + license = licenses.asl20; + # Swift doesn't support 32bit Linux, unknown on other platforms. + platforms = platforms.linux; + badPlatforms = platforms.i686; + broken = stdenv.isAarch64; # 2018-09-04, never built on Hydra + }; +} diff --git a/nixpkgs/pkgs/development/compilers/swift/patches/0001-build-presets-linux-don-t-require-using-Ninja.patch b/nixpkgs/pkgs/development/compilers/swift/patches/0001-build-presets-linux-don-t-require-using-Ninja.patch new file mode 100644 index 000000000000..f2b30e5dcdb6 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/swift/patches/0001-build-presets-linux-don-t-require-using-Ninja.patch @@ -0,0 +1,25 @@ +From 1fc49285c7a198de14005803dfde64bda17f4120 Mon Sep 17 00:00:00 2001 +From: Will Dietz <w@wdtz.org> +Date: Tue, 28 Mar 2017 15:01:16 -0500 +Subject: [PATCH 1/4] build-presets: (linux) don't require using Ninja + +--- + utils/build-presets.ini | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/utils/build-presets.ini b/utils/build-presets.ini +index 7ee57ad2df..e6b0af3581 100644 +--- a/utils/build-presets.ini ++++ b/utils/build-presets.ini +@@ -717,7 +717,7 @@ swiftpm + xctest + dash-dash + +-build-ninja ++# build-ninja + install-swift + install-lldb + install-llbuild +-- +2.12.2 + diff --git a/nixpkgs/pkgs/development/compilers/swift/patches/0002-build-presets-linux-allow-custom-install-prefix.patch b/nixpkgs/pkgs/development/compilers/swift/patches/0002-build-presets-linux-allow-custom-install-prefix.patch new file mode 100644 index 000000000000..612b33cdb483 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/swift/patches/0002-build-presets-linux-allow-custom-install-prefix.patch @@ -0,0 +1,25 @@ +From fca6624b7a0ad670157105336a737cc95f9ce9fb Mon Sep 17 00:00:00 2001 +From: Will Dietz <w@wdtz.org> +Date: Tue, 28 Mar 2017 15:01:40 -0500 +Subject: [PATCH 2/4] build-presets: (linux) allow custom install prefix + +--- + utils/build-presets.ini | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/utils/build-presets.ini b/utils/build-presets.ini +index e6b0af3581..1095cbaab7 100644 +--- a/utils/build-presets.ini ++++ b/utils/build-presets.ini +@@ -723,7 +723,7 @@ install-lldb + install-llbuild + install-swiftpm + install-xctest +-install-prefix=/usr ++install-prefix=%(install_prefix)s + swift-install-components=autolink-driver;compiler;clang-builtin-headers;stdlib;swift-remote-mirror;sdk-overlay;license;sourcekit-inproc + build-swift-static-stdlib + build-swift-static-sdk-overlay +-- +2.12.2 + diff --git a/nixpkgs/pkgs/development/compilers/swift/patches/0004-build-presets-linux-plumb-extra-cmake-options.patch b/nixpkgs/pkgs/development/compilers/swift/patches/0004-build-presets-linux-plumb-extra-cmake-options.patch new file mode 100644 index 000000000000..e84c7eb2a08a --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/swift/patches/0004-build-presets-linux-plumb-extra-cmake-options.patch @@ -0,0 +1,25 @@ +From 4a46b12f580d0a9779937d07c4f1fd347570c4ef Mon Sep 17 00:00:00 2001 +From: Will Dietz <w@wdtz.org> +Date: Tue, 28 Mar 2017 15:02:37 -0500 +Subject: [PATCH 4/4] build-presets: (linux) plumb extra-cmake-options + +--- + utils/build-presets.ini | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/utils/build-presets.ini b/utils/build-presets.ini +index 1739e91dc2..0608fed9c1 100644 +--- a/utils/build-presets.ini ++++ b/utils/build-presets.ini +@@ -740,6 +740,8 @@ install-destdir=%(install_destdir)s + # Path to the .tar.gz package we would create. + installable-package=%(installable_package)s + ++extra-cmake-options=%(extra_cmake_options)s ++ + [preset: buildbot_linux] + mixin-preset=mixin_linux_installation + build-subdir=buildbot_linux +-- +2.12.2 + diff --git a/nixpkgs/pkgs/development/compilers/swift/patches/glibc-arch-headers.patch b/nixpkgs/pkgs/development/compilers/swift/patches/glibc-arch-headers.patch new file mode 100644 index 000000000000..650e1a2429d4 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/swift/patches/glibc-arch-headers.patch @@ -0,0 +1,13 @@ +The Nix glibc headers do not use include/x86_64-linux-gnu subdirectories. + +--- swift/stdlib/public/Platform/CMakeLists.txt 2018-09-30 17:51:51.581766303 +0200 ++++ swift/stdlib/public/Platform/CMakeLists.txt 2018-09-30 18:40:04.118956708 +0200 +@@ -65,7 +65,7 @@ + endif() + + set(GLIBC_INCLUDE_PATH "${GLIBC_SYSROOT_RELATIVE_INCLUDE_PATH}") +- set(GLIBC_ARCH_INCLUDE_PATH "${GLIBC_SYSROOT_RELATIVE_ARCH_INCLUDE_PATH}") ++ set(GLIBC_ARCH_INCLUDE_PATH "${GLIBC_SYSROOT_RELATIVE_INCLUDE_PATH}") + + if(NOT "${SWIFT_SDK_${sdk}_ARCH_${arch}_PATH}" STREQUAL "/") + set(GLIBC_INCLUDE_PATH "${SWIFT_SDK_${sdk}_ARCH_${arch}_PATH}${GLIBC_INCLUDE_PATH}") diff --git a/nixpkgs/pkgs/development/compilers/swift/patches/llvm-include-dirs.patch b/nixpkgs/pkgs/development/compilers/swift/patches/llvm-include-dirs.patch new file mode 100644 index 000000000000..9523943c4801 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/swift/patches/llvm-include-dirs.patch @@ -0,0 +1,13 @@ +Only use the Nix include dirs when no sysroot is configured. + +--- clang/lib/Driver/ToolChains/Linux.cpp 2018-10-05 18:01:15.731109551 +0200 ++++ clang/lib/Driver/ToolChains/Linux.cpp 2018-10-05 18:00:27.959509924 +0200 +@@ -565,7 +565,7 @@ + + // Check for configure-time C include directories. + StringRef CIncludeDirs(C_INCLUDE_DIRS); +- if (CIncludeDirs != "") { ++ if (CIncludeDirs != "" && (SysRoot.empty() || SysRoot == "/")) { + SmallVector<StringRef, 5> dirs; + CIncludeDirs.split(dirs, ":"); + for (StringRef dir : dirs) { diff --git a/nixpkgs/pkgs/development/compilers/swift/purity.patch b/nixpkgs/pkgs/development/compilers/swift/purity.patch new file mode 100644 index 000000000000..d10e407260a5 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/swift/purity.patch @@ -0,0 +1,30 @@ +From 4add81bba40dcec62c4ea4481be8e35ac53e89d8 Mon Sep 17 00:00:00 2001 +From: Will Dietz <w@wdtz.org> +Date: Thu, 18 May 2017 11:56:12 -0500 +Subject: [PATCH] "purity" patch for 5.0 + +--- + lib/Driver/ToolChains/Gnu.cpp | 7 ------- + 1 file changed, 7 deletions(-) + +diff --git a/lib/Driver/ToolChains/Gnu.cpp b/lib/Driver/ToolChains/Gnu.cpp +index fe3c0191bb..c6a482bece 100644 +--- a/lib/Driver/ToolChains/Gnu.cpp ++++ b/lib/Driver/ToolChains/Gnu.cpp +@@ -398,13 +398,6 @@ void tools::gnutools::Linker::ConstructJob(Compilation &C, const JobAction &JA, + if (!Args.hasArg(options::OPT_static)) { + if (Args.hasArg(options::OPT_rdynamic)) + CmdArgs.push_back("-export-dynamic"); +- +- if (!Args.hasArg(options::OPT_shared)) { +- const std::string Loader = +- D.DyldPrefix + ToolChain.getDynamicLinker(Args); +- CmdArgs.push_back("-dynamic-linker"); +- CmdArgs.push_back(Args.MakeArgString(Loader)); +- } + } + + CmdArgs.push_back("-o"); +-- +2.11.0 + diff --git a/nixpkgs/pkgs/development/compilers/terra/default.nix b/nixpkgs/pkgs/development/compilers/terra/default.nix new file mode 100644 index 000000000000..312facde9489 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/terra/default.nix @@ -0,0 +1,63 @@ +{ stdenv, fetchFromGitHub, fetchurl, llvmPackages, ncurses, lua }: + +let + luajitArchive = "LuaJIT-2.0.5.tar.gz"; + luajitSrc = fetchurl { + url = "http://luajit.org/download/${luajitArchive}"; + sha256 = "0yg9q4q6v028bgh85317ykc9whgxgysp76qzaqgq55y6jy11yjw7"; + }; +in + +stdenv.mkDerivation rec { + name = "terra-git-${version}"; + version = "1.0.0-beta1"; + + src = fetchFromGitHub { + owner = "zdevito"; + repo = "terra"; + rev = "release-${version}"; + sha256 = "1blv3mbmlwb6fxkck6487ck4qq67cbwq6s1zlp86hy2wckgf8q2c"; + }; + + outputs = [ "bin" "dev" "out" "static" ]; + + postPatch = '' + substituteInPlace Makefile --replace \ + '-lcurses' '-lncurses' + ''; + + preBuild = '' + cat >Makefile.inc<<EOF + CLANG = ${stdenv.lib.getBin llvmPackages.clang-unwrapped}/bin/clang + LLVM_CONFIG = ${stdenv.lib.getBin llvmPackages.llvm}/bin/llvm-config + EOF + + mkdir -p build + cp ${luajitSrc} build/${luajitArchive} + ''; + + installPhase = '' + mkdir -pv $out/lib + cp -v release/lib/terra.so $out/lib + + mkdir -pv $bin/bin + cp -v release/bin/terra $bin/bin + + mkdir -pv $static/lib + cp -v release/lib/libterra.a $static/lib + + mkdir -pv $dev/include + cp -rv release/include/terra $dev/include + '' + ; + + buildInputs = with llvmPackages; [ lua llvm clang-unwrapped ncurses ]; + + meta = with stdenv.lib; { + inherit (src.meta) homepage; + description = "A low-level counterpart to Lua"; + platforms = [ "x86_64-linux" ]; + maintainers = with maintainers; [ jb55 ]; + license = licenses.mit; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/teyjus/default.nix b/nixpkgs/pkgs/development/compilers/teyjus/default.nix new file mode 100644 index 000000000000..04efe1a91342 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/teyjus/default.nix @@ -0,0 +1,34 @@ +{ stdenv, fetchurl, omake, ocaml, flex, bison }: + +let + version = "2.1"; +in + +stdenv.mkDerivation { + name = "teyjus-${version}"; + + src = fetchurl { + url = "https://github.com/teyjus/teyjus/archive/v${version}.tar.gz"; + sha256 = "0393wpg8v1vvarqy2xh4fdmrwlrl6jaj960kql7cq79mb9p3m269"; + }; + + patches = [ ./fix-lex-to-flex.patch ]; + + buildInputs = [ omake ocaml flex bison ]; + + hardeningDisable = [ "format" ]; + + buildPhase = "omake all"; + + checkPhase = "omake check"; + + installPhase = "mkdir -p $out/bin && cp tj* $out/bin"; + + meta = with stdenv.lib; { + description = "An efficient implementation of the Lambda Prolog language"; + homepage = https://github.com/teyjus/teyjus; + license = stdenv.lib.licenses.gpl3; + maintainers = [ maintainers.bcdarwin ]; + platforms = platforms.linux; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/teyjus/fix-lex-to-flex.patch b/nixpkgs/pkgs/development/compilers/teyjus/fix-lex-to-flex.patch new file mode 100644 index 000000000000..fa82d80633ad --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/teyjus/fix-lex-to-flex.patch @@ -0,0 +1,25 @@ +diff --git a/source/OMakefile b/source/OMakefile +index e6bd37e..1bbc0a8 100644 +--- a/source/OMakefile ++++ b/source/OMakefile +@@ -184,6 +184,12 @@ DEP_MAIN = $(FNT)/dependfront + PAR_MAIN = $(FNT)/parsefront + + ############################################################ ++# Nixpkgs specific changes ++# ++ ++LEX = flex ++ ++############################################################ + # Platform specific changes + # + +@@ -194,7 +200,6 @@ if $(mem $(SYSNAME), Linux) + + if $(mem $(OSTYPE), Cygwin Win32) + YACC = bison -by +- LEX = flex + CC = i686-pc-mingw32-gcc + INC_C[] += $(INC)/byteswap $(INC)/search + export diff --git a/nixpkgs/pkgs/development/compilers/tinycc/default.nix b/nixpkgs/pkgs/development/compilers/tinycc/default.nix new file mode 100644 index 000000000000..a5c3db65857f --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/tinycc/default.nix @@ -0,0 +1,69 @@ +{ stdenv, fetchFromRepoOrCz, perl, texinfo }: +with stdenv.lib; + +stdenv.mkDerivation rec { + name = "tcc-${version}"; + version = "0.9.27"; + + src = fetchFromRepoOrCz { + repo = "tinycc"; + rev = "release_0_9_27"; + sha256 = "12mm1lqywz0akr2yb2axjfbw8lwv57nh395vzsk534riz03ml977"; + }; + + nativeBuildInputs = [ perl texinfo ]; + + hardeningDisable = [ "fortify" ]; + + postPatch = '' + substituteInPlace "texi2pod.pl" \ + --replace "/usr/bin/perl" "${perl}/bin/perl" + ''; + + preConfigure = '' + echo ${version} > VERSION + + configureFlagsArray+=("--cc=cc") + configureFlagsArray+=("--elfinterp=$(< $NIX_CC/nix-support/dynamic-linker)") + configureFlagsArray+=("--crtprefix=${getLib stdenv.cc.libc}/lib") + configureFlagsArray+=("--sysincludepaths=${getDev stdenv.cc.libc}/include:{B}/include") + configureFlagsArray+=("--libpaths=${getLib stdenv.cc.libc}/lib") + ''; + + doCheck = true; + checkTarget = "test"; + + meta = { + description = "Small, fast, and embeddable C compiler and interpreter"; + + longDescription = '' + TinyCC (aka TCC) is a small but hyper fast C compiler. Unlike + other C compilers, it is meant to be self-sufficient: you do not + need an external assembler or linker because TCC does that for + you. + + TCC compiles so fast that even for big projects Makefiles may not + be necessary. + + TCC not only supports ANSI C, but also most of the new ISO C99 + standard and many GNU C extensions. + + TCC can also be used to make C scripts, i.e. pieces of C source + that you run as a Perl or Python script. Compilation is so fast + that your script will be as fast as if it was an executable. + + TCC can also automatically generate memory and bound checks while + allowing all C pointers operations. TCC can do these checks even + if non patched libraries are used. + + With libtcc, you can use TCC as a backend for dynamic code + generation. + ''; + + homepage = http://www.tinycc.org/; + license = licenses.mit; + + platforms = [ "x86_64-linux" ]; + maintainers = [ maintainers.joachifm ]; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/urn/default.nix b/nixpkgs/pkgs/development/compilers/urn/default.nix new file mode 100644 index 000000000000..d5f0dcbec29f --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/urn/default.nix @@ -0,0 +1,61 @@ +{ stdenv, fetchFromGitLab, buildEnv, makeWrapper, lua, luajit, readline +, useLuaJit ? false +, extraLibraries ? [] +}: + +let + version = "0.7.2"; + # Build a sort of "union package" with all the native dependencies we + # have: Lua (or LuaJIT), readline, etc. Then, we can depend on this + # and refer to ${urn-rt} instead of ${lua}, ${readline}, etc. + urn-rt = buildEnv { + name = "urn-rt-${version}"; + ignoreCollisions = true; + paths = if useLuaJit then + [ luajit readline ] + else + [ lua ]; + }; + + inherit (stdenv.lib) optionalString concatMapStringsSep; +in + +stdenv.mkDerivation rec { + name = "urn-${optionalString (extraLibraries != []) "with-libraries-"}${version}"; + + src = fetchFromGitLab { + owner = "urn"; + repo = "urn"; + rev = "v${version}"; + sha256 = "0nclr3d8ap0y5cg36i7g4ggdqci6m5q27y9f26b57km8p266kcpy"; + }; + + buildInputs = [ makeWrapper ]; + # Any packages that depend on the compiler have a transitive + # dependency on the Urn runtime support. + propagatedBuildInputs = [ urn-rt ]; + + makeFlags = ["-B"]; + + installPhase = '' + mkdir -p $out/bin $out/lib + install -m 0755 bin/urn.lua $out/bin/urn + cp -r lib $out/lib/urn + wrapProgram $out/bin/urn \ + --add-flags "-i $out/lib/urn --prelude $out/lib/urn/prelude.lisp" \ + --add-flags "${concatMapStringsSep " " (x: "-i ${x.libraryPath}") extraLibraries}" \ + --prefix PATH : ${urn-rt}/bin/ \ + --prefix LD_LIBRARY_PATH : ${urn-rt}/lib/ + ''; + + meta = with stdenv.lib; { + homepage = https://urn-lang.com; + description = "Yet another Lisp variant which compiles to Lua"; + license = licenses.bsd3; + maintainers = with maintainers; [ CrazedProgrammer ]; + }; + + passthru = { + inherit urn-rt; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/urweb/default.nix b/nixpkgs/pkgs/development/compilers/urweb/default.nix new file mode 100644 index 000000000000..d81ddd9b58f7 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/urweb/default.nix @@ -0,0 +1,45 @@ +{ stdenv, fetchurl, file, openssl, mlton +, mysql, postgresql, sqlite, gcc +}: + +stdenv.mkDerivation rec { + name = "urweb-${version}"; + version = "20180616"; + + src = fetchurl { + url = "https://github.com/urweb/urweb/releases/download/${version}/${name}.tar.gz"; + sha256 = "04iy2ky78q6w0d2xyfz2a1k26g2yrwsh1hw1bgs5ia9v3ih965r1"; + }; + + buildInputs = [ openssl mlton mysql.connector-c postgresql sqlite ]; + + prePatch = '' + sed -e 's@/usr/bin/file@${file}/bin/file@g' -i configure + ''; + + configureFlags = [ "--with-openssl=${openssl.dev}" ]; + + preConfigure = '' + export PGHEADER="${postgresql}/include/libpq-fe.h"; + export MSHEADER="${mysql.connector-c}/include/mysql/mysql.h"; + export SQHEADER="${sqlite.dev}/include/sqlite3.h"; + + export CC="${gcc}/bin/gcc"; + export CCARGS="-I$out/include \ + -L${openssl.out}/lib \ + -L${mysql.connector-c}/lib \ + -L${postgresql.lib}/lib \ + -L${sqlite.out}/lib"; + ''; + + # Be sure to keep the statically linked libraries + dontDisableStatic = true; + + meta = { + description = "Advanced purely-functional web programming language"; + homepage = "http://www.impredicative.com/ur/"; + license = stdenv.lib.licenses.bsd3; + platforms = stdenv.lib.platforms.linux ++ stdenv.lib.platforms.darwin; + maintainers = [ stdenv.lib.maintainers.thoughtpolice stdenv.lib.maintainers.sheganinans ]; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/vala/default.nix b/nixpkgs/pkgs/development/compilers/vala/default.nix new file mode 100644 index 000000000000..dfd40c92ecfa --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/vala/default.nix @@ -0,0 +1,136 @@ +{ stdenv, lib, fetchurl, fetchpatch, pkgconfig, flex, bison, libxslt, autoconf, automake, autoreconfHook +, graphviz, glib, libiconv, libintl, libtool, expat, substituteAll +}: + +let + generic = lib.makeOverridable ({ + major, minor, sha256, + extraNativeBuildInputs ? [], + extraBuildInputs ? [], + withGraphviz ? false + }: + let + atLeast = lib.versionAtLeast "${major}.${minor}"; + + # Patches from the openembedded-core project to build vala without graphviz + # support. We need to apply an additional patch to allow building when the + # header file isn't available at all, but that patch (./gvc-compat.patch) + # can be shared between all versions of Vala so far. + graphvizPatch = + let + fp = { commit, sha256 }: fetchpatch { + url = "https://github.com/openembedded/openembedded-core/raw/${commit}/meta/recipes-devtools/vala/vala/disable-graphviz.patch"; + inherit sha256; + }; + + in { + "0.38" = fp { + commit = "2c290f7253bba5ceb0d32e7d0b0ec0d0e81cc263"; + sha256 = "056ybapfx18d7xw1k8k85nsjrc26qk2q2d9v9nz2zrcwbq5brhkp"; + }; + + # NOTE: the openembedded-core project doesn't have a patch for 0.40.12 + # We've fixed the single merge conflict in the following patch. + # 0.40.12: https://github.com/openembedded/openembedded-core/raw/8553c52f174af4c8c433c543f806f5ed5c1ec48c/meta/recipes-devtools/vala/vala/disable-graphviz.patch + "0.40" = ./disable-graphviz-0.40.12.patch; + + "0.42" = fp { + commit = "f2b4f9ec6f44dced7f88df849cca68961419eeb8"; + sha256 = "112qhdzix0d7lfpfcam1cxprzmfzpwypb1226m5ma1vq9qy0sn7g"; + }; + + # NOTE: the openembedded-core project doesn't have a patch for 0.44.1 + # We've reverted the addition of the "--disable-valadoc" option + # and then applied the following patch. + # 0.42.4: https://github.com/openembedded/openembedded-core/raw/f2b4f9ec6f44dced7f88df849cca68961419eeb8/meta/recipes-devtools/vala/vala/disable-graphviz.patch + "0.44" = ./disable-graphviz-0.44.1.patch; + + }.${major} or (throw "no graphviz patch for this version of vala"); + + disableGraphviz = atLeast "0.38" && !withGraphviz; + + in stdenv.mkDerivation rec { + name = "vala-${version}"; + version = "${major}.${minor}"; + + setupHook = substituteAll { + src = ./setup-hook.sh; + apiVersion = major; + }; + + src = fetchurl { + url = "mirror://gnome/sources/vala/${major}/${name}.tar.xz"; + inherit sha256; + }; + + postPatch = '' + patchShebangs tests + ''; + + # If we're disabling graphviz, apply the patches and corresponding + # configure flag. We also need to override the path to the valac compiler + # so that it can be used to regenerate documentation. + patches = lib.optionals disableGraphviz [ graphvizPatch ./gvc-compat.patch ]; + configureFlags = lib.optional disableGraphviz "--disable-graphviz"; + preBuild = lib.optional disableGraphviz "buildFlagsArray+=(\"VALAC=$(pwd)/compiler/valac\")"; + + outputs = [ "out" "devdoc" ]; + + nativeBuildInputs = [ + pkgconfig flex bison libxslt + ] ++ lib.optional (stdenv.isDarwin && (atLeast "0.38")) expat + ++ lib.optional disableGraphviz autoreconfHook # if we changed our ./configure script, need to reconfigure + ++ extraNativeBuildInputs; + + buildInputs = [ + glib libiconv libintl + ] ++ lib.optional (atLeast "0.38" && withGraphviz) graphviz + ++ extraBuildInputs; + + enableParallelBuilding = true; + + doCheck = false; # fails, requires dbus daemon + + meta = with stdenv.lib; { + description = "Compiler for GObject type system"; + homepage = https://wiki.gnome.org/Projects/Vala; + license = licenses.lgpl21Plus; + platforms = platforms.unix; + maintainers = with maintainers; [ antono jtojnar lethalman peterhoeg worldofpeace ]; + }; + }); + +in rec { + vala_0_36 = generic { + major = "0.36"; + minor = "18"; + sha256 = "0csb9skgy663y05kl813dsarzjbfcdsmx5fvz13p8gas3hycciq9"; + }; + + vala_0_38 = generic { + major = "0.38"; + minor = "10"; + sha256 = "1rdwwqs973qv225v8b5izcgwvqn56jxgr4pa3wxxbliar3aww5sw"; + extraNativeBuildInputs = [ autoconf ] ++ lib.optional stdenv.isDarwin libtool; + }; + + vala_0_40 = generic { + major = "0.40"; + minor = "14"; + sha256 = "0llid9b9cgjcrcclc0pw2skkssb7br7b2clq9cql3p14dl94gki0"; + }; + + vala_0_42 = generic { + major = "0.42"; + minor = "6"; + sha256 = "14024gvs23q323fmd62hqd8jiypaxbjjvamyd782ixbhxmpz8x1p"; + }; + + vala_0_44 = generic { + major = "0.44"; + minor = "1"; + sha256 = "1qiglkgymws6a3m8xz1v8b3na165ywx2dbipp3bdg134bi0w3a4n"; + }; + + vala = vala_0_44; +} diff --git a/nixpkgs/pkgs/development/compilers/vala/disable-graphviz-0.40.12.patch b/nixpkgs/pkgs/development/compilers/vala/disable-graphviz-0.40.12.patch new file mode 100644 index 000000000000..fdc1eabf513e --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/vala/disable-graphviz-0.40.12.patch @@ -0,0 +1,208 @@ +diff --git i/configure.ac w/configure.ac +index 694ffd200..915062053 100644 +--- i/configure.ac ++++ w/configure.ac +@@ -112,34 +112,38 @@ PKG_CHECK_MODULES(GMODULE, gmodule-2.0 >= $GLIB_REQUIRED) + AC_SUBST(GMODULE_CFLAGS) + AC_SUBST(GMODULE_LIBS) + +-PKG_CHECK_MODULES(LIBGVC, libgvc >= $LIBGVC_REQUIRED) +-AC_MSG_CHECKING([for CGRAPH]) +-cgraph_tmp_LIBADD="$LIBADD" +-cgraph_tmp_CFLAGS="$CFLAGS" +-LIBADD="$LIBADD $LIBGVC_LIBS" +-CFLAGS="$CFLAGS $LIBGVC_CFLAGS" +-AC_RUN_IFELSE( +- [AC_LANG_SOURCE([ +- #include <gvc.h> +- +- int main(void) { +- #ifdef WITH_CGRAPH +- return 0; +- #else +- return -1; +- #endif +- } +- ])], [ +- AC_MSG_RESULT([yes]) +- VALAFLAGS="$VALAFLAGS -D WITH_CGRAPH" +- have_cgraph=yes +- ], [ +- AC_MSG_RESULT([no]) +- have_cgraph=no +- ] +-) +-LIBADD="$cgraph_tmp_LIBADD" +-CFLAGS="$cgraph_tmp_CFLAGS" ++AC_ARG_ENABLE(graphviz, AS_HELP_STRING([--disable-graphviz], [Disable graphviz usage for valadoc]), enable_graphviz=$enableval, enable_graphviz=yes) ++if test x$enable_graphviz = xyes; then ++ PKG_CHECK_MODULES(LIBGVC, libgvc >= $LIBGVC_REQUIRED) ++ AC_MSG_CHECKING([for CGRAPH]) ++ VALAFLAGS="$VALAFLAGS -D HAVE_GRAPHVIZ" ++ cgraph_tmp_LIBADD="$LIBADD" ++ cgraph_tmp_CFLAGS="$CFLAGS" ++ LIBADD="$LIBADD $LIBGVC_LIBS" ++ CFLAGS="$CFLAGS $LIBGVC_CFLAGS" ++ AC_RUN_IFELSE( ++ [AC_LANG_SOURCE([ ++ #include <gvc.h> ++ int main(void) { ++ #ifdef WITH_CGRAPH ++ return 0; ++ #else ++ return -1; ++ #endif ++ } ++ ])], [ ++ AC_MSG_RESULT([yes]) ++ VALAFLAGS="$VALAFLAGS -D WITH_CGRAPH" ++ have_cgraph=yes ++ ], [ ++ AC_MSG_RESULT([no]) ++ have_cgraph=no ++ ] ++ ) ++ LIBADD="$cgraph_tmp_LIBADD" ++ CFLAGS="$cgraph_tmp_CFLAGS" ++fi ++AM_CONDITIONAL(ENABLE_GRAPHVIZ, test x$enable_graphviz = xyes) + AM_CONDITIONAL(HAVE_CGRAPH, test "$have_cgraph" = "yes") + + AC_PATH_PROG([XSLTPROC], [xsltproc], :) +diff --git i/libvaladoc/Makefile.am w/libvaladoc/Makefile.am +index f3f790e76..3c5dc4c80 100644 +--- i/libvaladoc/Makefile.am ++++ w/libvaladoc/Makefile.am +@@ -128,10 +128,6 @@ libvaladoc_la_VALASOURCES = \ + content/tablerow.vala \ + content/taglet.vala \ + content/text.vala \ +- charts/chart.vala \ +- charts/chartfactory.vala \ +- charts/hierarchychart.vala \ +- charts/simplechartfactory.vala \ + parser/manyrule.vala \ + parser/oneofrule.vala \ + parser/optionalrule.vala \ +@@ -158,13 +154,24 @@ libvaladoc_la_VALASOURCES = \ + highlighter/codetoken.vala \ + highlighter/highlighter.vala \ + html/basicdoclet.vala \ +- html/htmlchartfactory.vala \ + html/linkhelper.vala \ + html/cssclassresolver.vala \ + html/htmlmarkupwriter.vala \ + html/htmlrenderer.vala \ + $(NULL) + ++if ENABLE_GRAPHVIZ ++libvaladoc_la_VALASOURCES += \ ++ charts/chart.vala \ ++ charts/chartfactory.vala \ ++ charts/hierarchychart.vala \ ++ charts/simplechartfactory.vala \ ++ html/htmlchartfactory.vala \ ++ $(NULL) ++ ++LIBGVC_PKG = --vapidir $(top_srcdir)/vapi --pkg libgvc ++endif ++ + libvaladoc@PACKAGE_SUFFIX@_la_SOURCES = \ + libvaladoc.vala.stamp \ + $(libvaladoc_la_VALASOURCES:.vala=.c) \ +@@ -184,11 +191,11 @@ libvaladoc.vala.stamp: $(libvaladoc_la_VALASOURCES) + --library valadoc \ + --vapi valadoc@PACKAGE_SUFFIX@.vapi \ + --vapidir $(top_srcdir)/vapi --pkg gmodule-2.0 \ +- --vapidir $(top_srcdir)/vapi --pkg libgvc \ + --vapidir $(top_srcdir)/gee --pkg gee \ + --vapidir $(top_srcdir)/vala --pkg vala \ + --vapidir $(top_srcdir)/ccode --pkg ccode \ + --vapidir $(top_srcdir)/codegen --pkg codegen \ ++ $(LIBGVC_PKG) \ + --pkg config \ + $(filter %.vala %.c,$^) + touch $@ +@@ -217,6 +224,9 @@ nodist_pkgconfig_DATA = valadoc@PACKAGE_SUFFIX@.pc + + valadoc@PACKAGE_SUFFIX@.pc: valadoc.pc + cp $< $@ ++if !ENABLE_GRAPHVIZ ++ sed -i "s/libgvc //g" $@ ++endif + + vapidir = $(datadir)/vala/vapi + dist_vapi_DATA = valadoc@PACKAGE_SUFFIX@.vapi +@@ -224,6 +234,9 @@ nodist_vapi_DATA = valadoc@PACKAGE_SUFFIX@.deps + + valadoc@PACKAGE_SUFFIX@.deps: valadoc.deps + cp $< $@ ++if !ENABLE_GRAPHVIZ ++ sed -i "s/libgvc//g" $@ ++endif + + EXTRA_DIST = \ + $(libvaladoc_la_VALASOURCES) \ +diff --git i/libvaladoc/html/basicdoclet.vala w/libvaladoc/html/basicdoclet.vala +index 192e488cd..ec0960222 100644 +--- i/libvaladoc/html/basicdoclet.vala ++++ w/libvaladoc/html/basicdoclet.vala +@@ -46,7 +46,11 @@ public abstract class Valadoc.Html.BasicDoclet : Api.Visitor, Doclet { + protected HtmlRenderer _renderer; + protected Html.MarkupWriter writer; + protected Html.CssClassResolver cssresolver; ++#if HAVE_GRAPHVIZ + protected Charts.Factory image_factory; ++#else ++ protected void* image_factory; ++#endif + protected ErrorReporter reporter; + protected string package_list_link = "../index.html"; + +@@ -120,7 +124,9 @@ public abstract class Valadoc.Html.BasicDoclet : Api.Visitor, Doclet { + this.linker = new LinkHelper (); + + _renderer = new HtmlRenderer (settings, this.linker, this.cssresolver); ++#if HAVE_GRAPHVIZ + this.image_factory = new SimpleChartFactory (settings, linker); ++#endif + } + + +@@ -1026,6 +1032,7 @@ public abstract class Valadoc.Html.BasicDoclet : Api.Visitor, Doclet { + } + + protected void write_image_block (Api.Node element) { ++#if HAVE_GRAPHVIZ + if (element is Class || element is Interface || element is Struct) { + unowned string format = (settings.use_svg_images ? "svg" : "png"); + var chart = new Charts.Hierarchy (image_factory, element); +@@ -1045,6 +1052,7 @@ public abstract class Valadoc.Html.BasicDoclet : Api.Visitor, Doclet { + this.get_img_path_html (element, format)}); + writer.add_usemap (chart); + } ++#endif + } + + public void write_namespace_content (Namespace node, Api.Node? parent) { +diff --git i/libvaladoc/html/htmlmarkupwriter.vala w/libvaladoc/html/htmlmarkupwriter.vala +index dcc4dad76..cf9c860b8 100644 +--- i/libvaladoc/html/htmlmarkupwriter.vala ++++ w/libvaladoc/html/htmlmarkupwriter.vala +@@ -51,12 +51,16 @@ public class Valadoc.Html.MarkupWriter : Valadoc.MarkupWriter { + } + } + ++#if HAVE_GRAPHVIZ + public MarkupWriter add_usemap (Charts.Chart chart) { + string? buf = (string?) chart.write_buffer ("cmapx"); + if (buf != null) { + raw_text ("\n"); + raw_text ((!) buf); + } ++#else ++ public MarkupWriter add_usemap (void* chart) { ++#endif + + return this; + } diff --git a/nixpkgs/pkgs/development/compilers/vala/disable-graphviz-0.44.1.patch b/nixpkgs/pkgs/development/compilers/vala/disable-graphviz-0.44.1.patch new file mode 100644 index 000000000000..2752aa1e2050 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/vala/disable-graphviz-0.44.1.patch @@ -0,0 +1,261 @@ +diff --git a/Makefile.am b/Makefile.am +index f70234759..b3d6c3833 100644 +--- a/Makefile.am ++++ b/Makefile.am +@@ -13,19 +13,9 @@ SUBDIRS = \ + doc \ + gobject-introspection \ + vapigen \ +- $(NULL) +- +-if ENABLE_VALADOC +-SUBDIRS += \ + libvaladoc \ + valadoc \ + $(NULL) +-endif +- +-DISTCHECK_CONFIGURE_FLAGS = \ +- --enable-valadoc \ +- --enable-unversioned \ +- $(NULL) + + if ENABLE_UNVERSIONED + aclocaldir = $(datadir)/aclocal +diff --git a/configure.ac b/configure.ac +index 16ebd1f81..cf23db4b8 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -156,10 +156,11 @@ PKG_CHECK_MODULES(GMODULE, gmodule-2.0 >= $GLIB_REQUIRED) + AC_SUBST(GMODULE_CFLAGS) + AC_SUBST(GMODULE_LIBS) + +-AC_ARG_ENABLE(valadoc, AS_HELP_STRING([--disable-valadoc], [Disable valadoc]), enable_valadoc=$enableval, enable_valadoc=yes) +-if test x$enable_valadoc = xyes; then ++AC_ARG_ENABLE(graphviz, AS_HELP_STRING([--disable-graphviz], [Disable graphviz usage for valadoc]), enable_graphviz=$enableval, enable_graphviz=yes) ++if test x$enable_graphviz = xyes; then + PKG_CHECK_MODULES(LIBGVC, libgvc >= $LIBGVC_REQUIRED) + AC_MSG_CHECKING([for CGRAPH]) ++ VALAFLAGS="$VALAFLAGS -D HAVE_GRAPHVIZ" + cgraph_tmp_LIBADD="$LIBADD" + cgraph_tmp_CFLAGS="$CFLAGS" + LIBADD="$LIBADD $LIBGVC_LIBS" +@@ -186,8 +187,8 @@ if test x$enable_valadoc = xyes; then + LIBADD="$cgraph_tmp_LIBADD" + CFLAGS="$cgraph_tmp_CFLAGS" + fi ++AM_CONDITIONAL(ENABLE_GRAPHVIZ, test x$enable_graphviz = xyes) + AM_CONDITIONAL(HAVE_CGRAPH, test "$have_cgraph" = "yes") +-AM_CONDITIONAL(ENABLE_VALADOC, test x$enable_valadoc = xyes) + + AC_PATH_PROG([XSLTPROC], [xsltproc], :) + AM_CONDITIONAL(HAVE_XSLTPROC, test "$XSLTPROC" != :) +diff --git a/doc/Makefile.am b/doc/Makefile.am +index d2684a0e0..b343c7c10 100644 +--- a/doc/Makefile.am ++++ b/doc/Makefile.am +@@ -6,16 +6,11 @@ SUBDIRS = \ + + dist_man_MANS = \ + valac.1 \ ++ valadoc.1 \ + vala-gen-introspect.1 \ + vapigen.1 \ + $(NULL) + +-if ENABLE_VALADOC +-dist_man_MANS += \ +- valadoc.1 \ +- $(NULL) +-endif +- + EXTRA_DIST = \ + valac.h2m \ + valadoc.h2m \ +@@ -24,11 +19,7 @@ EXTRA_DIST = \ + $(NULL) + + if HAVE_HELP2MAN +-if ENABLE_VALADOC + manpages: valac.1 valadoc.1 vala-gen-introspect.1 vapigen.1 +-else +-manpages: valac.1 vala-gen-introspect.1 vapigen.1 +-endif + @rm $^ + $(MAKE) $(AM_MAKEFLAGS) $^ + +@@ -37,13 +28,11 @@ valac.1: + --include $(srcdir)/valac.h2m \ + --libtool --no-info \ + --output=$@ +-if ENABLE_VALADOC + valadoc.1: + $(HELP2MAN) $(top_builddir)/valadoc/valadoc \ + --include $(srcdir)/valadoc.h2m \ + --libtool --no-info \ + --output=$@ +-endif + vala-gen-introspect.1: + $(HELP2MAN) $(top_builddir)/gobject-introspection/gen-introspect \ + --include $(srcdir)/vala-gen-introspect.h2m \ +@@ -60,15 +49,12 @@ endif + if ENABLE_UNVERSIONED + install-data-hook: + cd $(DESTDIR)$(man1dir) && $(LN_S) -f valac@PACKAGE_SUFFIX@.1 valac.1 +-if ENABLE_VALADOC + cd $(DESTDIR)$(man1dir) && $(LN_S) -f valadoc@PACKAGE_SUFFIX@.1 valadoc.1 +-endif + cd $(DESTDIR)$(man1dir) && $(LN_S) -f vala-gen-introspect@PACKAGE_SUFFIX@.1 vala-gen-introspect.1 + cd $(DESTDIR)$(man1dir) && $(LN_S) -f vapigen@PACKAGE_SUFFIX@.1 vapigen.1 + endif + + +-if ENABLE_VALADOC + COMMON_VALADOCFLAGS = \ + --force \ + --verbose \ +@@ -150,7 +136,6 @@ internal-apis/valadoc: $(valadoc_VALASOURCES) internal-apis/codegen + @touch $@ + + internal-api-docs: internal-apis/gee internal-apis/vala internal-apis/ccode internal-apis/codegen internal-apis/valadoc +-endif + + clean-local: + rm -rf $(builddir)/internal-apis +diff --git a/libvaladoc/Makefile.am b/libvaladoc/Makefile.am +index 7456fb836..107338e91 100644 +--- a/libvaladoc/Makefile.am ++++ b/libvaladoc/Makefile.am +@@ -119,10 +119,6 @@ libvaladoc_la_VALASOURCES = \ + content/tablerow.vala \ + content/taglet.vala \ + content/text.vala \ +- charts/chart.vala \ +- charts/chartfactory.vala \ +- charts/hierarchychart.vala \ +- charts/simplechartfactory.vala \ + parser/manyrule.vala \ + parser/oneofrule.vala \ + parser/optionalrule.vala \ +@@ -149,13 +145,24 @@ libvaladoc_la_VALASOURCES = \ + highlighter/codetoken.vala \ + highlighter/highlighter.vala \ + html/basicdoclet.vala \ +- html/htmlchartfactory.vala \ + html/linkhelper.vala \ + html/cssclassresolver.vala \ + html/htmlmarkupwriter.vala \ + html/htmlrenderer.vala \ + $(NULL) + ++if ENABLE_GRAPHVIZ ++libvaladoc_la_VALASOURCES += \ ++ charts/chart.vala \ ++ charts/chartfactory.vala \ ++ charts/hierarchychart.vala \ ++ charts/simplechartfactory.vala \ ++ html/htmlchartfactory.vala \ ++ $(NULL) ++ ++LIBGVC_PKG = --vapidir $(top_srcdir)/vapi --pkg libgvc ++endif ++ + libvaladoc@PACKAGE_SUFFIX@_la_SOURCES = \ + libvaladoc.vala.stamp \ + $(libvaladoc_la_VALASOURCES:.vala=.c) \ +@@ -175,11 +182,11 @@ libvaladoc.vala.stamp: $(libvaladoc_la_VALASOURCES) + --library valadoc \ + --vapi valadoc@PACKAGE_SUFFIX@.vapi \ + --vapidir $(top_srcdir)/vapi --pkg gmodule-2.0 \ +- --vapidir $(top_srcdir)/vapi --pkg libgvc \ + --vapidir $(top_srcdir)/gee --pkg gee \ + --vapidir $(top_srcdir)/vala --pkg vala \ + --vapidir $(top_srcdir)/ccode --pkg ccode \ + --vapidir $(top_srcdir)/codegen --pkg codegen \ ++ $(LIBGVC_PKG) \ + --pkg config \ + $(filter %.vala %.c,$^) + touch $@ +@@ -207,6 +214,9 @@ nodist_pkgconfig_DATA = valadoc@PACKAGE_SUFFIX@.pc + + valadoc@PACKAGE_SUFFIX@.pc: valadoc.pc + cp $< $@ ++if !ENABLE_GRAPHVIZ ++ sed -i "s/libgvc //g" $@ ++endif + + vapidir = $(datadir)/vala/vapi + dist_vapi_DATA = valadoc@PACKAGE_SUFFIX@.vapi +@@ -214,6 +224,9 @@ nodist_vapi_DATA = valadoc@PACKAGE_SUFFIX@.deps + + valadoc@PACKAGE_SUFFIX@.deps: valadoc.deps + cp $< $@ ++if !ENABLE_GRAPHVIZ ++ sed -i "s/libgvc//g" $@ ++endif + + EXTRA_DIST = \ + $(libvaladoc_la_VALASOURCES) \ +diff --git a/libvaladoc/html/basicdoclet.vala b/libvaladoc/html/basicdoclet.vala +index 46578c28f..f6ce7097c 100644 +--- a/libvaladoc/html/basicdoclet.vala ++++ b/libvaladoc/html/basicdoclet.vala +@@ -46,7 +46,11 @@ public abstract class Valadoc.Html.BasicDoclet : Api.Visitor, Doclet { + protected HtmlRenderer _renderer; + protected Html.MarkupWriter writer; + protected Html.CssClassResolver cssresolver; ++#if HAVE_GRAPHVIZ + protected Charts.Factory image_factory; ++#else ++ protected void* image_factory; ++#endif + protected ErrorReporter reporter; + protected string package_list_link = "../index.html"; + +@@ -120,7 +124,9 @@ public abstract class Valadoc.Html.BasicDoclet : Api.Visitor, Doclet { + this.linker = new LinkHelper (); + + _renderer = new HtmlRenderer (settings, this.linker, this.cssresolver); ++#if HAVE_GRAPHVIZ + this.image_factory = new SimpleChartFactory (settings, linker); ++#endif + } + + +@@ -1025,6 +1031,7 @@ public abstract class Valadoc.Html.BasicDoclet : Api.Visitor, Doclet { + } + + protected void write_image_block (Api.Node element) { ++#if HAVE_GRAPHVIZ + if (element is Class || element is Interface || element is Struct) { + unowned string format = (settings.use_svg_images ? "svg" : "png"); + var chart = new Charts.Hierarchy (image_factory, element); +@@ -1044,6 +1051,7 @@ public abstract class Valadoc.Html.BasicDoclet : Api.Visitor, Doclet { + this.get_img_path_html (element, format)}); + writer.add_usemap (chart); + } ++#endif + } + + public void write_namespace_content (Namespace node, Api.Node? parent) { +diff --git a/libvaladoc/html/htmlmarkupwriter.vala b/libvaladoc/html/htmlmarkupwriter.vala +index 5aa4afdea..e79b0b8f5 100644 +--- a/libvaladoc/html/htmlmarkupwriter.vala ++++ b/libvaladoc/html/htmlmarkupwriter.vala +@@ -51,12 +51,16 @@ public class Valadoc.Html.MarkupWriter : Valadoc.MarkupWriter { + } + } + ++#if HAVE_GRAPHVIZ + public unowned MarkupWriter add_usemap (Charts.Chart chart) { + string? buf = (string?) chart.write_buffer ("cmapx"); + if (buf != null) { + raw_text ("\n"); + raw_text ((!) buf); + } ++#else ++ public unowned MarkupWriter add_usemap (void* chart) { ++#endif + + return this; + } diff --git a/nixpkgs/pkgs/development/compilers/vala/gvc-compat.patch b/nixpkgs/pkgs/development/compilers/vala/gvc-compat.patch new file mode 100644 index 000000000000..8c0d25098f14 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/vala/gvc-compat.patch @@ -0,0 +1,19 @@ +diff --git i/libvaladoc/Makefile.am w/libvaladoc/Makefile.am +index 8dc398cf1..a5d8a45b4 100644 +--- i/libvaladoc/Makefile.am ++++ w/libvaladoc/Makefile.am +@@ -176,9 +176,13 @@ endif + libvaladoc@PACKAGE_SUFFIX@_la_SOURCES = \ + libvaladoc.vala.stamp \ + $(libvaladoc_la_VALASOURCES:.vala=.c) \ +- gvc-compat.c \ + $(NULL) + ++if ENABLE_GRAPHVIZ ++libvaladoc@PACKAGE_SUFFIX@_la_SOURCES += \ ++ gvc-compat.c ++endif ++ + valadoc@PACKAGE_SUFFIX@.vapi valadoc.h: libvaladoc.vala.stamp + libvaladoc.vala.stamp: $(libvaladoc_la_VALASOURCES) + $(VALA_V)$(VALAC) \ diff --git a/nixpkgs/pkgs/development/compilers/vala/setup-hook.sh b/nixpkgs/pkgs/development/compilers/vala/setup-hook.sh new file mode 100644 index 000000000000..8252143e998b --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/vala/setup-hook.sh @@ -0,0 +1,15 @@ +make_vala_find_vapi_files() { + # XDG_DATA_DIRS: required for finding .vapi files + if [ -d "$1/share/vala/vapi" -o -d "$1/share/vala-@apiVersion@/vapi" ]; then + addToSearchPath XDG_DATA_DIRS $1/share + fi +} + +addEnvHooks "$hostOffset" make_vala_find_vapi_files + +_multioutMoveVapiDirs() { + moveToOutput share/vala/vapi "${!outputDev}" + moveToOutput share/vala-@apiVersion@/vapi "${!outputDev}" +} + +preFixupHooks+=(_multioutMoveVapiDirs) diff --git a/nixpkgs/pkgs/development/compilers/wcc/default.nix b/nixpkgs/pkgs/development/compilers/wcc/default.nix new file mode 100644 index 000000000000..8cb1e8e5f2cd --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/wcc/default.nix @@ -0,0 +1,49 @@ +{ stdenv, fetchFromGitHub, capstone, libbfd, libelf, libiberty, readline }: + +stdenv.mkDerivation rec { + name = "wcc-unstable-${version}"; + version = "2018-04-05"; + + src = fetchFromGitHub { + owner = "endrazine"; + repo = "wcc"; + rev = "f141963ff193d7e1931d41acde36d20d7221e74f"; + sha256 = "1f0w869x0176n5nsq7m70r344gv5qvfmk7b58syc0jls8ghmjvb4"; + fetchSubmodules = true; + }; + + buildInputs = [ capstone libbfd libelf libiberty readline ]; + + postPatch = '' + sed -i src/wsh/include/libwitch/wsh.h src/wsh/scripts/INDEX \ + -e "s#/usr/share/wcc#$out/share/wcc#" + ''; + + installFlags = [ "DESTDIR=$(out)" ]; + + preInstall = '' + mkdir -p $out/usr/bin + ''; + + postInstall = '' + mv $out/usr/* $out + rmdir $out/usr + mkdir -p $out/share/man/man1 + cp doc/manpages/*.1 $out/share/man/man1/ + ''; + + preFixup = '' + # Let patchShebangs rewrite shebangs with wsh. + PATH+=:$out/bin + ''; + + enableParallelBuilding = true; + + meta = with stdenv.lib; { + homepage = https://github.com/endrazine/wcc; + description = "Witchcraft compiler collection: tools to convert and script ELF files"; + license = licenses.mit; + platforms = [ "x86_64-linux" ]; + maintainers = with maintainers; [ orivej ]; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/wla-dx/default.nix b/nixpkgs/pkgs/development/compilers/wla-dx/default.nix new file mode 100644 index 000000000000..78df2583140b --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/wla-dx/default.nix @@ -0,0 +1,30 @@ +{stdenv, fetchFromGitHub, cmake}: + +stdenv.mkDerivation rec { + version = "2017-06-05"; + name = "wla-dx-git-${version}"; + + src = fetchFromGitHub { + owner = "vhelin"; + repo = "wla-dx"; + rev = "ae6843f9711cbc2fa6dd8c200877b40bd2bcad7f"; + sha256 = "09c2kz12ld97ad41j6r8r65jknllrak1x8r43fgr26x7hdlxz5c6"; + }; + + hardeningDisable = [ "format" ]; + + installPhase = '' + mkdir -p $out/bin + install binaries/* $out/bin + ''; + + nativeBuildInputs = [ cmake ]; + + meta = with stdenv.lib; { + homepage = http://www.villehelin.com/wla.html; + description = "Yet Another GB-Z80/Z80/6502/65C02/6510/65816/HUC6280/SPC-700 Multi Platform Cross Assembler Package"; + license = licenses.gpl2; + maintainers = with maintainers; [ matthewbauer ]; + platforms = platforms.all; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/x11basic/default.nix b/nixpkgs/pkgs/development/compilers/x11basic/default.nix new file mode 100644 index 000000000000..a26bc41c5945 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/x11basic/default.nix @@ -0,0 +1,48 @@ +{ stdenv, lib, fetchFromGitHub +, automake, autoconf, readline +, libX11, bluez, SDL2 +}: + +stdenv.mkDerivation rec { + pname = "X11basic"; + version = "1.26"; + name = pname + "-" + version; + + src = fetchFromGitHub { + owner = "kollokollo"; + repo = pname; + rev = version; + sha256 = "0rwj9cf496xailply0rgw695bzdladh2dhy7vdqac1pwbkl53nvd"; + }; + + buildInputs = [ + autoconf automake readline libX11 SDL2 bluez + ]; + + preConfigure = "cd src;autoconf"; + + configureFlags = [ + "--with-bluetooth" + "--with-usb" + "--with-readline" + "--with-sdl" + "--with-x" + "--enable-cryptography" + ]; + + preInstall = '' + touch x11basic.{eps,svg} + mkdir -p $out/{bin,lib} + mkdir -p $out/share/{applications,icons/hicolor/scalable/apps} + cp -r ../examples $out/share/. + ''; + + meta = with stdenv.lib; { + homepage = http://x11-basic.sourceforge.net/; + description = "A Basic interpreter and compiler with graphics capabilities."; + license = licenses.gpl2; + maintainers = with maintainers; [ edwtjo ]; + platforms = platforms.unix; + }; + +} diff --git a/nixpkgs/pkgs/development/compilers/yap/default.nix b/nixpkgs/pkgs/development/compilers/yap/default.nix new file mode 100644 index 000000000000..3ad0bc25787e --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/yap/default.nix @@ -0,0 +1,27 @@ +{ stdenv, fetchurl, readline, gmp, zlib }: + +stdenv.mkDerivation rec { + version = "6.3.3"; + name = "yap-${version}"; + + src = fetchurl { + url = "https://www.dcc.fc.up.pt/~vsc/Yap/${name}.tar.gz"; + sha256 = "0y7sjwimadqsvgx9daz28c9mxcx9n1znxklih9xg16k6n54v9qxf"; + }; + + buildInputs = [ readline gmp zlib ]; + + configureFlags = [ "--enable-tabling=yes" ]; + + NIX_CFLAGS_COMPILE = [ "-fpermissive" ]; + + meta = { + homepage = http://www.dcc.fc.up.pt/~vsc/Yap/; + description = "A ISO-compatible high-performance Prolog compiler"; + license = stdenv.lib.licenses.artistic2; + + maintainers = [ stdenv.lib.maintainers.peti ]; + platforms = stdenv.lib.platforms.linux; + broken = !stdenv.is64bit; # the linux 32 bit build fails. + }; +} diff --git a/nixpkgs/pkgs/development/compilers/yasm/default.nix b/nixpkgs/pkgs/development/compilers/yasm/default.nix new file mode 100644 index 000000000000..5aea623b91d4 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/yasm/default.nix @@ -0,0 +1,17 @@ +{stdenv, fetchurl}: + +stdenv.mkDerivation rec { + name = "yasm-1.3.0"; + + src = fetchurl { + url = "https://www.tortall.net/projects/yasm/releases/${name}.tar.gz"; + sha256 = "0gv0slmm0qpq91za3v2v9glff3il594x5xsrbgab7xcmnh0ndkix"; + }; + + meta = with stdenv.lib; { + homepage = http://www.tortall.net/projects/yasm/; + description = "Complete rewrite of the NASM assembler"; + license = licenses.bsd2; + platforms = platforms.unix; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/yosys/default.nix b/nixpkgs/pkgs/development/compilers/yosys/default.nix new file mode 100644 index 000000000000..afb1bcd5a0b0 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/yosys/default.nix @@ -0,0 +1,77 @@ +{ stdenv, fetchFromGitHub +, pkgconfig, bison, flex +, tcl, readline, libffi, python3 +, protobuf +}: + +with builtins; + +stdenv.mkDerivation rec { + name = "yosys-${version}"; + version = "2019.04.23"; + + srcs = [ + (fetchFromGitHub { + owner = "yosyshq"; + repo = "yosys"; + rev = "d9daf09cf3aab202b6da058c5e959f6375a4541e"; + sha256 = "0l27r9l3fvkqhmbqqpjz1f3ny4wdh5mdc7jlnbgy6nxx6vqcmkh0"; + name = "yosys"; + }) + + # NOTE: the version of abc used here is synchronized with + # the one in the yosys Makefile of the version above; + # keep them the same for quality purposes. + (fetchFromGitHub { + owner = "berkeley-abc"; + repo = "abc"; + rev = "3709744c60696c5e3f4cc123939921ce8107fe04"; + sha256 = "18a9cjng3qfalq8m9az5ck1y5h4l2pf9ycrvkzs9hn82b1j7vrax"; + name = "yosys-abc"; + }) + ]; + sourceRoot = "yosys"; + + enableParallelBuilding = true; + nativeBuildInputs = [ pkgconfig ]; + buildInputs = [ tcl readline libffi python3 bison flex protobuf ]; + + makeFlags = [ "ENABLE_PROTOBUF=1" ]; + + patchPhase = '' + substituteInPlace ../yosys-abc/Makefile \ + --replace 'CC := gcc' "" + substituteInPlace ./Makefile \ + --replace 'CXX = clang' "" \ + --replace 'ABCMKARGS = CC="$(CXX)"' 'ABCMKARGS =' \ + --replace 'echo UNKNOWN' 'echo ${substring 0 10 (elemAt srcs 0).rev}' + ''; + + preBuild = '' + chmod -R u+w ../yosys-abc + ln -s ../yosys-abc abc + make config-${if stdenv.cc.isClang or false then "clang" else "gcc"} + echo 'ABCREV := default' >> Makefile.conf + makeFlags="PREFIX=$out $makeFlags" + + # we have to do this ourselves for some reason... + (cd misc && ${protobuf}/bin/protoc --cpp_out ../backends/protobuf/ ./yosys.proto) + ''; + + meta = { + description = "Framework for RTL synthesis tools"; + longDescription = '' + Yosys is a framework for RTL synthesis tools. It currently has + extensive Verilog-2005 support and provides a basic set of + synthesis algorithms for various application domains. + Yosys can be adapted to perform any synthesis job by combining + the existing passes (algorithms) using synthesis scripts and + adding additional passes as needed by extending the yosys C++ + code base. + ''; + homepage = http://www.clifford.at/yosys/; + license = stdenv.lib.licenses.isc; + maintainers = with stdenv.lib.maintainers; [ shell thoughtpolice ]; + platforms = stdenv.lib.platforms.unix; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/z88dk/default.nix b/nixpkgs/pkgs/development/compilers/z88dk/default.nix new file mode 100644 index 000000000000..1590075dc2a0 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/z88dk/default.nix @@ -0,0 +1,50 @@ +{ fetchFromGitHub, fetchpatch, stdenv, makeWrapper, unzip, libxml2, m4, uthash }: + +stdenv.mkDerivation rec { + name = "z88dk-${version}"; + version = "20180217"; + rev = "49a7c6032b2675af742f5b0b3aa5bd5260bdd814"; + short_rev = "${builtins.substring 0 7 rev}"; + + src = fetchFromGitHub { + owner = "z88dk"; + repo = "z88dk"; + inherit rev; + sha256 = "00vbklh6lkq1gyd08ig2vcg6c1mghvlwfx3vq3wldf34hcs3k4pp"; + }; + + # https://github.com/z88dk/z88dk/pull/612 + patches = [(fetchpatch { + url = "https://github.com/Mic92/z88dk/commit/5b4ca132fa1f31c9ac48cf2220358715739ca0b2.patch"; + sha256 = "1p2l31j68p7jzykhkhd9iagn2lr08hdclk3cl9l32p1q6ghdipfv"; + })]; + + postPatch = '' + # we dont rely on build.sh : + export PATH="$PWD/bin:$PATH" # needed to have zcc in testsuite + export ZCCCFG=$PWD/lib/config/ + ''; + + makeFlags = [ + "prefix=$(out)" + "git_rev=${short_rev}" + "version=${version}" + "git_count=0" + ]; + nativeBuildInputs = [ makeWrapper unzip ]; + buildInputs = [ libxml2 m4 uthash ]; + + preInstall = '' + mkdir -p $out/{bin,share} + ''; + + installTargets = "libs install"; + + meta = with stdenv.lib; { + homepage = https://www.z88dk.org; + description = "z80 Development Kit"; + license = licenses.clArtistic; + maintainers = [ maintainers.genesis ]; + platforms = [ "x86_64-linux" ]; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/zig/default.nix b/nixpkgs/pkgs/development/compilers/zig/default.nix new file mode 100644 index 000000000000..35ad09320dec --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/zig/default.nix @@ -0,0 +1,24 @@ +{ stdenv, fetchFromGitHub, cmake, llvmPackages, libxml2, zlib }: + +stdenv.mkDerivation rec { + version = "0.4.0"; + pname = "zig"; + + src = fetchFromGitHub { + owner = "ziglang"; + repo = pname; + rev = version; + sha256 = "1cq6cc5pvybz9kn3y0j5gskkjq88hkmmcsva54mfzpcc65l3pv6p"; + }; + + nativeBuildInputs = [ cmake ]; + buildInputs = [ llvmPackages.clang-unwrapped llvmPackages.llvm libxml2 zlib ]; + + meta = with stdenv.lib; { + description = "Programming languaged designed for robustness, optimality, and clarity"; + homepage = https://ziglang.org/; + license = licenses.mit; + platforms = platforms.unix; + maintainers = [ maintainers.andrewrk ]; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/zulu/8.nix b/nixpkgs/pkgs/development/compilers/zulu/8.nix new file mode 100644 index 000000000000..fb1798ab819c --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/zulu/8.nix @@ -0,0 +1,82 @@ +{ stdenv, lib, fetchurl, unzip, makeWrapper, setJavaClassPath +, zulu, glib, libxml2, libav_0_8, ffmpeg, libxslt, libGL, alsaLib +, fontconfig, freetype, gnome2, cairo, gdk_pixbuf, atk, xorg +, swingSupport ? true }: + +let + version = "8.28.0.1"; + openjdk = "8.0.163"; + + sha256_linux = "1z8s3a948nvv92wybnhkyr27ipibcy45k0zv5h5gp37ynd91df45"; + sha256_darwin = "0i0prjijsgg0yyycplpp9rlfl428126rqz7bb31pchrhi6jhk699"; + + platform = if stdenv.isDarwin then "macosx" else "linux"; + hash = if stdenv.isDarwin then sha256_darwin else sha256_linux; + extension = if stdenv.isDarwin then "zip" else "tar.gz"; + + libraries = [ + stdenv.cc.libc glib libxml2 libav_0_8 ffmpeg libxslt libGL + xorg.libXxf86vm alsaLib fontconfig freetype gnome2.pango + gnome2.gtk cairo gdk_pixbuf atk + ] ++ (lib.optionals swingSupport (with xorg; [ + xorg.libX11 xorg.libXext xorg.libXtst xorg.libXi xorg.libXp + xorg.libXt xorg.libXrender stdenv.cc.cc + ])); + +in stdenv.mkDerivation rec { + inherit version openjdk platform hash extension; + + name = "zulu-${version}"; + + src = fetchurl { + url = "https://cdn.azul.com/zulu/bin/zulu${version}-jdk${openjdk}-${platform}_x64.${extension}"; + sha256 = hash; + }; + + buildInputs = [ makeWrapper ] ++ lib.optional stdenv.isDarwin unzip; + + installPhase = '' + mkdir -p $out + cp -r ./* "$out/" + + jrePath="$out/jre" + + rpath=$rpath''${rpath:+:}$jrePath/lib/amd64/jli + rpath=$rpath''${rpath:+:}$jrePath/lib/amd64/server + rpath=$rpath''${rpath:+:}$jrePath/lib/amd64/xawt + rpath=$rpath''${rpath:+:}$jrePath/lib/amd64 + + # set all the dynamic linkers + find $out -type f -perm -0100 \ + -exec patchelf --interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \ + --set-rpath "$rpath" {} \; + + find $out -name "*.so" -exec patchelf --set-rpath "$rpath" {} \; + + mkdir -p $out/nix-support + printWords ${setJavaClassPath} > $out/nix-support/propagated-build-inputs + + # Set JAVA_HOME automatically. + cat <<EOF >> $out/nix-support/setup-hook + if [ -z "\$JAVA_HOME" ]; then export JAVA_HOME=$out; fi + EOF + ''; + + rpath = stdenv.lib.strings.makeLibraryPath libraries; + + passthru = { + home = "${zulu}"; + }; + + meta = with stdenv.lib; { + homepage = https://www.azul.com/products/zulu/; + license = licenses.gpl2; + description = "Certified builds of OpenJDK"; + longDescription = '' + Certified builds of OpenJDK that can be deployed across multiple + operating systems, containers, hypervisors and Cloud platforms. + ''; + maintainers = with maintainers; [ nequissimus fpletz ]; + platforms = [ "x86_64-linux" "x86_64-darwin" ]; + }; +} diff --git a/nixpkgs/pkgs/development/compilers/zulu/default.nix b/nixpkgs/pkgs/development/compilers/zulu/default.nix new file mode 100644 index 000000000000..908aa29e178f --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/zulu/default.nix @@ -0,0 +1,79 @@ +{ stdenv, lib, fetchurl, unzip, makeWrapper, setJavaClassPath +, zulu, glib, libxml2, libav_0_8, ffmpeg, libxslt, libGL, alsaLib +, fontconfig, freetype, gnome2, cairo, gdk_pixbuf, atk, xorg, zlib +, swingSupport ? true }: + +let + version = "10.1+11"; + openjdk = "10"; + + sha256_linux = "0g51n2zc7inal29n5ly3mrrfj15c7vl87zb6b2r1q67n4mnbrgm8"; + sha256_darwin = "1c5ib136nv6gz7ij31mg15nhzrl6zr7kp8spm17zwm1ib82bc73y"; + + platform = if stdenv.isDarwin then "macosx" else "linux"; + hash = if stdenv.isDarwin then sha256_darwin else sha256_linux; + extension = if stdenv.isDarwin then "zip" else "tar.gz"; + + libraries = [ + stdenv.cc.libc glib libxml2 libav_0_8 ffmpeg libxslt libGL + xorg.libXxf86vm alsaLib fontconfig freetype gnome2.pango + gnome2.gtk cairo gdk_pixbuf atk zlib + ] ++ (lib.optionals swingSupport (with xorg; [ + xorg.libX11 xorg.libXext xorg.libXtst xorg.libXi xorg.libXp + xorg.libXt xorg.libXrender stdenv.cc.cc + ])); + +in stdenv.mkDerivation rec { + inherit version openjdk platform hash extension; + + name = "zulu-${version}"; + + src = fetchurl { + url = "https://cdn.azul.com/zulu/bin/zulu${version}-jdk${openjdk}-${platform}_x64.${extension}"; + sha256 = hash; + }; + + buildInputs = [ makeWrapper ] ++ lib.optional stdenv.isDarwin unzip; + + installPhase = '' + mkdir -p $out + cp -r ./* "$out/" + + rpath=$rpath''${rpath:+:}$out/lib/jli + rpath=$rpath''${rpath:+:}$out/lib/server + rpath=$rpath''${rpath:+:}$out/lib + + # set all the dynamic linkers + find $out -type f -perm -0100 \ + -exec patchelf --interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \ + --set-rpath "$rpath" {} \; + + find $out -name "*.so" -exec patchelf --set-rpath "$rpath" {} \; + + mkdir -p $out/nix-support + printWords ${setJavaClassPath} > $out/nix-support/propagated-build-inputs + + # Set JAVA_HOME automatically. + cat <<EOF >> $out/nix-support/setup-hook + if [ -z "\$JAVA_HOME" ]; then export JAVA_HOME=$out; fi + EOF + ''; + + rpath = stdenv.lib.strings.makeLibraryPath libraries; + + passthru = { + home = "${zulu}"; + }; + + meta = with stdenv.lib; { + homepage = https://www.azul.com/products/zulu/; + license = licenses.gpl2; + description = "Certified builds of OpenJDK"; + longDescription = '' + Certified builds of OpenJDK that can be deployed across multiple + operating systems, containers, hypervisors and Cloud platforms. + ''; + maintainers = with maintainers; [ nequissimus fpletz ]; + platforms = [ "x86_64-linux" "x86_64-darwin" ]; + }; +} |