parent
fe565510cb
commit
c69d8bf5e6
@ -1,122 +0,0 @@ |
||||
#! @shell@ |
||||
set -eu -o pipefail +o posix |
||||
shopt -s nullglob |
||||
|
||||
if (( "${NIX_DEBUG:-0}" >= 7 )); then |
||||
set -x |
||||
fi |
||||
|
||||
# N.B. Gnat is not used during bootstrapping, so we don't need to |
||||
# worry about the old bash empty array `set -u` workarounds. |
||||
|
||||
path_backup="$PATH" |
||||
|
||||
# phase separation makes this look useless |
||||
# shellcheck disable=SC2157 |
||||
if [ -n "@coreutils_bin@" ]; then |
||||
PATH="@coreutils_bin@/bin" |
||||
fi |
||||
|
||||
source @out@/nix-support/utils.sh |
||||
|
||||
if [ -z "${NIX_@infixSalt@_GNAT_WRAPPER_FLAGS_SET:-}" ]; then |
||||
source @out@/nix-support/add-flags.sh |
||||
fi |
||||
|
||||
|
||||
# Figure out if linker flags should be passed. GCC prints annoying |
||||
# warnings when they are not needed. |
||||
dontLink=0 |
||||
nonFlagArgs=0 |
||||
|
||||
for i in "$@"; do |
||||
if [ "$i" = -c ]; then |
||||
dontLink=1 |
||||
elif [ "$i" = -M ]; then |
||||
dontLink=1 |
||||
elif [ "${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 [ "$nonFlagArgs" = 0 ]; then |
||||
dontLink=1 |
||||
fi |
||||
|
||||
|
||||
# Optionally filter out paths not refering to the store. |
||||
params=("$@") |
||||
if [[ "${NIX_ENFORCE_PURITY:-}" = 1 && -n "$NIX_STORE" ]]; then |
||||
rest=() |
||||
for p in "${params[@]}"; do |
||||
if [ "${p:0:3}" = -L/ ] && badPath "${p:2}"; then |
||||
skip "${p:2}" |
||||
elif [ "${p:0:3}" = -I/ ] && badPath "${p:2}"; then |
||||
skip "${p:2}" |
||||
elif [ "${p:0:4}" = -aI/ ] && badPath "${p:3}"; then |
||||
skip "${p:2}" |
||||
elif [ "${p:0:4}" = -aO/ ] && badPath "${p:3}"; then |
||||
skip "${p:2}" |
||||
else |
||||
rest+=("$p") |
||||
fi |
||||
done |
||||
params=("${rest[@]}") |
||||
fi |
||||
|
||||
|
||||
# Clear march/mtune=native -- they bring impurity. |
||||
if [ "$NIX_@infixSalt@_ENFORCE_NO_NATIVE" = 1 ]; then |
||||
rest=() |
||||
for p in "${params[@]}"; do |
||||
if [[ "$p" = -m*=native ]]; then |
||||
skip "$p" |
||||
else |
||||
rest+=("$p") |
||||
fi |
||||
done |
||||
params=("${rest[@]}") |
||||
fi |
||||
|
||||
|
||||
# Add the flags for the GNAT compiler proper. |
||||
extraAfter=($NIX_@infixSalt@_GNATFLAGS_COMPILE) |
||||
extraBefore=() |
||||
|
||||
if [ "$(basename "$0")x" = "gnatmakex" ]; then |
||||
extraBefore=("--GNATBIND=@out@/bin/gnatbind" "--GNATLINK=@out@/bin/gnatlink ") |
||||
fi |
||||
|
||||
#if [ "$dontLink" != 1 ]; then |
||||
# # Add the flags that should be passed to the linker (and prevent |
||||
# # `ld-wrapper' from adding NIX_@infixSalt@_LDFLAGS again). |
||||
# for i in $NIX_@infixSalt@_LDFLAGS_BEFORE; do |
||||
# extraBefore+=("-largs" "$i") |
||||
# done |
||||
# for i in $NIX_@infixSalt@_LDFLAGS; do |
||||
# if [ "${i:0:3}" = -L/ ]; then |
||||
# extraAfter+=("$i") |
||||
# else |
||||
# extraAfter+=("-largs" "$i") |
||||
# fi |
||||
# done |
||||
# export NIX_@infixSalt@_LDFLAGS_SET=1 |
||||
#fi |
||||
|
||||
# Optionally print debug info. |
||||
if (( "${NIX_DEBUG:-0}" >= 1 )); then |
||||
echo "extra flags before to @prog@:" >&2 |
||||
printf " %q\n" "${extraBefore[@]}" >&2 |
||||
echo "original flags to @prog@:" >&2 |
||||
printf " %q\n" "${params[@]}" >&2 |
||||
echo "extra flags after to @prog@:" >&2 |
||||
printf " %q\n" "${extraAfter[@]}" >&2 |
||||
fi |
||||
|
||||
PATH="$path_backup" |
||||
exec @prog@ "${extraBefore[@]}" "${params[@]}" "${extraAfter[@]}" |
@ -1,40 +0,0 @@ |
||||
#! @shell@ |
||||
set -eu -o pipefail +o posix |
||||
shopt -s nullglob |
||||
|
||||
if (( "${NIX_DEBUG:-0}" >= 7 )); then |
||||
set -x |
||||
fi |
||||
|
||||
# N.B. Gnat is not used during bootstrapping, so we don't need to |
||||
# worry about the old bash empty array `set -u` workarounds. |
||||
|
||||
# Add the flags for the GNAT compiler proper. |
||||
extraAfter=("--GCC=@out@/bin/gcc") |
||||
extraBefore=() |
||||
|
||||
## Add the flags that should be passed to the linker (and prevent |
||||
## `ld-wrapper' from adding NIX_@infixSalt@_LDFLAGS again). |
||||
#for i in $NIX_@infixSalt@_LDFLAGS_BEFORE; do |
||||
# extraBefore+=("-largs" "$i") |
||||
#done |
||||
#for i in $NIX_@infixSalt@_LDFLAGS; do |
||||
# if [ "${i:0:3}" = -L/ ]; then |
||||
# extraAfter+=("$i") |
||||
# else |
||||
# extraAfter+=("-largs" "$i") |
||||
# fi |
||||
#done |
||||
#export NIX_@infixSalt@_LDFLAGS_SET=1 |
||||
|
||||
# Optionally print debug info. |
||||
if (( "${NIX_DEBUG:-0}" >= 1 )); then |
||||
echo "extra flags before to @prog@:" >&2 |
||||
printf " %q\n" "${extraBefore[@]}" >&2 |
||||
echo "original flags to @prog@:" >&2 |
||||
printf " %q\n" "$@" >&2 |
||||
echo "extra flags after to @prog@:" >&2 |
||||
printf " %q\n" "${extraAfter[@]}" >&2 |
||||
fi |
||||
|
||||
exec @prog@ "${extraBefore[@]}" "$@" "${extraAfter[@]}" |
@ -1,28 +0,0 @@ |
||||
# `-B@out@/bin' forces cc 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/cc-cflags; then |
||||
export NIX_CFLAGS_COMPILE="$(cat @out@/nix-support/cc-cflags) $NIX_CFLAGS_COMPILE" |
||||
fi |
||||
|
||||
if test -e @out@/nix-support/gnat-cflags; then |
||||
export NIX_GNATFLAGS_COMPILE="$(cat @out@/nix-support/gnat-cflags) $NIX_GNATFLAGS_COMPILE" |
||||
fi |
||||
|
||||
if test -e @out@/nix-support/libc-ldflags; then |
||||
export NIX_LDFLAGS="$NIX_LDFLAGS $(cat @out@/nix-support/libc-ldflags)" |
||||
fi |
||||
|
||||
if test -e @out@/nix-support/cc-ldflags; then |
||||
export NIX_LDFLAGS="$NIX_LDFLAGS $(cat @out@/nix-support/cc-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_CC_WRAPPER_FLAGS_SET=1 |
@ -1,215 +0,0 @@ |
||||
source $stdenv/setup |
||||
|
||||
|
||||
mkdir -p $out/bin |
||||
mkdir -p $out/nix-support |
||||
|
||||
|
||||
if test -z "$nativeLibc"; then |
||||
dynamicLinker="$libc/lib/$dynamicLinker" |
||||
echo $dynamicLinker > $out/nix-support/dynamic-linker |
||||
|
||||
if test -e $libc/lib/32/ld-linux.so.2; then |
||||
echo $libc/lib/32/ld-linux.so.2 > $out/nix-support/dynamic-linker-m32 |
||||
fi |
||||
|
||||
# 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.) |
||||
# |
||||
# Unfortunately, setting -B appears to override the default search |
||||
# path. Thus, the gcc-specific "../includes-fixed" directory is |
||||
# now longer searched and glibc's <limits.h> header fails to |
||||
# compile, because it uses "#include_next <limits.h>" to find the |
||||
# limits.h file in ../includes-fixed. To remedy the problem, |
||||
# another -idirafter is necessary to add that directory again. |
||||
echo "-B$libc/lib/ -idirafter $libc_dev/include -idirafter $gcc/lib/gcc/*/*/include-fixed" > $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_lib/lib64" |
||||
fi |
||||
gccLDFlags="$gccLDFlags -L$gcc_lib/lib" |
||||
if [ -n "$langVhdl" ]; then |
||||
gccLDFlags="$gccLDFlags -L$zlib/lib" |
||||
fi |
||||
echo "$gccLDFlags" > $out/nix-support/cc-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 |
||||
|
||||
# Find the gcc libraries path (may work only without multilib) |
||||
if [ -n "$langAda" ]; then |
||||
basePath=`echo $gcc/lib/*/*/*` |
||||
gccCFlags="$gccCFlags -B$basePath -I$basePath/adainclude" |
||||
|
||||
gnatCFlags="-aI$basePath/adainclude -aO$basePath/adalib" |
||||
echo "$gnatCFlags" > $out/nix-support/gnat-cflags |
||||
fi |
||||
echo "$gccCFlags" > $out/nix-support/cc-cflags |
||||
|
||||
gccPath="$gcc/bin" |
||||
# On Illumos/Solaris we might prefer native ld |
||||
if test -n "$nativePrefix"; then |
||||
ldPath="$nativePrefix/bin" |
||||
else |
||||
ldPath="$binutils/bin" |
||||
fi; |
||||
fi |
||||
|
||||
|
||||
doSubstitute() { |
||||
local src=$1 |
||||
local dst=$2 |
||||
local ld="$ldPath/ld" |
||||
if $ld -V 2>&1 |grep Solaris; then |
||||
# Use Solaris specific linker wrapper |
||||
ld="$out/bin/ld-solaris" |
||||
fi |
||||
# 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^@gnatProg@^$gnatProg^g" \ |
||||
-e "s^@gnatlinkProg@^$gnatlinkProg^g" \ |
||||
-e "s^@binutils@^$binutils^g" \ |
||||
-e "s^@coreutils@^$coreutils^g" \ |
||||
-e "s^@libc@^$libc^g" \ |
||||
-e "s^@libc_bin@^$libc_bin^g" \ |
||||
-e "s^@ld@^$ld^g" \ |
||||
< "$src" > "$dst" |
||||
} |
||||
|
||||
|
||||
# Make wrapper scripts around gcc, g++, and gfortran. 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 1 |
||||
fi |
||||
|
||||
gccProg="$src" |
||||
doSubstitute "$gccWrapper" "$dst" |
||||
chmod +x "$dst" |
||||
} |
||||
|
||||
mkGnatWrapper() { |
||||
local dst=$1 |
||||
local src=$2 |
||||
|
||||
if ! test -f "$src"; then |
||||
echo "$src does not exist (skipping)" |
||||
return 1 |
||||
fi |
||||
|
||||
gnatProg="$src" |
||||
doSubstitute "$gnatWrapper" "$dst" |
||||
chmod +x "$dst" |
||||
} |
||||
|
||||
mkGnatLinkWrapper() { |
||||
local dst=$1 |
||||
local src=$2 |
||||
|
||||
if ! test -f "$src"; then |
||||
echo "$src does not exist (skipping)" |
||||
return 1 |
||||
fi |
||||
|
||||
gnatlinkProg="$src" |
||||
doSubstitute "$gnatlinkWrapper" "$dst" |
||||
chmod +x "$dst" |
||||
} |
||||
|
||||
if mkGccWrapper $out/bin/gcc $gccPath/gcc |
||||
then |
||||
ln -sv gcc $out/bin/cc |
||||
fi |
||||
|
||||
if mkGccWrapper $out/bin/g++ $gccPath/g++ |
||||
then |
||||
ln -sv g++ $out/bin/c++ |
||||
fi |
||||
|
||||
mkGccWrapper $out/bin/cpp $gccPath/cpp || true |
||||
|
||||
if mkGccWrapper $out/bin/gfortran $gccPath/gfortran |
||||
then |
||||
ln -sv gfortran $out/bin/g77 |
||||
ln -sv gfortran $out/bin/f77 |
||||
fi |
||||
|
||||
mkGccWrapper $out/bin/gcj $gccPath/gcj || true |
||||
|
||||
mkGccWrapper $out/bin/gccgo $gccPath/gccgo || true |
||||
|
||||
mkGccWrapper $out/bin/gnatgcc $gccPath/gnatgcc || true |
||||
mkGnatWrapper $out/bin/gnatmake $gccPath/gnatmake || true |
||||
mkGnatWrapper $out/bin/gnatbind $gccPath/gnatbind || true |
||||
mkGnatLinkWrapper $out/bin/gnatlink $gccPath/gnatlink || true |
||||
|
||||
if [ -f $gccPath/ghdl ]; then |
||||
ln -sf $gccPath/ghdl $out/bin/ghdl |
||||
fi |
||||
|
||||
|
||||
# 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" |
||||
|
||||
# Copy solaris ld wrapper if needed |
||||
if $ldPath/ld -V 2>&1 |grep Solaris; then |
||||
# Use Solaris specific linker wrapper |
||||
sed -e "s^@ld@^$ldPath/ld^g" < "$ldSolarisWrapper" > "$out/bin/ld-solaris" |
||||
chmod +x "$out/bin/ld-solaris" |
||||
fi |
||||
|
||||
|
||||
# Emit a setup hook. Also store the path to the original GCC and |
||||
# Glibc. |
||||
test -n "$gcc" && echo $gcc > $out/nix-support/orig-cc |
||||
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 |
||||
printWords $gcc $binutils $libc $libc_bin > $out/nix-support/propagated-user-env-packages |
||||
fi |
@ -1,76 +0,0 @@ |
||||
# 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, lib, nativeTools, nativeLibc, nativePrefix ? "" |
||||
, gcc ? null, libc ? null, binutils ? null, coreutils ? null, shell ? stdenv.shell |
||||
, zlib ? null |
||||
, hostPlatform, targetPlatform, targetPackages |
||||
}: |
||||
|
||||
assert nativeTools -> nativePrefix != ""; |
||||
assert !nativeTools -> gcc != null && binutils != null && coreutils != null; |
||||
assert !nativeLibc -> libc != null; |
||||
|
||||
# For ghdl (the vhdl language provider to gcc) we need zlib in the wrapper |
||||
assert (gcc != null && gcc ? langVhdl && gcc.langVhdl) -> zlib != null; |
||||
|
||||
let |
||||
|
||||
gccVersion = (builtins.parseDrvName gcc.name).version; |
||||
gccName = (builtins.parseDrvName gcc.name).name; |
||||
|
||||
langGo = if nativeTools then false else gcc ? langGo && gcc.langGo; |
||||
in |
||||
|
||||
stdenv.mkDerivation { |
||||
name = |
||||
(if name != "" then name else gccName + "-wrapper") + |
||||
(if gcc != null && gccVersion != "" then "-" + gccVersion else ""); |
||||
|
||||
builder = ./builder.sh; |
||||
setupHook = ./setup-hook.sh; |
||||
gccWrapper = ./gcc-wrapper.sh; |
||||
gnatWrapper = ./gnat-wrapper.sh; |
||||
gnatlinkWrapper = ./gnatlink-wrapper.sh; |
||||
ldWrapper = ./ld-wrapper.sh; |
||||
ldSolarisWrapper = ./ld-solaris-wrapper.sh; |
||||
utils = ./utils.sh; |
||||
addFlags = ./add-flags; |
||||
|
||||
inherit nativeTools nativeLibc nativePrefix gcc; |
||||
gcc_lib = lib.getLib gcc; |
||||
libc = if nativeLibc then null else libc; |
||||
libc_dev = if nativeLibc then null else lib.getDev libc; |
||||
libc_bin = if nativeLibc then null else lib.getBin libc; |
||||
binutils = if nativeTools then null else lib.getBin binutils; |
||||
# The wrapper scripts use 'cat', so we may need coreutils |
||||
coreutils = if nativeTools then null else lib.getBin coreutils; |
||||
|
||||
langC = if nativeTools then true else gcc.langC; |
||||
langCC = if nativeTools then true else gcc.langCC; |
||||
langFortran = if nativeTools then false else gcc ? langFortran; |
||||
langAda = if nativeTools then false else gcc ? langAda && gcc.langAda; |
||||
langVhdl = if nativeTools then false else gcc ? langVhdl && gcc.langVhdl; |
||||
zlib = if gcc != null && gcc ? langVhdl then zlib else null; |
||||
shell = shell + shell.shellPath or ""; |
||||
|
||||
preferLocalBuild = true; |
||||
|
||||
meta = |
||||
let gcc_ = if gcc != null then gcc else {}; in |
||||
(if gcc_ ? meta then removeAttrs gcc.meta ["priority"] else {}) // |
||||
{ description = |
||||
stdenv.lib.attrByPath ["meta" "description"] "System C compiler" gcc_ |
||||
+ " (wrapper script)"; |
||||
}; |
||||
|
||||
# The dynamic linker has different names on different platforms. |
||||
dynamicLinker = |
||||
if !nativeLibc then |
||||
targetPackages.stdenv.cc.bintools.dynamicLinker |
||||
else ""; |
||||
} |
@ -1,146 +0,0 @@ |
||||
#! @shell@ -e |
||||
|
||||
if [ -n "$NIX_CC_WRAPPER_START_HOOK" ]; then |
||||
source "$NIX_CC_WRAPPER_START_HOOK" |
||||
fi |
||||
|
||||
if [ -z "$NIX_CC_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 [ "$i" = -c ]; then |
||||
dontLink=1 |
||||
elif [ "$i" = -S ]; then |
||||
dontLink=1 |
||||
elif [ "$i" = -E ]; then |
||||
dontLink=1 |
||||
elif [ "$i" = -E ]; then |
||||
dontLink=1 |
||||
elif [ "$i" = -M ]; then |
||||
dontLink=1 |
||||
elif [ "$i" = -MM ]; then |
||||
dontLink=1 |
||||
elif [ "$i" = -x ]; then |
||||
# At least for the cases c-header or c++-header we should set dontLink. |
||||
# I expect no one use -x other than making precompiled headers. |
||||
dontLink=1 |
||||
elif [ "${i:0:1}" != - ]; then |
||||
nonFlagArgs=1 |
||||
elif [ "$i" = -m32 ]; then |
||||
if [ -e @out@/nix-support/dynamic-linker-m32 ]; then |
||||
NIX_LDFLAGS="$NIX_LDFLAGS -dynamic-linker $(cat @out@/nix-support/dynamic-linker-m32)" |
||||
fi |
||||
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 [ "$nonFlagArgs" = 0 ]; then |
||||
dontLink=1 |
||||
fi |
||||
|
||||
|
||||
# Optionally filter out paths not refering to the store. |
||||
params=("$@") |
||||
if [ "$NIX_ENFORCE_PURITY" = 1 -a -n "$NIX_STORE" ]; then |
||||
rest=() |
||||
n=0 |
||||
while [ $n -lt ${#params[*]} ]; do |
||||
p=${params[n]} |
||||
p2=${params[$((n+1))]} |
||||
if [ "${p:0:3}" = -L/ ] && badPath "${p:2}"; then |
||||
skip $p |
||||
elif [ "$p" = -L ] && badPath "$p2"; then |
||||
n=$((n + 1)); skip $p2 |
||||
elif [ "${p:0:3}" = -I/ ] && badPath "${p:2}"; then |
||||
skip $p |
||||
elif [ "$p" = -I ] && badPath "$p2"; then |
||||
n=$((n + 1)); skip $p2 |
||||
elif [ "$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=() |
||||
|
||||
# When enforcing purity, pretend gcc can't find the current date and |
||||
# time |
||||
if [ "$NIX_ENFORCE_PURITY" = 1 ]; then |
||||
extraAfter+=('-D__DATE__="Jan 01 1970"' |
||||
'-D__TIME__="00:00:01"' |
||||
) |
||||
fi |
||||
|
||||
|
||||
if [ "$dontLink" != 1 ]; then |
||||
|
||||
# Add the flags that should only be passed to the compiler when |
||||
# linking. |
||||
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 [ "${i:0:3}" = -L/ ]; then |
||||
extraAfter+=("$i") |
||||
else |
||||
extraAfter+=("-Wl,$i") |
||||
fi |
||||
done |
||||
export NIX_LDFLAGS_SET=1 |
||||
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 [ "$*" = -v ]; then |
||||
extraAfter=() |
||||
extraBefore=() |
||||
fi |
||||
|
||||
# Optionally print debug info. |
||||
if [ -n "$NIX_DEBUG" ]; then |
||||
echo "original flags to @prog@:" >&2 |
||||
for i in "${params[@]}"; do |
||||
echo " $i" >&2 |
||||
done |
||||
echo "extraBefore flags to @prog@:" >&2 |
||||
for i in ${extraBefore[@]}; do |
||||
echo " $i" >&2 |
||||
done |
||||
echo "extraAfter flags to @prog@:" >&2 |
||||
for i in ${extraAfter[@]}; do |
||||
echo " $i" >&2 |
||||
done |
||||
fi |
||||
|
||||
if [ -n "$NIX_CC_WRAPPER_EXEC_HOOK" ]; then |
||||
source "$NIX_CC_WRAPPER_EXEC_HOOK" |
||||
fi |
||||
|
||||
exec @prog@ ${extraBefore[@]} "${params[@]}" "${extraAfter[@]}" |
@ -1,147 +0,0 @@ |
||||
#! @shell@ -e |
||||
|
||||
if test -n "$NIX_CC_WRAPPER_START_HOOK"; then |
||||
source "$NIX_CC_WRAPPER_START_HOOK" |
||||
fi |
||||
|
||||
if test -z "$NIX_CC_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" = "-x"; then |
||||
# At least for the cases c-header or c++-header we should set dontLink. |
||||
# I expect no one use -x other than making precompiled headers. |
||||
dontLink=1 |
||||
elif test "${i:0:1}" != "-"; then |
||||
nonFlagArgs=1 |
||||
elif test "$i" = "-m32"; then |
||||
if test -e @out@/nix-support/dynamic-linker-m32; then |
||||
NIX_LDFLAGS="$NIX_LDFLAGS -dynamic-linker $(cat @out@/nix-support/dynamic-linker-m32)" |
||||
fi |
||||
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 |
||||
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_CC_WRAPPER_EXEC_HOOK"; then |
||||
source "$NIX_CC_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_CC_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 |
@ -1,113 +0,0 @@ |
||||
#! @shell@ -e |
||||
|
||||
if test -n "$NIX_GNAT_WRAPPER_START_HOOK"; then |
||||
source "$NIX_GNAT_WRAPPER_START_HOOK" |
||||
fi |
||||
|
||||
if test -z "$NIX_GNAT_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" = "-M"; then |
||||
dontLink=1 |
||||
elif test "${i:0:1}" != "-"; then |
||||
nonFlagArgs=1 |
||||
elif test "$i" = "-m32"; then |
||||
if test -e @out@/nix-support/dynamic-linker-m32; then |
||||
NIX_LDFLAGS="$NIX_LDFLAGS -dynamic-linker $(cat @out@/nix-support/dynamic-linker-m32)" |
||||
fi |
||||
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:0:3}" = "-I/" && badPath "${p:2}"; then |
||||
skip $p |
||||
elif test "${p:0:4}" = "-aI/" && badPath "${p:3}"; then |
||||
skip $p |
||||
elif test "${p:0:4}" = "-aO/" && badPath "${p:3}"; then |
||||
skip $p |
||||
else |
||||
rest=("${rest[@]}" "$p") |
||||
fi |
||||
n=$((n + 1)) |
||||
done |
||||
params=("${rest[@]}") |
||||
fi |
||||
|
||||
|
||||
# Add the flags for the GNAT compiler proper. |
||||
extraAfter=($NIX_GNATFLAGS_COMPILE) |
||||
extraBefore=() |
||||
|
||||
if [ "`basename $0`x" = "gnatmakex" ]; then |
||||
extraBefore=("--GNATBIND=@out@/bin/gnatbind --GNATLINK=@out@/bin/gnatlink ") |
||||
fi |
||||
|
||||
# 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[@]} "-largs $i") |
||||
#done |
||||
|
||||
# Optionally print debug info. |
||||
if test "$NIX_DEBUG" = "1"; then |
||||
echo "original flags to @gnatProg@:" >&2 |
||||
for i in "${params[@]}"; do |
||||
echo " $i" >&2 |
||||
done |
||||
echo "extraBefore flags to @gnatProg@:" >&2 |
||||
for i in ${extraBefore[@]}; do |
||||
echo " $i" >&2 |
||||
done |
||||
echo "extraAfter flags to @gnatProg@:" >&2 |
||||
for i in ${extraAfter[@]}; do |
||||
echo " $i" >&2 |
||||
done |
||||
fi |
||||
|
||||
if test -n "$NIX_GNAT_WRAPPER_EXEC_HOOK"; then |
||||
source "$NIX_GNAT_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_GNAT_NEEDS_GREP"; then |
||||
@gnatProg@ ${extraBefore[@]} "${params[@]}" ${extraAfter[@]} |
||||
else |
||||
(@gnatProg@ ${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 |
@ -1,43 +0,0 @@ |
||||
#! @shell@ -e |
||||
|
||||
# Add the flags for the GNAT compiler proper. |
||||
extraAfter="--GCC=@out@/bin/gcc" |
||||
extraBefore=() |
||||
|
||||
# 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[@]} "-largs $i") |
||||
#done |
||||
|
||||
# Optionally print debug info. |
||||
if test "$NIX_DEBUG" = "1"; then |
||||
echo "original flags to @gnatlinkProg@:" >&2 |
||||
for i in "$@"; do |
||||
echo " $i" >&2 |
||||
done |
||||
echo "extraBefore flags to @gnatlinkProg@:" >&2 |
||||
for i in ${extraBefore[@]}; do |
||||
echo " $i" >&2 |
||||
done |
||||
echo "extraAfter flags to @gnatlinkProg@:" >&2 |
||||
for i in ${extraAfter[@]}; do |
||||
echo " $i" >&2 |
||||
done |
||||
fi |
||||
|
||||
if test -n "$NIX_GNAT_WRAPPER_EXEC_HOOK"; then |
||||
source "$NIX_GNAT_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_GNAT_NEEDS_GREP"; then |
||||
@gnatlinkProg@ ${extraBefore[@]} "$@" ${extraAfter[@]} |
||||
else |
||||
(@gnatlinkProg@ ${extraBefore[@]} "$@" ${extraAfter[@]} 3>&2 2>&1 1>&3- \ |
||||
| (grep -v 'file path prefix' || true); exit ${PIPESTATUS[0]}) 3>&2 2>&1 1>&3- |
||||
exit $? |
||||
fi |
@ -1,40 +0,0 @@ |
||||
#!@shell@ |
||||
|
||||
set -e |
||||
set -u |
||||
|
||||
# I've also tried adding -z direct and -z lazyload, but it gave too many problems with C++ exceptions :'( |
||||
# Also made sure libgcc would not be lazy-loaded, as suggested here: https://www.illumos.org/issues/2534#note-3 |
||||
# but still no success. |
||||
cmd="@ld@ -z ignore" |
||||
|
||||
args=("$@"); |
||||
|
||||
# This loop makes sure all -L arguments are before -l arguments, or ld may complain it cannot find a library. |
||||
# GNU binutils does not have this problem: |
||||
# http://stackoverflow.com/questions/5817269/does-the-order-of-l-and-l-options-in-the-gnu-linker-matter |
||||
i=0; |
||||
while [[ $i -lt $# ]]; do |
||||
case "${args[$i]}" in |
||||
-L) cmd="$cmd ${args[$i]} ${args[($i+1)]}"; i=($i+1); ;; |
||||
-L*) cmd="$cmd ${args[$i]}" ;; |
||||
*) ;; |
||||
esac |
||||
i=($i+1); |
||||
done |
||||
|
||||
i=0; |
||||
while [[ $i -lt $# ]]; do |
||||
case "${args[$i]}" in |
||||
-L) i=($i+1); ;; |
||||
-L*) ;; |
||||
*) cmd="$cmd ${args[$i]}" ;; |
||||
esac |
||||
i=($i+1); |
||||
done |
||||
|
||||
# Trace: |
||||
set -x |
||||
exec $cmd |
||||
|
||||
exit 0 |
@ -1,166 +0,0 @@ |
||||
#! @shell@ -e |
||||
|
||||
if test -n "$NIX_LD_WRAPPER_START_HOOK"; then |
||||
source "$NIX_LD_WRAPPER_START_HOOK" |
||||
fi |
||||
|
||||
if test -z "$NIX_CC_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 |
||||
elif test "${p:0:9}" = "--sysroot"; then |
||||
# Our ld is not built with sysroot support (Can we fix that?) |
||||
: |
||||
else |
||||
rest=("${rest[@]}" "$p") |
||||
fi |
||||
n=$((n + 1)) |
||||
done |
||||
params=("${rest[@]}") |
||||
fi |
||||
|
||||
|
||||
extra=() |
||||
extraBefore=() |
||||
|
||||
if test -z "$NIX_LDFLAGS_SET"; then |
||||
extra+=($NIX_LDFLAGS) |
||||
extraBefore+=($NIX_LDFLAGS_BEFORE) |
||||
fi |
||||
|
||||
extra+=($NIX_LDFLAGS_AFTER) |
||||
|
||||
|
||||
# Add all used dynamic libraries to the rpath. |
||||
if test "$NIX_DONT_SET_RPATH" != "1"; then |
||||
|
||||
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 " |
||||
} |
||||
|
||||
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 " |
||||
} |
||||
|
||||
libs="" |
||||
addToLibs() { |
||||
libs="$libs $1" |
||||
} |
||||
|
||||
rpath="" |
||||
|
||||
# First, find all -L... switches. |
||||
allParams=("${params[@]}" ${extra[@]}) |
||||
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)) |
||||
elif test "$p" = "-l"; then |
||||
addToLibs ${p2} |
||||
n=$((n + 1)) |
||||
elif test "${p:0:2}" = "-l"; then |
||||
addToLibs ${p:2} |
||||
elif test "$p" = "-dynamic-linker"; then |
||||
# Ignore the dynamic linker argument, or it |
||||
# will get into the next 'elif'. We don't want |
||||
# the dynamic linker path rpath to go always first. |
||||
n=$((n + 1)) |
||||
elif [[ "$p" =~ ^[^-].*\.so($|\.) ]]; then |
||||
# This is a direct reference to a shared library, so add |
||||
# its directory to the rpath. |
||||
path="$(dirname "$p")"; |
||||
addToRPath "${path}" |
||||
fi |
||||
n=$((n + 1)) |
||||
done |
||||
|
||||
# Second, for each directory in the library search path (-L...), |
||||
# see if it contains a dynamic library used by a -l... flag. If |
||||
# so, add the directory to the rpath. |
||||
# It's important to add the rpath in the order of -L..., so |
||||
# the link time chosen objects will be those of runtime linking. |
||||
|
||||
for i in $libPath; do |
||||
for j in $libs; do |
||||
if test -f "$i/lib$j.so"; then |
||||
addToRPath $i |
||||
break |
||||
fi |
||||
done |
||||
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[@]} |
@ -1,33 +0,0 @@ |
||||
gccWrapperOld_addCVars () { |
||||
if test -d $1/include; then |
||||
export NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE -isystem $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 |
||||
} |
||||
|
||||
envBuildBuildHooks+=(gccWrapperOld_addCVars) |
||||
|
||||
# Note: these come *after* $out in the PATH (see setup.sh). |
||||
|
||||
if test -n "@gcc@"; then |
||||
addToSearchPath PATH @gcc@/bin |
||||
fi |
||||
|
||||
if test -n "@binutils@"; then |
||||
addToSearchPath PATH @binutils@/bin |
||||
fi |
||||
|
||||
if test -n "@libc@"; then |
||||
addToSearchPath PATH @libc_bin@/bin |
||||
fi |
||||
|
||||
if test -n "@coreutils@"; then |
||||
addToSearchPath PATH @coreutils@/bin |
||||
fi |
@ -1,26 +0,0 @@ |
||||
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 |
||||
|
||||
@extraPathTests@ |
||||
|
||||
# Otherwise, the path should refer to the store or some temporary |
||||
# directory (including the build directory). |
||||
test \ |
||||
"$p" != "/dev/null" -a \ |
||||
"${p:0:${#NIX_STORE}}" != "$NIX_STORE" -a \ |
||||
"${p:0:4}" != "/tmp" -a \ |
||||
"${p:0:${#NIX_BUILD_TOP}}" != "$NIX_BUILD_TOP" |
||||
} |
@ -1,472 +0,0 @@ |
||||
{ stdenv, targetPackages, fetchurl, noSysDirs |
||||
, langC ? true, langCC ? true, langFortran ? false |
||||
, langJava ? false |
||||
, langAda ? false |
||||
, langVhdl ? false |
||||
, profiledCompiler ? false |
||||
, staticCompiler ? false |
||||
, enableShared ? true |
||||
, texinfo ? null |
||||
, perl ? null # optional, for texi2pod (then pod2man); required for Java |
||||
, gmp, mpfr, libmpc, gettext, which |
||||
, libelf # optional, for link-time optimizations (LTO) |
||||
, ppl ? null, cloogppl ? null # optional, for the Graphite optimization framework |
||||
, zlib ? null, boehmgc ? null |
||||
, zip ? null, unzip ? null, pkgconfig ? null, gtk2 ? null, libart_lgpl ? null |
||||
, libX11 ? null, libXt ? null, libSM ? null, libICE ? null, libXtst ? null |
||||
, libXrender ? null, xproto ? null, renderproto ? null, xextproto ? null |
||||
, libXrandr ? null, libXi ? null, inputproto ? null, randrproto ? null |
||||
, gnatboot ? null |
||||
, enableMultilib ? false |
||||
, name ? "gcc" |
||||
, libcCross ? null |
||||
, crossStageStatic ? false |
||||
, gnat ? null |
||||
, libpthread ? null, libpthreadCross ? null # required for GNU/Hurd |
||||
, stripped ? true |
||||
, buildPlatform, hostPlatform, targetPlatform |
||||
, buildPackages |
||||
}: |
||||
|
||||
assert langJava -> zip != null && unzip != null |
||||
&& zlib != null && boehmgc != null |
||||
&& perl != null; # for `--enable-java-home' |
||||
assert langAda -> gnatboot != null; |
||||
assert langVhdl -> gnat != null; |
||||
|
||||
# LTO needs libelf and zlib. |
||||
assert libelf != null -> zlib != null; |
||||
|
||||
with stdenv.lib; |
||||
with builtins; |
||||
|
||||
let version = "4.5.4"; |
||||
javaEcj = fetchurl { |
||||
# The `$(top_srcdir)/ecj.jar' file is automatically picked up at |
||||
# `configure' time. |
||||
|
||||
# XXX: Eventually we might want to take it from upstream. |
||||
url = "ftp://sourceware.org/pub/java/ecj-4.3.jar"; |
||||
sha256 = "0jz7hvc0s6iydmhgh5h2m15yza7p2rlss2vkif30vm9y77m97qcx"; |
||||
}; |
||||
|
||||
# Antlr (optional) allows the Java `gjdoc' tool to be built. We want a |
||||
# binary distribution here to allow the whole chain to be bootstrapped. |
||||
javaAntlr = fetchurl { |
||||
url = http://www.antlr.org/download/antlr-3.1.3.jar; |
||||
sha256 = "1f41j0y4kjydl71lqlvr73yagrs2jsg1fjymzjz66mjy7al5lh09"; |
||||
}; |
||||
|
||||
xlibs = [ |
||||
libX11 libXt libSM libICE libXtst libXrender libXrandr libXi |
||||
xproto renderproto xextproto inputproto randrproto |
||||
]; |
||||
|
||||
javaAwtGtk = langJava && gtk2 != null; |
||||
|
||||
/* Platform flags */ |
||||
platformFlags = let |
||||
gccArch = targetPlatform.platform.gcc.arch or null; |
||||
gccCpu = targetPlatform.platform.gcc.cpu or null; |
||||
gccAbi = targetPlatform.platform.gcc.abi or null; |
||||
gccFpu = targetPlatform.platform.gcc.fpu or null; |
||||
gccFloat = targetPlatform.platform.gcc.float or null; |
||||
gccMode = targetPlatform.platform.gcc.mode or null; |
||||
in |
||||
optional (gccArch != null) "--with-arch=${gccArch}" ++ |
||||
optional (gccCpu != null) "--with-cpu=${gccCpu}" ++ |
||||
optional (gccAbi != null) "--with-abi=${gccAbi}" ++ |
||||
optional (gccFpu != null) "--with-fpu=${gccFpu}" ++ |
||||
optional (gccFloat != null) "--with-float=${gccFloat}" ++ |
||||
optional (gccMode != null) "--with-mode=${gccMode}"; |
||||
|
||||
/* Cross-gcc settings */ |
||||
crossMingw = (targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt"); |
||||
|
||||
crossConfigureFlags = |
||||
# Ensure that -print-prog-name is able to find the correct programs. |
||||
[ "--with-as=${targetPackages.stdenv.cc.bintools}/bin/${targetPlatform.config}-as" |
||||
"--with-ld=${targetPackages.stdenv.cc.bintools}/bin/${targetPlatform.config}-ld" ] ++ |
||||
(if crossMingw && crossStageStatic then [ |
||||
"--with-headers=${libcCross}/include" |
||||
"--with-gcc" |
||||
"--with-gnu-as" |
||||
"--with-gnu-ld" |
||||
"--with-gnu-ld" |
||||
"--disable-shared" |
||||
"--disable-nls" |
||||
"--disable-debug" |
||||
"--enable-sjlj-exceptions" |
||||
"--enable-threads=win32" |
||||
"--disable-win32-registry" |
||||
] else if crossStageStatic then [ |
||||
"--disable-libssp" |
||||
"--disable-nls" |
||||
"--without-headers" |
||||
"--disable-threads" |
||||
"--disable-libmudflap" |
||||
"--disable-libgomp" |
||||
"--disable-shared" |
||||
"--disable-decimal-float" # libdecnumber requires libc |
||||
] else [ |
||||
"--with-headers=${libcCross}/include" |
||||
"--enable-__cxa_atexit" |
||||
"--enable-long-long" |
||||
] ++ |
||||
(if crossMingw then [ |
||||
"--enable-threads=win32" |
||||
"--enable-sjlj-exceptions" |
||||
"--enable-hash-synchronization" |
||||
"--enable-version-specific-runtime-libs" |
||||
"--enable-libssp" |
||||
"--disable-nls" |
||||
"--with-dwarf2" |
||||
] else [ |
||||
"--enable-threads=posix" |
||||
"--enable-nls" |
||||
"--disable-decimal-float" # No final libdecnumber (it may work only in 386) |
||||
])); |
||||
stageNameAddon = if crossStageStatic then "-stage-static" else |
||||
"-stage-final"; |
||||
crossNameAddon = if targetPlatform != hostPlatform then "-${targetPlatform.config}" + stageNameAddon else ""; |
||||
|
||||
in |
||||
|
||||
# We need all these X libraries when building AWT with GTK+. |
||||
assert gtk2 != null -> (filter (x: x == null) xlibs) == []; |
||||
|
||||
stdenv.mkDerivation ({ |
||||
name = "${name}-${version}" + crossNameAddon; |
||||
|
||||
builder = ../builder.sh; |
||||
|
||||
src = (import ./sources.nix) { |
||||
inherit fetchurl optional version; |
||||
inherit langC langCC langFortran langJava langAda; |
||||
}; |
||||
|
||||
hardeningDisable = [ "format" ] ++ optional (name != "gnat") "all"; |
||||
|
||||
outputs = [ "out" "man" "info" ] |
||||
++ optional (!(hostPlatform.is64bit && langAda)) "lib"; |
||||
|
||||
setOutputFlags = false; |
||||
NIX_NO_SELF_RPATH = true; |
||||
|
||||
libc_dev = stdenv.cc.libc_dev; |
||||
|
||||
patches = |
||||
[ ] |
||||
++ optional (targetPlatform != hostPlatform) ../libstdc++-target.patch |
||||
++ optional noSysDirs ./no-sys-dirs.patch |
||||
# The GNAT Makefiles did not pay attention to CFLAGS_FOR_TARGET for its |
||||
# target libraries and tools. |
||||
++ optional langAda ../gnat-cflags.patch |
||||
++ optional langVhdl ./ghdl-ortho-cflags.patch |
||||
++ [ ../struct-ucontext-4.5.patch ] # glibc-2.26 |
||||
; |
||||
|
||||
postPatch = |
||||
if (stdenv.system == "i586-pc-gnu" |
||||
|| (libcCross != null # e.g., building `gcc.crossDrv' |
||||
&& libcCross ? crossConfig |
||||
&& libcCross.crossConfig == "i586-pc-gnu") |
||||
|| (targetPlatform != hostPlatform && targetPlatform.config == "i586-pc-gnu" |
||||
&& libcCross != null)) |
||||
then |
||||
# On GNU/Hurd glibc refers to Hurd & Mach headers and libpthread is not |
||||
# in glibc, so add the right `-I' flags to the default spec string. |
||||
assert libcCross != null -> libpthreadCross != null; |
||||
let |
||||
libc = if libcCross != null then libcCross else stdenv.glibc; |
||||
gnu_h = "gcc/config/gnu.h"; |
||||
i386_gnu_h = "gcc/config/i386/gnu.h"; |
||||
extraCPPDeps = |
||||
libc.propagatedBuildInputs |
||||
++ stdenv.lib.optional (libpthreadCross != null) libpthreadCross |
||||
++ stdenv.lib.optional (libpthread != null) libpthread; |
||||
extraCPPSpec = |
||||
concatStrings (intersperse " " |
||||
(map (x: "-I${x.dev or x}/include") extraCPPDeps)); |
||||
extraLibSpec = |
||||
if libpthreadCross != null |
||||
then "-L${libpthreadCross}/lib ${libpthreadCross.TARGET_LDFLAGS}" |
||||
else "-L${libpthread}/lib"; |
||||
in |
||||
'' echo "augmenting \`CPP_SPEC' in \`${i386_gnu_h}' with \`${extraCPPSpec}'..." |
||||
sed -i "${i386_gnu_h}" \ |
||||
-es'|CPP_SPEC *"\(.*\)$|CPP_SPEC "${extraCPPSpec} \1|g' |
||||
|
||||
echo "augmenting \`LIB_SPEC' in \`${gnu_h}' with \`${extraLibSpec}'..." |
||||
sed -i "${gnu_h}" \ |
||||
-es'|LIB_SPEC *"\(.*\)$|LIB_SPEC "${extraLibSpec} \1|g' |
||||
|
||||
echo "setting \`NATIVE_SYSTEM_HEADER_DIR' and \`STANDARD_INCLUDE_DIR' to \`${libc.dev}/include'..." |
||||
sed -i "${gnu_h}" \ |
||||
-es'|#define STANDARD_INCLUDE_DIR.*$|#define STANDARD_INCLUDE_DIR "${libc.dev}/include"|g' |
||||
sed -i gcc/config/t-gnu \ |
||||
-es'|NATIVE_SYSTEM_HEADER_DIR.*$|NATIVE_SYSTEM_HEADER_DIR = ${libc.dev}/include|g' |
||||
'' |
||||
else if targetPlatform != hostPlatform || stdenv.cc.libc != null then |
||||
# On NixOS, use the right path to the dynamic linker instead of |
||||
# `/lib/ld*.so'. |
||||
let |
||||
libc = if libcCross != null then libcCross else stdenv.cc.libc; |
||||
in |
||||
'' echo "fixing the \`GLIBC_DYNAMIC_LINKER' and \`UCLIBC_DYNAMIC_LINKER' macros..." |
||||
for header in "gcc/config/"*-gnu.h "gcc/config/"*"/"*.h |
||||
do |
||||
grep -q LIBC_DYNAMIC_LINKER "$header" || continue |
||||
echo " fixing \`$header'..." |
||||
sed -i "$header" \ |
||||
-e 's|define[[:blank:]]*\([UCG]\+\)LIBC_DYNAMIC_LINKER\([0-9]*\)[[:blank:]]"\([^\"]\+\)"$|define \1LIBC_DYNAMIC_LINKER\2 "${libc.out}\3"|g' |
||||
done |
||||
'' |
||||
else null; |
||||
|
||||
# TODO(@Ericson2314): Make passthru instead. Weird to avoid mass rebuild, |
||||
crossStageStatic = targetPlatform == hostPlatform || crossStageStatic; |
||||
inherit noSysDirs profiledCompiler staticCompiler langJava |
||||
libcCross crossMingw; |
||||
|
||||
depsBuildBuild = [ buildPackages.stdenv.cc ]; |
||||
nativeBuildInputs = [ texinfo which gettext ] |
||||
++ optional (perl != null) perl; |
||||
|
||||
# For building runtime libs |
||||
depsBuildTarget = |
||||
if hostPlatform == buildPlatform then [ |
||||
targetPackages.stdenv.cc.bintools # newly-built gcc will be used |
||||
] else assert targetPlatform == hostPlatform; [ # build != host == target |
||||
stdenv.cc |
||||
]; |
||||
|
||||
buildInputs = [ |
||||
gmp mpfr libmpc libelf |
||||
targetPackages.stdenv.cc.bintools # For linking code at run-time |
||||
] ++ (optional (ppl != null) ppl) |
||||
++ (optional (cloogppl != null) cloogppl) |
||||
++ (optional (zlib != null) zlib) |
||||
++ (optional langJava boehmgc) |
||||
++ (optionals langJava [zip unzip]) |
||||
++ (optionals javaAwtGtk ([gtk2 pkgconfig libart_lgpl] ++ xlibs)) |
||||
++ (optionals (targetPlatform != hostPlatform) [targetPackages.stdenv.cc.bintools]) |
||||
++ (optionals langAda [gnatboot]) |
||||
++ (optionals langVhdl [gnat]) |
||||
; |
||||
|
||||
# TODO(@Ericson2314): Always pass "--target" and always prefix. |
||||
configurePlatforms = |
||||
# TODO(@Ericson2314): Figure out what's going wrong with Arm |
||||
if buildPlatform == hostPlatform && hostPlatform == targetPlatform && targetPlatform.isArm |
||||
then [] |
||||
else [ "build" "host" ] ++ stdenv.lib.optional (targetPlatform != hostPlatform) "target"; |
||||
|
||||
configureFlags = |
||||
# Basic dependencies |
||||
[ |
||||
"--with-gmp=${gmp.dev}" |
||||
"--with-mpfr=${mpfr.dev}" |
||||
"--with-mpc=${libmpc}" |
||||
] ++ |
||||
optional (libelf != null) "--with-libelf=${libelf}" ++ |
||||
optional (!(crossMingw && crossStageStatic)) |
||||
"--with-native-system-header-dir=${getDev stdenv.cc.libc}/include" ++ |
||||
|
||||
# Basic configuration |
||||
[ |
||||
"--disable-libstdcxx-pch" |
||||
"--without-included-gettext" |
||||
"--with-system-zlib" |
||||
"--enable-languages=${ |
||||
concatStrings (intersperse "," |
||||
( optional langC "c" |
||||
++ optional langCC "c++" |
||||
++ optional langFortran "fortran" |
||||
++ optional langJava "java" |
||||
++ optional langAda "ada" |
||||
++ optional langVhdl "vhdl" |
||||
) |
||||
) |
||||
}" |
||||
] ++ |
||||
optional (!enableMultilib) "--disable-multilib" ++ |
||||
optional (!enableShared) "--disable-shared" ++ |
||||
|
||||
# Optional features |
||||
optional (cloogppl != null) "--with-cloog=${cloogppl}" ++ |
||||
optional (ppl != null) "--with-ppl=${ppl}" ++ |
||||
|
||||
# Java options |
||||
optionals langJava [ |
||||
"--with-ecj-jar=${javaEcj}" |
||||
|
||||
# Follow Sun's layout for the convenience of IcedTea/OpenJDK. See |
||||
# <http://mail.openjdk.java.net/pipermail/distro-pkg-dev/2010-April/008888.html>. |
||||
"--enable-java-home" |
||||
"--with-java-home=\${prefix}/lib/jvm/jre" |
||||
] ++ |
||||
optional javaAwtGtk "--enable-java-awt=gtk" ++ |
||||
optional (langJava && javaAntlr != null) "--with-antlr-jar=${javaAntlr}" ++ |
||||
|
||||
# Ada |
||||
optional langAda "--enable-libada" ++ |
||||
|
||||
platformFlags ++ |
||||
optional (targetPlatform != hostPlatform) crossConfigureFlags ++ |
||||
|
||||
# Platform-specific flags |
||||
optional (targetPlatform == hostPlatform && targetPlatform.isi686) "--with-arch=i686" ++ |
||||
# Trick that should be taken out once we have a mipsel-linux not loongson2f |
||||
optional (targetPlatform == hostPlatform && stdenv.system == "mipsel-linux") "--with-arch=loongson2f" |
||||
; |
||||
|
||||
targetConfig = if targetPlatform != hostPlatform then targetPlatform.config else null; |
||||
|
||||
/* For cross-built gcc (build != host == target) */ |
||||
crossAttrs = { |
||||
dontStrip = true; |
||||
}; |
||||
|
||||
# Setting $CPATH and $LIBRARY_PATH to make sure both `gcc' and `xgcc' find the |
||||
# library headers and binaries, regarless of the language being compiled. |
||||
# |
||||
# Note: When building the Java AWT GTK+ peer, the build system doesn't honor |
||||
# `--with-gmp' et al., e.g., when building |
||||
# `libjava/classpath/native/jni/java-math/gnu_java_math_GMP.c', so we just add |
||||
# them to $CPATH and $LIBRARY_PATH in this case. |
||||
# |
||||
# Likewise, the LTO code doesn't find zlib. |
||||
# |
||||
# Cross-compiling, we need gcc not to read ./specs in order to build the g++ |
||||
# compiler (after the specs for the cross-gcc are created). Having |
||||
# LIBRARY_PATH= makes gcc read the specs from ., and the build breaks. |
||||
|
||||
CPATH = optionals (targetPlatform == hostPlatform) (makeSearchPathOutput "dev" "include" ([] |
||||
++ optional (zlib != null) zlib |
||||
++ optional langJava boehmgc |
||||
++ optionals javaAwtGtk xlibs |
||||
++ optionals javaAwtGtk [ gmp mpfr ] |
||||
++ optional (libpthread != null) libpthread |
||||
++ optional (libpthreadCross != null) libpthreadCross |
||||
|
||||
# On GNU/Hurd glibc refers to Mach & Hurd |
||||
# headers. |
||||
++ optionals (libcCross != null && libcCross ? propagatedBuildInputs) |
||||
libcCross.propagatedBuildInputs |
||||
)); |
||||
|
||||
LIBRARY_PATH = optionals (targetPlatform == hostPlatform) (makeLibraryPath ([] |
||||
++ optional (zlib != null) zlib |
||||
++ optional langJava boehmgc |
||||
++ optionals javaAwtGtk xlibs |
||||
++ optionals javaAwtGtk [ gmp mpfr ] |
||||
++ optional (libpthread != null) libpthread) |
||||
); |
||||
|
||||
EXTRA_TARGET_FLAGS = optionals |
||||
(targetPlatform != hostPlatform && libcCross != null) |
||||
([ |
||||
"-idirafter ${libcCross.dev}/include" |
||||
] ++ optionals (! crossStageStatic) [ |
||||
"-B${libcCross.out}/lib" |
||||
]); |
||||
|
||||
EXTRA_TARGET_LDFLAGS = optionals |
||||
(targetPlatform != hostPlatform && libcCross != null) |
||||
([ |
||||
"-Wl,-L${libcCross.out}/lib" |
||||
] ++ (if crossStageStatic then [ |
||||
"-B${libcCross.out}/lib" |
||||
] else [ |
||||
"-Wl,-rpath,${libcCross.out}/lib" |
||||
"-Wl,-rpath-link,${libcCross.out}/lib" |
||||
]) ++ optionals (libpthreadCross != null) [ |
||||
"-L${libpthreadCross}/lib" |
||||
"-Wl,${libpthreadCross.TARGET_LDFLAGS}" |
||||
]); |
||||
|
||||
passthru = { |
||||
inherit langC langCC langAda langFortran langVhdl enableMultilib version; |
||||
isGNU = true; |
||||
hardeningUnsupportedFlags = [ "stackprotector" ]; |
||||
}; |
||||
|
||||
enableParallelBuilding = !langAda; |
||||
|
||||
meta = { |
||||
homepage = http://gcc.gnu.org/; |
||||
license = stdenv.lib.licenses.gpl3Plus; # runtime support libraries are typically LGPLv3+ |
||||
description = "GNU Compiler Collection, version ${version}" |
||||
+ (if stripped then "" else " (with debugging info)"); |
||||
|
||||
longDescription = '' |
||||
The GNU Compiler Collection includes compiler front ends for C, C++, |
||||
Objective-C, Fortran, OpenMP for C/C++/Fortran, Java, and Ada, as well |
||||
as libraries for these languages (libstdc++, libgcj, libgomp,...). |
||||
|
||||
GCC development is a part of the GNU Project, aiming to improve the |
||||
compiler used in the GNU system including the GNU/Linux variant. |
||||
''; |
||||
|
||||
maintainers = [ |
||||
stdenv.lib.maintainers.viric |
||||
]; |
||||
|
||||
# Volunteers needed for the {Cyg,Dar}win ports of *PPL. |
||||
# gnatboot is not available out of linux platforms, so we disable the darwin build |
||||
# for the gnat (ada compiler). |
||||
platforms = stdenv.lib.platforms.linux ++ optionals (langAda == false) [ "i686-darwin" ]; |
||||
}; |
||||
} |
||||
|
||||
// optionalAttrs (targetPlatform != hostPlatform || libcCross != null) { |
||||
# `builder.sh' sets $CPP, which leads configure to use "gcc -E" instead of, |
||||
# say, "i586-pc-gnu-gcc -E" when building `gcc.crossDrv'. |
||||
# FIXME: Fix `builder.sh' directly in the next stdenv-update. |
||||
postUnpack = "unset CPP"; |
||||
} |
||||
|
||||
// optionalAttrs (targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt" && crossStageStatic) { |
||||
makeFlags = [ "all-gcc" "all-target-libgcc" ]; |
||||
installTargets = "install-gcc install-target-libgcc"; |
||||
} |
||||
|
||||
# GCC 4.5.2 doesn't support the `install-strip' target, so let `stdenv' do |
||||
# the stripping by default. |
||||
// optionalAttrs (!stripped) { dontStrip = true; } |
||||
|
||||
// optionalAttrs langVhdl rec { |
||||
name = "ghdl-0.29"; |
||||
|
||||
ghdlSrc = fetchurl { |
||||
url = "http://ghdl.free.fr/ghdl-0.29.tar.bz2"; |
||||
sha256 = "15mlinr1lwljwll9ampzcfcrk9bk0qpdks1kxlvb70xf9zhh2jva"; |
||||
}; |
||||
|
||||
# Ghdl has some timestamps checks, storing file timestamps in '.cf' files. |
||||
# As we will change the timestamps to 1970-01-01 00:00:01, we also set the |
||||
# content of that .cf to that value. This way ghdl does not complain on |
||||
# the installed object files from the basic libraries (ieee, ...) |
||||
postInstallGhdl = '' |
||||
pushd $out |
||||
find . -name "*.cf" -exec \ |
||||
sed 's/[0-9]*\.000" /19700101000001.000" /g' -i {} \; |
||||
popd |
||||
''; |
||||
|
||||
postUnpack = '' |
||||
tar xvf ${ghdlSrc} |
||||
mv ghdl-*/vhdl gcc*/gcc |
||||
rm -Rf ghdl-* |
||||
''; |
||||
|
||||
meta = { |
||||
homepage = http://ghdl.free.fr/; |
||||
license = stdenv.lib.licenses.gpl2Plus; |
||||
description = "Complete VHDL simulator, using the GCC technology (gcc ${version})"; |
||||
maintainers = with stdenv.lib.maintainers; [viric]; |
||||
platforms = with stdenv.lib.platforms; linux; |
||||
}; |
||||
|
||||
}) |
@ -1,111 +0,0 @@ |
||||
diff --git a/gcc/vhdl/Make-lang.in b/gcc/vhdl/Make-lang.in
|
||||
index 8f481df..681ac59 100644
|
||||
--- a/gcc/vhdl/Make-lang.in
|
||||
+++ b/gcc/vhdl/Make-lang.in
|
||||
@@ -96,7 +96,7 @@ AGCC_GCCOBJ_DIR=../
|
||||
AGCC_INC_FLAGS=-I$(AGCC_GCCOBJ_DIR)/gcc -I$(AGCC_GCCSRC_DIR)/include \
|
||||
-I$(AGCC_GCCSRC_DIR)/gcc -I$(AGCC_GCCSRC_DIR)/gcc/config \
|
||||
-I$(AGCC_GCCSRC_DIR)/libcpp/include
|
||||
-AGCC_CFLAGS=-g -Wall -DIN_GCC $(AGCC_INC_FLAGS)
|
||||
+AGCC_CFLAGS=-g -Wall -DIN_GCC $(AGCC_INC_FLAGS) $(CFLAGS) $(INCLUDES)
|
||||
|
||||
AGCC_LOCAL_OBJS=ortho-lang.o
|
||||
|
||||
@@ -140,7 +140,7 @@ ghdl$(exeext): force
|
||||
|
||||
# Ghdl libraries.
|
||||
ghdllib: ghdl$(exeext) $(GCC_PASSES) force
|
||||
- $(MAKE_IN_VHDL) GRT_FLAGS="-O -g" ghdllib
|
||||
+ $(MAKE_IN_VHDL) GRT_FLAGS="-O -g $(CFLAGS)" ghdllib
|
||||
|
||||
# Build hooks:
|
||||
|
||||
diff --git a/gcc/vhdl/Makefile.in b/gcc/vhdl/Makefile.in
|
||||
index d754c6c..07abc4a 100644
|
||||
--- a/gcc/vhdl/Makefile.in
|
||||
+++ b/gcc/vhdl/Makefile.in
|
||||
@@ -80,7 +80,8 @@ T_CPPFLAGS =
|
||||
X_ADAFLAGS =
|
||||
T_ADAFLAGS =
|
||||
|
||||
-ADAC = $(CC)
|
||||
+# Never use the bootstrapped compiler, as it may not be built for ada
|
||||
+ADAC = gcc
|
||||
|
||||
ECHO = echo
|
||||
CHMOD = chmod
|
||||
diff --git a/gcc/vhdl/ortho-lang.c b/gcc/vhdl/ortho-lang.c
|
||||
index 84aeb92..8eddd42 100644
|
||||
--- a/gcc/vhdl/ortho-lang.c
|
||||
+++ b/gcc/vhdl/ortho-lang.c
|
||||
@@ -16,6 +16,7 @@
|
||||
#include "options.h"
|
||||
#include "real.h"
|
||||
-#include "tree-gimple.h"
|
||||
+#include "gimple.h"
|
||||
+#include "tree.h"
|
||||
#include "function.h"
|
||||
#include "cgraph.h"
|
||||
#include "target.h"
|
||||
@@ -680,38 +681,10 @@ type_for_mode (enum machine_mode mode, int unsignedp)
|
||||
|
||||
const struct lang_hooks lang_hooks = LANG_HOOKS_INITIALIZER;
|
||||
|
||||
-/* Tree code classes. */
|
||||
-
|
||||
-#define DEFTREECODE(SYM, NAME, TYPE, LENGTH) TYPE,
|
||||
-
|
||||
-const enum tree_code_class tree_code_type[] = {
|
||||
-#include "tree.def"
|
||||
- 'x'
|
||||
-};
|
||||
-#undef DEFTREECODE
|
||||
-
|
||||
-/* Table indexed by tree code giving number of expression
|
||||
- operands beyond the fixed part of the node structure.
|
||||
- Not used for types or decls. */
|
||||
-
|
||||
-#define DEFTREECODE(SYM, NAME, TYPE, LENGTH) LENGTH,
|
||||
-
|
||||
-const unsigned char tree_code_length[] = {
|
||||
-#include "tree.def"
|
||||
- 0
|
||||
-};
|
||||
-#undef DEFTREECODE
|
||||
-
|
||||
-#define DEFTREECODE(SYM, NAME, TYPE, LENGTH) NAME,
|
||||
-const char * const tree_code_name[] = {
|
||||
-#include "tree.def"
|
||||
- "@@dummy"
|
||||
-};
|
||||
-#undef DEFTREECODE
|
||||
|
||||
union lang_tree_node
|
||||
GTY((desc ("0"),
|
||||
- chain_next ("(union lang_tree_node *) GENERIC_NEXT (&%h.generic)")))
|
||||
+ chain_next ("(union lang_tree_node *) TREE_CHAIN (&%h.generic)")))
|
||||
{
|
||||
union tree_node GTY ((tag ("0"))) generic;
|
||||
};
|
||||
@@ -1162,7 +1135,7 @@ new_access_type (tree dtype)
|
||||
res = make_node (POINTER_TYPE);
|
||||
TREE_TYPE (res) = NULL_TREE;
|
||||
/* Seems necessary. */
|
||||
- TYPE_MODE (res) = Pmode;
|
||||
+ SET_TYPE_MODE (res, Pmode);
|
||||
layout_type (res);
|
||||
return res;
|
||||
}
|
||||
diff --git a/gcc/vhdl/Make-lang.in b/gcc/vhdl/Make-lang.in
|
||||
index e201f64..f36fb97 100644
|
||||
--- a/gcc/vhdl/Make-lang.in
|
||||
+++ b/gcc/vhdl/Make-lang.in
|
||||
@@ -132,7 +132,7 @@ ghdl1$(exeext): $(AGCC_OBJS) $(AGCC_DEPS) force
|
||||
-cargs $(CFLAGS) $(GHDL_ADAFLAGS)
|
||||
$(GNATMAKE) -o $@ -aI$(srcdir)/vhdl -aOvhdl ortho_gcc-main \
|
||||
-bargs -E -cargs $(CFLAGS) $(GHDL_ADAFLAGS) \
|
||||
- -largs $(AGCC_OBJS) $(LIBS) $(GMPLIBS)
|
||||
+ -largs $(AGCC_OBJS) $(LIBS) $(GMPLIBS) $(CLOOGLIBS) $(PPLLIBS)
|
||||
|
||||
# The driver for ghdl.
|
||||
ghdl$(exeext): force
|
@ -1,54 +0,0 @@ |
||||
diff -ru gcc-4.3.1-orig/gcc/cppdefault.c gcc-4.3.1/gcc/cppdefault.c
|
||||
--- gcc-4.3.1-orig/gcc/cppdefault.c 2007-07-26 10:37:01.000000000 +0200
|
||||
+++ gcc-4.3.1/gcc/cppdefault.c 2008-06-25 17:48:23.000000000 +0200
|
||||
@@ -41,6 +41,10 @@
|
||||
# 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 -ru gcc-4.3.1-orig/gcc/gcc.c gcc-4.3.1/gcc/gcc.c
|
||||
--- gcc-4.3.1-orig/gcc/gcc.c 2008-03-02 23:55:19.000000000 +0100
|
||||
+++ gcc-4.3.1/gcc/gcc.c 2008-06-25 17:52:53.000000000 +0200
|
||||
@@ -1478,10 +1478,10 @@
|
||||
/* Default prefixes to attach to command names. */
|
||||
|
||||
#ifndef STANDARD_STARTFILE_PREFIX_1
|
||||
-#define STANDARD_STARTFILE_PREFIX_1 "/lib/"
|
||||
+#define STANDARD_STARTFILE_PREFIX_1 ""
|
||||
#endif
|
||||
#ifndef STANDARD_STARTFILE_PREFIX_2
|
||||
-#define STANDARD_STARTFILE_PREFIX_2 "/usr/lib/"
|
||||
+#define STANDARD_STARTFILE_PREFIX_2 ""
|
||||
#endif
|
||||
|
||||
#ifdef CROSS_DIRECTORY_STRUCTURE /* Don't use these prefixes for a cross compiler. */
|
||||
--- gcc-4.3.1-orig/gcc/Makefile.in 2008-05-11 20:54:15.000000000 +0200
|
||||
+++ gcc-4.3.1/gcc/Makefile.in 2008-06-25 17:48:23.000000000 +0200
|
||||
@@ -378,7 +378,11 @@
|
||||
MD5_H = $(srcdir)/../include/md5.h
|
||||
|
||||
# Default native SYSTEM_HEADER_DIR, to be overridden by targets.
|
||||
-NATIVE_SYSTEM_HEADER_DIR = /usr/include
|
||||
+# 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@
|
||||
|
||||
@@ -3277,7 +3281,7 @@
|
||||
-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)\" \
|
||||
+ -DLOCAL_INCLUDE_DIR=\"/no-such-dir\" \
|
||||
-DCROSS_INCLUDE_DIR=\"$(CROSS_SYSTEM_HEADER_DIR)\" \
|
||||
-DTOOL_INCLUDE_DIR=\"$(gcc_tooldir)/include\" \
|
||||
-DPREFIX=\"$(prefix)/\" \
|
@ -1,26 +0,0 @@ |
||||
/* Automatically generated by `update-gcc.sh', do not edit. |
||||
For GCC 4.5.4. */ |
||||
{ fetchurl, optional, version, langC, langCC, langFortran, langJava, langAda }: |
||||
|
||||
assert version == "4.5.4"; |
||||
optional /* langC */ true (fetchurl { |
||||
url = "mirror://gcc/releases/gcc-${version}/gcc-core-${version}.tar.bz2"; |
||||
sha256 = "894d90f72cbfc8707e330fa2b1847c443fa97cf9b7f26e86be554709510e624a"; |
||||
}) ++ |
||||
optional langCC (fetchurl { |
||||
url = "mirror://gcc/releases/gcc-${version}/gcc-g++-${version}.tar.bz2"; |
||||
sha256 = "f7e3bab5e22713fbce46c2acb35fb727748473a34a942ce00393d75e1b09b6b9"; |
||||
}) ++ |
||||
optional langFortran (fetchurl { |
||||
url = "mirror://gcc/releases/gcc-${version}/gcc-fortran-${version}.tar.bz2"; |
||||
sha256 = "cf0803b4f5334a526dd8da1b2171d6724f50c17346b2d5c509b6abc973d2ef34"; |
||||
}) ++ |
||||
optional langJava (fetchurl { |
||||
url = "mirror://gcc/releases/gcc-${version}/gcc-java-${version}.tar.bz2"; |
||||
sha256 = "c98398da6f8c4c7d1758e291089d99853fdd27112cd3f146b7a8c26e6d762a23"; |
||||
}) ++ |
||||
optional langAda (fetchurl { |
||||
url = "mirror://gcc/releases/gcc-${version}/gcc-ada-${version}.tar.bz2"; |
||||
sha256 = "8abddae15be65572b4d639bd9818057019bb4a45da4decfc6451511c8d580c5e"; |
||||
}) ++ |
||||
[] |
@ -1,33 +0,0 @@ |
||||
diff --git a/libada/Makefile.in b/libada/Makefile.in
|
||||
index f5057a0..337e0c6 100644
|
||||
--- a/libada/Makefile.in
|
||||
+++ b/libada/Makefile.in
|
||||
@@ -55,7 +55,7 @@ GCC_WARN_CFLAGS = $(LOOSE_WARN)
|
||||
WARN_CFLAGS = @warn_cflags@
|
||||
|
||||
TARGET_LIBGCC2_CFLAGS=
|
||||
-GNATLIBCFLAGS= -g -O2
|
||||
+GNATLIBCFLAGS= -g -O2 $(CFLAGS)
|
||||
GNATLIBCFLAGS_FOR_C = $(GNATLIBCFLAGS) $(TARGET_LIBGCC2_CFLAGS) -fexceptions \
|
||||
-DIN_RTS @have_getipinfo@
|
||||
|
||||
--- a/gcc/ada/gcc-interface/Makefile.in
|
||||
+++ b/gcc/ada/gcc-interface/Makefile.in
|
||||
@@ -105,7 +105,7 @@ ADAFLAGS = -W -Wall -gnatpg -gnata
|
||||
SOME_ADAFLAGS =-gnata
|
||||
FORCE_DEBUG_ADAFLAGS = -g
|
||||
GNATLIBFLAGS = -gnatpg -nostdinc
|
||||
-GNATLIBCFLAGS = -g -O2
|
||||
+GNATLIBCFLAGS = -g -O2 $(CFLAGS_FOR_TARGET)
|
||||
# Pretend that _Unwind_GetIPInfo is available for the target by default. This
|
||||
# should be autodetected during the configuration of libada and passed down to
|
||||
# here, but we need something for --disable-libada and hope for the best.
|
||||
@@ -193,7 +193,7 @@ RTSDIR = rts$(subst /,_,$(MULTISUBDIR))
|
||||
# Link flags used to build gnat tools. By default we prefer to statically
|
||||
# link with libgcc to avoid a dependency on shared libgcc (which is tricky
|
||||
# to deal with as it may conflict with the libgcc provided by the system).
|
||||
-GCC_LINK_FLAGS=-static-libgcc
|
||||
+GCC_LINK_FLAGS=-static-libgcc $(CFLAGS_FOR_TARGET)
|
||||
|
||||
# End of variables for you to override.
|
||||
|
@ -1,44 +0,0 @@ |
||||
{ stdenv, fetchFromGitHub, gnat, zlib, llvm_35, ncurses, clang, flavour ? "mcode" }: |
||||
|
||||
# mcode only works on x86, while the llvm flavour works on both x86 and x86_64. |
||||
|
||||
|
||||
assert flavour == "llvm" || flavour == "mcode"; |
||||
|
||||
let |
||||
inherit (stdenv.lib) optional; |
||||
inherit (stdenv.lib) optionals; |
||||
version = "0.33"; |
||||
in |
||||
stdenv.mkDerivation rec { |
||||
name = "ghdl-${flavour}-${version}"; |
||||
|
||||
src = fetchFromGitHub { |
||||
owner = "tgingold"; |
||||
repo = "ghdl"; |
||||
rev = "v${version}"; |
||||
sha256 = "0g72rk2yzr0lrpncq2c1qcv71w3mi2hjq84r1yzgjr6d0qm87r2a"; |
||||
}; |
||||
|
||||
buildInputs = [ gnat zlib ] ++ optionals (flavour == "llvm") [ clang ncurses ]; |
||||
|
||||
configureFlags = optional (flavour == "llvm") "--with-llvm=${llvm_35}"; |
||||
|
||||
patchPhase = '' |
||||
# Disable warnings-as-errors, because there are warnings (unused things) |
||||
sed -i s/-gnatwae/-gnatwa/ Makefile.in ghdl.gpr.in |
||||
''; |
||||
|
||||
hardeningDisable = [ "all" ]; |
||||
|
||||
enableParallelBuilding = true; |
||||
|
||||
meta = { |
||||
homepage = https://sourceforge.net/p/ghdl-updates/wiki/Home/; |
||||
description = "Free VHDL simulator"; |
||||
maintainers = with stdenv.lib.maintainers; [viric]; |
||||
platforms = with stdenv.lib.platforms; (if flavour == "llvm" then [ "i686-linux" "x86_64-linux" ] |
||||
else [ "i686-linux" ]); |
||||
license = stdenv.lib.licenses.gpl2Plus; |
||||
}; |
||||
} |
@ -1,48 +0,0 @@ |
||||
{stdenv, fetchurl}: |
||||
|
||||
stdenv.mkDerivation { |
||||
name = "gentoo-gnatboot-4.1"; |
||||
|
||||
src = if stdenv.system == "i686-linux" then |
||||
fetchurl { |
||||
url = "mirror://gentoo/distfiles/gnatboot-4.1-i386.tar.bz2"; |
||||
sha256 = "0665zk71598204bf521vw68i5y6ccqarq9fcxsqp7ccgycb4lysr"; |
||||
} |
||||
else if stdenv.system == "x86_64-linux" then |
||||
fetchurl { |
||||
url = "mirror://gentoo/distfiles/gnatboot-4.1-amd64.tar.bz2"; |
||||
sha256 = "1li4d52lmbnfs6llcshlbqyik2q2q4bvpir0f7n38nagp0h6j0d4"; |
||||
} else throw "Platform not supported"; |
||||
|
||||
dontStrip=1; |
||||
|
||||
installPhase = '' |
||||
mkdir -p $out |
||||
cp -R * $out |
||||
set +e |
||||
for a in $out/bin/* ; do |
||||
patchelf --interpreter $(cat $NIX_CC/nix-support/dynamic-linker) \ |
||||
--set-rpath $(cat $NIX_CC/nix-support/orig-libc)/lib:$(cat $NIX_CC/nix-support/orig-cc)/lib64:$(cat $NIX_CC/nix-support/orig-cc)/lib $a |
||||
done |
||||
set -e |
||||
mv $out/bin/gnatgcc_2wrap $out/bin/gnatgcc |
||||
ln -s $out/bin/gnatgcc $out/bin/gcc |
||||
''; |
||||
|
||||
passthru = { |
||||
langC = true; /* TRICK for gcc-wrapper to wrap it */ |
||||
langCC = false; |
||||
langFortran = false; |
||||
langAda = true; |
||||
}; |
||||
|
||||
meta = { |
||||
homepage = http://gentoo.org; |
||||
license = stdenv.lib.licenses.gpl3Plus; # runtime support libraries are typically LGPLv3+ |
||||
maintainers = [ |
||||
stdenv.lib.maintainers.viric |
||||
]; |
||||
|
||||
platforms = stdenv.lib.platforms.linux; |
||||
}; |
||||
} |
Loading…
Reference in new issue