diff options
author | 2018-05-28 19:12:29 +0000 | |
---|---|---|
committer | 2018-05-31 23:39:35 +0200 | |
commit | 646a5c1cbfd95873950a87b5f75d52073a967023 (patch) | |
tree | b8b8d2ab3b0d432ea69ad1a64d1c789649d65020 /source/d | |
parent | d31c50870d0bee042ce660e445c9294a59a3a65b (diff) | |
download | current-646a5c1cbfd95873950a87b5f75d52073a967023.tar.gz current-646a5c1cbfd95873950a87b5f75d52073a967023.tar.xz |
Mon May 28 19:12:29 UTC 201820180528191229
a/pkgtools-15.0-noarch-13.txz: Rebuilt.
installpkg: default line length for --terselength is the number of columns.
removepkg: added --terse mode.
upgradepkg: default line length for --terselength is the number of columns.
upgradepkg: accept -option in addition to --option.
ap/vim-8.1.0026-x86_64-1.txz: Upgraded.
d/bison-3.0.5-x86_64-1.txz: Upgraded.
e/emacs-26.1-x86_64-1.txz: Upgraded.
kde/kopete-4.14.3-x86_64-8.txz: Rebuilt.
Recompiled against libidn-1.35.
n/conntrack-tools-1.4.5-x86_64-1.txz: Upgraded.
n/libnetfilter_conntrack-1.0.7-x86_64-1.txz: Upgraded.
n/libnftnl-1.1.0-x86_64-1.txz: Upgraded.
n/links-2.16-x86_64-2.txz: Rebuilt.
Rebuilt to enable X driver for -g mode.
n/lynx-2.8.9dev.19-x86_64-1.txz: Upgraded.
n/nftables-0.8.5-x86_64-1.txz: Upgraded.
n/p11-kit-0.23.11-x86_64-1.txz: Upgraded.
n/ulogd-2.0.7-x86_64-1.txz: Upgraded.
n/whois-5.3.1-x86_64-1.txz: Upgraded.
xap/network-manager-applet-1.8.12-x86_64-1.txz: Upgraded.
xap/vim-gvim-8.1.0026-x86_64-1.txz: Upgraded.
Diffstat (limited to 'source/d')
196 files changed, 31504 insertions, 5146 deletions
diff --git a/source/d/Cython/Cython.SlackBuild b/source/d/Cython/Cython.SlackBuild index 11716068..c3924c69 100755 --- a/source/d/Cython/Cython.SlackBuild +++ b/source/d/Cython/Cython.SlackBuild @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # Slackware build script for Cython @@ -22,8 +22,10 @@ # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +cd $(dirname $0) ; CWD=$(pwd) + PKGNAM=Cython -VERSION=${VERSION:-$(echo $PKGNAM-*.tar.?z* | rev | cut -f 3- -d . | cut -f 1 -d - | rev)} +VERSION=${VERSION:-$(echo $PKGNAM-*.tar.?z | rev | cut -f 3- -d . | cut -f 1 -d - | rev)} BUILD=${BUILD:-1} if [ -z "$ARCH" ]; then @@ -34,29 +36,22 @@ if [ -z "$ARCH" ]; then esac fi -CWD=$(pwd) +# If the variable PRINT_PACKAGE_NAME is set, then this script will report what +# the name of the created package would be, and then exit. This information +# could be useful to other scripts. +if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then + echo "$PKGNAM-$VERSION-$ARCH-$BUILD.txz" + exit 0 +fi + TMP=${TMP:-/tmp} PKG=$TMP/package-$PKGNAM -if [ "$ARCH" = "i586" ]; then - SLKCFLAGS="-O2 -march=i586 -mtune=i686" - LIBDIRSUFFIX="" -elif [ "$ARCH" = "i686" ]; then - SLKCFLAGS="-O2 -march=i686 -mtune=i686" - LIBDIRSUFFIX="" -elif [ "$ARCH" = "x86_64" ]; then - SLKCFLAGS="-O2 -fPIC" - LIBDIRSUFFIX="64" -else - SLKCFLAGS="-O2" - LIBDIRSUFFIX="" -fi - rm -rf $PKG mkdir -p $TMP $PKG cd $TMP rm -rf $PKGNAM-$VERSION -tar xvf $CWD/$PKGNAM-$VERSION.tar.xz || exit 1 +tar xvf $CWD/$PKGNAM-$VERSION.tar.?z || exit 1 cd $PKGNAM-$VERSION || exit 1 chown -R root:root . @@ -66,6 +61,12 @@ find -L . \ \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \ -exec chmod 644 {} \; +python3 setup.py install --root=$PKG --prefix=/usr || exit 1 + +for i in cython cythonize cygdb; do + mv $PKG/usr/bin/$i $PKG/usr/bin/${i}3 +done + python setup.py install --root=$PKG --prefix=/usr || exit 1 find $PKG | xargs file | grep -e "executable" -e "shared object" | grep ELF \ diff --git a/source/d/Cython/Cython.url b/source/d/Cython/Cython.url index caf98d8b..75c3b5f1 100644 --- a/source/d/Cython/Cython.url +++ b/source/d/Cython/Cython.url @@ -1,2 +1 @@ -http://www.cython.org -http://cython.org/release/Cython-0.23.4.tar.gz +http://pypi.python.org/pypi/Cython/ diff --git a/source/d/Cython/slack-desc b/source/d/Cython/slack-desc index 6c806733..2cf3b852 100644 --- a/source/d/Cython/slack-desc +++ b/source/d/Cython/slack-desc @@ -2,14 +2,14 @@ # The "handy ruler" below makes it easier to edit a package description. # Line up the first '|' above the ':' following the base package name, and # the '|' on the right side marks the last column you can put a character in. -# You must make exactly 11 lines for the formatting to be correct. It's also +# You must make exactly 11 lines for the formatting to be correct. It's also # customary to leave one space after the ':' except on otherwise blank lines. |-----handy-ruler------------------------------------------------------| Cython: Cython (C bindings for Python) Cython: Cython: Cython is a language that makes writing C extensions for the Python -Cython: language as easy as Python itself. Cython is based on the well-known +Cython: language as easy as Python itself. Cython is based on the well-known Cython: Pyrex, but supports more cutting edge functionality and optimizations. Cython: Cython: Homepage: http://www.cython.org/ diff --git a/source/d/FTBFSlog b/source/d/FTBFSlog new file mode 100644 index 00000000..3b50d8fd --- /dev/null +++ b/source/d/FTBFSlog @@ -0,0 +1,15 @@ +Thu Mar 29 18:14:22 UTC 2018 + doxygen: build fixed with update to flex. Thanks to nobodino. ++--------------------------+ +Fri Feb 16 20:45:05 UTC 2018 + make: use a different patch directly to glob/glob.c as the other patch was + producing an unstable binary. Thanks to nobodino. ++--------------------------+ +Sun Feb 11 05:21:56 UTC 2018 + Fix all packages that fail to build from source: + make: patch GLOB test in configure.ac to fix build with glibc-2.27. ++--------------------------+ +Thu Feb 1 21:36:53 UTC 2018 + Fix all packages that fail to build from source: + p2c: change builtin getline() function to p2c_getline() + rcs: build with -std=c99 diff --git a/source/d/autoconf/autoconf.SlackBuild b/source/d/autoconf/autoconf.SlackBuild index d71daa50..c748923b 100755 --- a/source/d/autoconf/autoconf.SlackBuild +++ b/source/d/autoconf/autoconf.SlackBuild @@ -1,6 +1,6 @@ -#!/bin/sh +#!/bin/bash -# Copyright 2005-2010 Patrick J. Volkerding, Sebeka, Minnesota, USA +# Copyright 2005-2018 Patrick J. Volkerding, Sebeka, Minnesota, USA # All rights reserved. # # Redistribution and use of this script, with or without modification, is @@ -20,10 +20,11 @@ # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +cd $(dirname $0) ; CWD=$(pwd) PKGNAM=autoconf VERSION=${VERSION:-$(echo $PKGNAM-*.tar.xz | rev | cut -f 3- -d . | cut -f 1 -d - | rev)} -BUILD=${BUILD:-1} +BUILD=${BUILD:-2} NUMJOBS=${NUMJOBS:-" -j7 "} @@ -32,14 +33,21 @@ NUMJOBS=${NUMJOBS:-" -j7 "} # Automatically determine the architecture we're building on: if [ -z "$ARCH" ]; then case "$( uname -m )" in - i?86) export ARCH=i486 ;; + i?86) export ARCH=i586 ;; arm*) export ARCH=arm ;; # Unless $ARCH is already set, use uname -m for all other archs: *) export ARCH=$( uname -m ) ;; esac fi -CWD=$(pwd) +# If the variable PRINT_PACKAGE_NAME is set, then this script will report what +# the name of the created package would be, and then exit. This information +# could be useful to other scripts. +if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then + echo "$PKGNAM-$VERSION-noarch-$BUILD.txz" + exit 0 +fi + TMP=${TMP:-/tmp} PKG=$TMP/package-autoconf diff --git a/source/d/autoconf/slack-desc b/source/d/autoconf/slack-desc index 4a3b9a9f..31f852a5 100644 --- a/source/d/autoconf/slack-desc +++ b/source/d/autoconf/slack-desc @@ -1,8 +1,8 @@ # HOW TO EDIT THIS FILE: -# The "handy ruler" below makes it easier to edit a package description. Line +# The "handy ruler" below makes it easier to edit a package description. Line # up the first '|' above the ':' following the base package name, and the '|' -# on the right side marks the last column you can put a character in. You must -# make exactly 11 lines for the formatting to be correct. It's also +# on the right side marks the last column you can put a character in. You must +# make exactly 11 lines for the formatting to be correct. It's also # customary to leave one space after the ':'. |-----handy-ruler------------------------------------------------------| @@ -11,9 +11,9 @@ autoconf: autoconf: GNU autoconf is an extensible package of m4 macros that produce shell autoconf: scripts to automatically configure software source code packages. autoconf: These scripts can adapt the packages to many kinds of UNIX-like -autoconf: systems without manual user intervention. Autoconf creates a +autoconf: systems without manual user intervention. Autoconf creates a autoconf: configuration script for a package from a template file that lists the autoconf: operating system features that the package can use, in the form of m4 -autoconf: macro calls. You must install the "m4" package to be able to use +autoconf: macro calls. You must install the "m4" package to be able to use autoconf: autoconf. autoconf: diff --git a/source/d/automake/automake-1.15-perl-escape-curly-bracket.patch b/source/d/automake/automake-1.15-perl-escape-curly-bracket.patch deleted file mode 100644 index 7c22c4ee..00000000 --- a/source/d/automake/automake-1.15-perl-escape-curly-bracket.patch +++ /dev/null @@ -1,21 +0,0 @@ -From: Pavel Raiskup <praiskup@redhat.com> -Date: Tue, 7 Jul 2015 10:54:24 +0200 -Subject: [PATCH 2/2] bin/automake: escape '{' in regexp pattern - -Resolves: rhbz#1239379 -Upstream report: -http://debbugs.gnu.org/cgi/bugreport.cgi?bug=21001 - -diff --git a/bin/automake.in b/bin/automake.in -index eedc8bc..a679d16 100644 ---- a/bin/automake.in -+++ b/bin/automake.in -@@ -3878,7 +3878,7 @@ sub substitute_ac_subst_variables_worker - sub substitute_ac_subst_variables - { - my ($text) = @_; -- $text =~ s/\${([^ \t=:+{}]+)}/substitute_ac_subst_variables_worker ($1)/ge; -+ $text =~ s/\$\{([^ \t=:+{}]+)}/substitute_ac_subst_variables_worker ($1)/ge; - return $text; - } - diff --git a/source/d/automake/automake.SlackBuild b/source/d/automake/automake.SlackBuild index 058b3b97..810eb315 100755 --- a/source/d/automake/automake.SlackBuild +++ b/source/d/automake/automake.SlackBuild @@ -1,6 +1,6 @@ -#!/bin/sh +#!/bin/bash -# Copyright 2008, 2009, 2012, 2015 Patrick J. Volkerding, Sebeka, Minnesota, USA +# Copyright 2008, 2009, 2012, 2015, 2018 Patrick J. Volkerding, Sebeka, Minnesota, USA # All rights reserved. # # Redistribution and use of this script, with or without modification, is @@ -20,10 +20,12 @@ # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +cd $(dirname $0) ; CWD=$(pwd) -VERSION=${VERSION:-$(echo automake-*.tar.xz | rev | cut -f 3- -d . | cut -f 1 -d - | rev)} +PKGNAM=automake +VERSION=${VERSION:-$(echo automake-*.tar.?z | rev | cut -f 3- -d . | cut -f 1 -d - | rev)} NUMJOBS=${NUMJOBS:-" -j7 "} -BUILD=${BUILD:-1} +BUILD=${BUILD:-2} # Note: the package is _built_ as 'noarch' # Automatically determine architecture for build & packaging: @@ -35,7 +37,14 @@ if [ -z "$ARCH" ]; then esac fi -CWD=$(pwd) +# If the variable PRINT_PACKAGE_NAME is set, then this script will report what +# the name of the created package would be, and then exit. This information +# could be useful to other scripts. +if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then + echo "$PKGNAM-$VERSION-noarch-$BUILD.txz" + exit 0 +fi + TMP=${TMP:-/tmp} PKG=$TMP/package-automake @@ -44,11 +53,8 @@ mkdir -p $TMP $PKG cd $TMP rm -rf automake-$VERSION -tar xvf $CWD/automake-$VERSION.tar.xz || exit 1 -cd automake-$VERSION - -# Patch to work with Perl 5.20: -zcat $CWD/automake-1.15-perl-escape-curly-bracket.patch.gz | patch -p1 --verbose || exit 1 +tar xvf $CWD/automake-$VERSION.tar.?z || exit 1 +cd automake-$VERSION || exit 1 chown -R root:root . find . \ @@ -61,7 +67,7 @@ find . \ --prefix=/usr \ --mandir=/usr/man \ --infodir=/usr/info \ - --build=$ARCH-slackware-linux + --build=$ARCH-slackware-linux || exit 1 make $NUMJOBS || make || exit 1 make install DESTDIR=$PKG || exit 1 diff --git a/source/d/automake/slack-desc b/source/d/automake/slack-desc index 0c6cff62..3ee36e63 100644 --- a/source/d/automake/slack-desc +++ b/source/d/automake/slack-desc @@ -1,19 +1,19 @@ # HOW TO EDIT THIS FILE: -# The "handy ruler" below makes it easier to edit a package description. Line +# The "handy ruler" below makes it easier to edit a package description. Line # up the first '|' above the ':' following the base package name, and the '|' -# on the right side marks the last column you can put a character in. You must -# make exactly 11 lines for the formatting to be correct. It's also +# on the right side marks the last column you can put a character in. You must +# make exactly 11 lines for the formatting to be correct. It's also # customary to leave one space after the ':'. |-----handy-ruler------------------------------------------------------| automake: automake (a Makefile generator) automake: -automake: This is Automake, a Makefile generator. It was inspired by the 4.4BSD +automake: This is Automake, a Makefile generator. It was inspired by the 4.4BSD automake: make and include files, but aims to be portable and to conform to the -automake: GNU standards for Makefile variables and targets. Automake is a Perl -automake: script. The input files are called Makefile.am. The output files are -automake: called Makefile.in; they are intended for use with Autoconf. Automake -automake: requires certain things to be done in your configure.in. You must +automake: GNU standards for Makefile variables and targets. Automake is a Perl +automake: script. The input files are called Makefile.am. The output files are +automake: called Makefile.in; they are intended for use with Autoconf. Automake +automake: requires certain things to be done in your configure.in. You must automake: install the "m4" and "perl" packages to be able to use automake. automake: automake: diff --git a/source/d/binutils/binutils.SlackBuild b/source/d/binutils/binutils.SlackBuild index 41fa980b..717c0b6a 100755 --- a/source/d/binutils/binutils.SlackBuild +++ b/source/d/binutils/binutils.SlackBuild @@ -1,6 +1,6 @@ -#!/bin/sh +#!/bin/bash -# Copyright 2005-2016 Patrick J. Volkerding, Sebeka, Minnesota, USA +# Copyright 2005-2018 Patrick J. Volkerding, Sebeka, Minnesota, USA # All rights reserved. # # Redistribution and use of this script, with or without modification, is @@ -22,9 +22,10 @@ # Modified 2011 by Eric Hameleers <alien at slackware.com> for ARM port. +cd $(dirname $0) ; CWD=$(pwd) PKGNAM=binutils -VERSION=${VERSION:-$(echo $PKGNAM-*.tar.xz | rev | cut -f 3- -d . | cut -f 1 -d - | rev)} +VERSION=${VERSION:-$(echo $PKGNAM-*.tar.?z | rev | cut -f 3- -d . | cut -f 1 -d - | rev)} BUILD=${BUILD:-3} # Automatically determine the architecture we're building on: @@ -39,6 +40,14 @@ if [ -z "$ARCH" ]; then esac fi +# If the variable PRINT_PACKAGE_NAME is set, then this script will report what +# the name of the created package would be, and then exit. This information +# could be useful to other scripts. +if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then + echo "$PKGNAM-$VERSION-$ARCH-$BUILD.txz" + exit 0 +fi + NUMJOBS=${NUMJOBS:-" -j7 "} # Uncomment this to include the experimental gold linker: @@ -87,7 +96,6 @@ case "$ARCH" in *) TARGET=$ARCH-slackware-linux ;; esac -CWD=$(pwd) TMP=${TMP:-/tmp} PKG=$TMP/package-binutils @@ -96,33 +104,26 @@ mkdir -p $TMP $PKG cd $TMP rm -rf binutils-$VERSION -tar xvf $CWD/binutils-$VERSION.tar.xz || \ - tar xvf $CWD/binutils-$VERSION.tar.bz2 || exit 1 -cd binutils-$VERSION +tar xvf $CWD/binutils-$VERSION.tar.?z || exit 1 +cd binutils-$VERSION || exit 1 # Various upstream patches: -zcat $CWD/patches/binutils-2.20.51.0.2-libtool-lib64.patch | patch -p1 --verbose || exit 1 -zcat $CWD/patches/binutils-2.20.51.0.10-ppc64-pie.patch | patch -p1 --verbose || exit 1 -zcat $CWD/patches/binutils-2.25-version.patch | patch -p1 --verbose || exit 1 -zcat $CWD/patches/binutils-2.25-set-long-long.patch | patch -p1 --verbose || exit 1 -zcat $CWD/patches/binutils-2.20.51.0.10-copy-osabi.patch | patch -p1 --verbose || exit 1 -zcat $CWD/patches/binutils-2.20.51.0.10-sec-merge-emit.patch | patch -p1 --verbose || exit 1 -zcat $CWD/patches/binutils-2.22.52.0.1-relro-on-by-default.patch | patch -p1 --verbose || exit 1 -zcat $CWD/patches/binutils-2.23.52.0.1-addr2line-dynsymtab.patch | patch -p1 --verbose || exit 1 -zcat $CWD/patches/binutils-2.24-ldforcele.patch | patch -p1 --verbose || exit 1 -zcat $CWD/patches/binutils-2.25.1-cleansweep.patch | patch -p2 --verbose || exit 1 -zcat $CWD/patches/binutils-2.26-formatting.patch | patch -p2 --verbose || exit 1 -zcat $CWD/patches/binutils-2.26-fix-compile-warnings.patch | patch -p1 --verbose || exit 1 -zcat $CWD/patches/binutils-2.26-Bsymbolic_PIE.patch | patch -p1 --verbose || exit 1 -zcat $CWD/patches/binutils-2.26-lto.patch | patch -p1 --verbose || exit 1 -zcat $CWD/patches/binutils-rh1312151.patch | patch -p1 --verbose || exit 1 -zcat $CWD/patches/binutils-2.26-fix-GOT-offset-calculation.patch | patch -p1 --verbose || exit 1 +zcat $CWD/patches/binutils-2.20.51.0.2-libtool-lib64.patch.gz | patch -p1 --verbose || exit 1 +zcat $CWD/patches/binutils-2.25-version.patch.gz | patch -p1 --verbose || exit 1 +zcat $CWD/patches/binutils-2.25-set-long-long.patch.gz | patch -p1 --verbose || exit 1 +zcat $CWD/patches/binutils-2.20.51.0.10-copy-osabi.patch.gz | patch -p1 --verbose || exit 1 +zcat $CWD/patches/binutils-2.20.51.0.10-sec-merge-emit.patch.gz | patch -p1 --verbose || exit 1 +zcat $CWD/patches/binutils-2.24-ldforcele.patch.gz | patch -p1 --verbose || exit 1 +zcat $CWD/patches/binutils-2.25.1-cleansweep.patch.gz | patch -p2 --verbose || exit 1 # Export the demangle.h header file: zcat $CWD/patches/binutils.export.demangle.h.diff.gz | patch -p1 --verbose || exit 1 # Don't check to see if "config.h" was included in the installed headers: zcat $CWD/patches/binutils.no-config-h-check.diff.gz | patch -p1 --verbose || exit 1 +# Set %version to something halfway meaningful: +sed -i -e 's/%''{release}/slack15/g' bfd/Makefile{.am,.in} + chown -R root:root . find . \ \( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \ @@ -143,6 +144,7 @@ CFLAGS="$SLKCFLAGS" \ --mandir=/usr/man \ --infodir=/usr/info \ --with-docdir=/usr/doc/binutils-$VERSION \ + --disable-compressed-debug-sections \ --enable-shared \ --enable-multilib \ --enable-64-bit-bfd \ @@ -156,32 +158,54 @@ CFLAGS="$SLKCFLAGS" \ --build=$TARGET \ || exit 1 +# Use "tooldir=/usr" to avoid internal references to the /usr/${TARGET}/ +# directory. While binutils won't actually use that directory after this, +# we'll still create it since some people have made local use of it. +# Note that this will place ldscripts in /usr/lib, even on $ARCH that +# use LIBDIRSUFFIX=64. According to Ian Lance Taylor, the ldscripts have +# been built into the linker for quite some time and the ones in the +# filesystem aren't actually loaded. For the most part they are now +# documentation and it doesn't matter where they reside. make clean || exit 1 -make $NUMJOBS || make || exit 1 -make install DESTDIR=$PKG || exit 1 - -# Differentiate between BSD strings and GNU strings -( cd $PKG/usr/bin ; mv strings strings-GNU ) -( cd $PKG/usr/man/man1 ; mv strings.1 strings-GNU.1 ) - -# Move ldscripts to /usr/lib${LIBDIRSUFFIX}, and then put symlinks in place -mv $PKG/usr/${TARGET}/lib/ldscripts $PKG/usr/lib${LIBDIRSUFFIX} -( cd $PKG/usr/${TARGET} - ln -s /usr/lib${LIBDIRSUFFIX}/ldscripts lib/ldscripts - for FILE in ar as ld ld.bfd ld.gold nm objcopy objdump ranlib strip ; do - if [ -r "/usr/bin/$FILE" ]; then - rm -f bin/$FILE - ln -s /usr/bin/$FILE bin/$FILE - fi - done -) +make tooldir=/usr $NUMJOBS || make tooldir=/usr || exit 1 +make tooldir=/usr install DESTDIR=$PKG || exit 1 + +# Using tooldir=/usr also makes the /usr/${TARGET}/lib${LIBDIRSUFFIX} +# directory obsolete, and the build will no longer install it. But since +# some people might be making local use of that directory, we'll install +# it anyway: +mkdir -p $PKG/usr/${TARGET}/lib${LIBDIRSUFFIX} +# Same with /usr/${TARGET}/bin: +mkdir -p $PKG/usr/${TARGET}/bin + +# Don't ship .la files: +rm -f $PKG/{,usr/}lib${LIBDIRSUFFIX}/*.la + +# Add a symlink since binutils's version of strings used to be called +# "strings-GNU" on Slackware, and it's possible that people have scripts +# that use that name: +( cd $PKG/usr/bin ; ln -sf strings strings-GNU ) + +## OBSOLETE, since we're using tooldir=/usr. But we'll keep this cruft as a +## reference until we get the all clear on the tooldir= changes. :-) +## Move ldscripts to /usr/lib${LIBDIRSUFFIX}, and then put symlinks in place +#mv $PKG/usr/${TARGET}/lib/ldscripts $PKG/usr/lib${LIBDIRSUFFIX} +#( cd $PKG/usr/${TARGET} +# ln -s /usr/lib${LIBDIRSUFFIX}/ldscripts lib/ldscripts +# for FILE in ar as ld ld.bfd ld.gold nm objcopy objdump ranlib strip ; do +# if [ -r "/usr/bin/$FILE" ]; then +# rm -f bin/$FILE +# ln -s /usr/bin/$FILE bin/$FILE +# fi +# done +#) # If the requested default linker is present, make it the default: # Set the link differently on the system to change the default at runtime. if [ -r $PKG/usr/bin/$DEFAULT_LD ]; then ( cd $PKG/usr/bin ; rm -f ld ; ln -sf $DEFAULT_LD ld ) fi - + find $PKG | xargs file | grep -e "executable" -e "shared object" \ | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null diff --git a/source/d/binutils/patches/binutils-2.20.51.0.10-ppc64-pie.patch b/source/d/binutils/patches/binutils-2.20.51.0.10-ppc64-pie.patch deleted file mode 100644 index 740c071b..00000000 --- a/source/d/binutils/patches/binutils-2.20.51.0.10-ppc64-pie.patch +++ /dev/null @@ -1,12 +0,0 @@ ---- a/bfd/elf64-ppc.c 2012-09-11 12:13:00.637448573 +0100 -+++ b/bfd/elf64-ppc.c 2012-09-11 12:13:17.922449052 +0100 -@@ -13523,6 +13523,9 @@ - { - BFD_ASSERT (h->elf.dynindx != -1); - outrel.r_info = ELF64_R_INFO (h->elf.dynindx, r_type); -+ if (h->elf.dynindx == -1 -+ && h->elf.root.type == bfd_link_hash_undefweak) -+ memset (&outrel, 0, sizeof outrel); - } - else - { diff --git a/source/d/binutils/patches/binutils-2.22.52.0.1-relro-on-by-default.patch b/source/d/binutils/patches/binutils-2.22.52.0.1-relro-on-by-default.patch deleted file mode 100644 index ba8318df..00000000 --- a/source/d/binutils/patches/binutils-2.22.52.0.1-relro-on-by-default.patch +++ /dev/null @@ -1,58 +0,0 @@ -diff -upr ../binutils-2.22.52.0.1.orig/ld/testsuite/config/default.exp ld/testsuite/config/default.exp ---- a/ld/testsuite/config/default.exp 2012-03-06 14:00:31.141957656 +0000 -+++ b/ld/testsuite/config/default.exp 2012-03-06 14:09:33.492940503 +0000 -@@ -23,7 +23,7 @@ - # - - if ![info exists ld] then { -- set ld [findfile $base_dir/ld-new $base_dir/ld-new [transform ld]] -+ set ld "[findfile $base_dir/ld-new $base_dir/ld-new [transform ld]] -znorelro" - } - - if ![info exists as] then { -@@ -60,7 +60,7 @@ if {![file isdirectory tmpdir/ld]} then - catch "exec ln -s ld tmpdir/ld/collect-ld" status - catch "exec ln -s ../../../gas/as-new tmpdir/ld/as" status - } --set gcc_B_opt "-B[pwd]/tmpdir/ld/" -+set gcc_B_opt "-B[pwd]/tmpdir/ld/ -Wl,-z,norelro" - - # load the linker path - set ld_L_opt "" -@@ -279,7 +279,7 @@ - } - - if ![info exists LD] then { -- set LD [findfile $base_dir/ld-new ./ld-new [transform ld]] -+ set LD "[findfile $base_dir/ld-new ./ld-new [transform ld]] -znorelro" - } - - if ![info exists LDFLAGS] then { -diff -cpr ../binutils-2.22.52.0.1.orig/ld/testsuite/ld-bootstrap/bootstrap.exp ld/testsuite/ld-bootstrap/bootstrap.exp ---- a/ld/testsuite/ld-bootstrap/bootstrap.exp 2012-03-06 14:00:30.503957676 +0000 -+++ b/ld/testsuite/ld-bootstrap/bootstrap.exp 2012-03-06 15:03:33.949837926 +0000 -@@ -71,7 +71,13 @@ - - # This test can only be run if we have the ld build directory, - # since we need the object files. -- if {$ld != "$objdir/ld-new"} { -+ set ldexe $ld -+ set ldparm [string first " " $ld] -+ if { $ldparm > 0 } then { -+ set ldparm [expr $ldparm - 1] -+ set ldexe [string range $ld 0 $ldparm] -+ } -+ if {$ldexe != "$objdir/ld-new"} { - untested $testname - continue - } ---- binutils-2.26.orig/ld/emultempl/elf32.em 2016-01-25 10:11:33.990291993 +0000 -+++ binutils-2.26/ld/emultempl/elf32.em 2016-01-25 10:21:40.333016777 +0000 -@@ -104,6 +104,7 @@ gld${EMULATION_NAME}_before_parse (void) - config.has_shared = `if test -n "$GENERATE_SHLIB_SCRIPT" ; then echo TRUE ; else echo FALSE ; fi`; - config.separate_code = `if test "x${SEPARATE_CODE}" = xyes ; then echo TRUE ; else echo FALSE ; fi`; - `if test -n "$CALL_NOP_BYTE" ; then echo link_info.call_nop_byte = $CALL_NOP_BYTE; fi`; -+ link_info.relro = TRUE; - } - - EOF diff --git a/source/d/binutils/patches/binutils-2.23.52.0.1-addr2line-dynsymtab.patch b/source/d/binutils/patches/binutils-2.23.52.0.1-addr2line-dynsymtab.patch deleted file mode 100644 index 944f4fdd..00000000 --- a/source/d/binutils/patches/binutils-2.23.52.0.1-addr2line-dynsymtab.patch +++ /dev/null @@ -1,38 +0,0 @@ ---- a/bfd/opncls.c 2013-03-14 11:25:30.338306122 +0000 -+++ b/bfd/opncls.c 2013-03-14 12:20:21.686397360 +0000 -@@ -1297,6 +1297,8 @@ - bfd_malloc (strlen (debug_file_directory) + 1 - + (canon_dirlen > dirlen ? canon_dirlen : dirlen) - + strlen (".debug/") -+#define FEDORA_LIB_DEBUG_DIR "/usr/lib/debug/" -+ + strlen (FEDORA_LIB_DEBUG_DIR) + strlen ("usr/") - + strlen (base) - + 1); - if (debugfile == NULL) -@@ -1332,6 +1334,26 @@ - if (check_func (debugfile, crc32)) - goto found; - -+ /* Then try in the global debug dir for Fedora libraries. */ -+ sprintf (debugfile, "%s%s%s", FEDORA_LIB_DEBUG_DIR, dir, base); -+ if (separate_debug_file_exists (debugfile, crc32)) -+ { -+ free (base); -+ free (dir); -+ free (canon_dir); -+ return debugfile; -+ } -+ -+ /* Then try in the usr subdirectory of the global debug dir for Fedora libraries. */ -+ sprintf (debugfile, "%s/usr%s%s", FEDORA_LIB_DEBUG_DIR, dir, base); -+ if (separate_debug_file_exists (debugfile, crc32)) -+ { -+ free (base); -+ free (dir); -+ free (canon_dir); -+ return debugfile; -+ } -+ - /* Then try in the global debugfile directory. */ - strcpy (debugfile, debug_file_directory); - dirlen = strlen (debug_file_directory) - 1; diff --git a/source/d/binutils/patches/binutils-2.26-Bsymbolic_PIE.patch b/source/d/binutils/patches/binutils-2.26-Bsymbolic_PIE.patch deleted file mode 100644 index 552056a7..00000000 --- a/source/d/binutils/patches/binutils-2.26-Bsymbolic_PIE.patch +++ /dev/null @@ -1,146 +0,0 @@ -diff -upr binutils-2.26.orig/ld/ld.texinfo binutils-2.26/ld/ld.texinfo ---- binutils-2.26.orig/ld/ld.texinfo 2016-02-16 10:45:43.245336561 +0000 -+++ binutils-2.26/ld/ld.texinfo 2016-02-16 10:47:04.670763451 +0000 -@@ -1325,15 +1325,21 @@ libraries. - When creating a shared library, bind references to global symbols to the - definition within the shared library, if any. Normally, it is possible - for a program linked against a shared library to override the definition --within the shared library. This option is only meaningful on ELF --platforms which support shared libraries. -+within the shared library. This option can also be used with the -+@option{--export-dynamic} option, when creating a position independent -+executable, to bind references to global symbols to the definition within -+the executable. This option is only meaningful on ELF platforms which -+support shared libraries and position independent executables. - - @kindex -Bsymbolic-functions - @item -Bsymbolic-functions - When creating a shared library, bind references to global function - symbols to the definition within the shared library, if any. -+This option can also be used with the @option{--export-dynamic} option, -+when creating a position independent executable, to bind references -+to global function symbols to the definition within the executable. - This option is only meaningful on ELF platforms which support shared --libraries. -+libraries and position independent executables. - - @kindex --dynamic-list=@var{dynamic-list-file} - @item --dynamic-list=@var{dynamic-list-file} -diff -upr binutils-2.26.orig/ld/lexsup.c binutils-2.26/ld/lexsup.c ---- binutils-2.26.orig/ld/lexsup.c 2016-02-16 10:45:43.246336567 +0000 -+++ binutils-2.26/ld/lexsup.c 2016-02-16 10:47:04.671763456 +0000 -@@ -1586,15 +1586,14 @@ parse_args (unsigned argc, char **argv) - /* We may have -Bsymbolic, -Bsymbolic-functions, --dynamic-list-data, - --dynamic-list-cpp-new, --dynamic-list-cpp-typeinfo and - --dynamic-list FILE. -Bsymbolic and -Bsymbolic-functions are -- for shared libraries. -Bsymbolic overrides all others and vice -- versa. */ -+ for PIC outputs. -Bsymbolic overrides all others and vice versa. */ - switch (command_line.symbolic) - { - case symbolic_unset: - break; - case symbolic: -- /* -Bsymbolic is for shared library only. */ -- if (bfd_link_dll (&link_info)) -+ /* -Bsymbolic is for PIC output only. */ -+ if (bfd_link_pic (&link_info)) - { - link_info.symbolic = TRUE; - /* Should we free the unused memory? */ -@@ -1603,8 +1602,8 @@ parse_args (unsigned argc, char **argv) - } - break; - case symbolic_functions: -- /* -Bsymbolic-functions is for shared library only. */ -- if (bfd_link_dll (&link_info)) -+ /* -Bsymbolic-functions is for PIC output only. */ -+ if (bfd_link_pic (&link_info)) - command_line.dynamic_list = dynamic_list_data; - break; - } -diff -upr binutils-2.26.orig/ld/testsuite/ld-i386/i386.exp binutils-2.26/ld/testsuite/ld-i386/i386.exp ---- binutils-2.26.orig/ld/testsuite/ld-i386/i386.exp 2016-02-16 10:45:43.319336949 +0000 -+++ binutils-2.26/ld/testsuite/ld-i386/i386.exp 2016-02-16 10:47:04.672763461 +0000 -@@ -319,6 +319,7 @@ run_dump_test "load5a" - run_dump_test "load5b" - run_dump_test "load6" - run_dump_test "pr19175" -+run_dump_test "pr19615" - - if { !([istarget "i?86-*-linux*"] - || [istarget "i?86-*-gnu*"] ---- /dev/null 2016-02-16 08:27:18.513962320 +0000 -+++ binutils-2.26/ld/testsuite/ld-i386/pr19615.s 2016-02-16 10:56:11.886632341 +0000 -@@ -0,0 +1,13 @@ -+ .text -+ .globl _start -+ .type _start, @function -+_start: -+ ret -+ -+ .globl xyzzy /* This symbol should be exported */ -+ .type xyzzy, @function -+xyzzy: -+ ret -+ -+ .section ".xyzzy_ptr","aw",%progbits -+ .dc.a xyzzy ---- /dev/null 2016-02-16 08:27:18.513962320 +0000 -+++ binutils-2.26/ld/testsuite/ld-i386/pr19615.d 2016-02-16 10:56:11.886632341 +0000 -@@ -0,0 +1,13 @@ -+#as: --32 -+#ld: -pie -Bsymbolic -E -melf_i386 -+#readelf: -r --wide --dyn-syms -+ -+Relocation section '.rel.dyn' at offset 0x[0-9a-f]+ contains 1 entries: -+ Offset Info Type Sym. Value Symbol's Name -+[0-9a-f]+ +[0-9a-f]+ +R_386_RELATIVE + -+ -+Symbol table '.dynsym' contains [0-9]+ entries: -+ Num: Value Size Type Bind Vis Ndx Name -+#... -+[ ]*[a-f0-9]+: [a-f0-9]+ 0 FUNC GLOBAL DEFAULT [a-f0-9]+ xyzzy -+#... ---- /dev/null 2016-02-16 08:27:18.513962320 +0000 -+++ binutils-2.26/ld/testsuite/ld-x86-64/pr19615.s 2016-02-16 10:57:55.386174958 +0000 -@@ -0,0 +1,13 @@ -+ .text -+ .globl _start -+ .type _start, @function -+_start: -+ ret -+ -+ .globl xyzzy /* This symbol should be exported */ -+ .type xyzzy, @function -+xyzzy: -+ ret -+ -+ .section ".xyzzy_ptr","aw",%progbits -+ .dc.a xyzzy ---- /dev/null 2016-02-16 08:27:18.513962320 +0000 -+++ binutils-2.26/ld/testsuite/ld-x86-64/pr19615.d 2016-02-16 10:57:55.386174958 +0000 -@@ -0,0 +1,13 @@ -+#as: --64 -+#ld: -pie -Bsymbolic -E -melf_x86_64 -+#readelf: -r --wide --dyn-syms -+ -+Relocation section '.rela.dyn' at offset 0x[0-9a-f]+ contains 1 entries: -+ Offset Info Type Symbol's Value Symbol's Name \+ Addend -+[0-9a-f]+ +[0-9a-f]+ +R_X86_64_RELATIVE +[0-9]+ -+ -+Symbol table '.dynsym' contains [0-9]+ entries: -+ Num: Value Size Type Bind Vis Ndx Name -+#... -+[ ]*[a-f0-9]+: [a-f0-9]+ 0 FUNC GLOBAL DEFAULT [a-f0-9]+ xyzzy -+#... ---- binutils-2.26.orig/ld/testsuite/ld-x86-64/x86-64.exp 2016-02-16 10:45:43.443337600 +0000 -+++ binutils-2.26/ld/testsuite/ld-x86-64/x86-64.exp 2016-02-16 11:01:02.418162157 +0000 -@@ -353,6 +353,7 @@ run_dump_test "pr19013-x32" - run_dump_test "pr19013-nacl" - run_dump_test "pr19162" - run_dump_test "pr19175" -+run_dump_test "pr19615" - - # Add $PLT_CFLAGS if PLT is expected. - global PLT_CFLAGS diff --git a/source/d/binutils/patches/binutils-2.26-fix-GOT-offset-calculation.patch b/source/d/binutils/patches/binutils-2.26-fix-GOT-offset-calculation.patch deleted file mode 100644 index 99e8b708..00000000 --- a/source/d/binutils/patches/binutils-2.26-fix-GOT-offset-calculation.patch +++ /dev/null @@ -1,17 +0,0 @@ ---- binutils-2.26.orig/bfd/elf32-i386.c 2016-02-29 15:47:45.172597805 +0000 -+++ binutils-2.26/bfd/elf32-i386.c 2016-02-29 15:48:42.161904973 +0000 -@@ -4016,10 +4016,12 @@ elf_i386_relocate_section (bfd *output_b - - /* It is relative to .got.plt section. */ - if (h->got.offset != (bfd_vma) -1) -- /* Use GOT entry. */ -+ /* Use GOT entry. Mask off the least significant bit in -+ GOT offset which may be set by R_386_GOT32 processing -+ below. */ - relocation = (htab->elf.sgot->output_section->vma - + htab->elf.sgot->output_offset -- + h->got.offset - offplt); -+ + (h->got.offset & ~1) - offplt); - else - /* Use GOTPLT entry. */ - relocation = (h->plt.offset / plt_entry_size - 1 + 3) * 4; diff --git a/source/d/binutils/patches/binutils-2.26-fix-compile-warnings.patch b/source/d/binutils/patches/binutils-2.26-fix-compile-warnings.patch deleted file mode 100644 index 0fa527c7..00000000 --- a/source/d/binutils/patches/binutils-2.26-fix-compile-warnings.patch +++ /dev/null @@ -1,75 +0,0 @@ ---- binutils-2.26.orig/gold/dirsearch.cc 2016-02-04 10:31:45.228796199 +0000 -+++ binutils-2.26/gold/dirsearch.cc 2016-02-04 11:33:15.875824355 +0000 -@@ -122,6 +122,7 @@ class Dir_caches - Cache_hash caches_; - }; - -+#if 0 - Dir_caches::~Dir_caches() - { - for (Cache_hash::iterator p = this->caches_.begin(); -@@ -129,6 +130,7 @@ Dir_caches::~Dir_caches() - ++p) - delete p->second; - } -+#endif - - void - Dir_caches::add(const char* dirname) ---- binutils-2.26.orig/gold/arm.cc 2016-02-04 10:31:45.227796193 +0000 -+++ binutils-2.26/gold/arm.cc 2016-02-04 12:02:43.897996168 +0000 -@@ -4493,7 +4493,7 @@ Stub::do_fixed_endian_write(unsigned cha - // Reloc_stub::Key methods. - - // Dump a Key as a string for debugging. -- -+#if 0 - std::string - Reloc_stub::Key::name() const - { -@@ -4524,7 +4524,7 @@ Reloc_stub::Key::name() const - return std::string(buffer); - } - } -- -+#endif - // Reloc_stub methods. - - // Determine the type of stub needed, if any, for a relocation of R_TYPE at ---- binutils-2.26.orig/gas/config/tc-arm.c 2016-02-04 10:31:44.893794316 +0000 -+++ binutils-2.26/gas/config/tc-arm.c 2016-02-04 12:41:25.534564806 +0000 -@@ -155,10 +155,12 @@ static const arm_feature_set *object_arc - - /* Constants for known architecture features. */ - static const arm_feature_set fpu_default = FPU_DEFAULT; --static const arm_feature_set fpu_arch_vfp_v1 = FPU_ARCH_VFP_V1; - static const arm_feature_set fpu_arch_vfp_v2 = FPU_ARCH_VFP_V2; -+#if 0 -+static const arm_feature_set fpu_arch_vfp_v1 = FPU_ARCH_VFP_V1; - static const arm_feature_set fpu_arch_vfp_v3 = FPU_ARCH_VFP_V3; - static const arm_feature_set fpu_arch_neon_v1 = FPU_ARCH_NEON_V1; -+#endif - static const arm_feature_set fpu_arch_fpa = FPU_ARCH_FPA; - static const arm_feature_set fpu_any_hard = FPU_ANY_HARD; - static const arm_feature_set fpu_arch_maverick = FPU_ARCH_MAVERICK; -@@ -210,7 +212,9 @@ static const arm_feature_set arm_ext_vir - static const arm_feature_set arm_ext_pan = ARM_FEATURE_CORE_HIGH (ARM_EXT2_PAN); - - static const arm_feature_set arm_arch_any = ARM_ANY; -+#if 0 - static const arm_feature_set arm_arch_full = ARM_FEATURE (-1, -1, -1); -+#endif - static const arm_feature_set arm_arch_t2 = ARM_ARCH_THUMB2; - static const arm_feature_set arm_arch_none = ARM_ARCH_NONE; - static const arm_feature_set arm_arch_v6m_only = ARM_ARCH_V6M_ONLY; -@@ -259,8 +263,10 @@ static const arm_feature_set fpu_crypto_ - ARM_FEATURE_COPROC (FPU_CRYPTO_EXT_ARMV8); - static const arm_feature_set crc_ext_armv8 = - ARM_FEATURE_COPROC (CRC_EXT_ARMV8); -+#if 0 - static const arm_feature_set fpu_neon_ext_v8_1 = - ARM_FEATURE_COPROC (FPU_NEON_EXT_ARMV8 | FPU_NEON_EXT_RDMA); -+#endif - - static int mfloat_abi_opt = -1; - /* Record user cpu selection for object attributes. */ diff --git a/source/d/binutils/patches/binutils-2.26-formatting.patch b/source/d/binutils/patches/binutils-2.26-formatting.patch deleted file mode 100644 index 0eadb0c3..00000000 --- a/source/d/binutils/patches/binutils-2.26-formatting.patch +++ /dev/null @@ -1,297 +0,0 @@ ---- ../binutils-2.26.orig/bfd/coff-i386.c 2016-02-04 10:31:44.684793142 +0000 -+++ bfd/coff-i386.c 2016-02-04 10:32:02.106891045 +0000 -@@ -139,41 +139,41 @@ coff_i386_reloc (bfd *abfd, - #define DOIT(x) \ - x = ((x & ~howto->dst_mask) | (((x & howto->src_mask) + diff) & howto->dst_mask)) - -- if (diff != 0) -- { -- reloc_howto_type *howto = reloc_entry->howto; -- unsigned char *addr = (unsigned char *) data + reloc_entry->address; -+ if (diff != 0) -+ { -+ reloc_howto_type *howto = reloc_entry->howto; -+ unsigned char *addr = (unsigned char *) data + reloc_entry->address; -+ -+ switch (howto->size) -+ { -+ case 0: -+ { -+ char x = bfd_get_8 (abfd, addr); -+ DOIT (x); -+ bfd_put_8 (abfd, x, addr); -+ } -+ break; - -- switch (howto->size) -+ case 1: - { -- case 0: -- { -- char x = bfd_get_8 (abfd, addr); -- DOIT (x); -- bfd_put_8 (abfd, x, addr); -- } -- break; -- -- case 1: -- { -- short x = bfd_get_16 (abfd, addr); -- DOIT (x); -- bfd_put_16 (abfd, (bfd_vma) x, addr); -- } -- break; -- -- case 2: -- { -- long x = bfd_get_32 (abfd, addr); -- DOIT (x); -- bfd_put_32 (abfd, (bfd_vma) x, addr); -- } -- break; -+ short x = bfd_get_16 (abfd, addr); -+ DOIT (x); -+ bfd_put_16 (abfd, (bfd_vma) x, addr); -+ } -+ break; - -- default: -- abort (); -+ case 2: -+ { -+ long x = bfd_get_32 (abfd, addr); -+ DOIT (x); -+ bfd_put_32 (abfd, (bfd_vma) x, addr); - } -- } -+ break; -+ -+ default: -+ abort (); -+ } -+ } - - /* Now let bfd_perform_relocation finish everything up. */ - return bfd_reloc_continue; ---- ../binutils-2.26.orig/bfd/coff-x86_64.c 2016-02-04 10:31:44.686793153 +0000 -+++ bfd/coff-x86_64.c 2016-02-04 10:33:02.044227862 +0000 -@@ -138,59 +138,61 @@ coff_amd64_reloc (bfd *abfd, - #define DOIT(x) \ - x = ((x & ~howto->dst_mask) | (((x & howto->src_mask) + diff) & howto->dst_mask)) - -- if (diff != 0) -- { -- reloc_howto_type *howto = reloc_entry->howto; -- unsigned char *addr = (unsigned char *) data + reloc_entry->address; -- -- /* FIXME: We do not have an end address for data, so we cannot -- accurately range check any addresses computed against it. -- cf: PR binutils/17512: file: 1085-1761-0.004. -- For now we do the best that we can. */ -- if (addr < (unsigned char *) data || addr > ((unsigned char *) data) + input_section->size) -+ if (diff != 0) -+ { -+ reloc_howto_type *howto = reloc_entry->howto; -+ unsigned char *addr = (unsigned char *) data + reloc_entry->address; -+ -+ /* FIXME: We do not have an end address for data, so we cannot -+ accurately range check any addresses computed against it. -+ cf: PR binutils/17512: file: 1085-1761-0.004. -+ For now we do the best that we can. */ -+ if (addr < (unsigned char *) data -+ || addr > ((unsigned char *) data) + input_section->size) -+ { -+ bfd_set_error (bfd_error_bad_value); -+ return bfd_reloc_notsupported; -+ } -+ -+ switch (howto->size) -+ { -+ case 0: - { -- bfd_set_error (bfd_error_bad_value); -- return bfd_reloc_notsupported; -+ char x = bfd_get_8 (abfd, addr); -+ DOIT (x); -+ bfd_put_8 (abfd, x, addr); - } -+ break; - -- switch (howto->size) -+ case 1: - { -- case 0: -- { -- char x = bfd_get_8 (abfd, addr); -- DOIT (x); -- bfd_put_8 (abfd, x, addr); -- } -- break; -- -- case 1: -- { -- short x = bfd_get_16 (abfd, addr); -- DOIT (x); -- bfd_put_16 (abfd, (bfd_vma) x, addr); -- } -- break; -- -- case 2: -- { -- long x = bfd_get_32 (abfd, addr); -- DOIT (x); -- bfd_put_32 (abfd, (bfd_vma) x, addr); -- } -- break; -- case 4: -- { -- long long x = bfd_get_64 (abfd, addr); -- DOIT (x); -- bfd_put_64 (abfd, (bfd_vma) x, addr); -- } -- break; -- -- default: -- bfd_set_error (bfd_error_bad_value); -- return bfd_reloc_notsupported; -+ short x = bfd_get_16 (abfd, addr); -+ DOIT (x); -+ bfd_put_16 (abfd, (bfd_vma) x, addr); - } -- } -+ break; -+ -+ case 2: -+ { -+ long x = bfd_get_32 (abfd, addr); -+ DOIT (x); -+ bfd_put_32 (abfd, (bfd_vma) x, addr); -+ } -+ break; -+ -+ case 4: -+ { -+ long long x = bfd_get_64 (abfd, addr); -+ DOIT (x); -+ bfd_put_64 (abfd, (bfd_vma) x, addr); -+ } -+ break; -+ -+ default: -+ bfd_set_error (bfd_error_bad_value); -+ return bfd_reloc_notsupported; -+ } -+ } - - /* Now let bfd_perform_relocation finish everything up. */ - return bfd_reloc_continue; ---- ../binutils-2.26.orig/bfd/elf64-s390.c 2016-02-09 15:01:11.983640775 +0000 -+++ bfd/elf64-s390.c 2016-02-09 15:01:37.675779605 +0000 -@@ -337,10 +337,10 @@ elf_s390_reloc_name_lookup (bfd *abfd AT - && strcasecmp (elf_howto_table[i].name, r_name) == 0) - return &elf_howto_table[i]; - -- if (strcasecmp (elf64_s390_vtinherit_howto.name, r_name) == 0) -- return &elf64_s390_vtinherit_howto; -- if (strcasecmp (elf64_s390_vtentry_howto.name, r_name) == 0) -- return &elf64_s390_vtentry_howto; -+ if (strcasecmp (elf64_s390_vtinherit_howto.name, r_name) == 0) -+ return &elf64_s390_vtinherit_howto; -+ if (strcasecmp (elf64_s390_vtentry_howto.name, r_name) == 0) -+ return &elf64_s390_vtentry_howto; - - return NULL; - } ---- ../binutils-2.26.orig/bfd/pe-mips.c 2016-02-09 15:01:11.995640840 +0000 -+++ bfd/pe-mips.c 2016-02-09 15:31:21.348317265 +0000 -@@ -95,44 +95,44 @@ coff_mips_reloc (bfd *abfd, - #define DOIT(x) \ - x = ((x & ~howto->dst_mask) | (((x & howto->src_mask) + (diff >> howto->rightshift)) & howto->dst_mask)) - -- if (diff != 0) -- { -- reloc_howto_type *howto = reloc_entry->howto; -- unsigned char *addr = (unsigned char *) data + reloc_entry->address; -+ if (diff != 0) -+ { -+ reloc_howto_type *howto = reloc_entry->howto; -+ unsigned char *addr = (unsigned char *) data + reloc_entry->address; -+ -+ switch (howto->size) -+ { -+ case 0: -+ { -+ char x = bfd_get_8 (abfd, addr); -+ -+ DOIT (x); -+ bfd_put_8 (abfd, x, addr); -+ } -+ break; -+ -+ case 1: -+ { -+ short x = bfd_get_16 (abfd, addr); -+ -+ DOIT (x); -+ bfd_put_16 (abfd, (bfd_vma) x, addr); -+ } -+ break; - -- switch (howto->size) -+ case 2: - { -- case 0: -- { -- char x = bfd_get_8 (abfd, addr); -- -- DOIT (x); -- bfd_put_8 (abfd, x, addr); -- } -- break; -- -- case 1: -- { -- short x = bfd_get_16 (abfd, addr); -- -- DOIT (x); -- bfd_put_16 (abfd, (bfd_vma) x, addr); -- } -- break; -- -- case 2: -- { -- long x = bfd_get_32 (abfd, addr); -- -- DOIT (x); -- bfd_put_32 (abfd, (bfd_vma) x, addr); -- } -- break; -+ long x = bfd_get_32 (abfd, addr); - -- default: -- abort (); -+ DOIT (x); -+ bfd_put_32 (abfd, (bfd_vma) x, addr); - } -- } -+ break; -+ -+ default: -+ abort (); -+ } -+ } - - /* Now let bfd_perform_relocation finish everything up. */ - return bfd_reloc_continue; ---- ../binutils-2.26.orig/gas/config/tc-ia64.c 2016-02-09 15:01:12.086641332 +0000 -+++ gas/config/tc-ia64.c 2016-02-09 15:30:18.562003661 +0000 -@@ -4360,7 +4360,8 @@ dot_prologue (int dummy ATTRIBUTE_UNUSED - as_warn (_("Pointless use of zero first operand to .prologue")); - else - mask = e.X_add_number; -- n = popcount (mask); -+ -+ n = popcount (mask); - - if (sep == ',') - parse_operand_and_eval (&e, 0); diff --git a/source/d/binutils/patches/binutils-2.26-lto.patch b/source/d/binutils/patches/binutils-2.26-lto.patch deleted file mode 100644 index a20757b6..00000000 --- a/source/d/binutils/patches/binutils-2.26-lto.patch +++ /dev/null @@ -1,2652 +0,0 @@ -diff -rup binutils-2.26.orig/bfd/bfd.c binutils-2.26/bfd/bfd.c ---- binutils-2.26.orig/bfd/bfd.c 2016-02-19 09:35:36.231000625 +0000 -+++ binutils-2.26/bfd/bfd.c 2016-02-19 09:35:54.901106498 +0000 -@@ -57,6 +57,14 @@ CODE_FRAGMENT - . bfd_byte data[1]; - . }; - . -+.enum bfd_lto_object_type -+. { -+. lto_non_object, -+. lto_non_ir_object, -+. lto_ir_object, -+. lto_mixed_object -+. }; -+. - .struct bfd - .{ - . {* The filename the application opened the BFD with. *} -@@ -227,6 +235,9 @@ CODE_FRAGMENT - . {* Set if this is a plugin output file. *} - . unsigned int lto_output : 1; - . -+. {* LTO object type. *} -+. ENUM_BITFIELD (bfd_lto_object_type) lto_type : 2; -+. - . {* Set to dummy BFD created when claimed by a compiler plug-in - . library. *} - . bfd *plugin_dummy_bfd; -@@ -252,6 +263,9 @@ CODE_FRAGMENT - . {* The last section on the section list. *} - . struct bfd_section *section_last; - . -+. {* The object-only section on the section list. *} -+. struct bfd_section *object_only_section; -+. - . {* The number of sections. *} - . unsigned int section_count; - . -@@ -2270,3 +2284,36 @@ bfd_convert_section_contents (bfd *ibfd, - *ptr_size = size; - return TRUE; - } -+ -+/* -+FUNCTION -+ bfd_group_signature -+ -+SYNOPSIS -+ asymbol *bfd_group_signature (asection *group, asymbol **isympp); -+ -+DESCRIPTION -+ Return a pointer to the symbol used as a signature for GROUP. -+*/ -+ -+asymbol * -+bfd_group_signature (asection *group, asymbol **isympp) -+{ -+ bfd *abfd = group->owner; -+ Elf_Internal_Shdr *ghdr; -+ -+ if (bfd_get_flavour (abfd) != bfd_target_elf_flavour) -+ return NULL; -+ -+ ghdr = &elf_section_data (group)->this_hdr; -+ if (ghdr->sh_link < elf_numsections (abfd)) -+ { -+ const struct elf_backend_data *bed = get_elf_backend_data (abfd); -+ Elf_Internal_Shdr *symhdr = elf_elfsections (abfd) [ghdr->sh_link]; -+ -+ if (symhdr->sh_type == SHT_SYMTAB -+ && ghdr->sh_info < symhdr->sh_size / bed->s->sizeof_sym) -+ return isympp[ghdr->sh_info - 1]; -+ } -+ return NULL; -+} -diff -rup binutils-2.26.orig/bfd/bfd-in2.h binutils-2.26/bfd/bfd-in2.h ---- binutils-2.26.orig/bfd/bfd-in2.h 2016-02-19 09:35:36.280000903 +0000 -+++ binutils-2.26/bfd/bfd-in2.h 2016-02-19 09:35:54.900106492 +0000 -@@ -1089,6 +1089,9 @@ struct bfd_section *bfd_create_gnu_debug - bfd_boolean bfd_fill_in_gnu_debuglink_section - (bfd *abfd, struct bfd_section *sect, const char *filename); - -+const char *bfd_extract_object_only_section -+ (bfd *abfd); -+ - /* Extracted from libbfd.c. */ - - /* Byte swapping macros for user section data. */ -@@ -1654,6 +1657,9 @@ extern asection _bfd_std_section[4]; - #define BFD_COM_SECTION_NAME "*COM*" - #define BFD_IND_SECTION_NAME "*IND*" - -+/* GNU object-only section name. */ -+#define GNU_OBJECT_ONLY_SECTION_NAME ".gnu_object_only" -+ - /* Pointer to the common section. */ - #define bfd_com_section_ptr (&_bfd_std_section[0]) - /* Pointer to the undefined section. */ -@@ -6511,6 +6517,14 @@ struct bfd_build_id - bfd_byte data[1]; - }; - -+enum bfd_lto_object_type -+ { -+ lto_non_object, -+ lto_non_ir_object, -+ lto_ir_object, -+ lto_mixed_object -+ }; -+ - struct bfd - { - /* The filename the application opened the BFD with. */ -@@ -6681,6 +6695,9 @@ struct bfd - /* Set if this is a plugin output file. */ - unsigned int lto_output : 1; - -+ /* LTO object type. */ -+ ENUM_BITFIELD (bfd_lto_object_type) lto_type : 2; -+ - /* Set to dummy BFD created when claimed by a compiler plug-in - library. */ - bfd *plugin_dummy_bfd; -@@ -6706,6 +6723,9 @@ struct bfd - /* The last section on the section list. */ - struct bfd_section *section_last; - -+ /* The object-only section on the section list. */ -+ struct bfd_section *object_only_section; -+ - /* The number of sections. */ - unsigned int section_count; - -@@ -7026,6 +7046,8 @@ bfd_boolean bfd_convert_section_contents - (bfd *ibfd, asection *isec, bfd *obfd, - bfd_byte **ptr, bfd_size_type *ptr_size); - -+asymbol *bfd_group_signature (asection *group, asymbol **isympp); -+ - /* Extracted from archive.c. */ - symindex bfd_get_next_mapent - (bfd *abfd, symindex previous, carsym **sym); -diff -rup binutils-2.26.orig/bfd/elf.c binutils-2.26/bfd/elf.c ---- binutils-2.26.orig/bfd/elf.c 2016-02-19 09:35:36.280000903 +0000 -+++ binutils-2.26/bfd/elf.c 2016-02-19 09:35:54.904106515 +0000 -@@ -2387,6 +2387,7 @@ static const struct bfd_elf_special_sect - { STRING_COMMA_LEN (".gnu.linkonce.b"), -2, SHT_NOBITS, SHF_ALLOC + SHF_WRITE }, - { STRING_COMMA_LEN (".gnu.lto_"), -1, SHT_PROGBITS, SHF_EXCLUDE }, - { STRING_COMMA_LEN (".got"), 0, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE }, -+ { STRING_COMMA_LEN (".gnu_object_only"), 0, SHT_GNU_OBJECT_ONLY, SHF_EXCLUDE }, - { STRING_COMMA_LEN (".gnu.version"), 0, SHT_GNU_versym, 0 }, - { STRING_COMMA_LEN (".gnu.version_d"), 0, SHT_GNU_verdef, 0 }, - { STRING_COMMA_LEN (".gnu.version_r"), 0, SHT_GNU_verneed, 0 }, -diff -rup binutils-2.26.orig/bfd/format.c binutils-2.26/bfd/format.c ---- binutils-2.26.orig/bfd/format.c 2016-02-19 09:35:36.265000818 +0000 -+++ binutils-2.26/bfd/format.c 2016-02-19 09:36:21.420256880 +0000 -@@ -46,6 +46,9 @@ SUBSECTION - #include "sysdep.h" - #include "bfd.h" - #include "libbfd.h" -+#if BFD_SUPPORTS_PLUGINS -+#include "plugin.h" -+#endif - - /* IMPORT from targets.c. */ - extern const size_t _bfd_target_vector_entries; -@@ -179,6 +182,33 @@ bfd_preserve_finish (bfd *abfd ATTRIBUTE - preserve->marker = NULL; - } - -+/* Set lto_type in ABFD. */ -+ -+static void -+bfd_set_lto_type (bfd *abfd) -+{ -+ if (abfd->format == bfd_object -+ && abfd->lto_type == lto_non_object -+ && (abfd->flags & (DYNAMIC | EXEC_P)) == 0) -+ { -+ asection *sec; -+ enum bfd_lto_object_type type = lto_non_ir_object; -+ for (sec = abfd->sections; sec != NULL; sec = sec->next) -+ { -+ if (strcmp (sec->name, GNU_OBJECT_ONLY_SECTION_NAME) == 0) -+ { -+ type = lto_mixed_object; -+ abfd->object_only_section = sec; -+ break; -+ } -+ else if (type != lto_ir_object -+ && strncmp (sec->name, ".gnu.lto_", 9) == 0) -+ type = lto_ir_object; -+ } -+ abfd->lto_type = type; -+ } -+} -+ - /* - FUNCTION - bfd_check_format_matches -@@ -221,7 +251,10 @@ bfd_check_format_matches (bfd *abfd, bfd - } - - if (abfd->format != bfd_unknown) -- return abfd->format == format; -+ { -+ bfd_set_lto_type (abfd); -+ return abfd->format == format; -+ } - - if (matching != NULL || *bfd_associated_vector != NULL) - { -@@ -285,6 +318,13 @@ bfd_check_format_matches (bfd *abfd, bfd - || (*target)->match_priority > best_match) - continue; - -+#if BFD_SUPPORTS_PLUGINS -+ /* If the plugin target is explicitly specified when a BFD file -+ is opened, don't check it twice. */ -+ if (bfd_plugin_specified_p () && bfd_plugin_target_p (*target)) -+ continue; -+#endif -+ - /* If we already tried a match, the bfd is modified and may - have sections attached, which will confuse the next - _bfd_check_format call. */ -@@ -449,6 +489,8 @@ bfd_check_format_matches (bfd *abfd, bfd - if (matching_vector) - free (matching_vector); - -+ bfd_set_lto_type (abfd); -+ - /* File position has moved, BTW. */ - return TRUE; - } -diff -rup binutils-2.26.orig/bfd/opncls.c binutils-2.26/bfd/opncls.c ---- binutils-2.26.orig/bfd/opncls.c 2016-02-19 09:35:36.281000909 +0000 -+++ binutils-2.26/bfd/opncls.c 2016-02-19 09:35:54.905106520 +0000 -@@ -1717,3 +1717,69 @@ bfd_fill_in_gnu_debuglink_section (bfd * - - return TRUE; - } -+ -+/* -+FUNCTION -+ bfd_extract_object_only_section -+ -+SYNOPSIS -+ const char *bfd_extract_object_only_section -+ (bfd *abfd); -+ -+DESCRIPTION -+ -+ Takes a @var{ABFD} and extract the .gnu_object_only section into -+ a temporary file. -+ -+RETURNS -+ The name of the temporary file is returned if all is ok. -+ Otherwise <<NULL>> is returned and bfd_error is set. -+*/ -+ -+const char * -+bfd_extract_object_only_section (bfd *abfd) -+{ -+ asection *sec = abfd->object_only_section; -+ const char *name; -+ FILE *file; -+ bfd_byte *memhunk = NULL; -+ size_t off, size; -+ bfd_error_type err; -+ -+ /* Get a temporary object-only file. */ -+ name = make_temp_file (".obj-only.o"); -+ -+ /* Open the object-only file. */ -+ file = real_fopen (name, FOPEN_WB); -+ if (!bfd_get_full_section_contents (abfd, sec, &memhunk)) -+ { -+ err = bfd_get_error (); -+ -+loser: -+ free (memhunk); -+ fclose (file); -+ unlink (name); -+ bfd_set_error (err); -+ return NULL; -+ } -+ -+ off = 0; -+ size = sec->size; -+ while (off != size) -+ { -+ size_t written, nwrite = size - off; -+ -+ written = fwrite (memhunk + off, 1, nwrite, file); -+ if (written < nwrite && ferror (file)) -+ { -+ err = bfd_error_system_call; -+ goto loser; -+ } -+ -+ off += written; -+ } -+ -+ free (memhunk); -+ fclose (file); -+ return name; -+} -diff -rup binutils-2.26.orig/bfd/plugin.c binutils-2.26/bfd/plugin.c ---- binutils-2.26.orig/bfd/plugin.c 2016-02-19 09:35:36.271000852 +0000 -+++ binutils-2.26/bfd/plugin.c 2016-02-19 09:35:54.905106520 +0000 -@@ -130,6 +130,146 @@ register_claim_file (ld_plugin_claim_fil - return LDPS_OK; - } - -+static asection bfd_plugin_fake_text_section -+ = BFD_FAKE_SECTION (bfd_plugin_fake_text_section, 0, 0, ".text", 0); -+static asection bfd_plugin_fake_common_section -+ = BFD_FAKE_SECTION (bfd_plugin_fake_common_section, SEC_IS_COMMON, 0, -+ NULL, 0); -+ -+/* Get symbols from object only section. */ -+ -+static void -+bfd_plugin_get_symbols_in_object_only (bfd *abfd) -+{ -+ struct plugin_data_struct *plugin_data = abfd->tdata.plugin_data; -+ const char *object_only_file; -+ bfd *nbfd; -+ long storage; -+ long object_only_nsyms, added_nsyms, i; -+ asymbol **object_only_syms, **added_syms; -+ -+ plugin_data->object_only_syms = NULL; -+ plugin_data->object_only_nsyms = 0; -+ -+ if (abfd->sections == NULL && abfd->my_archive == NULL) -+ { -+ nbfd = bfd_openr (abfd->filename, NULL); -+ if (nbfd == NULL) -+ { -+ (*_bfd_error_handler) -+ (_("%s: failed to open to extract object only section: %s"), -+ abfd->filename, bfd_errmsg (bfd_get_error ())); -+ goto error_return; -+ } -+ else if (!bfd_check_format (nbfd, bfd_object)) -+ { -+ /* There is no object only section if it isn't a bfd_object -+ file. */ -+error_return: -+ bfd_close (nbfd); -+ return; -+ } -+ } -+ else -+ { -+ if (!bfd_check_format (abfd, bfd_object)) -+ { -+ (*_bfd_error_handler) -+ (_("%B: invalid file to extract object only section: %s"), -+ abfd, bfd_errmsg (bfd_get_error ())); -+ return; -+ } -+ nbfd = abfd; -+ } -+ -+ if (nbfd->lto_type == lto_mixed_object -+ && (nbfd->flags & HAS_SYMS) != 0) -+ { -+ object_only_file = bfd_extract_object_only_section (nbfd); -+ if (object_only_file == NULL) -+ (*_bfd_error_handler) -+ (_("%B: failed to extract object only section: %s"), -+ abfd, bfd_errmsg (bfd_get_error ())); -+ } -+ else -+ object_only_file = NULL; -+ -+ /* Close the new bfd we just opened. */ -+ if (nbfd != abfd) -+ bfd_close (nbfd); -+ -+ /* Return if there is no object only section or there is no -+ symbol in object only section. */ -+ if (!object_only_file) -+ return; -+ -+ /* Open the file containing object only section. */ -+ nbfd = bfd_openr (object_only_file, NULL); -+ if (!bfd_check_format (nbfd, bfd_object)) -+ { -+ (*_bfd_error_handler) -+ (_("%B: failed to open object only section: %s"), -+ abfd, bfd_errmsg (bfd_get_error ())); -+ goto quit; -+ } -+ -+ storage = bfd_get_symtab_upper_bound (nbfd); -+ if (storage <= 0) -+ { -+ if (storage < 0) -+ (*_bfd_error_handler) -+ (_("%B: failed to get symbol table in object only section: %s"), -+ abfd, bfd_errmsg (bfd_get_error ())); -+ -+ goto quit; -+ } -+ -+ object_only_syms = (asymbol **) bfd_malloc (storage); -+ object_only_nsyms = bfd_canonicalize_symtab (nbfd, object_only_syms); -+ -+ /* FIXME: We waste some spaces if not all symbols are copied. */ -+ added_syms = (asymbol **) bfd_alloc (abfd, storage); -+ added_nsyms = 0; -+ -+ /* Copy only global symbols from object only section. */ -+ for (i = 0; i < object_only_nsyms; i++) -+ { -+ asection *sec = object_only_syms[i]->section; -+ flagword flags = object_only_syms[i]->flags; -+ asymbol *s; -+ -+ if (bfd_is_com_section (sec)) -+ sec = &bfd_plugin_fake_common_section; -+ else if (bfd_is_und_section (sec)) -+ ; -+ else if ((flags & (BSF_GLOBAL | BSF_WEAK | BSF_GNU_UNIQUE)) != 0) -+ sec = &bfd_plugin_fake_text_section; -+ else -+ continue; -+ -+ s = bfd_alloc (abfd, sizeof (asymbol)); -+ BFD_ASSERT (s); -+ added_syms[added_nsyms++] = s; -+ -+ s->section = sec; -+ s->the_bfd = abfd; -+ s->name = xstrdup (object_only_syms[i]->name); -+ s->value = 0; -+ s->flags = flags; -+ s->udata.p = NULL; -+ } -+ -+ plugin_data->object_only_syms = added_syms; -+ plugin_data->object_only_nsyms = added_nsyms; -+ -+ free (object_only_syms); -+ -+quit: -+ /* Close and remove the object only section file. */ -+ bfd_close (nbfd); -+ unlink (object_only_file); -+} -+ - static enum ld_plugin_status - add_symbols (void * handle, - int nsyms, -@@ -142,10 +282,13 @@ add_symbols (void * handle, - plugin_data->nsyms = nsyms; - plugin_data->syms = syms; - -- if (nsyms != 0) -+ abfd->tdata.plugin_data = plugin_data; -+ -+ bfd_plugin_get_symbols_in_object_only (abfd); -+ -+ if ((nsyms + plugin_data->object_only_nsyms) != 0) - abfd->flags |= HAS_SYMS; - -- abfd->tdata.plugin_data = plugin_data; - return LDPS_OK; - } - -@@ -440,7 +583,8 @@ static long - bfd_plugin_get_symtab_upper_bound (bfd *abfd) - { - struct plugin_data_struct *plugin_data = abfd->tdata.plugin_data; -- long nsyms = plugin_data->nsyms; -+ /* Add symbols from object only section. */ -+ long nsyms = plugin_data->nsyms + plugin_data->object_only_nsyms; - - BFD_ASSERT (nsyms >= 0); - -@@ -474,12 +618,7 @@ bfd_plugin_canonicalize_symtab (bfd *abf - struct plugin_data_struct *plugin_data = abfd->tdata.plugin_data; - long nsyms = plugin_data->nsyms; - const struct ld_plugin_symbol *syms = plugin_data->syms; -- static asection fake_section; -- static asection fake_common_section; -- int i; -- -- fake_section.name = ".text"; -- fake_common_section.flags = SEC_IS_COMMON; -+ int i, j; - - for (i = 0; i < nsyms; i++) - { -@@ -492,10 +631,11 @@ bfd_plugin_canonicalize_symtab (bfd *abf - s->name = syms[i].name; - s->value = 0; - s->flags = convert_flags (&syms[i]); -+ s->udata.p = NULL; - switch (syms[i].def) - { - case LDPK_COMMON: -- s->section = &fake_common_section; -+ s->section = &bfd_plugin_fake_common_section; - break; - case LDPK_UNDEF: - case LDPK_WEAKUNDEF: -@@ -503,15 +643,18 @@ bfd_plugin_canonicalize_symtab (bfd *abf - break; - case LDPK_DEF: - case LDPK_WEAKDEF: -- s->section = &fake_section; -+ s->section = &bfd_plugin_fake_text_section; - break; - default: - BFD_ASSERT (0); - } -- -- s->udata.p = (void *) &syms[i]; - } - -+ /* Copy symbols from object only section. */ -+ nsyms += plugin_data->object_only_nsyms; -+ for (j = 0; j < plugin_data->object_only_nsyms; j++, i++) -+ alocation[i] = plugin_data->object_only_syms[j]; -+ - return nsyms; - } - -diff -rup binutils-2.26.orig/bfd/plugin.h binutils-2.26/bfd/plugin.h ---- binutils-2.26.orig/bfd/plugin.h 2016-02-19 09:35:36.271000852 +0000 -+++ binutils-2.26/bfd/plugin.h 2016-02-19 09:35:54.906106526 +0000 -@@ -33,6 +33,8 @@ typedef struct plugin_data_struct - { - int nsyms; - const struct ld_plugin_symbol *syms; -+ int object_only_nsyms; -+ asymbol **object_only_syms; - } - plugin_data_struct; - -diff -rup binutils-2.26.orig/bfd/section.c binutils-2.26/bfd/section.c ---- binutils-2.26.orig/bfd/section.c 2016-02-19 09:35:36.276000881 +0000 -+++ binutils-2.26/bfd/section.c 2016-02-19 09:35:54.906106526 +0000 -@@ -588,6 +588,9 @@ CODE_FRAGMENT - .#define BFD_COM_SECTION_NAME "*COM*" - .#define BFD_IND_SECTION_NAME "*IND*" - . -+.{* GNU object-only section name. *} -+.#define GNU_OBJECT_ONLY_SECTION_NAME ".gnu_object_only" -+. - .{* Pointer to the common section. *} - .#define bfd_com_section_ptr (&_bfd_std_section[0]) - .{* Pointer to the undefined section. *} -diff -rup binutils-2.26.orig/binutils/objcopy.c binutils-2.26/binutils/objcopy.c ---- binutils-2.26.orig/binutils/objcopy.c 2016-02-19 09:35:36.287000943 +0000 -+++ binutils-2.26/binutils/objcopy.c 2016-02-19 09:35:54.908106537 +0000 -@@ -1108,30 +1108,6 @@ is_specified_symbol (const char *name, h - return htab_find (htab, name) != NULL; - } - --/* Return a pointer to the symbol used as a signature for GROUP. */ -- --static asymbol * --group_signature (asection *group) --{ -- bfd *abfd = group->owner; -- Elf_Internal_Shdr *ghdr; -- -- if (bfd_get_flavour (abfd) != bfd_target_elf_flavour) -- return NULL; -- -- ghdr = &elf_section_data (group)->this_hdr; -- if (ghdr->sh_link < elf_numsections (abfd)) -- { -- const struct elf_backend_data *bed = get_elf_backend_data (abfd); -- Elf_Internal_Shdr *symhdr = elf_elfsections (abfd) [ghdr->sh_link]; -- -- if (symhdr->sh_type == SHT_SYMTAB -- && ghdr->sh_info < symhdr->sh_size / bed->s->sizeof_sym) -- return isympp[ghdr->sh_info - 1]; -- } -- return NULL; --} -- - /* Return TRUE if the section is a DWO section. */ - - static bfd_boolean -@@ -1237,7 +1213,7 @@ is_strip_section (bfd *abfd ATTRIBUTE_UN - /* PR binutils/3181 - If we are going to strip the group signature symbol, then - strip the group section too. */ -- gsym = group_signature (sec); -+ gsym = bfd_group_signature (sec, isympp); - if (gsym != NULL) - gname = gsym->name; - else -@@ -3091,7 +3067,7 @@ setup_section (bfd *ibfd, sec_ptr isecti - - if ((isection->flags & SEC_GROUP) != 0) - { -- asymbol *gsym = group_signature (isection); -+ asymbol *gsym = bfd_group_signature (isection, isympp); - - if (gsym != NULL) - { -diff -rup binutils-2.26.orig/binutils/readelf.c binutils-2.26/binutils/readelf.c ---- binutils-2.26.orig/binutils/readelf.c 2016-02-19 09:35:36.295000988 +0000 -+++ binutils-2.26/binutils/readelf.c 2016-02-19 09:35:54.911106554 +0000 -@@ -3900,6 +3900,7 @@ get_section_type_name (unsigned int sh_t - case 0x7ffffffd: return "AUXILIARY"; - case 0x7fffffff: return "FILTER"; - case SHT_GNU_LIBLIST: return "GNU_LIBLIST"; -+ case SHT_GNU_OBJECT_ONLY: return "GNU_OBJECT_ONLY"; - - default: - if ((sh_type >= SHT_LOPROC) && (sh_type <= SHT_HIPROC)) -diff -rup binutils-2.26.orig/gas/testsuite/gas/elf/section9.d binutils-2.26/gas/testsuite/gas/elf/section9.d ---- binutils-2.26.orig/gas/testsuite/gas/elf/section9.d 2016-02-19 09:35:36.397001567 +0000 -+++ binutils-2.26/gas/testsuite/gas/elf/section9.d 2016-02-19 09:35:54.912106560 +0000 -@@ -4,4 +4,5 @@ - #... - [ ]*\[.*\][ ]+\.gnu\.lto_main[ ]+PROGBITS.*[ ]+E[ ]+.* - [ ]*\[.*\][ ]+\.gnu\.lto_\.pureconst[ ]+PROGBITS.*[ ]+E[ ]+.* -+[ ]*\[.*\][ ]+\.gnu_object_only[ ]+GNU_OBJECT_ONLY.*[ ]+E[ ]+.* - #pass -diff -rup binutils-2.26.orig/gas/testsuite/gas/elf/section9.s binutils-2.26/gas/testsuite/gas/elf/section9.s ---- binutils-2.26.orig/gas/testsuite/gas/elf/section9.s 2016-02-19 09:35:36.397001567 +0000 -+++ binutils-2.26/gas/testsuite/gas/elf/section9.s 2016-02-19 09:35:54.912106560 +0000 -@@ -2,3 +2,5 @@ - .byte 0,0,0,0 - .section .gnu.lto_.pureconst,"",%progbits - .byte 0,0,0,0 -+ .section .gnu_object_only -+ .byte 0,0,0,0 -diff -rup binutils-2.26.orig/include/bfdlink.h binutils-2.26/include/bfdlink.h ---- binutils-2.26.orig/include/bfdlink.h 2016-02-19 09:35:36.672003126 +0000 -+++ binutils-2.26/include/bfdlink.h 2016-02-19 09:35:54.913106566 +0000 -@@ -400,6 +400,12 @@ struct bfd_link_info - /* TRUE if ok to have multiple definition. */ - unsigned int allow_multiple_definition: 1; - -+ /* TRUE if .gnu_object_only section should be created. */ -+ unsigned int emit_gnu_object_only: 1; -+ -+ /* TRUE if .gnu_object_only section is being created. */ -+ unsigned int emitting_gnu_object_only: 1; -+ - /* TRUE if ok to have version with no definition. */ - unsigned int allow_undefined_version: 1; - -diff -rup binutils-2.26.orig/include/elf/common.h binutils-2.26/include/elf/common.h ---- binutils-2.26.orig/include/elf/common.h 2016-02-19 09:35:36.675003143 +0000 -+++ binutils-2.26/include/elf/common.h 2016-02-19 09:35:54.913106566 +0000 -@@ -478,6 +478,7 @@ - #define SHT_GNU_ATTRIBUTES 0x6ffffff5 /* Object attributes */ - #define SHT_GNU_HASH 0x6ffffff6 /* GNU style symbol hash table */ - #define SHT_GNU_LIBLIST 0x6ffffff7 /* List of prelink dependencies */ -+#define SHT_GNU_OBJECT_ONLY 0x6ffffff8 /* Object only */ - - /* The next three section types are defined by Solaris, and are named - SHT_SUNW*. We use them in GNU code, so we also define SHT_GNU* -diff -rup binutils-2.26.orig/ld/emultempl/aarch64elf.em binutils-2.26/ld/emultempl/aarch64elf.em ---- binutils-2.26.orig/ld/emultempl/aarch64elf.em 2016-02-19 09:35:36.698003274 +0000 -+++ binutils-2.26/ld/emultempl/aarch64elf.em 2016-02-19 09:35:54.914106571 +0000 -@@ -271,7 +271,7 @@ gld${EMULATION_NAME}_after_allocation (v - } - - static void --gld${EMULATION_NAME}_finish (void) -+aarch64_finish (void) - { - if (!bfd_link_relocatable (&link_info)) - { -@@ -283,7 +283,7 @@ gld${EMULATION_NAME}_finish (void) - } - } - -- finish_default (); -+ gld${EMULATION_NAME}_finish (); - } - - /* This is a convenient point to tell BFD about target specific flags. -@@ -435,4 +435,4 @@ LDEMUL_CREATE_OUTPUT_SECTION_STATEMENTS= - LDEMUL_BEFORE_PARSE=gld"${EMULATION_NAME}"_before_parse - - # Call the extra arm-elf function --LDEMUL_FINISH=gld${EMULATION_NAME}_finish -+LDEMUL_FINISH=aarch64_finish -diff -rup binutils-2.26.orig/ld/emultempl/alphaelf.em binutils-2.26/ld/emultempl/alphaelf.em ---- binutils-2.26.orig/ld/emultempl/alphaelf.em 2016-02-19 09:35:36.698003274 +0000 -+++ binutils-2.26/ld/emultempl/alphaelf.em 2016-02-19 09:35:54.914106571 +0000 -@@ -104,7 +104,7 @@ alpha_finish (void) - if (limit_32bit) - elf_elfheader (link_info.output_bfd)->e_flags |= EF_ALPHA_32BIT; - -- finish_default (); -+ gld${EMULATION_NAME}_finish (); - } - EOF - -diff -rup binutils-2.26.orig/ld/emultempl/armelf.em binutils-2.26/ld/emultempl/armelf.em ---- binutils-2.26.orig/ld/emultempl/armelf.em 2016-02-19 09:35:36.698003274 +0000 -+++ binutils-2.26/ld/emultempl/armelf.em 2016-02-19 09:35:54.914106571 +0000 -@@ -377,7 +377,7 @@ gld${EMULATION_NAME}_after_allocation (v - } - - static void --gld${EMULATION_NAME}_finish (void) -+arm_finish (void) - { - struct bfd_link_hash_entry * h; - -@@ -404,7 +404,7 @@ gld${EMULATION_NAME}_finish (void) - } - } - -- finish_default (); -+ gld${EMULATION_NAME}_finish (); - - if (thumb_entry_symbol) - { -@@ -730,4 +730,4 @@ LDEMUL_CREATE_OUTPUT_SECTION_STATEMENTS= - LDEMUL_BEFORE_PARSE=gld"${EMULATION_NAME}"_before_parse - - # Call the extra arm-elf function --LDEMUL_FINISH=gld${EMULATION_NAME}_finish -+LDEMUL_FINISH=arm_finish -diff -rup binutils-2.26.orig/ld/emultempl/avrelf.em binutils-2.26/ld/emultempl/avrelf.em ---- binutils-2.26.orig/ld/emultempl/avrelf.em 2016-02-19 09:35:36.698003274 +0000 -+++ binutils-2.26/ld/emultempl/avrelf.em 2016-02-19 09:35:54.915106577 +0000 -@@ -209,7 +209,7 @@ avr_finish (void) - else - elf_elfheader (abfd)->e_flags &= ~EF_AVR_LINKRELAX_PREPARED; - -- finish_default (); -+ gld${EMULATION_NAME}_finish (); - } - EOF - -diff -rup binutils-2.26.orig/ld/emultempl/elf32.em binutils-2.26/ld/emultempl/elf32.em ---- binutils-2.26.orig/ld/emultempl/elf32.em 2016-02-19 09:35:36.700003285 +0000 -+++ binutils-2.26/ld/emultempl/elf32.em 2016-02-19 09:35:54.915106577 +0000 -@@ -66,6 +66,7 @@ static void gld${EMULATION_NAME}_before_ - static void gld${EMULATION_NAME}_after_allocation (void); - static lang_output_section_statement_type *gld${EMULATION_NAME}_place_orphan - (asection *, const char *, int); -+static void gld${EMULATION_NAME}_finish (void); - EOF - - if [ "x${USE_LIBPATH}" = xyes ] ; then -@@ -1795,6 +1796,8 @@ output_rel_find (asection *sec, int isdy - return last; - } - -+static int orphan_init_done = 0; -+ - /* Place an orphan section. We use this to put random SHF_ALLOC - sections in the right segment. */ - -@@ -1803,7 +1806,7 @@ gld${EMULATION_NAME}_place_orphan (asect - const char *secname, - int constraint) - { -- static struct orphan_save hold[] = -+ static struct orphan_save orig_hold[] = - { - { ".text", - SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_READONLY | SEC_CODE, -@@ -1833,6 +1836,7 @@ gld${EMULATION_NAME}_place_orphan (asect - SEC_HAS_CONTENTS, - 0, 0, 0, 0 }, - }; -+ static struct orphan_save hold[ARRAY_SIZE (orig_hold)]; - enum orphan_save_index - { - orphan_text = 0, -@@ -1845,7 +1849,6 @@ gld${EMULATION_NAME}_place_orphan (asect - orphan_sdata, - orphan_nonalloc - }; -- static int orphan_init_done = 0; - struct orphan_save *place; - lang_output_section_statement_type *after; - lang_output_section_statement_type *os; -@@ -1924,15 +1927,22 @@ gld${EMULATION_NAME}_place_orphan (asect - - if (!orphan_init_done) - { -- struct orphan_save *ho; -+ struct orphan_save *ho, *horig; - - for (ho = hold; ho < hold + sizeof (hold) / sizeof (hold[0]); ++ho) -+ for (ho = hold, horig = orig_hold; -+ ho < hold + ARRAY_SIZE (hold); -+ ++ho, ++horig) -+ { -+ *ho = *horig; -+ if (ho->name != NULL) - if (ho->name != NULL) - { - ho->os = lang_output_section_find (ho->name); - if (ho->os != NULL && ho->os->flags == 0) - ho->os->flags = ho->flags; - } -+ } - orphan_init_done = 1; - } - -@@ -2017,6 +2027,27 @@ gld${EMULATION_NAME}_place_orphan (asect - EOF - fi - -+fragment <<EOF -+ -+/* Final emulation specific call. */ -+ -+static void -+gld${EMULATION_NAME}_finish (void) -+{ -+EOF -+if test x"$LDEMUL_PLACE_ORPHAN" != xgld"$EMULATION_NAME"_place_orphan; then -+fragment <<EOF -+ /* Support the object-only output. */ -+ if (link_info.emit_gnu_object_only) -+ orphan_init_done = 0; -+ -+EOF -+fi -+fragment <<EOF -+ finish_default (); -+} -+EOF -+ - if test x"$LDEMUL_AFTER_ALLOCATION" != xgld"$EMULATION_NAME"_after_allocation; then - fragment <<EOF - -@@ -2503,7 +2534,7 @@ struct ld_emulation_xfer_struct ld_${EMU - ${LDEMUL_GET_SCRIPT-gld${EMULATION_NAME}_get_script}, - "${EMULATION_NAME}", - "${OUTPUT_FORMAT}", -- ${LDEMUL_FINISH-finish_default}, -+ ${LDEMUL_FINISH-gld${EMULATION_NAME}_finish}, - ${LDEMUL_CREATE_OUTPUT_SECTION_STATEMENTS-NULL}, - ${LDEMUL_OPEN_DYNAMIC_ARCHIVE-gld${EMULATION_NAME}_open_dynamic_archive}, - ${LDEMUL_PLACE_ORPHAN-gld${EMULATION_NAME}_place_orphan}, -diff -rup binutils-2.26.orig/ld/emultempl/ppc32elf.em binutils-2.26/ld/emultempl/ppc32elf.em ---- binutils-2.26.orig/ld/emultempl/ppc32elf.em 2016-02-19 09:35:36.699003279 +0000 -+++ binutils-2.26/ld/emultempl/ppc32elf.em 2016-02-19 09:35:54.916106583 +0000 -@@ -215,7 +215,7 @@ ppc_finish (void) - { - if (params.ppc476_workaround) - lang_for_each_statement (no_zero_padding); -- finish_default (); -+ gld${EMULATION_NAME}_finish (); - } - - EOF -diff -rup binutils-2.26.orig/ld/emultempl/ppc64elf.em binutils-2.26/ld/emultempl/ppc64elf.em ---- binutils-2.26.orig/ld/emultempl/ppc64elf.em 2016-02-19 09:35:36.699003279 +0000 -+++ binutils-2.26/ld/emultempl/ppc64elf.em 2016-02-19 09:35:54.916106583 +0000 -@@ -562,7 +562,7 @@ gld${EMULATION_NAME}_after_allocation (v - /* Final emulation specific call. */ - - static void --gld${EMULATION_NAME}_finish (void) -+ppc_finish (void) - { - char *msg = NULL; - char *line, *endline; -@@ -594,7 +594,7 @@ gld${EMULATION_NAME}_finish (void) - free (msg); - - ppc64_elf_restore_symbols (&link_info); -- finish_default (); -+ gld${EMULATION_NAME}_finish (); - } - - -@@ -928,4 +928,4 @@ LDEMUL_CREATE_OUTPUT_SECTION_STATEMENTS= - LDEMUL_AFTER_OPEN=ppc_after_open - LDEMUL_BEFORE_ALLOCATION=ppc_before_allocation - LDEMUL_AFTER_ALLOCATION=gld${EMULATION_NAME}_after_allocation --LDEMUL_FINISH=gld${EMULATION_NAME}_finish -+LDEMUL_FINISH=ppc_finish -diff -rup binutils-2.26.orig/ld/emultempl/spuelf.em binutils-2.26/ld/emultempl/spuelf.em ---- binutils-2.26.orig/ld/emultempl/spuelf.em 2016-02-19 09:35:36.699003279 +0000 -+++ binutils-2.26/ld/emultempl/spuelf.em 2016-02-19 09:35:54.916106583 +0000 -@@ -416,7 +416,7 @@ spu_elf_relink (void) - /* Final emulation specific call. */ - - static void --gld${EMULATION_NAME}_finish (void) -+spu_finish (void) - { - if (is_spu_target ()) - { -@@ -432,7 +432,7 @@ gld${EMULATION_NAME}_finish (void) - einfo ("%P: --auto-overlay ignored with zero local store range\n"); - } - -- finish_default (); -+ gld${EMULATION_NAME}_finish (); - } - - static char * -@@ -832,5 +832,5 @@ PARSE_AND_LIST_ARGS_CASES=' - - LDEMUL_AFTER_OPEN=spu_after_open - LDEMUL_BEFORE_ALLOCATION=spu_before_allocation --LDEMUL_FINISH=gld${EMULATION_NAME}_finish -+LDEMUL_FINISH=spu_finish - LDEMUL_CHOOSE_TARGET=gld${EMULATION_NAME}_choose_target -diff -rup binutils-2.26.orig/ld/ldexp.c binutils-2.26/ld/ldexp.c ---- binutils-2.26.orig/ld/ldexp.c 2016-02-19 09:35:36.701003291 +0000 -+++ binutils-2.26/ld/ldexp.c 2016-02-19 09:35:54.917106588 +0000 -@@ -1616,14 +1616,15 @@ align_n (bfd_vma value, bfd_vma align) - } - - void --ldexp_init (void) -+ldexp_init (bfd_boolean object_only) - { - /* The value "13" is ad-hoc, somewhat related to the expected number of - assignments in a linker script. */ -- if (!bfd_hash_table_init_n (&definedness_table, -- definedness_newfunc, -- sizeof (struct definedness_hash_entry), -- 13)) -+ if (!object_only -+ && !bfd_hash_table_init_n (&definedness_table, -+ definedness_newfunc, -+ sizeof (struct definedness_hash_entry), -+ 13)) - einfo (_("%P%F: can not create hash table: %E\n")); - } - -@@ -1658,7 +1659,8 @@ ldexp_finalize_syms (void) - } - - void --ldexp_finish (void) -+ldexp_finish (bfd_boolean object_only) - { -- bfd_hash_table_free (&definedness_table); -+ if (!object_only) -+ bfd_hash_table_free (&definedness_table); - } -diff -rup binutils-2.26.orig/ld/ldexp.h binutils-2.26/ld/ldexp.h ---- binutils-2.26.orig/ld/ldexp.h 2016-02-19 09:35:36.701003291 +0000 -+++ binutils-2.26/ld/ldexp.h 2016-02-19 09:35:54.917106588 +0000 -@@ -229,8 +229,8 @@ fill_type *exp_get_fill - (etree_type *, fill_type *, char *); - bfd_vma exp_get_abs_int - (etree_type *, int, char *); --void ldexp_init (void); -+void ldexp_init (bfd_boolean); - void ldexp_finalize_syms (void); --void ldexp_finish (void); -+void ldexp_finish (bfd_boolean); - - #endif -diff -rup binutils-2.26.orig/ld/ldfile.c binutils-2.26/ld/ldfile.c ---- binutils-2.26.orig/ld/ldfile.c 2016-02-19 09:35:36.701003291 +0000 -+++ binutils-2.26/ld/ldfile.c 2016-02-19 09:35:54.918106594 +0000 -@@ -313,7 +313,9 @@ success: - && !no_more_claiming - && bfd_check_format (entry->the_bfd, bfd_object)) - plugin_maybe_claim (entry); -+ else - #endif /* ENABLE_PLUGINS */ -+ cmdline_check_object_only_section (entry->the_bfd, FALSE); - - /* It opened OK, the format checked out, and the plugins have had - their chance to claim it, so this is success. */ -diff -rup binutils-2.26.orig/ld/ldlang.c binutils-2.26/ld/ldlang.c ---- binutils-2.26.orig/ld/ldlang.c 2016-02-19 09:35:36.701003291 +0000 -+++ binutils-2.26/ld/ldlang.c 2016-02-19 09:35:54.921106611 +0000 -@@ -36,6 +36,7 @@ - #include "ldctor.h" - #include "ldfile.h" - #include "ldemul.h" -+#include "ldwrite.h" - #include "fnmatch.h" - #include "demangle.h" - #include "hashtab.h" -@@ -45,6 +46,9 @@ - #include "plugin.h" - #endif /* ENABLE_PLUGINS */ - -+/* FIXME: Put it here to avoid NAME conflict from ldgram.h. */ -+#include "elf-bfd.h" -+ - #ifndef offsetof - #define offsetof(TYPE, MEMBER) ((size_t) & (((TYPE*) 0)->MEMBER)) - #endif -@@ -68,6 +72,9 @@ static lang_statement_list_type *stat_sa - static lang_statement_list_type **stat_save_ptr = &stat_save[0]; - static struct unique_sections *unique_section_list; - static struct asneeded_minfo *asneeded_list_head; -+static cmdline_list_type cmdline_object_only_file_list; -+static cmdline_list_type cmdline_object_only_archive_list; -+static cmdline_list_type cmdline_temp_object_only_list; - - /* Forward declarations. */ - static void exp_init_os (etree_type *); -@@ -86,6 +93,10 @@ static void lang_do_version_exports_sect - static void lang_finalize_version_expr_head - (struct bfd_elf_version_expr_head *); - static void lang_do_memory_regions (void); -+static void cmdline_lists_init (void); -+static void cmdline_get_object_only_input_files (void); -+static void print_cmdline_list (cmdline_union_type *); -+static bfd_boolean cmdline_on_object_only_archive_list_p (bfd *); - - /* Exported variables. */ - const char *output_target; -@@ -1219,14 +1230,17 @@ output_section_statement_table_free (voi - /* Build enough state so that the parser can build its tree. */ - - void --lang_init (void) -+lang_init (bfd_boolean object_only) - { -- obstack_begin (&stat_obstack, 1000); -+ if (!object_only) -+ obstack_begin (&stat_obstack, 1000); - - stat_ptr = &statement_list; - - output_section_statement_table_init (); - -+ cmdline_lists_init (); -+ - lang_list_init (stat_ptr); - - lang_list_init (&input_file_chain); -@@ -2843,6 +2857,12 @@ load_symbols (lang_input_statement_type - loaded = FALSE; - } - -+ if (link_info.emitting_gnu_object_only) -+ { -+ if (!cmdline_on_object_only_archive_list_p (member)) -+ continue; -+ } -+ - subsbfd = member; - if (!(*link_info.callbacks - ->add_archive_element) (&link_info, member, -@@ -6780,7 +6800,38 @@ lang_process (void) - open_input_bfds (statement_list.head, OPEN_BFD_RESCAN); - } - } -+ else - #endif /* ENABLE_PLUGINS */ -+ if (bfd_link_relocatable (&link_info)) -+ { -+ /* Check if .gnu_object_only section should be created. */ -+ bfd *p; -+ int object_type; -+ -+ object_type = 0; -+ for (p = link_info.input_bfds; p != (bfd *) NULL; p = p->link.next) -+ { -+ object_type |= 1 << p->lto_type; -+ if ((object_type & (1 << lto_mixed_object)) != 0 -+ || ((object_type -+ & (1 << lto_non_ir_object -+ | 1 << lto_ir_object)) -+ == (1 << lto_non_ir_object | 1 << lto_ir_object))) -+ { -+ link_info.emit_gnu_object_only = TRUE; -+ break; -+ } -+ } -+ -+ if (verbose -+ && (cmdline_object_only_file_list.head -+ || cmdline_object_only_archive_list.head)) -+ { -+ info_msg (_("Object-only input files:\n ")); -+ print_cmdline_list (cmdline_object_only_file_list.head); -+ print_cmdline_list (cmdline_object_only_archive_list.head); -+ } -+ } - - link_info.gc_sym_list = &entry_symbol; - if (entry_symbol.name == NULL) -@@ -8275,3 +8326,965 @@ lang_print_memory_usage (void) - printf (" %6.2f%%\n", percent); - } - } -+ -+static void -+cmdline_lists_init (void) -+{ -+ cmdline_object_only_file_list.tail -+ = &cmdline_object_only_file_list.head; -+ cmdline_object_only_archive_list.tail -+ = &cmdline_object_only_archive_list.head; -+ cmdline_temp_object_only_list.tail -+ = &cmdline_temp_object_only_list.head; -+} -+ -+/* Allocate an item with TYPE and DATA. */ -+ -+static cmdline_union_type * -+cmdline_list_new (cmdline_enum_type type, void *data) -+{ -+ cmdline_union_type *new_opt; -+ -+ new_opt = (cmdline_union_type *) stat_alloc (sizeof (*new_opt)); -+ new_opt->header.type = type; -+ switch (type) -+ { -+ default: -+ break; -+ case cmdline_is_file_enum: -+ new_opt->file.filename = (const char *) data; -+ break; -+ case cmdline_is_bfd_enum: -+ new_opt->abfd.abfd = (bfd *) data; -+ break; -+ } -+ return new_opt; -+} -+ -+/* Append an item with TYPE and DATA to LIST. */ -+ -+static void -+cmdline_list_append (cmdline_list_type *list, cmdline_enum_type type, -+ void *data) -+{ -+ cmdline_union_type *new_opt = cmdline_list_new (type, data); -+ new_opt->header.next = NULL; -+ *list->tail = new_opt; -+ list->tail = &new_opt->header.next; -+} -+ -+static void -+print_cmdline_list (cmdline_union_type *c) -+{ -+ for (; c != NULL; c = c->header.next) -+ switch (c->header.type) -+ { -+ default: -+ abort (); -+ case cmdline_is_file_enum: -+ info_msg (" %s", c->file.filename); -+ break; -+ case cmdline_is_bfd_enum: -+ info_msg (" [%B]", c->abfd.abfd); -+ break; -+ } -+ -+ info_msg ("\n"); -+} -+ -+/* Return TRUE if ABFD is on cmdline_object_only_archive_list. */ -+ -+static bfd_boolean -+cmdline_on_object_only_archive_list_p (bfd *abfd) -+{ -+ cmdline_union_type *c, *next; -+ bfd *archive, *obfd, *oarchive; -+ ufile_ptr origin = abfd->origin; -+ -+ archive = bfd_my_archive (abfd); -+ for (c = cmdline_object_only_archive_list.head; c != NULL; c = next) -+ { -+ if (c->header.type != cmdline_is_bfd_enum) -+ abort (); -+ -+ next = c->header.next; -+ obfd = c->abfd.abfd; -+ oarchive = bfd_my_archive (obfd); -+ -+ /* The list is grouped by archive file name and sorted by member -+ origin. */ -+ if (strcmp (archive->filename, oarchive->filename) != 0) -+ continue; -+ -+ if (origin == obfd->origin) -+ return TRUE; -+ else if (origin < obfd->origin) -+ return FALSE; -+ } -+ -+ return FALSE; -+} -+ -+/* Append an item with TYPE and DATA to cmdline_object_only_file_list -+ or cmdline_object_only_archive_list if needed. */ -+ -+static void -+cmdline_object_only_list_append (cmdline_enum_type type, void *data) -+{ -+ cmdline_union_type *c; -+ cmdline_union_type *new_opt, *next, **prev; -+ bfd *abfd, *archive; -+ bfd *obfd, *oarchive; -+ bfd *nbfd, *narchive; -+ ufile_ptr origin, norigin; -+ -+ /* Put it on cmdline_object_only_file_list if it isn't an archive -+ member. */ -+ switch (type) -+ { -+ default: -+ abort (); -+ case cmdline_is_bfd_enum: -+ abfd = (bfd *) data; -+ archive = bfd_my_archive (abfd); -+ if (archive) -+ break; -+ case cmdline_is_file_enum: -+ cmdline_list_append (&cmdline_object_only_file_list, type, data); -+ return; -+ } -+ -+ /* Put archive member on cmdline_object_only_archive_list and sort -+ the list by archive name and archive member origin. */ -+ new_opt = (cmdline_union_type *) stat_alloc (sizeof (*new_opt)); -+ new_opt->header.type = cmdline_is_bfd_enum; -+ new_opt->header.next = NULL; -+ new_opt->abfd.abfd = (bfd *) data; -+ -+ c = cmdline_object_only_archive_list.head; -+ if (c == NULL) -+ { -+ cmdline_object_only_archive_list.head = new_opt; -+ cmdline_object_only_archive_list.tail = &new_opt->header.next; -+ return; -+ } -+ -+ prev = NULL; -+ origin = abfd->origin; -+ for (; c != NULL; c = next) -+ { -+ if (c->header.type != cmdline_is_bfd_enum) -+ abort (); -+ -+ next = c->header.next; -+ -+ obfd = c->abfd.abfd; -+ oarchive = bfd_my_archive (obfd); -+ -+ if (strcmp (archive->filename, oarchive->filename) == 0) -+ { -+ bfd_boolean after; -+ -+ if (origin < obfd->origin) -+ { -+ /* Insert it before the current. */ -+ new_opt->header.next = c; -+ if (prev) -+ *prev = new_opt; -+ else -+ cmdline_object_only_archive_list.head = new_opt; -+ return; -+ } -+ -+ after = TRUE; -+ -+ /* Check origin. */ -+ while (next) -+ { -+ if (next->header.type != cmdline_is_bfd_enum) -+ abort (); -+ -+ nbfd = next->abfd.abfd; -+ norigin = nbfd->origin; -+ if (origin > norigin) -+ { -+ /* Insert it after NEXT. */ -+ break; -+ } -+ -+ narchive = bfd_my_archive (nbfd); -+ if (strcmp (archive->filename, narchive->filename) != 0) -+ { -+ /* Insert it befor NEXT. */ -+ after = FALSE; -+ break; -+ } -+ -+ c = next; -+ next = next->header.next; -+ } -+ -+ if (after && next) -+ { -+ c = next; -+ next = next->header.next; -+ } -+ -+ if (*cmdline_object_only_archive_list.tail == c->header.next) -+ cmdline_object_only_archive_list.tail -+ = &new_opt->header.next; -+ -+ prev = &c->header.next; -+ new_opt->header.next = next; -+ *prev = new_opt; -+ return; -+ } -+ -+ prev = &c->header.next; -+ } -+ -+ *cmdline_object_only_archive_list.tail = new_opt; -+ cmdline_object_only_archive_list.tail = &new_opt->header.next; -+} -+ -+/* Get object-only input files. */ -+ -+static void -+cmdline_get_object_only_input_files (void) -+{ -+ cmdline_union_type *c, *next; -+ bfd *abfd, *archive; -+ bfd *nbfd, *narchive; -+ -+ /* Add files first. */ -+ for (c = cmdline_object_only_file_list.head; -+ c != NULL; c = c->header.next) -+ switch (c->header.type) -+ { -+ default: -+ abort (); -+ case cmdline_is_file_enum: -+ lang_add_input_file (c->file.filename, -+ lang_input_file_is_file_enum, NULL); -+ break; -+ case cmdline_is_bfd_enum: -+ abfd = c->abfd.abfd; -+ if (bfd_my_archive (abfd)) -+ abort (); -+ lang_add_input_file (abfd->filename, -+ lang_input_file_is_file_enum, NULL); -+ break; -+ } -+ -+ /* Add archive members next. */ -+ for (c = cmdline_object_only_archive_list.head; c != NULL; c = next) -+ { -+ if (c->header.type != cmdline_is_bfd_enum) -+ abort (); -+ -+ next = c->header.next; -+ -+ abfd = c->abfd.abfd; -+ archive = bfd_my_archive (abfd); -+ -+ /* Add the first archive of the archive member group. */ -+ lang_add_input_file (archive->filename, -+ lang_input_file_is_file_enum, NULL); -+ -+ /* Skip the rest members in the archive member group. */ -+ do -+ { -+ if (!next) -+ break; -+ -+ if (next->header.type != cmdline_is_bfd_enum) -+ abort (); -+ -+ next = next->header.next; -+ if (!next) -+ break; -+ nbfd = next->abfd.abfd; -+ narchive = bfd_my_archive (nbfd); -+ } -+ while (strcmp (archive->filename, narchive->filename) == 0); -+ } -+} -+ -+struct cmdline_arg -+{ -+ bfd *obfd; -+ asymbol **isympp; -+ int status; -+}; -+ -+/* Create a section in OBFD with the same -+ name and attributes as ISECTION in IBFD. */ -+ -+static void -+setup_section (bfd *ibfd, sec_ptr isection, void *p) -+{ -+ struct cmdline_arg *arg = (struct cmdline_arg *) p; -+ bfd *obfd = arg->obfd; -+ asymbol **isympp = arg->isympp; -+ const char *name = isection->name; -+ sec_ptr osection; -+ const char *err; -+ -+ /* Skip the object-only section. */ -+ if (ibfd->object_only_section == isection) -+ return; -+ -+ /* If we have already failed earlier on, do not keep on generating -+ complaints now. */ -+ if (arg->status) -+ return; -+ -+ osection = bfd_make_section_anyway_with_flags (obfd, name, -+ isection->flags); -+ -+ if (osection == NULL) -+ { -+ err = _("failed to create output section"); -+ goto loser; -+ } -+ -+ osection->size = isection->size; -+ osection->vma = isection->vma; -+ osection->lma = isection->lma; -+ osection->alignment_power = isection->alignment_power; -+ -+ /* Copy merge entity size. */ -+ osection->entsize = isection->entsize; -+ -+ /* This used to be mangle_section; we do here to avoid using -+ bfd_get_section_by_name since some formats allow multiple -+ sections with the same name. */ -+ isection->output_section = osection; -+ isection->output_offset = 0; -+ -+ if ((isection->flags & SEC_GROUP) != 0) -+ { -+ asymbol *gsym = bfd_group_signature (isection, isympp); -+ -+ if (gsym != NULL) -+ { -+ gsym->flags |= BSF_KEEP; -+ if (ibfd->xvec->flavour == bfd_target_elf_flavour) -+ elf_group_id (isection) = gsym; -+ } -+ } -+ -+ /* Allow the BFD backend to copy any private data it understands -+ from the input section to the output section. */ -+ if (!bfd_copy_private_section_data (ibfd, isection, obfd, osection)) -+ { -+ err = _("failed to copy private data"); -+ goto loser; -+ } -+ -+ /* All went well. */ -+ return; -+ -+loser: -+ arg->status = 1; -+ einfo (_("%P%F: setup_section: %s: %s\n"), err, name); -+} -+ -+/* Copy the data of input section ISECTION of IBFD -+ to an output section with the same name in OBFD. -+ If stripping then don't copy any relocation info. */ -+ -+static void -+copy_section (bfd *ibfd, sec_ptr isection, void *p) -+{ -+ struct cmdline_arg *arg = (struct cmdline_arg *) p; -+ bfd *obfd = arg->obfd; -+ asymbol **isympp = arg->isympp; -+ arelent **relpp; -+ long relcount; -+ sec_ptr osection; -+ bfd_size_type size; -+ long relsize; -+ flagword flags; -+ const char *err; -+ -+ /* Skip the object-only section. */ -+ if (ibfd->object_only_section == isection) -+ return; -+ -+ /* If we have already failed earlier on, do not keep on generating -+ complaints now. */ -+ if (arg->status) -+ return; -+ -+ flags = bfd_get_section_flags (ibfd, isection); -+ if ((flags & SEC_GROUP) != 0) -+ return; -+ -+ osection = isection->output_section; -+ size = bfd_get_section_size (isection); -+ -+ if (size == 0 || osection == 0) -+ return; -+ -+ relsize = bfd_get_reloc_upper_bound (ibfd, isection); -+ -+ if (relsize < 0) -+ { -+ /* Do not complain if the target does not support relocations. */ -+ if (relsize == -1 -+ && bfd_get_error () == bfd_error_invalid_operation) -+ relsize = 0; -+ else -+ { -+ err = bfd_errmsg (bfd_get_error ()); -+ goto loser; -+ } -+ } -+ -+ if (relsize == 0) -+ bfd_set_reloc (obfd, osection, NULL, 0); -+ else -+ { -+ relpp = (arelent **) xmalloc (relsize); -+ relcount = bfd_canonicalize_reloc (ibfd, isection, relpp, isympp); -+ if (relcount < 0) -+ { -+ err = _("relocation count is negative"); -+ goto loser; -+ } -+ -+ bfd_set_reloc (obfd, osection, -+ relcount == 0 ? NULL : relpp, relcount); -+ if (relcount == 0) -+ free (relpp); -+ } -+ -+ if (bfd_get_section_flags (ibfd, isection) & SEC_HAS_CONTENTS) -+ { -+ bfd_byte *memhunk = NULL; -+ -+ if (!bfd_get_full_section_contents (ibfd, isection, &memhunk)) -+ { -+ err = bfd_errmsg (bfd_get_error ()); -+ goto loser; -+ } -+ -+ if (!bfd_set_section_contents (obfd, osection, memhunk, 0, size)) -+ { -+ err = bfd_errmsg (bfd_get_error ()); -+ goto loser; -+ } -+ free (memhunk); -+ } -+ -+ /* All went well. */ -+ return; -+ -+loser: -+ einfo (_("%P%F: copy_section: %s: %s\n"), err, isection->name); -+} -+/* Open the temporary bfd created in the same directory as PATH. */ -+ -+static bfd * -+cmdline_fopen_temp (const char *path, const char *target, -+ const char *mode) -+{ -+#define template "ldXXXXXX" -+ const char *slash = strrchr (path, '/'); -+ char *tmpname; -+ size_t len; -+ int fd; -+ -+#ifdef HAVE_DOS_BASED_FILE_SYSTEM -+ { -+ /* We could have foo/bar\\baz, or foo\\bar, or d:bar. */ -+ char *bslash = strrchr (path, '\\'); -+ -+ if (slash == NULL || (bslash != NULL && bslash > slash)) -+ slash = bslash; -+ if (slash == NULL && path[0] != '\0' && path[1] == ':') -+ slash = path + 1; -+ } -+#endif -+ -+ if (slash != (char *) NULL) -+ { -+ len = slash - path; -+ tmpname = (char *) xmalloc (len + sizeof (template) + 2); -+ memcpy (tmpname, path, len); -+ -+#ifdef HAVE_DOS_BASED_FILE_SYSTEM -+ /* If tmpname is "X:", appending a slash will make it a root -+ directory on drive X, which is NOT the same as the current -+ directory on drive X. */ -+ if (len == 2 && tmpname[1] == ':') -+ tmpname[len++] = '.'; -+#endif -+ tmpname[len++] = '/'; -+ } -+ else -+ { -+ tmpname = (char *) xmalloc (sizeof (template)); -+ len = 0; -+ } -+ -+ memcpy (tmpname + len, template, sizeof (template)); -+#undef template -+ -+#ifdef HAVE_MKSTEMP -+ fd = mkstemp (tmpname); -+#else -+ tmpname = mktemp (tmpname); -+ if (tmpname == NULL) -+ return NULL; -+ fd = open (tmpname, O_RDWR | O_CREAT | O_EXCL, 0600); -+#endif -+ if (fd == -1) -+ return NULL; -+ return bfd_fopen (tmpname, target, mode, fd); -+} -+ -+/* Add the object-only section. */ -+ -+static void -+cmdline_add_object_only_section (bfd_byte *contents, size_t size) -+{ -+ bfd_vma start; -+ flagword flags; -+ enum bfd_architecture iarch; -+ unsigned int imach; -+ long symcount; -+ long symsize; -+ asymbol **isympp = NULL; -+ asymbol **osympp = NULL; -+ bfd *obfd = NULL, *ibfd; -+ const char *err; -+ struct arg -+ { -+ bfd *obfd; -+ asymbol **isympp; -+ int status; -+ } arg; -+ char **matching; -+ char *ofilename = NULL; -+ asection *sec; -+ -+ ibfd = bfd_openr (output_filename, output_target); -+ if (!ibfd) -+ { -+ err = bfd_errmsg (bfd_get_error ()); -+ goto loser; -+ } -+ -+ if (!bfd_check_format_matches (ibfd, bfd_object, &matching)) -+ { -+ err = bfd_errmsg (bfd_get_error ()); -+ goto loser; -+ } -+ -+ obfd = cmdline_fopen_temp (output_filename, output_target, "w"); -+ if (!obfd) -+ { -+ err = bfd_errmsg (bfd_get_error ()); -+ goto loser; -+ } -+ /* To be used after bfd_close (). */ -+ ofilename = xstrdup (bfd_get_filename (obfd)); -+ -+ if (!bfd_set_format (obfd, bfd_object)) -+ { -+ err = bfd_errmsg (bfd_get_error ()); -+ goto loser; -+ } -+ -+ /* Copy the start address, flags and architecture of input file to -+ output file. */ -+ flags = bfd_get_file_flags (ibfd); -+ start = bfd_get_start_address (ibfd); -+ iarch = bfd_get_arch (ibfd); -+ imach = bfd_get_mach (ibfd); -+ if (!bfd_set_start_address (obfd, start) -+ || !bfd_set_file_flags (obfd, flags) -+ || !bfd_set_arch_mach (obfd, iarch, imach)) -+ { -+ err = bfd_errmsg (bfd_get_error ()); -+ goto loser; -+ } -+ -+ symsize = bfd_get_symtab_upper_bound (ibfd); -+ if (symsize < 0) -+ { -+ err = bfd_errmsg (bfd_get_error ()); -+ goto loser; -+ } -+ -+ isympp = (asymbol **) xmalloc (symsize); -+ symcount = bfd_canonicalize_symtab (ibfd, isympp); -+ if (symcount < 0) -+ { -+ err = bfd_errmsg (bfd_get_error ()); -+ goto loser; -+ } -+ -+ arg.obfd = obfd; -+ arg.isympp = isympp; -+ arg.status = 0; -+ -+ /* BFD mandates that all output sections be created and sizes set before -+ any output is done. Thus, we traverse all sections multiple times. */ -+ bfd_map_over_sections (ibfd, setup_section, &arg); -+ -+ if (arg.status) -+ { -+ err = _("error setting up sections"); -+ goto loser; -+ } -+ -+ /* Allow the BFD backend to copy any private data it understands -+ from the input section to the output section. */ -+ if (! bfd_copy_private_header_data (ibfd, obfd)) -+ { -+ err = _("error copying private header data"); -+ goto loser; -+ } -+ -+ /* Create the object-only section. */ -+ sec = bfd_make_section_with_flags (obfd, -+ GNU_OBJECT_ONLY_SECTION_NAME, -+ (SEC_HAS_CONTENTS -+ | SEC_READONLY -+ | SEC_DATA -+ | SEC_LINKER_CREATED)); -+ if (sec == NULL) -+ { -+ err = _("can't create object-only section"); -+ goto loser; -+ } -+ -+ if (! bfd_set_section_size (obfd, sec, size)) -+ { -+ err = _("can't set object-only section size"); -+ goto loser; -+ } -+ -+ if (ibfd->object_only_section) -+ { -+ /* Filter out the object-only section symbol. */ -+ long src_count = 0, dst_count = 0; -+ asymbol **from, **to; -+ -+ osympp = (asymbol **) xmalloc (symcount * sizeof (asymbol *)); -+ from = isympp; -+ to = osympp; -+ for (; src_count < symcount; src_count++) -+ { -+ asymbol *sym = from[src_count]; -+ if (bfd_get_section (sym) != ibfd->object_only_section) -+ to[dst_count++] = sym; -+ } -+ to[dst_count] = NULL; -+ symcount = dst_count; -+ bfd_set_symtab (obfd, osympp, symcount); -+ } -+ else -+ bfd_set_symtab (obfd, isympp, symcount); -+ -+ /* This has to happen after the symbol table has been set. */ -+ bfd_map_over_sections (ibfd, copy_section, &arg); -+ -+ if (arg.status) -+ { -+ err = _("error copying sections"); -+ goto loser; -+ } -+ -+ /* Copy the object-only section to the output. */ -+ if (! bfd_set_section_contents (obfd, sec, contents, 0, size)) -+ { -+ err = _("error adding object-only section"); -+ goto loser; -+ } -+ -+ /* Allow the BFD backend to copy any private data it understands -+ from the input BFD to the output BFD. This is done last to -+ permit the routine to look at the filtered symbol table, which is -+ important for the ECOFF code at least. */ -+ if (! bfd_copy_private_bfd_data (ibfd, obfd)) -+ { -+ err = _("error copying private BFD data"); -+ goto loser; -+ } -+ -+ if (!bfd_close (obfd)) -+ { -+ unlink (ofilename); -+ einfo (_("%P%F: failed to finish output with object-only section\n")); -+ } -+ -+ /* Must be freed after bfd_close (). */ -+ free (isympp); -+ if (osympp) -+ free (osympp); -+ -+ if (rename (ofilename, output_filename)) -+ { -+ unlink (ofilename); -+ einfo (_("%P%F: failed to rename output with object-only section\n")); -+ } -+ -+ free (ofilename); -+ return; -+ -+loser: -+ if (isympp) -+ free (isympp); -+ if (osympp) -+ free (osympp); -+ if (obfd) -+ bfd_close (obfd); -+ if (ofilename) -+ unlink (ofilename); -+ einfo (_("%P%F: failed to add object-only section: %s\n"), err); -+} -+ -+/* Emit the final output with object-only section. */ -+ -+void -+cmdline_emit_object_only_section (void) -+{ -+ const char *saved_output_filename = output_filename; -+ int fd; -+ size_t size, off; -+ bfd_byte *contents; -+ struct stat st; -+ -+ /* Get a temporary object-only file. */ -+ output_filename = make_temp_file (".obj-only.o"); -+ -+ had_output_filename = FALSE; -+ link_info.input_bfds = NULL; -+ link_info.input_bfds_tail = &link_info.input_bfds; -+ -+ lang_init (TRUE); -+ ldexp_init (TRUE); -+ -+ ld_parse_linker_script (); -+ -+ /* Set up the object-only output. */ -+ lang_final (); -+ -+ /* Open the object-only file for output. */ -+ lang_for_each_statement (ldlang_open_output); -+ -+ ldemul_create_output_section_statements (); -+ -+ if (!bfd_section_already_linked_table_init ()) -+ einfo (_("%P%F: Failed to create hash table\n")); -+ -+ /* Call cmdline_on_object_only_archive_list_p to check which member -+ should be loaded. */ -+ input_flags.whole_archive = TRUE; -+ -+ /* Set it to avoid adding more to cmdline lists. */ -+ link_info.emitting_gnu_object_only = TRUE; -+ -+ /* Get object-only input files. */ -+ cmdline_get_object_only_input_files (); -+ -+ /* Open object-only input files. */ -+ open_input_bfds (statement_list.head, FALSE); -+ -+ ldemul_after_open (); -+ -+ bfd_section_already_linked_table_free (); -+ -+ /* Make sure that we're not mixing architectures. We call this -+ after all the input files have been opened, but before we do any -+ other processing, so that any operations merge_private_bfd_data -+ does on the output file will be known during the rest of the -+ link. */ -+ lang_check (); -+ -+ /* Size up the common data. */ -+ lang_common (); -+ -+ /* Update wild statements. */ -+ update_wild_statements (statement_list.head); -+ -+ /* Run through the contours of the script and attach input sections -+ to the correct output sections. */ -+ map_input_to_output_sections (statement_list.head, NULL, NULL); -+ -+ /* Find any sections not attached explicitly and handle them. */ -+ lang_place_orphans (); -+ -+ /* Do anything special before sizing sections. This is where ELF -+ and other back-ends size dynamic sections. */ -+ ldemul_before_allocation (); -+ -+ /* Size up the sections. */ -+ lang_size_sections (NULL, ! RELAXATION_ENABLED); -+ -+ /* See if anything special should be done now we know how big -+ everything is. This is where relaxation is done. */ -+ ldemul_after_allocation (); -+ -+ ldemul_finish (); -+ -+ /* Make sure that the section addresses make sense. */ -+ if (command_line.check_section_addresses) -+ lang_check_section_addresses (); -+ -+ lang_end (); -+ -+ ldwrite (); -+ -+ ldexp_finish (TRUE); -+ lang_finish (); -+ -+ if (! bfd_close (link_info.output_bfd)) -+ einfo (_("%P%F:%s: final close failed on object-only output: %E\n"), -+ output_filename); -+ -+ /* Read in the object-only file. */ -+ fd = open (output_filename, O_RDONLY | O_BINARY); -+ if (fd < 0) -+ { -+ bfd_set_error (bfd_error_system_call); -+ einfo (_("%P%F:%s: cannot open object-only output: %E"), -+ output_filename); -+ } -+ -+ /* Get the object-only file size. */ -+ if (fstat (fd, &st) != 0) -+ { -+ bfd_set_error (bfd_error_system_call); -+ einfo (_("%P%F:%s: cannot stat object-only output: %E"), -+ output_filename); -+ } -+ -+ size = st.st_size; -+ off = 0; -+ contents = (bfd_byte *) xmalloc (size); -+ while (off != size) -+ { -+ ssize_t got; -+ -+ got = read (fd, contents + off, size - off); -+ if (got < 0) -+ { -+ bfd_set_error (bfd_error_system_call); -+ einfo (_("%P%F:%s: read failed on object-only output: %E"), -+ output_filename); -+ } -+ -+ off += got; -+ } -+ -+ close (fd); -+ -+ /* Remove the temporary object-only file. */ -+ unlink (output_filename); -+ -+ output_filename = saved_output_filename; -+ -+ cmdline_add_object_only_section (contents, size); -+ -+ free (contents); -+} -+ -+/* Extract the object-only section. */ -+ -+static const char * -+cmdline_extract_object_only_section (bfd *abfd) -+{ -+ const char *name = bfd_extract_object_only_section (abfd); -+ -+ if (name == NULL) -+ einfo (_("%P%F: cannot extract object-only section from %B: %E"), -+ abfd); -+ -+ /* It should be removed after it is done. */ -+ cmdline_list_append (&cmdline_temp_object_only_list, -+ cmdline_is_file_enum, (void *) name); -+ -+ return name; -+} -+ -+/* Check and handle the object-only section. */ -+ -+void -+cmdline_check_object_only_section (bfd *abfd, bfd_boolean lto) -+{ -+ const char *filename; -+ -+ if (link_info.emitting_gnu_object_only -+ || abfd->format != bfd_object) -+ return; -+ -+ if (lto) -+ { -+ /* For LTO link, we only need to extract object-only section -+ from the mixed object, add it to input, and put it on LTO -+ claimed output. */ -+ switch (abfd->lto_type) -+ { -+ default: -+ abort (); -+ case lto_mixed_object: -+ filename = cmdline_extract_object_only_section (abfd); -+ lang_add_input_file (filename, -+ lang_input_file_is_file_enum, NULL); -+ break; -+ case lto_non_ir_object: -+ case lto_ir_object: -+ break; -+ } -+ } -+ else if (bfd_link_relocatable (&link_info)) -+ { -+ /* For non-LTO relocatable link, we need to append non-IR object -+ file and the object file in object-only section to the object -+ only list. */ -+ switch (abfd->lto_type) -+ { -+ default: -+ abort (); -+ case lto_mixed_object: -+ filename = cmdline_extract_object_only_section (abfd); -+ cmdline_object_only_list_append (cmdline_is_file_enum, -+ (void *) filename); -+ break; -+ case lto_non_ir_object: -+ cmdline_object_only_list_append (cmdline_is_bfd_enum, abfd); -+ break; -+ case lto_ir_object: -+ break; -+ } -+ } -+} -+ -+/* Remove temporary object-only files. */ -+ -+void -+cmdline_remove_object_only_files (void) -+{ -+ cmdline_union_type *c; -+ -+#ifdef ENABLE_PLUGINS -+ if (plugin_save_temps) -+ return; -+#endif -+ -+ c = cmdline_temp_object_only_list.head; -+ for (; c != NULL; c = c->header.next) -+ switch (c->header.type) -+ { -+ default: -+ abort (); -+ case cmdline_is_file_enum: -+ unlink (c->file.filename); -+ break; -+ } -+} -diff -rup binutils-2.26.orig/ld/ldlang.h binutils-2.26/ld/ldlang.h ---- binutils-2.26.orig/ld/ldlang.h 2016-02-19 09:35:36.701003291 +0000 -+++ binutils-2.26/ld/ldlang.h 2016-02-19 09:35:54.921106611 +0000 -@@ -517,7 +517,7 @@ extern struct asneeded_minfo **asneeded_ - extern void (*output_bfd_hash_table_free_fn) (struct bfd_link_hash_table *); - - extern void lang_init -- (void); -+ (bfd_boolean); - extern void lang_finish - (void); - extern lang_memory_region_type * lang_memory_region_lookup -@@ -693,4 +693,45 @@ lang_ld_feature (char *); - extern void - lang_print_memory_usage (void); - -+typedef enum -+{ -+ cmdline_is_file_enum, -+ cmdline_is_bfd_enum -+} cmdline_enum_type; -+ -+typedef struct cmdline_header_struct -+{ -+ union cmdline_union *next; -+ cmdline_enum_type type; -+} cmdline_header_type; -+ -+typedef struct cmdline_file_struct -+{ -+ cmdline_header_type header; -+ const char *filename; -+} cmdline_file_type; -+ -+typedef struct cmdline_bfd_struct -+{ -+ cmdline_header_type header; -+ bfd *abfd; -+} cmdline_bfd_type; -+ -+typedef union cmdline_union -+{ -+ cmdline_header_type header; -+ cmdline_file_type file; -+ cmdline_bfd_type abfd; -+} cmdline_union_type; -+ -+typedef struct cmdline_list -+{ -+ cmdline_union_type *head; -+ cmdline_union_type **tail; -+} cmdline_list_type; -+ -+extern void cmdline_emit_object_only_section (void); -+extern void cmdline_check_object_only_section (bfd *, bfd_boolean); -+extern void cmdline_remove_object_only_files (void); -+ - #endif -diff -rup binutils-2.26.orig/ld/ldlex.h binutils-2.26/ld/ldlex.h ---- binutils-2.26.orig/ld/ldlex.h 2016-02-19 09:35:36.701003291 +0000 -+++ binutils-2.26/ld/ldlex.h 2016-02-19 09:35:54.921106611 +0000 -@@ -134,6 +134,7 @@ enum option_values - #ifdef ENABLE_PLUGINS - OPTION_PLUGIN, - OPTION_PLUGIN_OPT, -+ OPTION_PLUGIN_SAVE_TEMPS, - #endif /* ENABLE_PLUGINS */ - OPTION_DEFAULT_SCRIPT, - OPTION_PRINT_OUTPUT_FORMAT, -diff -rup binutils-2.26.orig/ld/ldmain.c binutils-2.26/ld/ldmain.c ---- binutils-2.26.orig/ld/ldmain.c 2016-02-19 09:35:36.701003291 +0000 -+++ binutils-2.26/ld/ldmain.c 2016-02-19 09:35:54.922106617 +0000 -@@ -219,6 +219,9 @@ main (int argc, char **argv) - - xatexit (ld_cleanup); - -+ /* Remove temporary object-only files. */ -+ xatexit (cmdline_remove_object_only_files); -+ - /* Set up the sysroot directory. */ - ld_sysroot = get_sysroot (argc, argv); - if (*ld_sysroot) -@@ -291,8 +294,8 @@ main (int argc, char **argv) - default_target = ldemul_choose_target (argc, argv); - config.maxpagesize = bfd_emul_get_maxpagesize (default_target); - config.commonpagesize = bfd_emul_get_commonpagesize (default_target); -- lang_init (); -- ldexp_init (); -+ lang_init (FALSE); -+ ldexp_init (FALSE); - ldemul_before_parse (); - lang_has_input_file = FALSE; - parse_args (argc, argv); -@@ -307,34 +310,7 @@ main (int argc, char **argv) - - ldemul_set_symbols (); - -- /* If we have not already opened and parsed a linker script, -- try the default script from command line first. */ -- if (saved_script_handle == NULL -- && command_line.default_script != NULL) -- { -- ldfile_open_command_file (command_line.default_script); -- parser_input = input_script; -- yyparse (); -- } -- -- /* If we have not already opened and parsed a linker script -- read the emulation's appropriate default script. */ -- if (saved_script_handle == NULL) -- { -- int isfile; -- char *s = ldemul_get_script (&isfile); -- -- if (isfile) -- ldfile_open_default_command_file (s); -- else -- { -- lex_string = s; -- lex_redirect (s, _("built in linker script"), 1); -- } -- parser_input = input_script; -- yyparse (); -- lex_string = NULL; -- } -+ ld_parse_linker_script (); - - if (verbose) - { -@@ -445,7 +421,7 @@ main (int argc, char **argv) - fprintf (stderr, "lookup = %p val %lx\n", h, h ? h->u.def.value : 1); - } - #endif -- ldexp_finish (); -+ ldexp_finish (FALSE); - lang_finish (); - - /* Even if we're producing relocatable output, some non-fatal errors should -@@ -465,6 +441,8 @@ main (int argc, char **argv) - if (! bfd_close (link_info.output_bfd)) - einfo (_("%F%B: final close failed: %E\n"), link_info.output_bfd); - -+ link_info.output_bfd = NULL; -+ - /* If the --force-exe-suffix is enabled, and we're making an - executable file and it doesn't end in .exe, copy it to one - which does. */ -@@ -512,6 +490,9 @@ main (int argc, char **argv) - } - } - -+ if (link_info.emit_gnu_object_only) -+ cmdline_emit_object_only_section (); -+ - END_PROGRESS (program_name); - - if (config.stats) -@@ -805,7 +786,9 @@ add_archive_element (struct bfd_link_inf - *subsbfd = input->the_bfd; - } - } -+ else - #endif /* ENABLE_PLUGINS */ -+ cmdline_check_object_only_section (input->the_bfd, FALSE); - - ldlang_add_file (input); - -@@ -1484,3 +1467,38 @@ notice (struct bfd_link_info *info, - - return TRUE; - } -+ -+/* Parse the linker script. */ -+ -+void -+ld_parse_linker_script () -+{ -+ /* If we have not already opened and parsed a linker script, -+ try the default script from command line first. */ -+ if (saved_script_handle == NULL -+ && command_line.default_script != NULL) -+ { -+ ldfile_open_command_file (command_line.default_script); -+ parser_input = input_script; -+ yyparse (); -+ } -+ -+ /* If we have not already opened and parsed a linker script -+ read the emulation's appropriate default script. */ -+ if (saved_script_handle == NULL) -+ { -+ int isfile; -+ char *s = ldemul_get_script (&isfile); -+ -+ if (isfile) -+ ldfile_open_default_command_file (s); -+ else -+ { -+ lex_string = s; -+ lex_redirect (s, _("built in linker script"), 1); -+ } -+ parser_input = input_script; -+ yyparse (); -+ lex_string = NULL; -+ } -+} -diff -rup binutils-2.26.orig/ld/ldmain.h binutils-2.26/ld/ldmain.h ---- binutils-2.26.orig/ld/ldmain.h 2016-02-19 09:35:36.701003291 +0000 -+++ binutils-2.26/ld/ldmain.h 2016-02-19 09:35:54.922106617 +0000 -@@ -59,4 +59,6 @@ extern void add_wrap (const char *); - extern void add_ignoresym (struct bfd_link_info *, const char *); - extern void add_keepsyms_file (const char *); - -+extern void ld_parse_linker_script (void); -+ - #endif -diff -rup binutils-2.26.orig/ld/lexsup.c binutils-2.26/ld/lexsup.c ---- binutils-2.26.orig/ld/lexsup.c 2016-02-19 09:35:36.700003285 +0000 -+++ binutils-2.26/ld/lexsup.c 2016-02-19 09:35:54.923106623 +0000 -@@ -169,6 +169,9 @@ static const struct ld_option ld_options - '\0', N_("PLUGIN"), N_("Load named plugin"), ONE_DASH }, - { {"plugin-opt", required_argument, NULL, OPTION_PLUGIN_OPT}, - '\0', N_("ARG"), N_("Send arg to last-loaded plugin"), ONE_DASH }, -+ { {"plugin-save-temps", no_argument, NULL, OPTION_PLUGIN_SAVE_TEMPS}, -+ '\0', NULL, N_("Store plugin intermediate files permanently"), -+ ONE_DASH }, - { {"flto", optional_argument, NULL, OPTION_IGNORE}, - '\0', NULL, N_("Ignored for GCC LTO option compatibility"), - ONE_DASH }, -@@ -1020,6 +1023,9 @@ parse_args (unsigned argc, char **argv) - if (plugin_opt_plugin_arg (optarg)) - einfo (_("%P%F: bad -plugin-opt option\n")); - break; -+ case OPTION_PLUGIN_SAVE_TEMPS: -+ plugin_save_temps = TRUE; -+ break; - #endif /* ENABLE_PLUGINS */ - case 'q': - link_info.emitrelocations = TRUE; -diff -rup binutils-2.26.orig/ld/plugin.c binutils-2.26/ld/plugin.c ---- binutils-2.26.orig/ld/plugin.c 2016-02-19 09:35:36.702003296 +0000 -+++ binutils-2.26/ld/plugin.c 2016-02-19 09:35:54.923106623 +0000 -@@ -57,6 +57,9 @@ extern int errno; - /* Report plugin symbols. */ - bfd_boolean report_plugin_symbols; - -+/* Store plugin intermediate files permanently. */ -+bfd_boolean plugin_save_temps; -+ - /* The suffix to append to the name of the real (claimed) object file - when generating a dummy BFD to hold the IR symbols sent from the - plugin. For cosmetic use only; appears in maps, crefs etc. */ -@@ -1182,6 +1185,9 @@ plugin_maybe_claim (lang_input_statement - { - bfd *abfd = entry->the_bfd->plugin_dummy_bfd; - -+ /* Check object only section. */ -+ cmdline_check_object_only_section (entry->the_bfd, TRUE); -+ - /* Discard the real file's BFD and substitute the dummy one. */ - - /* BFD archive handling caches elements so we can't call -@@ -1227,14 +1233,17 @@ plugin_call_cleanup (void) - { - if (curplug->cleanup_handler && !curplug->cleanup_done) - { -- enum ld_plugin_status rv; -- curplug->cleanup_done = TRUE; -- called_plugin = curplug; -- rv = (*curplug->cleanup_handler) (); -- called_plugin = NULL; -- if (rv != LDPS_OK) -- info_msg (_("%P: %s: error in plugin cleanup: %d (ignored)\n"), -- curplug->name, rv); -+ if (!plugin_save_temps) -+ { -+ enum ld_plugin_status rv; -+ curplug->cleanup_done = TRUE; -+ called_plugin = curplug; -+ rv = (*curplug->cleanup_handler) (); -+ called_plugin = NULL; -+ if (rv != LDPS_OK) -+ info_msg (_("%P: %s: error in plugin cleanup: %d (ignored)\n"), -+ curplug->name, rv); -+ } - dlclose (curplug->dlhandle); - } - curplug = curplug->next; -diff -rup binutils-2.26.orig/ld/plugin.h binutils-2.26/ld/plugin.h ---- binutils-2.26.orig/ld/plugin.h 2016-02-19 09:35:36.702003296 +0000 -+++ binutils-2.26/ld/plugin.h 2016-02-19 09:35:54.924106628 +0000 -@@ -24,6 +24,9 @@ - /* Report plugin symbols. */ - extern bfd_boolean report_plugin_symbols; - -+/* Store plugin intermediate files permanently. */ -+extern bfd_boolean plugin_save_temps; -+ - /* Set at all symbols read time, to avoid recursively offering the plugin - its own newly-added input files and libs to claim. */ - extern bfd_boolean no_more_claiming; -diff -rup binutils-2.26.orig/ld/scripttempl/armbpabi.sc binutils-2.26/ld/scripttempl/armbpabi.sc ---- binutils-2.26.orig/ld/scripttempl/armbpabi.sc 2016-02-19 09:35:36.704003308 +0000 -+++ binutils-2.26/ld/scripttempl/armbpabi.sc 2016-02-19 09:35:54.924106628 +0000 -@@ -36,7 +36,7 @@ INTERP=".interp 0 : { *(.interp) } - PLT=".plt ${RELOCATING-0} : { *(.plt) }" - RODATA=".rodata ${RELOCATING-0} : { *(.rodata${RELOCATING+ .rodata.* .gnu.linkonce.r.*}) }" - DATARELRO=".data.rel.ro : { *(.data.rel.ro.local) *(.data.rel.ro .data.rel.ro.*) }" --DISCARDED="/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) }" -+DISCARDED="/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) *(.gnu_object_only) }" - if test -z "${NO_SMALL_DATA}"; then - SBSS=".sbss ${RELOCATING-0} : - { -diff -rup binutils-2.26.orig/ld/scripttempl/elf32sh-symbian.sc binutils-2.26/ld/scripttempl/elf32sh-symbian.sc ---- binutils-2.26.orig/ld/scripttempl/elf32sh-symbian.sc 2016-02-19 09:35:36.705003313 +0000 -+++ binutils-2.26/ld/scripttempl/elf32sh-symbian.sc 2016-02-19 09:35:54.925106634 +0000 -@@ -88,7 +88,7 @@ fi - PLT=".plt : { *(.plt) } :dynamic :dyn" - DYNAMIC=".dynamic : { *(.dynamic) } :dynamic :dyn" - RODATA=".rodata ALIGN(4) : { *(.rodata${RELOCATING+ .rodata.* .gnu.linkonce.r.*}) }" --DISCARDED="/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.directive) *(.gnu.lto_*) }" -+DISCARDED="/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.directive) *(.gnu.lto_*) *(.gnu_object_only) }" - test -z "$GOT" && GOT=".got ${RELOCATING-0} : { *(.got.plt) *(.got) } :dynamic :dyn" - INIT_ARRAY=".init_array ${RELOCATING-0} : - { -diff -rup binutils-2.26.orig/ld/scripttempl/elf64hppa.sc binutils-2.26/ld/scripttempl/elf64hppa.sc ---- binutils-2.26.orig/ld/scripttempl/elf64hppa.sc 2016-02-19 09:35:36.705003313 +0000 -+++ binutils-2.26/ld/scripttempl/elf64hppa.sc 2016-02-19 09:35:54.925106634 +0000 -@@ -132,7 +132,7 @@ fi - DYNAMIC=".dynamic ${RELOCATING-0} : { *(.dynamic) }" - RODATA=".rodata ${RELOCATING-0} : { *(.rodata${RELOCATING+ .rodata.* .gnu.linkonce.r.*}) }" - DATARELRO=".data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro .data.rel.ro.* .gnu.linkonce.d.rel.ro.*) }" --DISCARDED="/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) }" -+DISCARDED="/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) *(.gnu_object_only) }" - if test -z "${NO_SMALL_DATA}"; then - SBSS=".sbss ${RELOCATING-0} : - { -diff -rup binutils-2.26.orig/ld/scripttempl/elf.sc binutils-2.26/ld/scripttempl/elf.sc ---- binutils-2.26.orig/ld/scripttempl/elf.sc 2016-02-19 09:35:36.705003313 +0000 -+++ binutils-2.26/ld/scripttempl/elf.sc 2016-02-19 09:35:54.924106628 +0000 -@@ -170,7 +170,7 @@ RELA_IPLT=".rela.iplt ${RELOCATING-0} - DYNAMIC=".dynamic ${RELOCATING-0} : { *(.dynamic) }" - RODATA=".${RODATA_NAME} ${RELOCATING-0} : { *(.${RODATA_NAME}${RELOCATING+ .${RODATA_NAME}.* .gnu.linkonce.r.*}) }" - DATARELRO=".data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro .data.rel.ro.* .gnu.linkonce.d.rel.ro.*) }" --DISCARDED="/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) }" -+DISCARDED="/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) *(.gnu_object_only) }" - if test -z "${NO_SMALL_DATA}"; then - SBSS=".${SBSS_NAME} ${RELOCATING-0} : - { -diff -rup binutils-2.26.orig/ld/scripttempl/elfxtensa.sc binutils-2.26/ld/scripttempl/elfxtensa.sc ---- binutils-2.26.orig/ld/scripttempl/elfxtensa.sc 2016-02-19 09:35:36.705003313 +0000 -+++ binutils-2.26/ld/scripttempl/elfxtensa.sc 2016-02-19 09:35:54.925106634 +0000 -@@ -145,7 +145,7 @@ fi - DYNAMIC=".dynamic ${RELOCATING-0} : { *(.dynamic) }" - RODATA=".rodata ${RELOCATING-0} : { *(.rodata${RELOCATING+ .rodata.* .gnu.linkonce.r.*}) }" - DATARELRO=".data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro .data.rel.ro.* .gnu.linkonce.d.rel.ro.*) }" --DISCARDED="/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) }" -+DISCARDED="/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) *(.gnu_object_only) }" - INIT_LIT=".init.literal 0 : { *(.init.literal) }" - INIT=".init 0 : { *(.init) }" - FINI_LIT=".fini.literal 0 : { *(.fini.literal) }" -diff -rup binutils-2.26.orig/ld/scripttempl/mep.sc binutils-2.26/ld/scripttempl/mep.sc ---- binutils-2.26.orig/ld/scripttempl/mep.sc 2016-02-19 09:35:36.706003319 +0000 -+++ binutils-2.26/ld/scripttempl/mep.sc 2016-02-19 09:35:54.926106640 +0000 -@@ -119,7 +119,7 @@ fi - DYNAMIC=".dynamic ${RELOCATING-0} : { *(.dynamic) }" - RODATA=".rodata ${RELOCATING-0} : { *(.rodata${RELOCATING+ .rodata.* .gnu.linkonce.r.*}) }" - DATARELRO=".data.rel.ro : { *(.data.rel.ro.local) *(.data.rel.ro .data.rel.ro.*) }" --DISCARDED="/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) }" -+DISCARDED="/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) *(.gnu_object_only) }" - if test -z "${NO_SMALL_DATA}"; then - SBSS=".sbss ${RELOCATING-0} : - { -diff -rup binutils-2.26.orig/ld/scripttempl/pep.sc binutils-2.26/ld/scripttempl/pep.sc ---- binutils-2.26.orig/ld/scripttempl/pep.sc 2016-02-19 09:35:36.706003319 +0000 -+++ binutils-2.26/ld/scripttempl/pep.sc 2016-02-19 09:35:54.926106640 +0000 -@@ -178,6 +178,7 @@ SECTIONS - *(.drectve) - ${RELOCATING+ *(.note.GNU-stack)} - ${RELOCATING+ *(.gnu.lto_*)} -+ ${RELOCATING+ *(.gnu_object_only)} - } - - .idata ${RELOCATING+BLOCK(__section_alignment__)} : -diff -rup binutils-2.26.orig/ld/scripttempl/pe.sc binutils-2.26/ld/scripttempl/pe.sc ---- binutils-2.26.orig/ld/scripttempl/pe.sc 2016-02-19 09:35:36.706003319 +0000 -+++ binutils-2.26/ld/scripttempl/pe.sc 2016-02-19 09:35:54.926106640 +0000 -@@ -165,6 +165,7 @@ SECTIONS - *(.drectve) - ${RELOCATING+ *(.note.GNU-stack)} - ${RELOCATING+ *(.gnu.lto_*)} -+ ${RELOCATING+ *(.gnu_object_only)} - } - - .idata ${RELOCATING+BLOCK(__section_alignment__)} : -diff -rup binutils-2.26.orig/ld/testsuite/ld-plugin/lto.exp binutils-2.26/ld/testsuite/ld-plugin/lto.exp ---- binutils-2.26.orig/ld/testsuite/ld-plugin/lto.exp 2016-02-19 09:35:36.807003892 +0000 -+++ binutils-2.26/ld/testsuite/ld-plugin/lto.exp 2016-02-19 09:36:15.450223025 +0000 -@@ -79,6 +79,15 @@ set lto_link_tests [list \ - [list "Build liblto-3.a" \ - "" "-flto $lto_fat" \ - {lto-3b.c} {} "liblto-3.a"] \ -+ [list "Compile 4a" \ -+ "" "-flto $lto_fat" \ -+ {lto-4a.c} {} ""] \ -+ [list "Compile 4b" \ -+ "" "-O2" \ -+ {lto-4b.c} {} ""] \ -+ [list "Compile 4c" \ -+ "" "-O2" \ -+ {lto-4c.c} {} ""] \ - [list "Compile 5a" \ - "" "-flto $lto_fat" \ - {lto-5a.c} {} ""] \ -@@ -94,6 +103,12 @@ set lto_link_tests [list \ - [list "Compile 9" \ - "" "-O2 -finline -flto" \ - {lto-9.cc} {} "" "c++"] \ -+ [list "Compile 10a" \ -+ "" "-O2" \ -+ {lto-10a.c} {} ""] \ -+ [list "Compile 10b" \ -+ "" "-O2 -flto $lto_fat" \ -+ {lto-10b.c} {} ""] \ - [list "Compile 11a" \ - "" "-O -flto" \ - {lto-11a.c} {} ""] \ -@@ -291,9 +306,21 @@ set lto_run_tests [list \ - [list "LTO 3c" \ - "-O2 -flto -fuse-linker-plugin tmpdir/lto-3a.o tmpdir/lto-3c.o -Wl,--whole-archive tmpdir/liblto-3.a -Wl,--no-whole-archive tmpdir/liblto-3.a" "" \ - {dummy.c} "lto-3d.exe" "lto-3.out" "" "c"] \ -+ [list "LTO 4a" \ -+ "-O2 -flto -fuse-linker-plugin tmpdir/lto-4r-a.o" "" \ -+ {dummy.c} "lto-4a.exe" "lto-4.out" "" "c"] \ -+ [list "LTO 4c" \ -+ "-O2 -flto -fuse-linker-plugin tmpdir/lto-4r-c.o" "" \ -+ {dummy.c} "lto-4c.exe" "lto-4.out" "" "c"] \ -+ [list "LTO 4d" \ -+ "-O2 -flto -fuse-linker-plugin tmpdir/lto-4r-d.o" "" \ -+ {dummy.c} "lto-4d.exe" "lto-4.out" "" "c"] \ - [list "LTO 5" \ - "-O2 -flto -fuse-linker-plugin tmpdir/lto-5.o" "" \ - {dummy.c} "lto-5.exe" "lto-5.out" "" "c"] \ -+ [list "LTO 10" \ -+ "-O2 -flto -fuse-linker-plugin tmpdir/lto-10.o" "" \ -+ {dummy.c} "lto-10.exe" "lto-10.out" "" "c"] \ - [list "LTO 11" \ - "-O -flto -fuse-linker-plugin tmpdir/liblto-11.a" "" \ - {dummy.c} "lto-11.exe" "lto-11.out" "" "c"] \ -@@ -378,6 +405,15 @@ if { [is_elf_format] && [check_lto_share - } - } - -+set testname "Build liblto-4.a" -+remote_file host delete "tmpdir/liblto-4.a" -+set catch_output [run_host_cmd "$ar" "rc tmpdir/liblto-4.a tmpdir/lto-4a.o tmpdir/lto-4b.o tmpdir/lto-4c.o"] -+if {![string match "" $catch_output]} { -+ unresolved $testname -+ restore_notify -+ return -+} -+ - set testname "Build liblto-11.a" - remote_file host delete "tmpdir/liblto-11.a" - set catch_output [run_host_cmd "$ar" "rc $plug_opt tmpdir/liblto-11.a tmpdir/lto-11a.o tmpdir/lto-11b.o tmpdir/lto-11c.o"] -@@ -424,8 +460,30 @@ return - # Run "ld -r" to generate inputs for complex LTO tests. - run_dump_test "lto-3r" - remote_exec host "mv" "tmpdir/dump tmpdir/lto-3.o" -+run_dump_test "lto-4r-a" -+remote_exec host "mv" "tmpdir/dump tmpdir/lto-4r-a.o" -+run_dump_test "lto-4r-b" -+remote_exec host "mv" "tmpdir/dump tmpdir/lto-4r-b.o" -+run_dump_test "lto-4r-c" -+remote_exec host "mv" "tmpdir/dump tmpdir/lto-4r-c.o" -+run_dump_test "lto-4r-d" -+remote_exec host "mv" "tmpdir/dump tmpdir/lto-4r-d.o" - run_dump_test "lto-5r" - remote_exec host "mv" "tmpdir/dump tmpdir/lto-5.o" -+run_dump_test "lto-10r" -+remote_exec host "mv" "tmpdir/dump tmpdir/lto-10.o" -+set testname "nm mixed object" -+set lto_plugin [run_host_cmd "$CC" "-print-prog-name=liblto_plugin.so tmpdir/lto-10.o"] -+if { [ regexp "liblto_plugin.so" $lto_plugin ] } { -+ set exec_output [run_host_cmd "$NM" "--plugin $lto_plugin tmpdir/lto-10.o"] -+ if { [ regexp "T main" $exec_output ] } { -+ pass $testname -+ } { -+ fail $testname -+ } -+} { -+ fail $testname -+ } - - run_cc_link_tests $lto_link_symbol_tests - -diff -rup binutils-2.26.orig/ld/testsuite/ld-plugin/lto.exp.orig binutils-2.26/ld/testsuite/ld-plugin/lto.exp.orig ---- binutils-2.26.orig/ld/testsuite/ld-plugin/lto.exp.orig 2016-02-19 09:35:36.805003880 +0000 -+++ binutils-2.26/ld/testsuite/ld-plugin/lto.exp.orig 2016-02-19 09:35:54.929106657 +0000 -@@ -79,6 +79,15 @@ set lto_link_tests [list \ - [list "Build liblto-3.a" \ - "" "-flto $lto_fat" \ - {lto-3b.c} {} "liblto-3.a"] \ -+ [list "Compile 4a" \ -+ "" "-flto $lto_fat" \ -+ {lto-4a.c} {} ""] \ -+ [list "Compile 4b" \ -+ "" "-O2" \ -+ {lto-4b.c} {} ""] \ -+ [list "Compile 4c" \ -+ "" "-O2" \ -+ {lto-4c.c} {} ""] \ - [list "Compile 5a" \ - "" "-flto $lto_fat" \ - {lto-5a.c} {} ""] \ -@@ -94,6 +103,12 @@ set lto_link_tests [list \ - [list "Compile 9" \ - "" "-O2 -finline -flto" \ - {lto-9.cc} {} "" "c++"] \ -+ [list "Compile 10a" \ -+ "" "-O2" \ -+ {lto-10a.c} {} ""] \ -+ [list "Compile 10b" \ -+ "" "-O2 -flto $lto_fat" \ -+ {lto-10b.c} {} ""] \ - [list "Compile 11a" \ - "" "-O -flto" \ - {lto-11a.c} {} ""] \ -@@ -291,9 +306,21 @@ set lto_run_tests [list \ - [list "LTO 3c" \ - "-O2 -flto -fuse-linker-plugin tmpdir/lto-3a.o tmpdir/lto-3c.o -Wl,--whole-archive tmpdir/liblto-3.a -Wl,--no-whole-archive tmpdir/liblto-3.a" "" \ - {dummy.c} "lto-3d.exe" "lto-3.out" "" "c"] \ -+ [list "LTO 4a" \ -+ "-O2 -flto -fuse-linker-plugin tmpdir/lto-4r-a.o" "" \ -+ {dummy.c} "lto-4a.exe" "lto-4.out" "" "c"] \ -+ [list "LTO 4c" \ -+ "-O2 -flto -fuse-linker-plugin tmpdir/lto-4r-c.o" "" \ -+ {dummy.c} "lto-4c.exe" "lto-4.out" "" "c"] \ -+ [list "LTO 4d" \ -+ "-O2 -flto -fuse-linker-plugin tmpdir/lto-4r-d.o" "" \ -+ {dummy.c} "lto-4d.exe" "lto-4.out" "" "c"] \ - [list "LTO 5" \ - "-O2 -flto -fuse-linker-plugin tmpdir/lto-5.o" "" \ - {dummy.c} "lto-5.exe" "lto-5.out" "" "c"] \ -+ [list "LTO 10" \ -+ "-O2 -flto -fuse-linker-plugin tmpdir/lto-10.o" "" \ -+ {dummy.c} "lto-10.exe" "lto-10.out" "" "c"] \ - [list "LTO 11" \ - "-O -flto -fuse-linker-plugin tmpdir/liblto-11.a" "" \ - {dummy.c} "lto-11.exe" "lto-11.out" "" "c"] \ -@@ -378,6 +405,15 @@ if { [is_elf_format] && [check_lto_share - } - } - -+set testname "Build liblto-4.a" -+remote_file host delete "tmpdir/liblto-4.a" -+set catch_output [run_host_cmd "$ar" "rc tmpdir/liblto-4.a tmpdir/lto-4a.o tmpdir/lto-4b.o tmpdir/lto-4c.o"] -+if {![string match "" $catch_output]} { -+ unresolved $testname -+ restore_notify -+ return -+} -+ - set testname "Build liblto-11.a" - remote_file host delete "tmpdir/liblto-11.a" - set catch_output [run_host_cmd "$ar" "rc $plug_opt tmpdir/liblto-11.a tmpdir/lto-11a.o tmpdir/lto-11b.o tmpdir/lto-11c.o"] -@@ -416,11 +452,26 @@ if { [at_least_gcc_version 4 7] } { - } - } - -+# Fedora specific binutils patches break some of the tests that follow... -+restore_notify -+return -+ -+ - # Run "ld -r" to generate inputs for complex LTO tests. - run_dump_test "lto-3r" - remote_exec host "mv" "tmpdir/dump tmpdir/lto-3.o" -+run_dump_test "lto-4r-a" -+remote_exec host "mv" "tmpdir/dump tmpdir/lto-4r-a.o" -+run_dump_test "lto-4r-b" -+remote_exec host "mv" "tmpdir/dump tmpdir/lto-4r-b.o" -+run_dump_test "lto-4r-c" -+remote_exec host "mv" "tmpdir/dump tmpdir/lto-4r-c.o" -+run_dump_test "lto-4r-d" -+remote_exec host "mv" "tmpdir/dump tmpdir/lto-4r-d.o" - run_dump_test "lto-5r" - remote_exec host "mv" "tmpdir/dump tmpdir/lto-5.o" -+run_dump_test "lto-10r" -+remote_exec host "mv" "tmpdir/dump tmpdir/lto-10.o" - - run_cc_link_tests $lto_link_symbol_tests - diff --git a/source/d/binutils/patches/binutils-rh1312151.patch b/source/d/binutils/patches/binutils-rh1312151.patch deleted file mode 100644 index e989b86f..00000000 --- a/source/d/binutils/patches/binutils-rh1312151.patch +++ /dev/null @@ -1,22 +0,0 @@ ---- binutils-2.26.orig/bfd/elflink.c 2016-02-26 13:21:54.134859610 +0000 -+++ binutils-2.26/bfd/elflink.c 2016-02-26 13:22:49.083168157 +0000 -@@ -555,6 +555,19 @@ bfd_elf_record_link_assignment (bfd *out - if (h == NULL) - return provide; - -+ if (h->versioned == unknown) -+ { -+ /* Set versioned if symbol version is unknown. */ -+ char *version = strrchr (name, ELF_VER_CHR); -+ if (version) -+ { -+ if (version > name && version[-1] != ELF_VER_CHR) -+ h->versioned = versioned_hidden; -+ else -+ h->versioned = versioned; -+ } -+ } -+ - switch (h->root.type) - { - case bfd_link_hash_defined: diff --git a/source/d/binutils/slack-desc b/source/d/binutils/slack-desc index 417dc333..b2d81d1d 100644 --- a/source/d/binutils/slack-desc +++ b/source/d/binutils/slack-desc @@ -1,14 +1,14 @@ # HOW TO EDIT THIS FILE: -# The "handy ruler" below makes it easier to edit a package description. Line +# The "handy ruler" below makes it easier to edit a package description. Line # up the first '|' above the ':' following the base package name, and the '|' -# on the right side marks the last column you can put a character in. You must -# make exactly 11 lines for the formatting to be correct. It's also +# on the right side marks the last column you can put a character in. You must +# make exactly 11 lines for the formatting to be correct. It's also # customary to leave one space after the ':'. |-----handy-ruler------------------------------------------------------| binutils: binutils (GNU binary development tools) binutils: -binutils: Binutils is a collection of binary utilities. It includes "as" (the +binutils: Binutils is a collection of binary utilities. It includes "as" (the binutils: portable GNU assembler), "ld" (the GNU linker), and other utilities binutils: for creating and working with binary programs. binutils: diff --git a/source/d/bison/bison.SlackBuild b/source/d/bison/bison.SlackBuild index ea53e8be..b11ccd7e 100755 --- a/source/d/bison/bison.SlackBuild +++ b/source/d/bison/bison.SlackBuild @@ -1,6 +1,6 @@ -#!/bin/sh +#!/bin/bash -# Copyright 2005-2008, 2009, 2010, 2012, 2013 Patrick J. Volkerding, Sebeka, MN, USA +# Copyright 2005-2008, 2009, 2010, 2012, 2013, 2018 Patrick J. Volkerding, Sebeka, MN, USA # All rights reserved. # # Redistribution and use of this script, with or without modification, is @@ -20,6 +20,7 @@ # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +cd $(dirname $0) ; CWD=$(pwd) PKGNAM=bison VERSION=${VERSION:-$(echo $PKGNAM-*.tar.xz | rev | cut -f 3- -d . | cut -f 1 -d - | rev)} @@ -30,19 +31,26 @@ NUMJOBS=${NUMJOBS:--j6} # Automatically determine the architecture we're building on: if [ -z "$ARCH" ]; then case "$( uname -m )" in - i?86) export ARCH=i486 ;; + i?86) export ARCH=i586 ;; arm*) export ARCH=arm ;; # Unless $ARCH is already set, use uname -m for all other archs: *) export ARCH=$( uname -m ) ;; esac fi -CWD=$(pwd) +# If the variable PRINT_PACKAGE_NAME is set, then this script will report what +# the name of the created package would be, and then exit. This information +# could be useful to other scripts. +if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then + echo "$PKGNAM-$VERSION-$ARCH-$BUILD.txz" + exit 0 +fi + TMP=${TMP:-/tmp} PKG=$TMP/package-bison -if [ "$ARCH" = "i486" ]; then - SLKCFLAGS="-O2 -march=i486 -mtune=i686" +if [ "$ARCH" = "i586" ]; then + SLKCFLAGS="-O2 -march=i586 -mtune=i686" LIBDIRSUFFIX="" elif [ "$ARCH" = "s390" ]; then SLKCFLAGS="-O2" @@ -76,10 +84,10 @@ CFLAGS="$SLKCFLAGS" \ --mandir=/usr/man \ --infodir=/usr/info \ --docdir=/usr/doc/bison-$VERSION \ - --build=$ARCH-slackware-linux + --build=$ARCH-slackware-linux || exit 1 make $NUMJOBS || make || exit 1 -make install DESTDIR=$PKG +make install DESTDIR=$PKG || exit 1 find $PKG | xargs file | grep -e "executable" -e "shared object" \ | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null diff --git a/source/d/bison/slack-desc b/source/d/bison/slack-desc index 9b429253..02c40f6a 100644 --- a/source/d/bison/slack-desc +++ b/source/d/bison/slack-desc @@ -1,8 +1,8 @@ # HOW TO EDIT THIS FILE: -# The "handy ruler" below makes it easier to edit a package description. Line +# The "handy ruler" below makes it easier to edit a package description. Line # up the first '|' above the ':' following the base package name, and the '|' -# on the right side marks the last column you can put a character in. You must -# make exactly 11 lines for the formatting to be correct. It's also +# on the right side marks the last column you can put a character in. You must +# make exactly 11 lines for the formatting to be correct. It's also # customary to leave one space after the ':'. |-----handy-ruler------------------------------------------------------| @@ -12,8 +12,8 @@ bison: GNU "Bison" is a general-purpose parser generator that converts a bison: grammar description for an LALR(1) context-free grammar into a C bison: program to parse that grammar. bison: -bison: Bison is upward compatible with Yacc: all properly-written Yacc -bison: grammars ought to work with Bison with no change. Anyone familiar +bison: Bison is upward compatible with Yacc: all properly-written Yacc +bison: grammars ought to work with Bison with no change. Anyone familiar bison: with Yacc should be able to use Bison with little trouble. bison: bison: diff --git a/source/d/ccache/ccache.SlackBuild b/source/d/ccache/ccache.SlackBuild index ecd70ac3..16d64a71 100755 --- a/source/d/ccache/ccache.SlackBuild +++ b/source/d/ccache/ccache.SlackBuild @@ -1,6 +1,6 @@ -#!/bin/sh +#!/bin/bash -# Copyright 2008, 2009, 2010, 2011 Patrick J. Volkerding, Sebeka, MN, USA +# Copyright 2008, 2009, 2010, 2011, 2017, 2018 Patrick J. Volkerding, Sebeka, MN, USA # All rights reserved. # # Redistribution and use of this script, with or without modification, is @@ -20,9 +20,11 @@ # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +cd $(dirname $0) ; CWD=$(pwd) + PKGNAM=ccache VERSION=${VERSION:-$(echo $PKGNAM-*.tar.xz | rev | cut -f 3- -d . | cut -f 1 -d - | rev)} -BUILD=${BUILD:-1} +BUILD=${BUILD:-2} # Automatically determine the architecture we're building on: if [ -z "$ARCH" ]; then @@ -34,7 +36,14 @@ if [ -z "$ARCH" ]; then esac fi -CWD=$(pwd) +# If the variable PRINT_PACKAGE_NAME is set, then this script will report what +# the name of the created package would be, and then exit. This information +# could be useful to other scripts. +if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then + echo "$PKGNAM-$VERSION-$ARCH-$BUILD.txz" + exit 0 +fi + TMP=${TMP:-/tmp} PKG=$TMP/package-ccache @@ -57,7 +66,7 @@ find . \ ./configure \ --prefix=/usr \ --mandir=/usr/man \ - --sysconfdir=/etc + --sysconfdir=/etc || exit 1 make $NUMJOBS || make || exit 1 make install DESTDIR=$PKG || exit 1 @@ -79,7 +88,7 @@ fi mkdir -p $PKG/usr/doc/ccache-$VERSION cp -a \ - *.txt \ + *.md *.txt *.html \ $PKG/usr/doc/ccache-$VERSION # Strip binaries: diff --git a/source/d/ccache/slack-desc b/source/d/ccache/slack-desc index ebb56d94..f3fcf3b0 100644 --- a/source/d/ccache/slack-desc +++ b/source/d/ccache/slack-desc @@ -1,8 +1,8 @@ # HOW TO EDIT THIS FILE: -# The "handy ruler" below makes it easier to edit a package description. Line +# The "handy ruler" below makes it easier to edit a package description. Line # up the first '|' above the ':' following the base package name, and the '|' -# on the right side marks the last column you can put a character in. You must -# make exactly 11 lines for the formatting to be correct. It's also +# on the right side marks the last column you can put a character in. You must +# make exactly 11 lines for the formatting to be correct. It's also # customary to leave one space after the ':'. |-----handy-ruler------------------------------------------------------| @@ -14,6 +14,6 @@ ccache: being done again. ccache: ccache: ccache was written by Andrew Tridgell. ccache: -ccache: +ccache: Homepage: https://ccache.samba.org/ ccache: ccache: diff --git a/source/d/clisp/clisp.SlackBuild b/source/d/clisp/clisp.SlackBuild index f98057df..4205aa13 100755 --- a/source/d/clisp/clisp.SlackBuild +++ b/source/d/clisp/clisp.SlackBuild @@ -1,6 +1,6 @@ -#!/bin/sh +#!/bin/bash -# Copyright 2008, 2009, 2010, 2013, 2015 Patrick J. Volkerding, Sebeka, MN, USA +# Copyright 2008, 2009, 2010, 2013, 2015, 2017, 2018 Patrick J. Volkerding, Sebeka, MN, USA # All rights reserved. # # Redistribution and use of this script, with or without modification, is @@ -20,26 +20,35 @@ # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +cd $(dirname $0) ; CWD=$(pwd) -VERSION=2.49 -DIRNAME=2.49 -BUILD=${BUILD:-3} +PKGNAM=clisp +VERSION=${VERSION:-$(echo $PKGNAM-*.tar.?z | rev | cut -f 3- -d . | cut -f 1 -d - | rev)} +BUILD=${BUILD:-1} # Bundled libraries: -FFCALLVER=20120424cvs +FFCALLVER=2.1 # Automatically determine the architecture we're building on: if [ -z "$ARCH" ]; then case "$( uname -m )" in - i?86) export ARCH=i486 ;; + i?86) export ARCH=i586 ;; arm*) export ARCH=arm ;; # Unless $ARCH is already set, use uname -m for all other archs: *) export ARCH=$( uname -m ) ;; esac fi -if [ "$ARCH" = "i486" ]; then - SLKCFLAGS="-O2 -march=i486 -mtune=i686" +# If the variable PRINT_PACKAGE_NAME is set, then this script will report what +# the name of the created package would be, and then exit. This information +# could be useful to other scripts. +if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then + echo "$PKGNAM-$VERSION-$ARCH-$BUILD.txz" + exit 0 +fi + +if [ "$ARCH" = "i586" ]; then + SLKCFLAGS="-O2 -march=i586 -mtune=i686" LIBDIRSUFFIX="" elif [ "$ARCH" = "s390" ]; then SLKCFLAGS="-O2" @@ -54,7 +63,6 @@ fi NUMJOBS=${NUMJOBS:-" -j7 "} -CWD=$(pwd) TMP=${TMP:-/tmp} PKG=$TMP/package-clisp @@ -64,12 +72,9 @@ mkdir -p $TMP $PKG #================================================================= # Build ffcall - needed for --dynamic-ffi with clisp. cd $TMP -rm -rf ffcall* -tar xvf $CWD/ffcall-$FFCALLVER.tar.?z* || exit 1 -cd ffcall* || exit 1 - -# Not sure if this is useful or not, but I'll leave it for MoZes: -zcat $CWD/ffcall-arm.patch.gz | patch -p1 --verbose || exit 1 +rm -rf libffcall-$FFCALLVER +tar xvf $CWD/libffcall-$FFCALLVER.tar.?z || exit 1 +cd libffcall-$FFCALLVER || exit 1 chown -R root:root . find . \ @@ -83,22 +88,21 @@ CFLAGS="$SLKCFLAGS" \ --prefix=/usr \ --libdir=/usr/lib${LIBDIRSUFFIX} \ --mandir=/usr/man \ + --enable-static=yes \ + --enable-shared=no \ --build=$ARCH-slackware-linux || exit 1 make $NUMJOBS || make || exit 1 make install DESTDIR=$PKG || exit 1 -# We need ffcall installed in order to build clisp: -make install - -# Don't need this: -rm -f $PKG/usr/lib${LIBDIRSUFFIX}/*.la +# We need libffcall installed in order to build clisp: +make install || exit 1 # Move docs around: -mkdir -pm755 $PKG/usr/doc/clisp-$VERSION/ffcall-$FFCALLVER +mkdir -pm755 $PKG/usr/doc/clisp-$VERSION/libffcall-$FFCALLVER install -vpm644 README NEWS COPYING \ - $PKG/usr/doc/clisp-$VERSION/ffcall-$FFCALLVER -mv -f $PKG/usr/share/html/* $PKG/usr/doc/clisp-$VERSION/ffcall-$FFCALLVER + $PKG/usr/doc/clisp-$VERSION/libffcall-$FFCALLVER +mv -f $PKG/usr/share/html/* $PKG/usr/doc/clisp-$VERSION/libffcall-$FFCALLVER rmdir $PKG/usr/share/html/ rmdir $PKG/usr/share/ @@ -107,8 +111,8 @@ rmdir $PKG/usr/share/ # OK, now we compile CLISP: cd $TMP rm -rf clisp-$VERSION -tar xvf $CWD/clisp-$VERSION.tar.?z* || exit 1 -cd clisp-$DIRNAME || exit 1 +tar xvf $CWD/clisp-$VERSION.tar.?z || exit 1 +cd clisp-$VERSION || exit 1 chown -R root:root . find . \ \( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \ @@ -116,48 +120,51 @@ find . \ \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \ -exec chmod 644 {} \; +# Fix build failure with missing struct member: +zcat $CWD/clisp.c_data.compact_empty_buckets.diff.gz | patch -p1 --verbose || exit + +# I'll be unsafe if I want to: +export FORCE_UNSAFE_CONFIGURE=1 + +# --cbc instead of --config below will check the build. +# --cbcx will do even more extra checking. + CFLAGS="$SLKCFLAGS" \ ./configure \ --prefix=/usr \ --libdir=/usr/lib${LIBDIRSUFFIX} \ --mandir=/usr/man \ --docdir=/usr/doc/clisp-$VERSION \ + --with-module=asdf \ + --with-module=berkeley-db \ + --with-module=bindings/glibc \ --with-module=clx/new-clx \ + --with-module=dbus \ + --with-module=gdbm \ + --with-module=gtk2 \ --with-module=pcre \ --with-module=rawsock \ - --with-module=wildcard \ --with-module=zlib \ - --cbc with-gcc-wall \ + --config builddir \ --with-dynamic-ffi || exit 1 -cd with-gcc-wall -./makemake \ - --with-dynamic-ffi \ - --prefix=/usr \ - --libdir=/usr/lib${LIBDIRSUFFIX} \ - --with-module=clx/new-clx \ - --with-module=pcre \ - --with-module=rawsock \ - --with-module=wildcard \ - --with-module=zlib \ - --srcdir=../src \ - > Makefile -make config.lisp -make init -make allc -make $NUMJOBS lisp.run -make interpreted.mem -make halfcompiled.mem -make lispinit.mem -make manual -make modular +# Build: +make $NUMJOBS -C builddir || make -C builddir || exit 1 -make install DESTDIR=$PKG || exit 1 +# Install into package: +make -C builddir install DESTDIR=$PKG || exit 1 # Strip stuff: find $PKG | xargs file | grep -e "executable" -e "shared object" \ | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null +# Don't ship .la files: +pushd $PKG + for lafile in usr/lib${LIBDIRSUFFIX}/*.la ; do + rm -f ${lafile} /${lafile} + done +popd + #mv $PKG/usr/share/doc/clisp/* $PKG/usr/doc/clisp-$VERSION rm -r $PKG/usr/share/doc diff --git a/source/d/clisp/clisp.c_data.compact_empty_buckets.diff b/source/d/clisp/clisp.c_data.compact_empty_buckets.diff new file mode 100644 index 00000000..0a351848 --- /dev/null +++ b/source/d/clisp/clisp.c_data.compact_empty_buckets.diff @@ -0,0 +1,12 @@ +# Remove non-existant struct member: + +--- ./modules/berkeley-db/bdb.c.orig 2018-02-04 13:38:36.000000000 -0600 ++++ ./modules/berkeley-db/bdb.c 2018-02-04 15:29:06.147941837 -0600 +@@ -2216,7 +2216,6 @@ + c_data.compact_timeout = timeout; + c_data.compact_pages = pages; + SYSCALL(db->compact,(db,txn,pstart,pstop,&c_data,flags,&end)); +- pushSTACK(uint32_to_I(c_data.compact_empty_buckets)); + pushSTACK(uint32_to_I(c_data.compact_pages_free)); + pushSTACK(uint32_to_I(c_data.compact_pages_examine)); + pushSTACK(uint32_to_I(c_data.compact_levels)); diff --git a/source/d/clisp/ffcall-arm.patch b/source/d/clisp/ffcall-arm.patch deleted file mode 100644 index 8e8509b1..00000000 --- a/source/d/clisp/ffcall-arm.patch +++ /dev/null @@ -1,93 +0,0 @@ ---- ./callback/trampoline_r/cache-armel.c.orig 2009-04-27 10:44:13.000000000 -0600 -+++ ./callback/trampoline_r/cache-armel.c 2013-09-06 11:00:00.000000000 -0600 -@@ -12,8 +12,9 @@ - - void __TR_clear_cache (char *first_addr, char *last_addr) - { -- register unsigned long _beg __asm ("a1") = first_addr; -- register unsigned long _end __asm ("a2") = last_addr; -+ register unsigned long _beg __asm ("a1") = (unsigned long) first_addr; -+ register unsigned long _end __asm ("a2") = (unsigned long) last_addr; - register unsigned long _flg __asm ("a3") = 0; -- __asm __volatile__ ("swi 0x9f0002" : : "r" (_beg), "r" (_end), "r" (_flg)); -+ register unsigned long _sys __asm ("r7") = __ARM_NR_cacheflush; -+ __asm __volatile__ ("swi 0x0" : "=r" (_beg) : "0" (_beg), "r" (_end), "r" (_flg), "r" (_sys)); - } ---- ./callback/trampoline_r/cache-armel.s.orig 2009-04-27 10:44:13.000000000 -0600 -+++ ./callback/trampoline_r/cache-armel.s 2013-09-06 13:00:00.000000000 -0600 -@@ -1,5 +1,5 @@ -- .cpu arm10tdmi -- .fpu softvfp -+ .arch armv7-a -+ .fpu vfpv3-d16 - .file "cache-armel.c" - .text - .align 2 -@@ -9,10 +9,13 @@ __TR_clear_cache: - @ args = 0, pretend = 0, frame = 0 - @ frame_needed = 0, uses_anonymous_args = 0 - @ link register save eliminated. -- @ lr needed for prologue -+ str r7, [sp, #-4]! - mov r2, #0 -+ mov r7, #2 -+ movt r7, 15 - #APP -- swi 0x9f0002 -+ swi 0x0 -+ ldr r7, [sp], #4 - bx lr - .size __TR_clear_cache, .-__TR_clear_cache -- .ident "GCC: (GNU) 3.4.4 (release) (CodeSourcery ARM 2005q3-2)" -+ .ident "GCC: (GNU) 4.8.1 20130829 (Red Hat 4.8.1-7)" ---- ./trampoline/cache-armel.c.orig 2009-04-27 10:44:14.000000000 -0600 -+++ ./trampoline/cache-armel.c 2013-09-06 11:00:00.000000000 -0600 -@@ -12,8 +12,9 @@ - - void __TR_clear_cache (char *first_addr, char *last_addr) - { -- register unsigned long _beg __asm ("a1") = first_addr; -- register unsigned long _end __asm ("a2") = last_addr; -+ register unsigned long _beg __asm ("a1") = (unsigned long) first_addr; -+ register unsigned long _end __asm ("a2") = (unsigned long) last_addr; - register unsigned long _flg __asm ("a3") = 0; -- __asm __volatile__ ("swi 0x9f0002" : : "r" (_beg), "r" (_end), "r" (_flg)); -+ register unsigned long _sys __asm ("r7") = __ARM_NR_cacheflush; -+ __asm __volatile__ ("swi 0x0" : "=r" (_beg) : "0" (_beg), "r" (_end), "r" (_flg), "r" (_sys)); - } ---- ./trampoline/cache-armel.s.orig 2009-04-27 10:44:14.000000000 -0600 -+++ ./trampoline/cache-armel.s 2013-09-06 13:00:00.000000000 -0600 -@@ -1,24 +1,21 @@ -- .cpu arm10tdmi -- .fpu softvfp -+ .arch armv7-a -+ .fpu vfpv3-d16 - .file "cache-armel.c" - .text - .align 2 - .global __TR_clear_cache - .type __TR_clear_cache, %function - __TR_clear_cache: -- @ args = 0, pretend = 0, frame = 8 -+ @ args = 0, pretend = 0, frame = 0 - @ frame_needed = 0, uses_anonymous_args = 0 - @ link register save eliminated. -- sub sp, sp, #8 -- @ lr needed for prologue -- str r0, [sp, #4] -- str r1, [sp, #0] -- ldr r0, [sp, #4] -- ldr r1, [sp, #0] -+ str r7, [sp, #-4]! - mov r2, #0 -+ mov r7, #2 -+ movt r7, 15 - #APP -- swi 0x9f0002 -- add sp, sp, #8 -+ swi 0x0 -+ ldr r7, [sp], #4 - bx lr - .size __TR_clear_cache, .-__TR_clear_cache -- .ident "GCC: (GNU) 3.4.4 (release) (CodeSourcery ARM 2005q3-2)" -+ .ident "GCC: (GNU) 4.8.1 20130829 (Red Hat 4.8.1-7)" diff --git a/source/d/clisp/slack-desc b/source/d/clisp/slack-desc index 5fb2f195..5dc55efa 100644 --- a/source/d/clisp/slack-desc +++ b/source/d/clisp/slack-desc @@ -1,8 +1,8 @@ # HOW TO EDIT THIS FILE: -# The "handy ruler" below makes it easier to edit a package description. Line +# The "handy ruler" below makes it easier to edit a package description. Line # up the first '|' above the ':' following the base package name, and the '|' -# on the right side marks the last column you can put a character in. You must -# make exactly 11 lines for the formatting to be correct. It's also +# on the right side marks the last column you can put a character in. You must +# make exactly 11 lines for the formatting to be correct. It's also # customary to leave one space after the ':'. |-----handy-ruler------------------------------------------------------| @@ -13,7 +13,7 @@ clisp: GNU CLISP is a Common Lisp implementation by Bruno Haible of Karlsruhe clisp: University and Michael Stoll of Munich University, both in Germany. clisp: It mostly supports the Lisp described in the ANSI Common Lisp standard. clisp: The user interface comes in German, English, French, Spanish, Dutch -clisp: and Russian. GNU CLISP includes an interpreter, a compiler, a +clisp: and Russian. GNU CLISP includes an interpreter, a compiler, a clisp: debugger, a large subset of CLOS, a foreign language interface and a -clisp: socket interface. An X11 interface is available through CLX and +clisp: socket interface. An X11 interface is available through CLX and clisp: Garnet. diff --git a/source/d/clisp/source.download b/source/d/clisp/source.download index 4de17699..06bc8c9b 100755 --- a/source/d/clisp/source.download +++ b/source/d/clisp/source.download @@ -1,3 +1,14 @@ -# http://www.haible.de/bruno/packages-ffcall-README.html -# wget -c http://www.haible.de/bruno/gnu/ffcall-1.10.tar.gz -# wget -c ftp://download.fedora.redhat.com/pub/fedora/linux/development/source/SRPMS/ffcall-1.10-2.20080704cvs.fc10.src.rpm +# Pull the latest clisp sources from the upstream mercurial repository: +rm -rf clisp-2.49 +hg clone http://hg.code.sf.net/p/clisp/clisp clisp-2.49 +# Determine date and changeset for tarball labeling: +DATE="$(date -d "$( cd clisp-2.49 ; hg parent | grep date: | cut -b 14- | cut -f 1 -d +)" +"%Y%m%d")" +CHANGESET="$( cd clisp-2.49 ; hg parent | grep changeset: | cut -f 3 -d :)" +# Don't package .hg: +rm -fr clisp-2.49/.hg* +# Create tarball: +mv clisp-2.49 clisp-2.49.${DATE}.${CHANGESET} +tar cf clisp-2.49.${DATE}.${CHANGESET}.tar clisp-2.49.${DATE}.${CHANGESET} +plzip -9 -n 6 clisp-2.49.${DATE}.${CHANGESET}.tar +# Clean up: +rm -rf clisp-2.49.${DATE}.${CHANGESET} diff --git a/source/d/cmake/cmake.SlackBuild b/source/d/cmake/cmake.SlackBuild index 1f832f00..6bd22500 100755 --- a/source/d/cmake/cmake.SlackBuild +++ b/source/d/cmake/cmake.SlackBuild @@ -1,6 +1,6 @@ -#!/bin/sh +#!/bin/bash -# Copyright 2008, 2009, 2010, 2011, 2013, 2015 Patrick J. Volkerding, Sebeka, Minnesota, USA +# Copyright 2008, 2009, 2010, 2011, 2013, 2015, 2017, 2018 Patrick J. Volkerding, Sebeka, Minnesota, USA # All rights reserved. # # Redistribution and use of this script, with or without modification, is @@ -20,8 +20,10 @@ # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +cd $(dirname $0) ; CWD=$(pwd) + PKGNAM=cmake -VERSION=${VERSION:-$(echo $PKGNAM-*.tar.?z* | rev | cut -f 3- -d . | cut -f 1 -d - | rev)} +VERSION=${VERSION:-$(echo $PKGNAM-*.tar.?z | rev | cut -f 3- -d . | cut -f 1 -d - | rev)} BUILD=${BUILD:-1} # Automatically determine the architecture we're building on: @@ -34,6 +36,14 @@ if [ -z "$ARCH" ]; then esac fi +# If the variable PRINT_PACKAGE_NAME is set, then this script will report what +# the name of the created package would be, and then exit. This information +# could be useful to other scripts. +if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then + echo "$PKGNAM-$VERSION-$ARCH-$BUILD.txz" + exit 0 +fi + NUMJOBS=${NUMJOBS:-" -j7 "} if [ "$ARCH" = "i586" ]; then @@ -46,7 +56,6 @@ else SLKCFLAGS="-O2" fi -CWD=$(pwd) TMP=${TMP:-/tmp} PKG=$TMP/package-$PKGNAM @@ -55,8 +64,8 @@ mkdir -p $TMP $PKG cd $TMP rm -rf $PKGNAM-$VERSION -tar xvf $CWD/$PKGNAM-$VERSION.tar.?z* || exit 1 -cd $PKGNAM-$VERSION +tar xvf $CWD/$PKGNAM-$VERSION.tar.?z || exit 1 +cd $PKGNAM-$VERSION || exit 1 chown -R root:root . find . \ @@ -76,7 +85,7 @@ cd cmake-build --no-system-jsoncpp \ --system-zlib \ --system-bzip2 \ - --system-libarchive + --system-libarchive || exit 1 # --system-libs # --sphinx-man \ @@ -93,8 +102,7 @@ CXXFLAGS="$SLKCFLAGS" \ --no-system-jsoncpp \ --system-zlib \ --system-bzip2 \ - --system-libarchive \ - --build=$ARCH-slackware-linux + --system-libarchive || exit 1 # --system-libs \ # --sphinx-man \ @@ -104,7 +112,7 @@ make install DESTDIR=$PKG || exit 1 # Install preprocessed man pages instead of adding six new python packages: ( cd $PKG - tar xf $CWD/cmake.manpages.tar.xz + tar xf $CWD/cmake.manpages.tar.?z ) # If there's a ChangeLog, installing at least part of the recent history diff --git a/source/d/cmake/extract-manpages-from-binary.sh b/source/d/cmake/extract-manpages-from-binary.sh new file mode 100755 index 00000000..59dc561b --- /dev/null +++ b/source/d/cmake/extract-manpages-from-binary.sh @@ -0,0 +1,38 @@ +#!/bin/sh + +# Copyright 2017 Patrick J. Volkerding, Sebeka, Minnesota, USA +# All rights reserved. +# +# Redistribution and use of this script, with or without modification, is +# permitted provided that the following conditions are met: +# +# 1. Redistributions of this script must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED +# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO +# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +# This is a script to extract the manpages from cmake-*-Linux-x86_64.tar.gz +# and output them as cmake.manpages.tar.xz in the current directory. + +rm -rf tmp-manpages +mkdir tmp-manpages +tar xf cmake-*-Linux-x86_64.tar.?z +mv cmake-*-Linux-x86_64/man tmp-manpages +rm -r cmake-*-Linux-x86_64 +mkdir tmp-manpages/usr +mv tmp-manpages/man tmp-manpages/usr +chown -R root:root tmp-manpages +cd tmp-manpages +tar cf ../cmake.manpages.tar . +cd .. +lzip -9 -f cmake.manpages.tar +rm -r tmp-manpages diff --git a/source/d/cmake/slack-desc b/source/d/cmake/slack-desc index 8fb5c8dd..016e5895 100644 --- a/source/d/cmake/slack-desc +++ b/source/d/cmake/slack-desc @@ -1,8 +1,8 @@ # HOW TO EDIT THIS FILE: -# The "handy ruler" below makes it easier to edit a package description. Line +# The "handy ruler" below makes it easier to edit a package description. Line # up the first '|' above the ':' following the base package name, and the '|' on # the right side marks the last column you can put a character in. You must make -# exactly 11 lines for the formatting to be correct. It's also customary to +# exactly 11 lines for the formatting to be correct. It's also customary to # leave one space after the ':'. |-----handy-ruler------------------------------------------------------| @@ -13,7 +13,7 @@ cmake: and compiler independent configuration files. CMake generates cmake: native makefiles and workspaces that can be used in the cmake: compiler environment of your choice. cmake: -cmake: CMake's home on the web is: http://www.cmake.org +cmake: Homepage: http://www.cmake.org cmake: cmake: cmake: diff --git a/source/d/cscope/cscope.SlackBuild b/source/d/cscope/cscope.SlackBuild index e88ece4d..df452d9d 100755 --- a/source/d/cscope/cscope.SlackBuild +++ b/source/d/cscope/cscope.SlackBuild @@ -1,6 +1,6 @@ -#!/bin/sh +#!/bin/bash -# Copyright 2008, 2009, 2010, 2016 Patrick J. Volkerding, Sebeka, MN, USA +# Copyright 2008, 2009, 2010, 2016, 2018 Patrick J. Volkerding, Sebeka, MN, USA # All rights reserved. # # Redistribution and use of this script, with or without modification, is @@ -20,10 +20,11 @@ # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +cd $(dirname $0) ; CWD=$(pwd) PKGNAM=cscope -VERSION=${VERSION:-$(echo $(basename $(echo $PRGNAM-*.tar.xz | cut -f 2 -d -) .tar.xz) | cut -f 2 -d -)} -BUILD=${BUILD:-1} +VERSION=${VERSION:-$(echo $(basename $(echo $PKGNAM-*.tar.xz | cut -f 2 -d -) .tar.xz) | cut -f 2 -d -)} +BUILD=${BUILD:-3} # Automatically determine the architecture we're building on: if [ -z "$ARCH" ]; then @@ -35,7 +36,14 @@ if [ -z "$ARCH" ]; then esac fi -CWD=$(pwd) +# If the variable PRINT_PACKAGE_NAME is set, then this script will report what +# the name of the created package would be, and then exit. This information +# could be useful to other scripts. +if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then + echo "$PKGNAM-$VERSION-$ARCH-$BUILD.txz" + exit 0 +fi + TMP=${TMP:-/tmp} PKG=$TMP/package-cscope diff --git a/source/d/cscope/slack-desc b/source/d/cscope/slack-desc index b2126b52..4521c5f7 100644 --- a/source/d/cscope/slack-desc +++ b/source/d/cscope/slack-desc @@ -1,14 +1,14 @@ # HOW TO EDIT THIS FILE: -# The "handy ruler" below makes it easier to edit a package description. Line +# The "handy ruler" below makes it easier to edit a package description. Line # up the first '|' above the ':' following the base package name, and the '|' -# on the right side marks the last column you can put a character in. You must -# make exactly 11 lines for the formatting to be correct. It's also +# on the right side marks the last column you can put a character in. You must +# make exactly 11 lines for the formatting to be correct. It's also # customary to leave one space after the ':'. |-----handy-ruler------------------------------------------------------| cscope: cscope (source code browsing tool) cscope: -cscope: Cscope is a text screen based source browsing tool. Although it is +cscope: Cscope is a text screen based source browsing tool. Although it is cscope: primarily designed to search C code (including lex and yacc files), cscope: it can also be used for C++ code. cscope: diff --git a/source/d/cvs/cvs.SlackBuild b/source/d/cvs/cvs.SlackBuild index 81250f4a..1c558329 100755 --- a/source/d/cvs/cvs.SlackBuild +++ b/source/d/cvs/cvs.SlackBuild @@ -1,6 +1,6 @@ -#!/bin/sh +#!/bin/bash -# Copyright 2008, 2009, 2010, 2013 Patrick J. Volkerding, Sebeka, Minnesota, USA +# Copyright 2008, 2009, 2010, 2013, 2018 Patrick J. Volkerding, Sebeka, Minnesota, USA # All rights reserved. # # Redistribution and use of this script, with or without modification, is @@ -20,24 +20,34 @@ # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +cd $(dirname $0) ; CWD=$(pwd) +PKGNAM=cvs VERSION=1.11.23 -BUILD=${BUILD:-2} +BUILD=${BUILD:-3} # Automatically determine the architecture we're building on: if [ -z "$ARCH" ]; then case "$( uname -m )" in - i?86) export ARCH=i486 ;; + i?86) export ARCH=i586 ;; arm*) export ARCH=arm ;; # Unless $ARCH is already set, use uname -m for all other archs: *) export ARCH=$( uname -m ) ;; esac fi +# If the variable PRINT_PACKAGE_NAME is set, then this script will report what +# the name of the created package would be, and then exit. This information +# could be useful to other scripts. +if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then + echo "$PKGNAM-$VERSION-$ARCH-$BUILD.txz" + exit 0 +fi + NUMJOBS=${NUMJOBS:-" -j7 "} -if [ "$ARCH" = "i486" ]; then - SLKCFLAGS="-O2 -march=i486 -mtune=i686" +if [ "$ARCH" = "i586" ]; then + SLKCFLAGS="-O2 -march=i586 -mtune=i686" elif [ "$ARCH" = "s390" ]; then SLKCFLAGS="-O2" elif [ "$ARCH" = "x86_64" ]; then @@ -46,7 +56,6 @@ else SLKCFLAGS="-O2" fi -CWD=$(pwd) TMP=${TMP:-/tmp} PKG=$TMP/package-cvs rm -rf $PKG @@ -55,7 +64,7 @@ mkdir -p $TMP $PKG cd $TMP rm -rf cvs-$VERSION tar xvf $CWD/cvs-$VERSION.tar.bz2 || exit 1 -cd cvs-$VERSION +cd cvs-$VERSION || exit 1 # Patch to handle recent glib crypt(): zcat $CWD/cvs.crypt-2.diff.gz | patch -p1 --verbose || exit 1 @@ -73,7 +82,7 @@ CFLAGS="$SLKCFLAGS" \ ./configure \ --prefix=/usr \ --mandir=/usr/man \ - --infodir=/usr/info + --infodir=/usr/info || exit 1 make $NUMJOBS || make || exit 1 make install DESTDIR=$PKG || exit 1 @@ -86,14 +95,17 @@ gzip -9 $PKG/usr/info/* gzip -9 $PKG/usr/man/man?/*.? -( cd doc ; make txt ) mkdir -p $PKG/usr/doc/cvs-$VERSION cp -a \ BUGS COPYING* DEVEL-CVS FAQ HACKING INSTALL MINOR-BUGS NEWS PROJECTS \ README TESTS TODO \ $PKG/usr/doc/cvs-$VERSION -cat doc/cvs.txt | gzip -9c > $PKG/usr/doc/cvs-$VERSION/cvs.txt.gz -cat doc/cvsclient.txt | gzip -9c > $PKG/usr/doc/cvs-$VERSION/cvsclient.txt.gz + +# This fails, but who cares in 2018 +#( cd doc ; make txt || exit 1 ) || exit 1 +#cat doc/cvs.txt | gzip -9c > $PKG/usr/doc/cvs-$VERSION/cvs.txt.gz +#cat doc/cvsclient.txt | gzip -9c > $PKG/usr/doc/cvs-$VERSION/cvsclient.txt.gz + chmod 644 $PKG/usr/doc/cvs-$VERSION/* gzip -9 $PKG/usr/doc/cvs-$VERSION/FAQ ( cd $PKG/usr/doc/cvs-$VERSION ; rm -rf contrib ) diff --git a/source/d/cvs/slack-desc b/source/d/cvs/slack-desc index 9581cb88..4e540c2a 100644 --- a/source/d/cvs/slack-desc +++ b/source/d/cvs/slack-desc @@ -1,8 +1,8 @@ # HOW TO EDIT THIS FILE: -# The "handy ruler" below makes it easier to edit a package description. Line +# The "handy ruler" below makes it easier to edit a package description. Line # up the first '|' above the ':' following the base package name, and the '|' -# on the right side marks the last column you can put a character in. You must -# make exactly 11 lines for the formatting to be correct. It's also +# on the right side marks the last column you can put a character in. You must +# make exactly 11 lines for the formatting to be correct. It's also # customary to leave one space after the ':'. |-----handy-ruler------------------------------------------------------| @@ -10,10 +10,10 @@ cvs: cvs (Concurrent Versions System) cvs: cvs: CVS is a version control system, which allows you to keep old versions cvs: of files (usually source code), keep a log of who, when, and why -cvs: changes occurred, etc., like RCS or SCCS. It handles multiple +cvs: changes occurred, etc., like RCS or SCCS. It handles multiple cvs: developers, multiple directories, triggers to enable/log/control cvs: various operations, and can work over a wide area network. cvs: -cvs: Some of the people who have worked on CVS include: Dick Grune, +cvs: Some of the people who have worked on CVS include: Dick Grune, cvs: Brian Berliner, Jeff Polk, and others too numerous to mention. cvs: diff --git a/source/d/dev86/dev86.SlackBuild b/source/d/dev86/dev86.SlackBuild index 583e821c..1c10de80 100755 --- a/source/d/dev86/dev86.SlackBuild +++ b/source/d/dev86/dev86.SlackBuild @@ -1,7 +1,7 @@ -#!/bin/sh +#!/bin/bash # Copyright 2007, 2008, 2015 Heinz Wiesinger, Amsterdam, The Netherlands -# Copyright 2008, 2009 Patrick J. Volkerding, Sebeka, MN, USA +# Copyright 2008, 2009, 2018 Patrick J. Volkerding, Sebeka, MN, USA # All rights reserved. # # Redistribution and use of this script, with or without modification, is @@ -21,10 +21,12 @@ # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -PRGNAM=dev86 +cd $(dirname $0) ; CWD=$(pwd) + +PKGNAM=dev86 SRCNAM=Dev86src VERSION=0.16.21 -BUILD=${BUILD:-1} +BUILD=${BUILD:-2} # Automatically determine the architecture we're building on: if [ -z "$ARCH" ]; then @@ -36,9 +38,16 @@ if [ -z "$ARCH" ]; then esac fi -CWD=$(pwd) +# If the variable PRINT_PACKAGE_NAME is set, then this script will report what +# the name of the created package would be, and then exit. This information +# could be useful to other scripts. +if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then + echo "$PKGNAM-$VERSION-$ARCH-$BUILD.txz" + exit 0 +fi + TMP=${TMP:-/tmp} -PKG=$TMP/package-$PRGNAM +PKG=$TMP/package-$PKGNAM OUTPUT=${OUTPUT:-/tmp} if [ "$ARCH" = "i586" ]; then @@ -58,9 +67,9 @@ fi rm -rf $PKG mkdir -p $TMP $PKG $OUTPUT cd $TMP -rm -rf $PRGNAM-$VERSION +rm -rf $PKGNAM-$VERSION tar xvf $CWD/$SRCNAM-$VERSION.tar.?z* || exit 1 -cd $PRGNAM-$VERSION || exit 1 +cd $PKGNAM-$VERSION || exit 1 chown -R root:root . find . \ \( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \ @@ -69,7 +78,7 @@ find . \ -exec chmod 644 {} \; #Does not compile with changed CFLAGS -#CC="gcc" make CFLAGS="-Wall -Wstrict-prototypes $SLKCFLAGS -g" DIST=$PKG +#CC="gcc" make CFLAGS="-Wall -Wstrict-prototypes $SLKCFLAGS -g" DIST=$PKG || exit 1 CC="gcc" \ make \ DIST=$PKG MANDIR=/usr/man LIBDIR=/usr/lib${LIBDIRSUFFIX}/bcc \ @@ -84,15 +93,15 @@ find $PKG | xargs file | grep -e "executable" -e "shared object" \ for i in $( find . -type l ) ; do ln -s $( readlink $i ).gz $i.gz ; rm $i ; done ) -mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION -cp -a Changes Contributors COPYING README $PKG/usr/doc/$PRGNAM-$VERSION +mkdir -p $PKG/usr/doc/$PKGNAM-$VERSION +cp -a Changes Contributors COPYING README $PKG/usr/doc/$PKGNAM-$VERSION for i in bootblocks copt dis88 elksemu unproto ; do - cp -a $i/README $PKG/usr/doc/$PRGNAM-$VERSION/README.$i ; + cp -a $i/README $PKG/usr/doc/$PKGNAM-$VERSION/README.$i ; done find $PKG/usr/doc -type f -exec chmod 0644 {} \; if [ "$ARCH" = "x86_64" ]; then # Remove traces of elks - rm -f $PKG/usr/doc/$PRGNAM-$VERSION/README.elksemu + rm -f $PKG/usr/doc/$PKGNAM-$VERSION/README.elksemu find $PKG/usr/man -name "elks*.*" -exec rm -f {} \; fi @@ -100,4 +109,4 @@ mkdir -p $PKG/install cat $CWD/slack-desc > $PKG/install/slack-desc cd $PKG -/sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD.txz +/sbin/makepkg -l y -c n $OUTPUT/$PKGNAM-$VERSION-$ARCH-$BUILD.txz diff --git a/source/d/dev86/slack-desc b/source/d/dev86/slack-desc index 50c46cef..aa8e672f 100644 --- a/source/d/dev86/slack-desc +++ b/source/d/dev86/slack-desc @@ -2,7 +2,7 @@ dev86: dev86 (8086 development utilities) dev86: dev86: This is a complete 8086 assembler and loader which can make 32-bit -dev86: code for the 386+ processors. In the past it was used to compile the +dev86: code for the 386+ processors. In the past it was used to compile the dev86: 16-bit bootsector and setup binaries for the kernel, but modern dev86: (2.4.x or newer) kernels use GNU ld instead. dev86: diff --git a/source/d/distcc/distcc.SlackBuild b/source/d/distcc/distcc.SlackBuild index 99a9a5db..7d6947f4 100755 --- a/source/d/distcc/distcc.SlackBuild +++ b/source/d/distcc/distcc.SlackBuild @@ -1,6 +1,6 @@ -#!/bin/sh +#!/bin/bash -# Copyright 2008, 2009, 2010, 2013 Patrick J. Volkerding, Sebeka, MN, USA +# Copyright 2008, 2009, 2010, 2013, 2018 Patrick J. Volkerding, Sebeka, MN, USA # All rights reserved. # # Redistribution and use of this script, with or without modification, is @@ -20,23 +20,32 @@ # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +cd $(dirname $0) ; CWD=$(pwd) -VERSION=3.1 -BUILD=${BUILD:-1} +PKGNAM=distcc +VERSION=${VERSION:-$(echo $PKGNAM-*.tar.?z | rev | cut -f 3- -d . | cut -f 1 -d - | rev)} +BUILD=${BUILD:-2} # Automatically determine the architecture we're building on: if [ -z "$ARCH" ]; then case "$( uname -m )" in - i?86) export ARCH=i486 ;; + i?86) export ARCH=i586 ;; arm*) export ARCH=arm ;; # Unless $ARCH is already set, use uname -m for all other archs: *) export ARCH=$( uname -m ) ;; esac fi +# If the variable PRINT_PACKAGE_NAME is set, then this script will report what +# the name of the created package would be, and then exit. This information +# could be useful to other scripts. +if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then + echo "$PKGNAM-$VERSION-$ARCH-$BUILD.txz" + exit 0 +fi + NUMJOBS=${NUMJOBS:-" -j7 "} -CWD=$(pwd) TMP=${TMP:-/tmp} PKG=$TMP/package-distcc @@ -45,7 +54,7 @@ mkdir -p $TMP $PKG cd $TMP rm -rf distcc-$VERSION -tar xvf $CWD/distcc-$VERSION.tar.xz || exit 1 +tar xvf $CWD/distcc-$VERSION.tar.?z || exit 1 cd distcc-$VERSION || exit 1 chown -R root:root . find . \ @@ -62,7 +71,7 @@ find . \ --without-gnome \ --without-avahi \ --disable-Werror \ - --target=$ARCH-slackware-linux + --target=$ARCH-slackware-linux || exit 1 make $NUMJOBS || make || exit 1 make install DESTDIR=$PKG docdir=/usr/doc/distcc-$VERSION || exit 1 diff --git a/source/d/distcc/distcc.url b/source/d/distcc/distcc.url new file mode 100644 index 00000000..493d7c8e --- /dev/null +++ b/source/d/distcc/distcc.url @@ -0,0 +1 @@ +https://github.com/distcc/distcc diff --git a/source/d/distcc/slack-desc b/source/d/distcc/slack-desc index 121e9722..431c46ca 100644 --- a/source/d/distcc/slack-desc +++ b/source/d/distcc/slack-desc @@ -1,19 +1,19 @@ # HOW TO EDIT THIS FILE: -# The "handy ruler" below makes it easier to edit a package description. Line +# The "handy ruler" below makes it easier to edit a package description. Line # up the first '|' above the ':' following the base package name, and the '|' -# on the right side marks the last column you can put a character in. You must -# make exactly 11 lines for the formatting to be correct. It's also +# on the right side marks the last column you can put a character in. You must +# make exactly 11 lines for the formatting to be correct. It's also # customary to leave one space after the ':'. |-----handy-ruler------------------------------------------------------| distcc: distcc (distributed C/C++ compiler/daemon) distcc: distcc: distcc allows compilation of C code to be distributed across several -distcc: machines on a network. distcc should always generate the same results +distcc: machines on a network. distcc should always generate the same results distcc: as a local compile, is simple to install and use, and is often distcc: significantly faster than a local compile. distcc: -distcc: IMPORTANT SECURITY NOTE: distccd should only run on trusted networks. +distcc: IMPORTANT SECURITY NOTE: distccd should only run on trusted networks. distcc: distcc: distcc was written by Martin Pool. distcc: diff --git a/source/d/doxygen/doxygen.9468ede.diff b/source/d/doxygen/doxygen.9468ede.diff new file mode 100644 index 00000000..b189a85a --- /dev/null +++ b/source/d/doxygen/doxygen.9468ede.diff @@ -0,0 +1,52 @@ +From 9468ede259153cf79eb8d61635389744e9a2ee7d Mon Sep 17 00:00:00 2001 +From: Dimitri van Heesch <dimitri@stack.nl> +Date: Sun, 29 Oct 2017 11:47:48 +0100 +Subject: [PATCH] Bug 789168 - Increasing access of inherited C++ members with + 'using...' is not recognized by Doxygen + +--- + src/doxygen.cpp | 9 ++++----- + 1 file changed, 4 insertions(+), 5 deletions(-) + +diff --git a/src/doxygen.cpp b/src/doxygen.cpp +index d3554cffd..ec97d4354 100644 +--- a/src/doxygen.cpp ++++ b/src/doxygen.cpp +@@ -2112,9 +2112,8 @@ static void findUsingDeclImports(EntryNav *rootNav) + (rootNav->parent()->section()&Entry::COMPOUND_MASK) // in a class/struct member + ) + { +- //printf("Found using declaration %s at line %d of %s inside section %x\n", +- // root->name.data(),root->startLine,root->fileName.data(), +- // root->parent->section); ++ //printf("Found using declaration %s inside section %x\n", ++ // rootNav->name().data(), rootNav->parent()->section()); + QCString fullName=removeRedundantWhiteSpace(rootNav->parent()->name()); + fullName=stripAnonymousNamespaceScope(fullName); + fullName=stripTemplateSpecifiersFromScope(fullName); +@@ -2130,7 +2129,7 @@ static void findUsingDeclImports(EntryNav *rootNav) + ClassDef *bcd = getResolvedClass(cd,0,scope); // todo: file in fileScope parameter + if (bcd) + { +- //printf("found class %s\n",bcd->name().data()); ++ //printf("found class %s memName=%s\n",bcd->name().data(),memName.data()); + MemberNameInfoSDict *mndict=bcd->memberNameInfoSDict(); + if (mndict) + { +@@ -11181,7 +11180,6 @@ void parseInput() + g_s.end(); + + g_s.begin("Searching for members imported via using declarations...\n"); +- findUsingDeclImports(rootNav); + // this should be after buildTypedefList in order to properly import + // used typedefs + findUsingDeclarations(rootNav); +@@ -11249,6 +11247,7 @@ void parseInput() + g_s.begin("Searching for member function documentation...\n"); + findObjCMethodDefinitions(rootNav); + findMemberDocumentation(rootNav); // may introduce new members ! ++ findUsingDeclImports(rootNav); // may introduce new members ! + + transferRelatedFunctionDocumentation(); + transferFunctionDocumentation(); + diff --git a/source/d/doxygen/doxygen.SlackBuild b/source/d/doxygen/doxygen.SlackBuild index 2a4a0733..ce86b9f4 100755 --- a/source/d/doxygen/doxygen.SlackBuild +++ b/source/d/doxygen/doxygen.SlackBuild @@ -1,6 +1,6 @@ -#!/bin/sh +#!/bin/bash -# Copyright 2008, 2009, 2010 Patrick J. Volkerding, Sebeka, MN, USA +# Copyright 2008, 2009, 2010, 2018 Patrick J. Volkerding, Sebeka, MN, USA # All rights reserved. # # Redistribution and use of this script, with or without modification, is @@ -20,24 +20,34 @@ # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +cd $(dirname $0) ; CWD=$(pwd) -VERSION=${VERSION:-$(basename $(echo doxygen-*.tar.?z* | rev | cut -f 3- -d . | cut -f 1 -d - | rev) .src)} -BUILD=${BUILD:-1} +PKGNAM=doxygen +VERSION=${VERSION:-$(basename $(echo doxygen-*.tar.?z | rev | cut -f 3- -d . | cut -f 1 -d - | rev) .src)} +BUILD=${BUILD:-3} NUMJOBS=${NUMJOBS:-" -j7 "} # Automatically determine the architecture we're building on: if [ -z "$ARCH" ]; then case "$( uname -m )" in - i?86) export ARCH=i486 ;; + i?86) export ARCH=i586 ;; arm*) export ARCH=arm ;; # Unless $ARCH is already set, use uname -m for all other archs: *) export ARCH=$( uname -m ) ;; esac fi -if [ "$ARCH" = "i486" ]; then - SLKCFLAGS="-O2 -march=i486 -mtune=i686" +# If the variable PRINT_PACKAGE_NAME is set, then this script will report what +# the name of the created package would be, and then exit. This information +# could be useful to other scripts. +if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then + echo "$PKGNAM-$VERSION-$ARCH-$BUILD.txz" + exit 0 +fi + +if [ "$ARCH" = "i586" ]; then + SLKCFLAGS="-O2 -march=i586 -mtune=i686" LIBDIRSUFFIX="" elif [ "$ARCH" = "i686" ]; then SLKCFLAGS="-O2 -march=i686 -mtune=i686" @@ -50,7 +60,6 @@ else LIBDIRSUFFIX="" fi -CWD=$(pwd) TMP=${TMP:-/tmp} PKG=$TMP/package-doxygen @@ -58,8 +67,8 @@ rm -rf $PKG mkdir -p $TMP $PKG cd $TMP rm -rf doxygen-$VERSION -tar xvf $CWD/doxygen-${VERSION}.src.tar.?z* || exit 1 -cd doxygen-$VERSION +tar xvf $CWD/doxygen-${VERSION}.src.tar.?z || exit 1 +cd doxygen-$VERSION || exit 1 chown -R root:root . find . \ \( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \ @@ -67,25 +76,38 @@ find . \ \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \ -exec chmod 644 {} \; -CFLAGS="$SLKCFLAGS" \ -CXXFLAGS="$SLKCFLAGS" \ -QTDIR=/usr/lib${LIBDIRSUFFIX}/qt \ -./configure \ - --shared \ - --release \ - --prefix /usr \ - --docdir /usr/doc/doxygen-$VERSION \ - --with-doxywizard - -make $NUMJOBS || make || exit 1 -make install INSTALL=$PKG/usr DOCDIR=$PKG/usr/doc/doxygen-$VERSION -make install_docs INSTALL=$PKG/usr DOCDIR=$PKG/usr/doc/doxygen-$VERSION +# Revert patch that leads to segfaults: +zcat $CWD/doxygen.9468ede.diff.gz | patch -p1 -R --verbose || exit 1 + +mkdir build +cd build + cmake \ + -DCMAKE_C_FLAGS:STRING="$SLKCFLAGS" \ + -DCMAKE_CXX_FLAGS:STRING="$SLKCFLAGS" \ + -DCMAKE_INSTALL_PREFIX=/usr \ + -DCMAKE_BUILD_TYPE=Release \ + -DDOC_INSTALL_DIR:STRING="/doc/doxygen-$VERSION" \ + -Dbuild_app=yes \ + -Dbuild_doc=yes \ + -Dbuild_parse=yes \ + -Dbuild_search=yes \ + -Dbuild_wizard=yes \ + -Dbuild_xmlparser=yes \ + -Duse_sqlite3=yes \ + -G "Unix Makefiles" .. || exit 1 + make $NUMJOBS || make || exit 1 + make $NUMJOBS docs || make docs || exit 1 + make install DESTDIR=$PKG || exit 1 +cd .. find $PKG | xargs file | grep -e "executable" -e "shared object" | grep ELF \ | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null -# If there are misplaced man pages, fix that: -mv $PKG/usr/*.1 $PKG/usr/man/man1 +# Fix manpage location +mv $PKG/usr/share/man $PKG/usr/man + +# Removed unused /usr/share +rmdir $PKG/usr/share 2>/dev/null # Compress and if needed symlink the man pages: if [ -d $PKG/usr/man ]; then diff --git a/source/d/doxygen/slack-desc b/source/d/doxygen/slack-desc index df95eb7b..8220d232 100644 --- a/source/d/doxygen/slack-desc +++ b/source/d/doxygen/slack-desc @@ -1,17 +1,17 @@ # HOW TO EDIT THIS FILE: -# The "handy ruler" below makes it easier to edit a package description. Line +# The "handy ruler" below makes it easier to edit a package description. Line # up the first '|' above the ':' following the base package name, and the '|' -# on the right side marks the last column you can put a character in. You must -# make exactly 11 lines for the formatting to be correct. It's also +# on the right side marks the last column you can put a character in. You must +# make exactly 11 lines for the formatting to be correct. It's also # customary to leave one space after the ':'. |-----handy-ruler------------------------------------------------------| doxygen: doxygen (documentation generator) doxygen: doxygen: Doxygen is a documentation system for C++, C, Java, IDL, and to some -doxygen: extent PHP and C#. Doxygen generates project documentation using +doxygen: extent PHP and C#. Doxygen generates project documentation using doxygen: special documentation blocks in the source code, easing the process of -doxygen: keeping docs and code in sync. Doxygen produces documentation in +doxygen: keeping docs and code in sync. Doxygen produces documentation in doxygen: several output formats, including HTML, LaTeX, man pages, RTF, XML, doxygen: compressed HTML, PostScript, and PDF. doxygen: diff --git a/source/d/flex/flex.SlackBuild b/source/d/flex/flex.SlackBuild index b79f0e76..76956313 100755 --- a/source/d/flex/flex.SlackBuild +++ b/source/d/flex/flex.SlackBuild @@ -1,6 +1,6 @@ -#!/bin/sh +#!/bin/bash -# Copyright 2006, 2007, 2008, 2009, 2010, 2013 Patrick J. Volkerding, Sebeka, MN, USA +# Copyright 2006, 2007, 2008, 2009, 2010, 2013, 2017, 2018 Patrick J. Volkerding, Sebeka, MN, USA # All rights reserved. # # Redistribution and use of this script, with or without modification, is @@ -20,10 +20,11 @@ # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +cd $(dirname $0) ; CWD=$(pwd) PKGNAM=flex -VERSION=${VERSION:-$(echo $PKGNAM-*.tar.?z* | rev | cut -f 3- -d . | cut -f 1 -d - | rev)} -BUILD=${BUILD:-1} +VERSION=${VERSION:-$(echo $PKGNAM-*.tar.lz | rev | cut -f 3- -d . | cut -f 1 -d - | rev)} +BUILD=${BUILD:-3} # Automatically determine the architecture we're building on: if [ -z "$ARCH" ]; then @@ -35,9 +36,16 @@ if [ -z "$ARCH" ]; then esac fi +# If the variable PRINT_PACKAGE_NAME is set, then this script will report what +# the name of the created package would be, and then exit. This information +# could be useful to other scripts. +if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then + echo "$PKGNAM-$VERSION-$ARCH-$BUILD.txz" + exit 0 +fi + NUMJOBS=${NUMJOBS:-" -j7 "} -CWD=$(pwd) TMP=${TMP:-/tmp} PKG=$TMP/package-${PKGNAM} @@ -60,7 +68,7 @@ fi cd $TMP rm -rf ${PKGNAM}-${VERSION} -tar xvf $CWD/${PKGNAM}-$VERSION.tar.xz || exit 1 +tar xvf $CWD/${PKGNAM}-$VERSION.tar.lz || exit 1 cd ${PKGNAM}-$VERSION # Make sure ownerships and permissions are sane: @@ -71,6 +79,9 @@ find . \ \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \ -exec chmod 644 {} \; +# Fix an issue introduced with recent glibc versions. Thanks to LFS: +sed -i "/math.h/a #include <malloc.h>" src/flexdef.h + # Configure: CFLAGS="$SLKCFLAGS" \ ./configure \ @@ -79,12 +90,15 @@ CFLAGS="$SLKCFLAGS" \ --mandir=/usr/man \ --infodir=/usr/info \ --docdir=/usr/doc/flex-${VERSION} \ - --build=$ARCH-slackware-linux + --build=$ARCH-slackware-linux || exit 1 # Build and install: make $NUMJOBS || make || exit 1 make install DESTDIR=$PKG || exit 1 +# Don't ship .la files: +rm -f $PKG/{,usr/}lib${LIBDIRSUFFIX}/*.la + # A symlink to harken back to the Goodle days: ( cd $PKG/usr/bin ; ln -sf flex lex ) diff --git a/source/d/flex/slack-desc b/source/d/flex/slack-desc index 0fe0399d..6e7274a9 100644 --- a/source/d/flex/slack-desc +++ b/source/d/flex/slack-desc @@ -1,19 +1,19 @@ # HOW TO EDIT THIS FILE: -# The "handy ruler" below makes it easier to edit a package description. Line +# The "handy ruler" below makes it easier to edit a package description. Line # up the first '|' above the ':' following the base package name, and the '|' -# on the right side marks the last column you can put a character in. You must -# make exactly 11 lines for the formatting to be correct. It's also +# on the right side marks the last column you can put a character in. You must +# make exactly 11 lines for the formatting to be correct. It's also # customary to leave one space after the ':'. |-----handy-ruler------------------------------------------------------| flex: flex (fast lexical analyzer generator) flex: flex: flex is a tool for generating programs that perform pattern matching -flex: on text. flex is a rewrite of the AT&T Unix lex tool (the two +flex: on text. flex is a rewrite of the AT&T Unix lex tool (the two flex: implementations do not share any code, though), with some extensions flex: (and incompatibilities). flex: -flex: +flex: Homepage: https://github.com/westes/flex flex: flex: flex: diff --git a/source/d/gcc/antlr-runtime-3.4.jar b/source/d/gcc/antlr-runtime-3.4.jar Binary files differdeleted file mode 100644 index 865a537b..00000000 --- a/source/d/gcc/antlr-runtime-3.4.jar +++ /dev/null diff --git a/source/d/gcc/create_gcj_jvm.sh b/source/d/gcc/create_gcj_jvm.sh deleted file mode 100644 index d1011860..00000000 --- a/source/d/gcc/create_gcj_jvm.sh +++ /dev/null @@ -1,93 +0,0 @@ -# --------------------------------------------------------------------------- -# This script creates a directory structure below /usr/lib/jvm and populates -# it with symlinks to GCC binaries. -# This will work as a compatibility layer to emulate an Oracle JDK/JRE. -# This emulation is required in order to compile OpenJDK using GNU java. -# -# The same can automatically be achieved in Slackware's gcc packages if -# the 'configure' command is called with the following additional parameters: -# --enable-java-home \ -# --with-java-home=/usr/lib$LIBDIRSUFFIX/jvm/jre \ -# --with-jvm-root-dir=/usr/lib$LIBDIRSUFFIX/jvm \ -# --with-jvm-jar-dir=/usr/lib$LIBDIRSUFFIX/jvm/jvm-exports \ -# --with-arch-directory=$LIB_ARCH \ -# -# Author: Eric Hameleers <alien@slackware.com> December 2011 -# --------------------------------------------------------------------------- - -# Automatically determine the architecture we're building on: -if [ -z "$ARCH" ]; then - case "$( uname -m )" in - i?86) export ARCH=i486 ;; - arm*) export ARCH=arm ;; - # Unless $ARCH is already set, use uname -m for all other archs: - *) export ARCH=$( uname -m ) ;; - esac -fi - -if [ "$ARCH" = "i486" ]; then - SLKCFLAGS="-O2 -march=i486 -mtune=i686" - LIBDIRSUFFIX="" - LIB_ARCH=i386 -elif [ "$ARCH" = "i686" ]; then - SLKCFLAGS="-O2 -march=i686 -mtune=i686" - LIBDIRSUFFIX="" - LIB_ARCH=i386 -elif [ "$ARCH" = "x86_64" ]; then - SLKCFLAGS="-O2 -fPIC" - LIBDIRSUFFIX="64" - LIB_ARCH=amd64 -else - SLKCFLAGS="-O2" - LIBDIRSUFFIX="" - LIB_ARCH=$ARCH -fi - -# Where does the OpenJDK SlackBuild expect the GNU java compatibility symlinks: -JVM=${1:-/usr/lib${LIBDIRSUFFIX}/jvm} -BINDIR=/usr/bin - -# What version of GCC do we have installed: -GCJVER=$(gcj -dumpversion) - -# First, remove the old set of symlinks if they should exist: -rm -fr $JVM - -# Create a JDK compatible directory structure for GNU java: -mkdir -p $JVM -mkdir -p $JVM/bin -mkdir -p $JVM/jre/bin -mkdir -p $JVM/jre/lib/${LIB_ARCH}/client -mkdir -p $JVM/jre/lib/${LIB_ARCH}/server -mkdir -p $JVM/lib - -ln -sf $BINDIR/gjar $JVM/bin/jar -ln -sf $BINDIR/grmic $JVM/bin/rmic -ln -sf $BINDIR/gjavah $JVM/bin/javah -ln -sf $BINDIR/jcf-dump $JVM/bin/javap -ln -sf $BINDIR/gappletviewer $JVM/bin/appletviewer -ln -sf $BINDIR/grmiregistry $JVM/bin/rmiregistry -ln -sf $BINDIR/grmiregistry $JVM/jre/bin/rmiregistry -ln -sf $BINDIR/gkeytool $JVM/bin/keytool -ln -sf $BINDIR/gkeytool $JVM/jre/bin/keytool -ln -sf $BINDIR/gij $JVM/bin/java -ln -sf $BINDIR/ecj $JVM/bin/javac -ln -sf /usr/lib/gcj-${GCJVER}-11/libjvm.so $JVM/jre/lib/${LIB_ARCH}/client/libjvm.so -ln -sf /usr/lib/gcj-${GCJVER}-11/libjvm.so $JVM/jre/lib/${LIB_ARCH}/server/libjvm.so -ln -sf /usr/lib/gcj-${GCJVER}-11/libjawt.so $JVM/jre/lib/${LIB_ARCH}/libjawt.so -ln -sf /usr/share/java/libgcj-${GCJVER}.jar $JVM/jre/lib/rt.jar -ln -sf /usr/share/java/libgcj-tools-${GCJVER}.jar $JVM/lib/tools.jar -ln -sf /usr/include/c++/${GCJVER}/gnu/java $JVM/include - -# Add a Eclipse Java Compiler wrapper which is required -# for bootstrapping OpenJDK using GNU java: -cat <<EOT > /usr/bin/ecj -#!/bin/sh - -CLASSPATH=/usr/share/java/ecj.jar\${CLASSPATH:+:}\$CLASSPATH \ - java org.eclipse.jdt.internal.compiler.batch.Main "\$@" - -EOT -chmod 755 /usr/bin/ecj - - diff --git a/source/d/gcc/ecj-4.9.jar b/source/d/gcc/ecj-4.9.jar Binary files differdeleted file mode 100644 index 29dc442f..00000000 --- a/source/d/gcc/ecj-4.9.jar +++ /dev/null diff --git a/source/d/gcc/ecj.sh b/source/d/gcc/ecj.sh deleted file mode 100644 index 1d8b7979..00000000 --- a/source/d/gcc/ecj.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh - -CLASSPATH=@JAVADIR@/ecj.jar${CLASSPATH:+:}$CLASSPATH \ - java org.eclipse.jdt.internal.compiler.batch.Main "$@" - diff --git a/source/d/gcc/ecj.url b/source/d/gcc/ecj.url deleted file mode 100644 index 9a28b2ce..00000000 --- a/source/d/gcc/ecj.url +++ /dev/null @@ -1 +0,0 @@ -ftp://sourceware.org/pub/java/ecj-4.9.jar diff --git a/source/d/gcc/fastjar-patches/1000-fastjar-0.97-segfault.patch b/source/d/gcc/fastjar-patches/1000-fastjar-0.97-segfault.patch deleted file mode 100644 index ab626240..00000000 --- a/source/d/gcc/fastjar-patches/1000-fastjar-0.97-segfault.patch +++ /dev/null @@ -1,29 +0,0 @@ -2009-01-14 Jakub Jelinek <jakub@redhat.com> - - * jartool.c (make_manifest): Initialize current_time before - calling unix2dostime on it. - ---- fastjar-0.97/jartool.c.jj 2008-10-15 18:35:37.000000000 +0200 -+++ fastjar-0.97/jartool.c 2009-01-14 15:40:50.000000000 +0100 -@@ -820,6 +820,10 @@ int make_manifest(int jfd, const char *m - int mod_time; /* file modification time */ - struct zipentry *ze; - -+ current_time = time(NULL); -+ if(current_time == (time_t)-1) -+ exit_on_error("time"); -+ - mod_time = unix2dostime(¤t_time); - - /* If we are creating a new manifest, create a META-INF directory entry */ -@@ -828,10 +832,6 @@ int make_manifest(int jfd, const char *m - - memset((file_header + 12), '\0', 16); /*clear mod time, crc, size fields*/ - -- current_time = time(NULL); -- if(current_time == (time_t)-1) -- exit_on_error("time"); -- - PACK_UB2(file_header, LOC_EXTRA, 0); - PACK_UB2(file_header, LOC_COMP, 0); - PACK_UB2(file_header, LOC_FNLEN, nlen); diff --git a/source/d/gcc/fastjar-patches/1001-fastjar-0.97-len1.patch b/source/d/gcc/fastjar-patches/1001-fastjar-0.97-len1.patch deleted file mode 100644 index 722351d3..00000000 --- a/source/d/gcc/fastjar-patches/1001-fastjar-0.97-len1.patch +++ /dev/null @@ -1,16 +0,0 @@ -2009-12-21 Chris Ball <cjb@laptop.org> - - * jartool.c (add_file_to_jar): Test write return value against -1 - instead of 1. - ---- fastjar-0.97/jartool.c.jj 2008-10-15 12:35:37.000000000 -0400 -+++ fastjar-0.97/jartool.c 2009-12-22 06:48:09.309530000 -0500 -@@ -1257,7 +1257,7 @@ int add_file_to_jar(int jfd, int ffd, co - exit_on_error("write"); - - /* write the file name to the zip file */ -- if (1 == write(jfd, fname, file_name_length)) -+ if (-1 == write(jfd, fname, file_name_length)) - exit_on_error("write"); - - if(verbose){ diff --git a/source/d/gcc/fastjar-patches/1002-fastjar-0.97-filename0.patch b/source/d/gcc/fastjar-patches/1002-fastjar-0.97-filename0.patch deleted file mode 100644 index 34a02a74..00000000 --- a/source/d/gcc/fastjar-patches/1002-fastjar-0.97-filename0.patch +++ /dev/null @@ -1,14 +0,0 @@ -2010-03-01 Richard Guenther <rguenther@suse.de> - - * jartool.c (read_entries): Properly zero-terminate filename. - ---- fastjar-0.97/jartool.c 6 Sep 2009 22:16:00 -0000 1.59 -+++ fastjar-0.97/jartool.c 1 Mar 2010 15:38:43 -0000 1.60 -@@ -790,6 +790,7 @@ int read_entries (int fd) - progname, jarfile); - return 1; - } -+ ze->filename[len] = '\0'; - len = UNPACK_UB4(header, CEN_EFLEN); - len += UNPACK_UB4(header, CEN_COMLEN); - if (lseek (fd, len, SEEK_CUR) == -1) diff --git a/source/d/gcc/fastjar-patches/1003-fastjar-CVE-2010-0831.patch b/source/d/gcc/fastjar-patches/1003-fastjar-CVE-2010-0831.patch deleted file mode 100644 index 2c6e23c7..00000000 --- a/source/d/gcc/fastjar-patches/1003-fastjar-CVE-2010-0831.patch +++ /dev/null @@ -1,102 +0,0 @@ -2010-06-10 Jakub Jelinek <jakub@redhat.com> - Dan Rosenberg <dan.j.rosenberg@gmail.com> - - * jartool.c (extract_jar): Fix up checks for traversal to parent - directories, disallow absolute paths, make the code slightly more - efficient. - ---- fastjar-0.97/jartool.c.jj 2009-09-07 00:10:47.000000000 +0200 -+++ fastjar-0.97/jartool.c 2010-06-08 20:00:29.000000000 +0200 -@@ -1730,7 +1730,17 @@ int extract_jar(int fd, const char **fil - struct stat sbuf; - int depth = 0; - -- tmp_buff = malloc(sizeof(char) * strlen((const char *)filename)); -+ if(*filename == '/'){ -+ fprintf(stderr, "Absolute path names are not allowed.\n"); -+ exit(EXIT_FAILURE); -+ } -+ -+ tmp_buff = malloc(strlen((const char *)filename)); -+ -+ if(tmp_buff == NULL) { -+ fprintf(stderr, "Out of memory.\n"); -+ exit(EXIT_FAILURE); -+ } - - for(;;){ - const ub1 *idx = (const unsigned char *)strchr((const char *)start, '/'); -@@ -1738,25 +1748,28 @@ int extract_jar(int fd, const char **fil - if(idx == NULL) - break; - else if(idx == start){ -+ tmp_buff[idx - filename] = '/'; - start++; - continue; - } -- start = idx + 1; - -- strncpy(tmp_buff, (const char *)filename, (idx - filename)); -- tmp_buff[(idx - filename)] = '\0'; -+ memcpy(tmp_buff + (start - filename), (const char *)start, (idx - start)); -+ tmp_buff[idx - filename] = '\0'; - - #ifdef DEBUG - printf("checking the existance of %s\n", tmp_buff); - #endif -- if(strcmp(tmp_buff, "..") == 0){ -+ if(idx - start == 2 && memcmp(start, "..", 2) == 0){ - --depth; - if (depth < 0){ - fprintf(stderr, "Traversal to parent directories during unpacking!\n"); - exit(EXIT_FAILURE); - } -- } else if (strcmp(tmp_buff, ".") != 0) -+ } else if (idx - start != 1 || *start != '.') - ++depth; -+ -+ start = idx + 1; -+ - if(stat(tmp_buff, &sbuf) < 0){ - if(errno != ENOENT) - exit_on_error("stat"); -@@ -1765,6 +1778,7 @@ int extract_jar(int fd, const char **fil - #ifdef DEBUG - printf("Directory exists\n"); - #endif -+ tmp_buff[idx - filename] = '/'; - continue; - }else { - fprintf(stderr, "Hmmm.. %s exists but isn't a directory!\n", -@@ -1781,10 +1795,11 @@ int extract_jar(int fd, const char **fil - if(verbose && handle) - printf("%10s: %s/\n", "created", tmp_buff); - -+ tmp_buff[idx - filename] = '/'; - } - - /* only a directory */ -- if(strlen((const char *)start) == 0) -+ if(*start == '\0') - dir = TRUE; - - #ifdef DEBUG -@@ -1792,7 +1807,7 @@ int extract_jar(int fd, const char **fil - #endif - - /* If the entry was just a directory, don't write to file, etc */ -- if(strlen((const char *)start) == 0) -+ if(*start == '\0') - f_fd = -1; - - free(tmp_buff); -@@ -1876,7 +1891,8 @@ int extract_jar(int fd, const char **fil - exit(EXIT_FAILURE); - } - -- close(f_fd); -+ if (f_fd != -1) -+ close(f_fd); - - if(verbose && dir == FALSE && handle) - printf("%10s: %s\n", diff --git a/source/d/gcc/fastjar-patches/1004-fastjar-man.patch b/source/d/gcc/fastjar-patches/1004-fastjar-man.patch deleted file mode 100644 index 34bf704d..00000000 --- a/source/d/gcc/fastjar-patches/1004-fastjar-man.patch +++ /dev/null @@ -1,27 +0,0 @@ -2010-03-24 Jan Kratochvil <jan.kratochvil@redhat.com> - - * Makefile.am (POD2MAN): Provide --date from ChangeLog. - * Makefile.in: Regenerate. - ---- fastjar-0.97/Makefile.am.jj 2008-10-16 04:24:55.000000000 -0400 -+++ fastjar-0.97/Makefile.am 2010-06-21 09:29:41.021398000 -0400 -@@ -39,7 +39,7 @@ EXTRA_DIST = \ - texi2pod.pl - - TEXI2POD = perl $(srcdir)/texi2pod.pl --POD2MAN = pod2man --center="GNU" --release=@VERSION@ -+POD2MAN = pod2man --center="GNU" --release=@VERSION@ --date=$(shell sed -n '1s/ .*//p' <$(srcdir)/ChangeLog) - - .pod.1: - -($(POD2MAN) --section=1 $< > $(@).T$$$$ && \ ---- fastjar-0.97/Makefile.in.jj 2008-10-16 04:15:16.000000000 -0400 -+++ fastjar-0.97/Makefile.in 2010-06-21 09:30:15.882810000 -0400 -@@ -515,7 +515,7 @@ EXTRA_DIST = \ - texi2pod.pl - - TEXI2POD = perl $(srcdir)/texi2pod.pl --POD2MAN = pod2man --center="GNU" --release=@VERSION@ -+POD2MAN = pod2man --center="GNU" --release=@VERSION@ --date=$(shell sed -n '1s/ .*//p' <$(srcdir)/ChangeLog) - - #SPLINT_FLAGS=-I . -I $(srcdir)/lib -I $(srcdir) -DHAVE_CONFIG_H +posixlib +weak - SPLINT_FLAGS = -I . -I $(srcdir)/lib -I $(srcdir) -DHAVE_CONFIG_H -DPRIx32= -warnposix +weak diff --git a/source/d/gcc/gcc.66782.diff b/source/d/gcc/gcc.66782.diff deleted file mode 100644 index 0743f885..00000000 --- a/source/d/gcc/gcc.66782.diff +++ /dev/null @@ -1,124 +0,0 @@ -Index: config/i386/i386.md -=================================================================== ---- config/i386/i386.md (revision 225539) -+++ config/i386/i386.md (working copy) -@@ -108,6 +108,7 @@ - UNSPEC_LD_MPIC ; load_macho_picbase - UNSPEC_TRUNC_NOOP - UNSPEC_DIV_ALREADY_SPLIT -+ UNSPEC_MS_TO_SYSV_CALL - UNSPEC_PAUSE - UNSPEC_LEA_ADDR - UNSPEC_XBEGIN_ABORT -@@ -11584,6 +11585,15 @@ - "* return ix86_output_call_insn (insn, operands[0]);" - [(set_attr "type" "call")]) - -+(define_insn "*call_rex64_ms_sysv" -+ [(match_parallel 2 "call_rex64_ms_sysv_operation" -+ [(call (mem:QI (match_operand:DI 0 "call_insn_operand" "rBwBz")) -+ (match_operand 1)) -+ (unspec [(const_int 0)] UNSPEC_MS_TO_SYSV_CALL)])] -+ "TARGET_64BIT && !SIBLING_CALL_P (insn)" -+ "* return ix86_output_call_insn (insn, operands[0]);" -+ [(set_attr "type" "call")]) -+ - (define_insn "*sibcall" - [(call (mem:QI (match_operand:W 0 "sibcall_insn_operand" "UBsBz")) - (match_operand 1))] -@@ -11808,6 +11818,16 @@ - (match_dup 3))) - (unspec [(const_int 0)] UNSPEC_PEEPSIB)])]) - -+(define_insn "*call_value_rex64_ms_sysv" -+ [(match_parallel 3 "call_rex64_ms_sysv_operation" -+ [(set (match_operand 0) -+ (call (mem:QI (match_operand:DI 1 "call_insn_operand" "rBwBz")) -+ (match_operand 2))) -+ (unspec [(const_int 0)] UNSPEC_MS_TO_SYSV_CALL)])] -+ "TARGET_64BIT && !SIBLING_CALL_P (insn)" -+ "* return ix86_output_call_insn (insn, operands[1]);" -+ [(set_attr "type" "callv")]) -+ - (define_expand "call_value_pop" - [(parallel [(set (match_operand 0) - (call (match_operand:QI 1) -Index: config/i386/predicates.md -=================================================================== ---- config/i386/predicates.md (revision 225533) -+++ config/i386/predicates.md (working copy) -@@ -616,6 +616,36 @@ - && XINT (XEXP (op, 0), 1) == UNSPEC_GOTPCREL); - }) - -+;; Return true if OP is a call from MS ABI to SYSV ABI function. -+(define_predicate "call_rex64_ms_sysv_operation" -+ (match_code "parallel") -+{ -+ unsigned creg_size = ARRAY_SIZE (x86_64_ms_sysv_extra_clobbered_registers); -+ unsigned i; -+ -+ if ((unsigned) XVECLEN (op, 0) != creg_size + 2) -+ return false; -+ -+ for (i = 0; i < creg_size; i++) -+ { -+ rtx elt = XVECEXP (op, 0, i+2); -+ enum machine_mode mode; -+ unsigned regno; -+ -+ if (GET_CODE (elt) != CLOBBER -+ || GET_CODE (SET_DEST (elt)) != REG) -+ return false; -+ -+ regno = x86_64_ms_sysv_extra_clobbered_registers[i]; -+ mode = SSE_REGNO_P (regno) ? TImode : DImode; -+ -+ if (GET_MODE (SET_DEST (elt)) != mode -+ || REGNO (SET_DEST (elt)) != regno) -+ return false; -+ } -+ return true; -+}) -+ - ;; Match exactly zero. - (define_predicate "const0_operand" - (match_code "const_int,const_wide_int,const_double,const_vector") -Index: config/i386/i386.c -=================================================================== ---- config/i386/i386.c (revision 225533) -+++ config/i386/i386.c (working copy) -@@ -25639,7 +25639,9 @@ - rtx callarg2, - rtx pop, bool sibcall) - { -- rtx vec[3]; -+ unsigned int const cregs_size -+ = ARRAY_SIZE (x86_64_ms_sysv_extra_clobbered_registers); -+ rtx vec[3 + cregs_size]; - rtx use = NULL, call; - unsigned int vec_len = 0; - -@@ -25742,16 +25744,18 @@ - if (TARGET_64BIT_MS_ABI - && (!callarg2 || INTVAL (callarg2) != -2)) - { -- int const cregs_size -- = ARRAY_SIZE (x86_64_ms_sysv_extra_clobbered_registers); -- int i; -+ unsigned i; - -+ vec[vec_len++] = gen_rtx_UNSPEC (VOIDmode, gen_rtvec (1, const0_rtx), -+ UNSPEC_MS_TO_SYSV_CALL); -+ - for (i = 0; i < cregs_size; i++) - { - int regno = x86_64_ms_sysv_extra_clobbered_registers[i]; - machine_mode mode = SSE_REGNO_P (regno) ? TImode : DImode; - -- clobber_reg (&use, gen_rtx_REG (mode, regno)); -+ vec[vec_len++] -+ = gen_rtx_CLOBBER (VOIDmode, gen_rtx_REG (mode, regno)); - } - } - diff --git a/source/d/gcc/gcc.69140.diff b/source/d/gcc/gcc.69140.diff deleted file mode 100644 index ace60ebd..00000000 --- a/source/d/gcc/gcc.69140.diff +++ /dev/null @@ -1,13 +0,0 @@ ---- ./gcc/config/i386/i386.c.orig 2015-11-18 09:45:26.000000000 -0600 -+++ ./gcc/config/i386/i386.c 2016-02-05 13:50:07.202981920 -0600 -@@ -9677,6 +9677,10 @@ - if (TARGET_64BIT_MS_ABI && get_frame_size () > SEH_MAX_FRAME_SIZE) - return true; - -+ /* SSE saves require frame-pointer when stack is misaligned. */ -+ if (TARGET_64BIT_MS_ABI && ix86_incoming_stack_boundary < 128) -+ return true; -+ - /* In ix86_option_override_internal, TARGET_OMIT_LEAF_FRAME_POINTER - turns off the frame pointer by default. Turn it back on now if - we've not got a leaf function. */ diff --git a/source/d/gcc/gcc.SlackBuild b/source/d/gcc/gcc.SlackBuild index f23ed521..f16f923c 100755 --- a/source/d/gcc/gcc.SlackBuild +++ b/source/d/gcc/gcc.SlackBuild @@ -1,8 +1,8 @@ -#!/bin/sh +#!/bin/bash # GCC package build script (written by volkerdi@slackware.com) # # Copyright 2003, 2004 Slackware Linux, Inc., Concord, California, USA -# Copyright 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016 Patrick J. Volkerding, Sebeka, MN, USA +# Copyright 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018 Patrick J. Volkerding, Sebeka, MN, USA # All rights reserved. # # Redistribution and use of this script, with or without modification, is @@ -52,6 +52,8 @@ # efficient on modern CPUs running in 32-bit mode than the alternate i586 # instructions. No need to throw i586 CPUs under the bus (yet). +cd $(dirname $0) ; CWD=$(pwd) + PKGNAM=gcc VERSION=${VERSION:-$(echo $PKGNAM-*.tar.xz | rev | cut -f 3- -d . | cut -f 1 -d - | rev)} BUILD=${BUILD:-3} @@ -70,6 +72,20 @@ if [ -z "$ARCH" ]; then export ARCH fi +# If the variable PRINT_PACKAGE_NAME is set, then this script will report what +# the name of the created package would be, and then exit. This information +# could be useful to other scripts. +if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then + echo "gcc-$VERSION-$ARCH-$BUILD.txz" + echo "gcc-g++-$VERSION-$ARCH-$BUILD.txz" + echo "gcc-gfortran-$VERSION-$ARCH-$BUILD.txz" + echo "gcc-gnat-$VERSION-$ARCH-$BUILD.txz" + echo "gcc-objc-$VERSION-$ARCH-$BUILD.txz" + echo "gcc-go-$VERSION-$ARCH-$BUILD.txz" + echo "gcc-brig-$VERSION-$ARCH-$BUILD.txz" + exit 0 +fi + if [ "$ARCH" = "i386" ]; then SLKCFLAGS="-O2 -march=i386 -mcpu=i686" LIBDIRSUFFIX="" @@ -109,10 +125,8 @@ case "$ARCH" in *) TARGET=$ARCH-slackware-linux ;; esac -CWD=$(pwd) -# Temporary build location. This should *NOT* be a directory -# path a non-root user could create later... -TMP=${TMP:-"/gcc-$(mcookie)"} +# Temporary build location: +TMP=${TMP:-/tmp} # This is the main DESTDIR target: PKG1=$TMP/package-gcc @@ -120,55 +134,44 @@ PKG1=$TMP/package-gcc PKG2=$TMP/package-gcc-g++ PKG3=$TMP/package-gcc-gfortran PKG4=$TMP/package-gcc-gnat -PKG5=$TMP/package-gcc-java PKG6=$TMP/package-gcc-objc -PKG7=$TMP/package-gcc-g++-gch +#PKG7=$TMP/package-gcc-g++-gch PKG8=$TMP/package-gcc-go +PKG9=$TMP/package-gcc-brig # Clear the build locations: -if [ -d $TMP ]; then - rm -rf $TMP -fi -mkdir -p $PKG{1,2,3,4,5,6,7,8}/usr/doc/gcc-$VERSION +rm -rf $TMP/gcc.build.lnx +rm -rf $PKG{1,2,3,4,6,8,9} +mkdir -p $PKG{1,2,3,4,6,8,9}/usr/doc/gcc-$VERSION # Insert package descriptions: -mkdir -p $PKG{1,2,3,4,5,6,7,8}/install +mkdir -p $PKG{1,2,3,4,6,8,9}/install cat $CWD/slack-desc.gcc > $PKG1/install/slack-desc cat $CWD/slack-desc.gcc-g++ > $PKG2/install/slack-desc cat $CWD/slack-desc.gcc-gfortran > $PKG3/install/slack-desc cat $CWD/slack-desc.gcc-gnat > $PKG4/install/slack-desc -cat $CWD/slack-desc.gcc-java > $PKG5/install/slack-desc cat $CWD/slack-desc.gcc-objc > $PKG6/install/slack-desc -# cat $CWD/slack-desc.gcc-g++-gch > $PKG7/install/slack-desc +#cat $CWD/slack-desc.gcc-g++-gch > $PKG7/install/slack-desc cat $CWD/slack-desc.gcc-go > $PKG8/install/slack-desc +cat $CWD/slack-desc.gcc-brig > $PKG9/install/slack-desc cd $TMP -tar xvf $CWD/gcc-$VERSION.tar.?z* - -( cd gcc-$VERSION/gcc - zcat $CWD/gcc.66782.diff.gz | patch -p0 --verbose || exit 1 - zcat $CWD/gcc.69140.diff.gz | patch -p2 --verbose || exit 1 -) || exit 1 - -# Copy ecj.jar into the TLD of the source. Needed for java compiler. -# This can be retrieved from ftp://sourceware.org/pub/java -cp $CWD/ecj-4.9.jar gcc-$VERSION/ecj.jar +rm -rf gcc-$VERSION +tar xvf $CWD/gcc-$VERSION.tar.xz || exit 1 -# Use an antlr runtime to compile javadoc. -# The runtime can be obtained from: -#https://oss.sonatype.org/content/repositories/releases/org/antlr/antlr-runtime/ -ANTLJAR=$(echo $CWD/antlr-*.jar | tail -1) +( cd gcc-$VERSION || exit 1 -# install docs -( cd gcc-$VERSION # Smite the fixincludes: zcat $CWD/gcc-no_fixincludes.diff.gz | patch -p1 --verbose --backup --suffix=.orig || exit 1 - # Fix perms/owners + + # Fix perms/owners: chown -R root:root . find . -perm 777 -exec chmod 755 {} \; find . -perm 775 -exec chmod 755 {} \; find . -perm 754 -exec chmod 755 {} \; find . -perm 664 -exec chmod 644 {} \; + + # Install docs: mkdir -p $PKG1/usr/doc/gcc-$VERSION cp -a \ COPYING* ChangeLog* FAQ INSTALL \ @@ -189,13 +192,13 @@ ANTLJAR=$(echo $CWD/antlr-*.jar | tail -1) fi mkdir -p $PKG1/usr/doc/gcc-${VERSION}/gcc - ( cd gcc + ( cd gcc || exit 0 cp -a \ ABOUT* COPYING* DATESTAMP DEV-PHASE LANG* ONEWS README* SERVICE \ $PKG1/usr/doc/gcc-$VERSION/gcc mkdir -p $PKG3/usr/doc/gcc-${VERSION}/gcc/fortran - ( cd fortran + ( cd fortran || exit 0 if [ -r ChangeLog ]; then cat ChangeLog | head -n 1000 > $PKG3/usr/doc/gcc-$VERSION/gcc/fortran/ChangeLog touch -r ChangeLog $PKG3/usr/doc/gcc-$VERSION/gcc/fortran/ChangeLog @@ -203,7 +206,7 @@ ANTLJAR=$(echo $CWD/antlr-*.jar | tail -1) ) mkdir -p $PKG4/usr/doc/gcc-${VERSION}/gcc/ada - ( cd ada + ( cd ada || exit 0 cp -a \ ChangeLog.tree-ssa \ $PKG4/usr/doc/gcc-$VERSION/gcc/ada @@ -213,19 +216,8 @@ ANTLJAR=$(echo $CWD/antlr-*.jar | tail -1) fi ) - mkdir -p $PKG5/usr/doc/gcc-${VERSION}/gcc/java - ( cd java - cp -a \ - ChangeLog.tree-ssa \ - $PKG5/usr/doc/gcc-${VERSION}/gcc/java - if [ -r ChangeLog ]; then - cat ChangeLog | head -n 1000 > $PKG5/usr/doc/gcc-${VERSION}/gcc/java/ChangeLog - touch -r ChangeLog $PKG5/usr/doc/gcc-${VERSION}/gcc/java/ChangeLog - fi - ) - mkdir -p $PKG6/usr/doc/gcc-${VERSION}/gcc/objc - ( cd objc + ( cd objc || exit 0 cp -a \ README* \ $PKG6/usr/doc/gcc-${VERSION}/gcc/objc @@ -236,7 +228,7 @@ ANTLJAR=$(echo $CWD/antlr-*.jar | tail -1) ) mkdir -p $PKG8/usr/doc/gcc-${VERSION}/gcc/go - ( cd go + ( cd go || exit 0 if [ -r ChangeLog ]; then cat ChangeLog | head -n 1000 > $PKG8/usr/doc/gcc-${VERSION}/gcc/go/ChangeLog touch -r ChangeLog $PKG8/usr/doc/gcc-${VERSION}/gcc/go/ChangeLog @@ -247,10 +239,18 @@ ANTLJAR=$(echo $CWD/antlr-*.jar | tail -1) $PKG8/usr/doc/gcc-${VERSION}/gcc/go ) + mkdir -p $PKG9/usr/doc/gcc-${VERSION}/gcc/brig + ( cd brig || exit 0 + if [ -r ChangeLog ]; then + cat ChangeLog | head -n 1000 > $PKG9/usr/doc/gcc-${VERSION}/gcc/brig/ChangeLog + touch -r ChangeLog $PKG9/usr/doc/gcc-${VERSION}/gcc/brig/ChangeLog + fi + ) + ) || exit 1 mkdir -p $PKG3/usr/doc/gcc-${VERSION}/libgfortran - ( cd libgfortran + ( cd libgfortran || exit 0 if [ -r ChangeLog ]; then cat ChangeLog | head -n 1000 > $PKG3/usr/doc/gcc-${VERSION}/libgfortran/ChangeLog touch -r ChangeLog $PKG3/usr/doc/gcc-${VERSION}/libgfortran/ChangeLog @@ -258,47 +258,15 @@ ANTLJAR=$(echo $CWD/antlr-*.jar | tail -1) ) mkdir -p $PKG4/usr/doc/gcc-${VERSION}/libada - ( cd libada + ( cd libada || exit 0 if [ -r ChangeLog ]; then cat ChangeLog | head -n 1000 > $PKG4/usr/doc/gcc-${VERSION}/libada/ChangeLog touch -r ChangeLog $PKG4/usr/doc/gcc-${VERSION}/libada/ChangeLog fi ) - mkdir -p $PKG5/usr/doc/gcc-${VERSION}/libffi - ( cd libffi - cp -a \ - ChangeLog.libgcj ChangeLog.v1 \ - LICENSE* README* \ - $PKG5/usr/doc/gcc-${VERSION}/libffi - if [ -r ChangeLog ]; then - cat ChangeLog | head -n 1000 > $PKG5/usr/doc/gcc-${VERSION}/libffi/ChangeLog - touch -r ChangeLog $PKG5/usr/doc/gcc-${VERSION}/libffi/ChangeLog - fi - ) - - mkdir -p $PKG5/usr/doc/gcc-${VERSION}/libjava - ( cd libjava - cp -a \ - COPYING* HACKING LIBGCJ_LICENSE \ - NEWS README* THANKS \ - $PKG5/usr/doc/gcc-${VERSION}/libjava - if [ -r ChangeLog ]; then - cat ChangeLog | head -n 1000 > $PKG5/usr/doc/gcc-${VERSION}/libjava/ChangeLog - touch -r ChangeLog $PKG5/usr/doc/gcc-${VERSION}/libjava/ChangeLog - fi - ) - - mkdir -p $PKG1/usr/doc/gcc-${VERSION}/libmudflap - ( cd libmudflap - if [ -r ChangeLog ]; then - cat ChangeLog | head -n 1000 > $PKG1/usr/doc/gcc-${VERSION}/libmudflap/ChangeLog - touch -r ChangeLog $PKG1/usr/doc/gcc-${VERSION}/libmudflap/ChangeLog - fi - ) - mkdir -p $PKG1/usr/doc/gcc-${VERSION}/libgomp - ( cd libgomp + ( cd libgomp || exit 0 if [ -r ChangeLog ]; then cat ChangeLog | head -n 1000 > $PKG1/usr/doc/gcc-${VERSION}/libgomp/ChangeLog touch -r ChangeLog $PKG1/usr/doc/gcc-${VERSION}/libgomp/ChangeLog @@ -306,7 +274,7 @@ ANTLJAR=$(echo $CWD/antlr-*.jar | tail -1) ) mkdir -p $PKG6/usr/doc/gcc-${VERSION}/libobjc - ( cd libobjc + ( cd libobjc || exit 0 if [ -r ChangeLog ]; then cat ChangeLog | head -n 1000 > $PKG6/usr/doc/gcc-${VERSION}/libobjc/ChangeLog touch -r ChangeLog $PKG6/usr/doc/gcc-${VERSION}/libobjc/ChangeLog @@ -317,7 +285,7 @@ ANTLJAR=$(echo $CWD/antlr-*.jar | tail -1) ) mkdir -p $PKG2/usr/doc/gcc-${VERSION}/libstdc++-v3 - ( cd libstdc++-v3 + ( cd libstdc++-v3 || exit 0 cp -a \ README* \ doc/html/faq.html \ @@ -330,77 +298,10 @@ ANTLJAR=$(echo $CWD/antlr-*.jar | tail -1) ) -# Add fastjar to the gcc-java package: -( cd $TMP - FASTJARVER=$(echo $CWD/fastjar-*.tar.xz | rev | cut -f 3- -d . | cut -f 1 -d - | rev) - echo - echo "Building fastjar-$FASTJARVER first" - echo - rm -rf fastjar-$FASTJARVER - tar xvf $CWD/fastjar-$FASTJARVER.tar.xz || exit 1 - cd fastjar-$FASTJARVER || exit 1 - chown -R root:root . - find . \ - \( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \ - -exec chmod 755 {} \; -o \ - \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \ - -exec chmod 644 {} \; - for patch in $CWD/fastjar-patches/*.gz ; do - zcat $patch | patch -p1 --verbose || exit 1 - done - CFLAGS="$SLKCFLAGS" \ - CXXFLAGS="$SLKCFLAGS" \ - ./configure \ - --prefix=/usr \ - --libdir=/usr/lib$LIBDIRSUFFIX \ - --mandir=/usr/man \ - --infodir=/usr/info \ - --build=$TARGET - make $NUMJOBS || exit 1 - make install DESTDIR=$PKG5 || exit 1 - mkdir -p $PKG5/usr/doc/fastjar-$FASTJARVER - cp -a \ - AUTHORS CHANGES COPYING* INSTALL NEWS README* TODO \ - $PKG5/usr/doc/fastjar-$FASTJARVER - # If there's a ChangeLog, installing at least part of the recent history - # is useful, but don't let it get totally out of control: - if [ -r ChangeLog ]; then - DOCSDIR=$(echo $PKG5/usr/doc/fastjar-$FASTJARVER) - cat ChangeLog | head -n 1000 > $DOCSDIR/ChangeLog - touch -r ChangeLog $DOCSDIR/ChangeLog - fi - find $PKG5 | xargs file | grep -e "executable" -e "shared object" | grep ELF \ - | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null - # Compress and if needed symlink the man pages: - if [ -d $PKG5/usr/man ]; then - ( cd $PKG5/usr/man - for manpagedir in $(find . -type d -name "man*") ; do - ( cd $manpagedir - for eachpage in $( find . -type l -maxdepth 1) ; do - ln -s $( readlink $eachpage ).gz $eachpage.gz - rm $eachpage - done - gzip -9 *.? - ) - done - ) - fi - # Compress info files, if any: - if [ -d $PKG5/usr/info ]; then - ( cd $PKG5/usr/info - rm -f dir - gzip -9 * - ) - fi - echo -) || exit 1 - # build gcc ( mkdir gcc.build.lnx; cd gcc.build.lnx; - # If enough people need "treelang" support for it may be considered. - # --enable-languages=ada,c,c++,fortran,java,objc,treelang # I think it's incorrect to include this option (as it'll end up set # to i586 on x86 platforms), and we want to tune the binary structure # for i686, as that's where almost all of the optimization speedups @@ -414,9 +315,6 @@ ANTLJAR=$(echo $CWD/antlr-*.jar | tail -1) GCC_ARCHOPTS="--disable-multilib" fi - # NOTE: For Slackware 15.0, look into removing --with-default-libstdcxx-abi=gcc4-compatible, - # which will then require rebuilding all C++ libraries. That is, if there's any benefit. - CFLAGS="$SLKCFLAGS" \ CXXFLAGS="$SLKCFLAGS" \ ../gcc-$VERSION/configure --prefix=/usr \ @@ -425,14 +323,13 @@ ANTLJAR=$(echo $CWD/antlr-*.jar | tail -1) --infodir=/usr/info \ --enable-shared \ --enable-bootstrap \ - --enable-languages=ada,c,c++,fortran,go,java,lto,objc \ + --enable-languages=ada,brig,c,c++,fortran,go,lto,objc \ --enable-threads=posix \ --enable-checking=release \ --enable-objc-gc \ --with-system-zlib \ - --with-python-dir=/lib$LIBDIRSUFFIX/python2.7/site-packages \ --enable-libstdcxx-dual-abi \ - --with-default-libstdcxx-abi=gcc4-compatible \ + --with-default-libstdcxx-abi=new \ --disable-libunwind-exceptions \ --enable-__cxa_atexit \ --enable-libssp \ @@ -440,13 +337,7 @@ ANTLJAR=$(echo $CWD/antlr-*.jar | tail -1) --disable-install-libiberty \ --with-gnu-ld \ --verbose \ - --enable-java-home \ - --with-java-home=/usr/lib$LIBDIRSUFFIX/jvm/jre \ - --with-jvm-root-dir=/usr/lib$LIBDIRSUFFIX/jvm \ - --with-jvm-jar-dir=/usr/lib$LIBDIRSUFFIX/jvm/jvm-exports \ --with-arch-directory=$LIB_ARCH \ - --with-antlr-jar=$ANTLJAR \ - --enable-java-awt=gtk \ --disable-gtktest \ $GCC_ARCHOPTS \ --target=${TARGET} \ @@ -456,108 +347,123 @@ ANTLJAR=$(echo $CWD/antlr-*.jar | tail -1) # Start the build: # Include all debugging info (for now): - make $NUMJOBS bootstrap; + make $NUMJOBS bootstrap || exit 1 ( cd gcc - make $NUMJOBS gnatlib GNATLIBCFLAGS="$SLKCFLAGS" + make $NUMJOBS gnatlib GNATLIBCFLAGS="$SLKCFLAGS" || exit 1 # This wants a shared -ladd2line? - #make gnatlib-shared + #make gnatlib-shared || exit 1 CFLAGS="$SLKCFLAGS" \ CXXFLAGS="$SLKCFLAGS" \ - make $NUMJOBS gnattools - ) - make info + make $NUMJOBS gnattools || exit 1 + ) || exit 1 + make info || exit 1 # Set GCCCHECK=something to run the tests if [ ! -z $GCCCHECK ]; then - make $NUMJOBS check + make $NUMJOBS check || exit 1 fi - make install DESTDIR=$PKG1 + make install DESTDIR=$PKG1 || exit 1 -# KLUDGE ALERT -# These *gdb.py files are causing ldconfig to complain, so they are going -# to be REMOVED for now... at some point, they might be moved somewhere -# else, in which case things should Just Work(tm). Keep an eye on it. -rm -f $PKG1/usr/lib${LIBDIRSUFFIX}/*gdb.py + # Move gdb pretty printers to the correct place + mkdir -p $PKG1/usr/share/gdb/auto-load/usr/lib$LIBDIRSUFFIX + mv $PKG1/usr/lib$LIBDIRSUFFIX/*-gdb.py \ + $PKG1/usr/share/gdb/auto-load/usr/lib$LIBDIRSUFFIX/ -# Be sure the "specs" file is installed. -if [ ! -r $PKG1/usr/lib${LIBDIRSUFFIX}/gcc/${TARGET}/${VERSION}/specs ]; then - cat stage1-gcc/specs > $PKG1/usr/lib${LIBDIRSUFFIX}/gcc/${TARGET}/${VERSION}/specs -fi + # Be sure the "specs" file is installed. + if [ ! -r $PKG1/usr/lib${LIBDIRSUFFIX}/gcc/${TARGET}/${VERSION}/specs ]; then + cat stage1-gcc/specs > $PKG1/usr/lib${LIBDIRSUFFIX}/gcc/${TARGET}/${VERSION}/specs + fi -# Make our 64bit gcc look for 32bit gcc binaries in ./32 subdirectory: -if [ "$ARCH" = "x86_64" ]; then - sed -i 's#;.\(:../lib !m64 m32;\)$#;32\1#' \ - $PKG1/usr/lib${LIBDIRSUFFIX}/gcc/${TARGET}/${VERSION}/specs -fi + # Make our 64bit gcc look for 32bit gcc binaries in ./32 subdirectory: + if [ "$ARCH" = "x86_64" ]; then + sed -i 's#;.\(:../lib !m64 m32;\)$#;32\1#' \ + $PKG1/usr/lib${LIBDIRSUFFIX}/gcc/${TARGET}/${VERSION}/specs + fi + + # make ada.install-common DESTDIR=$PKG1 || exit 1 + # make install-gnatlib DESTDIR=$PKG1 || exit 1 + make -i install-info DESTDIR=$PKG1 || exit 1 + + chmod 755 $PKG1/usr/lib${LIBDIRSUFFIX}/libgcc_s.so.1 + + # Fix stuff up: + ( cd $PKG1/usr/info ; rm dir ; gzip -9 * ) + ( cd $PKG1 + # *not* ${LIBDIRSUFFIX} + mkdir -p lib + cd lib + ln -sf /usr/bin/cpp . + ) + + ( cd $PKG1/usr/bin + mv g++ g++-gcc-$VERSION + mv gcc gcc-$VERSION + mv ${TARGET}-gfortran gfortran-gcc-$VERSION + ln -sf g++-gcc-$VERSION g++ + ln -sf gcc-$VERSION gcc + ln -sf g++ c++ + ln -sf gcc cc + ln -sf gcc-$VERSION ${TARGET}-gcc + ln -sf gcc-$VERSION ${TARGET}-gcc-$VERSION + ln -sf gcc-ar ${TARGET}-gcc-ar + ln -sf gcc-nm ${TARGET}-gcc-nm + ln -sf gcc-ranlib ${TARGET}-gcc-ranlib + ln -sf g++-gcc-$VERSION ${TARGET}-c++ + ln -sf g++-gcc-$VERSION ${TARGET}-g++ + ln -sf gfortran-gcc-$VERSION gfortran + ln -sf gfortran-gcc-$VERSION ${TARGET}-gfortran + ln -sf gfortran-gcc-$VERSION ${TARGET}-gfortran-$VERSION + ln -sf gfortran-gcc-$VERSION ${TARGET}-g95 + ln -sf gfortran g95 + ln -sf gfortran f95 + ln -sf gfortran-gcc-$VERSION ${TARGET}-g77 + ln -sf gfortran g77 + ln -sf gfortran f77 + cat $CWD/c89.sh > c89 + cat $CWD/c99.sh > c99 + chmod 755 c89 c99 + ) -# make ada.install-common DESTDIR=$PKG1 -# make install-gnatlib DESTDIR=$PKG1 -make -i install-info DESTDIR=$PKG1 + ( cd $PKG1/usr/man + gzip -9 */* + cd man1 + ln -sf g++.1.gz c++.1.gz + ln -sf gcc.1.gz cc.1.gz + ) -chmod 755 $PKG1/usr/lib${LIBDIRSUFFIX}/libgcc_s.so.1 + ## build an all-in-one txz package: + #( + # cd $PKG1; + # makepkg -l y -c n $TMP/gcc-$VERSION-$ARCH-$BUILD.txz + #) -# The (huge) static GNU java libraries are not packaged. In nearly all -# cases one or more dependencies will not be available as static anyway. -rm -f $PKG1/usr/lib${LIBDIRSUFFIX}/libgcj.a -rm -f $PKG1/usr/lib${LIBDIRSUFFIX}/libgcj-tools.a +# keep a log: +) 2>&1 | tee $TMP/gcc.build.log -# Fix stuff up: -( cd $PKG1/usr/info ; rm dir ; gzip -9 * ) +# Filter all .la files (thanks much to Mark Post for the sed script): ( cd $PKG1 - # *not* ${LIBDIRSUFFIX} - mkdir -p lib - cd lib - ln -sf /usr/bin/cpp . + for file in $(find . -type f -name "*.la") ; do + cat $file | sed -e 's%-L/gcc-[[:graph:]]* % %g' > $TMP/tmp-la-file + cat $TMP/tmp-la-file > $file + done + rm $TMP/tmp-la-file ) -( cd $PKG1/usr/bin - mv g++ g++-gcc-$VERSION - mv gcc gcc-$VERSION - mv ${TARGET}-gfortran gfortran-gcc-$VERSION - ln -sf g++-gcc-$VERSION g++ - ln -sf gcc-$VERSION gcc - ln -sf g++ c++ - ln -sf gcc cc - ln -sf gcc-$VERSION ${TARGET}-gcc - ln -sf gcc-$VERSION ${TARGET}-gcc-$VERSION - ln -sf gcc-ar ${TARGET}-gcc-ar - ln -sf gcc-nm ${TARGET}-gcc-nm - ln -sf gcc-ranlib ${TARGET}-gcc-ranlib - ln -sf gcj ${TARGET}-gcj - ln -sf gcjh ${TARGET}-gcjh - ln -sf g++-gcc-$VERSION ${TARGET}-c++ - ln -sf g++-gcc-$VERSION ${TARGET}-g++ - ln -sf gfortran-gcc-$VERSION gfortran - ln -sf gfortran-gcc-$VERSION ${TARGET}-gfortran - ln -sf gfortran-gcc-$VERSION ${TARGET}-gfortran-$VERSION - ln -sf gfortran-gcc-$VERSION ${TARGET}-g95 - ln -sf gfortran g95 - ln -sf gfortran f95 - ln -sf gfortran-gcc-$VERSION ${TARGET}-g77 - ln -sf gfortran g77 - ln -sf gfortran f77 - cat $CWD/c89.sh > c89 - cat $CWD/c99.sh > c99 - chmod 755 c89 c99 -) +# Don't ship .la files in /{,usr/}lib${LIBDIRSUFFIX}: +rm -f $PKG1/{,usr/}lib${LIBDIRSUFFIX}/*.la -( cd $PKG1/usr/man - gzip -9 */* - cd man1 - ln -sf g++.1.gz c++.1.gz - ln -sf gcc.1.gz cc.1.gz -) - -## build the txz package -#( -# cd $PKG1; -# makepkg -l y -c n $TMP/gcc-$VERSION-$ARCH-$BUILD.txz -#) -# keep a log -) 2>&1 | tee $TMP/gcc.build.log +# Strip bloated binaries and libraries: +( cd $PKG1 + find . -name "lib*so*" -exec strip --strip-unneeded "{}" \; + find . -name "lib*so*" -exec patchelf --remove-rpath "{}" \; + find . -name "lib*a" -exec strip -g "{}" \; + strip --strip-unneeded usr/bin/* 2> /dev/null + find . | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null + find . | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null +) # OK, time to split the big package where needed: @@ -573,6 +479,10 @@ rm -f $PKG1/usr/lib${LIBDIRSUFFIX}/libgcj-tools.a mv $PKG1/usr/libexec/gcc/$TARGET/$VERSION/cc1plus usr/libexec/gcc/$TARGET/$VERSION/cc1plus mkdir -p usr/man/man1 mv $PKG1/usr/man/man1/*++* usr/man/man1 + mkdir -p usr/share + mv $PKG1/usr/share/gdb usr/share + mkdir -p usr/share/gcc-$VERSION/python + mv $PKG1/usr/share/gcc-$VERSION/python/libstdcxx usr/share/gcc-$VERSION/python ) # gcc-gfortran: @@ -598,11 +508,6 @@ rm -f $PKG1/usr/lib${LIBDIRSUFFIX}/libgcj-tools.a ) # gcc-gnat: -# First, relocate usr/bin/gnative2ascii to the gcc-java package so it -# isn't matched and accidentally put in gcc-gnat: -mkdir -p $PKG5/usr/bin -mv $PKG1/usr/bin/gnative2ascii $PKG5/usr/bin -# Now make the gcc-gnat package tree: ( cd $PKG4 mkdir -p usr/bin mv $PKG1/usr/bin/gnat* usr/bin @@ -616,117 +521,6 @@ mv $PKG1/usr/bin/gnative2ascii $PKG5/usr/bin mv $PKG1/usr/lib${LIBDIRSUFFIX}/gcc/$TARGET/$VERSION/adalib usr/lib${LIBDIRSUFFIX}/gcc/$TARGET/$VERSION ) -# gcc-java: -( cd $PKG5 - mkdir -p usr/bin - mv $PKG1/usr/bin/aot-compile usr/bin - mv $PKG1/usr/bin/addr2name.awk usr/bin - # mv $PKG1/usr/bin/fastjar usr/bin - mv $PKG1/usr/bin/gappletviewer usr/bin - mv $PKG1/usr/bin/gc-analyze usr/bin - mv $PKG1/usr/bin/*gcj* usr/bin - mv $PKG1/usr/bin/gij usr/bin - mv $PKG1/usr/bin/gjar usr/bin - mv $PKG1/usr/bin/gjarsigner usr/bin - mv $PKG1/usr/bin/gjdoc usr/bin - mv $PKG1/usr/bin/gkeytool usr/bin - mv $PKG1/usr/bin/grepjar usr/bin - mv $PKG1/usr/bin/grmid usr/bin - mv $PKG1/usr/bin/grmic usr/bin - mv $PKG1/usr/bin/grmiregistry usr/bin - mv $PKG1/usr/bin/gserialver usr/bin - mv $PKG1/usr/bin/gtnameserv usr/bin - mv $PKG1/usr/bin/gjavah usr/bin - mv $PKG1/usr/bin/gorbd usr/bin - mv $PKG1/usr/bin/jar usr/bin - mv $PKG1/usr/bin/jcf-dump usr/bin - mv $PKG1/usr/bin/jv-* usr/bin - mv $PKG1/usr/bin/rmi* usr/bin - mkdir -p usr/include/c++/$VERSION - # Move some Java only C++ headers from the C++ package: - mv $PKG2/usr/include/c++/$VERSION/{gcj,gnu,java,javax,org,sun} usr/include/c++/$VERSION - mv $PKG1/usr/include/ffi.h usr/include - mkdir -p usr/lib${LIBDIRSUFFIX}/gcc/$TARGET/$VERSION/include - mv $PKG1/usr/lib${LIBDIRSUFFIX}/gcc/$TARGET/$VERSION/include/jawt.h usr/lib${LIBDIRSUFFIX}/gcc/$TARGET/$VERSION/include - mv $PKG1/usr/lib${LIBDIRSUFFIX}/gcc/$TARGET/$VERSION/include/ffi.h usr/lib${LIBDIRSUFFIX}/gcc/$TARGET/$VERSION/include - mv $PKG1/usr/lib${LIBDIRSUFFIX}/gcc/$TARGET/$VERSION/include/ffitarget.h usr/lib${LIBDIRSUFFIX}/gcc/$TARGET/$VERSION/include - mv $PKG1/usr/lib${LIBDIRSUFFIX}/gcc/$TARGET/$VERSION/include/jawt_md.h usr/lib${LIBDIRSUFFIX}/gcc/$TARGET/$VERSION/include - mv $PKG1/usr/lib${LIBDIRSUFFIX}/gcc/$TARGET/$VERSION/include/jni.h usr/lib${LIBDIRSUFFIX}/gcc/$TARGET/$VERSION/include - mv $PKG1/usr/lib${LIBDIRSUFFIX}/gcc/$TARGET/$VERSION/include/jni_md.h usr/lib${LIBDIRSUFFIX}/gcc/$TARGET/$VERSION/include - mv $PKG1/usr/lib${LIBDIRSUFFIX}/gcc/$TARGET/$VERSION/include/jvmpi.h usr/lib${LIBDIRSUFFIX}/gcc/$TARGET/$VERSION/include - mv $PKG1/usr/lib${LIBDIRSUFFIX}/gcc/$TARGET/$VERSION/include/libffi usr/lib${LIBDIRSUFFIX}/gcc/$TARGET/$VERSION/include - # aot-compile Python plugins: - if [ ! -d $PKG1/usr/lib${LIBDIRSUFFIX}/python2.7 ]; then - echo "NO $PKG1/usr/lib${LIBDIRSUFFIX}/python2.7 !" - exit 1 - fi - mv $PKG1/usr/lib${LIBDIRSUFFIX}/python2.7 usr/lib${LIBDIRSUFFIX} - mkdir -p usr/info - mv $PKG1/usr/info/gcj.* usr/info - # mv $PKG1/usr/info/fastjar.* usr/info - mkdir -p usr/lib${LIBDIRSUFFIX} - mv $PKG1/usr/lib${LIBDIRSUFFIX}/libffi* usr/lib${LIBDIRSUFFIX} - mv $PKG1/usr/lib${LIBDIRSUFFIX}/logging.properties usr/lib${LIBDIRSUFFIX} - mv $PKG1/usr/lib${LIBDIRSUFFIX}/gcj* usr/lib${LIBDIRSUFFIX} - mv $PKG1/usr/lib${LIBDIRSUFFIX}/libgcj* usr/lib${LIBDIRSUFFIX} - mv $PKG1/usr/lib${LIBDIRSUFFIX}/libgij* usr/lib${LIBDIRSUFFIX} - mv $PKG1/usr/lib${LIBDIRSUFFIX}/lib-org* usr/lib${LIBDIRSUFFIX} - mv $PKG1/usr/lib${LIBDIRSUFFIX}/security usr/lib${LIBDIRSUFFIX} - mkdir -p usr/lib${LIBDIRSUFFIX}/pkgconfig - mv $PKG1/usr/lib${LIBDIRSUFFIX}/pkgconfig/libgcj*.pc usr/lib${LIBDIRSUFFIX}/pkgconfig - rmdir $PKG1/usr/lib${LIBDIRSUFFIX}/pkgconfig 2> /dev/null - mkdir -p usr/libexec/gcc/$TARGET/$VERSION - mv $PKG1/usr/libexec/gcc/$TARGET/$VERSION/jc1 usr/libexec/gcc/$TARGET/$VERSION - mv $PKG1/usr/libexec/gcc/$TARGET/$VERSION/ecj1 usr/libexec/gcc/$TARGET/$VERSION - mv $PKG1/usr/libexec/gcc/$TARGET/$VERSION/jvgenmain usr/libexec/gcc/$TARGET/$VERSION - mkdir -p usr/lib${LIBDIRSUFFIX}/gcc/$TARGET/$VERSION/include - mv $PKG1/usr/lib${LIBDIRSUFFIX}/gcc/$TARGET/$VERSION/include/gcj usr/lib${LIBDIRSUFFIX}/gcc/$TARGET/$VERSION/include - mkdir -p usr/man/man1 - mv $PKG1/usr/man/man1/aot-compile.1.gz usr/man/man1 - mv $PKG1/usr/man/man1/gappletviewer.1.gz usr/man/man1 - mv $PKG1/usr/man/man1/gc-analyze.1.gz usr/man/man1 - mv $PKG1/usr/man/man1/gcj.1.gz usr/man/man1 - mv $PKG1/usr/man/man1/gcjh.1.gz usr/man/man1 - mv $PKG1/usr/man/man1/gcj-dbtool.1.gz usr/man/man1 - mv $PKG1/usr/man/man1/gij.1.gz usr/man/man1 - mv $PKG1/usr/man/man1/gjar.1.gz usr/man/man1 - mv $PKG1/usr/man/man1/gjarsigner.1.gz usr/man/man1 - mv $PKG1/usr/man/man1/gjavah.1.gz usr/man/man1 - mv $PKG1/usr/man/man1/gjdoc.1.gz usr/man/man1 - mv $PKG1/usr/man/man1/gjnih.1.gz usr/man/man1 - mv $PKG1/usr/man/man1/gkeytool.1.gz usr/man/man1 - mv $PKG1/usr/man/man1/gnative2ascii.1.gz usr/man/man1 - mv $PKG1/usr/man/man1/gorbd.1.gz usr/man/man1 - mv $PKG1/usr/man/man1/grmic.1.gz usr/man/man1 - mv $PKG1/usr/man/man1/grmid.1.gz usr/man/man1 - mv $PKG1/usr/man/man1/grmiregistry.1.gz usr/man/man1 - mv $PKG1/usr/man/man1/gserialver.1.gz usr/man/man1 - mv $PKG1/usr/man/man1/gtnameserv.1.gz usr/man/man1 - mv $PKG1/usr/man/man1/jcf-dump.1.gz usr/man/man1 - mv $PKG1/usr/man/man1/jv-convert.1.gz usr/man/man1 - mv $PKG1/usr/man/man1/jv-scan.1.gz usr/man/man1 - mv $PKG1/usr/man/man1/rebuild-gcj-db.1.gz usr/man/man1 - mkdir -p usr/man/man3 - mv $PKG1/usr/man/man3/ffi* usr/man/man3 - mkdir -p usr/share - mv $PKG1/usr/share/java usr/share - # The ecj wrapper script: - cat $CWD/ecj.sh | sed -e "s,@JAVADIR@,/usr/share/java," > usr/bin/ecj - chmod 755 usr/bin/ecj - # The JAVA_HOME compatibility links. - # Caution: non-multilib arch-independent stuff! No lib64 here. - mkdir -p usr/lib$LIBDIRSUFFIX - mv $PKG1/usr/lib$LIBDIRSUFFIX/jvm* usr/lib$LIBDIRSUFFIX - # And add the missing javac symlink: - ln -s ../../../bin/ecj usr/lib$LIBDIRSUFFIX/jvm/bin/javac - # Don't package libffi stuff anymore. GCC will link the internal version - # statically, and we'll need a newer one elsewhere. - find . -name "ffi*.h" | xargs rm - find . -name "libffi*" | xargs rm - rm -f usr/man/man3/ffi* - rm -f usr/info/libffi* -) - # gcc-objc: ( cd $PKG6 mkdir -p usr/lib${LIBDIRSUFFIX} @@ -756,37 +550,29 @@ mv $PKG1/usr/bin/gnative2ascii $PKG5/usr/bin mv $PKG1/usr/info/gccgo.info.gz usr/info mkdir -p usr/lib${LIBDIRSUFFIX} mv $PKG1/usr/lib${LIBDIRSUFFIX}/go usr/lib${LIBDIRSUFFIX} - mv $PKG1/usr/lib${LIBDIRSUFFIX}/{libgo.la,libgo.so*,libgobegin.a,libgolibbegin.a,libnetgo.a} usr/lib${LIBDIRSUFFIX} || exit 1 - # Ordinarily Slackware doesn't package static libraries, but in this case - # it is useful for deploying compiled binaries on machines that do not yet - # have libgo.so.0.0.0. - mv $PKG1/usr/lib${LIBDIRSUFFIX}/libgo.a usr/lib${LIBDIRSUFFIX} + if [ -r $PKG1/usr/lib${LIBDIRSUFFIX}/libgo.la ]; then + mv $PKG1/usr/lib${LIBDIRSUFFIX}/libgo.la usr/lib${LIBDIRSUFFIX} + fi + mv $PKG1/usr/lib${LIBDIRSUFFIX}/{libgo.so*,libgobegin.a,libgolibbegin.a} usr/lib${LIBDIRSUFFIX} || exit 1 + # Don't package the (bloated) libgo.a. As a rule, we don't package static libraries. + rm -f $PKG1/usr/lib${LIBDIRSUFFIX}/libgo.a mkdir -p usr/man/man1 mv $PKG1/usr/man/man1/gccgo.1.gz usr/man/man1 mv $PKG1/usr/man/man1/go.1.gz usr/man/man1 mv $PKG1/usr/man/man1/gofmt.1.gz usr/man/man1 ) || exit 1 -# Filter all .la files (thanks much to Mark Post for the sed script): -( cd $TMP - for file in $(find . -type f -name "*.la") ; do - cat $file | sed -e 's%-L/gcc-[[:graph:]]* % %g' > $TMP/tmp-la-file - cat $TMP/tmp-la-file > $file - done - rm $TMP/tmp-la-file +# gcc-brig: +( cd $PKG9 + mkdir -p usr/bin + mv $PKG1/usr/bin/*brig* usr/bin + mkdir -p usr/lib${LIBDIRSUFFIX} + mv $PKG1/usr/lib${LIBDIRSUFFIX}/libhsail* usr/lib${LIBDIRSUFFIX} + mkdir -p usr/libexec/gcc/$TARGET/$VERSION + mv $PKG1/usr/libexec/gcc/$TARGET/$VERSION/brig1 usr/libexec/gcc/$TARGET/$VERSION ) -## Strip bloated binaries and libraries: -for dir in $PKG{1,2,3,4,5,6,8}; do - ( cd $dir - find . -name "lib*so*" -exec strip --strip-unneeded "{}" \; - find . -name "lib*a" -exec strip -g "{}" \; - strip --strip-unneeded usr/bin/* 2> /dev/null - find . | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null - find . | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null - ) -done - +# Generate packages: ( cd $PKG1 makepkg -l y -c n $TMP/gcc-$VERSION-$ARCH-$BUILD.txz ) ( cd $PKG2 @@ -795,14 +581,12 @@ done makepkg -l y -c n $TMP/gcc-gfortran-$VERSION-$ARCH-$BUILD.txz ) ( cd $PKG4 makepkg -l y -c n $TMP/gcc-gnat-$VERSION-$ARCH-$BUILD.txz ) -( cd $PKG5 - makepkg -l y -c n $TMP/gcc-java-$VERSION-$ARCH-$BUILD.txz ) ( cd $PKG6 makepkg -l y -c n $TMP/gcc-objc-$VERSION-$ARCH-$BUILD.txz ) -#( cd $PKG7 -# makepkg -l y -c n $TMP/gcc-g++-gch-$VERSION-$ARCH-$BUILD.txz ) ( cd $PKG8 makepkg -l y -c n $TMP/gcc-go-$VERSION-$ARCH-$BUILD.txz ) +( cd $PKG9 + makepkg -l y -c n $TMP/gcc-brig-$VERSION-$ARCH-$BUILD.txz ) echo echo "Slackware GCC package build complete!" diff --git a/source/d/gcc/slack-desc.gcc b/source/d/gcc/slack-desc.gcc index 72e33b46..1c00df83 100644 --- a/source/d/gcc/slack-desc.gcc +++ b/source/d/gcc/slack-desc.gcc @@ -1,8 +1,8 @@ # HOW TO EDIT THIS FILE: -# The "handy ruler" below makes it easier to edit a package description. Line +# The "handy ruler" below makes it easier to edit a package description. Line # up the first '|' above the ':' following the base package name, and the '|' on -# the right side marks the last column you can put a character in. You must make -# exactly 11 lines for the formatting to be correct. It's also customary to +# the right side marks the last column you can put a character in. You must make +# exactly 11 lines for the formatting to be correct. It's also customary to # leave one space after the ':'. |-----handy-ruler------------------------------------------------------| @@ -11,7 +11,7 @@ gcc: gcc: GCC is the GNU Compiler Collection. gcc: gcc: This package contains those parts of the compiler collection needed to -gcc: compile C code. Other packages add Ada, C++, Fortran, Go, +gcc: compile C code. Other packages add Ada, C++, Fortran, Go, gcc: Objective-C, and Java support to the compiler core. gcc: gcc: diff --git a/source/d/gcc/slack-desc.gcc-brig b/source/d/gcc/slack-desc.gcc-brig new file mode 100644 index 00000000..e9496b8b --- /dev/null +++ b/source/d/gcc/slack-desc.gcc-brig @@ -0,0 +1,19 @@ +# HOW TO EDIT THIS FILE: +# The "handy ruler" below makes it easier to edit a package description. Line +# up the first '|' above the ':' following the base package name, and the '|' on +# the right side marks the last column you can put a character in. You must make +# exactly 11 lines for the formatting to be correct. It's also customary to +# leave one space after the ':'. + + |-----handy-ruler------------------------------------------------------| +gcc-brig: gcc-brig (BRIG support for GCC) +gcc-brig: +gcc-brig: BRIG support for the GNU Compiler Collection. +gcc-brig: +gcc-brig: BRIG is the binary form of the Heterogeneous System Architecture +gcc-brig: Intermediate Language (HSA IL), which is a virtual instruction set for +gcc-brig: parallel programs. While similar in some ways to OpenCL or CUDA, HSA +gcc-brig: is designed to ease the burden on the programmer by automatically +gcc-brig: handling the offloading of tasks and moving of data. +gcc-brig: +gcc-brig: diff --git a/source/d/gcc/slack-desc.gcc-g++ b/source/d/gcc/slack-desc.gcc-g++ index 3cbabac1..fa9b4f1c 100644 --- a/source/d/gcc/slack-desc.gcc-g++ +++ b/source/d/gcc/slack-desc.gcc-g++ @@ -1,8 +1,8 @@ # HOW TO EDIT THIS FILE: -# The "handy ruler" below makes it easier to edit a package description. Line +# The "handy ruler" below makes it easier to edit a package description. Line # up the first '|' above the ':' following the base package name, and the '|' on -# the right side marks the last column you can put a character in. You must make -# exactly 11 lines for the formatting to be correct. It's also customary to +# the right side marks the last column you can put a character in. You must make +# exactly 11 lines for the formatting to be correct. It's also customary to # leave one space after the ':'. |-----handy-ruler------------------------------------------------------| @@ -11,7 +11,7 @@ gcc-g++: gcc-g++: C++ support for the GNU Compiler Collection. gcc-g++: gcc-g++: This package contains those parts of the compiler collection needed to -gcc-g++: compile C++ code. The base gcc package is also required. +gcc-g++: compile C++ code. The base gcc package is also required. gcc-g++: gcc-g++: gcc-g++: diff --git a/source/d/gcc/slack-desc.gcc-gfortran b/source/d/gcc/slack-desc.gcc-gfortran index 5141cb02..111dcb1f 100644 --- a/source/d/gcc/slack-desc.gcc-gfortran +++ b/source/d/gcc/slack-desc.gcc-gfortran @@ -1,19 +1,19 @@ # HOW TO EDIT THIS FILE: -# The "handy ruler" below makes it easier to edit a package description. Line +# The "handy ruler" below makes it easier to edit a package description. Line # up the first '|' above the ':' following the base package name, and the '|' on -# the right side marks the last column you can put a character in. You must make -# exactly 11 lines for the formatting to be correct. It's also customary to +# the right side marks the last column you can put a character in. You must make +# exactly 11 lines for the formatting to be correct. It's also customary to # leave one space after the ':'. |-----handy-ruler------------------------------------------------------| gcc-gfortran: gcc-gfortran (Fortran support for GCC) gcc-gfortran: gcc-gfortran: The GNU Fortran compiler is fully compliant with the Fortran 95 -gcc-gfortran: Standard and includes legacy F77 support. In addition, a significant +gcc-gfortran: Standard and includes legacy F77 support. In addition, a significant gcc-gfortran: number of Fortran 2003 and Fortran 2008 features are implemented. gcc-gfortran: GNU Fortran also contains many standard and extensions and can be gcc-gfortran: used to run real-world programs. gcc-gfortran: gcc-gfortran: This package contains those parts of the compiler collection -gcc-gfortran: needed to compile Fortran code. The gcc package is also required. +gcc-gfortran: needed to compile Fortran code. The gcc package is also required. gcc-gfortran: diff --git a/source/d/gcc/slack-desc.gcc-gnat b/source/d/gcc/slack-desc.gcc-gnat index 9aa4b3c4..8ffa7ac0 100644 --- a/source/d/gcc/slack-desc.gcc-gnat +++ b/source/d/gcc/slack-desc.gcc-gnat @@ -1,8 +1,8 @@ # HOW TO EDIT THIS FILE: -# The "handy ruler" below makes it easier to edit a package description. Line +# The "handy ruler" below makes it easier to edit a package description. Line # up the first '|' above the ':' following the base package name, and the '|' on -# the right side marks the last column you can put a character in. You must make -# exactly 11 lines for the formatting to be correct. It's also customary to +# the right side marks the last column you can put a character in. You must make +# exactly 11 lines for the formatting to be correct. It's also customary to # leave one space after the ':'. |-----handy-ruler------------------------------------------------------| @@ -11,9 +11,9 @@ gcc-gnat: gcc-gnat: Ada support for the GNU Compiler Collection. gcc-gnat: gcc-gnat: This package contains those parts of the compiler collection needed to -gcc-gnat: compile Ada code. GNAT implements Ada 95, Ada 2005 and Ada 2012, and -gcc-gnat: it may also be invoked in Ada 83 compatibility mode. By default, GNAT -gcc-gnat: assumes Ada 2012. The base gcc package is also required. +gcc-gnat: compile Ada code. GNAT implements Ada 95, Ada 2005 and Ada 2012, and +gcc-gnat: it may also be invoked in Ada 83 compatibility mode. By default, GNAT +gcc-gnat: assumes Ada 2012. The base gcc package is also required. gcc-gnat: gcc-gnat: gcc-gnat: diff --git a/source/d/gcc/slack-desc.gcc-go b/source/d/gcc/slack-desc.gcc-go index cdd859bc..0c518b18 100644 --- a/source/d/gcc/slack-desc.gcc-go +++ b/source/d/gcc/slack-desc.gcc-go @@ -1,19 +1,19 @@ # HOW TO EDIT THIS FILE: -# The "handy ruler" below makes it easier to edit a package description. Line +# The "handy ruler" below makes it easier to edit a package description. Line # up the first '|' above the ':' following the base package name, and the '|' on -# the right side marks the last column you can put a character in. You must make -# exactly 11 lines for the formatting to be correct. It's also customary to +# the right side marks the last column you can put a character in. You must make +# exactly 11 lines for the formatting to be correct. It's also customary to # leave one space after the ':'. |-----handy-ruler------------------------------------------------------| gcc-go: gcc-go (Go support for GCC) gcc-go: gcc-go: Go is a compiled, garbage-collected, concurrent programming language -gcc-go: developed by Google Inc. The initial design of Go was started in +gcc-go: developed by Google Inc. The initial design of Go was started in gcc-go: September 2007 by Robert Griesemer, Rob Pike, and Ken Thompson. gcc-go: Rob Pike has stated that Go is being used "for real stuff" at Google. gcc-go: Go's "gc" compiler targets the Linux, Mac OS X, FreeBSD, OpenBSD and gcc-go: Microsoft Windows operating systems, and the i386, amd64, and ARM gcc-go: processor architectures. gcc-go: -gcc-go: Homepage: http://golang.org +gcc-go: Homepage: http://golang.org diff --git a/source/d/gcc/slack-desc.gcc-java b/source/d/gcc/slack-desc.gcc-java deleted file mode 100644 index b65ca555..00000000 --- a/source/d/gcc/slack-desc.gcc-java +++ /dev/null @@ -1,19 +0,0 @@ -# HOW TO EDIT THIS FILE: -# The "handy ruler" below makes it easier to edit a package description. Line -# up the first '|' above the ':' following the base package name, and the '|' on -# the right side marks the last column you can put a character in. You must make -# exactly 11 lines for the formatting to be correct. It's also customary to -# leave one space after the ':'. - - |-----handy-ruler------------------------------------------------------| -gcc-java: gcc-java (Java support for GCC) -gcc-java: -gcc-java: Java support for the GNU Compiler Collection. -gcc-java: -gcc-java: This package contains those parts of the compiler collection needed to -gcc-java: compile programs written in the Java programming language. The base -gcc-java: gcc package is also required. -gcc-java: -gcc-java: -gcc-java: -gcc-java: diff --git a/source/d/gcc/slack-desc.gcc-objc b/source/d/gcc/slack-desc.gcc-objc index c01b79e3..17441843 100644 --- a/source/d/gcc/slack-desc.gcc-objc +++ b/source/d/gcc/slack-desc.gcc-objc @@ -1,8 +1,8 @@ # HOW TO EDIT THIS FILE: -# The "handy ruler" below makes it easier to edit a package description. Line +# The "handy ruler" below makes it easier to edit a package description. Line # up the first '|' above the ':' following the base package name, and the '|' on -# the right side marks the last column you can put a character in. You must make -# exactly 11 lines for the formatting to be correct. It's also customary to +# the right side marks the last column you can put a character in. You must make +# exactly 11 lines for the formatting to be correct. It's also customary to # leave one space after the ':'. |-----handy-ruler------------------------------------------------------| @@ -11,7 +11,7 @@ gcc-objc: gcc-objc: Objective-C support for the GNU Compiler Collection. gcc-objc: gcc-objc: This package contains those parts of the compiler collection needed to -gcc-objc: compile code written in Objective-C. Objective-C was originally +gcc-objc: compile code written in Objective-C. Objective-C was originally gcc-objc: developed to add object-oriented extensions to the C language, and is gcc-objc: best known as the native language of the NeXT computer. gcc-objc: diff --git a/source/d/gdb/gdb.SlackBuild b/source/d/gdb/gdb.SlackBuild index 41f6abfd..9c20588f 100755 --- a/source/d/gdb/gdb.SlackBuild +++ b/source/d/gdb/gdb.SlackBuild @@ -1,6 +1,6 @@ -#!/bin/sh +#!/bin/bash -# Copyright 2008, 2009, 2010, 2011, 2012, 2014, 2016 Patrick J. Volkerding, Sebeka, MN, USA +# Copyright 2008, 2009, 2010, 2011, 2012, 2014, 2016, 2017, 2018 Patrick J. Volkerding, Sebeka, MN, USA # All rights reserved. # # Redistribution and use of this script, with or without modification, is @@ -20,10 +20,11 @@ # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +cd $(dirname $0) ; CWD=$(pwd) PKGNAM=gdb VERSION=${VERSION:-$(echo $PKGNAM-*.tar.xz | rev | cut -f 3- -d . | cut -f 1 -d - | rev)} -BUILD=${BUILD:-1} +BUILD=${BUILD:-2} NUMJOBS=${NUMJOBS:-" -j7 "} @@ -37,13 +38,20 @@ if [ -z "$ARCH" ]; then esac fi +# If the variable PRINT_PACKAGE_NAME is set, then this script will report what +# the name of the created package would be, and then exit. This information +# could be useful to other scripts. +if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then + echo "$PKGNAM-$VERSION-$ARCH-$BUILD.txz" + exit 0 +fi + if [ "$ARCH" = "x86_64" ]; then LIBDIRSUFFIX="64" else LIBDIRSUFFIX="" fi -CWD=$(pwd) TMP=${TMP:-/tmp} PKG=$TMP/package-gdb @@ -61,17 +69,25 @@ find . \ \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \ -exec chmod 644 {} \; +# Currently broken in this version, but keep trying: +if [ "$VERSION" = "8.0.1" -o "$VERSION" = "8.1" ]; then + GUILE_OPTION="--without-guile" +else + # Might as well try it to see if it compiles this time: + GUILE_OPTION="--with-guile" +fi + ./configure \ --prefix=/usr \ --libdir=/usr/lib${LIBDIRSUFFIX} \ --mandir=/usr/man \ --infodir=/usr/info \ - --with-guile \ - --with-python \ + $GUILE_OPTION \ + --with-python=/usr/bin/python3 \ + --with-system-readline \ + --with-system-zlib \ --build=$ARCH-slackware-linux || exit 1 -( cd readline ; make ) - make $NUMJOBS || make || exit 1 make install DESTDIR=$PKG || exit 1 @@ -81,10 +97,6 @@ rmdir $PKG/usr/lib${LIBDIRSUFFIX} 2> /dev/null rm -f $PKG/usr/info/{annotate*,bfd*,configure*,standards*} rm -rf $PKG/usr/include -# Use the -tui option if you want this. -# Including a whole extra copy of the gdb binary is obnoxious: -rm -f $PKG/usr/bin/gdbtui $PKG/usr/man/man1/gdbtui.1* - mkdir -p $PKG/usr/doc/gdb-$VERSION/gdb cp -a COPYING* README $PKG/usr/doc/gdb-$VERSION cd gdb diff --git a/source/d/gdb/slack-desc b/source/d/gdb/slack-desc index bd6b78a6..f68e41f9 100644 --- a/source/d/gdb/slack-desc +++ b/source/d/gdb/slack-desc @@ -1,19 +1,19 @@ # HOW TO EDIT THIS FILE: -# The "handy ruler" below makes it easier to edit a package description. Line +# The "handy ruler" below makes it easier to edit a package description. Line # up the first '|' above the ':' following the base package name, and the '|' -# on the right side marks the last column you can put a character in. You must -# make exactly 11 lines for the formatting to be correct. It's also +# on the right side marks the last column you can put a character in. You must +# make exactly 11 lines for the formatting to be correct. It's also # customary to leave one space after the ':'. |-----handy-ruler------------------------------------------------------| gdb: gdb (the GNU symbolic debugger) gdb: GDB, the GNU Project debugger, allows you to see what is going on -gdb: inside another program while it executes -- or what another program -gdb: was doing at the moment it crashed. GDB can do four main kinds of -gdb: things to help you catch bugs in the act: 1) Start your program, -gdb: specifying anything that might affect its behavior. 2) Make your -gdb: program stop on specified conditions. 3) Examine what has happened, -gdb: when your program has stopped. 4) Change things in your program, so +gdb: inside another program while it executes - or what another program +gdb: was doing at the moment it crashed. GDB can do four main kinds of +gdb: things to help you catch bugs in the act: 1) Start your program, +gdb: specifying anything that might affect its behavior. 2) Make your +gdb: program stop on specified conditions. 3) Examine what has happened, +gdb: when your program has stopped. 4) Change things in your program, so gdb: you can experiment with correcting the effects of one bug and go on -gdb: to learn about another. The program being debugged can be written in +gdb: to learn about another. The program being debugged can be written in gdb: Ada, C, C++, Objective-C, Pascal and many other languages. diff --git a/source/d/git/git-2.17.0.tar.sign b/source/d/git/git-2.17.0.tar.sign Binary files differnew file mode 100644 index 00000000..e0bd837b --- /dev/null +++ b/source/d/git/git-2.17.0.tar.sign diff --git a/source/d/git/git-2.9.0.tar.sign b/source/d/git/git-2.9.0.tar.sign Binary files differdeleted file mode 100644 index 47cdfdf4..00000000 --- a/source/d/git/git-2.9.0.tar.sign +++ /dev/null diff --git a/source/d/git/git.SlackBuild b/source/d/git/git.SlackBuild index 3a947c59..b652b50c 100755 --- a/source/d/git/git.SlackBuild +++ b/source/d/git/git.SlackBuild @@ -1,6 +1,6 @@ -#!/bin/sh +#!/bin/bash -# Copyright 2008, 2009, 2010, 2011, 2016 Patrick J. Volkerding, Sebeka, Minnesota, USA +# Copyright 2008, 2009, 2010, 2011, 2016, 2018 Patrick J. Volkerding, Sebeka, Minnesota, USA # All rights reserved. # # Redistribution and use of this script, with or without modification, is @@ -20,10 +20,12 @@ # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -BUILD=${BUILD:-1} +cd $(dirname $0) ; CWD=$(pwd) PKGNAM=git VERSION=${VERSION:-$(echo $PKGNAM-*.tar.?z* | cut -d - -f 2 | rev | cut -f 3- -d . | rev)} +BUILD=${BUILD:-3} + NUMJOBS=${NUMJOBS:-" -j7 "} # Automatically determine the architecture we're building on: @@ -36,6 +38,14 @@ if [ -z "$ARCH" ]; then esac fi +# If the variable PRINT_PACKAGE_NAME is set, then this script will report what +# the name of the created package would be, and then exit. This information +# could be useful to other scripts. +if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then + echo "$PKGNAM-$VERSION-$ARCH-$BUILD.txz" + exit 0 +fi + eval $(perl '-V:installvendorlib') PERLDIR=$installvendorlib/$ARCH-linux-thread-multi/auto @@ -58,7 +68,6 @@ else SLKCFLAGS="-O2" fi -CWD=$(pwd) TMP=${TMP:-/tmp} PKG=$TMP/package-git @@ -68,7 +77,7 @@ mkdir -p $TMP $PKG cd $TMP rm -rf git-$VERSION tar xvf $CWD/git-$VERSION.tar.?z* || exit 1 -cd git-$VERSION +cd git-$VERSION || exit 1 chown -R root:root . find . \ diff --git a/source/d/git/slack-desc b/source/d/git/slack-desc index 271b863a..0e68a383 100644 --- a/source/d/git/slack-desc +++ b/source/d/git/slack-desc @@ -1,8 +1,8 @@ # HOW TO EDIT THIS FILE: -# The "handy ruler" below makes it easier to edit a package description. Line +# The "handy ruler" below makes it easier to edit a package description. Line # up the first '|' above the ':' following the base package name, and the '|' on -# the right side marks the last column you can put a character in. You must make -# exactly 11 lines for the formatting to be correct. It's also customary to +# the right side marks the last column you can put a character in. You must make +# exactly 11 lines for the formatting to be correct. It's also customary to # leave one space after the ':'. |-----handy-ruler------------------------------------------------------| diff --git a/source/d/gnu-cobol/slack-desc b/source/d/gnu-cobol/slack-desc deleted file mode 100644 index 9a6c9b4f..00000000 --- a/source/d/gnu-cobol/slack-desc +++ /dev/null @@ -1,19 +0,0 @@ -# HOW TO EDIT THIS FILE: -# The "handy ruler" below makes it easier to edit a package description. Line -# up the first '|' above the ':' following the base package name, and the '|' -# on the right side marks the last column you can put a character in. You must -# make exactly 11 lines for the formatting to be correct. It's also -# customary to leave one space after the ':'. - - |-----handy-ruler------------------------------------------------------| -gnu-cobol: gnu-cobol (open source COBOL compiler) -gnu-cobol: -gnu-cobol: GNU Cobol is an open source COBOL compiler. GNU Cobol implements a -gnu-cobol: substantial part of the COBOL 85 and COBOL 2002 standards, as well as -gnu-cobol: many extensions of the existent COBOL compilers. GNU Cobol translates -gnu-cobol: COBOL into C and compiles the translated code using the native C -gnu-cobol: compiler. GNU Cobol was written by Roger While and Keisuke Nishida, -gnu-cobol: with the invaluable assistance of many others. -gnu-cobol: -gnu-cobol: Homepage: http://opencobol.add1tocobol.com/gnucobol -gnu-cobol: diff --git a/source/d/gnu-cobol/gnu-cobol.SlackBuild b/source/d/gnucobol/gnucobol.SlackBuild index 142c5cf7..e297a640 100755 --- a/source/d/gnu-cobol/gnu-cobol.SlackBuild +++ b/source/d/gnucobol/gnucobol.SlackBuild @@ -1,6 +1,6 @@ -#!/bin/sh +#!/bin/bash -# Copyright 2013, 2014 Patrick J. Volkerding, Sebeka, Minnesota, USA +# Copyright 2013, 2014, 2017, 2018 Patrick J. Volkerding, Sebeka, Minnesota, USA # All rights reserved. # # Redistribution and use of this script, with or without modification, is @@ -20,15 +20,16 @@ # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +cd $(dirname $0) ; CWD=$(pwd) -PKGNAM=gnu-cobol -VERSION=${VERSION:-$(echo $PKGNAM-*.tar.?z* | rev | cut -f 3- -d . | cut -f 1 -d - | rev)} -BUILD=${BUILD:-1} +PKGNAM=gnucobol +VERSION=${VERSION:-$(echo $PKGNAM-*.tar.xz | rev | cut -f 3- -d . | cut -f 1 -d - | rev)} +BUILD=${BUILD:-2} # Automatically determine the architecture we're building on: if [ -z "$ARCH" ]; then case "$(uname -m)" in - i?86) ARCH=i486 ;; + i?86) ARCH=i586 ;; arm*) readelf /usr/bin/file -A | egrep -q "Tag_CPU.*[4,5]" && ARCH=arm || ARCH=armv7hl ;; # Unless $ARCH is already set, use uname -m for all other archs: *) ARCH=$(uname -m) ;; @@ -36,15 +37,17 @@ if [ -z "$ARCH" ]; then export ARCH fi +# If the variable PRINT_PACKAGE_NAME is set, then this script will report what +# the name of the created package would be, and then exit. This information +# could be useful to other scripts. +if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then + echo "$PKGNAM-$VERSION-$ARCH-$BUILD.txz" + exit 0 +fi + NUMJOBS=${NUMJOBS:-" -j7 "} -if [ "$ARCH" = "i386" ]; then - SLKCFLAGS="-O2 -march=i386 -mcpu=i686" - LIBDIRSUFFIX="" -elif [ "$ARCH" = "i486" ]; then - SLKCFLAGS="-O2 -march=i486 -mtune=i686" - LIBDIRSUFFIX="" -elif [ "$ARCH" = "i586" ]; then +if [ "$ARCH" = "i586" ]; then SLKCFLAGS="-O2 -march=i586 -mtune=i686" LIBDIRSUFFIX="" elif [ "$ARCH" = "i686" ]; then @@ -64,7 +67,6 @@ else LIBDIRSUFFIX="" fi -CWD=$(pwd) TMP=${TMP:-/tmp} PKG=$TMP/package-$PKGNAM @@ -73,8 +75,8 @@ mkdir -p $TMP $PKG cd $TMP rm -rf $PKGNAM-$VERSION -tar xvf $CWD/$PKGNAM-$VERSION.tar.?z* || exit 1 -cd $PKGNAM-$VERSION +tar xvf $CWD/$PKGNAM-$VERSION.tar.xz || exit 1 +cd $PKGNAM-$VERSION || exit 1 chown -R root:root . find . \ @@ -91,12 +93,15 @@ CFLAGS="$SLKCFLAGS" \ --libdir=/usr/lib${LIBDIRSUFFIX} \ --mandir=/usr/man \ --infodir=/usr/info \ - --build=$ARCH-slackware-linux + --build=$ARCH-slackware-linux || exit 1 # Build and install: make $NUMJOBS || make || exit 1 make install DESTDIR=$PKG || exit 1 +# Don't ship .la files: +rm -f $PKG/{,usr/}lib${LIBDIRSUFFIX}/*.la + # Strip binaries: ( cd $PKG find . | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null @@ -106,7 +111,7 @@ make install DESTDIR=$PKG || exit 1 # Add a documentation directory: mkdir -p $PKG/usr/doc/${PKGNAM}-$VERSION cp -a \ - ABOUT-NLS AUTHORS COPYING* ChangeLog INSTALL NEWS README* THANKS TODO \ + ABOUT-NLS AUTHORS COPYING* ChangeLog INSTALL NEWS* README* THANKS TODO \ $PKG/usr/doc/${PKGNAM}-$VERSION # Compress info files, if any: diff --git a/source/d/gnucobol/slack-desc b/source/d/gnucobol/slack-desc new file mode 100644 index 00000000..58bdb56e --- /dev/null +++ b/source/d/gnucobol/slack-desc @@ -0,0 +1,19 @@ +# HOW TO EDIT THIS FILE: +# The "handy ruler" below makes it easier to edit a package description. Line +# up the first '|' above the ':' following the base package name, and the '|' +# on the right side marks the last column you can put a character in. You must +# make exactly 11 lines for the formatting to be correct. It's also +# customary to leave one space after the ':'. + + |-----handy-ruler------------------------------------------------------| +gnucobol: gnucobol (open source COBOL compiler) +gnucobol: +gnucobol: GNU Cobol is an open source COBOL compiler. GNU Cobol implements a +gnucobol: substantial part of the COBOL 85, COBOL 2002, and COBOL 2014 +gnucobol: standards, as well as many extensions of the existent COBOL compilers. +gnucobol: GNU Cobol translates COBOL into C and compiles the translated code +gnucobol: using the native C compiler. GNU Cobol was written by Roger While and +gnucobol: Keisuke Nishida, with the invaluable assistance of many others. +gnucobol: +gnucobol: Homepage: ftp://ftp.gnu.org/gnu/gnucobol +gnucobol: diff --git a/source/d/gperf/gperf.SlackBuild b/source/d/gperf/gperf.SlackBuild index 62062dff..960df915 100755 --- a/source/d/gperf/gperf.SlackBuild +++ b/source/d/gperf/gperf.SlackBuild @@ -1,6 +1,6 @@ -#!/bin/sh +#!/bin/bash -# Copyright 2006, 2007, 2008, 2009, 2010 Patrick J. Volkerding, Sebeka, MN, USA +# Copyright 2006, 2007, 2008, 2009, 2010, 2018 Patrick J. Volkerding, Sebeka, MN, USA # All rights reserved. # # Redistribution and use of this script, with or without modification, is @@ -20,31 +20,39 @@ # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +cd $(dirname $0) ; CWD=$(pwd) PKGNAM=gperf VERSION=${VERSION:-$(echo $PKGNAM-*.tar.?z* | rev | cut -f 3- -d . | cut -f 1 -d - | rev)} -BUILD=${BUILD:-1} +BUILD=${BUILD:-2} # Automatically determine the architecture we're building on: if [ -z "$ARCH" ]; then case "$( uname -m )" in - i?86) export ARCH=i486 ;; + i?86) export ARCH=i586 ;; arm*) export ARCH=arm ;; # Unless $ARCH is already set, use uname -m for all other archs: *) export ARCH=$( uname -m ) ;; esac fi +# If the variable PRINT_PACKAGE_NAME is set, then this script will report what +# the name of the created package would be, and then exit. This information +# could be useful to other scripts. +if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then + echo "$PKGNAM-$VERSION-$ARCH-$BUILD.txz" + exit 0 +fi + NUMJOBS=${NUMJOBS:-" -j7 "} -CWD=$(pwd) TMP=${TMP:-/tmp} PKG=$TMP/package-${PKGNAM} rm -rf $PKG mkdir -p $TMP $PKG -if [ "$ARCH" = "i486" ]; then - SLKCFLAGS="-O2 -march=i486 -mtune=i686" +if [ "$ARCH" = "i586" ]; then + SLKCFLAGS="-O2 -march=i586 -mtune=i686" elif [ "$ARCH" = "s390" ]; then SLKCFLAGS="-O2" elif [ "$ARCH" = "x86_64" ]; then @@ -74,7 +82,7 @@ CFLAGS="$SLKCFLAGS" \ --mandir=/usr/man \ --infodir=/usr/info \ --docdir=/usr/doc/gperf-$VERSION \ - --build=$ARCH-slackware-linux + --build=$ARCH-slackware-linux || exit 1 # Build and install: make $NUMJOBS || make || exit 1 diff --git a/source/d/gperf/slack-desc b/source/d/gperf/slack-desc index 9451a6f8..e6963daf 100644 --- a/source/d/gperf/slack-desc +++ b/source/d/gperf/slack-desc @@ -1,8 +1,8 @@ # HOW TO EDIT THIS FILE: -# The "handy ruler" below makes it easier to edit a package description. Line +# The "handy ruler" below makes it easier to edit a package description. Line # up the first '|' above the ':' following the base package name, and the '|' -# on the right side marks the last column you can put a character in. You must -# make exactly 11 lines for the formatting to be correct. It's also +# on the right side marks the last column you can put a character in. You must +# make exactly 11 lines for the formatting to be correct. It's also # customary to leave one space after the ':'. |-----handy-ruler------------------------------------------------------| @@ -10,7 +10,7 @@ gperf: gperf (a perfect hash function generator) gperf: gperf: gperf is a perfect hash function generator written in C++. gperf: It transforms an n element user-specified keyword set W into a -gperf: perfect hash function F. gperf currently generates the reserved +gperf: perfect hash function F. gperf currently generates the reserved gperf: keyword recognizer for lexical analyzers in several production and gperf: research compilers and language processing tools, including GNU C, gperf: GNU C++, GNU Java, GNU Pascal, GNU Modula 3, and GNU indent. diff --git a/source/d/guile/guile.SlackBuild b/source/d/guile/guile.SlackBuild index ef6cdd1a..e71c701e 100755 --- a/source/d/guile/guile.SlackBuild +++ b/source/d/guile/guile.SlackBuild @@ -1,6 +1,6 @@ -#!/bin/sh +#!/bin/bash -# Copyright 2008, 2009, 2010, 2011, 2013 Patrick J. Volkerding, Sebeka, MN, USA +# Copyright 2008, 2009, 2010, 2011, 2013, 2016, 2017, 2018 Patrick J. Volkerding, Sebeka, MN, USA # All rights reserved. # # Redistribution and use of this script, with or without modification, is @@ -20,31 +20,39 @@ # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +cd $(dirname $0) ; CWD=$(pwd) PKGNAM=guile -VERSION=${VERSION:-$(echo $PKGNAM-*.tar.xz | rev | cut -f 3- -d . | cut -f 1 -d - | rev)} +VERSION=${VERSION:-$(echo $PKGNAM-*.tar.?z | rev | cut -f 3- -d . | cut -f 1 -d - | rev)} BUILD=${BUILD:-2} # Automatically determine the architecture we're building on: if [ -z "$ARCH" ]; then case "$( uname -m )" in - i?86) export ARCH=i486 ;; + i?86) export ARCH=i586 ;; arm*) export ARCH=arm ;; # Unless $ARCH is already set, use uname -m for all other archs: *) export ARCH=$( uname -m ) ;; esac fi +# If the variable PRINT_PACKAGE_NAME is set, then this script will report what +# the name of the created package would be, and then exit. This information +# could be useful to other scripts. +if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then + echo "$PKGNAM-$VERSION-$ARCH-$BUILD.txz" + exit 0 +fi + NUMJOBS=${NUMJOBS:-" -j7 "} -CWD=$(pwd) TMP=${TMP:-/tmp} PKG=$TMP/package-guile rm -rf $PKG mkdir -p $PKG/usr -if [ "$ARCH" = "i486" ]; then - SLKCFLAGS="-O2 -march=i486 -mtune=i686" +if [ "$ARCH" = "i586" ]; then + SLKCFLAGS="-O2 -march=i586 -mtune=i686" LIBDIRSUFFIX="" elif [ "$ARCH" = "s390" ]; then SLKCFLAGS="-O2" @@ -59,8 +67,9 @@ fi cd $TMP rm -rf guile-$VERSION -tar xvf $CWD/guile-$VERSION.tar.xz || exit 1 +tar xvf $CWD/guile-$VERSION.tar.?z || exit 1 cd guile-$VERSION || exit 1 + chown -R root:root . find . \ \( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \ @@ -78,17 +87,26 @@ CFLAGS="$SLKCFLAGS" \ --disable-static \ --disable-rpath \ --disable-error-on-warning \ - --build=$ARCH-slackware-linux + --build=$ARCH-slackware-linux || exit 1 # Does not like parallel make... make $NUMJOBS || make || exit 1 make install DESTDIR=$PKG || exit 1 +# Don't ship .la files: +rm -f $PKG/{,usr/}lib${LIBDIRSUFFIX}/*.la + # Move libguile*-gdb.scm to GDB's autoload directory to avoid # getting "not an ELF file" errors from ldconfig: mkdir -p $PKG/usr/share/gdb/auto-load/usr/lib${LIBDIRSUFFIX} mv $PKG/usr/lib${LIBDIRSUFFIX}/libguile*-gdb.scm $PKG/usr/share/gdb/auto-load/usr/lib${LIBDIRSUFFIX} || exit 1 +# Change timestamps on *.go and *.scm files, otherwise on multilib systems +# the compiled (go) files may be detected as older than the source (scm) +# files, causing guile to attempt to recompile itself with every use: +find $PKG/usr/lib${LIBDIRSUFFIX} -name "*.go" -exec touch -r $CWD/guile.SlackBuild "{}" \; +find $PKG/usr/share -name "*.scm" -exec touch -r $CWD/guile.SlackBuild "{}" \; + find $PKG | xargs file | grep -e "executable" -e "shared object" | grep ELF \ | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null diff --git a/source/d/guile/slack-desc b/source/d/guile/slack-desc index 2c23793f..c15b525f 100644 --- a/source/d/guile/slack-desc +++ b/source/d/guile/slack-desc @@ -1,16 +1,16 @@ # HOW TO EDIT THIS FILE: -# The "handy ruler" below makes it easier to edit a package description. Line +# The "handy ruler" below makes it easier to edit a package description. Line # up the first '|' above the ':' following the base package name, and the '|' -# on the right side marks the last column you can put a character in. You must -# make exactly 11 lines for the formatting to be correct. It's also +# on the right side marks the last column you can put a character in. You must +# make exactly 11 lines for the formatting to be correct. It's also # customary to leave one space after the ':'. |-----handy-ruler------------------------------------------------------| guile: guile (GNU extension language library) guile: -guile: This is Guile, Project GNU's extension language library. Guile is an +guile: This is Guile, Project GNU's extension language library. Guile is an guile: interpreter for Scheme, packaged as a library that you can link into -guile: your applications to give them their own scripting language. Guile +guile: your applications to give them their own scripting language. Guile guile: will eventually support other languages as well, giving users of guile: Guile-based applications a choice of languages. guile: diff --git a/source/d/help2man/help2man.SlackBuild b/source/d/help2man/help2man.SlackBuild index 7c21dc6f..00469327 100755 --- a/source/d/help2man/help2man.SlackBuild +++ b/source/d/help2man/help2man.SlackBuild @@ -1,6 +1,6 @@ -#!/bin/sh +#!/bin/bash -# Copyright 2013, 2015 Patrick J. Volkerding, Sebeka, Minnesota, USA +# Copyright 2013, 2015, 2018 Patrick J. Volkerding, Sebeka, Minnesota, USA # All rights reserved. # # Redistribution and use of this script, with or without modification, is @@ -20,15 +20,16 @@ # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +cd $(dirname $0) ; CWD=$(pwd) PKGNAM=help2man VERSION=${VERSION:-$(echo $PKGNAM-*.tar.xz | rev | cut -f 3- -d . | cut -f 1 -d - | rev)} -BUILD=${BUILD:-1} +BUILD=${BUILD:-2} # Automatically determine the architecture we're building on: if [ -z "$ARCH" ]; then case "$(uname -m)" in - i?86) ARCH=i486 ;; + i?86) ARCH=i586 ;; arm*) readelf /usr/bin/file -A | egrep -q "Tag_CPU.*[4,5]" && ARCH=arm || ARCH=armv7hl ;; # Unless $ARCH is already set, use uname -m for all other archs: *) ARCH=$(uname -m) ;; @@ -36,6 +37,14 @@ if [ -z "$ARCH" ]; then export ARCH fi +# If the variable PRINT_PACKAGE_NAME is set, then this script will report what +# the name of the created package would be, and then exit. This information +# could be useful to other scripts. +if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then + echo "$PKGNAM-$VERSION-$ARCH-$BUILD.txz" + exit 0 +fi + NUMJOBS=${NUMJOBS:-" -j7 "} if [ "$ARCH" = "i386" ]; then @@ -64,7 +73,6 @@ else LIBDIRSUFFIX="" fi -CWD=$(pwd) TMP=${TMP:-/tmp} PKG=$TMP/package-$PKGNAM @@ -74,7 +82,7 @@ mkdir -p $TMP $PKG cd $TMP rm -rf $PKGNAM-$VERSION tar xvf $CWD/$PKGNAM-$VERSION.tar.xz || exit 1 -cd $PKGNAM-$VERSION +cd $PKGNAM-$VERSION || exit 1 chown -R root:root . find . \ @@ -92,7 +100,7 @@ CFLAGS="$SLKCFLAGS" \ --infodir=/usr/info \ --mandir=/usr/man \ --localstatedir=/var \ - --build=$ARCH-slackware-linux + --build=$ARCH-slackware-linux || exit 1 # Build and install: make $NUMJOBS || make || exit 1 diff --git a/source/d/help2man/slack-desc b/source/d/help2man/slack-desc index 42173639..7fc5ff16 100644 --- a/source/d/help2man/slack-desc +++ b/source/d/help2man/slack-desc @@ -1,8 +1,8 @@ # HOW TO EDIT THIS FILE: -# The "handy ruler" below makes it easier to edit a package description. Line +# The "handy ruler" below makes it easier to edit a package description. Line # up the first '|' above the ':' following the base package name, and the '|' -# on the right side marks the last column you can put a character in. You must -# make exactly 11 lines for the formatting to be correct. It's also +# on the right side marks the last column you can put a character in. You must +# make exactly 11 lines for the formatting to be correct. It's also # customary to leave one space after the ':'. |-----handy-ruler------------------------------------------------------| @@ -11,7 +11,7 @@ help2man: help2man: help2man is a tool for automatically generating simple manual pages help2man: from program output. help2man: -help2man: Homepage: http://www.gnu.org/software/help2man +help2man: Homepage: http://www.gnu.org/software/help2man help2man: help2man: help2man: diff --git a/source/d/indent/indent.SlackBuild b/source/d/indent/indent.SlackBuild index d8bdbf19..169bcb97 100755 --- a/source/d/indent/indent.SlackBuild +++ b/source/d/indent/indent.SlackBuild @@ -1,6 +1,6 @@ -#!/bin/sh +#!/bin/bash -# Copyright 2008, 2009, 2010 Patrick J. Volkerding, Sebeka, MN, USA +# Copyright 2008, 2009, 2010, 2018 Patrick J. Volkerding, Sebeka, MN, USA # All rights reserved. # # Redistribution and use of this script, with or without modification, is @@ -20,22 +20,32 @@ # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +cd $(dirname $0) ; CWD=$(pwd) +PKGNAM=indent VERSION=${VERSION:-2.2.10} -BUILD=${BUILD:-1} +BUILD=${BUILD:-2} # Automatically determine the architecture we're building on: if [ -z "$ARCH" ]; then case "$( uname -m )" in - i?86) export ARCH=i486 ;; + i?86) export ARCH=i586 ;; arm*) export ARCH=arm ;; # Unless $ARCH is already set, use uname -m for all other archs: *) export ARCH=$( uname -m ) ;; esac fi -if [ "$ARCH" = "i486" ]; then - SLKCFLAGS="-O2 -march=i486 -mtune=i686" +# If the variable PRINT_PACKAGE_NAME is set, then this script will report what +# the name of the created package would be, and then exit. This information +# could be useful to other scripts. +if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then + echo "$PKGNAM-$VERSION-$ARCH-$BUILD.txz" + exit 0 +fi + +if [ "$ARCH" = "i586" ]; then + SLKCFLAGS="-O2 -march=i586 -mtune=i686" elif [ "$ARCH" = "i686" ]; then SLKCFLAGS="-O2 -march=i686 -mtune=i686" elif [ "$ARCH" = "s390" ]; then @@ -48,7 +58,6 @@ fi NUMJOBS=${NUMJOBS:-" -j7 "} -CWD=$(pwd) TMP=${TMP:-/tmp} PKG=$TMP/package-indent rm -rf $PKG @@ -57,7 +66,7 @@ mkdir -p $TMP $PKG cd $TMP rm -rf indent-$VERSION tar xvf $CWD/indent-$VERSION.tar.bz2 || exit 1 -cd indent-$VERSION +cd indent-$VERSION || exit 1 chown -R root:root . find . \ \( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \ @@ -76,10 +85,10 @@ CXXFLAGS="$SLKCFLAGS" \ --localstatedir=/var \ --mandir=/usr/man \ --infodir=/usr/info \ - --build=$ARCH-slackware-linux + --build=$ARCH-slackware-linux || exit 1 make $NUMJOBS || make || exit 1 -make install DESTDIR=$PKG +make install DESTDIR=$PKG || exit 1 # I'm not sure why this man page fails, but... if find $PKG -type f -size 0c -name indent.1 ; then diff --git a/source/d/indent/slack-desc b/source/d/indent/slack-desc index fd1d0712..8274a0e5 100644 --- a/source/d/indent/slack-desc +++ b/source/d/indent/slack-desc @@ -1,15 +1,15 @@ # HOW TO EDIT THIS FILE: -# The "handy ruler" below makes it easier to edit a package description. Line +# The "handy ruler" below makes it easier to edit a package description. Line # up the first '|' above the ':' following the base package name, and the '|' -# on the right side marks the last column you can put a character in. You must -# make exactly 11 lines for the formatting to be correct. It's also +# on the right side marks the last column you can put a character in. You must +# make exactly 11 lines for the formatting to be correct. It's also # customary to leave one space after the ':'. |-----handy-ruler------------------------------------------------------| indent: indent (changes the appearance of a C program) indent: indent: GNU indent changes the appearance of a C program by inserting or -indent: deleting whitespace according to a plethora of options. Some canned +indent: deleting whitespace according to a plethora of options. Some canned indent: styles of formatting (like the GNU style, Kernighan & Ritchie style, indent: and original Berkeley style) are supported as well. indent: diff --git a/source/d/intltool/intltool.SlackBuild b/source/d/intltool/intltool.SlackBuild index bf5a8f72..427f48b7 100755 --- a/source/d/intltool/intltool.SlackBuild +++ b/source/d/intltool/intltool.SlackBuild @@ -1,6 +1,6 @@ -#!/bin/sh +#!/bin/bash -# Copyright 2008, 2009, 2010, 2012, 2015 Patrick J. Volkerding, Sebeka, MN, USA +# Copyright 2008, 2009, 2010, 2012, 2015, 2018 Patrick J. Volkerding, Sebeka, MN, USA # All rights reserved. # # Redistribution and use of this script, with or without modification, is @@ -20,10 +20,11 @@ # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +cd $(dirname $0) ; CWD=$(pwd) PKGNAM=intltool VERSION=${VERSION:-$(echo $PKGNAM-*.tar.?z* | rev | cut -f 3- -d . | cut -f 1 -d - | rev)} -BUILD=${BUILD:-2} +BUILD=${BUILD:-4} NUMJOBS=${NUMJOBS:-" -j7 "} @@ -37,7 +38,14 @@ if [ -z "$ARCH" ]; then esac fi -CWD=$(pwd) +# If the variable PRINT_PACKAGE_NAME is set, then this script will report what +# the name of the created package would be, and then exit. This information +# could be useful to other scripts. +if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then + echo "$PKGNAM-$VERSION-$ARCH-$BUILD.txz" + exit 0 +fi + TMP=${TMP:-/tmp} PKG=$TMP/package-${PKGNAM} @@ -69,6 +77,9 @@ find . \ # Compatability with perl 5.22: zcat $CWD/intltool-0.51.0-perl-5.22.patch.gz | patch -p1 --verbose || exit 1 +# Fix build issues when used with automake >= 1.15: +zcat $CWD/no-guess-builddir.diff.gz | patch -p0 --verbose || exit 1 + # Configure: CFLAGS="$SLKCFLAGS" \ ./configure \ diff --git a/source/d/intltool/no-guess-builddir.diff b/source/d/intltool/no-guess-builddir.diff new file mode 100644 index 00000000..3670ee52 --- /dev/null +++ b/source/d/intltool/no-guess-builddir.diff @@ -0,0 +1,31 @@ +=== modified file 'intltool-update.in' +--- intltool-update.in 2014-05-14 02:15:53 +0000 ++++ intltool-update.in 2015-02-03 15:05:59 +0000 +@@ -620,6 +620,14 @@ + + my @result; + ++ # If the builddir is a subdir of srcdir, the list of files found will be prefixed with ++ # an additional prefix (e.g. "_build/sub" for automake 1.15 make distcheck). Try to ++ # handle that, by removing those matches as well. ++ my $absbuilddir = Cwd::abs_path("..\/"); ++ my $abssrcdir = Cwd::abs_path("$SRCDIR/.."); ++ # Check if builddir is a subdir of srcdir ++ my ($abspath,$relpath) = split /\s*$abssrcdir\/\s*/, $absbuilddir, 2; ++ + foreach (@buf_allfiles_sorted) + { + my $dummy = $_; +@@ -628,7 +636,10 @@ + $srcdir =~ s#^../##; + $dummy =~ s#^$srcdir/../##; + $dummy =~ s#^$srcdir/##; +- $dummy =~ s#_build/##; ++ if ($relpath) ++ { ++ $dummy =~ s#^$relpath/##; ++ } + if (!exists($in2{$dummy})) + { + push @result, $dummy + diff --git a/source/d/intltool/slack-desc b/source/d/intltool/slack-desc index 6741f290..905027b3 100644 --- a/source/d/intltool/slack-desc +++ b/source/d/intltool/slack-desc @@ -1,8 +1,8 @@ # HOW TO EDIT THIS FILE: -# The "handy ruler" below makes it easier to edit a package description. Line +# The "handy ruler" below makes it easier to edit a package description. Line # up the first '|' above the ':' following the base package name, and the '|' -# on the right side marks the last column you can put a character in. You must -# make exactly 11 lines for the formatting to be correct. It's also +# on the right side marks the last column you can put a character in. You must +# make exactly 11 lines for the formatting to be correct. It's also # customary to leave one space after the ':'. |-----handy-ruler------------------------------------------------------| @@ -11,7 +11,7 @@ intltool: intltool: This package contains scripts and autoconf files for intltool: internationalizing data. intltool: -intltool: +intltool: Homepage: https://edge.launchpad.net/intltool intltool: intltool: intltool: diff --git a/source/d/kernel-headers/slack-desc b/source/d/kernel-headers/slack-desc deleted file mode 100644 index 1593f4df..00000000 --- a/source/d/kernel-headers/slack-desc +++ /dev/null @@ -1,19 +0,0 @@ -# HOW TO EDIT THIS FILE: -# The "handy ruler" below makes it easier to edit a package description. Line -# up the first '|' above the ':' following the base package name, and the '|' -# on the right side marks the last column you can put a character in. You must -# make exactly 11 lines for the formatting to be correct. It's also -# customary to leave one space after the ':'. - - |-----handy-ruler------------------------------------------------------| -kernel-headers: kernel-headers (Linux kernel include files) -kernel-headers: -kernel-headers: These are the include files from the Linux kernel. -kernel-headers: -kernel-headers: You'll need these to compile most system software for Linux. -kernel-headers: -kernel-headers: -kernel-headers: -kernel-headers: -kernel-headers: -kernel-headers: diff --git a/source/d/libtool/libtool.SlackBuild b/source/d/libtool/libtool.SlackBuild index 44810932..0d77480e 100755 --- a/source/d/libtool/libtool.SlackBuild +++ b/source/d/libtool/libtool.SlackBuild @@ -1,6 +1,6 @@ -#!/bin/sh +#!/bin/bash -# Copyright 2008, 2013, 2015 Patrick J. Volkerding, Sebeka, MN, USA +# Copyright 2008, 2013, 2015, 2018 Patrick J. Volkerding, Sebeka, MN, USA # All rights reserved. # # Redistribution and use of this script, with or without modification, is @@ -20,8 +20,11 @@ # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +cd $(dirname $0) ; CWD=$(pwd) + +PKGNAM=libtool VERSION=${VERSION:-$(echo libtool-*.tar.xz | rev | cut -f 3- -d . | cut -f 1 -d - | rev)} -BUILD=${BUILD:-4} +BUILD=${BUILD:-7} NUMJOBS=${NUMJOBS:--j6} @@ -35,7 +38,14 @@ if [ -z "$ARCH" ]; then esac fi -CWD=$(pwd) +# If the variable PRINT_PACKAGE_NAME is set, then this script will report what +# the name of the created package would be, and then exit. This information +# could be useful to other scripts. +if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then + echo "$PKGNAM-$VERSION-$ARCH-$BUILD.txz" + exit 0 +fi + TMP=${TMP:-/tmp} PKG=$TMP/package-libtool @@ -82,6 +92,12 @@ CFLAGS="$SLKCFLAGS" \ make $NUMJOBS || make || exit 1 make install DESTDIR=$PKG || exit 1 +# Don't ship .la files: +rm -f $PKG/{,usr/}lib${LIBDIRSUFFIX}/*.la + +# Don't package the static libraries: +rm -f $PKG/usr/lib${LIBDIRSUFFIX}/*.a + find $PKG | xargs file | grep -e "executable" -e "shared object" | grep ELF \ | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null diff --git a/source/d/libtool/slack-desc b/source/d/libtool/slack-desc index 7bf0e8d3..88866a49 100644 --- a/source/d/libtool/slack-desc +++ b/source/d/libtool/slack-desc @@ -1,8 +1,8 @@ # HOW TO EDIT THIS FILE: -# The "handy ruler" below makes it easier to edit a package description. Line +# The "handy ruler" below makes it easier to edit a package description. Line # up the first '|' above the ':' following the base package name, and the '|' -# on the right side marks the last column you can put a character in. You must -# make exactly 11 lines for the formatting to be correct. It's also +# on the right side marks the last column you can put a character in. You must +# make exactly 11 lines for the formatting to be correct. It's also # customary to leave one space after the ':'. |-----handy-ruler------------------------------------------------------| @@ -10,8 +10,8 @@ libtool: libtool (a generic library support script) libtool: libtool: This is GNU Libtool, a generic library support script. Libtool hides libtool: the complexity of using shared libraries behind a consistent, portable -libtool: interface. To use libtool, add the new generic library building -libtool: commands to your Makefile, Makefile.in, or Makefile.am. See the +libtool: interface. To use libtool, add the new generic library building +libtool: commands to your Makefile, Makefile.in, or Makefile.am. See the libtool: documentation for details. libtool: libtool: You must install the "m4" package to be able to use libtool. diff --git a/source/d/llvm/clang.toolchains.i586.triple.diff b/source/d/llvm/clang.toolchains.i586.triple.diff index 3795f5e0..01b87c68 100644 --- a/source/d/llvm/clang.toolchains.i586.triple.diff +++ b/source/d/llvm/clang.toolchains.i586.triple.diff @@ -1,11 +1,13 @@ ---- ./tools/clang/lib/Driver/ToolChains.cpp.orig 2015-09-13 13:30:39.748069603 -0500 -+++ ./tools/clang/lib/Driver/ToolChains.cpp 2015-09-13 13:32:16.584075557 -0500 -@@ -1296,7 +1296,7 @@ +--- ./tools/clang/lib/Driver/ToolChains/Gnu.cpp.orig 2017-08-10 20:47:32.000000000 -0500 ++++ ./tools/clang/lib/Driver/ToolChains/Gnu.cpp 2017-09-07 14:41:16.170110145 -0500 +@@ -1834,8 +1834,8 @@ "i686-linux-gnu", "i686-pc-linux-gnu", "i486-linux-gnu", "i386-linux-gnu", "i386-redhat-linux6E", "i686-redhat-linux", "i586-redhat-linux", "i386-redhat-linux", "i586-suse-linux", - "i486-slackware-linux", "i686-montavista-linux", "i686-linux-android", -+ "i486-slackware-linux", "i586-slackware-linux", "i686-montavista-linux", "i686-linux-android", - "i586-linux-gnu"}; +- "i586-linux-gnu"}; ++ "i486-slackware-linux", "i586-slackware-linux", "i686-montavista-linux", ++ "i686-linux-android", "i586-linux-gnu"}; static const char *const MIPSLibDirs[] = {"/lib"}; + static const char *const MIPSTriples[] = {"mips-linux-gnu", "mips-mti-linux", diff --git a/source/d/llvm/clang_disable_pgo.patch b/source/d/llvm/clang_disable_pgo.patch new file mode 100644 index 00000000..c3998798 --- /dev/null +++ b/source/d/llvm/clang_disable_pgo.patch @@ -0,0 +1,14 @@ +--- ./tools/clang/lib/CodeGen/CodeGenPGO.cpp.orig 2018-03-08 19:50:01.115345121 -0600 ++++ ./tools/clang/lib/CodeGen/CodeGenPGO.cpp 2018-03-08 19:52:24.016358481 -0600 +@@ -22,10 +22,7 @@ + #include "llvm/Support/FileSystem.h" + #include "llvm/Support/MD5.h" + +-static llvm::cl::opt<bool> +- EnableValueProfiling("enable-value-profiling", llvm::cl::ZeroOrMore, +- llvm::cl::desc("Enable value profiling"), +- llvm::cl::Hidden, llvm::cl::init(false)); ++static bool EnableValueProfiling = false; + + using namespace clang; + using namespace CodeGen; diff --git a/source/d/llvm/llvm.SlackBuild b/source/d/llvm/llvm.SlackBuild index 4d15ffaa..4fb47ac4 100755 --- a/source/d/llvm/llvm.SlackBuild +++ b/source/d/llvm/llvm.SlackBuild @@ -1,8 +1,8 @@ -#!/bin/sh +#!/bin/bash # Slackware build script for llvm -# Copyright 2008-2015 Heinz Wiesinger, Amsterdam, The Netherlands +# Copyright 2008-2016 Heinz Wiesinger, Amsterdam, The Netherlands # Copyright 2012, 2013, 2014, 2015, 2016 Patrick J. Volkerding, Sebeka, MN, USA # All rights reserved. # @@ -23,6 +23,8 @@ # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +cd $(dirname $0) ; CWD=$(pwd) + PKGNAM=llvm VERSION=${VERSION:-$(echo llvm-*.tar.xz | rev | cut -f 4- -d . | cut -f 1 -d - | rev)} BUILD=${BUILD:-2} @@ -37,7 +39,14 @@ if [ -z "$ARCH" ]; then esac fi -CWD=$(pwd) +# If the variable PRINT_PACKAGE_NAME is set, then this script will report what +# the name of the created package would be, and then exit. This information +# could be useful to other scripts. +if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then + echo "$PKGNAM-$VERSION-$ARCH-$BUILD.txz" + exit 0 +fi + TMP=${TMP:-/tmp} PKG=$TMP/package-$PKGNAM @@ -64,6 +73,8 @@ tar xvf $CWD/$PKGNAM-$VERSION.src.tar.xz || exit 1 cd $PKGNAM-${VERSION}/tools || cd $PKGNAM-${VERSION}.src/tools || exit 1 tar xvf $CWD/cfe-$VERSION.src.tar.xz || exit 1 mv cfe-${VERSION} clang 2>/dev/null || mv cfe-${VERSION}.src clang || exit 1 + tar xvf $CWD/lldb-$VERSION.src.tar.xz || exit 1 + mv lldb-${VERSION} lldb 2>/dev/null || mv lldb-${VERSION}.src lldb || exit 1 cd ../ cd tools/clang/tools || exit 1 @@ -76,14 +87,25 @@ cd projects || exit 1 tar xvf $CWD/compiler-rt-$VERSION.src.tar.xz || exit 1 mv compiler-rt-${VERSION} compiler-rt 2>/dev/null \ || mv compiler-rt-${VERSION}.src compiler-rt || exit 1 + tar xvf $CWD/openmp-$VERSION.src.tar.xz || exit 1 + mv openmp-${VERSION} openmp 2>/dev/null \ + || mv openmp-${VERSION}.src openmp || exit 1 + tar xvf $CWD/libcxx-${VERSION}.src.tar.xz || exit 1 + mv libcxx-${VERSION} libcxx 2>/dev/null \ + || mv libcxx-${VERSION}.src libcxx || exit 1 + tar xvf $CWD/libcxxabi-${VERSION}.src.tar.xz || exit 1 + mv libcxxabi-${VERSION} libcxxabi 2>/dev/null \ + || mv libcxxabi-${VERSION}.src libcxxabi || exit 1 cd ../ # Support GCC built for i586-slackware-linux: zcat $CWD/clang.toolchains.i586.triple.diff.gz | patch -p1 --verbose || exit 1 -# Use i586 $ARCH on 32-bit x86: -sed -r "/ifeq.*CompilerTargetArch/s#i386#i586#g" \ - -i projects/compiler-rt/make/platform/clang_linux.mk +## This seems obsolete, so commenting it out: +# +## Use i586 $ARCH on 32-bit x86: +#sed -r "/ifeq.*CompilerTargetArch/s#i386#i586#g" \ +# -i projects/compiler-rt/make/platform/clang_linux.mk chown -R root:root . find . \ @@ -92,6 +114,10 @@ find . \ \( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \ -exec chmod 644 {} \; +# disable value profiling until https://llvm.org/bugs/show_bug.cgi?id=30587 +# is fixed. +zcat $CWD/clang_disable_pgo.patch.gz | patch -p1 --verbose || exit 1 + # need to disable assertions to make llvm thread-safe # clang resource dir is a relative path based on the location of the clang binary mkdir build @@ -112,7 +138,7 @@ cd build -DLLVM_ENABLE_ASSERTIONS=OFF \ -DLLVM_BINUTILS_INCDIR=/usr/include \ -DCLANG_RESOURCE_DIR="../lib${LIBDIRSUFFIX}/clang/${VERSION}" \ - .. + .. || exit 1 # breaks with one of the patches above. Maybe revisit later # -DBUILD_SHARED_LIBS=ON \ @@ -133,26 +159,25 @@ for i in ccc c++; do $PKG/usr/bin/$i-analyzer || exit 1 done -## Fix paths in scan-build -#sed -i "s|\$RealBin/bin|/usr/bin|" \ -# $PKG/usr/lib$LIBDIRSUFFIX/clang-analyzer/scan-build/scan-build -#sed -i "s|\$RealBin/sorttable.js|/usr/lib${LIBDIRSUFFIX}/clang-analyzer/scan-build/sorttable.js|" \ -# $PKG/usr/lib$LIBDIRSUFFIX/clang-analyzer/scan-build/scan-build -#sed -i "s|\$RealBin/scanview.css|/usr/lib${LIBDIRSUFFIX}/clang-analyzer/scan-build/scanview.css|" \ -# $PKG/usr/lib$LIBDIRSUFFIX/clang-analyzer/scan-build/scan-build -# -## fix strange permissions -#chmod 755 $PKG/usr/lib$LIBDIRSUFFIX/clang-analyzer/scan-build -#chmod 755 $PKG/usr/lib$LIBDIRSUFFIX/clang-analyzer/scan-view -#chmod 755 $PKG/usr/lib$LIBDIRSUFFIX/clang-analyzer/scan-view/Resources +# Remove symlink to libgomp, which is already provided by gcc +rm -f $PKG/usr/lib$LIBDIRSUFFIX/libgomp.so # Install Python bindings mkdir -p "$PKG/usr/lib$LIBDIRSUFFIX/python2.7/site-packages" cp -a tools/clang/bindings/python/clang "$PKG/usr/lib$LIBDIRSUFFIX/python2.7/site-packages/" +# Remove bundled python-six +rm -f "$PKG/usr/lib$LIBDIRSUFFIX/python2.7/site-packages/six.py" + # Compile Python scripts python -m compileall "$PKG/usr/lib$LIBDIRSUFFIX/python2.7/site-packages/clang" python -O -m compileall "$PKG/usr/lib$LIBDIRSUFFIX/python2.7/site-packages/clang" +python -m compileall "$PKG/usr/lib$LIBDIRSUFFIX/python2.7/site-packages/lldb" +python -O -m compileall "$PKG/usr/lib$LIBDIRSUFFIX/python2.7/site-packages/lldb" +python -m compileall "$PKG/usr/share/scan-view" +python -O -m compileall "$PKG/usr/share/scan-view" +python -m compileall "$PKG/usr/share/clang" +python -O -m compileall "$PKG/usr/share/clang" # Move man page directory: mv $PKG/usr/share/man $PKG/usr/ @@ -170,10 +195,18 @@ for i in $( find $PKG/usr/man -type l ) ; do rm $i done -mkdir -p $PKG/usr/doc/$PKGNAM-$VERSION/clang +mkdir -p $PKG/usr/doc/$PKGNAM-$VERSION/{clang,lldb,clang-tools-extra,compiler-rt,openmp} cp -a CREDITS* LICENSE* README* $PKG/usr/doc/$PKGNAM-$VERSION cp -a tools/clang/{INSTALL,LICENSE,NOTES,README}* \ $PKG/usr/doc/$PKGNAM-$VERSION/clang +cp -a tools/lldb/{CODE_OWNERS,INSTALL,LICENSE}* \ + $PKG/usr/doc/$PKGNAM-$VERSION/lldb +cp -a tools/clang/tools/extra/{CODE_OWNERS,LICENSE,README}* \ + $PKG/usr/doc/$PKGNAM-$VERSION/clang-tools-extra +cp -a projects/compiler-rt/{CODE_OWNERS,CREDITS,LICENSE,README}* \ + $PKG/usr/doc/$PKGNAM-$VERSION/compiler-rt +cp -a projects/openmp/{CREDITS,LICENSE}* \ + $PKG/usr/doc/$PKGNAM-$VERSION/openmp mv $PKG/usr/docs/llvm/* $PKG/usr/doc/$PKGNAM-$VERSION rm -rf $PKG/usr/docs diff --git a/source/d/llvm/llvm.url b/source/d/llvm/llvm.url index f276cfe1..c92e44e2 100644 --- a/source/d/llvm/llvm.url +++ b/source/d/llvm/llvm.url @@ -1,4 +1,8 @@ -http://llvm.org/releases/3.8.0/llvm-3.8.0.src.tar.xz -http://llvm.org/releases/3.8.0/cfe-3.8.0.src.tar.xz -http://llvm.org/releases/3.8.0/clang-tools-extra-3.8.0.src.tar.xz -http://llvm.org/releases/3.8.0/compiler-rt-3.8.0.src.tar.xz +http://llvm.org/releases/6.0.0/llvm-6.0.0.src.tar.xz +http://llvm.org/releases/6.0.0/cfe-6.0.0.src.tar.xz +http://llvm.org/releases/6.0.0/clang-tools-extra-6.0.0.src.tar.xz +http://llvm.org/releases/6.0.0/compiler-rt-6.0.0.src.tar.xz +http://llvm.org/releases/6.0.0/lldb-6.0.0.src.tar.xz +http://llvm.org/releases/6.0.0/openmp-6.0.0.src.tar.xz +http://llvm.org/releases/6.0.0/libcxx-6.0.0.src.tar.xz +http://llvm.org/releases/6.0.0/libcxxabi-6.0.0.src.tar.xz diff --git a/source/d/llvm/slack-desc b/source/d/llvm/slack-desc index b466d361..76280c24 100644 --- a/source/d/llvm/slack-desc +++ b/source/d/llvm/slack-desc @@ -1,8 +1,8 @@ # HOW TO EDIT THIS FILE: -# The "handy ruler" below makes it easier to edit a package description. Line +# The "handy ruler" below makes it easier to edit a package description. Line # up the first '|' above the ':' following the base package name, and the '|' -# on the right side marks the last column you can put a character in. You must -# make exactly 11 lines for the formatting to be correct. It's also +# on the right side marks the last column you can put a character in. You must +# make exactly 11 lines for the formatting to be correct. It's also # customary to leave one space after the ':' except on otherwise blank lines. |-----handy-ruler------------------------------------------------------| @@ -12,7 +12,7 @@ llvm: Low Level Virtual Machine is a toolkit for the construction of highly llvm: optimized compilers, optimizers, and runtime environments. llvm: llvm: This package also includes the clang frontend for the C family of -llvm: languages: C, C++, Objective-C, and Objective-C++ +llvm: languages: C, C++, Objective-C, and Objective-C++ llvm: llvm: llvm: Homepage: http://llvm.org/ diff --git a/source/d/m4/m4.SlackBuild b/source/d/m4/m4.SlackBuild index 5623854c..0bc3f10f 100755 --- a/source/d/m4/m4.SlackBuild +++ b/source/d/m4/m4.SlackBuild @@ -1,6 +1,6 @@ -#!/bin/sh +#!/bin/bash -# Copyright 2008, 2009, 2010, 2011 Patrick J. Volkerding, Sebeka, Minnesota, USA +# Copyright 2008, 2009, 2010, 2011, 2018 Patrick J. Volkerding, Sebeka, Minnesota, USA # All rights reserved. # # Redistribution and use of this script, with or without modification, is @@ -20,27 +20,36 @@ # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +cd $(dirname $0) ; CWD=$(pwd) + PKGNAM=m4 VERSION=${VERSION:-$(echo $PKGNAM-*.tar.xz | rev | cut -f 3- -d . | cut -f 1 -d - | rev)} -BUILD=${BUILD:-1} +BUILD=${BUILD:-2} NUMJOBS=${NUMJOBS:-" -j7 "} # Automatically determine the architecture we're building on: if [ -z "$ARCH" ]; then case "$( uname -m )" in - i?86) export ARCH=i486 ;; + i?86) export ARCH=i586 ;; arm*) export ARCH=arm ;; # Unless $ARCH is already set, use uname -m for all other archs: *) export ARCH=$( uname -m ) ;; esac fi -CWD=$(pwd) +# If the variable PRINT_PACKAGE_NAME is set, then this script will report what +# the name of the created package would be, and then exit. This information +# could be useful to other scripts. +if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then + echo "$PKGNAM-$VERSION-$ARCH-$BUILD.txz" + exit 0 +fi + TMP=${TMP:-/tmp} PKG=$TMP/package-m4 -if [ "$ARCH" = "i486" ]; then +if [ "$ARCH" = "i586" ]; then SLKCFLAGS="-O2" LIBDIRSUFFIX="" elif [ "$ARCH" = "s390" ]; then @@ -106,7 +115,7 @@ fi # ansi2knr is no longer part of the m4 sources. # Geez, I'm gonna have to learn ANSI C now... # -#( cd src ; make ansi2knr ) +#( cd src ; make ansi2knr || exit 1) || exit 1 #gzip -9 $PKG/usr/info/m4.info.gz #cat src/m4 > $PKG/usr/bin/m4 #chmod 755 $PKG/usr/bin/* diff --git a/source/d/m4/slack-desc b/source/d/m4/slack-desc index 7951b9bd..760e2d38 100644 --- a/source/d/m4/slack-desc +++ b/source/d/m4/slack-desc @@ -1,17 +1,17 @@ # HOW TO EDIT THIS FILE: -# The "handy ruler" below makes it easier to edit a package description. Line +# The "handy ruler" below makes it easier to edit a package description. Line # up the first '|' above the ':' following the base package name, and the '|' -# on the right side marks the last column you can put a character in. You must -# make exactly 11 lines for the formatting to be correct. It's also +# on the right side marks the last column you can put a character in. You must +# make exactly 11 lines for the formatting to be correct. It's also # customary to leave one space after the ':'. |-----handy-ruler------------------------------------------------------| m4: m4 (an implementation of the UNIX macro processor) m4: m4: This is GNU m4, a program which copies its input to the output, -m4: expanding macros as it goes. m4 has built-in functions for including +m4: expanding macros as it goes. m4 has built-in functions for including m4: named files, running commands, doing integer arithmetic, manipulating -m4: text in various ways, recursion, etc... Macros can also be user- +m4: text in various ways, recursion, etc... Macros can also be user- m4: defined, and can take any number of arguments. m4: m4: GNU 'm4' was originally written by Rene Seindal, from Denmark. diff --git a/source/d/make/make.SlackBuild b/source/d/make/make.SlackBuild index 66f60f0b..e31e5798 100755 --- a/source/d/make/make.SlackBuild +++ b/source/d/make/make.SlackBuild @@ -1,6 +1,6 @@ -#!/bin/sh +#!/bin/bash -# Copyright 2005-2016 Patrick J. Volkerding, Sebeka, Minnesota, USA +# Copyright 2005-2018 Patrick J. Volkerding, Sebeka, Minnesota, USA # All rights reserved. # # Redistribution and use of this script, with or without modification, is @@ -20,10 +20,11 @@ # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +cd $(dirname $0) ; CWD=$(pwd) PKGNAM=make VERSION=${VERSION:-$(echo $PKGNAM-*.tar.bz2 | rev | cut -f 3- -d . | cut -f 1 -d - | rev)} -BUILD=${BUILD:-2} +BUILD=${BUILD:-3} # Automatically determine the architecture we're building on: if [ -z "$ARCH" ]; then @@ -35,9 +36,16 @@ if [ -z "$ARCH" ]; then esac fi +# If the variable PRINT_PACKAGE_NAME is set, then this script will report what +# the name of the created package would be, and then exit. This information +# could be useful to other scripts. +if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then + echo "$PKGNAM-$VERSION-$ARCH-$BUILD.txz" + exit 0 +fi + NUMJOBS=${NUMJOBS:-" -j7 "} -CWD=$(pwd) TMP=${TMP:-/tmp} PKG=$TMP/package-make @@ -69,6 +77,11 @@ find . \ \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \ -exec chmod 644 {} \; +zcat $CWD/make.guile22.diff.gz | patch -p1 --verbose || exit 1 +zcat $CWD/make.glibc-2.27.glob.diff.gz | patch -p1 --verbose || exit 1 + +autoreconf -vif + # Configure: CFLAGS="$SLKCFLAGS" \ ./configure \ diff --git a/source/d/make/make.glibc-2.27.glob.diff b/source/d/make/make.glibc-2.27.glob.diff new file mode 100644 index 00000000..8d795f89 --- /dev/null +++ b/source/d/make/make.glibc-2.27.glob.diff @@ -0,0 +1,32 @@ +diff -u -r make-4.2.1.orig/glob/glob.c make-4.2.1/glob/glob.c +--- make-4.2.1.orig/glob/glob.c 2013-10-20 12:14:38.000000000 -0500 ++++ make-4.2.1/glob/glob.c 2018-02-16 14:41:18.956182332 -0600 +@@ -208,28 +208,9 @@ + #endif /* __GNU_LIBRARY__ || __DJGPP__ */ + + +-#if !defined __alloca && !defined __GNU_LIBRARY__ +- +-# ifdef __GNUC__ +-# undef alloca +-# define alloca(n) __builtin_alloca (n) +-# else /* Not GCC. */ +-# ifdef HAVE_ALLOCA_H + # include <alloca.h> +-# else /* Not HAVE_ALLOCA_H. */ +-# ifndef _AIX +-# ifdef WINDOWS32 +-# include <malloc.h> +-# else +-extern char *alloca (); +-# endif /* WINDOWS32 */ +-# endif /* Not _AIX. */ +-# endif /* sparc or HAVE_ALLOCA_H. */ +-# endif /* GCC. */ +- + # define __alloca alloca + +-#endif + + #ifndef __GNU_LIBRARY__ + # define __stat stat diff --git a/source/d/make/make.guile22.diff b/source/d/make/make.guile22.diff new file mode 100644 index 00000000..b3a3a276 --- /dev/null +++ b/source/d/make/make.guile22.diff @@ -0,0 +1,13 @@ +--- ./configure.ac.orig 2016-06-06 07:27:31.000000000 -0500 ++++ ./configure.ac 2017-12-02 12:21:41.682170019 -0600 +@@ -168,8 +168,8 @@ + # comes with it's own PC file so we have to specify them as individual + # packages. Ugh. + AS_IF([test "x$with_guile" != xno], +-[ PKG_CHECK_MODULES([GUILE], [guile-2.0], [have_guile=yes], +- [PKG_CHECK_MODULES([GUILE], [guile-1.8], [have_guile=yes], ++[ PKG_CHECK_MODULES([GUILE], [guile-2.2], [have_guile=yes], ++ [PKG_CHECK_MODULES([GUILE], [guile-2.0], [have_guile=yes], + [have_guile=no])]) + ]) + diff --git a/source/d/make/slack-desc b/source/d/make/slack-desc index ef19ca33..883506fb 100644 --- a/source/d/make/slack-desc +++ b/source/d/make/slack-desc @@ -1,17 +1,17 @@ # HOW TO EDIT THIS FILE: -# The "handy ruler" below makes it easier to edit a package description. Line +# The "handy ruler" below makes it easier to edit a package description. Line # up the first '|' above the ':' following the base package name, and the '|' -# on the right side marks the last column you can put a character in. You must -# make exactly 11 lines for the formatting to be correct. It's also +# on the right side marks the last column you can put a character in. You must +# make exactly 11 lines for the formatting to be correct. It's also # customary to leave one space after the ':'. |-----handy-ruler------------------------------------------------------| make: make (GNU make utility to maintain groups of programs) make: make: This is the GNU implementation of make, which was written by Richard -make: Stallman and Roland McGrath. The purpose of the make utility is to +make: Stallman and Roland McGrath. The purpose of the make utility is to make: determine automatically which pieces of a large program need to be -make: recompiled, and issue the commands to recompile them. +make: recompiled, and issue the commands to recompile them. make: make: This is needed to compile just about any major C program, including make: the Linux kernel. diff --git a/source/d/mercurial/mercurial.SlackBuild b/source/d/mercurial/mercurial.SlackBuild index b1629a65..ef09827b 100755 --- a/source/d/mercurial/mercurial.SlackBuild +++ b/source/d/mercurial/mercurial.SlackBuild @@ -1,6 +1,6 @@ -#!/bin/sh +#!/bin/bash -# Copyright 2008, 2009, 2010 Patrick J. Volkerding, Sebeka, MN, USA +# Copyright 2008, 2009, 2010, 2017, 2018 Patrick J. Volkerding, Sebeka, MN, USA # All rights reserved. # # Redistribution and use of this script, with or without modification, is @@ -20,8 +20,11 @@ # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -VERSION=${VERSION:-$(echo mercurial-*.tar.?z* | rev | cut -f 3- -d . | cut -f 1 -d - | rev)} -BUILD=${BUILD-1} +cd $(dirname $0) ; CWD=$(pwd) + +PKGNAM=mercurial +VERSION=${VERSION:-$(echo mercurial-*.tar.?z | rev | cut -f 3- -d . | cut -f 1 -d - | rev)} +BUILD=${BUILD:-2} # Automatically determine the architecture we're building on: if [ -z "$ARCH" ]; then @@ -33,7 +36,14 @@ if [ -z "$ARCH" ]; then esac fi -CWD=$(pwd) +# If the variable PRINT_PACKAGE_NAME is set, then this script will report what +# the name of the created package would be, and then exit. This information +# could be useful to other scripts. +if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then + echo "$PKGNAM-$VERSION-$ARCH-$BUILD.txz" + exit 0 +fi + TMP=${TMP:-/tmp} PKG=$TMP/package-mercurial @@ -42,8 +52,9 @@ mkdir -p $TMP $PKG cd $TMP rm -rf mercurial-$VERSION -tar xvf $CWD/mercurial-$VERSION.tar.?z* || exit 1 -cd mercurial-$VERSION +tar xvf $CWD/mercurial-$VERSION.tar.?z || exit 1 +cd mercurial-$VERSION || exit 1 + chown -R root.root . find . \ \( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \ diff --git a/source/d/mercurial/mercurial.url b/source/d/mercurial/mercurial.url new file mode 100644 index 00000000..78e14798 --- /dev/null +++ b/source/d/mercurial/mercurial.url @@ -0,0 +1 @@ +https://www.mercurial-scm.org/release diff --git a/source/d/mercurial/slack-desc b/source/d/mercurial/slack-desc index e770f6c3..af82c7af 100644 --- a/source/d/mercurial/slack-desc +++ b/source/d/mercurial/slack-desc @@ -1,8 +1,8 @@ # HOW TO EDIT THIS FILE: -# The "handy ruler" below makes it easier to edit a package description. Line +# The "handy ruler" below makes it easier to edit a package description. Line # up the first '|' above the ':' following the base package name, and the '|' on -# the right side marks the last column you can put a character in. You must make -# exactly 11 lines for the formatting to be correct. It's also customary to +# the right side marks the last column you can put a character in. You must make +# exactly 11 lines for the formatting to be correct. It's also customary to # leave one space after the ':'. # This article is licensed under the GNU Free Documentation License. @@ -12,11 +12,11 @@ mercurial: mercurial (a distributed source management system) mercurial: mercurial: Mercurial is a cross-platform, distributed source management tool for -mercurial: software developers. It is written in Python, with a binary diff -mercurial: implementation written in C. Its major features include high- -mercurial: performance; serverless, fully distributed collaborative development; -mercurial: robust handling of both plain text and binary files; advanced -mercurial: branching and merging capabilities; and full source code available +mercurial: software developers. It is written in Python, with a binary diff +mercurial: implementation written in C. Its major features include high- +mercurial: performance; serverless, fully distributed collaborative development; +mercurial: robust handling of both plain text and binary files; advanced +mercurial: branching and merging capabilities; and full source code available mercurial: under the terms of the LGPL. mercurial: mercurial: Mercurial was written by Matt Mackall and other contributors. diff --git a/source/d/meson/meson.SlackBuild b/source/d/meson/meson.SlackBuild new file mode 100755 index 00000000..38193377 --- /dev/null +++ b/source/d/meson/meson.SlackBuild @@ -0,0 +1,80 @@ +#!/bin/bash + +# Copyright 2017 Heinz Wiesinger, Amsterdam, NL +# Copyright 2017, 2018 Patrick J. Volkerding, Sebeka, MN, USA +# All rights reserved. +# +# Redistribution and use of this script, with or without modification, is +# permitted provided that the following conditions are met: +# +# 1. Redistributions of this script must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED +# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO +# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +cd $(dirname $0) ; CWD=$(pwd) + +PKGNAM=meson +VERSION=${VERSION:-$(echo $PKGNAM-*.tar.?z | rev | cut -f 3- -d . | cut -f 1 -d - | rev)} +BUILD=${BUILD:-1} + +if [ -z "$ARCH" ]; then + case "$( uname -m )" in + i?86) ARCH=i586 ;; + arm*) ARCH=arm ;; + *) ARCH=$( uname -m ) ;; + esac +fi + +# If the variable PRINT_PACKAGE_NAME is set, then this script will report what +# the name of the created package would be, and then exit. This information +# could be useful to other scripts. +if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then + echo "$PKGNAM-$VERSION-$ARCH-$BUILD.txz" + exit 0 +fi + +TMP=${TMP:-/tmp} +PKG=$TMP/package-$PKGNAM + +rm -rf $PKG +mkdir -p $TMP $PKG +cd $TMP +rm -rf $PKGNAM-$VERSION +tar xvf $CWD/$PKGNAM-$VERSION.tar.?z || exit 1 +cd $PKGNAM-$VERSION || exit 1 + +chown -R root:root . +find -L . \ + \( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 \ + -o -perm 511 \) -exec chmod 755 {} \; -o \ + \( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \ + -o -perm 440 -o -perm 400 \) -exec chmod 644 {} \; + +python3 setup.py install --root=$PKG || exit 1 + +mv $PKG/usr/share/man $PKG/usr/ +rmdir $PKG/usr/share 2> /dev/null + +find $PKG/usr/man -type f -exec gzip -9 {} \; +for i in $( find $PKG/usr/man -type l ) ; do ln -s $( readlink $i ).gz $i.gz ; rm $i ; done + +mkdir -p $PKG/usr/doc/$PKGNAM-$VERSION +cp -a contributing.txt COPYING PKG-INFO README* \ + $PKG/usr/doc/$PKGNAM-$VERSION +find $PKG/usr/doc/$PKGNAM-$VERSION -type f -exec chmod 0644 {} \; + +mkdir -p $PKG/install +cat $CWD/slack-desc > $PKG/install/slack-desc + +cd $PKG +/sbin/makepkg -l y -c n $TMP/$PKGNAM-$VERSION-$ARCH-$BUILD.txz diff --git a/source/d/meson/meson.url b/source/d/meson/meson.url new file mode 100644 index 00000000..21664427 --- /dev/null +++ b/source/d/meson/meson.url @@ -0,0 +1 @@ +https://github.com/mesonbuild/meson/releases/download/0.46.1/meson-0.46.1.tar.gz diff --git a/source/d/meson/slack-desc b/source/d/meson/slack-desc new file mode 100644 index 00000000..17469f9b --- /dev/null +++ b/source/d/meson/slack-desc @@ -0,0 +1,19 @@ +# HOW TO EDIT THIS FILE: +# The "handy ruler" below makes it easier to edit a package description. +# Line up the first '|' above the ':' following the base package name, and +# the '|' on the right side marks the last column you can put a character in. +# You must make exactly 11 lines for the formatting to be correct. It's also +# customary to leave one space after the ':' except on otherwise blank lines. + + |-----handy-ruler------------------------------------------------------| +meson: meson (A high performance build system) +meson: +meson: Meson is a cross-platform build system designed to be both as fast +meson: and as user friendly as possible. It supports many languages and +meson: compilers, including GCC and Clang. Its build definitions are written +meson: in a simple non-turing complete domain specific language. +meson: +meson: Homepage: http://mesonbuild.com/ +meson: +meson: +meson: diff --git a/source/d/nasm/nasm.SlackBuild b/source/d/nasm/nasm.SlackBuild index 63f80748..f52d2aa5 100755 --- a/source/d/nasm/nasm.SlackBuild +++ b/source/d/nasm/nasm.SlackBuild @@ -1,6 +1,6 @@ -#!/bin/sh +#!/bin/bash -# Copyright 2008, 2009, 2010, 2011 Patrick J. Volkerding, Sebeka, Minnesota, USA +# Copyright 2008, 2009, 2010, 2011, 2017, 2018 Patrick J. Volkerding, Sebeka, Minnesota, USA # All rights reserved. # # Redistribution and use of this script, with or without modification, is @@ -20,10 +20,11 @@ # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +cd $(dirname $0) ; CWD=$(pwd) PKGNAM=nasm VERSION=${VERSION:-$(echo $PKGNAM-*.tar.?z* | rev | cut -f 3- -d . | cut -f 1 -d - | rev)} -BUILD=${BUILD:-1} +BUILD=${BUILD:-2} # Automatically determine the architecture we're building on: if [ -z "$ARCH" ]; then @@ -35,13 +36,20 @@ if [ -z "$ARCH" ]; then esac fi +# If the variable PRINT_PACKAGE_NAME is set, then this script will report what +# the name of the created package would be, and then exit. This information +# could be useful to other scripts. +if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then + echo "$PKGNAM-$VERSION-$ARCH-$BUILD.txz" + exit 0 +fi + if [ "$ARCH" = "x86_64" ]; then SLKCFLAGS="-O2 -fPIC" else SLKCFLAGS="-O2" fi -CWD=$(pwd) TMP=${TMP:-/tmp} PKG=$TMP/package-nasm @@ -50,7 +58,7 @@ mkdir -p $TMP $PKG cd $TMP rm -rf nasm-$VERSION tar xvf $CWD/nasm-$VERSION.tar.?z* || exit 1 -cd nasm-$VERSION +cd nasm-$VERSION || exit 1 chown -R root:root . find . \ \( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \ @@ -65,11 +73,12 @@ CFLAGS="$SLKCFLAGS" \ --build=${ARCH}-slackware-linux || exit 1 make || exit 1 -make -C doc || exit 1 - -mkdir -p $PKG/usr/bin $PKG/usr/man/man1 $PKG/usr/info +( cd doc + make nasmdoc.txt || exit 1 + mkdir -p $PKG/usr/doc/nasm-$VERSION + cp nasmdoc.txt $PKG/usr/doc/nasm-$VERSION +) || exit 1 make install INSTALLROOT=$PKG || exit 1 -cp -a doc/info/* $PKG/usr/info find $PKG | xargs file | grep -e "executable" -e "shared object" \ | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null @@ -80,7 +89,6 @@ cp -a \ $PKG/usr/doc/nasm-$VERSION gzip -9 $PKG/usr/man/man?/* -gzip -9 $PKG/usr/info/* mkdir -p $PKG/install cat $CWD/slack-desc > $PKG/install/slack-desc diff --git a/source/d/nasm/slack-desc b/source/d/nasm/slack-desc index 6fd4778f..8c7c44d7 100644 --- a/source/d/nasm/slack-desc +++ b/source/d/nasm/slack-desc @@ -1,8 +1,8 @@ # HOW TO EDIT THIS FILE: -# The "handy ruler" below makes it easier to edit a package description. Line +# The "handy ruler" below makes it easier to edit a package description. Line # up the first '|' above the ':' following the base package name, and the '|' -# on the right side marks the last column you can put a character in. You must -# make exactly 11 lines for the formatting to be correct. It's also +# on the right side marks the last column you can put a character in. You must +# make exactly 11 lines for the formatting to be correct. It's also # customary to leave one space after the ':'. |-----handy-ruler------------------------------------------------------| @@ -14,6 +14,6 @@ nasm: instruction mnemonics and syntax. nasm: nasm: NASM was written by Simon Tatham and Julian Hall. nasm: -nasm: +nasm: Homepage: http://www.nasm.us nasm: nasm: diff --git a/source/d/ninja/ninja.SlackBuild b/source/d/ninja/ninja.SlackBuild new file mode 100755 index 00000000..007cc6d1 --- /dev/null +++ b/source/d/ninja/ninja.SlackBuild @@ -0,0 +1,132 @@ +#!/bin/bash + +# Copyright 2016, 2017 Eric Hameleers, Eindhoven, NL +# Copyright 2017, 2018 Patrick J. Volkerding, Sebeka, MN, USA +# All rights reserved. +# +# Redistribution and use of this script, with or without modification, is +# permitted provided that the following conditions are met: +# +# 1. Redistributions of this script must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED +# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO +# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +cd $(dirname $0) ; CWD=$(pwd) + +PKGNAM=ninja +VERSION=${VERSION:-$(echo $PKGNAM-*.tar.?z | rev | cut -f 3- -d . | cut -f 1 -d - | rev)} +BUILD=${BUILD:-2} + +NUMJOBS=${NUMJOBS:--j7} + +# Automatically determine the architecture we're building on: +if [ -z "$ARCH" ]; then + case "$(uname -m)" in + i?86) ARCH=i586 ;; + arm*) readelf /usr/bin/file -A | egrep -q "Tag_CPU.*[4,5]" && ARCH=arm || ARCH=armv7hl ;; + # Unless $ARCH is already set, use uname -m for all other archs: + *) ARCH=$(uname -m) ;; + esac + export ARCH +fi + +# If the variable PRINT_PACKAGE_NAME is set, then this script will report what +# the name of the created package would be, and then exit. This information +# could be useful to other scripts. +if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then + echo "$PKGNAM-$VERSION-$ARCH-$BUILD.txz" + exit 0 +fi + +TMP=${TMP:-/tmp} +PKG=$TMP/package-$PKGNAM + +if [ "$ARCH" = "i586" ]; then + SLKCFLAGS="-O2 -march=i586 -mtune=i686" + SLKLDFLAGS="" + LIBDIRSUFFIX="" +elif [ "$ARCH" = "x86_64" ]; then + SLKCFLAGS="-O2 -fPIC" + SLKLDFLAGS="-L/usr/lib64" + LIBDIRSUFFIX="64" +elif [ "$ARCH" = "armv7hl" ]; then + SLKCFLAGS="-O3 -march=armv7-a -mfpu=vfpv3-d16" + SLKLDFLAGS="" + LIBDIRSUFFIX="" +else + SLKCFLAGS="-O2" + SLKLDFLAGS="" + LIBDIRSUFFIX="" +fi + +case "$ARCH" in + arm*) TARGET=$ARCH-slackware-linux-gnueabi ;; + *) TARGET=$ARCH-slackware-linux ;; +esac + +rm -rf $PKG +mkdir -p $TMP $PKG +cd $TMP +rm -rf $PKGNAM-$VERSION +tar xvf $CWD/$PKGNAM-$VERSION.tar.?z || exit 1 +cd $PKGNAM-$VERSION || exit 1 + +# Fix bogus permissions: +chown -R root:root . +find . \ + \( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \ + -exec chmod 755 {} \; -o \ + \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \ + -exec chmod 644 {} \; + +# Build the program: +LDFLAGS="$SLKLDFLAGS" \ +CXXFLAGS="$SLKCFLAGS" \ +CFLAGS="$SLKCFLAGS" \ + python3 configure.py --bootstrap || exit 1 + +# Manually install stuff: +install -D -m0755 ninja $PKG/usr/bin/ninja || exit 1 +install -D -m0644 misc/bash-completion $PKG/usr/share/bash-completion/completions/ninja || exit 1 +install -D -m0644 misc/zsh-completion $PKG/usr/share/zsh/site-functions/_ninja || exit 1 +install -D -m0644 misc/ninja.vim $PKG/usr/share/vim/vimfiles/syntax/ninja.vim || exit 1 +install -D -m0644 misc/ninja-mode.el $PKG/usr/share/emacs/site-lisp/ninja-mode.el || exit 1 + +# Compiling the .el should be optional... +#emacs -Q --batch -f batch-byte-compile misc/ninja-mode.el || exit 1 +#install -D -m0644 misc/ninja-mode.elc $PKG/usr/share/emacs/site-lisp/ninja-mode.elc || exit 1 + +# Compress the man page(s): +if [ -d $PKG/usr/man ]; then + find $PKG/usr/man -type f -name "*.?" -exec gzip -9f {} \; + for i in $(find $PKG/usr/man -type l -name "*.?") ; do ln -s $( readlink $i ).gz $i.gz ; rm $i ; done +fi + +# Strip binaries (if any): +find $PKG | xargs file | grep -e "executable" -e "shared object" \ + | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null + +# Add documentation: +mkdir -p $PKG/usr/doc/$PKGNAM-$VERSION +cp -a \ + COPYING* HACKING* README* RELEASING \ + $PKG/usr/doc/$PKGNAM-$VERSION + +# Add a package description: +mkdir -p $PKG/install +cat $CWD/slack-desc > $PKG/install/slack-desc + +# Build the package: +cd $PKG +/sbin/makepkg -l y -c n $TMP/$PKGNAM-$VERSION-$ARCH-$BUILD.txz + diff --git a/source/d/ninja/ninja.url b/source/d/ninja/ninja.url new file mode 100644 index 00000000..c282f2a9 --- /dev/null +++ b/source/d/ninja/ninja.url @@ -0,0 +1 @@ +https://github.com/ninja-build/ninja/archive/v1.8.2/ninja-1.8.2.tar.gz diff --git a/source/d/ninja/slack-desc b/source/d/ninja/slack-desc new file mode 100644 index 00000000..4dd38021 --- /dev/null +++ b/source/d/ninja/slack-desc @@ -0,0 +1,19 @@ +# HOW TO EDIT THIS FILE: +# The "handy ruler" below makes it easier to edit a package description. Line +# up the first '|' above the ':' following the base package name, and the '|' +# on the right side marks the last column you can put a character in. You must +# make exactly 11 lines for the formatting to be correct. It's also +# customary to leave one space after the ':' except on otherwise blank lines. + + |-----handy-ruler------------------------------------------------------| +ninja: ninja (build system with a focus on speed) +ninja: +ninja: Ninja is a small build system with a focus on speed. It differs from +ninja: other build systems in two major respects: it is designed to have its +ninja: input files generated by a higher-level build system, and it is +ninja: designed to run builds as fast as possible. +ninja: +ninja: ninja home: https://ninja-build.org/ +ninja: +ninja: +ninja: diff --git a/source/d/opencl-headers/LICENSE.txt b/source/d/opencl-headers/LICENSE.txt new file mode 100644 index 00000000..a89e4f5c --- /dev/null +++ b/source/d/opencl-headers/LICENSE.txt @@ -0,0 +1,20 @@ + * Copyright (c) 2008-2010 The Khronos Group Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and/or associated documentation files (the + * "Materials"), to deal in the Materials without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Materials, and to + * permit persons to whom the Materials are furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Materials. + * + * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. diff --git a/source/d/opencl-headers/cl.hpp b/source/d/opencl-headers/cl.hpp new file mode 100644 index 00000000..396b8671 --- /dev/null +++ b/source/d/opencl-headers/cl.hpp @@ -0,0 +1,12934 @@ +/******************************************************************************* + * Copyright (c) 2008-2015 The Khronos Group Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and/or associated documentation files (the + * "Materials"), to deal in the Materials without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Materials, and to + * permit persons to whom the Materials are furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Materials. + * + * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. + ******************************************************************************/ + +/*! \file + * + * \brief C++ bindings for OpenCL 1.0 (rev 48), OpenCL 1.1 (rev 33) and + * OpenCL 1.2 (rev 15) + * \author Benedict R. Gaster, Laurent Morichetti and Lee Howes + * + * Additions and fixes from: + * Brian Cole, March 3rd 2010 and April 2012 + * Matt Gruenke, April 2012. + * Bruce Merry, February 2013. + * Tom Deakin and Simon McIntosh-Smith, July 2013 + * + * \version 1.2.8 + * \date October 2015 + * + * Optional extension support + * + * cl + * cl_ext_device_fission + * #define USE_CL_DEVICE_FISSION + */ + +/*! \mainpage + * \section intro Introduction + * For many large applications C++ is the language of choice and so it seems + * reasonable to define C++ bindings for OpenCL. + * + * + * The interface is contained with a single C++ header file \em cl.hpp and all + * definitions are contained within the namespace \em cl. There is no additional + * requirement to include \em cl.h and to use either the C++ or original C + * bindings it is enough to simply include \em cl.hpp. + * + * The bindings themselves are lightweight and correspond closely to the + * underlying C API. Using the C++ bindings introduces no additional execution + * overhead. + * + * For detail documentation on the bindings see: + * + * The OpenCL C++ Wrapper API 1.2 (revision 09) + * http://www.khronos.org/registry/cl/specs/opencl-cplusplus-1.2.pdf + * + * \section example Example + * + * The following example shows a general use case for the C++ + * bindings, including support for the optional exception feature and + * also the supplied vector and string classes, see following sections for + * decriptions of these features. + * + * \code + * #define __CL_ENABLE_EXCEPTIONS + * + * #if defined(__APPLE__) || defined(__MACOSX) + * #include <OpenCL/cl.hpp> + * #else + * #include <CL/cl.hpp> + * #endif + * #include <cstdio> + * #include <cstdlib> + * #include <iostream> + * + * const char * helloStr = "__kernel void " + * "hello(void) " + * "{ " + * " " + * "} "; + * + * int + * main(void) + * { + * cl_int err = CL_SUCCESS; + * try { + * + * std::vector<cl::Platform> platforms; + * cl::Platform::get(&platforms); + * if (platforms.size() == 0) { + * std::cout << "Platform size 0\n"; + * return -1; + * } + * + * cl_context_properties properties[] = + * { CL_CONTEXT_PLATFORM, (cl_context_properties)(platforms[0])(), 0}; + * cl::Context context(CL_DEVICE_TYPE_CPU, properties); + * + * std::vector<cl::Device> devices = context.getInfo<CL_CONTEXT_DEVICES>(); + * + * cl::Program::Sources source(1, + * std::make_pair(helloStr,strlen(helloStr))); + * cl::Program program_ = cl::Program(context, source); + * program_.build(devices); + * + * cl::Kernel kernel(program_, "hello", &err); + * + * cl::Event event; + * cl::CommandQueue queue(context, devices[0], 0, &err); + * queue.enqueueNDRangeKernel( + * kernel, + * cl::NullRange, + * cl::NDRange(4,4), + * cl::NullRange, + * NULL, + * &event); + * + * event.wait(); + * } + * catch (cl::Error err) { + * std::cerr + * << "ERROR: " + * << err.what() + * << "(" + * << err.err() + * << ")" + * << std::endl; + * } + * + * return EXIT_SUCCESS; + * } + * + * \endcode + * + */ +#ifndef CL_HPP_ +#define CL_HPP_ + +#ifdef _WIN32 + +#include <malloc.h> + +#if defined(USE_DX_INTEROP) +#include <CL/cl_d3d10.h> +#include <CL/cl_dx9_media_sharing.h> +#endif +#endif // _WIN32 + +#if defined(_MSC_VER) +#include <intrin.h> +#endif // _MSC_VER + +// +#if defined(USE_CL_DEVICE_FISSION) +#include <CL/cl_ext.h> +#endif + +#if defined(__APPLE__) || defined(__MACOSX) +#include <OpenCL/opencl.h> +#else +#include <CL/opencl.h> +#endif // !__APPLE__ + +#if (_MSC_VER >= 1700) || (__cplusplus >= 201103L) +#define CL_HPP_RVALUE_REFERENCES_SUPPORTED +#define CL_HPP_CPP11_ATOMICS_SUPPORTED +#include <atomic> +#endif + +#if (__cplusplus >= 201103L) +#define CL_HPP_NOEXCEPT noexcept +#else +#define CL_HPP_NOEXCEPT +#endif + + +// To avoid accidentally taking ownership of core OpenCL types +// such as cl_kernel constructors are made explicit +// under OpenCL 1.2 +#if defined(CL_VERSION_1_2) && !defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS) +#define __CL_EXPLICIT_CONSTRUCTORS explicit +#else // #if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS) +#define __CL_EXPLICIT_CONSTRUCTORS +#endif // #if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS) + +// Define deprecated prefixes and suffixes to ensure compilation +// in case they are not pre-defined +#if !defined(CL_EXT_PREFIX__VERSION_1_1_DEPRECATED) +#define CL_EXT_PREFIX__VERSION_1_1_DEPRECATED +#endif // #if !defined(CL_EXT_PREFIX__VERSION_1_1_DEPRECATED) +#if !defined(CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED) +#define CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED +#endif // #if !defined(CL_EXT_PREFIX__VERSION_1_1_DEPRECATED) + +#if !defined(CL_CALLBACK) +#define CL_CALLBACK +#endif //CL_CALLBACK + +#include <utility> +#include <limits> +#include <iterator> + +#if defined(__CL_ENABLE_EXCEPTIONS) +#include <exception> +#endif // #if defined(__CL_ENABLE_EXCEPTIONS) + +#if !defined(__NO_STD_VECTOR) +#include <vector> +#endif + +#if !defined(__NO_STD_STRING) +#include <string> +#endif + +#if defined(__ANDROID__) || defined(linux) || defined(__APPLE__) || defined(__MACOSX) +#include <alloca.h> +#endif // linux + +#include <cstring> + + +/*! \namespace cl + * + * \brief The OpenCL C++ bindings are defined within this namespace. + * + */ +namespace cl { + +class Memory; + +/** + * Deprecated APIs for 1.2 + */ +#if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS) || (defined(CL_VERSION_1_1) && !defined(CL_VERSION_1_2)) +#define __INIT_CL_EXT_FCN_PTR(name) \ + if(!pfn_##name) { \ + pfn_##name = (PFN_##name) \ + clGetExtensionFunctionAddress(#name); \ + if(!pfn_##name) { \ + } \ + } +#endif // #if defined(CL_VERSION_1_1) + +#if defined(CL_VERSION_1_2) +#define __INIT_CL_EXT_FCN_PTR_PLATFORM(platform, name) \ + if(!pfn_##name) { \ + pfn_##name = (PFN_##name) \ + clGetExtensionFunctionAddressForPlatform(platform, #name); \ + if(!pfn_##name) { \ + } \ + } +#endif // #if defined(CL_VERSION_1_1) + +class Program; +class Device; +class Context; +class CommandQueue; +class Memory; +class Buffer; + +#if defined(__CL_ENABLE_EXCEPTIONS) +/*! \brief Exception class + * + * This may be thrown by API functions when __CL_ENABLE_EXCEPTIONS is defined. + */ +class Error : public std::exception +{ +private: + cl_int err_; + const char * errStr_; +public: + /*! \brief Create a new CL error exception for a given error code + * and corresponding message. + * + * \param err error code value. + * + * \param errStr a descriptive string that must remain in scope until + * handling of the exception has concluded. If set, it + * will be returned by what(). + */ + Error(cl_int err, const char * errStr = NULL) : err_(err), errStr_(errStr) + {} + + ~Error() throw() {} + + /*! \brief Get error string associated with exception + * + * \return A memory pointer to the error message string. + */ + virtual const char * what() const throw () + { + if (errStr_ == NULL) { + return "empty"; + } + else { + return errStr_; + } + } + + /*! \brief Get error code associated with exception + * + * \return The error code. + */ + cl_int err(void) const { return err_; } +}; + +#define __ERR_STR(x) #x +#else +#define __ERR_STR(x) NULL +#endif // __CL_ENABLE_EXCEPTIONS + + +namespace detail +{ +#if defined(__CL_ENABLE_EXCEPTIONS) +static inline cl_int errHandler ( + cl_int err, + const char * errStr = NULL) +{ + if (err != CL_SUCCESS) { + throw Error(err, errStr); + } + return err; +} +#else +static inline cl_int errHandler (cl_int err, const char * errStr = NULL) +{ + (void) errStr; // suppress unused variable warning + return err; +} +#endif // __CL_ENABLE_EXCEPTIONS +} + + + +//! \cond DOXYGEN_DETAIL +#if !defined(__CL_USER_OVERRIDE_ERROR_STRINGS) +#define __GET_DEVICE_INFO_ERR __ERR_STR(clGetDeviceInfo) +#define __GET_PLATFORM_INFO_ERR __ERR_STR(clGetPlatformInfo) +#define __GET_DEVICE_IDS_ERR __ERR_STR(clGetDeviceIDs) +#define __GET_PLATFORM_IDS_ERR __ERR_STR(clGetPlatformIDs) +#define __GET_CONTEXT_INFO_ERR __ERR_STR(clGetContextInfo) +#define __GET_EVENT_INFO_ERR __ERR_STR(clGetEventInfo) +#define __GET_EVENT_PROFILE_INFO_ERR __ERR_STR(clGetEventProfileInfo) +#define __GET_MEM_OBJECT_INFO_ERR __ERR_STR(clGetMemObjectInfo) +#define __GET_IMAGE_INFO_ERR __ERR_STR(clGetImageInfo) +#define __GET_SAMPLER_INFO_ERR __ERR_STR(clGetSamplerInfo) +#define __GET_KERNEL_INFO_ERR __ERR_STR(clGetKernelInfo) +#if defined(CL_VERSION_1_2) +#define __GET_KERNEL_ARG_INFO_ERR __ERR_STR(clGetKernelArgInfo) +#endif // #if defined(CL_VERSION_1_2) +#define __GET_KERNEL_WORK_GROUP_INFO_ERR __ERR_STR(clGetKernelWorkGroupInfo) +#define __GET_PROGRAM_INFO_ERR __ERR_STR(clGetProgramInfo) +#define __GET_PROGRAM_BUILD_INFO_ERR __ERR_STR(clGetProgramBuildInfo) +#define __GET_COMMAND_QUEUE_INFO_ERR __ERR_STR(clGetCommandQueueInfo) + +#define __CREATE_CONTEXT_ERR __ERR_STR(clCreateContext) +#define __CREATE_CONTEXT_FROM_TYPE_ERR __ERR_STR(clCreateContextFromType) +#define __GET_SUPPORTED_IMAGE_FORMATS_ERR __ERR_STR(clGetSupportedImageFormats) + +#define __CREATE_BUFFER_ERR __ERR_STR(clCreateBuffer) +#define __COPY_ERR __ERR_STR(cl::copy) +#define __CREATE_SUBBUFFER_ERR __ERR_STR(clCreateSubBuffer) +#define __CREATE_GL_BUFFER_ERR __ERR_STR(clCreateFromGLBuffer) +#define __CREATE_GL_RENDER_BUFFER_ERR __ERR_STR(clCreateFromGLBuffer) +#define __GET_GL_OBJECT_INFO_ERR __ERR_STR(clGetGLObjectInfo) +#if defined(CL_VERSION_1_2) +#define __CREATE_IMAGE_ERR __ERR_STR(clCreateImage) +#define __CREATE_GL_TEXTURE_ERR __ERR_STR(clCreateFromGLTexture) +#define __IMAGE_DIMENSION_ERR __ERR_STR(Incorrect image dimensions) +#endif // #if defined(CL_VERSION_1_2) +#define __CREATE_SAMPLER_ERR __ERR_STR(clCreateSampler) +#define __SET_MEM_OBJECT_DESTRUCTOR_CALLBACK_ERR __ERR_STR(clSetMemObjectDestructorCallback) + +#define __CREATE_USER_EVENT_ERR __ERR_STR(clCreateUserEvent) +#define __SET_USER_EVENT_STATUS_ERR __ERR_STR(clSetUserEventStatus) +#define __SET_EVENT_CALLBACK_ERR __ERR_STR(clSetEventCallback) +#define __WAIT_FOR_EVENTS_ERR __ERR_STR(clWaitForEvents) + +#define __CREATE_KERNEL_ERR __ERR_STR(clCreateKernel) +#define __SET_KERNEL_ARGS_ERR __ERR_STR(clSetKernelArg) +#define __CREATE_PROGRAM_WITH_SOURCE_ERR __ERR_STR(clCreateProgramWithSource) +#define __CREATE_PROGRAM_WITH_BINARY_ERR __ERR_STR(clCreateProgramWithBinary) +#if defined(CL_VERSION_1_2) +#define __CREATE_PROGRAM_WITH_BUILT_IN_KERNELS_ERR __ERR_STR(clCreateProgramWithBuiltInKernels) +#endif // #if defined(CL_VERSION_1_2) +#define __BUILD_PROGRAM_ERR __ERR_STR(clBuildProgram) +#if defined(CL_VERSION_1_2) +#define __COMPILE_PROGRAM_ERR __ERR_STR(clCompileProgram) +#define __LINK_PROGRAM_ERR __ERR_STR(clLinkProgram) +#endif // #if defined(CL_VERSION_1_2) +#define __CREATE_KERNELS_IN_PROGRAM_ERR __ERR_STR(clCreateKernelsInProgram) + +#define __CREATE_COMMAND_QUEUE_ERR __ERR_STR(clCreateCommandQueue) +#define __SET_COMMAND_QUEUE_PROPERTY_ERR __ERR_STR(clSetCommandQueueProperty) +#define __ENQUEUE_READ_BUFFER_ERR __ERR_STR(clEnqueueReadBuffer) +#define __ENQUEUE_READ_BUFFER_RECT_ERR __ERR_STR(clEnqueueReadBufferRect) +#define __ENQUEUE_WRITE_BUFFER_ERR __ERR_STR(clEnqueueWriteBuffer) +#define __ENQUEUE_WRITE_BUFFER_RECT_ERR __ERR_STR(clEnqueueWriteBufferRect) +#define __ENQEUE_COPY_BUFFER_ERR __ERR_STR(clEnqueueCopyBuffer) +#define __ENQEUE_COPY_BUFFER_RECT_ERR __ERR_STR(clEnqueueCopyBufferRect) +#define __ENQUEUE_FILL_BUFFER_ERR __ERR_STR(clEnqueueFillBuffer) +#define __ENQUEUE_READ_IMAGE_ERR __ERR_STR(clEnqueueReadImage) +#define __ENQUEUE_WRITE_IMAGE_ERR __ERR_STR(clEnqueueWriteImage) +#define __ENQUEUE_COPY_IMAGE_ERR __ERR_STR(clEnqueueCopyImage) +#define __ENQUEUE_FILL_IMAGE_ERR __ERR_STR(clEnqueueFillImage) +#define __ENQUEUE_COPY_IMAGE_TO_BUFFER_ERR __ERR_STR(clEnqueueCopyImageToBuffer) +#define __ENQUEUE_COPY_BUFFER_TO_IMAGE_ERR __ERR_STR(clEnqueueCopyBufferToImage) +#define __ENQUEUE_MAP_BUFFER_ERR __ERR_STR(clEnqueueMapBuffer) +#define __ENQUEUE_MAP_IMAGE_ERR __ERR_STR(clEnqueueMapImage) +#define __ENQUEUE_UNMAP_MEM_OBJECT_ERR __ERR_STR(clEnqueueUnMapMemObject) +#define __ENQUEUE_NDRANGE_KERNEL_ERR __ERR_STR(clEnqueueNDRangeKernel) +#define __ENQUEUE_TASK_ERR __ERR_STR(clEnqueueTask) +#define __ENQUEUE_NATIVE_KERNEL __ERR_STR(clEnqueueNativeKernel) +#if defined(CL_VERSION_1_2) +#define __ENQUEUE_MIGRATE_MEM_OBJECTS_ERR __ERR_STR(clEnqueueMigrateMemObjects) +#endif // #if defined(CL_VERSION_1_2) + +#define __ENQUEUE_ACQUIRE_GL_ERR __ERR_STR(clEnqueueAcquireGLObjects) +#define __ENQUEUE_RELEASE_GL_ERR __ERR_STR(clEnqueueReleaseGLObjects) + + +#define __RETAIN_ERR __ERR_STR(Retain Object) +#define __RELEASE_ERR __ERR_STR(Release Object) +#define __FLUSH_ERR __ERR_STR(clFlush) +#define __FINISH_ERR __ERR_STR(clFinish) +#define __VECTOR_CAPACITY_ERR __ERR_STR(Vector capacity error) + +/** + * CL 1.2 version that uses device fission. + */ +#if defined(CL_VERSION_1_2) +#define __CREATE_SUB_DEVICES __ERR_STR(clCreateSubDevices) +#else +#define __CREATE_SUB_DEVICES __ERR_STR(clCreateSubDevicesEXT) +#endif // #if defined(CL_VERSION_1_2) + +/** + * Deprecated APIs for 1.2 + */ +#if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS) || (defined(CL_VERSION_1_1) && !defined(CL_VERSION_1_2)) +#define __ENQUEUE_MARKER_ERR __ERR_STR(clEnqueueMarker) +#define __ENQUEUE_WAIT_FOR_EVENTS_ERR __ERR_STR(clEnqueueWaitForEvents) +#define __ENQUEUE_BARRIER_ERR __ERR_STR(clEnqueueBarrier) +#define __UNLOAD_COMPILER_ERR __ERR_STR(clUnloadCompiler) +#define __CREATE_GL_TEXTURE_2D_ERR __ERR_STR(clCreateFromGLTexture2D) +#define __CREATE_GL_TEXTURE_3D_ERR __ERR_STR(clCreateFromGLTexture3D) +#define __CREATE_IMAGE2D_ERR __ERR_STR(clCreateImage2D) +#define __CREATE_IMAGE3D_ERR __ERR_STR(clCreateImage3D) +#endif // #if defined(CL_VERSION_1_1) + +#endif // __CL_USER_OVERRIDE_ERROR_STRINGS +//! \endcond + +/** + * CL 1.2 marker and barrier commands + */ +#if defined(CL_VERSION_1_2) +#define __ENQUEUE_MARKER_WAIT_LIST_ERR __ERR_STR(clEnqueueMarkerWithWaitList) +#define __ENQUEUE_BARRIER_WAIT_LIST_ERR __ERR_STR(clEnqueueBarrierWithWaitList) +#endif // #if defined(CL_VERSION_1_2) + +#if !defined(__USE_DEV_STRING) && !defined(__NO_STD_STRING) +typedef std::string STRING_CLASS; +#elif !defined(__USE_DEV_STRING) + +/*! \class string + * \brief Simple string class, that provides a limited subset of std::string + * functionality but avoids many of the issues that come with that class. + + * \note Deprecated. Please use std::string as default or + * re-define the string class to match the std::string + * interface by defining STRING_CLASS + */ +class CL_EXT_PREFIX__VERSION_1_1_DEPRECATED string CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED +{ +private: + ::size_t size_; + char * str_; +public: + //! \brief Constructs an empty string, allocating no memory. + string(void) : size_(0), str_(NULL) + { + } + + /*! \brief Constructs a string populated from an arbitrary value of + * specified size. + * + * An extra '\0' is added, in case none was contained in str. + * + * \param str the initial value of the string instance. Note that '\0' + * characters receive no special treatment. If NULL, + * the string is left empty, with a size of 0. + * + * \param size the number of characters to copy from str. + */ + string(const char * str, ::size_t size) : + size_(size), + str_(NULL) + { + if( size > 0 ) { + str_ = new char[size_+1]; + if (str_ != NULL) { + memcpy(str_, str, size_ * sizeof(char)); + str_[size_] = '\0'; + } + else { + size_ = 0; + } + } + } + + /*! \brief Constructs a string populated from a null-terminated value. + * + * \param str the null-terminated initial value of the string instance. + * If NULL, the string is left empty, with a size of 0. + */ + string(const char * str) : + size_(0), + str_(NULL) + { + if( str ) { + size_= ::strlen(str); + } + if( size_ > 0 ) { + str_ = new char[size_ + 1]; + if (str_ != NULL) { + memcpy(str_, str, (size_ + 1) * sizeof(char)); + } + } + } + + void resize( ::size_t n ) + { + if( size_ == n ) { + return; + } + if (n == 0) { + if( str_ ) { + delete [] str_; + } + str_ = NULL; + size_ = 0; + } + else { + char *newString = new char[n + 1]; + ::size_t copySize = n; + if( size_ < n ) { + copySize = size_; + } + size_ = n; + + if(str_) { + memcpy(newString, str_, (copySize + 1) * sizeof(char)); + } + if( copySize < size_ ) { + memset(newString + copySize, 0, size_ - copySize); + } + newString[size_] = '\0'; + + delete [] str_; + str_ = newString; + } + } + + const char& operator[] ( ::size_t pos ) const + { + return str_[pos]; + } + + char& operator[] ( ::size_t pos ) + { + return str_[pos]; + } + + /*! \brief Copies the value of another string to this one. + * + * \param rhs the string to copy. + * + * \returns a reference to the modified instance. + */ + string& operator=(const string& rhs) + { + if (this == &rhs) { + return *this; + } + + if( str_ != NULL ) { + delete [] str_; + str_ = NULL; + size_ = 0; + } + + if (rhs.size_ == 0 || rhs.str_ == NULL) { + str_ = NULL; + size_ = 0; + } + else { + str_ = new char[rhs.size_ + 1]; + size_ = rhs.size_; + + if (str_ != NULL) { + memcpy(str_, rhs.str_, (size_ + 1) * sizeof(char)); + } + else { + size_ = 0; + } + } + + return *this; + } + + /*! \brief Constructs a string by copying the value of another instance. + * + * \param rhs the string to copy. + */ + string(const string& rhs) : + size_(0), + str_(NULL) + { + *this = rhs; + } + + //! \brief Destructor - frees memory used to hold the current value. + ~string() + { + delete[] str_; + str_ = NULL; + } + + //! \brief Queries the length of the string, excluding any added '\0's. + ::size_t size(void) const { return size_; } + + //! \brief Queries the length of the string, excluding any added '\0's. + ::size_t length(void) const { return size(); } + + /*! \brief Returns a pointer to the private copy held by this instance, + * or "" if empty/unset. + */ + const char * c_str(void) const { return (str_) ? str_ : "";} +}; +typedef cl::string STRING_CLASS; +#endif // #elif !defined(__USE_DEV_STRING) + +#if !defined(__USE_DEV_VECTOR) && !defined(__NO_STD_VECTOR) +#define VECTOR_CLASS std::vector +#elif !defined(__USE_DEV_VECTOR) +#define VECTOR_CLASS cl::vector + +#if !defined(__MAX_DEFAULT_VECTOR_SIZE) +#define __MAX_DEFAULT_VECTOR_SIZE 10 +#endif + +/*! \class vector + * \brief Fixed sized vector implementation that mirroring + * + * \note Deprecated. Please use std::vector as default or + * re-define the vector class to match the std::vector + * interface by defining VECTOR_CLASS + + * \note Not recommended for use with custom objects as + * current implementation will construct N elements + * + * std::vector functionality. + * \brief Fixed sized vector compatible with std::vector. + * + * \note + * This differs from std::vector<> not just in memory allocation, + * but also in terms of when members are constructed, destroyed, + * and assigned instead of being copy constructed. + * + * \param T type of element contained in the vector. + * + * \param N maximum size of the vector. + */ +template <typename T, unsigned int N = __MAX_DEFAULT_VECTOR_SIZE> +class CL_EXT_PREFIX__VERSION_1_1_DEPRECATED vector +{ +private: + T data_[N]; + unsigned int size_; + +public: + //! \brief Constructs an empty vector with no memory allocated. + vector() : + size_(static_cast<unsigned int>(0)) + {} + + //! \brief Deallocates the vector's memory and destroys all of its elements. + ~vector() + { + clear(); + } + + //! \brief Returns the number of elements currently contained. + unsigned int size(void) const + { + return size_; + } + + /*! \brief Empties the vector of all elements. + * \note + * This does not deallocate memory but will invoke destructors + * on contained elements. + */ + void clear() + { + while(!empty()) { + pop_back(); + } + } + + /*! \brief Appends an element after the last valid element. + * Calling this on a vector that has reached capacity will throw an + * exception if exceptions are enabled. + */ + void push_back (const T& x) + { + if (size() < N) { + new (&data_[size_]) T(x); + size_++; + } else { + detail::errHandler(CL_MEM_OBJECT_ALLOCATION_FAILURE, __VECTOR_CAPACITY_ERR); + } + } + + /*! \brief Removes the last valid element from the vector. + * Calling this on an empty vector will throw an exception + * if exceptions are enabled. + */ + void pop_back(void) + { + if (size_ != 0) { + --size_; + data_[size_].~T(); + } else { + detail::errHandler(CL_MEM_OBJECT_ALLOCATION_FAILURE, __VECTOR_CAPACITY_ERR); + } + } + + /*! \brief Constructs with a value copied from another. + * + * \param vec the vector to copy. + */ + vector(const vector<T, N>& vec) : + size_(vec.size_) + { + if (size_ != 0) { + assign(vec.begin(), vec.end()); + } + } + + /*! \brief Constructs with a specified number of initial elements. + * + * \param size number of initial elements. + * + * \param val value of initial elements. + */ + vector(unsigned int size, const T& val = T()) : + size_(0) + { + for (unsigned int i = 0; i < size; i++) { + push_back(val); + } + } + + /*! \brief Overwrites the current content with that copied from another + * instance. + * + * \param rhs vector to copy. + * + * \returns a reference to this. + */ + vector<T, N>& operator=(const vector<T, N>& rhs) + { + if (this == &rhs) { + return *this; + } + + if (rhs.size_ != 0) { + assign(rhs.begin(), rhs.end()); + } else { + clear(); + } + + return *this; + } + + /*! \brief Tests equality against another instance. + * + * \param vec the vector against which to compare. + */ + bool operator==(vector<T,N> &vec) + { + if (size() != vec.size()) { + return false; + } + + for( unsigned int i = 0; i < size(); ++i ) { + if( operator[](i) != vec[i] ) { + return false; + } + } + return true; + } + + //! \brief Conversion operator to T*. + operator T* () { return data_; } + + //! \brief Conversion operator to const T*. + operator const T* () const { return data_; } + + //! \brief Tests whether this instance has any elements. + bool empty (void) const + { + return size_==0; + } + + //! \brief Returns the maximum number of elements this instance can hold. + unsigned int max_size (void) const + { + return N; + } + + //! \brief Returns the maximum number of elements this instance can hold. + unsigned int capacity () const + { + return N; + } + + //! \brief Resizes the vector to the given size + void resize(unsigned int newSize, T fill = T()) + { + if (newSize > N) + { + detail::errHandler(CL_MEM_OBJECT_ALLOCATION_FAILURE, __VECTOR_CAPACITY_ERR); + } + else + { + while (size_ < newSize) + { + new (&data_[size_]) T(fill); + size_++; + } + while (size_ > newSize) + { + --size_; + data_[size_].~T(); + } + } + } + + /*! \brief Returns a reference to a given element. + * + * \param index which element to access. * + * \note + * The caller is responsible for ensuring index is >= 0 and < size(). + */ + T& operator[](int index) + { + return data_[index]; + } + + /*! \brief Returns a const reference to a given element. + * + * \param index which element to access. + * + * \note + * The caller is responsible for ensuring index is >= 0 and < size(). + */ + const T& operator[](int index) const + { + return data_[index]; + } + + /*! \brief Assigns elements of the vector based on a source iterator range. + * + * \param start Beginning iterator of source range + * \param end Enditerator of source range + * + * \note + * Will throw an exception if exceptions are enabled and size exceeded. + */ + template<class I> + void assign(I start, I end) + { + clear(); + while(start != end) { + push_back(*start); + start++; + } + } + + /*! \class iterator + * \brief Const iterator class for vectors + */ + class iterator + { + private: + const vector<T,N> *vec_; + int index_; + + /** + * Internal iterator constructor to capture reference + * to the vector it iterates over rather than taking + * the vector by copy. + */ + iterator (const vector<T,N> &vec, int index) : + vec_(&vec) + { + if( !vec.empty() ) { + index_ = index; + } else { + index_ = -1; + } + } + + public: + iterator(void) : + index_(-1), + vec_(NULL) + { + } + + iterator(const iterator& rhs) : + vec_(rhs.vec_), + index_(rhs.index_) + { + } + + ~iterator(void) {} + + static iterator begin(const cl::vector<T,N> &vec) + { + iterator i(vec, 0); + + return i; + } + + static iterator end(const cl::vector<T,N> &vec) + { + iterator i(vec, vec.size()); + + return i; + } + + bool operator==(iterator i) + { + return ((vec_ == i.vec_) && + (index_ == i.index_)); + } + + bool operator!=(iterator i) + { + return (!(*this==i)); + } + + iterator& operator++() + { + ++index_; + return *this; + } + + iterator operator++(int) + { + iterator retVal(*this); + ++index_; + return retVal; + } + + iterator& operator--() + { + --index_; + return *this; + } + + iterator operator--(int) + { + iterator retVal(*this); + --index_; + return retVal; + } + + const T& operator *() const + { + return (*vec_)[index_]; + } + }; + + iterator begin(void) + { + return iterator::begin(*this); + } + + iterator begin(void) const + { + return iterator::begin(*this); + } + + iterator end(void) + { + return iterator::end(*this); + } + + iterator end(void) const + { + return iterator::end(*this); + } + + T& front(void) + { + return data_[0]; + } + + T& back(void) + { + return data_[size_]; + } + + const T& front(void) const + { + return data_[0]; + } + + const T& back(void) const + { + return data_[size_-1]; + } +} CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED; +#endif // #if !defined(__USE_DEV_VECTOR) && !defined(__NO_STD_VECTOR) + + + + + +namespace detail { +#define __DEFAULT_NOT_INITIALIZED 1 +#define __DEFAULT_BEING_INITIALIZED 2 +#define __DEFAULT_INITIALIZED 4 + + /* + * Compare and exchange primitives are needed for handling of defaults + */ + +#ifdef CL_HPP_CPP11_ATOMICS_SUPPORTED + inline int compare_exchange(std::atomic<int> * dest, int exchange, int comparand) +#else // !CL_HPP_CPP11_ATOMICS_SUPPORTED + inline int compare_exchange(volatile int * dest, int exchange, int comparand) +#endif // !CL_HPP_CPP11_ATOMICS_SUPPORTED + { +#ifdef CL_HPP_CPP11_ATOMICS_SUPPORTED + std::atomic_compare_exchange_strong(dest, &comparand, exchange); + return comparand; +#elif _MSC_VER + return (int)(_InterlockedCompareExchange( + (volatile long*)dest, + (long)exchange, + (long)comparand)); +#else // !_MSC_VER && !CL_HPP_CPP11_ATOMICS_SUPPORTED + return (__sync_val_compare_and_swap( + dest, + comparand, + exchange)); +#endif // !CL_HPP_CPP11_ATOMICS_SUPPORTED + } + + inline void fence() { +#ifdef CL_HPP_CPP11_ATOMICS_SUPPORTED + std::atomic_thread_fence(std::memory_order_seq_cst); +#elif _MSC_VER // !CL_HPP_CPP11_ATOMICS_SUPPORTED + _ReadWriteBarrier(); +#else // !_MSC_VER && !CL_HPP_CPP11_ATOMICS_SUPPORTED + __sync_synchronize(); +#endif // !CL_HPP_CPP11_ATOMICS_SUPPORTED + } +} // namespace detail + + +/*! \brief class used to interface between C++ and + * OpenCL C calls that require arrays of size_t values, whose + * size is known statically. + */ +template <int N> +class size_t +{ +private: + ::size_t data_[N]; + +public: + //! \brief Initialize size_t to all 0s + size_t() + { + for( int i = 0; i < N; ++i ) { + data_[i] = 0; + } + } + + ::size_t& operator[](int index) + { + return data_[index]; + } + + const ::size_t& operator[](int index) const + { + return data_[index]; + } + + //! \brief Conversion operator to T*. + operator ::size_t* () { return data_; } + + //! \brief Conversion operator to const T*. + operator const ::size_t* () const { return data_; } +}; + +namespace detail { + +// Generic getInfoHelper. The final parameter is used to guide overload +// resolution: the actual parameter passed is an int, which makes this +// a worse conversion sequence than a specialization that declares the +// parameter as an int. +template<typename Functor, typename T> +inline cl_int getInfoHelper(Functor f, cl_uint name, T* param, long) +{ + return f(name, sizeof(T), param, NULL); +} + +// Specialized getInfoHelper for VECTOR_CLASS params +template <typename Func, typename T> +inline cl_int getInfoHelper(Func f, cl_uint name, VECTOR_CLASS<T>* param, long) +{ + ::size_t required; + cl_int err = f(name, 0, NULL, &required); + if (err != CL_SUCCESS) { + return err; + } + + T* value = (T*) alloca(required); + err = f(name, required, value, NULL); + if (err != CL_SUCCESS) { + return err; + } + + param->assign(&value[0], &value[required/sizeof(T)]); + return CL_SUCCESS; +} + +/* Specialization for reference-counted types. This depends on the + * existence of Wrapper<T>::cl_type, and none of the other types having the + * cl_type member. Note that simplify specifying the parameter as Wrapper<T> + * does not work, because when using a derived type (e.g. Context) the generic + * template will provide a better match. + */ +template <typename Func, typename T> +inline cl_int getInfoHelper(Func f, cl_uint name, VECTOR_CLASS<T>* param, int, typename T::cl_type = 0) +{ + ::size_t required; + cl_int err = f(name, 0, NULL, &required); + if (err != CL_SUCCESS) { + return err; + } + + typename T::cl_type * value = (typename T::cl_type *) alloca(required); + err = f(name, required, value, NULL); + if (err != CL_SUCCESS) { + return err; + } + + ::size_t elements = required / sizeof(typename T::cl_type); + param->assign(&value[0], &value[elements]); + for (::size_t i = 0; i < elements; i++) + { + if (value[i] != NULL) + { + err = (*param)[i].retain(); + if (err != CL_SUCCESS) { + return err; + } + } + } + return CL_SUCCESS; +} + +// Specialized for getInfo<CL_PROGRAM_BINARIES> +template <typename Func> +inline cl_int getInfoHelper(Func f, cl_uint name, VECTOR_CLASS<char *>* param, int) +{ + cl_int err = f(name, param->size() * sizeof(char *), &(*param)[0], NULL); + + if (err != CL_SUCCESS) { + return err; + } + + return CL_SUCCESS; +} + +// Specialized GetInfoHelper for STRING_CLASS params +template <typename Func> +inline cl_int getInfoHelper(Func f, cl_uint name, STRING_CLASS* param, long) +{ +#if defined(__NO_STD_VECTOR) || defined(__NO_STD_STRING) + ::size_t required; + cl_int err = f(name, 0, NULL, &required); + if (err != CL_SUCCESS) { + return err; + } + + char* value = (char*)alloca(required); + err = f(name, required, value, NULL); + if (err != CL_SUCCESS) { + return err; + } + + *param = value; + return CL_SUCCESS; +#else + ::size_t required; + cl_int err = f(name, 0, NULL, &required); + if (err != CL_SUCCESS) { + return err; + } + + // std::string has a constant data member + // a char vector does not + VECTOR_CLASS<char> value(required); + err = f(name, required, value.data(), NULL); + if (err != CL_SUCCESS) { + return err; + } + if (param) { + param->assign(value.begin(), value.end()); + } +#endif + return CL_SUCCESS; +} + +// Specialized GetInfoHelper for cl::size_t params +template <typename Func, ::size_t N> +inline cl_int getInfoHelper(Func f, cl_uint name, size_t<N>* param, long) +{ + ::size_t required; + cl_int err = f(name, 0, NULL, &required); + if (err != CL_SUCCESS) { + return err; + } + + ::size_t* value = (::size_t*) alloca(required); + err = f(name, required, value, NULL); + if (err != CL_SUCCESS) { + return err; + } + + for(int i = 0; i < N; ++i) { + (*param)[i] = value[i]; + } + + return CL_SUCCESS; +} + +template<typename T> struct ReferenceHandler; + +/* Specialization for reference-counted types. This depends on the + * existence of Wrapper<T>::cl_type, and none of the other types having the + * cl_type member. Note that simplify specifying the parameter as Wrapper<T> + * does not work, because when using a derived type (e.g. Context) the generic + * template will provide a better match. + */ +template<typename Func, typename T> +inline cl_int getInfoHelper(Func f, cl_uint name, T* param, int, typename T::cl_type = 0) +{ + typename T::cl_type value; + cl_int err = f(name, sizeof(value), &value, NULL); + if (err != CL_SUCCESS) { + return err; + } + *param = value; + if (value != NULL) + { + err = param->retain(); + if (err != CL_SUCCESS) { + return err; + } + } + return CL_SUCCESS; +} + +#define __PARAM_NAME_INFO_1_0(F) \ + F(cl_platform_info, CL_PLATFORM_PROFILE, STRING_CLASS) \ + F(cl_platform_info, CL_PLATFORM_VERSION, STRING_CLASS) \ + F(cl_platform_info, CL_PLATFORM_NAME, STRING_CLASS) \ + F(cl_platform_info, CL_PLATFORM_VENDOR, STRING_CLASS) \ + F(cl_platform_info, CL_PLATFORM_EXTENSIONS, STRING_CLASS) \ + \ + F(cl_device_info, CL_DEVICE_TYPE, cl_device_type) \ + F(cl_device_info, CL_DEVICE_VENDOR_ID, cl_uint) \ + F(cl_device_info, CL_DEVICE_MAX_COMPUTE_UNITS, cl_uint) \ + F(cl_device_info, CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS, cl_uint) \ + F(cl_device_info, CL_DEVICE_MAX_WORK_GROUP_SIZE, ::size_t) \ + F(cl_device_info, CL_DEVICE_MAX_WORK_ITEM_SIZES, VECTOR_CLASS< ::size_t>) \ + F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_CHAR, cl_uint) \ + F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_SHORT, cl_uint) \ + F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_INT, cl_uint) \ + F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_LONG, cl_uint) \ + F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_FLOAT, cl_uint) \ + F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE, cl_uint) \ + F(cl_device_info, CL_DEVICE_MAX_CLOCK_FREQUENCY, cl_uint) \ + F(cl_device_info, CL_DEVICE_ADDRESS_BITS, cl_uint) \ + F(cl_device_info, CL_DEVICE_MAX_READ_IMAGE_ARGS, cl_uint) \ + F(cl_device_info, CL_DEVICE_MAX_WRITE_IMAGE_ARGS, cl_uint) \ + F(cl_device_info, CL_DEVICE_MAX_MEM_ALLOC_SIZE, cl_ulong) \ + F(cl_device_info, CL_DEVICE_IMAGE2D_MAX_WIDTH, ::size_t) \ + F(cl_device_info, CL_DEVICE_IMAGE2D_MAX_HEIGHT, ::size_t) \ + F(cl_device_info, CL_DEVICE_IMAGE3D_MAX_WIDTH, ::size_t) \ + F(cl_device_info, CL_DEVICE_IMAGE3D_MAX_HEIGHT, ::size_t) \ + F(cl_device_info, CL_DEVICE_IMAGE3D_MAX_DEPTH, ::size_t) \ + F(cl_device_info, CL_DEVICE_IMAGE_SUPPORT, cl_bool) \ + F(cl_device_info, CL_DEVICE_MAX_PARAMETER_SIZE, ::size_t) \ + F(cl_device_info, CL_DEVICE_MAX_SAMPLERS, cl_uint) \ + F(cl_device_info, CL_DEVICE_MEM_BASE_ADDR_ALIGN, cl_uint) \ + F(cl_device_info, CL_DEVICE_MIN_DATA_TYPE_ALIGN_SIZE, cl_uint) \ + F(cl_device_info, CL_DEVICE_SINGLE_FP_CONFIG, cl_device_fp_config) \ + F(cl_device_info, CL_DEVICE_GLOBAL_MEM_CACHE_TYPE, cl_device_mem_cache_type) \ + F(cl_device_info, CL_DEVICE_GLOBAL_MEM_CACHELINE_SIZE, cl_uint)\ + F(cl_device_info, CL_DEVICE_GLOBAL_MEM_CACHE_SIZE, cl_ulong) \ + F(cl_device_info, CL_DEVICE_GLOBAL_MEM_SIZE, cl_ulong) \ + F(cl_device_info, CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE, cl_ulong) \ + F(cl_device_info, CL_DEVICE_MAX_CONSTANT_ARGS, cl_uint) \ + F(cl_device_info, CL_DEVICE_LOCAL_MEM_TYPE, cl_device_local_mem_type) \ + F(cl_device_info, CL_DEVICE_LOCAL_MEM_SIZE, cl_ulong) \ + F(cl_device_info, CL_DEVICE_ERROR_CORRECTION_SUPPORT, cl_bool) \ + F(cl_device_info, CL_DEVICE_PROFILING_TIMER_RESOLUTION, ::size_t) \ + F(cl_device_info, CL_DEVICE_ENDIAN_LITTLE, cl_bool) \ + F(cl_device_info, CL_DEVICE_AVAILABLE, cl_bool) \ + F(cl_device_info, CL_DEVICE_COMPILER_AVAILABLE, cl_bool) \ + F(cl_device_info, CL_DEVICE_EXECUTION_CAPABILITIES, cl_device_exec_capabilities) \ + F(cl_device_info, CL_DEVICE_QUEUE_PROPERTIES, cl_command_queue_properties) \ + F(cl_device_info, CL_DEVICE_PLATFORM, cl_platform_id) \ + F(cl_device_info, CL_DEVICE_NAME, STRING_CLASS) \ + F(cl_device_info, CL_DEVICE_VENDOR, STRING_CLASS) \ + F(cl_device_info, CL_DRIVER_VERSION, STRING_CLASS) \ + F(cl_device_info, CL_DEVICE_PROFILE, STRING_CLASS) \ + F(cl_device_info, CL_DEVICE_VERSION, STRING_CLASS) \ + F(cl_device_info, CL_DEVICE_EXTENSIONS, STRING_CLASS) \ + \ + F(cl_context_info, CL_CONTEXT_REFERENCE_COUNT, cl_uint) \ + F(cl_context_info, CL_CONTEXT_DEVICES, VECTOR_CLASS<Device>) \ + F(cl_context_info, CL_CONTEXT_PROPERTIES, VECTOR_CLASS<cl_context_properties>) \ + \ + F(cl_event_info, CL_EVENT_COMMAND_QUEUE, cl::CommandQueue) \ + F(cl_event_info, CL_EVENT_COMMAND_TYPE, cl_command_type) \ + F(cl_event_info, CL_EVENT_REFERENCE_COUNT, cl_uint) \ + F(cl_event_info, CL_EVENT_COMMAND_EXECUTION_STATUS, cl_int) \ + \ + F(cl_profiling_info, CL_PROFILING_COMMAND_QUEUED, cl_ulong) \ + F(cl_profiling_info, CL_PROFILING_COMMAND_SUBMIT, cl_ulong) \ + F(cl_profiling_info, CL_PROFILING_COMMAND_START, cl_ulong) \ + F(cl_profiling_info, CL_PROFILING_COMMAND_END, cl_ulong) \ + \ + F(cl_mem_info, CL_MEM_TYPE, cl_mem_object_type) \ + F(cl_mem_info, CL_MEM_FLAGS, cl_mem_flags) \ + F(cl_mem_info, CL_MEM_SIZE, ::size_t) \ + F(cl_mem_info, CL_MEM_HOST_PTR, void*) \ + F(cl_mem_info, CL_MEM_MAP_COUNT, cl_uint) \ + F(cl_mem_info, CL_MEM_REFERENCE_COUNT, cl_uint) \ + F(cl_mem_info, CL_MEM_CONTEXT, cl::Context) \ + \ + F(cl_image_info, CL_IMAGE_FORMAT, cl_image_format) \ + F(cl_image_info, CL_IMAGE_ELEMENT_SIZE, ::size_t) \ + F(cl_image_info, CL_IMAGE_ROW_PITCH, ::size_t) \ + F(cl_image_info, CL_IMAGE_SLICE_PITCH, ::size_t) \ + F(cl_image_info, CL_IMAGE_WIDTH, ::size_t) \ + F(cl_image_info, CL_IMAGE_HEIGHT, ::size_t) \ + F(cl_image_info, CL_IMAGE_DEPTH, ::size_t) \ + \ + F(cl_sampler_info, CL_SAMPLER_REFERENCE_COUNT, cl_uint) \ + F(cl_sampler_info, CL_SAMPLER_CONTEXT, cl::Context) \ + F(cl_sampler_info, CL_SAMPLER_NORMALIZED_COORDS, cl_bool) \ + F(cl_sampler_info, CL_SAMPLER_ADDRESSING_MODE, cl_addressing_mode) \ + F(cl_sampler_info, CL_SAMPLER_FILTER_MODE, cl_filter_mode) \ + \ + F(cl_program_info, CL_PROGRAM_REFERENCE_COUNT, cl_uint) \ + F(cl_program_info, CL_PROGRAM_CONTEXT, cl::Context) \ + F(cl_program_info, CL_PROGRAM_NUM_DEVICES, cl_uint) \ + F(cl_program_info, CL_PROGRAM_DEVICES, VECTOR_CLASS<Device>) \ + F(cl_program_info, CL_PROGRAM_SOURCE, STRING_CLASS) \ + F(cl_program_info, CL_PROGRAM_BINARY_SIZES, VECTOR_CLASS< ::size_t>) \ + F(cl_program_info, CL_PROGRAM_BINARIES, VECTOR_CLASS<char *>) \ + \ + F(cl_program_build_info, CL_PROGRAM_BUILD_STATUS, cl_build_status) \ + F(cl_program_build_info, CL_PROGRAM_BUILD_OPTIONS, STRING_CLASS) \ + F(cl_program_build_info, CL_PROGRAM_BUILD_LOG, STRING_CLASS) \ + \ + F(cl_kernel_info, CL_KERNEL_FUNCTION_NAME, STRING_CLASS) \ + F(cl_kernel_info, CL_KERNEL_NUM_ARGS, cl_uint) \ + F(cl_kernel_info, CL_KERNEL_REFERENCE_COUNT, cl_uint) \ + F(cl_kernel_info, CL_KERNEL_CONTEXT, cl::Context) \ + F(cl_kernel_info, CL_KERNEL_PROGRAM, cl::Program) \ + \ + F(cl_kernel_work_group_info, CL_KERNEL_WORK_GROUP_SIZE, ::size_t) \ + F(cl_kernel_work_group_info, CL_KERNEL_COMPILE_WORK_GROUP_SIZE, cl::size_t<3>) \ + F(cl_kernel_work_group_info, CL_KERNEL_LOCAL_MEM_SIZE, cl_ulong) \ + \ + F(cl_command_queue_info, CL_QUEUE_CONTEXT, cl::Context) \ + F(cl_command_queue_info, CL_QUEUE_DEVICE, cl::Device) \ + F(cl_command_queue_info, CL_QUEUE_REFERENCE_COUNT, cl_uint) \ + F(cl_command_queue_info, CL_QUEUE_PROPERTIES, cl_command_queue_properties) + +#if defined(CL_VERSION_1_1) +#define __PARAM_NAME_INFO_1_1(F) \ + F(cl_context_info, CL_CONTEXT_NUM_DEVICES, cl_uint)\ + F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_HALF, cl_uint) \ + F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_CHAR, cl_uint) \ + F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_SHORT, cl_uint) \ + F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_INT, cl_uint) \ + F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_LONG, cl_uint) \ + F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_FLOAT, cl_uint) \ + F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE, cl_uint) \ + F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_HALF, cl_uint) \ + F(cl_device_info, CL_DEVICE_DOUBLE_FP_CONFIG, cl_device_fp_config) \ + F(cl_device_info, CL_DEVICE_HALF_FP_CONFIG, cl_device_fp_config) \ + F(cl_device_info, CL_DEVICE_HOST_UNIFIED_MEMORY, cl_bool) \ + F(cl_device_info, CL_DEVICE_OPENCL_C_VERSION, STRING_CLASS) \ + \ + F(cl_mem_info, CL_MEM_ASSOCIATED_MEMOBJECT, cl::Memory) \ + F(cl_mem_info, CL_MEM_OFFSET, ::size_t) \ + \ + F(cl_kernel_work_group_info, CL_KERNEL_PREFERRED_WORK_GROUP_SIZE_MULTIPLE, ::size_t) \ + F(cl_kernel_work_group_info, CL_KERNEL_PRIVATE_MEM_SIZE, cl_ulong) \ + \ + F(cl_event_info, CL_EVENT_CONTEXT, cl::Context) +#endif // CL_VERSION_1_1 + + +#if defined(CL_VERSION_1_2) +#define __PARAM_NAME_INFO_1_2(F) \ + F(cl_image_info, CL_IMAGE_BUFFER, cl::Buffer) \ + \ + F(cl_program_info, CL_PROGRAM_NUM_KERNELS, ::size_t) \ + F(cl_program_info, CL_PROGRAM_KERNEL_NAMES, STRING_CLASS) \ + \ + F(cl_program_build_info, CL_PROGRAM_BINARY_TYPE, cl_program_binary_type) \ + \ + F(cl_kernel_info, CL_KERNEL_ATTRIBUTES, STRING_CLASS) \ + \ + F(cl_kernel_arg_info, CL_KERNEL_ARG_ADDRESS_QUALIFIER, cl_kernel_arg_address_qualifier) \ + F(cl_kernel_arg_info, CL_KERNEL_ARG_ACCESS_QUALIFIER, cl_kernel_arg_access_qualifier) \ + F(cl_kernel_arg_info, CL_KERNEL_ARG_TYPE_NAME, STRING_CLASS) \ + F(cl_kernel_arg_info, CL_KERNEL_ARG_NAME, STRING_CLASS) \ + F(cl_kernel_arg_info, CL_KERNEL_ARG_TYPE_QUALIFIER, cl_kernel_arg_type_qualifier) \ + \ + F(cl_device_info, CL_DEVICE_PARENT_DEVICE, cl_device_id) \ + F(cl_device_info, CL_DEVICE_PARTITION_PROPERTIES, VECTOR_CLASS<cl_device_partition_property>) \ + F(cl_device_info, CL_DEVICE_PARTITION_TYPE, VECTOR_CLASS<cl_device_partition_property>) \ + F(cl_device_info, CL_DEVICE_REFERENCE_COUNT, cl_uint) \ + F(cl_device_info, CL_DEVICE_PREFERRED_INTEROP_USER_SYNC, ::size_t) \ + F(cl_device_info, CL_DEVICE_PARTITION_AFFINITY_DOMAIN, cl_device_affinity_domain) \ + F(cl_device_info, CL_DEVICE_BUILT_IN_KERNELS, STRING_CLASS) +#endif // #if defined(CL_VERSION_1_2) + +#if defined(USE_CL_DEVICE_FISSION) +#define __PARAM_NAME_DEVICE_FISSION(F) \ + F(cl_device_info, CL_DEVICE_PARENT_DEVICE_EXT, cl_device_id) \ + F(cl_device_info, CL_DEVICE_PARTITION_TYPES_EXT, VECTOR_CLASS<cl_device_partition_property_ext>) \ + F(cl_device_info, CL_DEVICE_AFFINITY_DOMAINS_EXT, VECTOR_CLASS<cl_device_partition_property_ext>) \ + F(cl_device_info, CL_DEVICE_REFERENCE_COUNT_EXT , cl_uint) \ + F(cl_device_info, CL_DEVICE_PARTITION_STYLE_EXT, VECTOR_CLASS<cl_device_partition_property_ext>) +#endif // USE_CL_DEVICE_FISSION + +template <typename enum_type, cl_int Name> +struct param_traits {}; + +#define __CL_DECLARE_PARAM_TRAITS(token, param_name, T) \ +struct token; \ +template<> \ +struct param_traits<detail:: token,param_name> \ +{ \ + enum { value = param_name }; \ + typedef T param_type; \ +}; + +__PARAM_NAME_INFO_1_0(__CL_DECLARE_PARAM_TRAITS) +#if defined(CL_VERSION_1_1) +__PARAM_NAME_INFO_1_1(__CL_DECLARE_PARAM_TRAITS) +#endif // CL_VERSION_1_1 +#if defined(CL_VERSION_1_2) +__PARAM_NAME_INFO_1_2(__CL_DECLARE_PARAM_TRAITS) +#endif // CL_VERSION_1_1 + +#if defined(USE_CL_DEVICE_FISSION) +__PARAM_NAME_DEVICE_FISSION(__CL_DECLARE_PARAM_TRAITS); +#endif // USE_CL_DEVICE_FISSION + +#ifdef CL_PLATFORM_ICD_SUFFIX_KHR +__CL_DECLARE_PARAM_TRAITS(cl_platform_info, CL_PLATFORM_ICD_SUFFIX_KHR, STRING_CLASS) +#endif + +#ifdef CL_DEVICE_PROFILING_TIMER_OFFSET_AMD +__CL_DECLARE_PARAM_TRAITS(cl_device_info, CL_DEVICE_PROFILING_TIMER_OFFSET_AMD, cl_ulong) +#endif + +#ifdef CL_DEVICE_GLOBAL_FREE_MEMORY_AMD +__CL_DECLARE_PARAM_TRAITS(cl_device_info, CL_DEVICE_GLOBAL_FREE_MEMORY_AMD, VECTOR_CLASS< ::size_t>) +#endif +#ifdef CL_DEVICE_SIMD_PER_COMPUTE_UNIT_AMD +__CL_DECLARE_PARAM_TRAITS(cl_device_info, CL_DEVICE_SIMD_PER_COMPUTE_UNIT_AMD, cl_uint) +#endif +#ifdef CL_DEVICE_SIMD_WIDTH_AMD +__CL_DECLARE_PARAM_TRAITS(cl_device_info, CL_DEVICE_SIMD_WIDTH_AMD, cl_uint) +#endif +#ifdef CL_DEVICE_SIMD_INSTRUCTION_WIDTH_AMD +__CL_DECLARE_PARAM_TRAITS(cl_device_info, CL_DEVICE_SIMD_INSTRUCTION_WIDTH_AMD, cl_uint) +#endif +#ifdef CL_DEVICE_WAVEFRONT_WIDTH_AMD +__CL_DECLARE_PARAM_TRAITS(cl_device_info, CL_DEVICE_WAVEFRONT_WIDTH_AMD, cl_uint) +#endif +#ifdef CL_DEVICE_GLOBAL_MEM_CHANNELS_AMD +__CL_DECLARE_PARAM_TRAITS(cl_device_info, CL_DEVICE_GLOBAL_MEM_CHANNELS_AMD, cl_uint) +#endif +#ifdef CL_DEVICE_GLOBAL_MEM_CHANNEL_BANKS_AMD +__CL_DECLARE_PARAM_TRAITS(cl_device_info, CL_DEVICE_GLOBAL_MEM_CHANNEL_BANKS_AMD, cl_uint) +#endif +#ifdef CL_DEVICE_GLOBAL_MEM_CHANNEL_BANK_WIDTH_AMD +__CL_DECLARE_PARAM_TRAITS(cl_device_info, CL_DEVICE_GLOBAL_MEM_CHANNEL_BANK_WIDTH_AMD, cl_uint) +#endif +#ifdef CL_DEVICE_LOCAL_MEM_SIZE_PER_COMPUTE_UNIT_AMD +__CL_DECLARE_PARAM_TRAITS(cl_device_info, CL_DEVICE_LOCAL_MEM_SIZE_PER_COMPUTE_UNIT_AMD, cl_uint) +#endif +#ifdef CL_DEVICE_LOCAL_MEM_BANKS_AMD +__CL_DECLARE_PARAM_TRAITS(cl_device_info, CL_DEVICE_LOCAL_MEM_BANKS_AMD, cl_uint) +#endif + +#ifdef CL_DEVICE_COMPUTE_CAPABILITY_MAJOR_NV +__CL_DECLARE_PARAM_TRAITS(cl_device_info, CL_DEVICE_COMPUTE_CAPABILITY_MAJOR_NV, cl_uint) +#endif +#ifdef CL_DEVICE_COMPUTE_CAPABILITY_MINOR_NV +__CL_DECLARE_PARAM_TRAITS(cl_device_info, CL_DEVICE_COMPUTE_CAPABILITY_MINOR_NV, cl_uint) +#endif +#ifdef CL_DEVICE_REGISTERS_PER_BLOCK_NV +__CL_DECLARE_PARAM_TRAITS(cl_device_info, CL_DEVICE_REGISTERS_PER_BLOCK_NV, cl_uint) +#endif +#ifdef CL_DEVICE_WARP_SIZE_NV +__CL_DECLARE_PARAM_TRAITS(cl_device_info, CL_DEVICE_WARP_SIZE_NV, cl_uint) +#endif +#ifdef CL_DEVICE_GPU_OVERLAP_NV +__CL_DECLARE_PARAM_TRAITS(cl_device_info, CL_DEVICE_GPU_OVERLAP_NV, cl_bool) +#endif +#ifdef CL_DEVICE_KERNEL_EXEC_TIMEOUT_NV +__CL_DECLARE_PARAM_TRAITS(cl_device_info, CL_DEVICE_KERNEL_EXEC_TIMEOUT_NV, cl_bool) +#endif +#ifdef CL_DEVICE_INTEGRATED_MEMORY_NV +__CL_DECLARE_PARAM_TRAITS(cl_device_info, CL_DEVICE_INTEGRATED_MEMORY_NV, cl_bool) +#endif + +// Convenience functions + +template <typename Func, typename T> +inline cl_int +getInfo(Func f, cl_uint name, T* param) +{ + return getInfoHelper(f, name, param, 0); +} + +template <typename Func, typename Arg0> +struct GetInfoFunctor0 +{ + Func f_; const Arg0& arg0_; + cl_int operator ()( + cl_uint param, ::size_t size, void* value, ::size_t* size_ret) + { return f_(arg0_, param, size, value, size_ret); } +}; + +template <typename Func, typename Arg0, typename Arg1> +struct GetInfoFunctor1 +{ + Func f_; const Arg0& arg0_; const Arg1& arg1_; + cl_int operator ()( + cl_uint param, ::size_t size, void* value, ::size_t* size_ret) + { return f_(arg0_, arg1_, param, size, value, size_ret); } +}; + +template <typename Func, typename Arg0, typename T> +inline cl_int +getInfo(Func f, const Arg0& arg0, cl_uint name, T* param) +{ + GetInfoFunctor0<Func, Arg0> f0 = { f, arg0 }; + return getInfoHelper(f0, name, param, 0); +} + +template <typename Func, typename Arg0, typename Arg1, typename T> +inline cl_int +getInfo(Func f, const Arg0& arg0, const Arg1& arg1, cl_uint name, T* param) +{ + GetInfoFunctor1<Func, Arg0, Arg1> f0 = { f, arg0, arg1 }; + return getInfoHelper(f0, name, param, 0); +} + +template<typename T> +struct ReferenceHandler +{ }; + +#if defined(CL_VERSION_1_2) +/** + * OpenCL 1.2 devices do have retain/release. + */ +template <> +struct ReferenceHandler<cl_device_id> +{ + /** + * Retain the device. + * \param device A valid device created using createSubDevices + * \return + * CL_SUCCESS if the function executed successfully. + * CL_INVALID_DEVICE if device was not a valid subdevice + * CL_OUT_OF_RESOURCES + * CL_OUT_OF_HOST_MEMORY + */ + static cl_int retain(cl_device_id device) + { return ::clRetainDevice(device); } + /** + * Retain the device. + * \param device A valid device created using createSubDevices + * \return + * CL_SUCCESS if the function executed successfully. + * CL_INVALID_DEVICE if device was not a valid subdevice + * CL_OUT_OF_RESOURCES + * CL_OUT_OF_HOST_MEMORY + */ + static cl_int release(cl_device_id device) + { return ::clReleaseDevice(device); } +}; +#else // #if defined(CL_VERSION_1_2) +/** + * OpenCL 1.1 devices do not have retain/release. + */ +template <> +struct ReferenceHandler<cl_device_id> +{ + // cl_device_id does not have retain(). + static cl_int retain(cl_device_id) + { return CL_SUCCESS; } + // cl_device_id does not have release(). + static cl_int release(cl_device_id) + { return CL_SUCCESS; } +}; +#endif // #if defined(CL_VERSION_1_2) + +template <> +struct ReferenceHandler<cl_platform_id> +{ + // cl_platform_id does not have retain(). + static cl_int retain(cl_platform_id) + { return CL_SUCCESS; } + // cl_platform_id does not have release(). + static cl_int release(cl_platform_id) + { return CL_SUCCESS; } +}; + +template <> +struct ReferenceHandler<cl_context> +{ + static cl_int retain(cl_context context) + { return ::clRetainContext(context); } + static cl_int release(cl_context context) + { return ::clReleaseContext(context); } +}; + +template <> +struct ReferenceHandler<cl_command_queue> +{ + static cl_int retain(cl_command_queue queue) + { return ::clRetainCommandQueue(queue); } + static cl_int release(cl_command_queue queue) + { return ::clReleaseCommandQueue(queue); } +}; + +template <> +struct ReferenceHandler<cl_mem> +{ + static cl_int retain(cl_mem memory) + { return ::clRetainMemObject(memory); } + static cl_int release(cl_mem memory) + { return ::clReleaseMemObject(memory); } +}; + +template <> +struct ReferenceHandler<cl_sampler> +{ + static cl_int retain(cl_sampler sampler) + { return ::clRetainSampler(sampler); } + static cl_int release(cl_sampler sampler) + { return ::clReleaseSampler(sampler); } +}; + +template <> +struct ReferenceHandler<cl_program> +{ + static cl_int retain(cl_program program) + { return ::clRetainProgram(program); } + static cl_int release(cl_program program) + { return ::clReleaseProgram(program); } +}; + +template <> +struct ReferenceHandler<cl_kernel> +{ + static cl_int retain(cl_kernel kernel) + { return ::clRetainKernel(kernel); } + static cl_int release(cl_kernel kernel) + { return ::clReleaseKernel(kernel); } +}; + +template <> +struct ReferenceHandler<cl_event> +{ + static cl_int retain(cl_event event) + { return ::clRetainEvent(event); } + static cl_int release(cl_event event) + { return ::clReleaseEvent(event); } +}; + + +// Extracts version number with major in the upper 16 bits, minor in the lower 16 +static cl_uint getVersion(const char *versionInfo) +{ + int highVersion = 0; + int lowVersion = 0; + int index = 7; + while(versionInfo[index] != '.' ) { + highVersion *= 10; + highVersion += versionInfo[index]-'0'; + ++index; + } + ++index; + while(versionInfo[index] != ' ' && versionInfo[index] != '\0') { + lowVersion *= 10; + lowVersion += versionInfo[index]-'0'; + ++index; + } + return (highVersion << 16) | lowVersion; +} + +static cl_uint getPlatformVersion(cl_platform_id platform) +{ + ::size_t size = 0; + clGetPlatformInfo(platform, CL_PLATFORM_VERSION, 0, NULL, &size); + char *versionInfo = (char *) alloca(size); + clGetPlatformInfo(platform, CL_PLATFORM_VERSION, size, &versionInfo[0], &size); + return getVersion(versionInfo); +} + +static cl_uint getDevicePlatformVersion(cl_device_id device) +{ + cl_platform_id platform; + clGetDeviceInfo(device, CL_DEVICE_PLATFORM, sizeof(platform), &platform, NULL); + return getPlatformVersion(platform); +} + +#if defined(CL_VERSION_1_2) && defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS) +static cl_uint getContextPlatformVersion(cl_context context) +{ + // The platform cannot be queried directly, so we first have to grab a + // device and obtain its context + ::size_t size = 0; + clGetContextInfo(context, CL_CONTEXT_DEVICES, 0, NULL, &size); + if (size == 0) + return 0; + cl_device_id *devices = (cl_device_id *) alloca(size); + clGetContextInfo(context, CL_CONTEXT_DEVICES, size, devices, NULL); + return getDevicePlatformVersion(devices[0]); +} +#endif // #if defined(CL_VERSION_1_2) && defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS) + +template <typename T> +class Wrapper +{ +public: + typedef T cl_type; + +protected: + cl_type object_; + +public: + Wrapper() : object_(NULL) { } + + Wrapper(const cl_type &obj) : object_(obj) { } + + ~Wrapper() + { + if (object_ != NULL) { release(); } + } + + Wrapper(const Wrapper<cl_type>& rhs) + { + object_ = rhs.object_; + if (object_ != NULL) { detail::errHandler(retain(), __RETAIN_ERR); } + } + +#if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED) + Wrapper(Wrapper<cl_type>&& rhs) CL_HPP_NOEXCEPT + { + object_ = rhs.object_; + rhs.object_ = NULL; + } +#endif + + Wrapper<cl_type>& operator = (const Wrapper<cl_type>& rhs) + { + if (this != &rhs) { + if (object_ != NULL) { detail::errHandler(release(), __RELEASE_ERR); } + object_ = rhs.object_; + if (object_ != NULL) { detail::errHandler(retain(), __RETAIN_ERR); } + } + return *this; + } + +#if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED) + Wrapper<cl_type>& operator = (Wrapper<cl_type>&& rhs) + { + if (this != &rhs) { + if (object_ != NULL) { detail::errHandler(release(), __RELEASE_ERR); } + object_ = rhs.object_; + rhs.object_ = NULL; + } + return *this; + } +#endif + + Wrapper<cl_type>& operator = (const cl_type &rhs) + { + if (object_ != NULL) { detail::errHandler(release(), __RELEASE_ERR); } + object_ = rhs; + return *this; + } + + cl_type operator ()() const { return object_; } + + cl_type& operator ()() { return object_; } + +protected: + template<typename Func, typename U> + friend inline cl_int getInfoHelper(Func, cl_uint, U*, int, typename U::cl_type); + + cl_int retain() const + { + return ReferenceHandler<cl_type>::retain(object_); + } + + cl_int release() const + { + return ReferenceHandler<cl_type>::release(object_); + } +}; + +template <> +class Wrapper<cl_device_id> +{ +public: + typedef cl_device_id cl_type; + +protected: + cl_type object_; + bool referenceCountable_; + + static bool isReferenceCountable(cl_device_id device) + { + bool retVal = false; + if (device != NULL) { + int version = getDevicePlatformVersion(device); + if(version > ((1 << 16) + 1)) { + retVal = true; + } + } + return retVal; + } + +public: + Wrapper() : object_(NULL), referenceCountable_(false) + { + } + + Wrapper(const cl_type &obj) : object_(obj), referenceCountable_(false) + { + referenceCountable_ = isReferenceCountable(obj); + } + + ~Wrapper() + { + if (object_ != NULL) { release(); } + } + + Wrapper(const Wrapper<cl_type>& rhs) + { + object_ = rhs.object_; + referenceCountable_ = isReferenceCountable(object_); + if (object_ != NULL) { detail::errHandler(retain(), __RETAIN_ERR); } + } + +#if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED) + Wrapper(Wrapper<cl_type>&& rhs) CL_HPP_NOEXCEPT + { + object_ = rhs.object_; + referenceCountable_ = rhs.referenceCountable_; + rhs.object_ = NULL; + rhs.referenceCountable_ = false; + } +#endif + + Wrapper<cl_type>& operator = (const Wrapper<cl_type>& rhs) + { + if (this != &rhs) { + if (object_ != NULL) { detail::errHandler(release(), __RELEASE_ERR); } + object_ = rhs.object_; + referenceCountable_ = rhs.referenceCountable_; + if (object_ != NULL) { detail::errHandler(retain(), __RETAIN_ERR); } + } + return *this; + } + +#if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED) + Wrapper<cl_type>& operator = (Wrapper<cl_type>&& rhs) + { + if (this != &rhs) { + if (object_ != NULL) { detail::errHandler(release(), __RELEASE_ERR); } + object_ = rhs.object_; + referenceCountable_ = rhs.referenceCountable_; + rhs.object_ = NULL; + rhs.referenceCountable_ = false; + } + return *this; + } +#endif + + Wrapper<cl_type>& operator = (const cl_type &rhs) + { + if (object_ != NULL) { detail::errHandler(release(), __RELEASE_ERR); } + object_ = rhs; + referenceCountable_ = isReferenceCountable(object_); + return *this; + } + + cl_type operator ()() const { return object_; } + + cl_type& operator ()() { return object_; } + +protected: + template<typename Func, typename U> + friend inline cl_int getInfoHelper(Func, cl_uint, U*, int, typename U::cl_type); + + template<typename Func, typename U> + friend inline cl_int getInfoHelper(Func, cl_uint, VECTOR_CLASS<U>*, int, typename U::cl_type); + + cl_int retain() const + { + if( referenceCountable_ ) { + return ReferenceHandler<cl_type>::retain(object_); + } + else { + return CL_SUCCESS; + } + } + + cl_int release() const + { + if( referenceCountable_ ) { + return ReferenceHandler<cl_type>::release(object_); + } + else { + return CL_SUCCESS; + } + } +}; + +} // namespace detail +//! \endcond + +/*! \stuct ImageFormat + * \brief Adds constructors and member functions for cl_image_format. + * + * \see cl_image_format + */ +struct ImageFormat : public cl_image_format +{ + //! \brief Default constructor - performs no initialization. + ImageFormat(){} + + //! \brief Initializing constructor. + ImageFormat(cl_channel_order order, cl_channel_type type) + { + image_channel_order = order; + image_channel_data_type = type; + } + + //! \brief Assignment operator. + ImageFormat& operator = (const ImageFormat& rhs) + { + if (this != &rhs) { + this->image_channel_data_type = rhs.image_channel_data_type; + this->image_channel_order = rhs.image_channel_order; + } + return *this; + } +}; + +/*! \brief Class interface for cl_device_id. + * + * \note Copies of these objects are inexpensive, since they don't 'own' + * any underlying resources or data structures. + * + * \see cl_device_id + */ +class Device : public detail::Wrapper<cl_device_id> +{ +public: + //! \brief Default constructor - initializes to NULL. + Device() : detail::Wrapper<cl_type>() { } + + /*! \brief Constructor from cl_device_id. + * + * This simply copies the device ID value, which is an inexpensive operation. + */ + __CL_EXPLICIT_CONSTRUCTORS Device(const cl_device_id &device) : detail::Wrapper<cl_type>(device) { } + + /*! \brief Returns the first device on the default context. + * + * \see Context::getDefault() + */ + static Device getDefault(cl_int * err = NULL); + + /*! \brief Assignment operator from cl_device_id. + * + * This simply copies the device ID value, which is an inexpensive operation. + */ + Device& operator = (const cl_device_id& rhs) + { + detail::Wrapper<cl_type>::operator=(rhs); + return *this; + } + + /*! \brief Copy constructor to forward copy to the superclass correctly. + * Required for MSVC. + */ + Device(const Device& dev) : detail::Wrapper<cl_type>(dev) {} + + /*! \brief Copy assignment to forward copy to the superclass correctly. + * Required for MSVC. + */ + Device& operator = (const Device &dev) + { + detail::Wrapper<cl_type>::operator=(dev); + return *this; + } + +#if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED) + /*! \brief Move constructor to forward move to the superclass correctly. + * Required for MSVC. + */ + Device(Device&& dev) CL_HPP_NOEXCEPT : detail::Wrapper<cl_type>(std::move(dev)) {} + + /*! \brief Move assignment to forward move to the superclass correctly. + * Required for MSVC. + */ + Device& operator = (Device &&dev) + { + detail::Wrapper<cl_type>::operator=(std::move(dev)); + return *this; + } +#endif // #if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED) + + //! \brief Wrapper for clGetDeviceInfo(). + template <typename T> + cl_int getInfo(cl_device_info name, T* param) const + { + return detail::errHandler( + detail::getInfo(&::clGetDeviceInfo, object_, name, param), + __GET_DEVICE_INFO_ERR); + } + + //! \brief Wrapper for clGetDeviceInfo() that returns by value. + template <cl_int name> typename + detail::param_traits<detail::cl_device_info, name>::param_type + getInfo(cl_int* err = NULL) const + { + typename detail::param_traits< + detail::cl_device_info, name>::param_type param; + cl_int result = getInfo(name, ¶m); + if (err != NULL) { + *err = result; + } + return param; + } + + /** + * CL 1.2 version + */ +#if defined(CL_VERSION_1_2) + //! \brief Wrapper for clCreateSubDevicesEXT(). + cl_int createSubDevices( + const cl_device_partition_property * properties, + VECTOR_CLASS<Device>* devices) + { + cl_uint n = 0; + cl_int err = clCreateSubDevices(object_, properties, 0, NULL, &n); + if (err != CL_SUCCESS) { + return detail::errHandler(err, __CREATE_SUB_DEVICES); + } + + cl_device_id* ids = (cl_device_id*) alloca(n * sizeof(cl_device_id)); + err = clCreateSubDevices(object_, properties, n, ids, NULL); + if (err != CL_SUCCESS) { + return detail::errHandler(err, __CREATE_SUB_DEVICES); + } + + devices->assign(&ids[0], &ids[n]); + return CL_SUCCESS; + } +#endif // #if defined(CL_VERSION_1_2) + +/** + * CL 1.1 version that uses device fission. + */ +#if defined(CL_VERSION_1_1) +#if defined(USE_CL_DEVICE_FISSION) + cl_int createSubDevices( + const cl_device_partition_property_ext * properties, + VECTOR_CLASS<Device>* devices) + { + typedef CL_API_ENTRY cl_int + ( CL_API_CALL * PFN_clCreateSubDevicesEXT)( + cl_device_id /*in_device*/, + const cl_device_partition_property_ext * /* properties */, + cl_uint /*num_entries*/, + cl_device_id * /*out_devices*/, + cl_uint * /*num_devices*/ ) CL_EXT_SUFFIX__VERSION_1_1; + + static PFN_clCreateSubDevicesEXT pfn_clCreateSubDevicesEXT = NULL; + __INIT_CL_EXT_FCN_PTR(clCreateSubDevicesEXT); + + cl_uint n = 0; + cl_int err = pfn_clCreateSubDevicesEXT(object_, properties, 0, NULL, &n); + if (err != CL_SUCCESS) { + return detail::errHandler(err, __CREATE_SUB_DEVICES); + } + + cl_device_id* ids = (cl_device_id*) alloca(n * sizeof(cl_device_id)); + err = pfn_clCreateSubDevicesEXT(object_, properties, n, ids, NULL); + if (err != CL_SUCCESS) { + return detail::errHandler(err, __CREATE_SUB_DEVICES); + } + + devices->assign(&ids[0], &ids[n]); + return CL_SUCCESS; + } +#endif // #if defined(USE_CL_DEVICE_FISSION) +#endif // #if defined(CL_VERSION_1_1) +}; + +/*! \brief Class interface for cl_platform_id. + * + * \note Copies of these objects are inexpensive, since they don't 'own' + * any underlying resources or data structures. + * + * \see cl_platform_id + */ +class Platform : public detail::Wrapper<cl_platform_id> +{ +public: + //! \brief Default constructor - initializes to NULL. + Platform() : detail::Wrapper<cl_type>() { } + + /*! \brief Constructor from cl_platform_id. + * + * This simply copies the platform ID value, which is an inexpensive operation. + */ + __CL_EXPLICIT_CONSTRUCTORS Platform(const cl_platform_id &platform) : detail::Wrapper<cl_type>(platform) { } + + /*! \brief Assignment operator from cl_platform_id. + * + * This simply copies the platform ID value, which is an inexpensive operation. + */ + Platform& operator = (const cl_platform_id& rhs) + { + detail::Wrapper<cl_type>::operator=(rhs); + return *this; + } + + //! \brief Wrapper for clGetPlatformInfo(). + cl_int getInfo(cl_platform_info name, STRING_CLASS* param) const + { + return detail::errHandler( + detail::getInfo(&::clGetPlatformInfo, object_, name, param), + __GET_PLATFORM_INFO_ERR); + } + + //! \brief Wrapper for clGetPlatformInfo() that returns by value. + template <cl_int name> typename + detail::param_traits<detail::cl_platform_info, name>::param_type + getInfo(cl_int* err = NULL) const + { + typename detail::param_traits< + detail::cl_platform_info, name>::param_type param; + cl_int result = getInfo(name, ¶m); + if (err != NULL) { + *err = result; + } + return param; + } + + /*! \brief Gets a list of devices for this platform. + * + * Wraps clGetDeviceIDs(). + */ + cl_int getDevices( + cl_device_type type, + VECTOR_CLASS<Device>* devices) const + { + cl_uint n = 0; + if( devices == NULL ) { + return detail::errHandler(CL_INVALID_ARG_VALUE, __GET_DEVICE_IDS_ERR); + } + cl_int err = ::clGetDeviceIDs(object_, type, 0, NULL, &n); + if (err != CL_SUCCESS) { + return detail::errHandler(err, __GET_DEVICE_IDS_ERR); + } + + cl_device_id* ids = (cl_device_id*) alloca(n * sizeof(cl_device_id)); + err = ::clGetDeviceIDs(object_, type, n, ids, NULL); + if (err != CL_SUCCESS) { + return detail::errHandler(err, __GET_DEVICE_IDS_ERR); + } + + devices->assign(&ids[0], &ids[n]); + return CL_SUCCESS; + } + +#if defined(USE_DX_INTEROP) + /*! \brief Get the list of available D3D10 devices. + * + * \param d3d_device_source. + * + * \param d3d_object. + * + * \param d3d_device_set. + * + * \param devices returns a vector of OpenCL D3D10 devices found. The cl::Device + * values returned in devices can be used to identify a specific OpenCL + * device. If \a devices argument is NULL, this argument is ignored. + * + * \return One of the following values: + * - CL_SUCCESS if the function is executed successfully. + * + * The application can query specific capabilities of the OpenCL device(s) + * returned by cl::getDevices. This can be used by the application to + * determine which device(s) to use. + * + * \note In the case that exceptions are enabled and a return value + * other than CL_SUCCESS is generated, then cl::Error exception is + * generated. + */ + cl_int getDevices( + cl_d3d10_device_source_khr d3d_device_source, + void * d3d_object, + cl_d3d10_device_set_khr d3d_device_set, + VECTOR_CLASS<Device>* devices) const + { + typedef CL_API_ENTRY cl_int (CL_API_CALL *PFN_clGetDeviceIDsFromD3D10KHR)( + cl_platform_id platform, + cl_d3d10_device_source_khr d3d_device_source, + void * d3d_object, + cl_d3d10_device_set_khr d3d_device_set, + cl_uint num_entries, + cl_device_id * devices, + cl_uint* num_devices); + + if( devices == NULL ) { + return detail::errHandler(CL_INVALID_ARG_VALUE, __GET_DEVICE_IDS_ERR); + } + + static PFN_clGetDeviceIDsFromD3D10KHR pfn_clGetDeviceIDsFromD3D10KHR = NULL; + __INIT_CL_EXT_FCN_PTR_PLATFORM(object_, clGetDeviceIDsFromD3D10KHR); + + cl_uint n = 0; + cl_int err = pfn_clGetDeviceIDsFromD3D10KHR( + object_, + d3d_device_source, + d3d_object, + d3d_device_set, + 0, + NULL, + &n); + if (err != CL_SUCCESS) { + return detail::errHandler(err, __GET_DEVICE_IDS_ERR); + } + + cl_device_id* ids = (cl_device_id*) alloca(n * sizeof(cl_device_id)); + err = pfn_clGetDeviceIDsFromD3D10KHR( + object_, + d3d_device_source, + d3d_object, + d3d_device_set, + n, + ids, + NULL); + if (err != CL_SUCCESS) { + return detail::errHandler(err, __GET_DEVICE_IDS_ERR); + } + + devices->assign(&ids[0], &ids[n]); + return CL_SUCCESS; + } +#endif + + /*! \brief Gets a list of available platforms. + * + * Wraps clGetPlatformIDs(). + */ + static cl_int get( + VECTOR_CLASS<Platform>* platforms) + { + cl_uint n = 0; + + if( platforms == NULL ) { + return detail::errHandler(CL_INVALID_ARG_VALUE, __GET_PLATFORM_IDS_ERR); + } + + cl_int err = ::clGetPlatformIDs(0, NULL, &n); + if (err != CL_SUCCESS) { + return detail::errHandler(err, __GET_PLATFORM_IDS_ERR); + } + + cl_platform_id* ids = (cl_platform_id*) alloca( + n * sizeof(cl_platform_id)); + err = ::clGetPlatformIDs(n, ids, NULL); + if (err != CL_SUCCESS) { + return detail::errHandler(err, __GET_PLATFORM_IDS_ERR); + } + + platforms->assign(&ids[0], &ids[n]); + return CL_SUCCESS; + } + + /*! \brief Gets the first available platform. + * + * Wraps clGetPlatformIDs(), returning the first result. + */ + static cl_int get( + Platform * platform) + { + cl_uint n = 0; + + if( platform == NULL ) { + return detail::errHandler(CL_INVALID_ARG_VALUE, __GET_PLATFORM_IDS_ERR); + } + + cl_int err = ::clGetPlatformIDs(0, NULL, &n); + if (err != CL_SUCCESS) { + return detail::errHandler(err, __GET_PLATFORM_IDS_ERR); + } + + cl_platform_id* ids = (cl_platform_id*) alloca( + n * sizeof(cl_platform_id)); + err = ::clGetPlatformIDs(n, ids, NULL); + if (err != CL_SUCCESS) { + return detail::errHandler(err, __GET_PLATFORM_IDS_ERR); + } + + *platform = ids[0]; + return CL_SUCCESS; + } + + /*! \brief Gets the first available platform, returning it by value. + * + * Wraps clGetPlatformIDs(), returning the first result. + */ + static Platform get( + cl_int * errResult = NULL) + { + Platform platform; + cl_uint n = 0; + cl_int err = ::clGetPlatformIDs(0, NULL, &n); + if (err != CL_SUCCESS) { + detail::errHandler(err, __GET_PLATFORM_IDS_ERR); + if (errResult != NULL) { + *errResult = err; + } + return Platform(); + } + + cl_platform_id* ids = (cl_platform_id*) alloca( + n * sizeof(cl_platform_id)); + err = ::clGetPlatformIDs(n, ids, NULL); + + if (err != CL_SUCCESS) { + detail::errHandler(err, __GET_PLATFORM_IDS_ERR); + if (errResult != NULL) { + *errResult = err; + } + return Platform(); + } + + + return Platform(ids[0]); + } + + static Platform getDefault( + cl_int *errResult = NULL ) + { + return get(errResult); + } + + +#if defined(CL_VERSION_1_2) + //! \brief Wrapper for clUnloadCompiler(). + cl_int + unloadCompiler() + { + return ::clUnloadPlatformCompiler(object_); + } +#endif // #if defined(CL_VERSION_1_2) +}; // class Platform + +/** + * Deprecated APIs for 1.2 + */ +#if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS) || (defined(CL_VERSION_1_1) && !defined(CL_VERSION_1_2)) +/** + * Unload the OpenCL compiler. + * \note Deprecated for OpenCL 1.2. Use Platform::unloadCompiler instead. + */ +inline CL_EXT_PREFIX__VERSION_1_1_DEPRECATED cl_int +UnloadCompiler() CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED; +inline cl_int +UnloadCompiler() +{ + return ::clUnloadCompiler(); +} +#endif // #if defined(CL_VERSION_1_1) + +/*! \brief Class interface for cl_context. + * + * \note Copies of these objects are shallow, meaning that the copy will refer + * to the same underlying cl_context as the original. For details, see + * clRetainContext() and clReleaseContext(). + * + * \see cl_context + */ +class Context + : public detail::Wrapper<cl_context> +{ +private: + +#ifdef CL_HPP_CPP11_ATOMICS_SUPPORTED + static std::atomic<int> default_initialized_; +#else // !CL_HPP_CPP11_ATOMICS_SUPPORTED + static volatile int default_initialized_; +#endif // !CL_HPP_CPP11_ATOMICS_SUPPORTED + static Context default_; + static volatile cl_int default_error_; +public: + /*! \brief Constructs a context including a list of specified devices. + * + * Wraps clCreateContext(). + */ + Context( + const VECTOR_CLASS<Device>& devices, + cl_context_properties* properties = NULL, + void (CL_CALLBACK * notifyFptr)( + const char *, + const void *, + ::size_t, + void *) = NULL, + void* data = NULL, + cl_int* err = NULL) + { + cl_int error; + + ::size_t numDevices = devices.size(); + cl_device_id* deviceIDs = (cl_device_id*) alloca(numDevices * sizeof(cl_device_id)); + for( ::size_t deviceIndex = 0; deviceIndex < numDevices; ++deviceIndex ) { + deviceIDs[deviceIndex] = (devices[deviceIndex])(); + } + + object_ = ::clCreateContext( + properties, (cl_uint) numDevices, + deviceIDs, + notifyFptr, data, &error); + + detail::errHandler(error, __CREATE_CONTEXT_ERR); + if (err != NULL) { + *err = error; + } + } + + Context( + const Device& device, + cl_context_properties* properties = NULL, + void (CL_CALLBACK * notifyFptr)( + const char *, + const void *, + ::size_t, + void *) = NULL, + void* data = NULL, + cl_int* err = NULL) + { + cl_int error; + + cl_device_id deviceID = device(); + + object_ = ::clCreateContext( + properties, 1, + &deviceID, + notifyFptr, data, &error); + + detail::errHandler(error, __CREATE_CONTEXT_ERR); + if (err != NULL) { + *err = error; + } + } + + /*! \brief Constructs a context including all or a subset of devices of a specified type. + * + * Wraps clCreateContextFromType(). + */ + Context( + cl_device_type type, + cl_context_properties* properties = NULL, + void (CL_CALLBACK * notifyFptr)( + const char *, + const void *, + ::size_t, + void *) = NULL, + void* data = NULL, + cl_int* err = NULL) + { + cl_int error; + +#if !defined(__APPLE__) && !defined(__MACOS) + cl_context_properties prop[4] = {CL_CONTEXT_PLATFORM, 0, 0, 0 }; + + if (properties == NULL) { + // Get a valid platform ID as we cannot send in a blank one + VECTOR_CLASS<Platform> platforms; + error = Platform::get(&platforms); + if (error != CL_SUCCESS) { + detail::errHandler(error, __CREATE_CONTEXT_FROM_TYPE_ERR); + if (err != NULL) { + *err = error; + } + return; + } + + // Check the platforms we found for a device of our specified type + cl_context_properties platform_id = 0; + for (unsigned int i = 0; i < platforms.size(); i++) { + + VECTOR_CLASS<Device> devices; + +#if defined(__CL_ENABLE_EXCEPTIONS) + try { +#endif + + error = platforms[i].getDevices(type, &devices); + +#if defined(__CL_ENABLE_EXCEPTIONS) + } catch (Error) {} + // Catch if exceptions are enabled as we don't want to exit if first platform has no devices of type + // We do error checking next anyway, and can throw there if needed +#endif + + // Only squash CL_SUCCESS and CL_DEVICE_NOT_FOUND + if (error != CL_SUCCESS && error != CL_DEVICE_NOT_FOUND) { + detail::errHandler(error, __CREATE_CONTEXT_FROM_TYPE_ERR); + if (err != NULL) { + *err = error; + } + } + + if (devices.size() > 0) { + platform_id = (cl_context_properties)platforms[i](); + break; + } + } + + if (platform_id == 0) { + detail::errHandler(CL_DEVICE_NOT_FOUND, __CREATE_CONTEXT_FROM_TYPE_ERR); + if (err != NULL) { + *err = CL_DEVICE_NOT_FOUND; + } + return; + } + + prop[1] = platform_id; + properties = &prop[0]; + } +#endif + object_ = ::clCreateContextFromType( + properties, type, notifyFptr, data, &error); + + detail::errHandler(error, __CREATE_CONTEXT_FROM_TYPE_ERR); + if (err != NULL) { + *err = error; + } + } + + /*! \brief Copy constructor to forward copy to the superclass correctly. + * Required for MSVC. + */ + Context(const Context& ctx) : detail::Wrapper<cl_type>(ctx) {} + + /*! \brief Copy assignment to forward copy to the superclass correctly. + * Required for MSVC. + */ + Context& operator = (const Context &ctx) + { + detail::Wrapper<cl_type>::operator=(ctx); + return *this; + } + +#if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED) + /*! \brief Move constructor to forward move to the superclass correctly. + * Required for MSVC. + */ + Context(Context&& ctx) CL_HPP_NOEXCEPT : detail::Wrapper<cl_type>(std::move(ctx)) {} + + /*! \brief Move assignment to forward move to the superclass correctly. + * Required for MSVC. + */ + Context& operator = (Context &&ctx) + { + detail::Wrapper<cl_type>::operator=(std::move(ctx)); + return *this; + } +#endif // #if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED) + + /*! \brief Returns a singleton context including all devices of CL_DEVICE_TYPE_DEFAULT. + * + * \note All calls to this function return the same cl_context as the first. + */ + static Context getDefault(cl_int * err = NULL) + { + int state = detail::compare_exchange( + &default_initialized_, + __DEFAULT_BEING_INITIALIZED, __DEFAULT_NOT_INITIALIZED); + + if (state & __DEFAULT_INITIALIZED) { + if (err != NULL) { + *err = default_error_; + } + return default_; + } + + if (state & __DEFAULT_BEING_INITIALIZED) { + // Assume writes will propagate eventually... + while(default_initialized_ != __DEFAULT_INITIALIZED) { + detail::fence(); + } + + if (err != NULL) { + *err = default_error_; + } + return default_; + } + + cl_int error; + default_ = Context( + CL_DEVICE_TYPE_DEFAULT, + NULL, + NULL, + NULL, + &error); + + detail::fence(); + + default_error_ = error; + // Assume writes will propagate eventually... + default_initialized_ = __DEFAULT_INITIALIZED; + + detail::fence(); + + if (err != NULL) { + *err = default_error_; + } + return default_; + + } + + //! \brief Default constructor - initializes to NULL. + Context() : detail::Wrapper<cl_type>() { } + + /*! \brief Constructor from cl_context - takes ownership. + * + * This effectively transfers ownership of a refcount on the cl_context + * into the new Context object. + */ + __CL_EXPLICIT_CONSTRUCTORS Context(const cl_context& context) : detail::Wrapper<cl_type>(context) { } + + /*! \brief Assignment operator from cl_context - takes ownership. + * + * This effectively transfers ownership of a refcount on the rhs and calls + * clReleaseContext() on the value previously held by this instance. + */ + Context& operator = (const cl_context& rhs) + { + detail::Wrapper<cl_type>::operator=(rhs); + return *this; + } + + //! \brief Wrapper for clGetContextInfo(). + template <typename T> + cl_int getInfo(cl_context_info name, T* param) const + { + return detail::errHandler( + detail::getInfo(&::clGetContextInfo, object_, name, param), + __GET_CONTEXT_INFO_ERR); + } + + //! \brief Wrapper for clGetContextInfo() that returns by value. + template <cl_int name> typename + detail::param_traits<detail::cl_context_info, name>::param_type + getInfo(cl_int* err = NULL) const + { + typename detail::param_traits< + detail::cl_context_info, name>::param_type param; + cl_int result = getInfo(name, ¶m); + if (err != NULL) { + *err = result; + } + return param; + } + + /*! \brief Gets a list of supported image formats. + * + * Wraps clGetSupportedImageFormats(). + */ + cl_int getSupportedImageFormats( + cl_mem_flags flags, + cl_mem_object_type type, + VECTOR_CLASS<ImageFormat>* formats) const + { + cl_uint numEntries; + + if (!formats) { + return CL_SUCCESS; + } + + cl_int err = ::clGetSupportedImageFormats( + object_, + flags, + type, + 0, + NULL, + &numEntries); + if (err != CL_SUCCESS) { + return detail::errHandler(err, __GET_SUPPORTED_IMAGE_FORMATS_ERR); + } + + if (numEntries > 0) { + ImageFormat* value = (ImageFormat*) + alloca(numEntries * sizeof(ImageFormat)); + err = ::clGetSupportedImageFormats( + object_, + flags, + type, + numEntries, + (cl_image_format*)value, + NULL); + if (err != CL_SUCCESS) { + return detail::errHandler(err, __GET_SUPPORTED_IMAGE_FORMATS_ERR); + } + + formats->assign(&value[0], &value[numEntries]); + } + else { + formats->clear(); + } + return CL_SUCCESS; + } +}; + +inline Device Device::getDefault(cl_int * err) +{ + cl_int error; + Device device; + + Context context = Context::getDefault(&error); + detail::errHandler(error, __CREATE_CONTEXT_ERR); + + if (error != CL_SUCCESS) { + if (err != NULL) { + *err = error; + } + } + else { + device = context.getInfo<CL_CONTEXT_DEVICES>()[0]; + if (err != NULL) { + *err = CL_SUCCESS; + } + } + + return device; +} + + +#ifdef _WIN32 +#ifdef CL_HPP_CPP11_ATOMICS_SUPPORTED +__declspec(selectany) std::atomic<int> Context::default_initialized_; +#else // !CL_HPP_CPP11_ATOMICS_SUPPORTED +__declspec(selectany) volatile int Context::default_initialized_ = __DEFAULT_NOT_INITIALIZED; +#endif // !CL_HPP_CPP11_ATOMICS_SUPPORTED +__declspec(selectany) Context Context::default_; +__declspec(selectany) volatile cl_int Context::default_error_ = CL_SUCCESS; +#else // !_WIN32 +#ifdef CL_HPP_CPP11_ATOMICS_SUPPORTED +__attribute__((weak)) std::atomic<int> Context::default_initialized_; +#else // !CL_HPP_CPP11_ATOMICS_SUPPORTED +__attribute__((weak)) volatile int Context::default_initialized_ = __DEFAULT_NOT_INITIALIZED; +#endif // !CL_HPP_CPP11_ATOMICS_SUPPORTED +__attribute__((weak)) Context Context::default_; +__attribute__((weak)) volatile cl_int Context::default_error_ = CL_SUCCESS; +#endif // !_WIN32 + +/*! \brief Class interface for cl_event. + * + * \note Copies of these objects are shallow, meaning that the copy will refer + * to the same underlying cl_event as the original. For details, see + * clRetainEvent() and clReleaseEvent(). + * + * \see cl_event + */ +class Event : public detail::Wrapper<cl_event> +{ +public: + //! \brief Default constructor - initializes to NULL. + Event() : detail::Wrapper<cl_type>() { } + + /*! \brief Constructor from cl_event - takes ownership. + * + * This effectively transfers ownership of a refcount on the cl_event + * into the new Event object. + */ + __CL_EXPLICIT_CONSTRUCTORS Event(const cl_event& event) : detail::Wrapper<cl_type>(event) { } + + /*! \brief Assignment operator from cl_event - takes ownership. + * + * This effectively transfers ownership of a refcount on the rhs and calls + * clReleaseEvent() on the value previously held by this instance. + */ + Event& operator = (const cl_event& rhs) + { + detail::Wrapper<cl_type>::operator=(rhs); + return *this; + } + + //! \brief Wrapper for clGetEventInfo(). + template <typename T> + cl_int getInfo(cl_event_info name, T* param) const + { + return detail::errHandler( + detail::getInfo(&::clGetEventInfo, object_, name, param), + __GET_EVENT_INFO_ERR); + } + + //! \brief Wrapper for clGetEventInfo() that returns by value. + template <cl_int name> typename + detail::param_traits<detail::cl_event_info, name>::param_type + getInfo(cl_int* err = NULL) const + { + typename detail::param_traits< + detail::cl_event_info, name>::param_type param; + cl_int result = getInfo(name, ¶m); + if (err != NULL) { + *err = result; + } + return param; + } + + //! \brief Wrapper for clGetEventProfilingInfo(). + template <typename T> + cl_int getProfilingInfo(cl_profiling_info name, T* param) const + { + return detail::errHandler(detail::getInfo( + &::clGetEventProfilingInfo, object_, name, param), + __GET_EVENT_PROFILE_INFO_ERR); + } + + //! \brief Wrapper for clGetEventProfilingInfo() that returns by value. + template <cl_int name> typename + detail::param_traits<detail::cl_profiling_info, name>::param_type + getProfilingInfo(cl_int* err = NULL) const + { + typename detail::param_traits< + detail::cl_profiling_info, name>::param_type param; + cl_int result = getProfilingInfo(name, ¶m); + if (err != NULL) { + *err = result; + } + return param; + } + + /*! \brief Blocks the calling thread until this event completes. + * + * Wraps clWaitForEvents(). + */ + cl_int wait() const + { + return detail::errHandler( + ::clWaitForEvents(1, &object_), + __WAIT_FOR_EVENTS_ERR); + } + +#if defined(CL_VERSION_1_1) + /*! \brief Registers a user callback function for a specific command execution status. + * + * Wraps clSetEventCallback(). + */ + cl_int setCallback( + cl_int type, + void (CL_CALLBACK * pfn_notify)(cl_event, cl_int, void *), + void * user_data = NULL) + { + return detail::errHandler( + ::clSetEventCallback( + object_, + type, + pfn_notify, + user_data), + __SET_EVENT_CALLBACK_ERR); + } +#endif + + /*! \brief Blocks the calling thread until every event specified is complete. + * + * Wraps clWaitForEvents(). + */ + static cl_int + waitForEvents(const VECTOR_CLASS<Event>& events) + { + return detail::errHandler( + ::clWaitForEvents( + (cl_uint) events.size(), (events.size() > 0) ? (cl_event*)&events.front() : NULL), + __WAIT_FOR_EVENTS_ERR); + } +}; + +#if defined(CL_VERSION_1_1) +/*! \brief Class interface for user events (a subset of cl_event's). + * + * See Event for details about copy semantics, etc. + */ +class UserEvent : public Event +{ +public: + /*! \brief Constructs a user event on a given context. + * + * Wraps clCreateUserEvent(). + */ + UserEvent( + const Context& context, + cl_int * err = NULL) + { + cl_int error; + object_ = ::clCreateUserEvent( + context(), + &error); + + detail::errHandler(error, __CREATE_USER_EVENT_ERR); + if (err != NULL) { + *err = error; + } + } + + //! \brief Default constructor - initializes to NULL. + UserEvent() : Event() { } + + /*! \brief Sets the execution status of a user event object. + * + * Wraps clSetUserEventStatus(). + */ + cl_int setStatus(cl_int status) + { + return detail::errHandler( + ::clSetUserEventStatus(object_,status), + __SET_USER_EVENT_STATUS_ERR); + } +}; +#endif + +/*! \brief Blocks the calling thread until every event specified is complete. + * + * Wraps clWaitForEvents(). + */ +inline static cl_int +WaitForEvents(const VECTOR_CLASS<Event>& events) +{ + return detail::errHandler( + ::clWaitForEvents( + (cl_uint) events.size(), (events.size() > 0) ? (cl_event*)&events.front() : NULL), + __WAIT_FOR_EVENTS_ERR); +} + +/*! \brief Class interface for cl_mem. + * + * \note Copies of these objects are shallow, meaning that the copy will refer + * to the same underlying cl_mem as the original. For details, see + * clRetainMemObject() and clReleaseMemObject(). + * + * \see cl_mem + */ +class Memory : public detail::Wrapper<cl_mem> +{ +public: + //! \brief Default constructor - initializes to NULL. + Memory() : detail::Wrapper<cl_type>() { } + + /*! \brief Constructor from cl_mem - takes ownership. + * + * This effectively transfers ownership of a refcount on the cl_mem + * into the new Memory object. + */ + __CL_EXPLICIT_CONSTRUCTORS Memory(const cl_mem& memory) : detail::Wrapper<cl_type>(memory) { } + + /*! \brief Assignment operator from cl_mem - takes ownership. + * + * This effectively transfers ownership of a refcount on the rhs and calls + * clReleaseMemObject() on the value previously held by this instance. + */ + Memory& operator = (const cl_mem& rhs) + { + detail::Wrapper<cl_type>::operator=(rhs); + return *this; + } + + /*! \brief Copy constructor to forward copy to the superclass correctly. + * Required for MSVC. + */ + Memory(const Memory& mem) : detail::Wrapper<cl_type>(mem) {} + + /*! \brief Copy assignment to forward copy to the superclass correctly. + * Required for MSVC. + */ + Memory& operator = (const Memory &mem) + { + detail::Wrapper<cl_type>::operator=(mem); + return *this; + } + +#if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED) + /*! \brief Move constructor to forward move to the superclass correctly. + * Required for MSVC. + */ + Memory(Memory&& mem) CL_HPP_NOEXCEPT : detail::Wrapper<cl_type>(std::move(mem)) {} + + /*! \brief Move assignment to forward move to the superclass correctly. + * Required for MSVC. + */ + Memory& operator = (Memory &&mem) + { + detail::Wrapper<cl_type>::operator=(std::move(mem)); + return *this; + } +#endif // #if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED) + + //! \brief Wrapper for clGetMemObjectInfo(). + template <typename T> + cl_int getInfo(cl_mem_info name, T* param) const + { + return detail::errHandler( + detail::getInfo(&::clGetMemObjectInfo, object_, name, param), + __GET_MEM_OBJECT_INFO_ERR); + } + + //! \brief Wrapper for clGetMemObjectInfo() that returns by value. + template <cl_int name> typename + detail::param_traits<detail::cl_mem_info, name>::param_type + getInfo(cl_int* err = NULL) const + { + typename detail::param_traits< + detail::cl_mem_info, name>::param_type param; + cl_int result = getInfo(name, ¶m); + if (err != NULL) { + *err = result; + } + return param; + } + +#if defined(CL_VERSION_1_1) + /*! \brief Registers a callback function to be called when the memory object + * is no longer needed. + * + * Wraps clSetMemObjectDestructorCallback(). + * + * Repeated calls to this function, for a given cl_mem value, will append + * to the list of functions called (in reverse order) when memory object's + * resources are freed and the memory object is deleted. + * + * \note + * The registered callbacks are associated with the underlying cl_mem + * value - not the Memory class instance. + */ + cl_int setDestructorCallback( + void (CL_CALLBACK * pfn_notify)(cl_mem, void *), + void * user_data = NULL) + { + return detail::errHandler( + ::clSetMemObjectDestructorCallback( + object_, + pfn_notify, + user_data), + __SET_MEM_OBJECT_DESTRUCTOR_CALLBACK_ERR); + } +#endif + +}; + +// Pre-declare copy functions +class Buffer; +template< typename IteratorType > +cl_int copy( IteratorType startIterator, IteratorType endIterator, cl::Buffer &buffer ); +template< typename IteratorType > +cl_int copy( const cl::Buffer &buffer, IteratorType startIterator, IteratorType endIterator ); +template< typename IteratorType > +cl_int copy( const CommandQueue &queue, IteratorType startIterator, IteratorType endIterator, cl::Buffer &buffer ); +template< typename IteratorType > +cl_int copy( const CommandQueue &queue, const cl::Buffer &buffer, IteratorType startIterator, IteratorType endIterator ); + + +/*! \brief Class interface for Buffer Memory Objects. + * + * See Memory for details about copy semantics, etc. + * + * \see Memory + */ +class Buffer : public Memory +{ +public: + + /*! \brief Constructs a Buffer in a specified context. + * + * Wraps clCreateBuffer(). + * + * \param host_ptr Storage to be used if the CL_MEM_USE_HOST_PTR flag was + * specified. Note alignment & exclusivity requirements. + */ + Buffer( + const Context& context, + cl_mem_flags flags, + ::size_t size, + void* host_ptr = NULL, + cl_int* err = NULL) + { + cl_int error; + object_ = ::clCreateBuffer(context(), flags, size, host_ptr, &error); + + detail::errHandler(error, __CREATE_BUFFER_ERR); + if (err != NULL) { + *err = error; + } + } + + /*! \brief Constructs a Buffer in the default context. + * + * Wraps clCreateBuffer(). + * + * \param host_ptr Storage to be used if the CL_MEM_USE_HOST_PTR flag was + * specified. Note alignment & exclusivity requirements. + * + * \see Context::getDefault() + */ + Buffer( + cl_mem_flags flags, + ::size_t size, + void* host_ptr = NULL, + cl_int* err = NULL) + { + cl_int error; + + Context context = Context::getDefault(err); + + object_ = ::clCreateBuffer(context(), flags, size, host_ptr, &error); + + detail::errHandler(error, __CREATE_BUFFER_ERR); + if (err != NULL) { + *err = error; + } + } + + /*! + * \brief Construct a Buffer from a host container via iterators. + * IteratorType must be random access. + * If useHostPtr is specified iterators must represent contiguous data. + */ + template< typename IteratorType > + Buffer( + IteratorType startIterator, + IteratorType endIterator, + bool readOnly, + bool useHostPtr = false, + cl_int* err = NULL) + { + typedef typename std::iterator_traits<IteratorType>::value_type DataType; + cl_int error; + + cl_mem_flags flags = 0; + if( readOnly ) { + flags |= CL_MEM_READ_ONLY; + } + else { + flags |= CL_MEM_READ_WRITE; + } + if( useHostPtr ) { + flags |= CL_MEM_USE_HOST_PTR; + } + + ::size_t size = sizeof(DataType)*(endIterator - startIterator); + + Context context = Context::getDefault(err); + + if( useHostPtr ) { + object_ = ::clCreateBuffer(context(), flags, size, static_cast<DataType*>(&*startIterator), &error); + } else { + object_ = ::clCreateBuffer(context(), flags, size, 0, &error); + } + + detail::errHandler(error, __CREATE_BUFFER_ERR); + if (err != NULL) { + *err = error; + } + + if( !useHostPtr ) { + error = cl::copy(startIterator, endIterator, *this); + detail::errHandler(error, __CREATE_BUFFER_ERR); + if (err != NULL) { + *err = error; + } + } + } + + /*! + * \brief Construct a Buffer from a host container via iterators using a specified context. + * IteratorType must be random access. + * If useHostPtr is specified iterators must represent contiguous data. + */ + template< typename IteratorType > + Buffer(const Context &context, IteratorType startIterator, IteratorType endIterator, + bool readOnly, bool useHostPtr = false, cl_int* err = NULL); + + /*! + * \brief Construct a Buffer from a host container via iterators using a specified queue. + * If useHostPtr is specified iterators must represent contiguous data. + */ + template< typename IteratorType > + Buffer(const CommandQueue &queue, IteratorType startIterator, IteratorType endIterator, + bool readOnly, bool useHostPtr = false, cl_int* err = NULL); + + //! \brief Default constructor - initializes to NULL. + Buffer() : Memory() { } + + /*! \brief Constructor from cl_mem - takes ownership. + * + * See Memory for further details. + */ + __CL_EXPLICIT_CONSTRUCTORS Buffer(const cl_mem& buffer) : Memory(buffer) { } + + /*! \brief Assignment from cl_mem - performs shallow copy. + * + * See Memory for further details. + */ + Buffer& operator = (const cl_mem& rhs) + { + Memory::operator=(rhs); + return *this; + } + + /*! \brief Copy constructor to forward copy to the superclass correctly. + * Required for MSVC. + */ + Buffer(const Buffer& buf) : Memory(buf) {} + + /*! \brief Copy assignment to forward copy to the superclass correctly. + * Required for MSVC. + */ + Buffer& operator = (const Buffer &buf) + { + Memory::operator=(buf); + return *this; + } + +#if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED) + /*! \brief Move constructor to forward move to the superclass correctly. + * Required for MSVC. + */ + Buffer(Buffer&& buf) CL_HPP_NOEXCEPT : Memory(std::move(buf)) {} + + /*! \brief Move assignment to forward move to the superclass correctly. + * Required for MSVC. + */ + Buffer& operator = (Buffer &&buf) + { + Memory::operator=(std::move(buf)); + return *this; + } +#endif // #if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED) + +#if defined(CL_VERSION_1_1) + /*! \brief Creates a new buffer object from this. + * + * Wraps clCreateSubBuffer(). + */ + Buffer createSubBuffer( + cl_mem_flags flags, + cl_buffer_create_type buffer_create_type, + const void * buffer_create_info, + cl_int * err = NULL) + { + Buffer result; + cl_int error; + result.object_ = ::clCreateSubBuffer( + object_, + flags, + buffer_create_type, + buffer_create_info, + &error); + + detail::errHandler(error, __CREATE_SUBBUFFER_ERR); + if (err != NULL) { + *err = error; + } + + return result; + } +#endif +}; + +#if defined (USE_DX_INTEROP) +/*! \brief Class interface for creating OpenCL buffers from ID3D10Buffer's. + * + * This is provided to facilitate interoperability with Direct3D. + * + * See Memory for details about copy semantics, etc. + * + * \see Memory + */ +class BufferD3D10 : public Buffer +{ +public: + typedef CL_API_ENTRY cl_mem (CL_API_CALL *PFN_clCreateFromD3D10BufferKHR)( + cl_context context, cl_mem_flags flags, ID3D10Buffer* buffer, + cl_int* errcode_ret); + + /*! \brief Constructs a BufferD3D10, in a specified context, from a + * given ID3D10Buffer. + * + * Wraps clCreateFromD3D10BufferKHR(). + */ + BufferD3D10( + const Context& context, + cl_mem_flags flags, + ID3D10Buffer* bufobj, + cl_int * err = NULL) + { + static PFN_clCreateFromD3D10BufferKHR pfn_clCreateFromD3D10BufferKHR = NULL; + +#if defined(CL_VERSION_1_2) + vector<cl_context_properties> props = context.getInfo<CL_CONTEXT_PROPERTIES>(); + cl_platform platform = -1; + for( int i = 0; i < props.size(); ++i ) { + if( props[i] == CL_CONTEXT_PLATFORM ) { + platform = props[i+1]; + } + } + __INIT_CL_EXT_FCN_PTR_PLATFORM(platform, clCreateFromD3D10BufferKHR); +#endif +#if defined(CL_VERSION_1_1) + __INIT_CL_EXT_FCN_PTR(clCreateFromD3D10BufferKHR); +#endif + + cl_int error; + object_ = pfn_clCreateFromD3D10BufferKHR( + context(), + flags, + bufobj, + &error); + + detail::errHandler(error, __CREATE_GL_BUFFER_ERR); + if (err != NULL) { + *err = error; + } + } + + //! \brief Default constructor - initializes to NULL. + BufferD3D10() : Buffer() { } + + /*! \brief Constructor from cl_mem - takes ownership. + * + * See Memory for further details. + */ + __CL_EXPLICIT_CONSTRUCTORS BufferD3D10(const cl_mem& buffer) : Buffer(buffer) { } + + /*! \brief Assignment from cl_mem - performs shallow copy. + * + * See Memory for further details. + */ + BufferD3D10& operator = (const cl_mem& rhs) + { + Buffer::operator=(rhs); + return *this; + } + + /*! \brief Copy constructor to forward copy to the superclass correctly. + * Required for MSVC. + */ + BufferD3D10(const BufferD3D10& buf) : Buffer(buf) {} + + /*! \brief Copy assignment to forward copy to the superclass correctly. + * Required for MSVC. + */ + BufferD3D10& operator = (const BufferD3D10 &buf) + { + Buffer::operator=(buf); + return *this; + } + +#if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED) + /*! \brief Move constructor to forward move to the superclass correctly. + * Required for MSVC. + */ + BufferD3D10(BufferD3D10&& buf) CL_HPP_NOEXCEPT : Buffer(std::move(buf)) {} + + /*! \brief Move assignment to forward move to the superclass correctly. + * Required for MSVC. + */ + BufferD3D10& operator = (BufferD3D10 &&buf) + { + Buffer::operator=(std::move(buf)); + return *this; + } +#endif // #if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED) +}; +#endif + +/*! \brief Class interface for GL Buffer Memory Objects. + * + * This is provided to facilitate interoperability with OpenGL. + * + * See Memory for details about copy semantics, etc. + * + * \see Memory + */ +class BufferGL : public Buffer +{ +public: + /*! \brief Constructs a BufferGL in a specified context, from a given + * GL buffer. + * + * Wraps clCreateFromGLBuffer(). + */ + BufferGL( + const Context& context, + cl_mem_flags flags, + cl_GLuint bufobj, + cl_int * err = NULL) + { + cl_int error; + object_ = ::clCreateFromGLBuffer( + context(), + flags, + bufobj, + &error); + + detail::errHandler(error, __CREATE_GL_BUFFER_ERR); + if (err != NULL) { + *err = error; + } + } + + //! \brief Default constructor - initializes to NULL. + BufferGL() : Buffer() { } + + /*! \brief Constructor from cl_mem - takes ownership. + * + * See Memory for further details. + */ + __CL_EXPLICIT_CONSTRUCTORS BufferGL(const cl_mem& buffer) : Buffer(buffer) { } + + /*! \brief Assignment from cl_mem - performs shallow copy. + * + * See Memory for further details. + */ + BufferGL& operator = (const cl_mem& rhs) + { + Buffer::operator=(rhs); + return *this; + } + + /*! \brief Copy constructor to forward copy to the superclass correctly. + * Required for MSVC. + */ + BufferGL(const BufferGL& buf) : Buffer(buf) {} + + /*! \brief Copy assignment to forward copy to the superclass correctly. + * Required for MSVC. + */ + BufferGL& operator = (const BufferGL &buf) + { + Buffer::operator=(buf); + return *this; + } + +#if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED) + /*! \brief Move constructor to forward move to the superclass correctly. + * Required for MSVC. + */ + BufferGL(BufferGL&& buf) CL_HPP_NOEXCEPT : Buffer(std::move(buf)) {} + + /*! \brief Move assignment to forward move to the superclass correctly. + * Required for MSVC. + */ + BufferGL& operator = (BufferGL &&buf) + { + Buffer::operator=(std::move(buf)); + return *this; + } +#endif // #if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED) + + //! \brief Wrapper for clGetGLObjectInfo(). + cl_int getObjectInfo( + cl_gl_object_type *type, + cl_GLuint * gl_object_name) + { + return detail::errHandler( + ::clGetGLObjectInfo(object_,type,gl_object_name), + __GET_GL_OBJECT_INFO_ERR); + } +}; + +/*! \brief C++ base class for Image Memory objects. + * + * See Memory for details about copy semantics, etc. + * + * \see Memory + */ +class Image : public Memory +{ +protected: + //! \brief Default constructor - initializes to NULL. + Image() : Memory() { } + + /*! \brief Constructor from cl_mem - takes ownership. + * + * See Memory for further details. + */ + __CL_EXPLICIT_CONSTRUCTORS Image(const cl_mem& image) : Memory(image) { } + + /*! \brief Assignment from cl_mem - performs shallow copy. + * + * See Memory for further details. + */ + Image& operator = (const cl_mem& rhs) + { + Memory::operator=(rhs); + return *this; + } + + /*! \brief Copy constructor to forward copy to the superclass correctly. + * Required for MSVC. + */ + Image(const Image& img) : Memory(img) {} + + /*! \brief Copy assignment to forward copy to the superclass correctly. + * Required for MSVC. + */ + Image& operator = (const Image &img) + { + Memory::operator=(img); + return *this; + } + +#if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED) + /*! \brief Move constructor to forward move to the superclass correctly. + * Required for MSVC. + */ + Image(Image&& img) CL_HPP_NOEXCEPT : Memory(std::move(img)) {} + + /*! \brief Move assignment to forward move to the superclass correctly. + * Required for MSVC. + */ + Image& operator = (Image &&img) + { + Memory::operator=(std::move(img)); + return *this; + } +#endif // #if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED) + +public: + //! \brief Wrapper for clGetImageInfo(). + template <typename T> + cl_int getImageInfo(cl_image_info name, T* param) const + { + return detail::errHandler( + detail::getInfo(&::clGetImageInfo, object_, name, param), + __GET_IMAGE_INFO_ERR); + } + + //! \brief Wrapper for clGetImageInfo() that returns by value. + template <cl_int name> typename + detail::param_traits<detail::cl_image_info, name>::param_type + getImageInfo(cl_int* err = NULL) const + { + typename detail::param_traits< + detail::cl_image_info, name>::param_type param; + cl_int result = getImageInfo(name, ¶m); + if (err != NULL) { + *err = result; + } + return param; + } +}; + +#if defined(CL_VERSION_1_2) +/*! \brief Class interface for 1D Image Memory objects. + * + * See Memory for details about copy semantics, etc. + * + * \see Memory + */ +class Image1D : public Image +{ +public: + /*! \brief Constructs a 1D Image in a specified context. + * + * Wraps clCreateImage(). + */ + Image1D( + const Context& context, + cl_mem_flags flags, + ImageFormat format, + ::size_t width, + void* host_ptr = NULL, + cl_int* err = NULL) + { + cl_int error; + cl_image_desc desc = + { + CL_MEM_OBJECT_IMAGE1D, + width, + 0, 0, 0, 0, 0, 0, 0, 0 + }; + object_ = ::clCreateImage( + context(), + flags, + &format, + &desc, + host_ptr, + &error); + + detail::errHandler(error, __CREATE_IMAGE_ERR); + if (err != NULL) { + *err = error; + } + } + + //! \brief Default constructor - initializes to NULL. + Image1D() { } + + /*! \brief Constructor from cl_mem - takes ownership. + * + * See Memory for further details. + */ + __CL_EXPLICIT_CONSTRUCTORS Image1D(const cl_mem& image1D) : Image(image1D) { } + + /*! \brief Assignment from cl_mem - performs shallow copy. + * + * See Memory for further details. + */ + Image1D& operator = (const cl_mem& rhs) + { + Image::operator=(rhs); + return *this; + } + + /*! \brief Copy constructor to forward copy to the superclass correctly. + * Required for MSVC. + */ + Image1D(const Image1D& img) : Image(img) {} + + /*! \brief Copy assignment to forward copy to the superclass correctly. + * Required for MSVC. + */ + Image1D& operator = (const Image1D &img) + { + Image::operator=(img); + return *this; + } + +#if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED) + /*! \brief Move constructor to forward move to the superclass correctly. + * Required for MSVC. + */ + Image1D(Image1D&& img) CL_HPP_NOEXCEPT : Image(std::move(img)) {} + + /*! \brief Move assignment to forward move to the superclass correctly. + * Required for MSVC. + */ + Image1D& operator = (Image1D &&img) + { + Image::operator=(std::move(img)); + return *this; + } +#endif // #if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED) +}; + +/*! \class Image1DBuffer + * \brief Image interface for 1D buffer images. + */ +class Image1DBuffer : public Image +{ +public: + Image1DBuffer( + const Context& context, + cl_mem_flags flags, + ImageFormat format, + ::size_t width, + const Buffer &buffer, + cl_int* err = NULL) + { + cl_int error; + cl_image_desc desc = + { + CL_MEM_OBJECT_IMAGE1D_BUFFER, + width, + 0, 0, 0, 0, 0, 0, 0, + buffer() + }; + object_ = ::clCreateImage( + context(), + flags, + &format, + &desc, + NULL, + &error); + + detail::errHandler(error, __CREATE_IMAGE_ERR); + if (err != NULL) { + *err = error; + } + } + + Image1DBuffer() { } + + __CL_EXPLICIT_CONSTRUCTORS Image1DBuffer(const cl_mem& image1D) : Image(image1D) { } + + Image1DBuffer& operator = (const cl_mem& rhs) + { + Image::operator=(rhs); + return *this; + } + + /*! \brief Copy constructor to forward copy to the superclass correctly. + * Required for MSVC. + */ + Image1DBuffer(const Image1DBuffer& img) : Image(img) {} + + /*! \brief Copy assignment to forward copy to the superclass correctly. + * Required for MSVC. + */ + Image1DBuffer& operator = (const Image1DBuffer &img) + { + Image::operator=(img); + return *this; + } + +#if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED) + /*! \brief Move constructor to forward move to the superclass correctly. + * Required for MSVC. + */ + Image1DBuffer(Image1DBuffer&& img) CL_HPP_NOEXCEPT : Image(std::move(img)) {} + + /*! \brief Move assignment to forward move to the superclass correctly. + * Required for MSVC. + */ + Image1DBuffer& operator = (Image1DBuffer &&img) + { + Image::operator=(std::move(img)); + return *this; + } +#endif // #if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED) +}; + +/*! \class Image1DArray + * \brief Image interface for arrays of 1D images. + */ +class Image1DArray : public Image +{ +public: + Image1DArray( + const Context& context, + cl_mem_flags flags, + ImageFormat format, + ::size_t arraySize, + ::size_t width, + ::size_t rowPitch, + void* host_ptr = NULL, + cl_int* err = NULL) + { + cl_int error; + cl_image_desc desc = + { + CL_MEM_OBJECT_IMAGE1D_ARRAY, + width, + 0, 0, // height, depth (unused) + arraySize, + rowPitch, + 0, 0, 0, 0 + }; + object_ = ::clCreateImage( + context(), + flags, + &format, + &desc, + host_ptr, + &error); + + detail::errHandler(error, __CREATE_IMAGE_ERR); + if (err != NULL) { + *err = error; + } + } + + Image1DArray() { } + + __CL_EXPLICIT_CONSTRUCTORS Image1DArray(const cl_mem& imageArray) : Image(imageArray) { } + + Image1DArray& operator = (const cl_mem& rhs) + { + Image::operator=(rhs); + return *this; + } + + /*! \brief Copy constructor to forward copy to the superclass correctly. + * Required for MSVC. + */ + Image1DArray(const Image1DArray& img) : Image(img) {} + + /*! \brief Copy assignment to forward copy to the superclass correctly. + * Required for MSVC. + */ + Image1DArray& operator = (const Image1DArray &img) + { + Image::operator=(img); + return *this; + } + +#if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED) + /*! \brief Move constructor to forward move to the superclass correctly. + * Required for MSVC. + */ + Image1DArray(Image1DArray&& img) CL_HPP_NOEXCEPT : Image(std::move(img)) {} + + /*! \brief Move assignment to forward move to the superclass correctly. + * Required for MSVC. + */ + Image1DArray& operator = (Image1DArray &&img) + { + Image::operator=(std::move(img)); + return *this; + } +#endif // #if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED) +}; +#endif // #if defined(CL_VERSION_1_2) + + +/*! \brief Class interface for 2D Image Memory objects. + * + * See Memory for details about copy semantics, etc. + * + * \see Memory + */ +class Image2D : public Image +{ +public: + /*! \brief Constructs a 1D Image in a specified context. + * + * Wraps clCreateImage(). + */ + Image2D( + const Context& context, + cl_mem_flags flags, + ImageFormat format, + ::size_t width, + ::size_t height, + ::size_t row_pitch = 0, + void* host_ptr = NULL, + cl_int* err = NULL) + { + cl_int error; + bool useCreateImage; + +#if defined(CL_VERSION_1_2) && defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS) + // Run-time decision based on the actual platform + { + cl_uint version = detail::getContextPlatformVersion(context()); + useCreateImage = (version >= 0x10002); // OpenCL 1.2 or above + } +#elif defined(CL_VERSION_1_2) + useCreateImage = true; +#else + useCreateImage = false; +#endif + +#if defined(CL_VERSION_1_2) + if (useCreateImage) + { + cl_image_desc desc = + { + CL_MEM_OBJECT_IMAGE2D, + width, + height, + 0, 0, // depth, array size (unused) + row_pitch, + 0, 0, 0, 0 + }; + object_ = ::clCreateImage( + context(), + flags, + &format, + &desc, + host_ptr, + &error); + + detail::errHandler(error, __CREATE_IMAGE_ERR); + if (err != NULL) { + *err = error; + } + } +#endif // #if defined(CL_VERSION_1_2) +#if !defined(CL_VERSION_1_2) || defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS) + if (!useCreateImage) + { + object_ = ::clCreateImage2D( + context(), flags,&format, width, height, row_pitch, host_ptr, &error); + + detail::errHandler(error, __CREATE_IMAGE2D_ERR); + if (err != NULL) { + *err = error; + } + } +#endif // #if !defined(CL_VERSION_1_2) || defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS) + } + + //! \brief Default constructor - initializes to NULL. + Image2D() { } + + /*! \brief Constructor from cl_mem - takes ownership. + * + * See Memory for further details. + */ + __CL_EXPLICIT_CONSTRUCTORS Image2D(const cl_mem& image2D) : Image(image2D) { } + + /*! \brief Assignment from cl_mem - performs shallow copy. + * + * See Memory for further details. + */ + Image2D& operator = (const cl_mem& rhs) + { + Image::operator=(rhs); + return *this; + } + + /*! \brief Copy constructor to forward copy to the superclass correctly. + * Required for MSVC. + */ + Image2D(const Image2D& img) : Image(img) {} + + /*! \brief Copy assignment to forward copy to the superclass correctly. + * Required for MSVC. + */ + Image2D& operator = (const Image2D &img) + { + Image::operator=(img); + return *this; + } + +#if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED) + /*! \brief Move constructor to forward move to the superclass correctly. + * Required for MSVC. + */ + Image2D(Image2D&& img) CL_HPP_NOEXCEPT : Image(std::move(img)) {} + + /*! \brief Move assignment to forward move to the superclass correctly. + * Required for MSVC. + */ + Image2D& operator = (Image2D &&img) + { + Image::operator=(std::move(img)); + return *this; + } +#endif // #if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED) +}; + + +#if !defined(CL_VERSION_1_2) +/*! \brief Class interface for GL 2D Image Memory objects. + * + * This is provided to facilitate interoperability with OpenGL. + * + * See Memory for details about copy semantics, etc. + * + * \see Memory + * \note Deprecated for OpenCL 1.2. Please use ImageGL instead. + */ +class CL_EXT_PREFIX__VERSION_1_1_DEPRECATED Image2DGL CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED : public Image2D +{ +public: + /*! \brief Constructs an Image2DGL in a specified context, from a given + * GL Texture. + * + * Wraps clCreateFromGLTexture2D(). + */ + Image2DGL( + const Context& context, + cl_mem_flags flags, + cl_GLenum target, + cl_GLint miplevel, + cl_GLuint texobj, + cl_int * err = NULL) + { + cl_int error; + object_ = ::clCreateFromGLTexture2D( + context(), + flags, + target, + miplevel, + texobj, + &error); + + detail::errHandler(error, __CREATE_GL_TEXTURE_2D_ERR); + if (err != NULL) { + *err = error; + } + + } + + //! \brief Default constructor - initializes to NULL. + Image2DGL() : Image2D() { } + + /*! \brief Constructor from cl_mem - takes ownership. + * + * See Memory for further details. + */ + __CL_EXPLICIT_CONSTRUCTORS Image2DGL(const cl_mem& image) : Image2D(image) { } + + /*! \brief Assignment from cl_mem - performs shallow copy. + * + * See Memory for further details. + */ + Image2DGL& operator = (const cl_mem& rhs) + { + Image2D::operator=(rhs); + return *this; + } + + /*! \brief Copy constructor to forward copy to the superclass correctly. + * Required for MSVC. + */ + Image2DGL(const Image2DGL& img) : Image2D(img) {} + + /*! \brief Copy assignment to forward copy to the superclass correctly. + * Required for MSVC. + */ + Image2DGL& operator = (const Image2DGL &img) + { + Image2D::operator=(img); + return *this; + } + +#if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED) + /*! \brief Move constructor to forward move to the superclass correctly. + * Required for MSVC. + */ + Image2DGL(Image2DGL&& img) CL_HPP_NOEXCEPT : Image2D(std::move(img)) {} + + /*! \brief Move assignment to forward move to the superclass correctly. + * Required for MSVC. + */ + Image2DGL& operator = (Image2DGL &&img) + { + Image2D::operator=(std::move(img)); + return *this; + } +#endif // #if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED) +}; +#endif // #if !defined(CL_VERSION_1_2) + +#if defined(CL_VERSION_1_2) +/*! \class Image2DArray + * \brief Image interface for arrays of 2D images. + */ +class Image2DArray : public Image +{ +public: + Image2DArray( + const Context& context, + cl_mem_flags flags, + ImageFormat format, + ::size_t arraySize, + ::size_t width, + ::size_t height, + ::size_t rowPitch, + ::size_t slicePitch, + void* host_ptr = NULL, + cl_int* err = NULL) + { + cl_int error; + cl_image_desc desc = + { + CL_MEM_OBJECT_IMAGE2D_ARRAY, + width, + height, + 0, // depth (unused) + arraySize, + rowPitch, + slicePitch, + 0, 0, 0 + }; + object_ = ::clCreateImage( + context(), + flags, + &format, + &desc, + host_ptr, + &error); + + detail::errHandler(error, __CREATE_IMAGE_ERR); + if (err != NULL) { + *err = error; + } + } + + Image2DArray() { } + + __CL_EXPLICIT_CONSTRUCTORS Image2DArray(const cl_mem& imageArray) : Image(imageArray) { } + + Image2DArray& operator = (const cl_mem& rhs) + { + Image::operator=(rhs); + return *this; + } + + /*! \brief Copy constructor to forward copy to the superclass correctly. + * Required for MSVC. + */ + Image2DArray(const Image2DArray& img) : Image(img) {} + + /*! \brief Copy assignment to forward copy to the superclass correctly. + * Required for MSVC. + */ + Image2DArray& operator = (const Image2DArray &img) + { + Image::operator=(img); + return *this; + } + +#if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED) + /*! \brief Move constructor to forward move to the superclass correctly. + * Required for MSVC. + */ + Image2DArray(Image2DArray&& img) CL_HPP_NOEXCEPT : Image(std::move(img)) {} + + /*! \brief Move assignment to forward move to the superclass correctly. + * Required for MSVC. + */ + Image2DArray& operator = (Image2DArray &&img) + { + Image::operator=(std::move(img)); + return *this; + } +#endif // #if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED) +}; +#endif // #if defined(CL_VERSION_1_2) + +/*! \brief Class interface for 3D Image Memory objects. + * + * See Memory for details about copy semantics, etc. + * + * \see Memory + */ +class Image3D : public Image +{ +public: + /*! \brief Constructs a 3D Image in a specified context. + * + * Wraps clCreateImage(). + */ + Image3D( + const Context& context, + cl_mem_flags flags, + ImageFormat format, + ::size_t width, + ::size_t height, + ::size_t depth, + ::size_t row_pitch = 0, + ::size_t slice_pitch = 0, + void* host_ptr = NULL, + cl_int* err = NULL) + { + cl_int error; + bool useCreateImage; + +#if defined(CL_VERSION_1_2) && defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS) + // Run-time decision based on the actual platform + { + cl_uint version = detail::getContextPlatformVersion(context()); + useCreateImage = (version >= 0x10002); // OpenCL 1.2 or above + } +#elif defined(CL_VERSION_1_2) + useCreateImage = true; +#else + useCreateImage = false; +#endif + +#if defined(CL_VERSION_1_2) + if (useCreateImage) + { + cl_image_desc desc = + { + CL_MEM_OBJECT_IMAGE3D, + width, + height, + depth, + 0, // array size (unused) + row_pitch, + slice_pitch, + 0, 0, 0 + }; + object_ = ::clCreateImage( + context(), + flags, + &format, + &desc, + host_ptr, + &error); + + detail::errHandler(error, __CREATE_IMAGE_ERR); + if (err != NULL) { + *err = error; + } + } +#endif // #if defined(CL_VERSION_1_2) +#if !defined(CL_VERSION_1_2) || defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS) + if (!useCreateImage) + { + object_ = ::clCreateImage3D( + context(), flags, &format, width, height, depth, row_pitch, + slice_pitch, host_ptr, &error); + + detail::errHandler(error, __CREATE_IMAGE3D_ERR); + if (err != NULL) { + *err = error; + } + } +#endif // #if !defined(CL_VERSION_1_2) || defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS) + } + + //! \brief Default constructor - initializes to NULL. + Image3D() : Image() { } + + /*! \brief Constructor from cl_mem - takes ownership. + * + * See Memory for further details. + */ + __CL_EXPLICIT_CONSTRUCTORS Image3D(const cl_mem& image3D) : Image(image3D) { } + + /*! \brief Assignment from cl_mem - performs shallow copy. + * + * See Memory for further details. + */ + Image3D& operator = (const cl_mem& rhs) + { + Image::operator=(rhs); + return *this; + } + + /*! \brief Copy constructor to forward copy to the superclass correctly. + * Required for MSVC. + */ + Image3D(const Image3D& img) : Image(img) {} + + /*! \brief Copy assignment to forward copy to the superclass correctly. + * Required for MSVC. + */ + Image3D& operator = (const Image3D &img) + { + Image::operator=(img); + return *this; + } + +#if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED) + /*! \brief Move constructor to forward move to the superclass correctly. + * Required for MSVC. + */ + Image3D(Image3D&& img) CL_HPP_NOEXCEPT : Image(std::move(img)) {} + + /*! \brief Move assignment to forward move to the superclass correctly. + * Required for MSVC. + */ + Image3D& operator = (Image3D &&img) + { + Image::operator=(std::move(img)); + return *this; + } +#endif // #if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED) +}; + +#if !defined(CL_VERSION_1_2) +/*! \brief Class interface for GL 3D Image Memory objects. + * + * This is provided to facilitate interoperability with OpenGL. + * + * See Memory for details about copy semantics, etc. + * + * \see Memory + */ +class Image3DGL : public Image3D +{ +public: + /*! \brief Constructs an Image3DGL in a specified context, from a given + * GL Texture. + * + * Wraps clCreateFromGLTexture3D(). + */ + Image3DGL( + const Context& context, + cl_mem_flags flags, + cl_GLenum target, + cl_GLint miplevel, + cl_GLuint texobj, + cl_int * err = NULL) + { + cl_int error; + object_ = ::clCreateFromGLTexture3D( + context(), + flags, + target, + miplevel, + texobj, + &error); + + detail::errHandler(error, __CREATE_GL_TEXTURE_3D_ERR); + if (err != NULL) { + *err = error; + } + } + + //! \brief Default constructor - initializes to NULL. + Image3DGL() : Image3D() { } + + /*! \brief Constructor from cl_mem - takes ownership. + * + * See Memory for further details. + */ + __CL_EXPLICIT_CONSTRUCTORS Image3DGL(const cl_mem& image) : Image3D(image) { } + + /*! \brief Assignment from cl_mem - performs shallow copy. + * + * See Memory for further details. + */ + Image3DGL& operator = (const cl_mem& rhs) + { + Image3D::operator=(rhs); + return *this; + } + + /*! \brief Copy constructor to forward copy to the superclass correctly. + * Required for MSVC. + */ + Image3DGL(const Image3DGL& img) : Image3D(img) {} + + /*! \brief Copy assignment to forward copy to the superclass correctly. + * Required for MSVC. + */ + Image3DGL& operator = (const Image3DGL &img) + { + Image3D::operator=(img); + return *this; + } + +#if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED) + /*! \brief Move constructor to forward move to the superclass correctly. + * Required for MSVC. + */ + Image3DGL(Image3DGL&& img) CL_HPP_NOEXCEPT : Image3D(std::move(img)) {} + + /*! \brief Move assignment to forward move to the superclass correctly. + * Required for MSVC. + */ + Image3DGL& operator = (Image3DGL &&img) + { + Image3D::operator=(std::move(img)); + return *this; + } +#endif // #if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED) +}; +#endif // #if !defined(CL_VERSION_1_2) + +#if defined(CL_VERSION_1_2) +/*! \class ImageGL + * \brief general image interface for GL interop. + * We abstract the 2D and 3D GL images into a single instance here + * that wraps all GL sourced images on the grounds that setup information + * was performed by OpenCL anyway. + */ +class ImageGL : public Image +{ +public: + ImageGL( + const Context& context, + cl_mem_flags flags, + cl_GLenum target, + cl_GLint miplevel, + cl_GLuint texobj, + cl_int * err = NULL) + { + cl_int error; + object_ = ::clCreateFromGLTexture( + context(), + flags, + target, + miplevel, + texobj, + &error); + + detail::errHandler(error, __CREATE_GL_TEXTURE_ERR); + if (err != NULL) { + *err = error; + } + } + + ImageGL() : Image() { } + + __CL_EXPLICIT_CONSTRUCTORS ImageGL(const cl_mem& image) : Image(image) { } + + ImageGL& operator = (const cl_mem& rhs) + { + Image::operator=(rhs); + return *this; + } + + /*! \brief Copy constructor to forward copy to the superclass correctly. + * Required for MSVC. + */ + ImageGL(const ImageGL& img) : Image(img) {} + + /*! \brief Copy assignment to forward copy to the superclass correctly. + * Required for MSVC. + */ + ImageGL& operator = (const ImageGL &img) + { + Image::operator=(img); + return *this; + } + +#if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED) + /*! \brief Move constructor to forward move to the superclass correctly. + * Required for MSVC. + */ + ImageGL(ImageGL&& img) CL_HPP_NOEXCEPT : Image(std::move(img)) {} + + /*! \brief Move assignment to forward move to the superclass correctly. + * Required for MSVC. + */ + ImageGL& operator = (ImageGL &&img) + { + Image::operator=(std::move(img)); + return *this; + } +#endif // #if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED) +}; +#endif // #if defined(CL_VERSION_1_2) + +/*! \brief Class interface for GL Render Buffer Memory Objects. +* +* This is provided to facilitate interoperability with OpenGL. +* +* See Memory for details about copy semantics, etc. +* +* \see Memory +*/ +class BufferRenderGL : +#if defined(CL_VERSION_1_2) + public ImageGL +#else // #if defined(CL_VERSION_1_2) + public Image2DGL +#endif //#if defined(CL_VERSION_1_2) +{ +public: + /*! \brief Constructs a BufferRenderGL in a specified context, from a given + * GL Renderbuffer. + * + * Wraps clCreateFromGLRenderbuffer(). + */ + BufferRenderGL( + const Context& context, + cl_mem_flags flags, + cl_GLuint bufobj, + cl_int * err = NULL) + { + cl_int error; + object_ = ::clCreateFromGLRenderbuffer( + context(), + flags, + bufobj, + &error); + + detail::errHandler(error, __CREATE_GL_RENDER_BUFFER_ERR); + if (err != NULL) { + *err = error; + } + } + + //! \brief Default constructor - initializes to NULL. +#if defined(CL_VERSION_1_2) + BufferRenderGL() : ImageGL() {}; +#else // #if defined(CL_VERSION_1_2) + BufferRenderGL() : Image2DGL() {}; +#endif //#if defined(CL_VERSION_1_2) + + /*! \brief Constructor from cl_mem - takes ownership. + * + * See Memory for further details. + */ +#if defined(CL_VERSION_1_2) + __CL_EXPLICIT_CONSTRUCTORS BufferRenderGL(const cl_mem& buffer) : ImageGL(buffer) { } +#else // #if defined(CL_VERSION_1_2) + __CL_EXPLICIT_CONSTRUCTORS BufferRenderGL(const cl_mem& buffer) : Image2DGL(buffer) { } +#endif //#if defined(CL_VERSION_1_2) + + + /*! \brief Assignment from cl_mem - performs shallow copy. + * + * See Memory for further details. + */ + BufferRenderGL& operator = (const cl_mem& rhs) + { +#if defined(CL_VERSION_1_2) + ImageGL::operator=(rhs); +#else // #if defined(CL_VERSION_1_2) + Image2DGL::operator=(rhs); +#endif //#if defined(CL_VERSION_1_2) + + return *this; + } + + /*! \brief Copy constructor to forward copy to the superclass correctly. + * Required for MSVC. + */ +#if defined(CL_VERSION_1_2) + BufferRenderGL(const BufferRenderGL& buf) : ImageGL(buf) {} +#else // #if defined(CL_VERSION_1_2) + BufferRenderGL(const BufferRenderGL& buf) : Image2DGL(buf) {} +#endif //#if defined(CL_VERSION_1_2) + + /*! \brief Copy assignment to forward copy to the superclass correctly. + * Required for MSVC. + */ + BufferRenderGL& operator = (const BufferRenderGL &rhs) + { +#if defined(CL_VERSION_1_2) + ImageGL::operator=(rhs); +#else // #if defined(CL_VERSION_1_2) + Image2DGL::operator=(rhs); +#endif //#if defined(CL_VERSION_1_2) + return *this; + } + +#if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED) + /*! \brief Move constructor to forward move to the superclass correctly. + * Required for MSVC. + */ +#if defined(CL_VERSION_1_2) + BufferRenderGL(BufferRenderGL&& buf) CL_HPP_NOEXCEPT : ImageGL(std::move(buf)) {} +#else // #if defined(CL_VERSION_1_2) + BufferRenderGL(BufferRenderGL&& buf) CL_HPP_NOEXCEPT : Image2DGL(std::move(buf)) {} +#endif //#if defined(CL_VERSION_1_2) + + + /*! \brief Move assignment to forward move to the superclass correctly. + * Required for MSVC. + */ + BufferRenderGL& operator = (BufferRenderGL &&buf) + { +#if defined(CL_VERSION_1_2) + ImageGL::operator=(std::move(buf)); +#else // #if defined(CL_VERSION_1_2) + Image2DGL::operator=(std::move(buf)); +#endif //#if defined(CL_VERSION_1_2) + + return *this; + } +#endif // #if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED) + + //! \brief Wrapper for clGetGLObjectInfo(). + cl_int getObjectInfo( + cl_gl_object_type *type, + cl_GLuint * gl_object_name) + { + return detail::errHandler( + ::clGetGLObjectInfo(object_, type, gl_object_name), + __GET_GL_OBJECT_INFO_ERR); + } +}; + +/*! \brief Class interface for cl_sampler. + * + * \note Copies of these objects are shallow, meaning that the copy will refer + * to the same underlying cl_sampler as the original. For details, see + * clRetainSampler() and clReleaseSampler(). + * + * \see cl_sampler + */ +class Sampler : public detail::Wrapper<cl_sampler> +{ +public: + //! \brief Default constructor - initializes to NULL. + Sampler() { } + + /*! \brief Constructs a Sampler in a specified context. + * + * Wraps clCreateSampler(). + */ + Sampler( + const Context& context, + cl_bool normalized_coords, + cl_addressing_mode addressing_mode, + cl_filter_mode filter_mode, + cl_int* err = NULL) + { + cl_int error; + object_ = ::clCreateSampler( + context(), + normalized_coords, + addressing_mode, + filter_mode, + &error); + + detail::errHandler(error, __CREATE_SAMPLER_ERR); + if (err != NULL) { + *err = error; + } + } + + /*! \brief Constructor from cl_sampler - takes ownership. + * + * This effectively transfers ownership of a refcount on the cl_sampler + * into the new Sampler object. + */ + __CL_EXPLICIT_CONSTRUCTORS Sampler(const cl_sampler& sampler) : detail::Wrapper<cl_type>(sampler) { } + + /*! \brief Assignment operator from cl_sampler - takes ownership. + * + * This effectively transfers ownership of a refcount on the rhs and calls + * clReleaseSampler() on the value previously held by this instance. + */ + Sampler& operator = (const cl_sampler& rhs) + { + detail::Wrapper<cl_type>::operator=(rhs); + return *this; + } + + /*! \brief Copy constructor to forward copy to the superclass correctly. + * Required for MSVC. + */ + Sampler(const Sampler& sam) : detail::Wrapper<cl_type>(sam) {} + + /*! \brief Copy assignment to forward copy to the superclass correctly. + * Required for MSVC. + */ + Sampler& operator = (const Sampler &sam) + { + detail::Wrapper<cl_type>::operator=(sam); + return *this; + } + +#if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED) + /*! \brief Move constructor to forward move to the superclass correctly. + * Required for MSVC. + */ + Sampler(Sampler&& sam) CL_HPP_NOEXCEPT : detail::Wrapper<cl_type>(std::move(sam)) {} + + /*! \brief Move assignment to forward move to the superclass correctly. + * Required for MSVC. + */ + Sampler& operator = (Sampler &&sam) + { + detail::Wrapper<cl_type>::operator=(std::move(sam)); + return *this; + } +#endif // #if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED) + + //! \brief Wrapper for clGetSamplerInfo(). + template <typename T> + cl_int getInfo(cl_sampler_info name, T* param) const + { + return detail::errHandler( + detail::getInfo(&::clGetSamplerInfo, object_, name, param), + __GET_SAMPLER_INFO_ERR); + } + + //! \brief Wrapper for clGetSamplerInfo() that returns by value. + template <cl_int name> typename + detail::param_traits<detail::cl_sampler_info, name>::param_type + getInfo(cl_int* err = NULL) const + { + typename detail::param_traits< + detail::cl_sampler_info, name>::param_type param; + cl_int result = getInfo(name, ¶m); + if (err != NULL) { + *err = result; + } + return param; + } +}; + +class Program; +class CommandQueue; +class Kernel; + +//! \brief Class interface for specifying NDRange values. +class NDRange +{ +private: + size_t<3> sizes_; + cl_uint dimensions_; + +public: + //! \brief Default constructor - resulting range has zero dimensions. + NDRange() + : dimensions_(0) + { } + + //! \brief Constructs one-dimensional range. + NDRange(::size_t size0) + : dimensions_(1) + { + sizes_[0] = size0; + } + + //! \brief Constructs two-dimensional range. + NDRange(::size_t size0, ::size_t size1) + : dimensions_(2) + { + sizes_[0] = size0; + sizes_[1] = size1; + } + + //! \brief Constructs three-dimensional range. + NDRange(::size_t size0, ::size_t size1, ::size_t size2) + : dimensions_(3) + { + sizes_[0] = size0; + sizes_[1] = size1; + sizes_[2] = size2; + } + + /*! \brief Conversion operator to const ::size_t *. + * + * \returns a pointer to the size of the first dimension. + */ + operator const ::size_t*() const { + return (const ::size_t*) sizes_; + } + + //! \brief Queries the number of dimensions in the range. + ::size_t dimensions() const { return dimensions_; } +}; + +//! \brief A zero-dimensional range. +static const NDRange NullRange; + +//! \brief Local address wrapper for use with Kernel::setArg +struct LocalSpaceArg +{ + ::size_t size_; +}; + +namespace detail { + +template <typename T> +struct KernelArgumentHandler +{ + static ::size_t size(const T&) { return sizeof(T); } + static const T* ptr(const T& value) { return &value; } +}; + +template <> +struct KernelArgumentHandler<LocalSpaceArg> +{ + static ::size_t size(const LocalSpaceArg& value) { return value.size_; } + static const void* ptr(const LocalSpaceArg&) { return NULL; } +}; + +} +//! \endcond + +/*! __local + * \brief Helper function for generating LocalSpaceArg objects. + * Deprecated. Replaced with Local. + */ +inline CL_EXT_PREFIX__VERSION_1_1_DEPRECATED LocalSpaceArg +__local(::size_t size) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED; +inline LocalSpaceArg +__local(::size_t size) +{ + LocalSpaceArg ret = { size }; + return ret; +} + +/*! Local + * \brief Helper function for generating LocalSpaceArg objects. + */ +inline LocalSpaceArg +Local(::size_t size) +{ + LocalSpaceArg ret = { size }; + return ret; +} + +//class KernelFunctor; + +/*! \brief Class interface for cl_kernel. + * + * \note Copies of these objects are shallow, meaning that the copy will refer + * to the same underlying cl_kernel as the original. For details, see + * clRetainKernel() and clReleaseKernel(). + * + * \see cl_kernel + */ +class Kernel : public detail::Wrapper<cl_kernel> +{ +public: + inline Kernel(const Program& program, const char* name, cl_int* err = NULL); + + //! \brief Default constructor - initializes to NULL. + Kernel() { } + + /*! \brief Constructor from cl_kernel - takes ownership. + * + * This effectively transfers ownership of a refcount on the cl_kernel + * into the new Kernel object. + */ + __CL_EXPLICIT_CONSTRUCTORS Kernel(const cl_kernel& kernel) : detail::Wrapper<cl_type>(kernel) { } + + /*! \brief Assignment operator from cl_kernel - takes ownership. + * + * This effectively transfers ownership of a refcount on the rhs and calls + * clReleaseKernel() on the value previously held by this instance. + */ + Kernel& operator = (const cl_kernel& rhs) + { + detail::Wrapper<cl_type>::operator=(rhs); + return *this; + } + + /*! \brief Copy constructor to forward copy to the superclass correctly. + * Required for MSVC. + */ + Kernel(const Kernel& kernel) : detail::Wrapper<cl_type>(kernel) {} + + /*! \brief Copy assignment to forward copy to the superclass correctly. + * Required for MSVC. + */ + Kernel& operator = (const Kernel &kernel) + { + detail::Wrapper<cl_type>::operator=(kernel); + return *this; + } + +#if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED) + /*! \brief Move constructor to forward move to the superclass correctly. + * Required for MSVC. + */ + Kernel(Kernel&& kernel) CL_HPP_NOEXCEPT : detail::Wrapper<cl_type>(std::move(kernel)) {} + + /*! \brief Move assignment to forward move to the superclass correctly. + * Required for MSVC. + */ + Kernel& operator = (Kernel &&kernel) + { + detail::Wrapper<cl_type>::operator=(std::move(kernel)); + return *this; + } +#endif // #if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED) + + template <typename T> + cl_int getInfo(cl_kernel_info name, T* param) const + { + return detail::errHandler( + detail::getInfo(&::clGetKernelInfo, object_, name, param), + __GET_KERNEL_INFO_ERR); + } + + template <cl_int name> typename + detail::param_traits<detail::cl_kernel_info, name>::param_type + getInfo(cl_int* err = NULL) const + { + typename detail::param_traits< + detail::cl_kernel_info, name>::param_type param; + cl_int result = getInfo(name, ¶m); + if (err != NULL) { + *err = result; + } + return param; + } + +#if defined(CL_VERSION_1_2) + template <typename T> + cl_int getArgInfo(cl_uint argIndex, cl_kernel_arg_info name, T* param) const + { + return detail::errHandler( + detail::getInfo(&::clGetKernelArgInfo, object_, argIndex, name, param), + __GET_KERNEL_ARG_INFO_ERR); + } + + template <cl_int name> typename + detail::param_traits<detail::cl_kernel_arg_info, name>::param_type + getArgInfo(cl_uint argIndex, cl_int* err = NULL) const + { + typename detail::param_traits< + detail::cl_kernel_arg_info, name>::param_type param; + cl_int result = getArgInfo(argIndex, name, ¶m); + if (err != NULL) { + *err = result; + } + return param; + } +#endif // #if defined(CL_VERSION_1_2) + + template <typename T> + cl_int getWorkGroupInfo( + const Device& device, cl_kernel_work_group_info name, T* param) const + { + return detail::errHandler( + detail::getInfo( + &::clGetKernelWorkGroupInfo, object_, device(), name, param), + __GET_KERNEL_WORK_GROUP_INFO_ERR); + } + + template <cl_int name> typename + detail::param_traits<detail::cl_kernel_work_group_info, name>::param_type + getWorkGroupInfo(const Device& device, cl_int* err = NULL) const + { + typename detail::param_traits< + detail::cl_kernel_work_group_info, name>::param_type param; + cl_int result = getWorkGroupInfo(device, name, ¶m); + if (err != NULL) { + *err = result; + } + return param; + } + + template <typename T> + cl_int setArg(cl_uint index, const T &value) + { + return detail::errHandler( + ::clSetKernelArg( + object_, + index, + detail::KernelArgumentHandler<T>::size(value), + detail::KernelArgumentHandler<T>::ptr(value)), + __SET_KERNEL_ARGS_ERR); + } + + cl_int setArg(cl_uint index, ::size_t size, const void* argPtr) + { + return detail::errHandler( + ::clSetKernelArg(object_, index, size, argPtr), + __SET_KERNEL_ARGS_ERR); + } +}; + +/*! \class Program + * \brief Program interface that implements cl_program. + */ +class Program : public detail::Wrapper<cl_program> +{ +public: + typedef VECTOR_CLASS<std::pair<const void*, ::size_t> > Binaries; + typedef VECTOR_CLASS<std::pair<const char*, ::size_t> > Sources; + + Program( + const STRING_CLASS& source, + bool build = false, + cl_int* err = NULL) + { + cl_int error; + + const char * strings = source.c_str(); + const ::size_t length = source.size(); + + Context context = Context::getDefault(err); + + object_ = ::clCreateProgramWithSource( + context(), (cl_uint)1, &strings, &length, &error); + + detail::errHandler(error, __CREATE_PROGRAM_WITH_SOURCE_ERR); + + if (error == CL_SUCCESS && build) { + + error = ::clBuildProgram( + object_, + 0, + NULL, + "", + NULL, + NULL); + + detail::errHandler(error, __BUILD_PROGRAM_ERR); + } + + if (err != NULL) { + *err = error; + } + } + + Program( + const Context& context, + const STRING_CLASS& source, + bool build = false, + cl_int* err = NULL) + { + cl_int error; + + const char * strings = source.c_str(); + const ::size_t length = source.size(); + + object_ = ::clCreateProgramWithSource( + context(), (cl_uint)1, &strings, &length, &error); + + detail::errHandler(error, __CREATE_PROGRAM_WITH_SOURCE_ERR); + + if (error == CL_SUCCESS && build) { + + error = ::clBuildProgram( + object_, + 0, + NULL, + "", + NULL, + NULL); + + detail::errHandler(error, __BUILD_PROGRAM_ERR); + } + + if (err != NULL) { + *err = error; + } + } + + Program( + const Context& context, + const Sources& sources, + cl_int* err = NULL) + { + cl_int error; + + const ::size_t n = (::size_t)sources.size(); + ::size_t* lengths = (::size_t*) alloca(n * sizeof(::size_t)); + const char** strings = (const char**) alloca(n * sizeof(const char*)); + + for (::size_t i = 0; i < n; ++i) { + strings[i] = sources[(int)i].first; + lengths[i] = sources[(int)i].second; + } + + object_ = ::clCreateProgramWithSource( + context(), (cl_uint)n, strings, lengths, &error); + + detail::errHandler(error, __CREATE_PROGRAM_WITH_SOURCE_ERR); + if (err != NULL) { + *err = error; + } + } + + /** + * Construct a program object from a list of devices and a per-device list of binaries. + * \param context A valid OpenCL context in which to construct the program. + * \param devices A vector of OpenCL device objects for which the program will be created. + * \param binaries A vector of pairs of a pointer to a binary object and its length. + * \param binaryStatus An optional vector that on completion will be resized to + * match the size of binaries and filled with values to specify if each binary + * was successfully loaded. + * Set to CL_SUCCESS if the binary was successfully loaded. + * Set to CL_INVALID_VALUE if the length is 0 or the binary pointer is NULL. + * Set to CL_INVALID_BINARY if the binary provided is not valid for the matching device. + * \param err if non-NULL will be set to CL_SUCCESS on successful operation or one of the following errors: + * CL_INVALID_CONTEXT if context is not a valid context. + * CL_INVALID_VALUE if the length of devices is zero; or if the length of binaries does not match the length of devices; + * or if any entry in binaries is NULL or has length 0. + * CL_INVALID_DEVICE if OpenCL devices listed in devices are not in the list of devices associated with context. + * CL_INVALID_BINARY if an invalid program binary was encountered for any device. binaryStatus will return specific status for each device. + * CL_OUT_OF_HOST_MEMORY if there is a failure to allocate resources required by the OpenCL implementation on the host. + */ + Program( + const Context& context, + const VECTOR_CLASS<Device>& devices, + const Binaries& binaries, + VECTOR_CLASS<cl_int>* binaryStatus = NULL, + cl_int* err = NULL) + { + cl_int error; + + const ::size_t numDevices = devices.size(); + + // Catch size mismatch early and return + if(binaries.size() != numDevices) { + error = CL_INVALID_VALUE; + detail::errHandler(error, __CREATE_PROGRAM_WITH_BINARY_ERR); + if (err != NULL) { + *err = error; + } + return; + } + + ::size_t* lengths = (::size_t*) alloca(numDevices * sizeof(::size_t)); + const unsigned char** images = (const unsigned char**) alloca(numDevices * sizeof(const unsigned char**)); + + for (::size_t i = 0; i < numDevices; ++i) { + images[i] = (const unsigned char*)binaries[i].first; + lengths[i] = binaries[(int)i].second; + } + + cl_device_id* deviceIDs = (cl_device_id*) alloca(numDevices * sizeof(cl_device_id)); + for( ::size_t deviceIndex = 0; deviceIndex < numDevices; ++deviceIndex ) { + deviceIDs[deviceIndex] = (devices[deviceIndex])(); + } + + if(binaryStatus) { + binaryStatus->resize(numDevices); + } + + object_ = ::clCreateProgramWithBinary( + context(), (cl_uint) devices.size(), + deviceIDs, + lengths, images, (binaryStatus != NULL && numDevices > 0) + ? &binaryStatus->front() + : NULL, &error); + + detail::errHandler(error, __CREATE_PROGRAM_WITH_BINARY_ERR); + if (err != NULL) { + *err = error; + } + } + + +#if defined(CL_VERSION_1_2) + /** + * Create program using builtin kernels. + * \param kernelNames Semi-colon separated list of builtin kernel names + */ + Program( + const Context& context, + const VECTOR_CLASS<Device>& devices, + const STRING_CLASS& kernelNames, + cl_int* err = NULL) + { + cl_int error; + + + ::size_t numDevices = devices.size(); + cl_device_id* deviceIDs = (cl_device_id*) alloca(numDevices * sizeof(cl_device_id)); + for( ::size_t deviceIndex = 0; deviceIndex < numDevices; ++deviceIndex ) { + deviceIDs[deviceIndex] = (devices[deviceIndex])(); + } + + object_ = ::clCreateProgramWithBuiltInKernels( + context(), + (cl_uint) devices.size(), + deviceIDs, + kernelNames.c_str(), + &error); + + detail::errHandler(error, __CREATE_PROGRAM_WITH_BUILT_IN_KERNELS_ERR); + if (err != NULL) { + *err = error; + } + } +#endif // #if defined(CL_VERSION_1_2) + + Program() { } + + __CL_EXPLICIT_CONSTRUCTORS Program(const cl_program& program) : detail::Wrapper<cl_type>(program) { } + + Program& operator = (const cl_program& rhs) + { + detail::Wrapper<cl_type>::operator=(rhs); + return *this; + } + + /*! \brief Copy constructor to forward copy to the superclass correctly. + * Required for MSVC. + */ + Program(const Program& program) : detail::Wrapper<cl_type>(program) {} + + /*! \brief Copy assignment to forward copy to the superclass correctly. + * Required for MSVC. + */ + Program& operator = (const Program &program) + { + detail::Wrapper<cl_type>::operator=(program); + return *this; + } + +#if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED) + /*! \brief Move constructor to forward move to the superclass correctly. + * Required for MSVC. + */ + Program(Program&& program) CL_HPP_NOEXCEPT : detail::Wrapper<cl_type>(std::move(program)) {} + + /*! \brief Move assignment to forward move to the superclass correctly. + * Required for MSVC. + */ + Program& operator = (Program &&program) + { + detail::Wrapper<cl_type>::operator=(std::move(program)); + return *this; + } +#endif // #if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED) + + cl_int build( + const VECTOR_CLASS<Device>& devices, + const char* options = NULL, + void (CL_CALLBACK * notifyFptr)(cl_program, void *) = NULL, + void* data = NULL) const + { + ::size_t numDevices = devices.size(); + cl_device_id* deviceIDs = (cl_device_id*) alloca(numDevices * sizeof(cl_device_id)); + for( ::size_t deviceIndex = 0; deviceIndex < numDevices; ++deviceIndex ) { + deviceIDs[deviceIndex] = (devices[deviceIndex])(); + } + + return detail::errHandler( + ::clBuildProgram( + object_, + (cl_uint) + devices.size(), + deviceIDs, + options, + notifyFptr, + data), + __BUILD_PROGRAM_ERR); + } + + cl_int build( + const char* options = NULL, + void (CL_CALLBACK * notifyFptr)(cl_program, void *) = NULL, + void* data = NULL) const + { + return detail::errHandler( + ::clBuildProgram( + object_, + 0, + NULL, + options, + notifyFptr, + data), + __BUILD_PROGRAM_ERR); + } + +#if defined(CL_VERSION_1_2) + cl_int compile( + const char* options = NULL, + void (CL_CALLBACK * notifyFptr)(cl_program, void *) = NULL, + void* data = NULL) const + { + return detail::errHandler( + ::clCompileProgram( + object_, + 0, + NULL, + options, + 0, + NULL, + NULL, + notifyFptr, + data), + __COMPILE_PROGRAM_ERR); + } +#endif + + template <typename T> + cl_int getInfo(cl_program_info name, T* param) const + { + return detail::errHandler( + detail::getInfo(&::clGetProgramInfo, object_, name, param), + __GET_PROGRAM_INFO_ERR); + } + + template <cl_int name> typename + detail::param_traits<detail::cl_program_info, name>::param_type + getInfo(cl_int* err = NULL) const + { + typename detail::param_traits< + detail::cl_program_info, name>::param_type param; + cl_int result = getInfo(name, ¶m); + if (err != NULL) { + *err = result; + } + return param; + } + + template <typename T> + cl_int getBuildInfo( + const Device& device, cl_program_build_info name, T* param) const + { + return detail::errHandler( + detail::getInfo( + &::clGetProgramBuildInfo, object_, device(), name, param), + __GET_PROGRAM_BUILD_INFO_ERR); + } + + template <cl_int name> typename + detail::param_traits<detail::cl_program_build_info, name>::param_type + getBuildInfo(const Device& device, cl_int* err = NULL) const + { + typename detail::param_traits< + detail::cl_program_build_info, name>::param_type param; + cl_int result = getBuildInfo(device, name, ¶m); + if (err != NULL) { + *err = result; + } + return param; + } + + cl_int createKernels(VECTOR_CLASS<Kernel>* kernels) + { + cl_uint numKernels; + cl_int err = ::clCreateKernelsInProgram(object_, 0, NULL, &numKernels); + if (err != CL_SUCCESS) { + return detail::errHandler(err, __CREATE_KERNELS_IN_PROGRAM_ERR); + } + + Kernel* value = (Kernel*) alloca(numKernels * sizeof(Kernel)); + err = ::clCreateKernelsInProgram( + object_, numKernels, (cl_kernel*) value, NULL); + if (err != CL_SUCCESS) { + return detail::errHandler(err, __CREATE_KERNELS_IN_PROGRAM_ERR); + } + + kernels->assign(&value[0], &value[numKernels]); + return CL_SUCCESS; + } +}; + +#if defined(CL_VERSION_1_2) +inline Program linkProgram( + Program input1, + Program input2, + const char* options = NULL, + void (CL_CALLBACK * notifyFptr)(cl_program, void *) = NULL, + void* data = NULL, + cl_int* err = NULL) +{ + cl_int error_local = CL_SUCCESS; + + cl_program programs[2] = { input1(), input2() }; + + Context ctx = input1.getInfo<CL_PROGRAM_CONTEXT>(&error_local); + if(error_local!=CL_SUCCESS) { + detail::errHandler(error_local, __LINK_PROGRAM_ERR); + } + + cl_program prog = ::clLinkProgram( + ctx(), + 0, + NULL, + options, + 2, + programs, + notifyFptr, + data, + &error_local); + + detail::errHandler(error_local,__COMPILE_PROGRAM_ERR); + if (err != NULL) { + *err = error_local; + } + + return Program(prog); +} + +inline Program linkProgram( + VECTOR_CLASS<Program> inputPrograms, + const char* options = NULL, + void (CL_CALLBACK * notifyFptr)(cl_program, void *) = NULL, + void* data = NULL, + cl_int* err = NULL) +{ + cl_int error_local = CL_SUCCESS; + + cl_program * programs = (cl_program*) alloca(inputPrograms.size() * sizeof(cl_program)); + + if (programs != NULL) { + for (unsigned int i = 0; i < inputPrograms.size(); i++) { + programs[i] = inputPrograms[i](); + } + } + + Context ctx; + if(inputPrograms.size() > 0) { + ctx = inputPrograms[0].getInfo<CL_PROGRAM_CONTEXT>(&error_local); + if(error_local!=CL_SUCCESS) { + detail::errHandler(error_local, __LINK_PROGRAM_ERR); + } + } + cl_program prog = ::clLinkProgram( + ctx(), + 0, + NULL, + options, + (cl_uint)inputPrograms.size(), + programs, + notifyFptr, + data, + &error_local); + + detail::errHandler(error_local,__COMPILE_PROGRAM_ERR); + if (err != NULL) { + *err = error_local; + } + + return Program(prog); +} +#endif + +template<> +inline VECTOR_CLASS<char *> cl::Program::getInfo<CL_PROGRAM_BINARIES>(cl_int* err) const +{ + VECTOR_CLASS< ::size_t> sizes = getInfo<CL_PROGRAM_BINARY_SIZES>(); + VECTOR_CLASS<char *> binaries; + for (VECTOR_CLASS< ::size_t>::iterator s = sizes.begin(); s != sizes.end(); ++s) + { + char *ptr = NULL; + if (*s != 0) + ptr = new char[*s]; + binaries.push_back(ptr); + } + + cl_int result = getInfo(CL_PROGRAM_BINARIES, &binaries); + if (err != NULL) { + *err = result; + } + return binaries; +} + +inline Kernel::Kernel(const Program& program, const char* name, cl_int* err) +{ + cl_int error; + + object_ = ::clCreateKernel(program(), name, &error); + detail::errHandler(error, __CREATE_KERNEL_ERR); + + if (err != NULL) { + *err = error; + } + +} + +/*! \class CommandQueue + * \brief CommandQueue interface for cl_command_queue. + */ +class CommandQueue : public detail::Wrapper<cl_command_queue> +{ +private: +#ifdef CL_HPP_CPP11_ATOMICS_SUPPORTED + static std::atomic<int> default_initialized_; +#else // !CL_HPP_CPP11_ATOMICS_SUPPORTED + static volatile int default_initialized_; +#endif // !CL_HPP_CPP11_ATOMICS_SUPPORTED + static CommandQueue default_; + static volatile cl_int default_error_; +public: + CommandQueue( + cl_command_queue_properties properties, + cl_int* err = NULL) + { + cl_int error; + + Context context = Context::getDefault(&error); + detail::errHandler(error, __CREATE_CONTEXT_ERR); + + if (error != CL_SUCCESS) { + if (err != NULL) { + *err = error; + } + } + else { + Device device = context.getInfo<CL_CONTEXT_DEVICES>()[0]; + + object_ = ::clCreateCommandQueue( + context(), device(), properties, &error); + + detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR); + if (err != NULL) { + *err = error; + } + } + } + /*! + * \brief Constructs a CommandQueue for an implementation defined device in the given context + */ + explicit CommandQueue( + const Context& context, + cl_command_queue_properties properties = 0, + cl_int* err = NULL) + { + cl_int error; + VECTOR_CLASS<cl::Device> devices; + error = context.getInfo(CL_CONTEXT_DEVICES, &devices); + + detail::errHandler(error, __CREATE_CONTEXT_ERR); + + if (error != CL_SUCCESS) + { + if (err != NULL) { + *err = error; + } + return; + } + + object_ = ::clCreateCommandQueue(context(), devices[0](), properties, &error); + + detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR); + + if (err != NULL) { + *err = error; + } + + } + + CommandQueue( + const Context& context, + const Device& device, + cl_command_queue_properties properties = 0, + cl_int* err = NULL) + { + cl_int error; + object_ = ::clCreateCommandQueue( + context(), device(), properties, &error); + + detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR); + if (err != NULL) { + *err = error; + } + } + + /*! \brief Copy constructor to forward copy to the superclass correctly. + * Required for MSVC. + */ + CommandQueue(const CommandQueue& queue) : detail::Wrapper<cl_type>(queue) {} + + /*! \brief Copy assignment to forward copy to the superclass correctly. + * Required for MSVC. + */ + CommandQueue& operator = (const CommandQueue &queue) + { + detail::Wrapper<cl_type>::operator=(queue); + return *this; + } + +#if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED) + /*! \brief Move constructor to forward move to the superclass correctly. + * Required for MSVC. + */ + CommandQueue(CommandQueue&& queue) CL_HPP_NOEXCEPT : detail::Wrapper<cl_type>(std::move(queue)) {} + + /*! \brief Move assignment to forward move to the superclass correctly. + * Required for MSVC. + */ + CommandQueue& operator = (CommandQueue &&queue) + { + detail::Wrapper<cl_type>::operator=(std::move(queue)); + return *this; + } +#endif // #if defined(CL_HPP_RVALUE_REFERENCES_SUPPORTED) + + static CommandQueue getDefault(cl_int * err = NULL) + { + int state = detail::compare_exchange( + &default_initialized_, + __DEFAULT_BEING_INITIALIZED, __DEFAULT_NOT_INITIALIZED); + + if (state & __DEFAULT_INITIALIZED) { + if (err != NULL) { + *err = default_error_; + } + return default_; + } + + if (state & __DEFAULT_BEING_INITIALIZED) { + // Assume writes will propagate eventually... + while(default_initialized_ != __DEFAULT_INITIALIZED) { + detail::fence(); + } + + if (err != NULL) { + *err = default_error_; + } + return default_; + } + + cl_int error; + + Context context = Context::getDefault(&error); + detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR); + + if (error != CL_SUCCESS) { + if (err != NULL) { + *err = error; + } + } + else { + Device device = context.getInfo<CL_CONTEXT_DEVICES>()[0]; + + default_ = CommandQueue(context, device, 0, &error); + + detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR); + if (err != NULL) { + *err = error; + } + } + + detail::fence(); + + default_error_ = error; + // Assume writes will propagate eventually... + default_initialized_ = __DEFAULT_INITIALIZED; + + detail::fence(); + + if (err != NULL) { + *err = default_error_; + } + return default_; + + } + + CommandQueue() { } + + __CL_EXPLICIT_CONSTRUCTORS CommandQueue(const cl_command_queue& commandQueue) : detail::Wrapper<cl_type>(commandQueue) { } + + CommandQueue& operator = (const cl_command_queue& rhs) + { + detail::Wrapper<cl_type>::operator=(rhs); + return *this; + } + + template <typename T> + cl_int getInfo(cl_command_queue_info name, T* param) const + { + return detail::errHandler( + detail::getInfo( + &::clGetCommandQueueInfo, object_, name, param), + __GET_COMMAND_QUEUE_INFO_ERR); + } + + template <cl_int name> typename + detail::param_traits<detail::cl_command_queue_info, name>::param_type + getInfo(cl_int* err = NULL) const + { + typename detail::param_traits< + detail::cl_command_queue_info, name>::param_type param; + cl_int result = getInfo(name, ¶m); + if (err != NULL) { + *err = result; + } + return param; + } + + cl_int enqueueReadBuffer( + const Buffer& buffer, + cl_bool blocking, + ::size_t offset, + ::size_t size, + void* ptr, + const VECTOR_CLASS<Event>* events = NULL, + Event* event = NULL) const + { + cl_event tmp; + cl_int err = detail::errHandler( + ::clEnqueueReadBuffer( + object_, buffer(), blocking, offset, size, + ptr, + (events != NULL) ? (cl_uint) events->size() : 0, + (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL, + (event != NULL) ? &tmp : NULL), + __ENQUEUE_READ_BUFFER_ERR); + + if (event != NULL && err == CL_SUCCESS) + *event = tmp; + + return err; + } + + cl_int enqueueWriteBuffer( + const Buffer& buffer, + cl_bool blocking, + ::size_t offset, + ::size_t size, + const void* ptr, + const VECTOR_CLASS<Event>* events = NULL, + Event* event = NULL) const + { + cl_event tmp; + cl_int err = detail::errHandler( + ::clEnqueueWriteBuffer( + object_, buffer(), blocking, offset, size, + ptr, + (events != NULL) ? (cl_uint) events->size() : 0, + (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL, + (event != NULL) ? &tmp : NULL), + __ENQUEUE_WRITE_BUFFER_ERR); + + if (event != NULL && err == CL_SUCCESS) + *event = tmp; + + return err; + } + + cl_int enqueueCopyBuffer( + const Buffer& src, + const Buffer& dst, + ::size_t src_offset, + ::size_t dst_offset, + ::size_t size, + const VECTOR_CLASS<Event>* events = NULL, + Event* event = NULL) const + { + cl_event tmp; + cl_int err = detail::errHandler( + ::clEnqueueCopyBuffer( + object_, src(), dst(), src_offset, dst_offset, size, + (events != NULL) ? (cl_uint) events->size() : 0, + (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL, + (event != NULL) ? &tmp : NULL), + __ENQEUE_COPY_BUFFER_ERR); + + if (event != NULL && err == CL_SUCCESS) + *event = tmp; + + return err; + } + + cl_int enqueueReadBufferRect( + const Buffer& buffer, + cl_bool blocking, + const size_t<3>& buffer_offset, + const size_t<3>& host_offset, + const size_t<3>& region, + ::size_t buffer_row_pitch, + ::size_t buffer_slice_pitch, + ::size_t host_row_pitch, + ::size_t host_slice_pitch, + void *ptr, + const VECTOR_CLASS<Event>* events = NULL, + Event* event = NULL) const + { + cl_event tmp; + cl_int err = detail::errHandler( + ::clEnqueueReadBufferRect( + object_, + buffer(), + blocking, + (const ::size_t *)buffer_offset, + (const ::size_t *)host_offset, + (const ::size_t *)region, + buffer_row_pitch, + buffer_slice_pitch, + host_row_pitch, + host_slice_pitch, + ptr, + (events != NULL) ? (cl_uint) events->size() : 0, + (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL, + (event != NULL) ? &tmp : NULL), + __ENQUEUE_READ_BUFFER_RECT_ERR); + + if (event != NULL && err == CL_SUCCESS) + *event = tmp; + + return err; + } + + cl_int enqueueWriteBufferRect( + const Buffer& buffer, + cl_bool blocking, + const size_t<3>& buffer_offset, + const size_t<3>& host_offset, + const size_t<3>& region, + ::size_t buffer_row_pitch, + ::size_t buffer_slice_pitch, + ::size_t host_row_pitch, + ::size_t host_slice_pitch, + void *ptr, + const VECTOR_CLASS<Event>* events = NULL, + Event* event = NULL) const + { + cl_event tmp; + cl_int err = detail::errHandler( + ::clEnqueueWriteBufferRect( + object_, + buffer(), + blocking, + (const ::size_t *)buffer_offset, + (const ::size_t *)host_offset, + (const ::size_t *)region, + buffer_row_pitch, + buffer_slice_pitch, + host_row_pitch, + host_slice_pitch, + ptr, + (events != NULL) ? (cl_uint) events->size() : 0, + (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL, + (event != NULL) ? &tmp : NULL), + __ENQUEUE_WRITE_BUFFER_RECT_ERR); + + if (event != NULL && err == CL_SUCCESS) + *event = tmp; + + return err; + } + + cl_int enqueueCopyBufferRect( + const Buffer& src, + const Buffer& dst, + const size_t<3>& src_origin, + const size_t<3>& dst_origin, + const size_t<3>& region, + ::size_t src_row_pitch, + ::size_t src_slice_pitch, + ::size_t dst_row_pitch, + ::size_t dst_slice_pitch, + const VECTOR_CLASS<Event>* events = NULL, + Event* event = NULL) const + { + cl_event tmp; + cl_int err = detail::errHandler( + ::clEnqueueCopyBufferRect( + object_, + src(), + dst(), + (const ::size_t *)src_origin, + (const ::size_t *)dst_origin, + (const ::size_t *)region, + src_row_pitch, + src_slice_pitch, + dst_row_pitch, + dst_slice_pitch, + (events != NULL) ? (cl_uint) events->size() : 0, + (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL, + (event != NULL) ? &tmp : NULL), + __ENQEUE_COPY_BUFFER_RECT_ERR); + + if (event != NULL && err == CL_SUCCESS) + *event = tmp; + + return err; + } + +#if defined(CL_VERSION_1_2) + /** + * Enqueue a command to fill a buffer object with a pattern + * of a given size. The pattern is specified a as vector. + * \tparam PatternType The datatype of the pattern field. + * The pattern type must be an accepted OpenCL data type. + */ + template<typename PatternType> + cl_int enqueueFillBuffer( + const Buffer& buffer, + PatternType pattern, + ::size_t offset, + ::size_t size, + const VECTOR_CLASS<Event>* events = NULL, + Event* event = NULL) const + { + cl_event tmp; + cl_int err = detail::errHandler( + ::clEnqueueFillBuffer( + object_, + buffer(), + static_cast<void*>(&pattern), + sizeof(PatternType), + offset, + size, + (events != NULL) ? (cl_uint) events->size() : 0, + (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL, + (event != NULL) ? &tmp : NULL), + __ENQUEUE_FILL_BUFFER_ERR); + + if (event != NULL && err == CL_SUCCESS) + *event = tmp; + + return err; + } +#endif // #if defined(CL_VERSION_1_2) + + cl_int enqueueReadImage( + const Image& image, + cl_bool blocking, + const size_t<3>& origin, + const size_t<3>& region, + ::size_t row_pitch, + ::size_t slice_pitch, + void* ptr, + const VECTOR_CLASS<Event>* events = NULL, + Event* event = NULL) const + { + cl_event tmp; + cl_int err = detail::errHandler( + ::clEnqueueReadImage( + object_, image(), blocking, (const ::size_t *) origin, + (const ::size_t *) region, row_pitch, slice_pitch, ptr, + (events != NULL) ? (cl_uint) events->size() : 0, + (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL, + (event != NULL) ? &tmp : NULL), + __ENQUEUE_READ_IMAGE_ERR); + + if (event != NULL && err == CL_SUCCESS) + *event = tmp; + + return err; + } + + cl_int enqueueWriteImage( + const Image& image, + cl_bool blocking, + const size_t<3>& origin, + const size_t<3>& region, + ::size_t row_pitch, + ::size_t slice_pitch, + void* ptr, + const VECTOR_CLASS<Event>* events = NULL, + Event* event = NULL) const + { + cl_event tmp; + cl_int err = detail::errHandler( + ::clEnqueueWriteImage( + object_, image(), blocking, (const ::size_t *) origin, + (const ::size_t *) region, row_pitch, slice_pitch, ptr, + (events != NULL) ? (cl_uint) events->size() : 0, + (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL, + (event != NULL) ? &tmp : NULL), + __ENQUEUE_WRITE_IMAGE_ERR); + + if (event != NULL && err == CL_SUCCESS) + *event = tmp; + + return err; + } + + cl_int enqueueCopyImage( + const Image& src, + const Image& dst, + const size_t<3>& src_origin, + const size_t<3>& dst_origin, + const size_t<3>& region, + const VECTOR_CLASS<Event>* events = NULL, + Event* event = NULL) const + { + cl_event tmp; + cl_int err = detail::errHandler( + ::clEnqueueCopyImage( + object_, src(), dst(), (const ::size_t *) src_origin, + (const ::size_t *)dst_origin, (const ::size_t *) region, + (events != NULL) ? (cl_uint) events->size() : 0, + (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL, + (event != NULL) ? &tmp : NULL), + __ENQUEUE_COPY_IMAGE_ERR); + + if (event != NULL && err == CL_SUCCESS) + *event = tmp; + + return err; + } + +#if defined(CL_VERSION_1_2) + /** + * Enqueue a command to fill an image object with a specified color. + * \param fillColor is the color to use to fill the image. + * This is a four component RGBA floating-point color value if + * the image channel data type is not an unnormalized signed or + * unsigned data type. + */ + cl_int enqueueFillImage( + const Image& image, + cl_float4 fillColor, + const size_t<3>& origin, + const size_t<3>& region, + const VECTOR_CLASS<Event>* events = NULL, + Event* event = NULL) const + { + cl_event tmp; + cl_int err = detail::errHandler( + ::clEnqueueFillImage( + object_, + image(), + static_cast<void*>(&fillColor), + (const ::size_t *) origin, + (const ::size_t *) region, + (events != NULL) ? (cl_uint) events->size() : 0, + (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL, + (event != NULL) ? &tmp : NULL), + __ENQUEUE_FILL_IMAGE_ERR); + + if (event != NULL && err == CL_SUCCESS) + *event = tmp; + + return err; + } + + /** + * Enqueue a command to fill an image object with a specified color. + * \param fillColor is the color to use to fill the image. + * This is a four component RGBA signed integer color value if + * the image channel data type is an unnormalized signed integer + * type. + */ + cl_int enqueueFillImage( + const Image& image, + cl_int4 fillColor, + const size_t<3>& origin, + const size_t<3>& region, + const VECTOR_CLASS<Event>* events = NULL, + Event* event = NULL) const + { + cl_event tmp; + cl_int err = detail::errHandler( + ::clEnqueueFillImage( + object_, + image(), + static_cast<void*>(&fillColor), + (const ::size_t *) origin, + (const ::size_t *) region, + (events != NULL) ? (cl_uint) events->size() : 0, + (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL, + (event != NULL) ? &tmp : NULL), + __ENQUEUE_FILL_IMAGE_ERR); + + if (event != NULL && err == CL_SUCCESS) + *event = tmp; + + return err; + } + + /** + * Enqueue a command to fill an image object with a specified color. + * \param fillColor is the color to use to fill the image. + * This is a four component RGBA unsigned integer color value if + * the image channel data type is an unnormalized unsigned integer + * type. + */ + cl_int enqueueFillImage( + const Image& image, + cl_uint4 fillColor, + const size_t<3>& origin, + const size_t<3>& region, + const VECTOR_CLASS<Event>* events = NULL, + Event* event = NULL) const + { + cl_event tmp; + cl_int err = detail::errHandler( + ::clEnqueueFillImage( + object_, + image(), + static_cast<void*>(&fillColor), + (const ::size_t *) origin, + (const ::size_t *) region, + (events != NULL) ? (cl_uint) events->size() : 0, + (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL, + (event != NULL) ? &tmp : NULL), + __ENQUEUE_FILL_IMAGE_ERR); + + if (event != NULL && err == CL_SUCCESS) + *event = tmp; + + return err; + } +#endif // #if defined(CL_VERSION_1_2) + + cl_int enqueueCopyImageToBuffer( + const Image& src, + const Buffer& dst, + const size_t<3>& src_origin, + const size_t<3>& region, + ::size_t dst_offset, + const VECTOR_CLASS<Event>* events = NULL, + Event* event = NULL) const + { + cl_event tmp; + cl_int err = detail::errHandler( + ::clEnqueueCopyImageToBuffer( + object_, src(), dst(), (const ::size_t *) src_origin, + (const ::size_t *) region, dst_offset, + (events != NULL) ? (cl_uint) events->size() : 0, + (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL, + (event != NULL) ? &tmp : NULL), + __ENQUEUE_COPY_IMAGE_TO_BUFFER_ERR); + + if (event != NULL && err == CL_SUCCESS) + *event = tmp; + + return err; + } + + cl_int enqueueCopyBufferToImage( + const Buffer& src, + const Image& dst, + ::size_t src_offset, + const size_t<3>& dst_origin, + const size_t<3>& region, + const VECTOR_CLASS<Event>* events = NULL, + Event* event = NULL) const + { + cl_event tmp; + cl_int err = detail::errHandler( + ::clEnqueueCopyBufferToImage( + object_, src(), dst(), src_offset, + (const ::size_t *) dst_origin, (const ::size_t *) region, + (events != NULL) ? (cl_uint) events->size() : 0, + (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL, + (event != NULL) ? &tmp : NULL), + __ENQUEUE_COPY_BUFFER_TO_IMAGE_ERR); + + if (event != NULL && err == CL_SUCCESS) + *event = tmp; + + return err; + } + + void* enqueueMapBuffer( + const Buffer& buffer, + cl_bool blocking, + cl_map_flags flags, + ::size_t offset, + ::size_t size, + const VECTOR_CLASS<Event>* events = NULL, + Event* event = NULL, + cl_int* err = NULL) const + { + cl_event tmp; + cl_int error; + void * result = ::clEnqueueMapBuffer( + object_, buffer(), blocking, flags, offset, size, + (events != NULL) ? (cl_uint) events->size() : 0, + (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL, + (event != NULL) ? &tmp : NULL, + &error); + + detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR); + if (err != NULL) { + *err = error; + } + if (event != NULL && error == CL_SUCCESS) + *event = tmp; + + return result; + } + + void* enqueueMapImage( + const Image& buffer, + cl_bool blocking, + cl_map_flags flags, + const size_t<3>& origin, + const size_t<3>& region, + ::size_t * row_pitch, + ::size_t * slice_pitch, + const VECTOR_CLASS<Event>* events = NULL, + Event* event = NULL, + cl_int* err = NULL) const + { + cl_event tmp; + cl_int error; + void * result = ::clEnqueueMapImage( + object_, buffer(), blocking, flags, + (const ::size_t *) origin, (const ::size_t *) region, + row_pitch, slice_pitch, + (events != NULL) ? (cl_uint) events->size() : 0, + (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL, + (event != NULL) ? &tmp : NULL, + &error); + + detail::errHandler(error, __ENQUEUE_MAP_IMAGE_ERR); + if (err != NULL) { + *err = error; + } + if (event != NULL && error == CL_SUCCESS) + *event = tmp; + return result; + } + + cl_int enqueueUnmapMemObject( + const Memory& memory, + void* mapped_ptr, + const VECTOR_CLASS<Event>* events = NULL, + Event* event = NULL) const + { + cl_event tmp; + cl_int err = detail::errHandler( + ::clEnqueueUnmapMemObject( + object_, memory(), mapped_ptr, + (events != NULL) ? (cl_uint) events->size() : 0, + (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL, + (event != NULL) ? &tmp : NULL), + __ENQUEUE_UNMAP_MEM_OBJECT_ERR); + + if (event != NULL && err == CL_SUCCESS) + *event = tmp; + + return err; + } + +#if defined(CL_VERSION_1_2) + /** + * Enqueues a marker command which waits for either a list of events to complete, + * or all previously enqueued commands to complete. + * + * Enqueues a marker command which waits for either a list of events to complete, + * or if the list is empty it waits for all commands previously enqueued in command_queue + * to complete before it completes. This command returns an event which can be waited on, + * i.e. this event can be waited on to insure that all events either in the event_wait_list + * or all previously enqueued commands, queued before this command to command_queue, + * have completed. + */ + cl_int enqueueMarkerWithWaitList( + const VECTOR_CLASS<Event> *events = 0, + Event *event = 0) + { + cl_event tmp; + cl_int err = detail::errHandler( + ::clEnqueueMarkerWithWaitList( + object_, + (events != NULL) ? (cl_uint) events->size() : 0, + (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL, + (event != NULL) ? &tmp : NULL), + __ENQUEUE_MARKER_WAIT_LIST_ERR); + + if (event != NULL && err == CL_SUCCESS) + *event = tmp; + + return err; + } + + /** + * A synchronization point that enqueues a barrier operation. + * + * Enqueues a barrier command which waits for either a list of events to complete, + * or if the list is empty it waits for all commands previously enqueued in command_queue + * to complete before it completes. This command blocks command execution, that is, any + * following commands enqueued after it do not execute until it completes. This command + * returns an event which can be waited on, i.e. this event can be waited on to insure that + * all events either in the event_wait_list or all previously enqueued commands, queued + * before this command to command_queue, have completed. + */ + cl_int enqueueBarrierWithWaitList( + const VECTOR_CLASS<Event> *events = 0, + Event *event = 0) + { + cl_event tmp; + cl_int err = detail::errHandler( + ::clEnqueueBarrierWithWaitList( + object_, + (events != NULL) ? (cl_uint) events->size() : 0, + (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL, + (event != NULL) ? &tmp : NULL), + __ENQUEUE_BARRIER_WAIT_LIST_ERR); + + if (event != NULL && err == CL_SUCCESS) + *event = tmp; + + return err; + } + + /** + * Enqueues a command to indicate with which device a set of memory objects + * should be associated. + */ + cl_int enqueueMigrateMemObjects( + const VECTOR_CLASS<Memory> &memObjects, + cl_mem_migration_flags flags, + const VECTOR_CLASS<Event>* events = NULL, + Event* event = NULL + ) + { + cl_event tmp; + + cl_mem* localMemObjects = static_cast<cl_mem*>(alloca(memObjects.size() * sizeof(cl_mem))); + for( int i = 0; i < (int)memObjects.size(); ++i ) { + localMemObjects[i] = memObjects[i](); + } + + + cl_int err = detail::errHandler( + ::clEnqueueMigrateMemObjects( + object_, + (cl_uint)memObjects.size(), + static_cast<const cl_mem*>(localMemObjects), + flags, + (events != NULL) ? (cl_uint) events->size() : 0, + (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL, + (event != NULL) ? &tmp : NULL), + __ENQUEUE_UNMAP_MEM_OBJECT_ERR); + + if (event != NULL && err == CL_SUCCESS) + *event = tmp; + + return err; + } +#endif // #if defined(CL_VERSION_1_2) + + cl_int enqueueNDRangeKernel( + const Kernel& kernel, + const NDRange& offset, + const NDRange& global, + const NDRange& local = NullRange, + const VECTOR_CLASS<Event>* events = NULL, + Event* event = NULL) const + { + cl_event tmp; + cl_int err = detail::errHandler( + ::clEnqueueNDRangeKernel( + object_, kernel(), (cl_uint) global.dimensions(), + offset.dimensions() != 0 ? (const ::size_t*) offset : NULL, + (const ::size_t*) global, + local.dimensions() != 0 ? (const ::size_t*) local : NULL, + (events != NULL) ? (cl_uint) events->size() : 0, + (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL, + (event != NULL) ? &tmp : NULL), + __ENQUEUE_NDRANGE_KERNEL_ERR); + + if (event != NULL && err == CL_SUCCESS) + *event = tmp; + + return err; + } + + cl_int enqueueTask( + const Kernel& kernel, + const VECTOR_CLASS<Event>* events = NULL, + Event* event = NULL) const + { + cl_event tmp; + cl_int err = detail::errHandler( + ::clEnqueueTask( + object_, kernel(), + (events != NULL) ? (cl_uint) events->size() : 0, + (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL, + (event != NULL) ? &tmp : NULL), + __ENQUEUE_TASK_ERR); + + if (event != NULL && err == CL_SUCCESS) + *event = tmp; + + return err; + } + + cl_int enqueueNativeKernel( + void (CL_CALLBACK *userFptr)(void *), + std::pair<void*, ::size_t> args, + const VECTOR_CLASS<Memory>* mem_objects = NULL, + const VECTOR_CLASS<const void*>* mem_locs = NULL, + const VECTOR_CLASS<Event>* events = NULL, + Event* event = NULL) const + { + cl_mem * mems = (mem_objects != NULL && mem_objects->size() > 0) + ? (cl_mem*) alloca(mem_objects->size() * sizeof(cl_mem)) + : NULL; + + if (mems != NULL) { + for (unsigned int i = 0; i < mem_objects->size(); i++) { + mems[i] = ((*mem_objects)[i])(); + } + } + + cl_event tmp; + cl_int err = detail::errHandler( + ::clEnqueueNativeKernel( + object_, userFptr, args.first, args.second, + (mem_objects != NULL) ? (cl_uint) mem_objects->size() : 0, + mems, + (mem_locs != NULL && mem_locs->size() > 0) ? (const void **) &mem_locs->front() : NULL, + (events != NULL) ? (cl_uint) events->size() : 0, + (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL, + (event != NULL) ? &tmp : NULL), + __ENQUEUE_NATIVE_KERNEL); + + if (event != NULL && err == CL_SUCCESS) + *event = tmp; + + return err; + } + +/** + * Deprecated APIs for 1.2 + */ +#if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS) || (defined(CL_VERSION_1_1) && !defined(CL_VERSION_1_2)) + CL_EXT_PREFIX__VERSION_1_1_DEPRECATED + cl_int enqueueMarker(Event* event = NULL) const CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED + { + cl_event tmp; + cl_int err = detail::errHandler( + ::clEnqueueMarker( + object_, + (event != NULL) ? &tmp : NULL), + __ENQUEUE_MARKER_ERR); + + if (event != NULL && err == CL_SUCCESS) + *event = tmp; + + return err; + } + + CL_EXT_PREFIX__VERSION_1_1_DEPRECATED + cl_int enqueueWaitForEvents(const VECTOR_CLASS<Event>& events) const CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED + { + return detail::errHandler( + ::clEnqueueWaitForEvents( + object_, + (cl_uint) events.size(), + events.size() > 0 ? (const cl_event*) &events.front() : NULL), + __ENQUEUE_WAIT_FOR_EVENTS_ERR); + } +#endif // #if defined(CL_VERSION_1_1) + + cl_int enqueueAcquireGLObjects( + const VECTOR_CLASS<Memory>* mem_objects = NULL, + const VECTOR_CLASS<Event>* events = NULL, + Event* event = NULL) const + { + cl_event tmp; + cl_int err = detail::errHandler( + ::clEnqueueAcquireGLObjects( + object_, + (mem_objects != NULL) ? (cl_uint) mem_objects->size() : 0, + (mem_objects != NULL && mem_objects->size() > 0) ? (const cl_mem *) &mem_objects->front(): NULL, + (events != NULL) ? (cl_uint) events->size() : 0, + (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL, + (event != NULL) ? &tmp : NULL), + __ENQUEUE_ACQUIRE_GL_ERR); + + if (event != NULL && err == CL_SUCCESS) + *event = tmp; + + return err; + } + + cl_int enqueueReleaseGLObjects( + const VECTOR_CLASS<Memory>* mem_objects = NULL, + const VECTOR_CLASS<Event>* events = NULL, + Event* event = NULL) const + { + cl_event tmp; + cl_int err = detail::errHandler( + ::clEnqueueReleaseGLObjects( + object_, + (mem_objects != NULL) ? (cl_uint) mem_objects->size() : 0, + (mem_objects != NULL && mem_objects->size() > 0) ? (const cl_mem *) &mem_objects->front(): NULL, + (events != NULL) ? (cl_uint) events->size() : 0, + (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL, + (event != NULL) ? &tmp : NULL), + __ENQUEUE_RELEASE_GL_ERR); + + if (event != NULL && err == CL_SUCCESS) + *event = tmp; + + return err; + } + +#if defined (USE_DX_INTEROP) +typedef CL_API_ENTRY cl_int (CL_API_CALL *PFN_clEnqueueAcquireD3D10ObjectsKHR)( + cl_command_queue command_queue, cl_uint num_objects, + const cl_mem* mem_objects, cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, cl_event* event); +typedef CL_API_ENTRY cl_int (CL_API_CALL *PFN_clEnqueueReleaseD3D10ObjectsKHR)( + cl_command_queue command_queue, cl_uint num_objects, + const cl_mem* mem_objects, cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, cl_event* event); + + cl_int enqueueAcquireD3D10Objects( + const VECTOR_CLASS<Memory>* mem_objects = NULL, + const VECTOR_CLASS<Event>* events = NULL, + Event* event = NULL) const + { + static PFN_clEnqueueAcquireD3D10ObjectsKHR pfn_clEnqueueAcquireD3D10ObjectsKHR = NULL; +#if defined(CL_VERSION_1_2) + cl_context context = getInfo<CL_QUEUE_CONTEXT>(); + cl::Device device(getInfo<CL_QUEUE_DEVICE>()); + cl_platform_id platform = device.getInfo<CL_DEVICE_PLATFORM>(); + __INIT_CL_EXT_FCN_PTR_PLATFORM(platform, clEnqueueAcquireD3D10ObjectsKHR); +#endif +#if defined(CL_VERSION_1_1) + __INIT_CL_EXT_FCN_PTR(clEnqueueAcquireD3D10ObjectsKHR); +#endif + + cl_event tmp; + cl_int err = detail::errHandler( + pfn_clEnqueueAcquireD3D10ObjectsKHR( + object_, + (mem_objects != NULL) ? (cl_uint) mem_objects->size() : 0, + (mem_objects != NULL && mem_objects->size() > 0) ? (const cl_mem *) &mem_objects->front(): NULL, + (events != NULL) ? (cl_uint) events->size() : 0, + (events != NULL) ? (cl_event*) &events->front() : NULL, + (event != NULL) ? &tmp : NULL), + __ENQUEUE_ACQUIRE_GL_ERR); + + if (event != NULL && err == CL_SUCCESS) + *event = tmp; + + return err; + } + + cl_int enqueueReleaseD3D10Objects( + const VECTOR_CLASS<Memory>* mem_objects = NULL, + const VECTOR_CLASS<Event>* events = NULL, + Event* event = NULL) const + { + static PFN_clEnqueueReleaseD3D10ObjectsKHR pfn_clEnqueueReleaseD3D10ObjectsKHR = NULL; +#if defined(CL_VERSION_1_2) + cl_context context = getInfo<CL_QUEUE_CONTEXT>(); + cl::Device device(getInfo<CL_QUEUE_DEVICE>()); + cl_platform_id platform = device.getInfo<CL_DEVICE_PLATFORM>(); + __INIT_CL_EXT_FCN_PTR_PLATFORM(platform, clEnqueueReleaseD3D10ObjectsKHR); +#endif // #if defined(CL_VERSION_1_2) +#if defined(CL_VERSION_1_1) + __INIT_CL_EXT_FCN_PTR(clEnqueueReleaseD3D10ObjectsKHR); +#endif // #if defined(CL_VERSION_1_1) + + cl_event tmp; + cl_int err = detail::errHandler( + pfn_clEnqueueReleaseD3D10ObjectsKHR( + object_, + (mem_objects != NULL) ? (cl_uint) mem_objects->size() : 0, + (mem_objects != NULL && mem_objects->size() > 0) ? (const cl_mem *) &mem_objects->front(): NULL, + (events != NULL) ? (cl_uint) events->size() : 0, + (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL, + (event != NULL) ? &tmp : NULL), + __ENQUEUE_RELEASE_GL_ERR); + + if (event != NULL && err == CL_SUCCESS) + *event = tmp; + + return err; + } +#endif + +/** + * Deprecated APIs for 1.2 + */ +#if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS) || (defined(CL_VERSION_1_1) && !defined(CL_VERSION_1_2)) + CL_EXT_PREFIX__VERSION_1_1_DEPRECATED + cl_int enqueueBarrier() const CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED + { + return detail::errHandler( + ::clEnqueueBarrier(object_), + __ENQUEUE_BARRIER_ERR); + } +#endif // #if defined(CL_VERSION_1_1) + + cl_int flush() const + { + return detail::errHandler(::clFlush(object_), __FLUSH_ERR); + } + + cl_int finish() const + { + return detail::errHandler(::clFinish(object_), __FINISH_ERR); + } +}; + +#ifdef _WIN32 +#ifdef CL_HPP_CPP11_ATOMICS_SUPPORTED +__declspec(selectany) std::atomic<int> CommandQueue::default_initialized_; +#else // !CL_HPP_CPP11_ATOMICS_SUPPORTED +__declspec(selectany) volatile int CommandQueue::default_initialized_ = __DEFAULT_NOT_INITIALIZED; +#endif // !CL_HPP_CPP11_ATOMICS_SUPPORTED +__declspec(selectany) CommandQueue CommandQueue::default_; +__declspec(selectany) volatile cl_int CommandQueue::default_error_ = CL_SUCCESS; +#else // !_WIN32 +#ifdef CL_HPP_CPP11_ATOMICS_SUPPORTED +__attribute__((weak)) std::atomic<int> CommandQueue::default_initialized_; +#else // !CL_HPP_CPP11_ATOMICS_SUPPORTED +__attribute__((weak)) volatile int CommandQueue::default_initialized_ = __DEFAULT_NOT_INITIALIZED; +#endif // !CL_HPP_CPP11_ATOMICS_SUPPORTED +__attribute__((weak)) CommandQueue CommandQueue::default_; +__attribute__((weak)) volatile cl_int CommandQueue::default_error_ = CL_SUCCESS; +#endif // !_WIN32 + +template< typename IteratorType > +Buffer::Buffer( + const Context &context, + IteratorType startIterator, + IteratorType endIterator, + bool readOnly, + bool useHostPtr, + cl_int* err) +{ + typedef typename std::iterator_traits<IteratorType>::value_type DataType; + cl_int error; + + cl_mem_flags flags = 0; + if( readOnly ) { + flags |= CL_MEM_READ_ONLY; + } + else { + flags |= CL_MEM_READ_WRITE; + } + if( useHostPtr ) { + flags |= CL_MEM_USE_HOST_PTR; + } + + ::size_t size = sizeof(DataType)*(endIterator - startIterator); + + if( useHostPtr ) { + object_ = ::clCreateBuffer(context(), flags, size, static_cast<DataType*>(&*startIterator), &error); + } else { + object_ = ::clCreateBuffer(context(), flags, size, 0, &error); + } + + detail::errHandler(error, __CREATE_BUFFER_ERR); + if (err != NULL) { + *err = error; + } + + if( !useHostPtr ) { + CommandQueue queue(context, 0, &error); + detail::errHandler(error, __CREATE_BUFFER_ERR); + if (err != NULL) { + *err = error; + } + + error = cl::copy(queue, startIterator, endIterator, *this); + detail::errHandler(error, __CREATE_BUFFER_ERR); + if (err != NULL) { + *err = error; + } + } +} + +template< typename IteratorType > +Buffer::Buffer( + const CommandQueue &queue, + IteratorType startIterator, + IteratorType endIterator, + bool readOnly, + bool useHostPtr, + cl_int* err) +{ + typedef typename std::iterator_traits<IteratorType>::value_type DataType; + cl_int error; + + cl_mem_flags flags = 0; + if (readOnly) { + flags |= CL_MEM_READ_ONLY; + } + else { + flags |= CL_MEM_READ_WRITE; + } + if (useHostPtr) { + flags |= CL_MEM_USE_HOST_PTR; + } + + ::size_t size = sizeof(DataType)*(endIterator - startIterator); + + Context context = queue.getInfo<CL_QUEUE_CONTEXT>(); + + if (useHostPtr) { + object_ = ::clCreateBuffer(context(), flags, size, static_cast<DataType*>(&*startIterator), &error); + } + else { + object_ = ::clCreateBuffer(context(), flags, size, 0, &error); + } + + detail::errHandler(error, __CREATE_BUFFER_ERR); + if (err != NULL) { + *err = error; + } + + if (!useHostPtr) { + error = cl::copy(queue, startIterator, endIterator, *this); + detail::errHandler(error, __CREATE_BUFFER_ERR); + if (err != NULL) { + *err = error; + } + } +} + +inline cl_int enqueueReadBuffer( + const Buffer& buffer, + cl_bool blocking, + ::size_t offset, + ::size_t size, + void* ptr, + const VECTOR_CLASS<Event>* events = NULL, + Event* event = NULL) +{ + cl_int error; + CommandQueue queue = CommandQueue::getDefault(&error); + + if (error != CL_SUCCESS) { + return error; + } + + return queue.enqueueReadBuffer(buffer, blocking, offset, size, ptr, events, event); +} + +inline cl_int enqueueWriteBuffer( + const Buffer& buffer, + cl_bool blocking, + ::size_t offset, + ::size_t size, + const void* ptr, + const VECTOR_CLASS<Event>* events = NULL, + Event* event = NULL) +{ + cl_int error; + CommandQueue queue = CommandQueue::getDefault(&error); + + if (error != CL_SUCCESS) { + return error; + } + + return queue.enqueueWriteBuffer(buffer, blocking, offset, size, ptr, events, event); +} + +inline void* enqueueMapBuffer( + const Buffer& buffer, + cl_bool blocking, + cl_map_flags flags, + ::size_t offset, + ::size_t size, + const VECTOR_CLASS<Event>* events = NULL, + Event* event = NULL, + cl_int* err = NULL) +{ + cl_int error; + CommandQueue queue = CommandQueue::getDefault(&error); + detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR); + if (err != NULL) { + *err = error; + } + + void * result = ::clEnqueueMapBuffer( + queue(), buffer(), blocking, flags, offset, size, + (events != NULL) ? (cl_uint) events->size() : 0, + (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL, + (cl_event*) event, + &error); + + detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR); + if (err != NULL) { + *err = error; + } + return result; +} + +inline cl_int enqueueUnmapMemObject( + const Memory& memory, + void* mapped_ptr, + const VECTOR_CLASS<Event>* events = NULL, + Event* event = NULL) +{ + cl_int error; + CommandQueue queue = CommandQueue::getDefault(&error); + detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR); + if (error != CL_SUCCESS) { + return error; + } + + cl_event tmp; + cl_int err = detail::errHandler( + ::clEnqueueUnmapMemObject( + queue(), memory(), mapped_ptr, + (events != NULL) ? (cl_uint) events->size() : 0, + (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL, + (event != NULL) ? &tmp : NULL), + __ENQUEUE_UNMAP_MEM_OBJECT_ERR); + + if (event != NULL && err == CL_SUCCESS) + *event = tmp; + + return err; +} + +inline cl_int enqueueCopyBuffer( + const Buffer& src, + const Buffer& dst, + ::size_t src_offset, + ::size_t dst_offset, + ::size_t size, + const VECTOR_CLASS<Event>* events = NULL, + Event* event = NULL) +{ + cl_int error; + CommandQueue queue = CommandQueue::getDefault(&error); + + if (error != CL_SUCCESS) { + return error; + } + + return queue.enqueueCopyBuffer(src, dst, src_offset, dst_offset, size, events, event); +} + +/** + * Blocking copy operation between iterators and a buffer. + * Host to Device. + * Uses default command queue. + */ +template< typename IteratorType > +inline cl_int copy( IteratorType startIterator, IteratorType endIterator, cl::Buffer &buffer ) +{ + cl_int error; + CommandQueue queue = CommandQueue::getDefault(&error); + if (error != CL_SUCCESS) + return error; + + return cl::copy(queue, startIterator, endIterator, buffer); +} + +/** + * Blocking copy operation between iterators and a buffer. + * Device to Host. + * Uses default command queue. + */ +template< typename IteratorType > +inline cl_int copy( const cl::Buffer &buffer, IteratorType startIterator, IteratorType endIterator ) +{ + cl_int error; + CommandQueue queue = CommandQueue::getDefault(&error); + if (error != CL_SUCCESS) + return error; + + return cl::copy(queue, buffer, startIterator, endIterator); +} + +/** + * Blocking copy operation between iterators and a buffer. + * Host to Device. + * Uses specified queue. + */ +template< typename IteratorType > +inline cl_int copy( const CommandQueue &queue, IteratorType startIterator, IteratorType endIterator, cl::Buffer &buffer ) +{ + typedef typename std::iterator_traits<IteratorType>::value_type DataType; + cl_int error; + + ::size_t length = endIterator-startIterator; + ::size_t byteLength = length*sizeof(DataType); + + DataType *pointer = + static_cast<DataType*>(queue.enqueueMapBuffer(buffer, CL_TRUE, CL_MAP_WRITE, 0, byteLength, 0, 0, &error)); + // if exceptions enabled, enqueueMapBuffer will throw + if( error != CL_SUCCESS ) { + return error; + } +#if defined(_MSC_VER) + std::copy( + startIterator, + endIterator, + stdext::checked_array_iterator<DataType*>( + pointer, length)); +#else + std::copy(startIterator, endIterator, pointer); +#endif + Event endEvent; + error = queue.enqueueUnmapMemObject(buffer, pointer, 0, &endEvent); + // if exceptions enabled, enqueueUnmapMemObject will throw + if( error != CL_SUCCESS ) { + return error; + } + endEvent.wait(); + return CL_SUCCESS; +} + +/** + * Blocking copy operation between iterators and a buffer. + * Device to Host. + * Uses specified queue. + */ +template< typename IteratorType > +inline cl_int copy( const CommandQueue &queue, const cl::Buffer &buffer, IteratorType startIterator, IteratorType endIterator ) +{ + typedef typename std::iterator_traits<IteratorType>::value_type DataType; + cl_int error; + + ::size_t length = endIterator-startIterator; + ::size_t byteLength = length*sizeof(DataType); + + DataType *pointer = + static_cast<DataType*>(queue.enqueueMapBuffer(buffer, CL_TRUE, CL_MAP_READ, 0, byteLength, 0, 0, &error)); + // if exceptions enabled, enqueueMapBuffer will throw + if( error != CL_SUCCESS ) { + return error; + } + std::copy(pointer, pointer + length, startIterator); + Event endEvent; + error = queue.enqueueUnmapMemObject(buffer, pointer, 0, &endEvent); + // if exceptions enabled, enqueueUnmapMemObject will throw + if( error != CL_SUCCESS ) { + return error; + } + endEvent.wait(); + return CL_SUCCESS; +} + +#if defined(CL_VERSION_1_1) +inline cl_int enqueueReadBufferRect( + const Buffer& buffer, + cl_bool blocking, + const size_t<3>& buffer_offset, + const size_t<3>& host_offset, + const size_t<3>& region, + ::size_t buffer_row_pitch, + ::size_t buffer_slice_pitch, + ::size_t host_row_pitch, + ::size_t host_slice_pitch, + void *ptr, + const VECTOR_CLASS<Event>* events = NULL, + Event* event = NULL) +{ + cl_int error; + CommandQueue queue = CommandQueue::getDefault(&error); + + if (error != CL_SUCCESS) { + return error; + } + + return queue.enqueueReadBufferRect( + buffer, + blocking, + buffer_offset, + host_offset, + region, + buffer_row_pitch, + buffer_slice_pitch, + host_row_pitch, + host_slice_pitch, + ptr, + events, + event); +} + +inline cl_int enqueueWriteBufferRect( + const Buffer& buffer, + cl_bool blocking, + const size_t<3>& buffer_offset, + const size_t<3>& host_offset, + const size_t<3>& region, + ::size_t buffer_row_pitch, + ::size_t buffer_slice_pitch, + ::size_t host_row_pitch, + ::size_t host_slice_pitch, + void *ptr, + const VECTOR_CLASS<Event>* events = NULL, + Event* event = NULL) +{ + cl_int error; + CommandQueue queue = CommandQueue::getDefault(&error); + + if (error != CL_SUCCESS) { + return error; + } + + return queue.enqueueWriteBufferRect( + buffer, + blocking, + buffer_offset, + host_offset, + region, + buffer_row_pitch, + buffer_slice_pitch, + host_row_pitch, + host_slice_pitch, + ptr, + events, + event); +} + +inline cl_int enqueueCopyBufferRect( + const Buffer& src, + const Buffer& dst, + const size_t<3>& src_origin, + const size_t<3>& dst_origin, + const size_t<3>& region, + ::size_t src_row_pitch, + ::size_t src_slice_pitch, + ::size_t dst_row_pitch, + ::size_t dst_slice_pitch, + const VECTOR_CLASS<Event>* events = NULL, + Event* event = NULL) +{ + cl_int error; + CommandQueue queue = CommandQueue::getDefault(&error); + + if (error != CL_SUCCESS) { + return error; + } + + return queue.enqueueCopyBufferRect( + src, + dst, + src_origin, + dst_origin, + region, + src_row_pitch, + src_slice_pitch, + dst_row_pitch, + dst_slice_pitch, + events, + event); +} +#endif + +inline cl_int enqueueReadImage( + const Image& image, + cl_bool blocking, + const size_t<3>& origin, + const size_t<3>& region, + ::size_t row_pitch, + ::size_t slice_pitch, + void* ptr, + const VECTOR_CLASS<Event>* events = NULL, + Event* event = NULL) +{ + cl_int error; + CommandQueue queue = CommandQueue::getDefault(&error); + + if (error != CL_SUCCESS) { + return error; + } + + return queue.enqueueReadImage( + image, + blocking, + origin, + region, + row_pitch, + slice_pitch, + ptr, + events, + event); +} + +inline cl_int enqueueWriteImage( + const Image& image, + cl_bool blocking, + const size_t<3>& origin, + const size_t<3>& region, + ::size_t row_pitch, + ::size_t slice_pitch, + void* ptr, + const VECTOR_CLASS<Event>* events = NULL, + Event* event = NULL) +{ + cl_int error; + CommandQueue queue = CommandQueue::getDefault(&error); + + if (error != CL_SUCCESS) { + return error; + } + + return queue.enqueueWriteImage( + image, + blocking, + origin, + region, + row_pitch, + slice_pitch, + ptr, + events, + event); +} + +inline cl_int enqueueCopyImage( + const Image& src, + const Image& dst, + const size_t<3>& src_origin, + const size_t<3>& dst_origin, + const size_t<3>& region, + const VECTOR_CLASS<Event>* events = NULL, + Event* event = NULL) +{ + cl_int error; + CommandQueue queue = CommandQueue::getDefault(&error); + + if (error != CL_SUCCESS) { + return error; + } + + return queue.enqueueCopyImage( + src, + dst, + src_origin, + dst_origin, + region, + events, + event); +} + +inline cl_int enqueueCopyImageToBuffer( + const Image& src, + const Buffer& dst, + const size_t<3>& src_origin, + const size_t<3>& region, + ::size_t dst_offset, + const VECTOR_CLASS<Event>* events = NULL, + Event* event = NULL) +{ + cl_int error; + CommandQueue queue = CommandQueue::getDefault(&error); + + if (error != CL_SUCCESS) { + return error; + } + + return queue.enqueueCopyImageToBuffer( + src, + dst, + src_origin, + region, + dst_offset, + events, + event); +} + +inline cl_int enqueueCopyBufferToImage( + const Buffer& src, + const Image& dst, + ::size_t src_offset, + const size_t<3>& dst_origin, + const size_t<3>& region, + const VECTOR_CLASS<Event>* events = NULL, + Event* event = NULL) +{ + cl_int error; + CommandQueue queue = CommandQueue::getDefault(&error); + + if (error != CL_SUCCESS) { + return error; + } + + return queue.enqueueCopyBufferToImage( + src, + dst, + src_offset, + dst_origin, + region, + events, + event); +} + + +inline cl_int flush(void) +{ + cl_int error; + CommandQueue queue = CommandQueue::getDefault(&error); + + if (error != CL_SUCCESS) { + return error; + } + + return queue.flush(); +} + +inline cl_int finish(void) +{ + cl_int error; + CommandQueue queue = CommandQueue::getDefault(&error); + + if (error != CL_SUCCESS) { + return error; + } + + + return queue.finish(); +} + +// Kernel Functor support +// New interface as of September 2011 +// Requires the C++11 std::tr1::function (note do not support TR1) +// Visual Studio 2010 and GCC 4.2 + +struct EnqueueArgs +{ + CommandQueue queue_; + const NDRange offset_; + const NDRange global_; + const NDRange local_; + VECTOR_CLASS<Event> events_; + + EnqueueArgs(NDRange global) : + queue_(CommandQueue::getDefault()), + offset_(NullRange), + global_(global), + local_(NullRange) + { + + } + + EnqueueArgs(NDRange global, NDRange local) : + queue_(CommandQueue::getDefault()), + offset_(NullRange), + global_(global), + local_(local) + { + + } + + EnqueueArgs(NDRange offset, NDRange global, NDRange local) : + queue_(CommandQueue::getDefault()), + offset_(offset), + global_(global), + local_(local) + { + + } + + EnqueueArgs(Event e, NDRange global) : + queue_(CommandQueue::getDefault()), + offset_(NullRange), + global_(global), + local_(NullRange) + { + events_.push_back(e); + } + + EnqueueArgs(Event e, NDRange global, NDRange local) : + queue_(CommandQueue::getDefault()), + offset_(NullRange), + global_(global), + local_(local) + { + events_.push_back(e); + } + + EnqueueArgs(Event e, NDRange offset, NDRange global, NDRange local) : + queue_(CommandQueue::getDefault()), + offset_(offset), + global_(global), + local_(local) + { + events_.push_back(e); + } + + EnqueueArgs(const VECTOR_CLASS<Event> &events, NDRange global) : + queue_(CommandQueue::getDefault()), + offset_(NullRange), + global_(global), + local_(NullRange), + events_(events) + { + + } + + EnqueueArgs(const VECTOR_CLASS<Event> &events, NDRange global, NDRange local) : + queue_(CommandQueue::getDefault()), + offset_(NullRange), + global_(global), + local_(local), + events_(events) + { + + } + + EnqueueArgs(const VECTOR_CLASS<Event> &events, NDRange offset, NDRange global, NDRange local) : + queue_(CommandQueue::getDefault()), + offset_(offset), + global_(global), + local_(local), + events_(events) + { + + } + + EnqueueArgs(CommandQueue &queue, NDRange global) : + queue_(queue), + offset_(NullRange), + global_(global), + local_(NullRange) + { + + } + + EnqueueArgs(CommandQueue &queue, NDRange global, NDRange local) : + queue_(queue), + offset_(NullRange), + global_(global), + local_(local) + { + + } + + EnqueueArgs(CommandQueue &queue, NDRange offset, NDRange global, NDRange local) : + queue_(queue), + offset_(offset), + global_(global), + local_(local) + { + + } + + EnqueueArgs(CommandQueue &queue, Event e, NDRange global) : + queue_(queue), + offset_(NullRange), + global_(global), + local_(NullRange) + { + events_.push_back(e); + } + + EnqueueArgs(CommandQueue &queue, Event e, NDRange global, NDRange local) : + queue_(queue), + offset_(NullRange), + global_(global), + local_(local) + { + events_.push_back(e); + } + + EnqueueArgs(CommandQueue &queue, Event e, NDRange offset, NDRange global, NDRange local) : + queue_(queue), + offset_(offset), + global_(global), + local_(local) + { + events_.push_back(e); + } + + EnqueueArgs(CommandQueue &queue, const VECTOR_CLASS<Event> &events, NDRange global) : + queue_(queue), + offset_(NullRange), + global_(global), + local_(NullRange), + events_(events) + { + + } + + EnqueueArgs(CommandQueue &queue, const VECTOR_CLASS<Event> &events, NDRange global, NDRange local) : + queue_(queue), + offset_(NullRange), + global_(global), + local_(local), + events_(events) + { + + } + + EnqueueArgs(CommandQueue &queue, const VECTOR_CLASS<Event> &events, NDRange offset, NDRange global, NDRange local) : + queue_(queue), + offset_(offset), + global_(global), + local_(local), + events_(events) + { + + } +}; + +namespace detail { + +class NullType {}; + +template<int index, typename T0> +struct SetArg +{ + static void set (Kernel kernel, T0 arg) + { + kernel.setArg(index, arg); + } +}; + +template<int index> +struct SetArg<index, NullType> +{ + static void set (Kernel, NullType) + { + } +}; + +template < + typename T0, typename T1, typename T2, typename T3, + typename T4, typename T5, typename T6, typename T7, + typename T8, typename T9, typename T10, typename T11, + typename T12, typename T13, typename T14, typename T15, + typename T16, typename T17, typename T18, typename T19, + typename T20, typename T21, typename T22, typename T23, + typename T24, typename T25, typename T26, typename T27, + typename T28, typename T29, typename T30, typename T31 +> +class KernelFunctorGlobal +{ +private: + Kernel kernel_; + +public: + KernelFunctorGlobal( + Kernel kernel) : + kernel_(kernel) + {} + + KernelFunctorGlobal( + const Program& program, + const STRING_CLASS name, + cl_int * err = NULL) : + kernel_(program, name.c_str(), err) + {} + + Event operator() ( + const EnqueueArgs& args, + T0 t0, + T1 t1 = NullType(), + T2 t2 = NullType(), + T3 t3 = NullType(), + T4 t4 = NullType(), + T5 t5 = NullType(), + T6 t6 = NullType(), + T7 t7 = NullType(), + T8 t8 = NullType(), + T9 t9 = NullType(), + T10 t10 = NullType(), + T11 t11 = NullType(), + T12 t12 = NullType(), + T13 t13 = NullType(), + T14 t14 = NullType(), + T15 t15 = NullType(), + T16 t16 = NullType(), + T17 t17 = NullType(), + T18 t18 = NullType(), + T19 t19 = NullType(), + T20 t20 = NullType(), + T21 t21 = NullType(), + T22 t22 = NullType(), + T23 t23 = NullType(), + T24 t24 = NullType(), + T25 t25 = NullType(), + T26 t26 = NullType(), + T27 t27 = NullType(), + T28 t28 = NullType(), + T29 t29 = NullType(), + T30 t30 = NullType(), + T31 t31 = NullType() + ) + { + Event event; + SetArg<0, T0>::set(kernel_, t0); + SetArg<1, T1>::set(kernel_, t1); + SetArg<2, T2>::set(kernel_, t2); + SetArg<3, T3>::set(kernel_, t3); + SetArg<4, T4>::set(kernel_, t4); + SetArg<5, T5>::set(kernel_, t5); + SetArg<6, T6>::set(kernel_, t6); + SetArg<7, T7>::set(kernel_, t7); + SetArg<8, T8>::set(kernel_, t8); + SetArg<9, T9>::set(kernel_, t9); + SetArg<10, T10>::set(kernel_, t10); + SetArg<11, T11>::set(kernel_, t11); + SetArg<12, T12>::set(kernel_, t12); + SetArg<13, T13>::set(kernel_, t13); + SetArg<14, T14>::set(kernel_, t14); + SetArg<15, T15>::set(kernel_, t15); + SetArg<16, T16>::set(kernel_, t16); + SetArg<17, T17>::set(kernel_, t17); + SetArg<18, T18>::set(kernel_, t18); + SetArg<19, T19>::set(kernel_, t19); + SetArg<20, T20>::set(kernel_, t20); + SetArg<21, T21>::set(kernel_, t21); + SetArg<22, T22>::set(kernel_, t22); + SetArg<23, T23>::set(kernel_, t23); + SetArg<24, T24>::set(kernel_, t24); + SetArg<25, T25>::set(kernel_, t25); + SetArg<26, T26>::set(kernel_, t26); + SetArg<27, T27>::set(kernel_, t27); + SetArg<28, T28>::set(kernel_, t28); + SetArg<29, T29>::set(kernel_, t29); + SetArg<30, T30>::set(kernel_, t30); + SetArg<31, T31>::set(kernel_, t31); + + args.queue_.enqueueNDRangeKernel( + kernel_, + args.offset_, + args.global_, + args.local_, + &args.events_, + &event); + + return event; + } + +}; + +//------------------------------------------------------------------------------------------------------ + + +template< + typename T0, + typename T1, + typename T2, + typename T3, + typename T4, + typename T5, + typename T6, + typename T7, + typename T8, + typename T9, + typename T10, + typename T11, + typename T12, + typename T13, + typename T14, + typename T15, + typename T16, + typename T17, + typename T18, + typename T19, + typename T20, + typename T21, + typename T22, + typename T23, + typename T24, + typename T25, + typename T26, + typename T27, + typename T28, + typename T29, + typename T30, + typename T31> +struct functionImplementation_ +{ + typedef detail::KernelFunctorGlobal< + T0, + T1, + T2, + T3, + T4, + T5, + T6, + T7, + T8, + T9, + T10, + T11, + T12, + T13, + T14, + T15, + T16, + T17, + T18, + T19, + T20, + T21, + T22, + T23, + T24, + T25, + T26, + T27, + T28, + T29, + T30, + T31> FunctorType; + + FunctorType functor_; + + functionImplementation_(const FunctorType &functor) : + functor_(functor) + { + + #if (defined(_WIN32) && defined(_VARIADIC_MAX) && (_VARIADIC_MAX < 32)) + // Fail variadic expansion for dev11 + static_assert(0, "Visual Studio has a hard limit of argument count for a std::function expansion. Please define _VARIADIC_MAX to be 10. If you need more arguments than that VC12 and below cannot support it."); + #endif + + } + + //! \brief Return type of the functor + typedef Event result_type; + + //! \brief Function signature of kernel functor with no event dependency. + typedef Event type_( + const EnqueueArgs&, + T0, + T1, + T2, + T3, + T4, + T5, + T6, + T7, + T8, + T9, + T10, + T11, + T12, + T13, + T14, + T15, + T16, + T17, + T18, + T19, + T20, + T21, + T22, + T23, + T24, + T25, + T26, + T27, + T28, + T29, + T30, + T31); + + Event operator()( + const EnqueueArgs& enqueueArgs, + T0 arg0, + T1 arg1, + T2 arg2, + T3 arg3, + T4 arg4, + T5 arg5, + T6 arg6, + T7 arg7, + T8 arg8, + T9 arg9, + T10 arg10, + T11 arg11, + T12 arg12, + T13 arg13, + T14 arg14, + T15 arg15, + T16 arg16, + T17 arg17, + T18 arg18, + T19 arg19, + T20 arg20, + T21 arg21, + T22 arg22, + T23 arg23, + T24 arg24, + T25 arg25, + T26 arg26, + T27 arg27, + T28 arg28, + T29 arg29, + T30 arg30, + T31 arg31) + { + return functor_( + enqueueArgs, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11, + arg12, + arg13, + arg14, + arg15, + arg16, + arg17, + arg18, + arg19, + arg20, + arg21, + arg22, + arg23, + arg24, + arg25, + arg26, + arg27, + arg28, + arg29, + arg30, + arg31); + } + + +}; + +template< + typename T0, + typename T1, + typename T2, + typename T3, + typename T4, + typename T5, + typename T6, + typename T7, + typename T8, + typename T9, + typename T10, + typename T11, + typename T12, + typename T13, + typename T14, + typename T15, + typename T16, + typename T17, + typename T18, + typename T19, + typename T20, + typename T21, + typename T22, + typename T23, + typename T24, + typename T25, + typename T26, + typename T27, + typename T28, + typename T29, + typename T30> +struct functionImplementation_ +< T0, + T1, + T2, + T3, + T4, + T5, + T6, + T7, + T8, + T9, + T10, + T11, + T12, + T13, + T14, + T15, + T16, + T17, + T18, + T19, + T20, + T21, + T22, + T23, + T24, + T25, + T26, + T27, + T28, + T29, + T30, + NullType> +{ + typedef detail::KernelFunctorGlobal< + T0, + T1, + T2, + T3, + T4, + T5, + T6, + T7, + T8, + T9, + T10, + T11, + T12, + T13, + T14, + T15, + T16, + T17, + T18, + T19, + T20, + T21, + T22, + T23, + T24, + T25, + T26, + T27, + T28, + T29, + T30, + NullType> FunctorType; + + FunctorType functor_; + + functionImplementation_(const FunctorType &functor) : + functor_(functor) + { + + #if (defined(_WIN32) && defined(_VARIADIC_MAX) && (_VARIADIC_MAX < 31)) + // Fail variadic expansion for dev11 + static_assert(0, "Visual Studio has a hard limit of argument count for a std::function expansion. Please define _VARIADIC_MAX to be 10. If you need more arguments than that VC12 and below cannot support it."); + #endif + + } + + //! \brief Return type of the functor + typedef Event result_type; + + //! \brief Function signature of kernel functor with no event dependency. + typedef Event type_( + const EnqueueArgs&, + T0, + T1, + T2, + T3, + T4, + T5, + T6, + T7, + T8, + T9, + T10, + T11, + T12, + T13, + T14, + T15, + T16, + T17, + T18, + T19, + T20, + T21, + T22, + T23, + T24, + T25, + T26, + T27, + T28, + T29, + T30); + + Event operator()( + const EnqueueArgs& enqueueArgs, + T0 arg0, + T1 arg1, + T2 arg2, + T3 arg3, + T4 arg4, + T5 arg5, + T6 arg6, + T7 arg7, + T8 arg8, + T9 arg9, + T10 arg10, + T11 arg11, + T12 arg12, + T13 arg13, + T14 arg14, + T15 arg15, + T16 arg16, + T17 arg17, + T18 arg18, + T19 arg19, + T20 arg20, + T21 arg21, + T22 arg22, + T23 arg23, + T24 arg24, + T25 arg25, + T26 arg26, + T27 arg27, + T28 arg28, + T29 arg29, + T30 arg30) + { + return functor_( + enqueueArgs, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11, + arg12, + arg13, + arg14, + arg15, + arg16, + arg17, + arg18, + arg19, + arg20, + arg21, + arg22, + arg23, + arg24, + arg25, + arg26, + arg27, + arg28, + arg29, + arg30); + } + + +}; + +template< + typename T0, + typename T1, + typename T2, + typename T3, + typename T4, + typename T5, + typename T6, + typename T7, + typename T8, + typename T9, + typename T10, + typename T11, + typename T12, + typename T13, + typename T14, + typename T15, + typename T16, + typename T17, + typename T18, + typename T19, + typename T20, + typename T21, + typename T22, + typename T23, + typename T24, + typename T25, + typename T26, + typename T27, + typename T28, + typename T29> +struct functionImplementation_ +< T0, + T1, + T2, + T3, + T4, + T5, + T6, + T7, + T8, + T9, + T10, + T11, + T12, + T13, + T14, + T15, + T16, + T17, + T18, + T19, + T20, + T21, + T22, + T23, + T24, + T25, + T26, + T27, + T28, + T29, + NullType, + NullType> +{ + typedef detail::KernelFunctorGlobal< + T0, + T1, + T2, + T3, + T4, + T5, + T6, + T7, + T8, + T9, + T10, + T11, + T12, + T13, + T14, + T15, + T16, + T17, + T18, + T19, + T20, + T21, + T22, + T23, + T24, + T25, + T26, + T27, + T28, + T29, + NullType, + NullType> FunctorType; + + FunctorType functor_; + + functionImplementation_(const FunctorType &functor) : + functor_(functor) + { + + #if (defined(_WIN32) && defined(_VARIADIC_MAX) && (_VARIADIC_MAX < 30)) + // Fail variadic expansion for dev11 + static_assert(0, "Visual Studio has a hard limit of argument count for a std::function expansion. Please define _VARIADIC_MAX to be 10. If you need more arguments than that VC12 and below cannot support it."); + #endif + + } + + //! \brief Return type of the functor + typedef Event result_type; + + //! \brief Function signature of kernel functor with no event dependency. + typedef Event type_( + const EnqueueArgs&, + T0, + T1, + T2, + T3, + T4, + T5, + T6, + T7, + T8, + T9, + T10, + T11, + T12, + T13, + T14, + T15, + T16, + T17, + T18, + T19, + T20, + T21, + T22, |