Add GCC-UPC, a compiler for the UPC distributed shared memory language.
svn path=/nixpkgs/trunk/; revision=10956
This commit is contained in:
parent
cfe56735b0
commit
8b34b723f7
24
pkgs/build-support/gcc-upc-wrapper/add-flags
Normal file
24
pkgs/build-support/gcc-upc-wrapper/add-flags
Normal file
|
@ -0,0 +1,24 @@
|
|||
# `-B@out@/bin' forces gcc to use ld-wrapper.sh when calling ld.
|
||||
export NIX_CFLAGS_COMPILE="-B@out@/bin/ $NIX_CFLAGS_COMPILE"
|
||||
|
||||
if test -e @out@/nix-support/libc-cflags; then
|
||||
export NIX_CFLAGS_COMPILE="$(cat @out@/nix-support/libc-cflags) $NIX_CFLAGS_COMPILE"
|
||||
fi
|
||||
|
||||
if test -e @out@/nix-support/libc-ldflags; then
|
||||
export NIX_LDFLAGS="$(cat @out@/nix-support/libc-ldflags) $NIX_LDFLAGS"
|
||||
fi
|
||||
|
||||
if test -e @out@/nix-support/gcc-cflags; then
|
||||
export NIX_CFLAGS_COMPILE="$(cat @out@/nix-support/gcc-cflags) $NIX_CFLAGS_COMPILE"
|
||||
fi
|
||||
|
||||
if test -e @out@/nix-support/gcc-ldflags; then
|
||||
export NIX_LDFLAGS="$(cat @out@/nix-support/gcc-ldflags) $NIX_LDFLAGS"
|
||||
fi
|
||||
|
||||
if test -e @out@/nix-support/libc-ldflags-before; then
|
||||
export NIX_LDFLAGS_BEFORE="$(cat @out@/nix-support/libc-ldflags-before) $NIX_LDFLAGS_BEFORE"
|
||||
fi
|
||||
|
||||
export NIX_GCC_WRAPPER_FLAGS_SET=1
|
114
pkgs/build-support/gcc-upc-wrapper/builder.sh
Normal file
114
pkgs/build-support/gcc-upc-wrapper/builder.sh
Normal file
|
@ -0,0 +1,114 @@
|
|||
source $stdenv/setup
|
||||
|
||||
|
||||
ensureDir $out/bin
|
||||
ensureDir $out/nix-support
|
||||
|
||||
|
||||
if test -z "$nativeLibc"; then
|
||||
dynamicLinker="$libc/lib/$dynamicLinker"
|
||||
echo $dynamicLinker > $out/nix-support/dynamic-linker
|
||||
|
||||
# The "-B$libc/lib/" flag is a quick hack to force gcc to link
|
||||
# against the crt1.o from our own glibc, rather than the one in
|
||||
# /usr/lib. (This is only an issue when using an `impure'
|
||||
# compiler/linker, i.e., one that searches /usr/lib and so on.)
|
||||
echo "-B$libc/lib/ -isystem $libc/include" > $out/nix-support/libc-cflags
|
||||
|
||||
echo "-L$libc/lib" > $out/nix-support/libc-ldflags
|
||||
|
||||
# The dynamic linker is passed in `ldflagsBefore' to allow
|
||||
# explicit overrides of the dynamic linker by callers to gcc/ld
|
||||
# (the *last* value counts, so ours should come first).
|
||||
echo "-dynamic-linker $dynamicLinker" > $out/nix-support/libc-ldflags-before
|
||||
fi
|
||||
|
||||
if test -n "$nativeTools"; then
|
||||
gccPath="$nativePrefix/bin"
|
||||
ldPath="$nativePrefix/bin"
|
||||
else
|
||||
if test -e "$gcc/lib64"; then
|
||||
gccLDFlags="$gccLDFlags -L$gcc/lib64"
|
||||
fi
|
||||
gccLDFlags="$gccLDFlags -L$gcc/lib"
|
||||
echo "$gccLDFlags" > $out/nix-support/gcc-ldflags
|
||||
|
||||
# GCC shows $gcc/lib in `gcc -print-search-dirs', but not
|
||||
# $gcc/lib64 (even though it does actually search there...)..
|
||||
# This confuses libtool. So add it to the compiler tool search
|
||||
# path explicitly.
|
||||
if test -e "$gcc/lib64"; then
|
||||
gccCFlags="$gccCFlags -B$gcc/lib64"
|
||||
fi
|
||||
echo "$gccCFlags" > $out/nix-support/gcc-cflags
|
||||
|
||||
gccPath="$gcc/bin"
|
||||
ldPath="$binutils/bin"
|
||||
fi
|
||||
|
||||
|
||||
doSubstitute() {
|
||||
local src=$1
|
||||
local dst=$2
|
||||
# Can't use substitute() here, because replace may not have been
|
||||
# built yet (in the bootstrap).
|
||||
sed \
|
||||
-e "s^@out@^$out^g" \
|
||||
-e "s^@shell@^$shell^g" \
|
||||
-e "s^@gcc@^$gcc^g" \
|
||||
-e "s^@gccProg@^$gccProg^g" \
|
||||
-e "s^@binutils@^$binutils^g" \
|
||||
-e "s^@libc@^$libc^g" \
|
||||
-e "s^@ld@^$ldPath/ld^g" \
|
||||
< "$src" > "$dst"
|
||||
}
|
||||
|
||||
|
||||
# Make wrapper scripts around gcc, g++, and g77. Also make symlinks
|
||||
# cc, c++, and f77.
|
||||
mkGccWrapper() {
|
||||
local dst=$1
|
||||
local src=$2
|
||||
|
||||
if ! test -f "$src"; then
|
||||
echo "$src does not exist (skipping)"
|
||||
return
|
||||
fi
|
||||
|
||||
gccProg="$src"
|
||||
doSubstitute "$gccWrapper" "$dst"
|
||||
chmod +x "$dst"
|
||||
}
|
||||
|
||||
mkGccWrapper $out/bin/upc $gccPath/upc
|
||||
|
||||
|
||||
# Create a symlink to as (the assembler). This is useful when a
|
||||
# gcc-wrapper is installed in a user environment, as it ensures that
|
||||
# the right assembler is called.
|
||||
ln -s $ldPath/as $out/bin/as
|
||||
|
||||
|
||||
# Make a wrapper around the linker.
|
||||
doSubstitute "$ldWrapper" "$out/bin/ld"
|
||||
chmod +x "$out/bin/ld"
|
||||
|
||||
|
||||
# Emit a setup hook. Also store the path to the original GCC and
|
||||
# Glibc.
|
||||
test -n "$gcc" && echo $gcc > $out/nix-support/orig-gcc
|
||||
test -n "$libc" && echo $libc > $out/nix-support/orig-libc
|
||||
|
||||
doSubstitute "$addFlags" "$out/nix-support/add-flags.sh"
|
||||
|
||||
doSubstitute "$setupHook" "$out/nix-support/setup-hook"
|
||||
|
||||
cp -p $utils $out/nix-support/utils.sh
|
||||
|
||||
|
||||
# Propagate the wrapped gcc so that if you install the wrapper, you get
|
||||
# tools like gcov, the manpages, etc. as well (including for binutils
|
||||
# and Glibc).
|
||||
if test -z "$nativeTools"; then
|
||||
echo $gcc $binutils $libc > $out/nix-support/propagated-user-env-packages
|
||||
fi
|
43
pkgs/build-support/gcc-upc-wrapper/default.nix
Normal file
43
pkgs/build-support/gcc-upc-wrapper/default.nix
Normal file
|
@ -0,0 +1,43 @@
|
|||
# The Nix `gcc' stdenv.mkDerivation is not directly usable, since it doesn't
|
||||
# know where the C library and standard header files are. Therefore
|
||||
# the compiler produced by that package cannot be installed directly
|
||||
# in a user environment and used from the command line. This
|
||||
# stdenv.mkDerivation provides a wrapper that sets up the right environment
|
||||
# variables so that the compiler and the linker just "work".
|
||||
|
||||
{ name ? "", stdenv, nativeTools, nativeLibc, nativePrefix ? ""
|
||||
, gcc ? null, libc ? null, binutils ? null, shell ? ""
|
||||
}:
|
||||
|
||||
assert nativeTools -> nativePrefix != "";
|
||||
assert !nativeTools -> gcc != null && binutils != null;
|
||||
assert !nativeLibc -> libc != null;
|
||||
|
||||
stdenv.mkDerivation {
|
||||
builder = ./builder.sh;
|
||||
setupHook = ./setup-hook.sh;
|
||||
gccWrapper = ./gcc-wrapper.sh;
|
||||
ldWrapper = ./ld-wrapper.sh;
|
||||
utils = ./utils.sh;
|
||||
addFlags = ./add-flags;
|
||||
|
||||
inherit nativeTools nativeLibc nativePrefix gcc libc binutils;
|
||||
name = if name == "" then gcc.name else name;
|
||||
langC = if nativeTools then true else gcc.langC;
|
||||
langCC = if nativeTools then true else gcc.langCC;
|
||||
langF77 = if nativeTools then false else gcc.langF77;
|
||||
shell = if shell == "" then stdenv.shell else shell;
|
||||
|
||||
meta = if gcc != null && (gcc ? meta) then removeAttrs gcc.meta ["priority"] else
|
||||
{ description = "System C compiler wrapper";
|
||||
};
|
||||
|
||||
# The dynamic linker has different names on different Linux platforms.
|
||||
dynamicLinker =
|
||||
if !nativeLibc then
|
||||
(if stdenv.system == "i686-linux" then "ld-linux.so.2" else
|
||||
if stdenv.system == "x86_64-linux" then "ld-linux-x86-64.so.2" else
|
||||
if stdenv.system == "powerpc-linux" then "ld.so.1" else
|
||||
abort "don't know the name of the dynamic linker for this platform")
|
||||
else "";
|
||||
}
|
144
pkgs/build-support/gcc-upc-wrapper/gcc-wrapper.sh
Normal file
144
pkgs/build-support/gcc-upc-wrapper/gcc-wrapper.sh
Normal file
|
@ -0,0 +1,144 @@
|
|||
#! @shell@ -e
|
||||
|
||||
if test -n "$NIX_GCC_WRAPPER_START_HOOK"; then
|
||||
source "$NIX_GCC_WRAPPER_START_HOOK"
|
||||
fi
|
||||
|
||||
if test -z "$NIX_GCC_WRAPPER_FLAGS_SET"; then
|
||||
source @out@/nix-support/add-flags.sh
|
||||
fi
|
||||
|
||||
source @out@/nix-support/utils.sh
|
||||
|
||||
|
||||
# Figure out if linker flags should be passed. GCC prints annoying
|
||||
# warnings when they are not needed.
|
||||
dontLink=0
|
||||
getVersion=0
|
||||
nonFlagArgs=0
|
||||
|
||||
for i in "$@"; do
|
||||
if test "$i" = "-c"; then
|
||||
dontLink=1
|
||||
elif test "$i" = "-S"; then
|
||||
dontLink=1
|
||||
elif test "$i" = "-E"; then
|
||||
dontLink=1
|
||||
elif test "$i" = "-E"; then
|
||||
dontLink=1
|
||||
elif test "$i" = "-M"; then
|
||||
dontLink=1
|
||||
elif test "$i" = "-MM"; then
|
||||
dontLink=1
|
||||
elif test "${i:0:1}" != "-"; then
|
||||
nonFlagArgs=1
|
||||
fi
|
||||
done
|
||||
|
||||
# If we pass a flag like -Wl, then gcc will call the linker unless it
|
||||
# can figure out that it has to do something else (e.g., because of a
|
||||
# "-c" flag). So if no non-flag arguments are given, don't pass any
|
||||
# linker flags. This catches cases like "gcc" (should just print
|
||||
# "gcc: no input files") and "gcc -v" (should print the version).
|
||||
if test "$nonFlagArgs" = "0"; then
|
||||
dontLink=1
|
||||
fi
|
||||
|
||||
|
||||
# Optionally filter out paths not refering to the store.
|
||||
params=("$@")
|
||||
if test "$NIX_ENFORCE_PURITY" = "1" -a -n "$NIX_STORE"; then
|
||||
rest=()
|
||||
n=0
|
||||
while test $n -lt ${#params[*]}; do
|
||||
p=${params[n]}
|
||||
p2=${params[$((n+1))]}
|
||||
if test "${p:0:3}" = "-L/" && badPath "${p:2}"; then
|
||||
skip $p
|
||||
elif test "$p" = "-L" && badPath "$p2"; then
|
||||
n=$((n + 1)); skip $p2
|
||||
elif test "${p:0:3}" = "-I/" && badPath "${p:2}"; then
|
||||
skip $p
|
||||
elif test "$p" = "-I" && badPath "$p2"; then
|
||||
n=$((n + 1)); skip $p2
|
||||
elif test "$p" = "-isystem" && badPath "$p2"; then
|
||||
n=$((n + 1)); skip $p2
|
||||
else
|
||||
rest=("${rest[@]}" "$p")
|
||||
fi
|
||||
n=$((n + 1))
|
||||
done
|
||||
params=("${rest[@]}")
|
||||
fi
|
||||
|
||||
|
||||
# Add the flags for the C compiler proper.
|
||||
extraAfter=($NIX_CFLAGS_COMPILE)
|
||||
extraBefore=()
|
||||
|
||||
if test "$dontLink" != "1"; then
|
||||
|
||||
# Add the flags that should only be passed to the compiler when
|
||||
# linking.
|
||||
extraAfter=(${extraAfter[@]} $NIX_CFLAGS_LINK)
|
||||
|
||||
# Add the flags that should be passed to the linker (and prevent
|
||||
# `ld-wrapper' from adding NIX_LDFLAGS again).
|
||||
for i in $NIX_LDFLAGS_BEFORE; do
|
||||
extraBefore=(${extraBefore[@]} "-Wl,$i")
|
||||
done
|
||||
for i in $NIX_LDFLAGS; do
|
||||
if test "${i:0:3}" = "-L/"; then
|
||||
extraAfter=(${extraAfter[@]} "$i")
|
||||
else
|
||||
extraAfter=(${extraAfter[@]} "-Wl,$i")
|
||||
fi
|
||||
done
|
||||
export NIX_LDFLAGS_SET=1
|
||||
|
||||
if test "$NIX_STRIP_DEBUG" = "1"; then
|
||||
# Add executable-stripping flags.
|
||||
extraAfter=(${extraAfter[@]} $NIX_CFLAGS_STRIP)
|
||||
fi
|
||||
fi
|
||||
|
||||
# As a very special hack, if the arguments are just `-v', then don't
|
||||
# add anything. This is to prevent `gcc -v' (which normally prints
|
||||
# out the version number and returns exit code 0) from printing out
|
||||
# `No input files specified' and returning exit code 1.
|
||||
if test "$*" = "-v"; then
|
||||
extraAfter=()
|
||||
extraBefore=()
|
||||
fi
|
||||
|
||||
# Optionally print debug info.
|
||||
if test "$NIX_DEBUG" = "1"; then
|
||||
echo "original flags to @gccProg@:" >&2
|
||||
for i in "${params[@]}"; do
|
||||
echo " $i" >&2
|
||||
done
|
||||
echo "extraBefore flags to @gccProg@:" >&2
|
||||
for i in ${extraBefore[@]}; do
|
||||
echo " $i" >&2
|
||||
done
|
||||
echo "extraAfter flags to @gccProg@:" >&2
|
||||
for i in ${extraAfter[@]}; do
|
||||
echo " $i" >&2
|
||||
done
|
||||
fi
|
||||
|
||||
if test -n "$NIX_GCC_WRAPPER_EXEC_HOOK"; then
|
||||
source "$NIX_GCC_WRAPPER_EXEC_HOOK"
|
||||
fi
|
||||
|
||||
|
||||
# Call the real `gcc'. Filter out warnings from stderr about unused
|
||||
# `-B' flags, since they confuse some programs. Deep bash magic to
|
||||
# apply grep to stderr (by swapping stdin/stderr twice).
|
||||
if test -z "$NIX_GCC_NEEDS_GREP"; then
|
||||
@gccProg@ ${extraBefore[@]} "${params[@]}" ${extraAfter[@]}
|
||||
else
|
||||
(@gccProg@ ${extraBefore[@]} "${params[@]}" ${extraAfter[@]} 3>&2 2>&1 1>&3- \
|
||||
| (grep -v 'file path prefix' || true); exit ${PIPESTATUS[0]}) 3>&2 2>&1 1>&3-
|
||||
exit $?
|
||||
fi
|
145
pkgs/build-support/gcc-upc-wrapper/ld-wrapper.sh
Normal file
145
pkgs/build-support/gcc-upc-wrapper/ld-wrapper.sh
Normal file
|
@ -0,0 +1,145 @@
|
|||
#! @shell@ -e
|
||||
|
||||
if test -n "$NIX_LD_WRAPPER_START_HOOK"; then
|
||||
source "$NIX_LD_WRAPPER_START_HOOK"
|
||||
fi
|
||||
|
||||
if test -z "$NIX_GCC_WRAPPER_FLAGS_SET"; then
|
||||
source @out@/nix-support/add-flags.sh
|
||||
fi
|
||||
|
||||
source @out@/nix-support/utils.sh
|
||||
|
||||
|
||||
# Optionally filter out paths not refering to the store.
|
||||
params=("$@")
|
||||
if test "$NIX_ENFORCE_PURITY" = "1" -a -n "$NIX_STORE" \
|
||||
-a \( -z "$NIX_IGNORE_LD_THROUGH_GCC" -o -z "$NIX_LDFLAGS_SET" \); then
|
||||
rest=()
|
||||
n=0
|
||||
while test $n -lt ${#params[*]}; do
|
||||
p=${params[n]}
|
||||
p2=${params[$((n+1))]}
|
||||
if test "${p:0:3}" = "-L/" && badPath "${p:2}"; then
|
||||
skip $p
|
||||
elif test "$p" = "-L" && badPath "$p2"; then
|
||||
n=$((n + 1)); skip $p2
|
||||
elif test "$p" = "-rpath" && badPath "$p2"; then
|
||||
n=$((n + 1)); skip $p2
|
||||
elif test "$p" = "-dynamic-linker" && badPath "$p2"; then
|
||||
n=$((n + 1)); skip $p2
|
||||
elif test "${p:0:1}" = "/" && badPath "$p"; then
|
||||
# We cannot skip this; barf.
|
||||
echo "impure path \`$p' used in link" >&2
|
||||
exit 1
|
||||
else
|
||||
rest=("${rest[@]}" "$p")
|
||||
fi
|
||||
n=$((n + 1))
|
||||
done
|
||||
params=("${rest[@]}")
|
||||
fi
|
||||
|
||||
|
||||
extra=()
|
||||
extraBefore=()
|
||||
|
||||
if test -z "$NIX_LDFLAGS_SET"; then
|
||||
extra=(${extra[@]} $NIX_LDFLAGS)
|
||||
extraBefore=(${extraBefore[@]} $NIX_LDFLAGS_BEFORE)
|
||||
fi
|
||||
|
||||
|
||||
# Add all used dynamic libraries to the rpath.
|
||||
if test "$NIX_DONT_SET_RPATH" != "1"; then
|
||||
|
||||
# First, find all -L... switches.
|
||||
allParams=("${params[@]}" ${extra[@]})
|
||||
libPath=""
|
||||
addToLibPath() {
|
||||
local path="$1"
|
||||
if test "${path:0:1}" != "/"; then return 0; fi
|
||||
case "$path" in
|
||||
*..*|*./*|*/.*|*//*)
|
||||
local path2
|
||||
if path2=$(readlink -f "$path"); then
|
||||
path="$path2"
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
case $libPath in
|
||||
*\ $path\ *) return 0 ;;
|
||||
esac
|
||||
libPath="$libPath $path "
|
||||
}
|
||||
n=0
|
||||
while test $n -lt ${#allParams[*]}; do
|
||||
p=${allParams[n]}
|
||||
p2=${allParams[$((n+1))]}
|
||||
if test "${p:0:3}" = "-L/"; then
|
||||
addToLibPath ${p:2}
|
||||
elif test "$p" = "-L"; then
|
||||
addToLibPath ${p2}
|
||||
n=$((n + 1))
|
||||
fi
|
||||
n=$((n + 1))
|
||||
done
|
||||
|
||||
# Second, for each -l... switch, find the directory containing the
|
||||
# library and add it to the rpath.
|
||||
rpath=""
|
||||
addToRPath() {
|
||||
# If the path is not in the store, don't add it to the rpath.
|
||||
# This typically happens for libraries in /tmp that are later
|
||||
# copied to $out/lib. If not, we're screwed.
|
||||
if test "${1:0:${#NIX_STORE}}" != "$NIX_STORE"; then return 0; fi
|
||||
case $rpath in
|
||||
*\ $1\ *) return 0 ;;
|
||||
esac
|
||||
rpath="$rpath $1 "
|
||||
}
|
||||
findLib() {
|
||||
for i in $libPath; do
|
||||
if test -f $i/lib$1.so; then
|
||||
addToRPath $i
|
||||
fi
|
||||
done
|
||||
}
|
||||
n=0
|
||||
while test $n -lt ${#allParams[*]}; do
|
||||
p=${allParams[n]}
|
||||
p2=${allParams[$((n+1))]}
|
||||
if test "${p:0:2}" = "-l"; then
|
||||
findLib ${p:2}
|
||||
elif test "$p" = "-l"; then
|
||||
# I haven't seen `-l foo', but you never know...
|
||||
findLib ${p2}
|
||||
n=$((n + 1))
|
||||
fi
|
||||
n=$((n + 1))
|
||||
done
|
||||
|
||||
# Finally, add `-rpath' switches.
|
||||
for i in $rpath; do
|
||||
extra=(${extra[@]} -rpath $i)
|
||||
done
|
||||
fi
|
||||
|
||||
|
||||
# Optionally print debug info.
|
||||
if test "$NIX_DEBUG" = "1"; then
|
||||
echo "original flags to @ld@:" >&2
|
||||
for i in "${params[@]}"; do
|
||||
echo " $i" >&2
|
||||
done
|
||||
echo "extra flags to @ld@:" >&2
|
||||
for i in ${extra[@]}; do
|
||||
echo " $i" >&2
|
||||
done
|
||||
fi
|
||||
|
||||
if test -n "$NIX_LD_WRAPPER_EXEC_HOOK"; then
|
||||
source "$NIX_LD_WRAPPER_EXEC_HOOK"
|
||||
fi
|
||||
|
||||
exec @ld@ ${extraBefore[@]} "${params[@]}" ${extra[@]}
|
29
pkgs/build-support/gcc-upc-wrapper/setup-hook.sh
Normal file
29
pkgs/build-support/gcc-upc-wrapper/setup-hook.sh
Normal file
|
@ -0,0 +1,29 @@
|
|||
addCVars () {
|
||||
if test -d $1/include; then
|
||||
export NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE -I$1/include"
|
||||
fi
|
||||
|
||||
if test -d $1/lib64; then
|
||||
export NIX_LDFLAGS="$NIX_LDFLAGS -L$1/lib64"
|
||||
fi
|
||||
|
||||
if test -d $1/lib; then
|
||||
export NIX_LDFLAGS="$NIX_LDFLAGS -L$1/lib"
|
||||
fi
|
||||
}
|
||||
|
||||
envHooks=(${envHooks[@]} addCVars)
|
||||
|
||||
# Note: these come *after* $out in the PATH (see setup.sh).
|
||||
|
||||
if test -n "@gcc@"; then
|
||||
PATH=$PATH:@gcc@/bin
|
||||
fi
|
||||
|
||||
if test -n "@binutils@"; then
|
||||
PATH=$PATH:@binutils@/bin
|
||||
fi
|
||||
|
||||
if test -n "@libc@"; then
|
||||
PATH=$PATH:@libc@/bin
|
||||
fi
|
23
pkgs/build-support/gcc-upc-wrapper/utils.sh
Normal file
23
pkgs/build-support/gcc-upc-wrapper/utils.sh
Normal file
|
@ -0,0 +1,23 @@
|
|||
skip () {
|
||||
if test "$NIX_DEBUG" = "1"; then
|
||||
echo "skipping impure path $1" >&2
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
# Checks whether a path is impure. E.g., `/lib/foo.so' is impure, but
|
||||
# `/nix/store/.../lib/foo.so' isn't.
|
||||
badPath() {
|
||||
local p=$1
|
||||
|
||||
# Relative paths are okay (since they're presumably relative to
|
||||
# the temporary build directory).
|
||||
if test "${p:0:1}" != "/"; then return 1; fi
|
||||
|
||||
# Otherwise, the path should refer to the store or some temporary
|
||||
# directory (including the build directory).
|
||||
test \
|
||||
"${p:0:${#NIX_STORE}}" != "$NIX_STORE" -a \
|
||||
"${p:0:4}" != "/tmp" -a \
|
||||
"${p:0:${#NIX_BUILD_TOP}}" != "$NIX_BUILD_TOP"
|
||||
}
|
87
pkgs/development/compilers/gcc-upc-4.0/builder.sh
Normal file
87
pkgs/development/compilers/gcc-upc-4.0/builder.sh
Normal file
|
@ -0,0 +1,87 @@
|
|||
source $stdenv/setup
|
||||
|
||||
|
||||
export NIX_FIXINC_DUMMY=$NIX_BUILD_TOP/dummy
|
||||
mkdir $NIX_FIXINC_DUMMY
|
||||
|
||||
|
||||
# libstdc++ needs this; otherwise it will use /lib/cpp, which is a Bad
|
||||
# Thing.
|
||||
export CPP="gcc -E"
|
||||
export CXXCPP="gcc -E"
|
||||
|
||||
|
||||
if test "$noSysDirs" = "1"; then
|
||||
|
||||
if test -e $NIX_GCC/nix-support/orig-libc; then
|
||||
|
||||
# Figure out what extra flags to pass to the gcc compilers
|
||||
# being generated to make sure that they use our glibc.
|
||||
extraCFlags="$(cat $NIX_GCC/nix-support/libc-cflags)"
|
||||
extraLDFlags="$(cat $NIX_GCC/nix-support/libc-ldflags) $(cat $NIX_GCC/nix-support/libc-ldflags-before)"
|
||||
|
||||
# Use *real* header files, otherwise a limits.h is generated
|
||||
# that does not include Glibc's limits.h (notably missing
|
||||
# SSIZE_MAX, which breaks the build).
|
||||
export NIX_FIXINC_DUMMY=$(cat $NIX_GCC/nix-support/orig-libc)/include
|
||||
|
||||
else
|
||||
# Hack: support impure environments.
|
||||
extraCFlags="-isystem /usr/include"
|
||||
extraLDFlags="-L/usr/lib64 -L/usr/lib"
|
||||
export NIX_FIXINC_DUMMY=/usr/include
|
||||
fi
|
||||
|
||||
extraCFlags="-g0 $extraCFlags"
|
||||
extraLDFlags="--strip-debug $extraLDFlags"
|
||||
|
||||
export NIX_EXTRA_CFLAGS=$extraCFlags
|
||||
for i in $extraLDFlags; do
|
||||
export NIX_EXTRA_LDFLAGS="$NIX_EXTRA_LDFLAGS -Wl,$i"
|
||||
done
|
||||
|
||||
export CFLAGS=$extraCFlags
|
||||
export CXXFLAGS=$extraCFlags
|
||||
|
||||
makeFlagsArray=( \
|
||||
NATIVE_SYSTEM_HEADER_DIR="$NIX_FIXINC_DUMMY" \
|
||||
SYSTEM_HEADER_DIR="$NIX_FIXINC_DUMMY" \
|
||||
LIMITS_H_TEST=true \
|
||||
X_CFLAGS="$NIX_EXTRA_CFLAGS $NIX_EXTRA_LDFLAGS" \
|
||||
LDFLAGS="$NIX_EXTRA_CFLAGS $NIX_EXTRA_LDFLAGS" \
|
||||
LDFLAGS_FOR_TARGET="$NIX_EXTRA_CFLAGS $NIX_EXTRA_LDFLAGS" \
|
||||
)
|
||||
fi
|
||||
|
||||
|
||||
preConfigure=preConfigure
|
||||
preConfigure() {
|
||||
# Perform the build in a different directory.
|
||||
mkdir ../build
|
||||
cd ../build
|
||||
configureScript=../$sourceRoot/configure
|
||||
}
|
||||
|
||||
|
||||
postInstall=postInstall
|
||||
postInstall() {
|
||||
# Remove precompiled headers for now. They are very big and
|
||||
# probably not very useful yet.
|
||||
find $out/include -name "*.gch" -exec rm -rf {} \; -prune
|
||||
|
||||
# Remove `fixincl' to prevent a retained dependency on the
|
||||
# previous gcc.
|
||||
rm -rf $out/libexec/gcc/*/*/install-tools
|
||||
|
||||
# Get rid of some "fixed" header files
|
||||
rm -rf $out/lib/gcc/*/*/include/root
|
||||
}
|
||||
|
||||
|
||||
if test -z "$profiledCompiler"; then
|
||||
buildFlags="bootstrap"
|
||||
else
|
||||
buildFlags="profiledbootstrap"
|
||||
fi
|
||||
|
||||
genericBuild
|
59
pkgs/development/compilers/gcc-upc-4.0/default.nix
Normal file
59
pkgs/development/compilers/gcc-upc-4.0/default.nix
Normal file
|
@ -0,0 +1,59 @@
|
|||
# Nix expression for GCC-UPC 4.0, based on that of GCC 4.0.
|
||||
|
||||
{ stdenv, fetchurl, noSysDirs, bison, autoconf, gnum4
|
||||
, profiledCompiler ? false
|
||||
, gmp ? null , mpfr ? null
|
||||
, texinfo ? null
|
||||
}:
|
||||
|
||||
with import ../../../lib;
|
||||
|
||||
# GCC-UPC apparently doesn't support GCov and friends.
|
||||
assert profiledCompiler == false;
|
||||
|
||||
stdenv.mkDerivation {
|
||||
name = "gcc-upc-4.0.3.5";
|
||||
builder = ../gcc-4.0/builder.sh;
|
||||
src = fetchurl {
|
||||
url = "ftp://ftp.intrepid.com/pub/upc/rls/upc-4.0.3.5/upc-4.0.3.5.src.tar.gz";
|
||||
sha256 = "0afnz1bz0kknhl18205bbwncyza08983ivfaagj5yl7x3nwy7prv";
|
||||
};
|
||||
|
||||
patches = [ ./honor-cflags.patch ]
|
||||
++ optional noSysDirs [ ./no-sys-dirs.patch ];
|
||||
|
||||
inherit noSysDirs profiledCompiler;
|
||||
|
||||
# Attributes used by `wrapGCC'.
|
||||
langC = true ;
|
||||
langCC = false;
|
||||
langF77 = false;
|
||||
langUPC = true; # unused
|
||||
|
||||
buildInputs = [gmp mpfr texinfo
|
||||
|
||||
# Bison is needed to build the parsers.
|
||||
bison
|
||||
|
||||
# For some reason, `autoheader' and `m4' are needed.
|
||||
autoconf gnum4];
|
||||
|
||||
# Note: We use `--enable-maintainer-mode' so that `bison' is actually
|
||||
# run when needed.
|
||||
configureFlags = "
|
||||
--disable-multilib
|
||||
--disable-libstdcxx-pch
|
||||
--disable-libmudflap
|
||||
--with-system-zlib
|
||||
${if stdenv.isi686 then "--with-arch=i686" else ""}
|
||||
--enable-maintainer-mode
|
||||
";
|
||||
|
||||
meta = {
|
||||
homepage = http://www.intrepid.com/upc.html;
|
||||
license = "GPL/LGPL";
|
||||
description = ''A GCC-based compiler for the Unified Parallel C (UPC)
|
||||
language, a distributed shared memory aware variant of
|
||||
C (see http://upc.gwu.edu/).'';
|
||||
};
|
||||
}
|
20
pkgs/development/compilers/gcc-upc-4.0/honor-cflags.patch
Normal file
20
pkgs/development/compilers/gcc-upc-4.0/honor-cflags.patch
Normal file
|
@ -0,0 +1,20 @@
|
|||
--- upc-4.0.3.5/gcc/upc/Make-lang.in 2008-03-03 18:56:13.000000000 +0100
|
||||
+++ upc-4.0.3.5/gcc/upc/Make-lang.in 2008-03-03 18:57:27.000000000 +0100
|
||||
@@ -70,7 +70,7 @@ xupc$(exeext): $(srcdir)/upc/upc-cmd.c M
|
||||
"-DLIB_PATH=\"$${libdir}\"" \
|
||||
"-DINC_PATH=\"$${incdir}\"" \
|
||||
-c $(srcdir)/upc/upc-cmd.c -o xupc-tmp.o
|
||||
- $(CC) xupc-tmp.o -o xupc$(exeext) $(LIBS)
|
||||
+ $(CC) xupc-tmp.o $(ALL_CFLAGS) $(LDFLAGS) -o xupc$(exeext) $(LIBS)
|
||||
rm -f xupc-tmp.o
|
||||
|
||||
upc-cmd$(exeext): $(srcdir)/upc/upc-cmd.c Makefile cc1upc$(exeext) $(LIBDEPS)
|
||||
@@ -80,7 +80,7 @@ upc-cmd$(exeext): $(srcdir)/upc/upc-cmd.
|
||||
"-DCOMPILER=\"gcc\"" \
|
||||
"-DBIN_PATH=\"$(bindir)\"" \
|
||||
-c $(srcdir)/upc/upc-cmd.c -o upc-cmd-tmp.o
|
||||
- $(CC) upc-cmd-tmp.o -o upc-cmd$(exeext) $(LIBS)
|
||||
+ $(CC) upc-cmd-tmp.o $(ALL_CFLAGS) $(LDFLAGS) -o upc-cmd$(exeext) $(LIBS)
|
||||
rm -f upc-cmd-tmp.o
|
||||
|
||||
# UPC language specific files.
|
202
pkgs/development/compilers/gcc-upc-4.0/no-sys-dirs.patch
Normal file
202
pkgs/development/compilers/gcc-upc-4.0/no-sys-dirs.patch
Normal file
|
@ -0,0 +1,202 @@
|
|||
diff -rc gcc-4.0.0-orig/gcc/cppdefault.c gcc-4.0.0/gcc/cppdefault.c
|
||||
*** gcc-4.0.0-orig/gcc/cppdefault.c 2004-11-03 04:23:49.000000000 +0100
|
||||
--- gcc-4.0.0/gcc/cppdefault.c 2005-04-22 09:53:28.000000000 +0200
|
||||
***************
|
||||
*** 41,46 ****
|
||||
--- 41,50 ----
|
||||
# undef CROSS_INCLUDE_DIR
|
||||
#endif
|
||||
|
||||
+ #undef LOCAL_INCLUDE_DIR
|
||||
+ #undef SYSTEM_INCLUDE_DIR
|
||||
+ #undef STANDARD_INCLUDE_DIR
|
||||
+
|
||||
const struct default_include cpp_include_defaults[]
|
||||
#ifdef INCLUDE_DEFAULTS
|
||||
= INCLUDE_DEFAULTS;
|
||||
diff -rc gcc-4.0.0-orig/gcc/Makefile.in gcc-4.0.0/gcc/Makefile.in
|
||||
*** gcc-4.0.0-orig/gcc/Makefile.in 2005-04-04 21:45:13.000000000 +0200
|
||||
--- gcc-4.0.0/gcc/Makefile.in 2005-04-22 10:38:50.000000000 +0200
|
||||
***************
|
||||
*** 213,219 ****
|
||||
CPPFLAGS = @CPPFLAGS@
|
||||
|
||||
# These exists to be overridden by the x-* and t-* files, respectively.
|
||||
! X_CFLAGS =
|
||||
T_CFLAGS =
|
||||
|
||||
X_CPPFLAGS =
|
||||
--- 213,219 ----
|
||||
CPPFLAGS = @CPPFLAGS@
|
||||
|
||||
# These exists to be overridden by the x-* and t-* files, respectively.
|
||||
! X_CFLAGS = $(NIX_EXTRA_CFLAGS) $(NIX_EXTRA_LDFLAGS)
|
||||
T_CFLAGS =
|
||||
|
||||
X_CPPFLAGS =
|
||||
***************
|
||||
*** 373,379 ****
|
||||
MD5_H = $(srcdir)/../include/md5.h
|
||||
|
||||
# Default native SYSTEM_HEADER_DIR, to be overridden by targets.
|
||||
! NATIVE_SYSTEM_HEADER_DIR = /usr/include
|
||||
# Default cross SYSTEM_HEADER_DIR, to be overridden by targets.
|
||||
CROSS_SYSTEM_HEADER_DIR = @CROSS_SYSTEM_HEADER_DIR@
|
||||
|
||||
--- 373,383 ----
|
||||
MD5_H = $(srcdir)/../include/md5.h
|
||||
|
||||
# Default native SYSTEM_HEADER_DIR, to be overridden by targets.
|
||||
! # Nix: we override NATIVE_SYSTEM_HEADER_DIR in order to prevent
|
||||
! # `fixinc' from fixing header files in /usr/include. However,
|
||||
! # NATIVE_SYSTEM_HEADER_DIR must point to an existing directory, so set
|
||||
! # it to some dummy directory.
|
||||
! NATIVE_SYSTEM_HEADER_DIR = $(NIX_FIXINC_DUMMY)
|
||||
# Default cross SYSTEM_HEADER_DIR, to be overridden by targets.
|
||||
CROSS_SYSTEM_HEADER_DIR = @CROSS_SYSTEM_HEADER_DIR@
|
||||
|
||||
***************
|
||||
*** 385,391 ****
|
||||
STMP_FIXINC = @STMP_FIXINC@
|
||||
|
||||
# Test to see whether <limits.h> exists in the system header files.
|
||||
! LIMITS_H_TEST = [ -f $(SYSTEM_HEADER_DIR)/limits.h ]
|
||||
|
||||
# Directory for prefix to system directories, for
|
||||
# each of $(system_prefix)/usr/include, $(system_prefix)/usr/lib, etc.
|
||||
--- 389,395 ----
|
||||
STMP_FIXINC = @STMP_FIXINC@
|
||||
|
||||
# Test to see whether <limits.h> exists in the system header files.
|
||||
! LIMITS_H_TEST = true
|
||||
|
||||
# Directory for prefix to system directories, for
|
||||
# each of $(system_prefix)/usr/include, $(system_prefix)/usr/lib, etc.
|
||||
***************
|
||||
*** 2677,2683 ****
|
||||
-DGPLUSPLUS_INCLUDE_DIR=\"$(gcc_gxx_include_dir)\" \
|
||||
-DGPLUSPLUS_TOOL_INCLUDE_DIR=\"$(gcc_gxx_include_dir)/$(target_noncanonical)\" \
|
||||
-DGPLUSPLUS_BACKWARD_INCLUDE_DIR=\"$(gcc_gxx_include_dir)/backward\" \
|
||||
! -DLOCAL_INCLUDE_DIR=\"$(local_includedir)\" \
|
||||
-DCROSS_INCLUDE_DIR=\"$(CROSS_SYSTEM_HEADER_DIR)\" \
|
||||
-DTOOL_INCLUDE_DIR=\"$(gcc_tooldir)/include\" \
|
||||
@TARGET_SYSTEM_ROOT_DEFINE@
|
||||
--- 2681,2687 ----
|
||||
-DGPLUSPLUS_INCLUDE_DIR=\"$(gcc_gxx_include_dir)\" \
|
||||
-DGPLUSPLUS_TOOL_INCLUDE_DIR=\"$(gcc_gxx_include_dir)/$(target_noncanonical)\" \
|
||||
-DGPLUSPLUS_BACKWARD_INCLUDE_DIR=\"$(gcc_gxx_include_dir)/backward\" \
|
||||
! -DLOCAL_INCLUDE_DIR=\"/no-such-dir\" \
|
||||
-DCROSS_INCLUDE_DIR=\"$(CROSS_SYSTEM_HEADER_DIR)\" \
|
||||
-DTOOL_INCLUDE_DIR=\"$(gcc_tooldir)/include\" \
|
||||
@TARGET_SYSTEM_ROOT_DEFINE@
|
||||
diff -rc gcc-4.0.0-orig/ltcf-cxx.sh gcc-4.0.0/ltcf-cxx.sh
|
||||
*** gcc-4.0.0-orig/ltcf-cxx.sh 2004-10-02 18:33:06.000000000 +0200
|
||||
--- gcc-4.0.0/ltcf-cxx.sh 2005-04-22 09:53:28.000000000 +0200
|
||||
***************
|
||||
*** 988,994 ****
|
||||
# the conftest object file.
|
||||
pre_test_object_deps_done=no
|
||||
|
||||
! for p in `eval $output_verbose_link_cmd`; do
|
||||
|
||||
case $p in
|
||||
|
||||
--- 988,994 ----
|
||||
# the conftest object file.
|
||||
pre_test_object_deps_done=no
|
||||
|
||||
! for p in `true`; do
|
||||
|
||||
case $p in
|
||||
|
||||
Only in gcc-4.0.0: ltcf-cxx.sh.orig
|
||||
diff -rc gcc-4.0.0-orig/ltconfig gcc-4.0.0/ltconfig
|
||||
*** gcc-4.0.0-orig/ltconfig 2004-10-02 18:33:06.000000000 +0200
|
||||
--- gcc-4.0.0/ltconfig 2005-04-22 13:33:33.000000000 +0200
|
||||
***************
|
||||
*** 2321,2326 ****
|
||||
--- 2321,2331 ----
|
||||
# A language-specific compiler.
|
||||
CC=$CC
|
||||
|
||||
+ # Ugly hack to get libmudflap (and possibly other libraries) to build.
|
||||
+ # Libtool filters out \`-B' flags when linking (why?), so the \`-B' flag
|
||||
+ # to Glibc gets lost. Here we forcibly add it to any invocation.
|
||||
+ CC="\$CC $NIX_EXTRA_LDFLAGS"
|
||||
+
|
||||
# Is the compiler the GNU C compiler?
|
||||
with_gcc=$with_gcc
|
||||
|
||||
Only in gcc-4.0.0: ltconfig~
|
||||
diff -rc gcc-4.0.0-orig/Makefile.in gcc-4.0.0/Makefile.in
|
||||
*** gcc-4.0.0-orig/Makefile.in 2005-04-21 09:04:10.000000000 +0200
|
||||
--- gcc-4.0.0/Makefile.in 2005-04-22 09:53:28.000000000 +0200
|
||||
***************
|
||||
*** 336,342 ****
|
||||
NM = @NM@
|
||||
|
||||
LD = @LD@
|
||||
! LDFLAGS =
|
||||
|
||||
RANLIB = @RANLIB@
|
||||
|
||||
--- 336,342 ----
|
||||
NM = @NM@
|
||||
|
||||
LD = @LD@
|
||||
! LDFLAGS = $(NIX_EXTRA_LDFLAGS)
|
||||
|
||||
RANLIB = @RANLIB@
|
||||
|
||||
***************
|
||||
*** 387,393 ****
|
||||
# CFLAGS will be just -g. We want to ensure that TARGET libraries
|
||||
# (which we know are built with gcc) are built with optimizations so
|
||||
# prepend -O2 when setting CFLAGS_FOR_TARGET.
|
||||
! CFLAGS_FOR_TARGET = -O2 $(CFLAGS)
|
||||
# If GCC_FOR_TARGET is not overriden on the command line, then this
|
||||
# variable is passed down to the gcc Makefile, where it is used to
|
||||
# build libgcc2.a. We define it here so that it can itself be
|
||||
--- 387,393 ----
|
||||
# CFLAGS will be just -g. We want to ensure that TARGET libraries
|
||||
# (which we know are built with gcc) are built with optimizations so
|
||||
# prepend -O2 when setting CFLAGS_FOR_TARGET.
|
||||
! CFLAGS_FOR_TARGET = -O2 $(CFLAGS) $(NIX_EXTRA_CFLAGS)
|
||||
# If GCC_FOR_TARGET is not overriden on the command line, then this
|
||||
# variable is passed down to the gcc Makefile, where it is used to
|
||||
# build libgcc2.a. We define it here so that it can itself be
|
||||
***************
|
||||
*** 400,406 ****
|
||||
RAW_CXX_FOR_TARGET = @RAW_CXX_FOR_TARGET@
|
||||
CXX_FOR_TARGET_FOR_RECURSIVE_MAKE = @CXX_FOR_TARGET_FOR_RECURSIVE_MAKE@
|
||||
RAW_CXX_FOR_TARGET_FOR_RECURSIVE_MAKE = @RAW_CXX_FOR_TARGET_FOR_RECURSIVE_MAKE@
|
||||
! CXXFLAGS_FOR_TARGET = $(CXXFLAGS)
|
||||
LIBCXXFLAGS_FOR_TARGET = $(CXXFLAGS_FOR_TARGET) -fno-implicit-templates
|
||||
|
||||
DLLTOOL_FOR_TARGET=@DLLTOOL_FOR_TARGET@
|
||||
--- 400,406 ----
|
||||
RAW_CXX_FOR_TARGET = @RAW_CXX_FOR_TARGET@
|
||||
CXX_FOR_TARGET_FOR_RECURSIVE_MAKE = @CXX_FOR_TARGET_FOR_RECURSIVE_MAKE@
|
||||
RAW_CXX_FOR_TARGET_FOR_RECURSIVE_MAKE = @RAW_CXX_FOR_TARGET_FOR_RECURSIVE_MAKE@
|
||||
! CXXFLAGS_FOR_TARGET = $(CXXFLAGS) $(NIX_EXTRA_CFLAGS)
|
||||
LIBCXXFLAGS_FOR_TARGET = $(CXXFLAGS_FOR_TARGET) -fno-implicit-templates
|
||||
|
||||
DLLTOOL_FOR_TARGET=@DLLTOOL_FOR_TARGET@
|
||||
***************
|
||||
*** 434,440 ****
|
||||
fi; \
|
||||
fi`
|
||||
|
||||
! LDFLAGS_FOR_TARGET =
|
||||
|
||||
NM_FOR_TARGET=@NM_FOR_TARGET@
|
||||
CONFIGURED_NM_FOR_TARGET=@CONFIGURED_NM_FOR_TARGET@
|
||||
--- 434,440 ----
|
||||
fi; \
|
||||
fi`
|
||||
|
||||
! LDFLAGS_FOR_TARGET = $(NIX_EXTRA_LDFLAGS)
|
||||
|
||||
NM_FOR_TARGET=@NM_FOR_TARGET@
|
||||
CONFIGURED_NM_FOR_TARGET=@CONFIGURED_NM_FOR_TARGET@
|
||||
Only in gcc-4.0.0: Makefile.in.orig
|
|
@ -1186,6 +1186,11 @@ rec {
|
|||
profiledCompiler = true;
|
||||
});
|
||||
|
||||
gccupc40 = wrapGCCUPC (import ../development/compilers/gcc-upc-4.0 {
|
||||
inherit fetchurl stdenv bison autoconf gnum4 noSysDirs;
|
||||
texinfo = texinfo49;
|
||||
});
|
||||
|
||||
# This new ghc stuff is under heavy development and will change !
|
||||
# ===============================================================
|
||||
|
||||
|
@ -1657,6 +1662,17 @@ rec {
|
|||
};
|
||||
|
||||
|
||||
# FIXME: This is a specific hack for GCC-UPC. Eventually, we may
|
||||
# want to merge `gcc-upc-wrapper' and `gcc-wrapper'.
|
||||
wrapGCCUPC = baseGCC: import ../build-support/gcc-upc-wrapper {
|
||||
nativeTools = stdenv ? gcc && stdenv.gcc.nativeTools;
|
||||
nativeLibc = stdenv ? gcc && stdenv.gcc.nativeLibc;
|
||||
gcc = baseGCC;
|
||||
libc = glibc;
|
||||
inherit stdenv binutils;
|
||||
};
|
||||
|
||||
|
||||
### DEVELOPMENT / INTERPRETERS
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue