mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-25 08:23:09 +00:00
* Started reorganising stdenv:
- gcc/ld-wrappers have been factored out into a separate derivation. This allows a working gcc to be installed in the user environment. (Previously the Nix gcc didn't work because it needed a whole bunch of flags to point to glibc.) - Better modularity: packages can specify hooks into the setup scripts. For instance, setup no longer knows about the PKG_CONFIG_PATH variable; pkgconfig can set it up instead. - gcc not longer depends on binutils. This simplifies the bootstrap process. svn path=/nixpkgs/trunk/; revision=816
This commit is contained in:
parent
1b8e9faf08
commit
ce50734cf0
62
pkgs/build-support/gcc-wrapper/builder.sh
Executable file
62
pkgs/build-support/gcc-wrapper/builder.sh
Executable file
@ -0,0 +1,62 @@
|
||||
#! /bin/sh -e
|
||||
|
||||
. $stdenv/setup
|
||||
|
||||
if test -z "$isNative"; then
|
||||
cflagsCompile="-B$out/bin -B$glibc/lib -isystem $glibc/include"
|
||||
ldflags="-L$glibc/lib -L$gcc/lib " \
|
||||
"-dynamic-linker $glibc/lib/ld-linux.so.2" \
|
||||
"-rpath $glibc/lib -rpath $gcc/lib"
|
||||
else
|
||||
cflagsCompile="-B$out/bin"
|
||||
fi
|
||||
|
||||
mkdir $out
|
||||
mkdir $out/bin
|
||||
|
||||
|
||||
mkGccWrapper () {
|
||||
local dst=$1
|
||||
local src=$2
|
||||
|
||||
if ! test -f "$src"; then
|
||||
echo "$src does not exist (skipping)"
|
||||
return
|
||||
fi
|
||||
|
||||
sed \
|
||||
-e "s^@cflagsCompile@^$cflagsCompile^g" \
|
||||
-e "s^@cflagsLink@^$cflagsLink^g" \
|
||||
-e "s^@ldflags@^$ldflags^g" \
|
||||
-e "s^@gcc@^$src^g" \
|
||||
< $gccWrapper > $dst
|
||||
chmod +x $dst
|
||||
|
||||
}
|
||||
|
||||
mkGccWrapper $out/bin/gcc $gcc/bin/gcc
|
||||
ln -s gcc $out/bin/cc
|
||||
|
||||
mkGccWrapper $out/bin/g++ $gcc/bin/g++
|
||||
ln -s g++ $out/bin/c++
|
||||
|
||||
mkGccWrapper $out/bin/g77 $gcc/bin/g77
|
||||
ln -s g77 $out/bin/f77
|
||||
|
||||
|
||||
sed \
|
||||
-e "s^@ldflags@^$ldflags^g" \
|
||||
-e "s^@ld@^$gcc/bin/ld^g" \
|
||||
< $ldWrapper > $out/bin/ld
|
||||
chmod +x $out/bin/ld
|
||||
|
||||
|
||||
mkdir $out/nix-support
|
||||
test -z "$isNative" && echo $gcc > $out/nix-support/orig-gcc
|
||||
test -z "$isNative" && echo $glibc > $out/nix-support/orig-glibc
|
||||
|
||||
sed \
|
||||
-e "s^@isNative@^$isNative^g" \
|
||||
-e "s^@gcc@^$gcc^g" \
|
||||
-e "s^@glibc@^$glibc^g" \
|
||||
< $setupHook > $out/nix-support/setup-hook
|
23
pkgs/build-support/gcc-wrapper/default.nix
Normal file
23
pkgs/build-support/gcc-wrapper/default.nix
Normal file
@ -0,0 +1,23 @@
|
||||
# The Nix `gcc' derivation 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
|
||||
# derivation provides a wrapper that sets up the right environment
|
||||
# variables so that the compiler and the linker just "work".
|
||||
|
||||
{name, stdenv, isNative, gcc ? null, glibc ? null, binutils ? null}:
|
||||
|
||||
assert isNative -> gcc != "";
|
||||
assert !isNative -> gcc != null && glibc != null && binutils != null;
|
||||
|
||||
derivation {
|
||||
system = stdenv.system;
|
||||
builder = ./builder.sh;
|
||||
setupHook = ./setup-hook.sh;
|
||||
gccWrapper = ./gcc-wrapper.sh;
|
||||
ldWrapper = ./ld-wrapper.sh;
|
||||
inherit name stdenv isNative gcc glibc binutils;
|
||||
langC = if isNative then true else gcc.langC;
|
||||
langCC = if isNative then true else gcc.langCC;
|
||||
langF77 = if isNative then false else gcc.langF77;
|
||||
}
|
74
pkgs/build-support/gcc-wrapper/gcc-wrapper.sh
Normal file
74
pkgs/build-support/gcc-wrapper/gcc-wrapper.sh
Normal file
@ -0,0 +1,74 @@
|
||||
#! /bin/sh
|
||||
|
||||
if test -n "$NIX_GCC_WRAPPER_START_HOOK"; then
|
||||
. "$NIX_GCC_WRAPPER_START_HOOK"
|
||||
fi
|
||||
|
||||
if test -z "$NIX_GLIBC_FLAGS_SET"; then
|
||||
NIX_CFLAGS_COMPILE="@cflagsCompile@ $NIX_CFLAGS_COMPILE"
|
||||
NIX_CFLAGS_LINK="@cflagsLink@ $NIX_CFLAGS_LINK"
|
||||
NIX_LDFLAGS="@ldflags@ $NIX_LDFLAGS"
|
||||
fi
|
||||
|
||||
# Figure out if linker flags should be passed. GCC prints annoying
|
||||
# warnings when they are not needed.
|
||||
dontLink=0
|
||||
if test "$*" = "-v"; then
|
||||
dontLink=1
|
||||
else
|
||||
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
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
# Add the flags for the C compiler proper.
|
||||
extra=($NIX_CFLAGS_COMPILE)
|
||||
|
||||
if test "$dontLink" != "1"; then
|
||||
|
||||
# Add the flags that should only be passed to the compiler when
|
||||
# linking.
|
||||
extra=(${extra[@]} $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; do
|
||||
extra=(${extra[@]} "-Wl,$i")
|
||||
done
|
||||
export NIX_LDFLAGS_SET=1
|
||||
|
||||
if test "$NIX_STRIP_DEBUG" = "1"; then
|
||||
# Add executable-stripping flags.
|
||||
extra=(${extra[@]} $NIX_CFLAGS_STRIP)
|
||||
fi
|
||||
fi
|
||||
|
||||
# Optionally print debug info.
|
||||
if test "$NIX_DEBUG" = "1"; then
|
||||
echo "original flags to @gcc@:" >&2
|
||||
for i in "$@"; do
|
||||
echo " $i" >&2
|
||||
done
|
||||
echo "extra flags to @gcc@:" >&2
|
||||
for i in ${extra[@]}; do
|
||||
echo " $i" >&2
|
||||
done
|
||||
fi
|
||||
|
||||
if test -n "$NIX_GCC_WRAPPER_EXEC_HOOK"; then
|
||||
. "$NIX_GCC_WRAPPER_EXEC_HOOK"
|
||||
fi
|
||||
|
||||
exec @gcc@ "$@" ${extra[@]}
|
28
pkgs/build-support/gcc-wrapper/ld-wrapper.sh
Normal file
28
pkgs/build-support/gcc-wrapper/ld-wrapper.sh
Normal file
@ -0,0 +1,28 @@
|
||||
#! /bin/sh
|
||||
|
||||
if test -n "$NIX_LD_WRAPPER_START_HOOK"; then
|
||||
. "$NIX_LD_WRAPPER_START_HOOK"
|
||||
fi
|
||||
|
||||
extra=()
|
||||
|
||||
if test -z "$NIX_LDFLAGS_SET"; then
|
||||
extra=(${extra[@]} $NIX_LDFLAGS)
|
||||
fi
|
||||
|
||||
if test "$NIX_DEBUG" = "1"; then
|
||||
echo "original flags to @ld@:" >&2
|
||||
for i in "$@"; 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
|
||||
. "$NIX_LD_WRAPPER_EXEC_HOOK"
|
||||
fi
|
||||
|
||||
exec @ld@ "$@" ${extra[@]}
|
15
pkgs/build-support/gcc-wrapper/setup-hook.sh
Normal file
15
pkgs/build-support/gcc-wrapper/setup-hook.sh
Normal file
@ -0,0 +1,15 @@
|
||||
addCVars () {
|
||||
if test -d $1/include; then
|
||||
export NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE -I$1/include"
|
||||
fi
|
||||
|
||||
if test -d $1/lib; then
|
||||
export NIX_LDFLAGS="$NIX_LDFLAGS -L$1/lib -rpath $1/lib"
|
||||
fi
|
||||
}
|
||||
|
||||
envHooks=(${envHooks[@]} addCVars)
|
||||
|
||||
if test -z "@isNative@"; then
|
||||
PATH=$PATH:@gcc@/bin:@glibc@/bin
|
||||
fi
|
@ -1,65 +0,0 @@
|
||||
#! /bin/sh -e
|
||||
|
||||
. $stdenv/setup
|
||||
|
||||
mkdir $out
|
||||
mkdir $out/bin
|
||||
for i in $(cd $gcc/bin && ls); do
|
||||
cat > $out/bin/$i <<EOF
|
||||
#! /bin/sh
|
||||
|
||||
_NIX_CFLAGS_COMPILE="-B$glibc/lib -isystem $glibc/include $NIX_CFLAGS_COMPILE"
|
||||
_NIX_CFLAGS_LINK="-L$glibc/lib -L$gcc/lib $NIX_CFLAGS_LINK"
|
||||
_NIX_LDFLAGS="-dynamic-linker $glibc/lib/ld-linux.so.2 -rpath $glibc/lib -rpath $gcc/lib $NIX_LDFLAGS"
|
||||
|
||||
IFS=
|
||||
|
||||
justcompile=0
|
||||
if test "\$*" = "-v"; then
|
||||
justcompile=1
|
||||
else
|
||||
for i in \$@; do
|
||||
if test "\$i" == "-c"; then
|
||||
justcompile=1
|
||||
elif test "\$i" == "-S"; then
|
||||
justcompile=1
|
||||
elif test "\$i" == "-E"; then
|
||||
justcompile=1
|
||||
elif test "\$i" == "-E"; then
|
||||
justcompile=1
|
||||
elif test "\$i" == "-M"; then
|
||||
justcompile=1
|
||||
elif test "\$i" == "-MM"; then
|
||||
justcompile=1
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
IFS=" "
|
||||
extra=(\$_NIX_CFLAGS_COMPILE)
|
||||
if test "\$justcompile" != "1"; then
|
||||
extra=(\${extra[@]} \$_NIX_CFLAGS_LINK)
|
||||
for i in \$_NIX_LDFLAGS; do
|
||||
extra=(\${extra[@]} "-Wl,\$i")
|
||||
done
|
||||
if test "\$_NIX_STRIP_DEBUG" == "1"; then
|
||||
extra=(\${extra[@]} -g0 -Wl,-s)
|
||||
fi
|
||||
fi
|
||||
|
||||
if test "\$NIX_DEBUG" == "1"; then
|
||||
echo "extra flags to @GCC@:" >&2
|
||||
for i in \${extra[@]}; do
|
||||
echo " \$i" >&2
|
||||
done
|
||||
fi
|
||||
|
||||
IFS=
|
||||
|
||||
exec $gcc/bin/$i \$@ \${extra[@]}
|
||||
EOF
|
||||
chmod +x $out/bin/$i
|
||||
done
|
||||
|
||||
echo $gcc > $out/orig-gcc
|
||||
echo $glibc > $out/orig-glibc
|
@ -1,17 +0,0 @@
|
||||
# The Nix `gcc' derivation 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
|
||||
# derivation provides a wrapper that sets up the right environment
|
||||
# variables so that the compiler and the linker just "work".
|
||||
|
||||
{stdenv, gcc}:
|
||||
|
||||
derivation {
|
||||
name = gcc.name; # maybe a bad idea
|
||||
system = stdenv.system;
|
||||
builder = ./builder.sh;
|
||||
glibc = stdenv.param4; # !!! hack
|
||||
inherit stdenv gcc;
|
||||
inherit (gcc) langC langCC langF77;
|
||||
}
|
@ -1,41 +1,17 @@
|
||||
#! /bin/sh
|
||||
|
||||
# Set up the initial path.
|
||||
for i in $initialPath; do
|
||||
PATH=$PATH:$i/bin
|
||||
done
|
||||
. $stdenv/setup
|
||||
|
||||
# Make output directories.
|
||||
mkdir $out || exit 1
|
||||
mkdir $out/bin || exit 1
|
||||
|
||||
# Create the setup script.
|
||||
sed \
|
||||
-e "s^@OUT@^$out^g" \
|
||||
-e "s^@PREHOOK@^$prehook^g" \
|
||||
-e "s^@POSTHOOK@^$posthook^g" \
|
||||
-e "s^@INITIALPATH@^$initialPath^g" \
|
||||
-e "s^@PARAM1@^$param1^g" \
|
||||
-e "s^@PARAM2@^$param2^g" \
|
||||
-e "s^@PARAM3@^$param3^g" \
|
||||
-e "s^@PARAM4@^$param4^g" \
|
||||
-e "s^@PARAM5@^$param5^g" \
|
||||
-e "s^@preHook@^$preHook^g" \
|
||||
-e "s^@postHook@^$postHook^g" \
|
||||
-e "s^@initialPath@^$initialPath^g" \
|
||||
-e "s^@gcc@^$gcc^g" \
|
||||
-e "s^@param1@^$param1^g" \
|
||||
-e "s^@param2@^$param2^g" \
|
||||
-e "s^@param3@^$param3^g" \
|
||||
-e "s^@param4@^$param4^g" \
|
||||
-e "s^@param5@^$param5^g" \
|
||||
< $setup > $out/setup || exit 1
|
||||
|
||||
# Create the gcc wrapper.
|
||||
sed \
|
||||
-e 's^@GCC\@^$NIX_CC^g' \
|
||||
< $gccwrapper > $out/bin/gcc || exit 1
|
||||
chmod +x $out/bin/gcc || exit 1
|
||||
ln -s gcc $out/bin/cc || exit 1
|
||||
|
||||
# Create the g++ wrapper.
|
||||
sed \
|
||||
-e 's^@GCC\@^$NIX_CXX^g' \
|
||||
< $gccwrapper > $out/bin/g++ || exit 1
|
||||
chmod +x $out/bin/g++ || exit 1
|
||||
ln -s g++ $out/bin/c++ || exit 1
|
||||
|
||||
# Create the ld wrapper.
|
||||
cp $ldwrapper $out/bin/ld || exit 1
|
||||
chmod +x $out/bin/ld || exit 1
|
||||
|
@ -1,23 +1,17 @@
|
||||
{system, name, noSysDirs, prehook, posthook, initialPath,
|
||||
param1, param2, param3, param4, param5}:
|
||||
{ stdenv, name, preHook, postHook, initialPath, gcc
|
||||
, param1 ? "", param2 ? "", param3 ? "", param4 ? "", param5 ? ""
|
||||
}:
|
||||
|
||||
derivation {
|
||||
name = name;
|
||||
system = system;
|
||||
inherit stdenv name;
|
||||
system = stdenv.system;
|
||||
|
||||
builder = ./builder.sh;
|
||||
noSysDirs = noSysDirs;
|
||||
|
||||
setup = ./setup.sh;
|
||||
gccwrapper = ./gcc-wrapper.sh;
|
||||
ldwrapper = ./ld-wrapper.sh;
|
||||
|
||||
prehook = prehook;
|
||||
posthook = posthook;
|
||||
inherit preHook postHook initialPath gcc;
|
||||
|
||||
initialPath = initialPath;
|
||||
# TODO: make this more elegant.
|
||||
param1 = param1;
|
||||
param2 = param2;
|
||||
param3 = param3;
|
||||
param4 = param4;
|
||||
param5 = param5;
|
||||
inherit param1 param2 param3 param4 param5;
|
||||
}
|
||||
|
@ -1,42 +0,0 @@
|
||||
#! /bin/sh
|
||||
|
||||
IFS=
|
||||
|
||||
justcompile=0
|
||||
for i in $@; do
|
||||
if test "$i" == "-c"; then
|
||||
justcompile=1
|
||||
elif test "$i" == "-S"; then
|
||||
justcompile=1
|
||||
elif test "$i" == "-E"; then
|
||||
justcompile=1
|
||||
elif test "$i" == "-E"; then
|
||||
justcompile=1
|
||||
elif test "$i" == "-M"; then
|
||||
justcompile=1
|
||||
elif test "$i" == "-MM"; then
|
||||
justcompile=1
|
||||
fi
|
||||
done
|
||||
|
||||
IFS=" "
|
||||
extra=($NIX_CFLAGS_COMPILE)
|
||||
if test "$justcompile" != "1"; then
|
||||
extra=(${extra[@]} $NIX_CFLAGS_LINK)
|
||||
for i in $NIX_LDFLAGS; do
|
||||
extra=(${extra[@]} "-Wl,$i")
|
||||
done
|
||||
if test "$NIX_STRIP_DEBUG" == "1"; then
|
||||
extra=(${extra[@]} -g0 -Wl,-s)
|
||||
fi
|
||||
fi
|
||||
|
||||
if test "$NIX_DEBUG" == "1"; then
|
||||
echo "extra flags to @GCC@:" >&2
|
||||
for i in ${extra[@]}; do
|
||||
echo " $i" >&2
|
||||
done
|
||||
fi
|
||||
|
||||
IFS=
|
||||
exec @GCC@ $@ ${extra[@]}
|
@ -1,17 +0,0 @@
|
||||
#! /bin/sh
|
||||
|
||||
IFS=" "
|
||||
extra=($NIX_CFLAGS_LINK $NIX_LDFLAGS)
|
||||
if test "$NIX_STRIP_DEBUG" == "1"; then
|
||||
extra=(${extra[@]} -s)
|
||||
fi
|
||||
|
||||
if test "$NIX_DEBUG" == "1"; then
|
||||
echo "extra flags to @LD@:" >&2
|
||||
for i in ${extra[@]}; do
|
||||
echo " $i" >&2
|
||||
done
|
||||
fi
|
||||
|
||||
IFS=
|
||||
exec $NIX_LD $@ ${extra[@]}
|
@ -1,67 +1,85 @@
|
||||
set -e
|
||||
|
||||
|
||||
# Set up the initial path.
|
||||
for i in @INITIALPATH@; do
|
||||
PATH=$PATH:$i/bin
|
||||
PATH=
|
||||
for i in @gcc@ @initialPath@; do
|
||||
PATH=$PATH${PATH:+:}$i/bin
|
||||
done
|
||||
echo $PATH
|
||||
|
||||
if test "$NIX_DEBUG" = "1"; then
|
||||
echo "Initial path: $PATH"
|
||||
fi
|
||||
|
||||
|
||||
# Execute the pre-hook.
|
||||
param1=@PARAM1@
|
||||
param2=@PARAM2@
|
||||
param3=@PARAM3@
|
||||
param4=@PARAM4@
|
||||
param5=@PARAM5@
|
||||
. @PREHOOK@
|
||||
param1=@param1@
|
||||
param2=@param2@
|
||||
param3=@param3@
|
||||
param4=@param4@
|
||||
param5=@param5@
|
||||
. @preHook@
|
||||
|
||||
# Add the directory containing the GCC wrappers to the PATH.
|
||||
export PATH=@OUT@/bin:$PATH
|
||||
|
||||
# Recursively add all buildinputs to the relevant environment variables.
|
||||
addtoenv()
|
||||
# Recursively find all build inputs.
|
||||
findInputs()
|
||||
{
|
||||
pkgs="$buildinputs $1"
|
||||
local pkg=$1
|
||||
pkgs=(${pkgs[@]} $pkg)
|
||||
|
||||
if test -d $1/bin; then
|
||||
export PATH=$1/bin:$PATH
|
||||
if test -f $pkg/nix-support/setup-hook; then
|
||||
. $pkg/nix-support/setup-hook
|
||||
fi
|
||||
|
||||
if test -d $1/lib; then
|
||||
export NIX_CFLAGS_LINK="-L$1/lib $NIX_CFLAGS_LINK"
|
||||
export NIX_LDFLAGS="-rpath $1/lib $NIX_LDFLAGS"
|
||||
fi
|
||||
|
||||
if test -d $1/lib/pkgconfig; then
|
||||
export PKG_CONFIG_PATH=$1/lib/pkgconfig:$PKG_CONFIG_PATH
|
||||
fi
|
||||
|
||||
if test -d $1/include; then
|
||||
export NIX_CFLAGS_COMPILE="-I$1/include $NIX_CFLAGS_COMPILE"
|
||||
fi
|
||||
|
||||
if test -f $1/propagated-build-inputs; then
|
||||
for i in $(cat $1/propagated-build-inputs); do
|
||||
addtoenv $i
|
||||
|
||||
if test -f $pkg/nix-support/propagated-build-inputs; then
|
||||
for i in $(cat $pkg/nix-support/propagated-build-inputs); do
|
||||
addToEnv $pkg
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
oldbuildinputs=$buildinputs
|
||||
buildinputs=
|
||||
|
||||
for i in $oldbuildinputs; do
|
||||
addtoenv $i
|
||||
pkgs=()
|
||||
envHooks=()
|
||||
for i in $buildinputs; do
|
||||
findInputs $i
|
||||
done
|
||||
|
||||
|
||||
# Set the relevant environment variables to point to the build inputs
|
||||
# found above.
|
||||
addToEnv()
|
||||
{
|
||||
local pkg=$1
|
||||
|
||||
if test -d $1/bin; then
|
||||
export _PATH=$_PATH:$1/bin
|
||||
fi
|
||||
|
||||
for i in "${envHooks[@]}"; do
|
||||
$i $pkg
|
||||
done
|
||||
}
|
||||
|
||||
for i in "${pkgs[@]}"; do
|
||||
addToEnv $i
|
||||
done
|
||||
|
||||
|
||||
# Add the output as an rpath.
|
||||
if test "$NIX_NO_SELF_RPATH" != "1"; then
|
||||
export NIX_LDFLAGS="-rpath $out/lib $NIX_LDFLAGS"
|
||||
fi
|
||||
|
||||
|
||||
# Strip debug information by default.
|
||||
export NIX_STRIP_DEBUG=1
|
||||
export NIX_CFLAGS_STRIP="-g0 -Wl,-s"
|
||||
|
||||
|
||||
# Execute the post-hook.
|
||||
. @POSTHOOK@
|
||||
. @postHook@
|
||||
|
||||
if test "$NIX_DEBUG" == "1"; then
|
||||
echo "Setup: PATH=$PATH"
|
||||
PATH=$_PATH${_PATH}$PATH
|
||||
if test "$NIX_DEBUG" = "1"; then
|
||||
echo "Final path: $PATH"
|
||||
fi
|
||||
|
9
pkgs/stdenv/initial/builder.sh
Executable file
9
pkgs/stdenv/initial/builder.sh
Executable file
@ -0,0 +1,9 @@
|
||||
#! /bin/sh -e
|
||||
|
||||
export PATH=/usr/bin:/bin
|
||||
|
||||
mkdir $out
|
||||
cat > $out/setup <<EOF
|
||||
export PATH=/usr/bin:/bin
|
||||
EOF
|
||||
chmod +x $out/setup
|
11
pkgs/stdenv/initial/default.nix
Normal file
11
pkgs/stdenv/initial/default.nix
Normal file
@ -0,0 +1,11 @@
|
||||
# Here we construct an absolutely trivial `initial' standard
|
||||
# environment. It's not actually a functional stdenv, since there is
|
||||
# not necessarily a working C compiler. We need this to build
|
||||
# gcc-wrapper et al. for the native stdenv.
|
||||
|
||||
{system, name}:
|
||||
|
||||
derivation {
|
||||
inherit system name;
|
||||
builder = ./builder.sh;
|
||||
}
|
@ -1,13 +1,17 @@
|
||||
{system}: (import ../generic) {
|
||||
{stdenv}:
|
||||
|
||||
(import ../generic) {
|
||||
name = "stdenv-native";
|
||||
system = system;
|
||||
prehook = ./prehook.sh;
|
||||
posthook = ./posthook.sh;
|
||||
preHook = ./prehook.sh;
|
||||
postHook = ./posthook.sh;
|
||||
initialPath = "/usr/local /usr /";
|
||||
param1 = "";
|
||||
param2 = "";
|
||||
param3 = "";
|
||||
param4 = "";
|
||||
param5 = "";
|
||||
noSysDirs = false;
|
||||
|
||||
inherit stdenv;
|
||||
|
||||
gcc = (import ../../build-support/gcc-wrapper) {
|
||||
inherit stdenv;
|
||||
name = "gcc-native";
|
||||
isNative = true;
|
||||
gcc = "/usr";
|
||||
};
|
||||
}
|
||||
|
@ -1,5 +1 @@
|
||||
export SHELL=/bin/sh
|
||||
|
||||
export NIX_CC=/usr/bin/gcc
|
||||
export NIX_CXX=/usr/bin/g++
|
||||
export NIX_LD=/usr/bin/ld
|
||||
|
@ -201,7 +201,7 @@
|
||||
inherit fetchurl stdenv binutils;
|
||||
};
|
||||
|
||||
g77 = (import ../development/compilers/gcc-wrapper) {
|
||||
g77 = (import ../build-support/gcc-wrapper) {
|
||||
inherit stdenv;
|
||||
gcc = (import ../development/compilers/gcc-new) {
|
||||
inherit fetchurl stdenv;
|
||||
|
41
pkgs/test/simple/builder.sh
Executable file
41
pkgs/test/simple/builder.sh
Executable file
@ -0,0 +1,41 @@
|
||||
#! /bin/sh
|
||||
|
||||
export NIX_DEBUG=1
|
||||
|
||||
. $stdenv/setup
|
||||
|
||||
export NIX_CFLAGS_COMPILE="-v $NIX_CFLAGS_COMPILE"
|
||||
|
||||
mkdir $out
|
||||
mkdir $out/bin
|
||||
|
||||
cat > hello.c <<EOF
|
||||
#include <stdio.h>
|
||||
|
||||
int main(int argc, char * * argv)
|
||||
{
|
||||
printf("Hello World!\n");
|
||||
return 0;
|
||||
}
|
||||
EOF
|
||||
|
||||
gcc hello.c -o $out/bin/hello
|
||||
|
||||
$out/bin/hello
|
||||
|
||||
cat > hello2.cc <<EOF
|
||||
#include <iostream>
|
||||
|
||||
int main(int argc, char * * argv)
|
||||
{
|
||||
std::cout << "Hello World!\n";
|
||||
std::cout << VALUE << std::endl;
|
||||
return 0;
|
||||
}
|
||||
EOF
|
||||
|
||||
g++ hello2.cc -o $out/bin/hello2 -DVALUE="1 + 2 * 3"
|
||||
|
||||
$out/bin/hello2
|
||||
|
||||
ld -v
|
18
pkgs/test/simple/default.nix
Normal file
18
pkgs/test/simple/default.nix
Normal file
@ -0,0 +1,18 @@
|
||||
let {
|
||||
system = "i686-linux";
|
||||
|
||||
stdenvInitial = (import ../../stdenv/initial) {
|
||||
name = "stdenv-initial";
|
||||
inherit system;
|
||||
};
|
||||
|
||||
stdenv = (import ../../stdenv/native) {stdenv = stdenvInitial;};
|
||||
|
||||
test = derivation {
|
||||
name = "simple-test";
|
||||
inherit system stdenv;
|
||||
builder = ./builder.sh;
|
||||
};
|
||||
|
||||
body = test;
|
||||
}
|
Loading…
Reference in New Issue
Block a user