Revert "Merge pull request #28557 from obsidiansystems/binutils-wrapper"
This reverts commit0a944b345e
, reversing changes made to61733ed6cc
. I dislike these massive stdenv changes with unclear motivation, especially when they involve gratuitous mass renames like NIX_CC -> NIX_BINUTILS. The previous such rename (NIX_GCC -> NIX_CC) caused months of pain, so let's not do that again.
This commit is contained in:
parent
d38ee5b46c
commit
ec8d41f08c
183 changed files with 548 additions and 881 deletions
|
@ -1,3 +1,4 @@
|
|||
|
||||
<chapter xmlns="http://docbook.org/ns/docbook"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||
xml:id="chap-stdenv">
|
||||
|
@ -1341,58 +1342,33 @@ someVar=$(stripHash $name)
|
|||
|
||||
<variablelist>
|
||||
|
||||
<varlistentry>
|
||||
<term>Binutils Wrapper</term>
|
||||
<listitem>
|
||||
<para>
|
||||
Binutils Wrapper wraps the binary utilities for a bunch of miscellaneous purposes.
|
||||
Specifically, GNU Binutils (for Linux, but a mix of cctools and GNU Binutils for Darwin), and a C standard library (glibc or Darwin's libSystem, just for the dynamic loader) are all fed in, and dependency finding, hardening (see below), and purity checks for each are handled by Binutils Wrapper.
|
||||
Packages typically depend on CC Wrapper, which in turn (at run time) depends on binutils-wrapper.
|
||||
</para>
|
||||
<para>
|
||||
Binutils Wrapper was only just recently split off from CC Wrapper, so the division of labor is still being worked out.
|
||||
For example, it shouldn't care about about the C standard library, but just take a derivation with the dynamic loader (which happens to be the glibc on linux).
|
||||
Dependency finding however is a task both wrappers will continue to need to share, and probably the most important to understand.
|
||||
It is currently accomplished by collecting directories of host-platform dependencies (i.e. <varname>buildInputs</varname> and <varname>nativeBuildInputs</varname>) in environment variables.
|
||||
Binutils Wrapper's setup hook causes any <filename>lib</filename> and <filename>lib64</filename> subdirectories to <envar>NIX_LDFLAGS</envar>.
|
||||
Sine CC Wrapper and Binutils Wrapper use the same strategy, most of the Binutils Wrapper code is sparsely commented and refers to CC Wrapper.
|
||||
But CC Wrapper's code, by contrast, has quite lengthy comments.
|
||||
Binutils Wrapper merely cites those, rather than repeating them, to avoid falling out of sync.
|
||||
</para>
|
||||
<para>
|
||||
A final task of the setup hook is defining a number of standard environment variables to tell build systems which executables full-fill which purpose.
|
||||
They are defined to just be the base name of the tools, under the assumption that Binutils Wrapper's binaries will be on the path.
|
||||
Firstly, this helps poorly-written packages, e.g. ones that look for just <command>gcc</command> when <envar>CC</envar> isn't defined yet <command>clang</command> is to be used.
|
||||
Secondly, this helps packages not get confused when cross-compiling, in which case multiple Binutils Wrappers may be simultaneous in use (targeting different platforms).
|
||||
<envar>BUILD_</envar>- and <envar>TARGET_</envar>-prefixed versions of the normal environment variable are defined for the additional Binutils Wrappers, properly disambiguating them.
|
||||
</para>
|
||||
<para>
|
||||
A problem with this final task is that Binutils Wrapper is honest and defines <envar>LD</envar> as <command>ld</command>.
|
||||
Most packages, however, firstly use the C compiler for linking, secondly use <envar>LD</envar> anyways, defining it as the C compiler, and thirdly, only so define <envar>LD</envar> when it is undefined as a fallback.
|
||||
This triple-threat means Binutils Wrapper will break those packages, as LD is already defined as the actually linker which the package won't override yet doesn't want to use.
|
||||
The workaround is to define, just for the problematic package, <envar>LD</envar> as the C compiler.
|
||||
A good way to do this would be <command>preConfigure = "LD=$CC"</command>.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>CC Wrapper</term>
|
||||
<listitem>
|
||||
<para>
|
||||
CC Wrapper wraps a C toolchain for a bunch of miscellaneous purposes.
|
||||
Specifically, a C compiler (GCC or Clang), Binutils (or the CCTools + binutils mashup when targetting Darwin), and a C standard library (glibc or Darwin's libSystem, just for the dynamic loader) are all fed in, and dependency finding, hardening (see below), and purity checks for each are handled by Binutils Wrapper.
|
||||
Packages typically depend on CC Wrapper, which in turn (at run time) depends on Binutils Wrapper.
|
||||
Specifically, a C compiler (GCC or Clang), Binutils (or the CCTools + binutils mashup when targetting Darwin), and a C standard library (glibc or Darwin's libSystem) are all fed in, and dependency finding, hardening (see below), and purity checks for each are handled by CC Wrapper.
|
||||
Packages typically depend on only CC Wrapper, instead of those 3 inputs directly.
|
||||
</para>
|
||||
<para>
|
||||
Dependency finding is undoubtedly the main task of CC Wrapper.
|
||||
This works just like Binutils Wrapper, except the any <filename>include</filename> subdirectory of any relevant dependency is added to <envar>NIX_CFLAGS_COMPILE</envar>.
|
||||
Dependency finding is undoubtedly the main task of CC wrapper.
|
||||
It is currently accomplished by collecting directories of host-platform dependencies (i.e. <varname>buildInputs</varname> and <varname>nativeBuildInputs</varname>) in environment variables.
|
||||
CC wrapper's setup hook causes any <filename>include</filename> subdirectory of such a dependency to be added to <envar>NIX_CFLAGS_COMPILE</envar>, and any <filename>lib</filename> and <filename>lib64</filename> subdirectories to <envar>NIX_LDFLAGS</envar>.
|
||||
The setup hook itself contains some lengthy comments describing the exact convoluted mechanism by which this is accomplished.
|
||||
</para>
|
||||
<para>
|
||||
CC Wrapper also like Binutils Wrapper defines standard environment variables with the names of the tools it wraps, for the same reasons described above.
|
||||
Importantly, while it includes a <command>cc</command> symlink to the c compiler for portability, the <envar>CC</envar> will be defined using the compiler's "real name" (i.e. <command>gcc</command> or <command>clang</command>).
|
||||
This helps lousy build systems that inspect on the name of the compiler rather than run it.
|
||||
A final task of the setup hook is defining a number of standard environment variables to tell build systems which executables full-fill which purpose.
|
||||
They are defined to just be the base name of the tools, under the assumption that CC Wrapper's binaries will be on the path.
|
||||
Firstly, this helps poorly-written packages, e.g. ones that look for just <command>gcc</command> when <envar>CC</envar> isn't defined yet <command>clang</command> is to be used.
|
||||
Secondly, this helps packages not get confused when cross-compiling, in which case multiple CC wrappers may be simultaneous in use (targeting different platforms).
|
||||
<envar>BUILD_</envar>- and <envar>TARGET_</envar>-prefixed versions of the normal environment variable are defined for the additional CC Wrappers, properly disambiguating them.
|
||||
</para>
|
||||
<para>
|
||||
A problem with this final task is that CC Wrapper is honest and defines <envar>LD</envar> as <command>ld</command>.
|
||||
Most packages, however, firstly use the C compiler for linking, secondly use <envar>LD</envar> anyways, defining it as the C compiler, and thirdly, only so define <envar>LD</envar> when it is undefined as a fallback.
|
||||
This triple-threat means CC Wrapper will break those packages, as LD is already defined as the actually linker which the package won't override yet doesn't want to use.
|
||||
The workaround is to define, just for the problematic package, <envar>LD</envar> as the C compiler.
|
||||
A good way to do this would be <command>preConfigure = "LD=$CC"</command>.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
|
|
@ -35,7 +35,7 @@ stdenv.mkDerivation rec {
|
|||
|
||||
buildPhase = ''
|
||||
patchelf \
|
||||
--set-interpreter "$(cat $NIX_BINUTILS/nix-support/dynamic-linker)" \
|
||||
--set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
|
||||
--set-rpath "$out/opt/google/musicmanager:${stdenv.lib.makeLibraryPath [ readline ncurses stdenv.cc.libc.out qt48 stdenv.cc.cc libidn expat flac libvorbis ]}" opt/google/musicmanager/MusicManager
|
||||
'';
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ stdenv.mkDerivation {
|
|||
cp -r ./usr/share $out
|
||||
cp -r ./usr/bin $out
|
||||
|
||||
patchelf --set-interpreter "$(cat $NIX_BINUTILS/nix-support/dynamic-linker)" \
|
||||
patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
|
||||
"$out/share/google-play-music-desktop-player/Google Play Music Desktop Player"
|
||||
|
||||
wrapProgram $out/bin/google-play-music-desktop-player \
|
||||
|
|
|
@ -49,7 +49,7 @@ stdenv.mkDerivation rec {
|
|||
mkdir $out/bin
|
||||
ln -s $out/renoise $out/bin/renoise
|
||||
|
||||
patchelf --set-interpreter $(cat $NIX_BINUTILS/nix-support/dynamic-linker) --set-rpath $out/lib $out/renoise
|
||||
patchelf --set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) --set-rpath $out/lib $out/renoise
|
||||
'';
|
||||
|
||||
meta = {
|
||||
|
|
|
@ -89,7 +89,7 @@ stdenv.mkDerivation {
|
|||
rpath="$out/share/spotify:$libdir"
|
||||
|
||||
patchelf \
|
||||
--interpreter "$(cat $NIX_BINUTILS/nix-support/dynamic-linker)" \
|
||||
--interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
|
||||
--set-rpath $rpath $out/share/spotify/spotify
|
||||
|
||||
librarypath="${stdenv.lib.makeLibraryPath deps}:$libdir"
|
||||
|
|
|
@ -25,10 +25,10 @@ stdenv.mkDerivation rec {
|
|||
|
||||
fixupPhase
|
||||
|
||||
patchelf --set-interpreter "$(cat $NIX_BINUTILS/nix-support/dynamic-linker)" \
|
||||
patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
|
||||
--set-rpath "${atomEnv.libPath}:$out/share/atom" \
|
||||
$out/share/atom/atom
|
||||
patchelf --set-interpreter "$(cat $NIX_BINUTILS/nix-support/dynamic-linker)" \
|
||||
patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
|
||||
--set-rpath "${atomEnv.libPath}" \
|
||||
$out/share/atom/resources/app/apm/bin/node
|
||||
|
||||
|
|
|
@ -36,11 +36,11 @@ stdenv.mkDerivation rec {
|
|||
'';
|
||||
|
||||
postFixup = ''
|
||||
patchelf --set-interpreter "$(cat $NIX_BINUTILS/nix-support/dynamic-linker)" \
|
||||
patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
|
||||
--set-rpath "${bracketsLibs}:$out/opt/brackets/lib" \
|
||||
$out/opt/brackets/Brackets
|
||||
|
||||
patchelf --set-interpreter "$(cat $NIX_BINUTILS/nix-support/dynamic-linker)" \
|
||||
patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
|
||||
--set-rpath "${bracketsLibs}" \
|
||||
$out/opt/brackets/Brackets-node
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ let
|
|||
ln -s ${cmake} bin/cmake
|
||||
|
||||
lldbLibPath=$out/clion-${version}/bin/lldb/lib
|
||||
interp="$(cat $NIX_BINUTILS/nix-support/dynamic-linker)"
|
||||
interp="$(cat $NIX_CC/nix-support/dynamic-linker)"
|
||||
ln -s ${ncurses.out}/lib/libncurses.so $lldbLibPath/libtinfo.so.5
|
||||
|
||||
patchelf --set-interpreter $interp \
|
||||
|
|
|
@ -50,31 +50,31 @@ in
|
|||
postFixup = lib.optionalString (stdenv.system == "i686-linux" || stdenv.system == "x86_64-linux") ''
|
||||
# Patch Binaries
|
||||
patchelf \
|
||||
--set-interpreter "$(cat $NIX_BINUTILS/nix-support/dynamic-linker)" \
|
||||
--set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
|
||||
--set-rpath "$out:${atomEnv.libPath}" \
|
||||
$out/kodestudio
|
||||
patchelf \
|
||||
--set-interpreter "$(cat $NIX_BINUTILS/nix-support/dynamic-linker)" \
|
||||
--set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
|
||||
--set-rpath ".:${stdenv.cc.libc}/lib:${xorg.libXinerama}/lib:${xorg.libX11}/lib:${alsaLib}/lib:${mesa}/lib:${openssl.out}/lib" \
|
||||
$out/resources/app/extensions/krom/Krom/linux/Krom
|
||||
patchelf \
|
||||
--set-interpreter "$(cat $NIX_BINUTILS/nix-support/dynamic-linker)" \
|
||||
--set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
|
||||
--set-rpath ".:${stdenv.cc.libc}/lib" \
|
||||
$out/resources/app/extensions/kha/Kha/Kore/Tools/krafix/krafix-linux64
|
||||
patchelf \
|
||||
--set-interpreter "$(cat $NIX_BINUTILS/nix-support/dynamic-linker)" \
|
||||
--set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
|
||||
--set-rpath ".:${stdenv.cc.libc}/lib" \
|
||||
$out/resources/app/extensions/kha/Kha/Kore/Tools/kraffiti/kraffiti-linux64
|
||||
patchelf \
|
||||
--set-interpreter "$(cat $NIX_BINUTILS/nix-support/dynamic-linker)" \
|
||||
--set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
|
||||
--set-rpath ".:${stdenv.cc.libc}/lib:${stdenv.cc.cc.lib}/lib" \
|
||||
$out/resources/app/extensions/kha/Kha/Tools/kravur/kravur-linux64
|
||||
patchelf \
|
||||
--set-interpreter "$(cat $NIX_BINUTILS/nix-support/dynamic-linker)" \
|
||||
--set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
|
||||
--set-rpath ".:${stdenv.cc.libc}/lib:${zlib}/lib" \
|
||||
$out/resources/app/extensions/kha/Kha/Tools/haxe/haxe-linux64
|
||||
patchelf \
|
||||
--set-interpreter "$(cat $NIX_BINUTILS/nix-support/dynamic-linker)" \
|
||||
--set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
|
||||
--set-rpath ".:${stdenv.cc.libc}/lib:${libvorbis}/lib:${libogg}/lib:${flac.out}/lib" \
|
||||
$out/resources/app/extensions/kha/Kha/Tools/oggenc/oggenc-linux64
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ stdenv.mkDerivation rec {
|
|||
mv ./${name}-linux/* $out/share/LightTable
|
||||
|
||||
patchelf \
|
||||
--interpreter "$(cat $NIX_BINUTILS/nix-support/dynamic-linker)" \
|
||||
--interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
|
||||
--set-rpath ${libPath}:${libPath}/lib64:$out/share/LightTable \
|
||||
$out/share/LightTable/LightTable
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ stdenv.mkDerivation rec {
|
|||
|
||||
echo ${libPath}
|
||||
patchelf \
|
||||
--interpreter "$(cat $NIX_BINUTILS/nix-support/dynamic-linker)" \
|
||||
--interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
|
||||
--set-rpath ${libPath}:${stdenv.cc.cc.lib}/lib${stdenv.lib.optionalString stdenv.is64bit "64"} \
|
||||
$out/sublime/sublime_text
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ in let
|
|||
buildPhase = ''
|
||||
for i in sublime_text plugin_host crash_reporter; do
|
||||
patchelf \
|
||||
--interpreter "$(cat $NIX_BINUTILS/nix-support/dynamic-linker)" \
|
||||
--interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
|
||||
--set-rpath ${libPath}:${stdenv.cc.cc.lib}/lib${stdenv.lib.optionalString stdenv.is64bit "64"} \
|
||||
$i
|
||||
done
|
||||
|
|
|
@ -66,7 +66,7 @@ stdenv.mkDerivation rec {
|
|||
|
||||
postFixup = ''
|
||||
patchelf \
|
||||
--set-interpreter "$(cat $NIX_BINUTILS/nix-support/dynamic-linker)" \
|
||||
--set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
|
||||
--set-rpath "$out/share/typora:${rpath}" "$out/share/typora/Typora"
|
||||
|
||||
ln -s "$out/share/typora/Typora" "$out/bin/typora"
|
||||
|
|
|
@ -72,7 +72,7 @@ in
|
|||
|
||||
postFixup = lib.optionalString (stdenv.system == "i686-linux" || stdenv.system == "x86_64-linux") ''
|
||||
patchelf \
|
||||
--set-interpreter "$(cat $NIX_BINUTILS/nix-support/dynamic-linker)" \
|
||||
--set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
|
||||
--set-rpath "${rpath}" \
|
||||
$out/lib/vscode/code
|
||||
'';
|
||||
|
|
|
@ -26,7 +26,7 @@ stdenv.mkDerivation {
|
|||
mkdir $out/bin
|
||||
for exe in DraftSight dsHttpApiController dsHttpApiService FxCrashRptApp HelpGuide; do
|
||||
echo "Patching $exe..."
|
||||
patchelf --interpreter "$(cat $NIX_BINUTILS/nix-support/dynamic-linker)" \
|
||||
patchelf --interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
|
||||
--set-rpath $libPath:\$ORIGIN/../Libraries \
|
||||
$out/draftsight/opt/dassault-systemes/DraftSight/Linux/$exe
|
||||
makeWrapper $out/draftsight/opt/dassault-systemes/DraftSight/Linux/$exe \
|
||||
|
|
|
@ -17,7 +17,7 @@ rm $p/Reader/intellinux/plug_ins/PPKLite.api
|
|||
# More pointless files.
|
||||
rm $p/bin/UNINSTALL
|
||||
|
||||
patchelf --interpreter "$(cat $NIX_BINUTILS/nix-support/dynamic-linker)" \
|
||||
patchelf --interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
|
||||
--set-rpath $libPath \
|
||||
$p/Reader/intellinux/bin/acroread
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@ stdenv.mkDerivation rec {
|
|||
rm $out/bin/google-earth $out/opt/google/earth/free/google-earth
|
||||
ln -s $out/opt/google/earth/free/googleearth $out/bin/google-earth
|
||||
|
||||
patchelf --interpreter "$(cat $NIX_BINUTILS/nix-support/dynamic-linker)" \
|
||||
patchelf --interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
|
||||
--set-rpath "${fullPath}:\$ORIGIN" \
|
||||
$out/opt/google/earth/free/googleearth-bin
|
||||
|
||||
|
|
|
@ -67,7 +67,7 @@ stdenv.mkDerivation rec {
|
|||
echo "export QT_XKB_CONFIG_ROOT="${xkeyboardconfig}/share/X11/xkb"" >> $out/houdini/sbin/app_init.sh
|
||||
'';
|
||||
postFixup = ''
|
||||
INTERPRETER="$(cat "$NIX_BINUTILS/nix-support/dynamic-linker")"
|
||||
INTERPRETER="$(cat "$NIX_CC"/nix-support/dynamic-linker)"
|
||||
for BIN in $(find $out/bin -type f -executable); do
|
||||
if patchelf $BIN 2>/dev/null ; then
|
||||
echo "Patching ELF $BIN"
|
||||
|
|
|
@ -28,7 +28,7 @@ stdenv.mkDerivation rec {
|
|||
mkdir -p "$out/bin"
|
||||
mv opt "$out/"
|
||||
ln -s "$out/opt/Hyper/hyper" "$out/bin/hyper"
|
||||
patchelf --set-interpreter "$(cat $NIX_BINUTILS/nix-support/dynamic-linker)" --set-rpath "${libPath}:\$ORIGIN" "$out/opt/Hyper/hyper"
|
||||
patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" --set-rpath "${libPath}:\$ORIGIN" "$out/opt/Hyper/hyper"
|
||||
mv usr/* "$out/"
|
||||
'';
|
||||
dontPatchELF = true;
|
||||
|
|
|
@ -17,8 +17,8 @@ stdenv.mkDerivation rec {
|
|||
buildPhase = with xorg; ''
|
||||
patchelf --set-rpath "${stdenv.lib.makeLibraryPath [ libX11 libXext libXrender libXtst libXi ]}" ./jre/lib/amd64/xawt/libmawt.so
|
||||
patchelf --set-rpath "${gcc.cc}/lib" ./libiKVM64.so
|
||||
patchelf --set-rpath "${stdenv.lib.makeLibraryPath [ libXcursor libX11 libXext libXrender libXtst libXi ]}" --set-interpreter "$(cat $NIX_BINUTILS/nix-support/dynamic-linker)" ./jre/bin/javaws
|
||||
patchelf --set-rpath "${gcc.cc}/lib:$out/jre/lib/amd64/jli" --set-interpreter "$(cat $NIX_BINUTILS/nix-support/dynamic-linker)" ./jre/bin/java
|
||||
patchelf --set-rpath "${stdenv.lib.makeLibraryPath [ libXcursor libX11 libXext libXrender libXtst libXi ]}" --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" ./jre/bin/javaws
|
||||
patchelf --set-rpath "${gcc.cc}/lib:$out/jre/lib/amd64/jli" --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" ./jre/bin/java
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
|
|
|
@ -30,7 +30,7 @@ stdenv.mkDerivation rec {
|
|||
mkdir -p $out/bin $out/libexec
|
||||
|
||||
patchelf \
|
||||
--interpreter "$(cat $NIX_BINUTILS/nix-support/dynamic-linker)" \
|
||||
--interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
|
||||
--set-rpath ${libPath} \
|
||||
./q/l32/q
|
||||
mv ./q/l32/q $out/libexec/q
|
||||
|
|
|
@ -88,7 +88,7 @@ stdenv.mkDerivation rec {
|
|||
postInstall = ''
|
||||
cp -r src/dependencies/xulrunner $out/lib/kiwix
|
||||
|
||||
patchelf --set-interpreter "$(cat $NIX_BINUTILS/nix-support/dynamic-linker)" $out/lib/kiwix/xulrunner/xulrunner
|
||||
patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" $out/lib/kiwix/xulrunner/xulrunner
|
||||
|
||||
rm $out/bin/kiwix
|
||||
makeWrapper $out/lib/kiwix/kiwix-launcher $out/bin/kiwix \
|
||||
|
|
|
@ -33,7 +33,7 @@ stdenv.mkDerivation {
|
|||
cp usr/bin/rescuetime $out/bin
|
||||
|
||||
${patchelf}/bin/patchelf \
|
||||
--interpreter "$(cat $NIX_BINUTILS/nix-support/dynamic-linker)" \
|
||||
--interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
|
||||
$out/bin/rescuetime
|
||||
|
||||
wrapProgram $out/bin/rescuetime \
|
||||
|
|
|
@ -47,7 +47,7 @@
|
|||
|
||||
fixupPhase
|
||||
|
||||
patchelf --set-interpreter "$(cat $NIX_BINUTILS/nix-support/dynamic-linker)" \
|
||||
patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
|
||||
--set-rpath "${libPath}:$out/share/simplenote" \
|
||||
$out/share/simplenote/simplenote
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ stdenv.mkDerivation rec {
|
|||
|
||||
installPhase = ''
|
||||
install -D btsync "$out/bin/btsync"
|
||||
patchelf --interpreter "$(< $NIX_BINUTILS/nix-support/dynamic-linker)" --set-rpath ${libPath} "$out/bin/btsync"
|
||||
patchelf --interpreter "$(< $NIX_CC/nix-support/dynamic-linker)" --set-rpath ${libPath} "$out/bin/btsync"
|
||||
'';
|
||||
|
||||
meta = {
|
||||
|
|
|
@ -152,7 +152,7 @@ stdenv.mkDerivation {
|
|||
updater crashreporter webapprt-stub
|
||||
do
|
||||
if [ -e "$out/usr/lib/firefox-bin-${version}/$executable" ]; then
|
||||
patchelf --interpreter "$(cat $NIX_BINUTILS/nix-support/dynamic-linker)" \
|
||||
patchelf --interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
|
||||
"$out/usr/lib/firefox-bin-${version}/$executable"
|
||||
fi
|
||||
done
|
||||
|
|
|
@ -130,7 +130,7 @@ in stdenv.mkDerivation rec {
|
|||
|
||||
for elf in $out/share/google/$appname/{chrome,chrome-sandbox,nacl_helper}; do
|
||||
patchelf --set-rpath $rpath $elf
|
||||
patchelf --set-interpreter "$(cat $NIX_BINUTILS/nix-support/dynamic-linker)" $elf
|
||||
patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" $elf
|
||||
done
|
||||
'';
|
||||
|
||||
|
|
|
@ -118,7 +118,7 @@ stdenv.mkDerivation rec {
|
|||
$out/lib${lib_suffix}/kde4/kcm_adobe_flash_player.so
|
||||
|
||||
patchelf \
|
||||
--set-interpreter $(cat $NIX_BINUTILS/nix-support/dynamic-linker) \
|
||||
--set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) \
|
||||
--set-rpath "$rpath" \
|
||||
$out/bin/flash-player-properties
|
||||
'';
|
||||
|
|
|
@ -84,7 +84,7 @@ stdenv.mkDerivation rec {
|
|||
cp -pv flashplayer${lib.optionalString debug "debugger"} $out/bin
|
||||
|
||||
patchelf \
|
||||
--set-interpreter $(cat $NIX_BINUTILS/nix-support/dynamic-linker) \
|
||||
--set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) \
|
||||
--set-rpath "$rpath" \
|
||||
$out/bin/flashplayer${lib.optionalString debug "debugger"}
|
||||
'';
|
||||
|
|
|
@ -88,7 +88,7 @@ stdenv.mkDerivation rec {
|
|||
cp -prd opt/google/talkplugin/{data,GoogleTalkPlugin,locale,remoting24x24.png,windowpicker.glade} $out/libexec/google/talkplugin/
|
||||
|
||||
patchelf \
|
||||
--set-interpreter "$(cat $NIX_BINUTILS/nix-support/dynamic-linker)" \
|
||||
--set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
|
||||
--set-rpath "${rpathProgram}:${stdenv.cc.cc.lib}/lib64" \
|
||||
$out/libexec/google/talkplugin/GoogleTalkPlugin
|
||||
|
||||
|
|
|
@ -114,7 +114,7 @@ in stdenv.mkDerivation {
|
|||
| while read f
|
||||
do
|
||||
patchelf \
|
||||
--set-interpreter "$(cat $NIX_BINUTILS/nix-support/dynamic-linker)" \
|
||||
--set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
|
||||
--set-rpath "$out/lib:${rpath}" \
|
||||
"$f"
|
||||
done
|
||||
|
|
|
@ -129,7 +129,7 @@ stdenv.mkDerivation rec {
|
|||
buildCommand = ''
|
||||
# For convenience ...
|
||||
TBB_IN_STORE=$out/share/tor-browser
|
||||
interp=$(< $NIX_BINUTILS/nix-support/dynamic-linker)
|
||||
interp=$(< $NIX_CC/nix-support/dynamic-linker)
|
||||
|
||||
# Unpack & enter
|
||||
mkdir -p "$TBB_IN_STORE"
|
||||
|
|
|
@ -43,7 +43,7 @@ stdenv.mkDerivation rec {
|
|||
buildPhase = ''
|
||||
echo "Patching Vivaldi binaries"
|
||||
patchelf \
|
||||
--set-interpreter "$(cat $NIX_BINUTILS/nix-support/dynamic-linker)" \
|
||||
--set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
|
||||
--set-rpath "${libPath}" \
|
||||
opt/vivaldi/vivaldi-bin
|
||||
'' + stdenv.lib.optionalString proprietaryCodecs ''
|
||||
|
|
|
@ -16,7 +16,7 @@ stdenv.mkDerivation rec {
|
|||
sed -i $n -e "s|#!/usr/bin/env bash|#! ${bash}/bin/bash|"
|
||||
done
|
||||
'' + stdenv.lib.optionalString (!stdenv.isDarwin) ''
|
||||
patchelf --set-interpreter "$(cat $NIX_BINUTILS/nix-support/dynamic-linker)" bin/container-executor;
|
||||
patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" bin/container-executor;
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
|
|
|
@ -108,7 +108,7 @@ in mkDerivation {
|
|||
'';
|
||||
|
||||
preFixup = ''
|
||||
INTERP=$(cat $NIX_BINUTILS/nix-support/dynamic-linker)
|
||||
INTERP=$(cat $NIX_CC/nix-support/dynamic-linker)
|
||||
RPATH="${ldpath}:$out/${appdir}"
|
||||
getType='s/ *Type: *\([A-Z]*\) (.*/\1/'
|
||||
find "$out/${appdir}" -type f -print | while read obj; do
|
||||
|
|
|
@ -30,7 +30,7 @@ stdenv.mkDerivation rec {
|
|||
|
||||
# Copying how adobe-reader does it,
|
||||
# see pkgs/applications/misc/adobe-reader/builder.sh
|
||||
patchelf --set-interpreter "$(cat $NIX_BINUTILS/nix-support/dynamic-linker)" \
|
||||
patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
|
||||
--set-rpath "$out/opt/discord:$libPath" \
|
||||
$out/opt/discord/Discord
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ in stdenv.mkDerivation rec {
|
|||
'';
|
||||
|
||||
installPhase = ''
|
||||
patchelf --set-interpreter "$(cat $NIX_BINUTILS/nix-support/dynamic-linker)" Franz
|
||||
patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" Franz
|
||||
patchelf --set-rpath "$out/opt/franz:${stdenv.lib.makeLibraryPath deps}" Franz
|
||||
|
||||
mkdir -p $out/bin $out/opt/franz
|
||||
|
|
|
@ -68,7 +68,7 @@ stdenv.mkDerivation {
|
|||
mv usr/share $out
|
||||
|
||||
for file in $(find $d -type f); do
|
||||
patchelf --set-interpreter "$(cat $NIX_BINUTILS/nix-support/dynamic-linker)" $file || true
|
||||
patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" $file || true
|
||||
patchelf --set-rpath ${rpath}:$out/libexec/hipchat/lib:\$ORIGIN $file || true
|
||||
done
|
||||
|
||||
|
|
|
@ -72,7 +72,7 @@ in stdenv.mkDerivation {
|
|||
|
||||
# patch the binaries
|
||||
for file in $(find $out -type f \( -perm /0111 -o -name \*.so\* \) ); do
|
||||
patchelf --set-interpreter "$(cat $NIX_BINUTILS/nix-support/dynamic-linker)" "$file" || true
|
||||
patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" "$file" || true
|
||||
patchelf --set-rpath ${rpath}:$out/libexec $file || true
|
||||
done
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ in stdenv.mkDerivation rec {
|
|||
dontPatchELF = true;
|
||||
|
||||
installPhase = ''
|
||||
patchelf --set-interpreter "$(cat $NIX_BINUTILS/nix-support/dynamic-linker)" rambox
|
||||
patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" rambox
|
||||
patchelf --set-rpath "$out/opt/rambox:${stdenv.lib.makeLibraryPath deps}" rambox
|
||||
|
||||
mkdir -p $out/bin $out/opt/rambox
|
||||
|
|
|
@ -78,7 +78,7 @@ in stdenv.mkDerivation {
|
|||
|
||||
postFixup = ''
|
||||
patchelf \
|
||||
--set-interpreter "$(cat $NIX_BINUTILS/nix-support/dynamic-linker)" \
|
||||
--set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
|
||||
--set-rpath "$out/share/skypeforlinux:${rpath}" "$out/share/skypeforlinux/skypeforlinux"
|
||||
|
||||
ln -s "$out/share/skypeforlinux/skypeforlinux" "$out/bin/skypeforlinux"
|
||||
|
|
|
@ -68,7 +68,7 @@ in stdenv.mkDerivation {
|
|||
chmod -R g-w $out
|
||||
|
||||
for file in $(find $out -type f \( -perm /0111 -o -name \*.so\* \) ); do
|
||||
patchelf --set-interpreter "$(cat $NIX_BINUTILS/nix-support/dynamic-linker)" "$file" || true
|
||||
patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" "$file" || true
|
||||
patchelf --set-rpath ${rpath}:$out/lib/slack $file || true
|
||||
done
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@ stdenv.mkDerivation rec {
|
|||
mv ts3client_linux_${arch} ts3client
|
||||
echo "patching ts3client..."
|
||||
patchelf \
|
||||
--interpreter "$(cat $NIX_BINUTILS/nix-support/dynamic-linker)" \
|
||||
--interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
|
||||
--set-rpath ${stdenv.lib.makeLibraryPath deps}:$(cat $NIX_CC/nix-support/orig-cc)/${libDir} \
|
||||
--force-rpath \
|
||||
ts3client
|
||||
|
|
|
@ -25,13 +25,13 @@ stdenv.mkDerivation {
|
|||
''
|
||||
echo "patching ts3server"
|
||||
patchelf \
|
||||
--interpreter "$(cat $NIX_BINUTILS/nix-support/dynamic-linker)" \
|
||||
--interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
|
||||
--set-rpath $(cat $NIX_CC/nix-support/orig-cc)/${libDir} \
|
||||
--force-rpath \
|
||||
ts3server
|
||||
cp tsdns/tsdnsserver tsdnsserver
|
||||
patchelf \
|
||||
--interpreter "$(cat $NIX_BINUTILS/nix-support/dynamic-linker)" \
|
||||
--interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
|
||||
--set-rpath $(cat $NIX_CC/nix-support/orig-cc)/${libDir} \
|
||||
--force-rpath \
|
||||
tsdnsserver
|
||||
|
|
|
@ -72,7 +72,7 @@ stdenv.mkDerivation rec {
|
|||
chmod -R g-w $out
|
||||
|
||||
for file in $(find $out -type f \( -perm /0111 -o -name \*.so\* \) ); do
|
||||
patchelf --set-interpreter "$(cat $NIX_BINUTILS/nix-support/dynamic-linker)" "$file" || true
|
||||
patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" "$file" || true
|
||||
patchelf --set-rpath $libPath:$out/opt/viber/lib $file || true
|
||||
done
|
||||
|
||||
|
|
|
@ -65,10 +65,10 @@ in stdenv.mkDerivation {
|
|||
mkdir -p $out/bin
|
||||
cp -ar * $packagePath
|
||||
|
||||
patchelf --set-interpreter "$(cat $NIX_BINUTILS/nix-support/dynamic-linker)" $packagePath/zoom
|
||||
patchelf --set-interpreter "$(cat $NIX_BINUTILS/nix-support/dynamic-linker)" $packagePath/QtWebEngineProcess
|
||||
patchelf --set-interpreter "$(cat $NIX_BINUTILS/nix-support/dynamic-linker)" $packagePath/qtdiag
|
||||
patchelf --set-interpreter "$(cat $NIX_BINUTILS/nix-support/dynamic-linker)" $packagePath/zopen
|
||||
patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" $packagePath/zoom
|
||||
patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" $packagePath/QtWebEngineProcess
|
||||
patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" $packagePath/qtdiag
|
||||
patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" $packagePath/zopen
|
||||
# included from https://github.com/NixOS/nixpkgs/commit/fc218766333a05c9352b386e0cbb16e1ae84bf53
|
||||
# it works for me without it, but, well...
|
||||
paxmark m $packagePath/zoom
|
||||
|
|
|
@ -15,7 +15,7 @@ stdenv.mkDerivation rec {
|
|||
buildInputs = [ makeWrapper ];
|
||||
|
||||
postPatch = ''
|
||||
patchelf --interpreter "$(cat $NIX_BINUTILS/nix-support/dynamic-linker)" client/insync-portable
|
||||
patchelf --interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" client/insync-portable
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
|
|
|
@ -107,7 +107,7 @@ stdenv.mkDerivation rec {
|
|||
|
||||
# Patch binaries
|
||||
binrp=$(patchelf --print-rpath $out/share/nylas-mail/nylas)
|
||||
patchelf --interpreter $(cat "$NIX_BINUTILS/nix-support/dynamic-linker") \
|
||||
patchelf --interpreter $(cat "$NIX_CC"/nix-support/dynamic-linker) \
|
||||
--set-rpath $binrp:$out/lib:${stdenv.cc.cc.lib}/lib:${lib.makeLibraryPath propagatedBuildInputs } \
|
||||
$out/share/nylas-mail/nylas
|
||||
|
||||
|
@ -119,7 +119,7 @@ stdenv.mkDerivation rec {
|
|||
|
||||
wrapProgram $out/share/nylas-mail/resources/apm/bin/apm \
|
||||
--set PATH "${coreutils}/bin"
|
||||
patchelf --interpreter $(cat "$NIX_BINUTILS/nix-support/dynamic-linker") \
|
||||
patchelf --interpreter $(cat "$NIX_CC"/nix-support/dynamic-linker) \
|
||||
--set-rpath ${gcc-unwrapped.lib}/lib $out/share/nylas-mail/resources/apm/bin/node
|
||||
'';
|
||||
|
||||
|
|
|
@ -134,7 +134,7 @@ stdenv.mkDerivation {
|
|||
for executable in \
|
||||
thunderbird crashreporter thunderbird-bin plugin-container updater
|
||||
do
|
||||
patchelf --interpreter "$(cat $NIX_BINUTILS/nix-support/dynamic-linker)" \
|
||||
patchelf --interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
|
||||
"$out/usr/lib/thunderbird-bin-${version}/$executable"
|
||||
done
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ in stdenv.mkDerivation rec {
|
|||
|
||||
postFixup = ''
|
||||
patchelf \
|
||||
--set-interpreter $(cat $NIX_BINUTILS/nix-support/dynamic-linker) \
|
||||
--set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) \
|
||||
--set-rpath "${libPath}" \
|
||||
$out/bin/anydesk
|
||||
|
||||
|
|
|
@ -131,7 +131,7 @@ in stdenv.mkDerivation rec {
|
|||
echo "Patching ELF intrepreter and rpath for $f"
|
||||
chmod u+w "$f"
|
||||
patchelf \
|
||||
--set-interpreter $(cat $NIX_BINUTILS/nix-support/dynamic-linker) \
|
||||
--set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) \
|
||||
--set-rpath "$ICAInstDir:$libPath" "$f"
|
||||
done
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ in stdenv.mkDerivation rec {
|
|||
installPhase = ''
|
||||
install -D rslsync "$out/bin/rslsync"
|
||||
patchelf \
|
||||
--interpreter "$(< $NIX_BINUTILS/nix-support/dynamic-linker)" \
|
||||
--interpreter "$(< $NIX_CC/nix-support/dynamic-linker)" \
|
||||
--set-rpath ${libPath} "$out/bin/rslsync"
|
||||
'';
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ stdenv.mkDerivation rec {
|
|||
'';
|
||||
|
||||
postFixup = ''
|
||||
patchelf --set-interpreter "$(cat $NIX_BINUTILS/nix-support/dynamic-linker)" \
|
||||
patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
|
||||
--set-rpath "${atomEnv.libPath}:${stdenv.lib.makeLibraryPath [ libXScrnSaver ]}:$out/lib/marp" \
|
||||
$out/bin/Marp
|
||||
'';
|
||||
|
|
|
@ -78,9 +78,9 @@ stdenv.mkDerivation rec {
|
|||
${coreutils}/bin/cp "\$MDIR/moneyplex" "\$MDIR/moneyplex.patched"
|
||||
${coreutils}/bin/chmod 0755 "\$MDIR/moneyplex.patched"
|
||||
fi
|
||||
if [ ! \`${patchelf}/bin/patchelf --print-interpreter \$MDIR/moneyplex.patched\` = $(cat $NIX_BINUTILS/nix-support/dynamic-linker) ] ||
|
||||
if [ ! \`${patchelf}/bin/patchelf --print-interpreter \$MDIR/moneyplex.patched\` = $(cat $NIX_CC/nix-support/dynamic-linker) ] ||
|
||||
[ ! \`${patchelf}/bin/patchelf --print-rpath \$MDIR/moneyplex.patched\` = "${libPath}" ]; then
|
||||
${patchelf}/bin/patchelf --set-interpreter $(cat $NIX_BINUTILS/nix-support/dynamic-linker) --set-rpath "${libPath}" "\$MDIR/moneyplex.patched"
|
||||
${patchelf}/bin/patchelf --set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) --set-rpath "${libPath}" "\$MDIR/moneyplex.patched"
|
||||
fi
|
||||
|
||||
exec \$MDIR/moneyplex.patched
|
||||
|
|
|
@ -53,7 +53,7 @@ in stdenv.mkDerivation rec{
|
|||
mkdir $out/bin
|
||||
for i in wps wpp et; do
|
||||
patchelf \
|
||||
--set-interpreter "$(cat $NIX_BINUTILS/nix-support/dynamic-linker)" \
|
||||
--set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
|
||||
--force-rpath --set-rpath "$prefix/office6:$libPath" \
|
||||
$prefix/office6/$i
|
||||
|
||||
|
|
|
@ -69,7 +69,7 @@ stdenv.mkDerivation rec {
|
|||
gcc -shared -fPIC -DEAGLE_PATH=\"$out/eagle-${version}\" ${./eagle_fixer.c} -o "$out"/lib/eagle_fixer.so -ldl
|
||||
|
||||
# Make wrapper script
|
||||
dynlinker="$(cat $NIX_BINUTILS/nix-support/dynamic-linker)"
|
||||
dynlinker="$(cat $NIX_CC/nix-support/dynamic-linker)"
|
||||
mkdir -p "$out"/bin
|
||||
cat > "$out"/bin/eagle << EOF
|
||||
#!${stdenv.shell}
|
||||
|
|
|
@ -44,7 +44,7 @@ stdenv.mkDerivation rec {
|
|||
|
||||
fixupPhase = ''
|
||||
for x in bin/bcdump bin/extcore-info bin/jss bin/llvm-disasm bin/lss bin/saw; do
|
||||
patchelf --interpreter "$(cat $NIX_BINUTILS/nix-support/dynamic-linker)" \
|
||||
patchelf --interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
|
||||
--set-rpath "$out/lib:${libPath}" $out/$x;
|
||||
done
|
||||
'';
|
||||
|
|
|
@ -27,7 +27,7 @@ stdenv.mkDerivation rec {
|
|||
substituteInPlace $sharedir/TPTP2X/tptp2X_install --replace /bin/mv mv
|
||||
tcsh $sharedir/TPTP2X/tptp2X_install -default
|
||||
|
||||
patchelf --interpreter $(cat $NIX_BINUTILS/nix-support/dynamic-linker) $sharedir/Scripts/tptp4X
|
||||
patchelf --interpreter $(cat $NIX_CC/nix-support/dynamic-linker) $sharedir/Scripts/tptp4X
|
||||
|
||||
mkdir -p $out/bin
|
||||
ln -s $sharedir/TPTP2X/tptp2X $out/bin
|
||||
|
|
|
@ -10,7 +10,7 @@ let
|
|||
] + ":${stdenv.cc.cc.lib}/lib64";
|
||||
|
||||
patchExe = x: ''
|
||||
patchelf --interpreter "$(cat $NIX_BINUTILS/nix-support/dynamic-linker)" \
|
||||
patchelf --interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
|
||||
--set-rpath ${libPath} ${x}
|
||||
'';
|
||||
in
|
||||
|
|
|
@ -106,7 +106,7 @@ stdenv.mkDerivation rec {
|
|||
echo "patching $f executable <<"
|
||||
patchelf --shrink-rpath "$f"
|
||||
patchelf \
|
||||
--set-interpreter "$(cat $NIX_BINUTILS/nix-support/dynamic-linker)" \
|
||||
--set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
|
||||
--set-rpath "$(patchelf --print-rpath "$f"):${ldpath}" \
|
||||
"$f" \
|
||||
&& patchelf --shrink-rpath "$f" \
|
||||
|
|
|
@ -93,7 +93,7 @@ stdenv.mkDerivation rec {
|
|||
elif [ "$type" == "EXEC" ]; then
|
||||
echo "patching $f executable <<"
|
||||
patchelf \
|
||||
--set-interpreter "$(cat $NIX_BINUTILS/nix-support/dynamic-linker)" \
|
||||
--set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
|
||||
--set-rpath "${ldpath}" \
|
||||
"$f"
|
||||
patchelf --shrink-rpath "$f"
|
||||
|
|
|
@ -114,7 +114,7 @@ stdenv.mkDerivation rec {
|
|||
echo "patching $f executable <<"
|
||||
patchelf --shrink-rpath "$f"
|
||||
patchelf \
|
||||
--set-interpreter "$(cat $NIX_BINUTILS/nix-support/dynamic-linker)" \
|
||||
--set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
|
||||
--set-rpath "$(patchelf --print-rpath "$f"):${ldpath}" \
|
||||
"$f" \
|
||||
&& patchelf --shrink-rpath "$f" \
|
||||
|
|
|
@ -51,7 +51,7 @@ stdenv.mkDerivation rec {
|
|||
fullLibPath="$sci/lib/scilab:$sci/lib/thirdparty:$libPath"
|
||||
fullLibPath="$fullLibPath:$sci/lib/thirdparty/redist"
|
||||
|
||||
patchelf --set-interpreter $(cat $NIX_BINUTILS/nix-support/dynamic-linker) \
|
||||
patchelf --set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) \
|
||||
--set-rpath "$fullLibPath" bin/scilab-bin
|
||||
find . -name '*.so' -type f | while read file; do
|
||||
patchelf --set-rpath "$fullLibPath" "$file" 2>/dev/null
|
||||
|
|
|
@ -29,11 +29,11 @@ stdenv.mkDerivation {
|
|||
libs = stdenv.lib.makeLibraryPath [ qt4 zlib stdenv.cc.cc libSM libICE libX11 libXext libXt mesa ];
|
||||
in ''
|
||||
${patchelf}/bin/patchelf \
|
||||
--interpreter "$(cat $NIX_BINUTILS/nix-support/dynamic-linker)" \
|
||||
--interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
|
||||
$out/bin/aliza
|
||||
|
||||
${patchelf}/bin/patchelf \
|
||||
--interpreter "$(cat $NIX_BINUTILS/nix-support/dynamic-linker)" \
|
||||
--interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
|
||||
$out/bin/aliza-vtkvol
|
||||
|
||||
wrapProgram $out/bin/aliza \
|
||||
|
|
|
@ -33,7 +33,7 @@ stdenv.mkDerivation {
|
|||
|
||||
for b in fdr4 _fdr4 refines _refines cspmprofiler cspmexplorerprof
|
||||
do
|
||||
patchelf --set-interpreter $(cat $NIX_BINUTILS/nix-support/dynamic-linker) \
|
||||
patchelf --set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) \
|
||||
--set-rpath "$libPath:$out/lib" \
|
||||
"$out/bin/$b"
|
||||
done
|
||||
|
|
|
@ -3,7 +3,7 @@ source $stdenv/setup
|
|||
buildPhase() {
|
||||
for i in bin/*; do
|
||||
patchelf \
|
||||
--set-interpreter "$(cat $NIX_BINUTILS/nix-support/dynamic-linker)" \
|
||||
--set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
|
||||
--set-rpath $libX11/lib:$libXext/lib \
|
||||
$i
|
||||
done
|
||||
|
|
|
@ -5,7 +5,7 @@ echo $NIX_CC
|
|||
buildPhase() {
|
||||
for i in bin/*; do
|
||||
patchelf \
|
||||
--set-interpreter "$(cat $NIX_BINUTILS/nix-support/dynamic-linker)" \
|
||||
--set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
|
||||
--set-rpath $libX11/lib:$libXext/lib:$libSM/lib:$(cat $NIX_CC/nix-support/orig-cc)/lib \
|
||||
$i
|
||||
done
|
||||
|
|
|
@ -5,7 +5,7 @@ echo $NIX_CC
|
|||
buildPhase() {
|
||||
for i in bin/*; do
|
||||
patchelf \
|
||||
--set-interpreter "$(cat $NIX_BINUTILS/nix-support/dynamic-linker)" \
|
||||
--set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
|
||||
--set-rpath $libX11/lib:$libXext/lib:$libSM/lib:$(cat $NIX_CC/nix-support/orig-cc)/lib \
|
||||
$i
|
||||
done
|
||||
|
|
|
@ -17,7 +17,7 @@ stdenv.mkDerivation {
|
|||
''
|
||||
for i in bin/*; do
|
||||
patchelf \
|
||||
--set-interpreter "$(cat $NIX_BINUTILS/nix-support/dynamic-linker)" \
|
||||
--set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
|
||||
--set-rpath ${stdenv.lib.makeLibraryPath [ libX11 libXext libSM ]}:$(cat $NIX_CC/nix-support/orig-cc)/lib \
|
||||
$i
|
||||
done
|
||||
|
|
|
@ -17,7 +17,7 @@ stdenv.mkDerivation {
|
|||
''
|
||||
for i in bin/*; do
|
||||
patchelf \
|
||||
--set-interpreter "$(cat $NIX_BINUTILS/nix-support/dynamic-linker)" \
|
||||
--set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
|
||||
--set-rpath ${stdenv.lib.makeLibraryPath [ libX11 libXext libSM ]}:$(cat $NIX_CC/nix-support/orig-cc)/lib \
|
||||
$i
|
||||
done
|
||||
|
|
|
@ -17,7 +17,7 @@ stdenv.mkDerivation {
|
|||
''
|
||||
for i in bin/*; do
|
||||
patchelf \
|
||||
--set-interpreter "$(cat $NIX_BINUTILS/nix-support/dynamic-linker)" \
|
||||
--set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
|
||||
--set-rpath ${stdenv.lib.makeLibraryPath [ libX11 libXext libSM ]}:$(cat $NIX_CC/nix-support/orig-cc)/lib \
|
||||
$i
|
||||
done
|
||||
|
|
|
@ -17,7 +17,7 @@ stdenv.mkDerivation {
|
|||
''
|
||||
for i in bin/*; do
|
||||
patchelf \
|
||||
--set-interpreter "$(cat $NIX_BINUTILS/nix-support/dynamic-linker)" \
|
||||
--set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
|
||||
--set-rpath ${stdenv.lib.makeLibraryPath [ libX11 libXext libSM ]}:$(cat $NIX_CC/nix-support/orig-cc)/lib \
|
||||
$i
|
||||
done
|
||||
|
|
|
@ -17,7 +17,7 @@ stdenv.mkDerivation {
|
|||
''
|
||||
for i in bin/*; do
|
||||
patchelf \
|
||||
--set-interpreter "$(cat $NIX_BINUTILS/nix-support/dynamic-linker)" \
|
||||
--set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
|
||||
--set-rpath ${stdenv.lib.makeLibraryPath [ libX11 libXext libSM ]}:$(cat $NIX_CC/nix-support/orig-cc)/lib \
|
||||
$i
|
||||
done
|
||||
|
|
|
@ -17,7 +17,7 @@ stdenv.mkDerivation {
|
|||
''
|
||||
for i in bin/*; do
|
||||
patchelf \
|
||||
--set-interpreter "$(cat $NIX_BINUTILS/nix-support/dynamic-linker)" \
|
||||
--set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
|
||||
--set-rpath ${stdenv.lib.makeLibraryPath [ libX11 libXext libSM ]}:$(cat $NIX_CC/nix-support/orig-cc)/lib \
|
||||
$i
|
||||
done
|
||||
|
|
|
@ -17,7 +17,7 @@ stdenv.mkDerivation {
|
|||
''
|
||||
for i in bin/*; do
|
||||
patchelf \
|
||||
--set-interpreter "$(cat $NIX_BINUTILS/nix-support/dynamic-linker)" \
|
||||
--set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
|
||||
--set-rpath ${stdenv.lib.makeLibraryPath [ libX11 libXext libSM ]}:$(cat $NIX_CC/nix-support/orig-cc)/lib \
|
||||
$i
|
||||
done
|
||||
|
|
|
@ -17,7 +17,7 @@ stdenv.mkDerivation {
|
|||
''
|
||||
for i in bin/*; do
|
||||
patchelf \
|
||||
--set-interpreter "$(cat $NIX_BINUTILS/nix-support/dynamic-linker)" \
|
||||
--set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
|
||||
--set-rpath ${stdenv.lib.makeLibraryPath [ libX11 libXext libSM ]}:$(cat $NIX_CC/nix-support/orig-cc)/lib \
|
||||
$i
|
||||
done
|
||||
|
|
|
@ -80,7 +80,7 @@ stdenv.mkDerivation rec {
|
|||
'';
|
||||
|
||||
postFixup = ''
|
||||
patchelf --set-interpreter $(cat $NIX_BINUTILS/nix-support/dynamic-linker) \
|
||||
patchelf --set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) \
|
||||
--set-rpath "$libPath:$out/opt/gitkraken" "$out/opt/gitkraken/gitkraken"
|
||||
wrapProgram $out/opt/gitkraken/gitkraken \
|
||||
--prefix LD_PRELOAD : "${makeLibraryPath [ curl ]}/libcurl.so.4" \
|
||||
|
|
|
@ -27,7 +27,7 @@ libPath="${libPath}:${out}/lib" # XXX: der. This should be in the nix file?
|
|||
|
||||
for i in ${bin} ; do
|
||||
patchelf \
|
||||
--interpreter "$(cat $NIX_BINUTILS/nix-support/dynamic-linker)" \
|
||||
--interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
|
||||
--set-rpath $libPath \
|
||||
${i}
|
||||
done
|
||||
|
|
|
@ -1,40 +0,0 @@
|
|||
# See cc-wrapper for comments.
|
||||
var_templates_list=(
|
||||
NIX+IGNORE_LD_THROUGH_GCC
|
||||
NIX+LDFLAGS
|
||||
NIX+LDFLAGS_BEFORE
|
||||
NIX+LDFLAGS_AFTER
|
||||
NIX+LDFLAGS_HARDEN
|
||||
)
|
||||
var_templates_bool=(
|
||||
NIX+SET_BUILD_ID
|
||||
NIX+DONT_SET_RPATH
|
||||
)
|
||||
|
||||
declare -a role_infixes=()
|
||||
if [ "${NIX_BINUTILS_WRAPPER_@infixSalt@_TARGET_BUILD:-}" ]; then
|
||||
role_infixes+=(_BUILD_)
|
||||
fi
|
||||
if [ "${NIX_BINUTILS_WRAPPER_@infixSalt@_TARGET_HOST:-}" ]; then
|
||||
role_infixes+=(_)
|
||||
fi
|
||||
if [ "${NIX_BINUTILS_WRAPPER_@infixSalt@_TARGET_TARGET:-}" ]; then
|
||||
role_infixes+=(_TARGET_)
|
||||
fi
|
||||
|
||||
for var in "${var_templates_list[@]}"; do
|
||||
mangleVarList "$var" "${role_infixes[@]}"
|
||||
done
|
||||
for var in "${var_templates_bool[@]}"; do
|
||||
mangleVarBool "$var" "${role_infixes[@]}"
|
||||
done
|
||||
|
||||
if [ -e @out@/nix-support/libc-ldflags ]; then
|
||||
NIX_@infixSalt@_LDFLAGS+=" $(< @out@/nix-support/libc-ldflags)"
|
||||
fi
|
||||
|
||||
if [ -e @out@/nix-support/libc-ldflags-before ]; then
|
||||
NIX_@infixSalt@_LDFLAGS_BEFORE="$(< @out@/nix-support/libc-ldflags-before) $NIX_@infixSalt@_LDFLAGS_BEFORE"
|
||||
fi
|
||||
|
||||
export NIX_BINUTILS_WRAPPER_@infixSalt@_FLAGS_SET=1
|
|
@ -1,53 +0,0 @@
|
|||
hardeningFlags=(relro bindnow)
|
||||
# Intentionally word-split in case 'hardeningEnable' is defined in
|
||||
# Nix. Also, our bootstrap tools version of bash is old enough that
|
||||
# undefined arrays trip `set -u`.
|
||||
if [[ -v hardeningEnable[@] ]]; then
|
||||
hardeningFlags+=(${hardeningEnable[@]})
|
||||
fi
|
||||
hardeningLDFlags=()
|
||||
|
||||
declare -A hardeningDisableMap
|
||||
|
||||
# Intentionally word-split in case 'hardeningDisable' is defined in Nix.
|
||||
for flag in ${hardeningDisable[@]:-IGNORED_KEY} @hardening_unsupported_flags@
|
||||
do
|
||||
hardeningDisableMap[$flag]=1
|
||||
done
|
||||
|
||||
if [[ -n "${NIX_DEBUG:-}" ]]; then
|
||||
printf 'HARDENING: disabled flags:' >&2
|
||||
(( "${#hardeningDisableMap[@]}" )) && printf ' %q' "${!hardeningDisableMap[@]}" >&2
|
||||
echo >&2
|
||||
fi
|
||||
|
||||
if [[ -z "${hardeningDisableMap[all]:-}" ]]; then
|
||||
if [[ -n "${NIX_DEBUG:-}" ]]; then
|
||||
echo 'HARDENING: Is active (not completely disabled with "all" flag)' >&2;
|
||||
fi
|
||||
for flag in "${hardeningFlags[@]}"
|
||||
do
|
||||
if [[ -z "${hardeningDisableMap[$flag]:-}" ]]; then
|
||||
case $flag in
|
||||
pie)
|
||||
if [[ ! ("$*" =~ " -shared " || "$*" =~ " -static ") ]]; then
|
||||
if [[ -n "${NIX_DEBUG:-}" ]]; then echo HARDENING: enabling LDFlags -pie >&2; fi
|
||||
hardeningLDFlags+=('-pie')
|
||||
fi
|
||||
;;
|
||||
relro)
|
||||
if [[ -n "${NIX_DEBUG:-}" ]]; then echo HARDENING: enabling relro >&2; fi
|
||||
hardeningLDFlags+=('-z' 'relro')
|
||||
;;
|
||||
bindnow)
|
||||
if [[ -n "${NIX_DEBUG:-}" ]]; then echo HARDENING: enabling bindnow >&2; fi
|
||||
hardeningLDFlags+=('-z' 'now')
|
||||
;;
|
||||
*)
|
||||
# Ignore unsupported. Checked in Nix that at least *some*
|
||||
# tool supports each flag.
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
done
|
||||
fi
|
|
@ -1,288 +0,0 @@
|
|||
# The Nixpkgs CC 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. So we use a wrapper
|
||||
# script that sets up the right environment variables so that the
|
||||
# compiler and the linker just "work".
|
||||
|
||||
{ name ? "", stdenv, nativeTools, noLibc ? false, nativeLibc, nativePrefix ? ""
|
||||
, binutils ? null, libc ? null
|
||||
, coreutils ? null, shell ? stdenv.shell, gnugrep ? null
|
||||
, extraPackages ? [], extraBuildCommands ? ""
|
||||
, buildPackages ? {}
|
||||
, useMacosReexportHack ? false
|
||||
}:
|
||||
|
||||
with stdenv.lib;
|
||||
|
||||
assert nativeTools -> nativePrefix != "";
|
||||
assert !nativeTools ->
|
||||
binutils != null && coreutils != null && gnugrep != null;
|
||||
assert !(nativeLibc && noLibc);
|
||||
assert (noLibc || nativeLibc) == (libc == null);
|
||||
|
||||
let
|
||||
inherit (stdenv) hostPlatform targetPlatform;
|
||||
|
||||
# Prefix for binaries. Customarily ends with a dash separator.
|
||||
#
|
||||
# TODO(@Ericson2314) Make unconditional, or optional but always true by
|
||||
# default.
|
||||
prefix = stdenv.lib.optionalString (targetPlatform != hostPlatform)
|
||||
(targetPlatform.config + "-");
|
||||
|
||||
binutilsVersion = (builtins.parseDrvName binutils.name).version;
|
||||
binutilsName = (builtins.parseDrvName binutils.name).name;
|
||||
|
||||
libc_bin = if libc == null then null else getBin libc;
|
||||
libc_dev = if libc == null then null else getDev libc;
|
||||
libc_lib = if libc == null then null else getLib libc;
|
||||
binutils_bin = if nativeTools then "" else getBin binutils;
|
||||
# The wrapper scripts use 'cat' and 'grep', so we may need coreutils.
|
||||
coreutils_bin = if nativeTools then "" else getBin coreutils;
|
||||
|
||||
dashlessTarget = stdenv.lib.replaceStrings ["-"] ["_"] targetPlatform.config;
|
||||
|
||||
# See description in cc-wrapper.
|
||||
infixSalt = dashlessTarget;
|
||||
|
||||
# The dynamic linker has different names on different platforms. This is a
|
||||
# shell glob that ought to match it.
|
||||
dynamicLinker =
|
||||
/**/ if libc == null then null
|
||||
else if targetPlatform.system == "i686-linux" then "${libc_lib}/lib/ld-linux.so.2"
|
||||
else if targetPlatform.system == "x86_64-linux" then "${libc_lib}/lib/ld-linux-x86-64.so.2"
|
||||
# ARM with a wildcard, which can be "" or "-armhf".
|
||||
else if targetPlatform.isArm then "${libc_lib}/lib/ld-linux*.so.3"
|
||||
else if targetPlatform.system == "aarch64-linux" then "${libc_lib}/lib/ld-linux-aarch64.so.1"
|
||||
else if targetPlatform.system == "powerpc-linux" then "${libc_lib}/lib/ld.so.1"
|
||||
else if targetPlatform.system == "mips64el-linux" then "${libc_lib}/lib/ld.so.1"
|
||||
else if targetPlatform.system == "x86_64-darwin" then "/usr/lib/dyld"
|
||||
else if stdenv.lib.hasSuffix "pc-gnu" targetPlatform.config then "ld.so.1"
|
||||
else null;
|
||||
|
||||
expand-response-params =
|
||||
if buildPackages.stdenv.cc or null != null && buildPackages.stdenv.cc != "/dev/null"
|
||||
then import ../expand-response-params { inherit (buildPackages) stdenv; }
|
||||
else "";
|
||||
|
||||
in
|
||||
|
||||
stdenv.mkDerivation {
|
||||
name = prefix
|
||||
+ (if name != "" then name else "${binutilsName}-wrapper")
|
||||
+ (stdenv.lib.optionalString (binutils != null && binutilsVersion != "") "-${binutilsVersion}");
|
||||
|
||||
preferLocalBuild = true;
|
||||
|
||||
inherit binutils_bin shell libc_bin libc_dev libc_lib coreutils_bin;
|
||||
gnugrep_bin = if nativeTools then "" else gnugrep;
|
||||
|
||||
binPrefix = prefix;
|
||||
inherit infixSalt;
|
||||
|
||||
outputs = [ "out" "man" ];
|
||||
|
||||
passthru = {
|
||||
inherit binutils libc nativeTools nativeLibc nativePrefix prefix;
|
||||
|
||||
emacsBufferSetup = pkgs: ''
|
||||
; We should handle propagation here too
|
||||
(mapc
|
||||
(lambda (arg)
|
||||
(when (file-directory-p (concat arg "/lib"))
|
||||
(setenv "NIX_${infixSalt}_LDFLAGS" (concat (getenv "NIX_${infixSalt}_LDFLAGS") " -L" arg "/lib")))
|
||||
(when (file-directory-p (concat arg "/lib64"))
|
||||
(setenv "NIX_${infixSalt}_LDFLAGS" (concat (getenv "NIX_${infixSalt}_LDFLAGS") " -L" arg "/lib64"))))
|
||||
'(${concatStringsSep " " (map (pkg: "\"${pkg}\"") pkgs)}))
|
||||
'';
|
||||
};
|
||||
|
||||
dontBuild = true;
|
||||
dontConfigure = true;
|
||||
|
||||
unpackPhase = ''
|
||||
src=$PWD
|
||||
'';
|
||||
|
||||
installPhase =
|
||||
''
|
||||
set -u
|
||||
|
||||
mkdir -p $out/bin $out/nix-support $man/nix-support
|
||||
|
||||
wrap() {
|
||||
local dst="$1"
|
||||
local wrapper="$2"
|
||||
export prog="$3"
|
||||
set +u
|
||||
substituteAll "$wrapper" "$out/bin/$dst"
|
||||
set -u
|
||||
chmod +x "$out/bin/$dst"
|
||||
}
|
||||
''
|
||||
|
||||
+ (if nativeTools then ''
|
||||
echo ${nativePrefix} > $out/nix-support/orig-binutils
|
||||
|
||||
ldPath="${nativePrefix}/bin"
|
||||
'' else ''
|
||||
echo $binutils_bin > $out/nix-support/orig-binutils
|
||||
|
||||
ldPath="${binutils_bin}/bin"
|
||||
''
|
||||
|
||||
+ optionalString (targetPlatform.isSunOS && nativePrefix != "") ''
|
||||
# Solaris needs an additional ld wrapper.
|
||||
ldPath="${nativePrefix}/bin"
|
||||
exec="$ldPath/${prefix}ld"
|
||||
wrap ld-solaris ${./ld-solaris-wrapper.sh}
|
||||
'')
|
||||
|
||||
+ ''
|
||||
# Create a symlink to as (the assembler).
|
||||
if [ -e $ldPath/${prefix}as ]; then
|
||||
ln -s $ldPath/${prefix}as $out/bin/${prefix}as
|
||||
fi
|
||||
|
||||
'' + (if !useMacosReexportHack then ''
|
||||
wrap ${prefix}ld ${./ld-wrapper.sh} ''${ld:-$ldPath/${prefix}ld}
|
||||
'' else ''
|
||||
ldInner="${prefix}ld-reexport-delegate"
|
||||
wrap "$ldInner" ${./macos-sierra-reexport-hack.bash} ''${ld:-$ldPath/${prefix}ld}
|
||||
wrap "${prefix}ld" ${./ld-wrapper.sh} "$out/bin/$ldInner"
|
||||
unset ldInner
|
||||
'') + ''
|
||||
|
||||
if [ -e ${binutils_bin}/bin/${prefix}ld.gold ]; then
|
||||
wrap ${prefix}ld.gold ${./ld-wrapper.sh} ${binutils_bin}/bin/${prefix}ld.gold
|
||||
fi
|
||||
|
||||
if [ -e ${binutils_bin}/bin/ld.bfd ]; then
|
||||
wrap ${prefix}ld.bfd ${./ld-wrapper.sh} ${binutils_bin}/bin/${prefix}ld.bfd
|
||||
fi
|
||||
|
||||
set +u
|
||||
'';
|
||||
|
||||
propagatedBuildInputs = extraPackages;
|
||||
|
||||
setupHook = ./setup-hook.sh;
|
||||
|
||||
postFixup =
|
||||
''
|
||||
set -u
|
||||
''
|
||||
|
||||
+ optionalString (libc != null) (''
|
||||
##
|
||||
## General libc support
|
||||
##
|
||||
|
||||
echo "-L${libc_lib}/lib" > $out/nix-support/libc-ldflags
|
||||
|
||||
echo "${libc_lib}" > $out/nix-support/orig-libc
|
||||
echo "${libc_dev}" > $out/nix-support/orig-libc-dev
|
||||
|
||||
##
|
||||
## Dynamic linker support
|
||||
##
|
||||
|
||||
if [[ -z ''${dynamicLinker+x} ]]; then
|
||||
echo "Don't know the name of the dynamic linker for platform '${targetPlatform.config}', so guessing instead." >&2
|
||||
local dynamicLinker="${libc_lib}/lib/ld*.so.?"
|
||||
fi
|
||||
|
||||
# Expand globs to fill array of options
|
||||
dynamicLinker=($dynamicLinker)
|
||||
|
||||
case ''${#dynamicLinker[@]} in
|
||||
0) echo "No dynamic linker found for platform '${targetPlatform.config}'." >&2;;
|
||||
1) echo "Using dynamic linker: '$dynamicLinker'" >&2;;
|
||||
*) echo "Multiple dynamic linkers found for platform '${targetPlatform.config}'." >&2;;
|
||||
esac
|
||||
|
||||
if [ -n "$dynamicLinker" ]; then
|
||||
echo $dynamicLinker > $out/nix-support/dynamic-linker
|
||||
|
||||
'' + (if targetPlatform.isDarwin then ''
|
||||
printf "export LD_DYLD_PATH=%q\n" "$dynamicLinker" >> $out/nix-support/setup-hook
|
||||
'' else ''
|
||||
if [ -e ${libc_lib}/lib/32/ld-linux.so.2 ]; then
|
||||
echo ${libc_lib}/lib/32/ld-linux.so.2 > $out/nix-support/dynamic-linker-m32
|
||||
fi
|
||||
|
||||
local ldflagsBefore=(-dynamic-linker "$dynamicLinker")
|
||||
'') + ''
|
||||
fi
|
||||
|
||||
# The dynamic linker is passed in `ldflagsBefore' to allow
|
||||
# explicit overrides of the dynamic linker by callers to ld
|
||||
# (the *last* value counts, so ours should come first).
|
||||
printWords "''${ldflagsBefore[@]}" > $out/nix-support/libc-ldflags-before
|
||||
'')
|
||||
|
||||
+ optionalString (!nativeTools) ''
|
||||
|
||||
##
|
||||
## User env support
|
||||
##
|
||||
|
||||
# Propagate the underling unwrapped binutils so that if you
|
||||
# install the wrapper, you get tools like objdump, the manpages,
|
||||
# etc. as well (same for any binaries of libc).
|
||||
printWords ${binutils_bin} ${if libc == null then "" else libc_bin} > $out/nix-support/propagated-user-env-packages
|
||||
''
|
||||
|
||||
+ ''
|
||||
|
||||
##
|
||||
## Hardening support
|
||||
##
|
||||
|
||||
# some linkers on some platforms don't support specific -z flags
|
||||
export hardening_unsupported_flags=""
|
||||
if [[ "$($ldPath/${prefix}ld -z now 2>&1 || true)" =~ un(recognized|known)\ option ]]; then
|
||||
hardening_unsupported_flags+=" bindnow"
|
||||
fi
|
||||
if [[ "$($ldPath/${prefix}ld -z relro 2>&1 || true)" =~ un(recognized|known)\ option ]]; then
|
||||
hardening_unsupported_flags+=" relro"
|
||||
fi
|
||||
''
|
||||
|
||||
+ optionalString hostPlatform.isCygwin ''
|
||||
hardening_unsupported_flags+=" pic"
|
||||
''
|
||||
|
||||
+ ''
|
||||
set +u
|
||||
substituteAll ${./add-flags.sh} $out/nix-support/add-flags.sh
|
||||
substituteAll ${./add-hardening.sh} $out/nix-support/add-hardening.sh
|
||||
substituteAll ${../cc-wrapper/utils.sh} $out/nix-support/utils.sh
|
||||
|
||||
##
|
||||
## Extra custom steps
|
||||
##
|
||||
|
||||
''
|
||||
+ extraBuildCommands;
|
||||
|
||||
inherit dynamicLinker expand-response-params;
|
||||
|
||||
# for substitution in utils.sh
|
||||
expandResponseParams = "${expand-response-params}/bin/expand-response-params";
|
||||
|
||||
crossAttrs = {
|
||||
shell = shell.crossDrv + shell.crossDrv.shellPath;
|
||||
};
|
||||
|
||||
meta =
|
||||
let binutils_ = if binutils != null then binutils else {}; in
|
||||
(if binutils_ ? meta then removeAttrs binutils.meta ["priority"] else {}) //
|
||||
{ description =
|
||||
stdenv.lib.attrByPath ["meta" "description"] "System binary utilities" binutils_
|
||||
+ " (wrapper script)";
|
||||
} // optionalAttrs useMacosReexportHack {
|
||||
platforms = stdenv.lib.platforms.darwin;
|
||||
};
|
||||
}
|
|
@ -1,63 +0,0 @@
|
|||
# Binutils Wrapper hygiene
|
||||
#
|
||||
# See comments in cc-wrapper's setup hook. This works exactly the same way.
|
||||
|
||||
binutilsWrapper_addLDVars () {
|
||||
case $depOffset in
|
||||
-1) local role='BUILD_' ;;
|
||||
0) local role='' ;;
|
||||
1) local role='TARGET_' ;;
|
||||
*) echo "binutils-wrapper: Error: Cannot be used with $depOffset-offset deps, " >2;
|
||||
return 1 ;;
|
||||
esac
|
||||
|
||||
if [[ -d "$1/lib64" && ! -L "$1/lib64" ]]; then
|
||||
export NIX_${role}LDFLAGS+=" -L$1/lib64"
|
||||
fi
|
||||
|
||||
if [[ -d "$1/lib" ]]; then
|
||||
export NIX_${role}LDFLAGS+=" -L$1/lib"
|
||||
fi
|
||||
}
|
||||
|
||||
if [ -n "${crossConfig:-}" ]; then
|
||||
export NIX_BINUTILS_WRAPPER_@infixSalt@_TARGET_BUILD=1
|
||||
role="BUILD_"
|
||||
else
|
||||
export NIX_BINUTILS_WRAPPER_@infixSalt@_TARGET_HOST=1
|
||||
role=""
|
||||
fi
|
||||
|
||||
envHooks+=(binutilsWrapper_addLDVars)
|
||||
|
||||
# shellcheck disable=SC2157
|
||||
if [ -n "@binutils_bin@" ]; then
|
||||
addToSearchPath _PATH @binutils_bin@/bin
|
||||
fi
|
||||
|
||||
# shellcheck disable=SC2157
|
||||
if [ -n "@libc_bin@" ]; then
|
||||
addToSearchPath _PATH @libc_bin@/bin
|
||||
fi
|
||||
|
||||
# shellcheck disable=SC2157
|
||||
if [ -n "@coreutils_bin@" ]; then
|
||||
addToSearchPath _PATH @coreutils_bin@/bin
|
||||
fi
|
||||
|
||||
# Export tool environment variables so various build systems use the right ones.
|
||||
|
||||
export NIX_${role}BINUTILS=@out@
|
||||
|
||||
for CMD in \
|
||||
ar as nm objcopy ranlib strip strings size ld windres
|
||||
do
|
||||
if
|
||||
PATH=$_PATH type -p "@binPrefix@$CMD" > /dev/null
|
||||
then
|
||||
export "${role}$(echo "$CMD" | tr "[:lower:]" "[:upper:]")=@binPrefix@${CMD}";
|
||||
fi
|
||||
done
|
||||
|
||||
# No local scope in sourced file
|
||||
unset role
|
|
@ -4,14 +4,19 @@
|
|||
# that case, it is cheaper/better to not repeat this step and let the forked
|
||||
# wrapped binary just inherit the work of the forker's wrapper script.
|
||||
|
||||
var_templates_list=(
|
||||
var_templates=(
|
||||
NIX+CFLAGS_COMPILE
|
||||
NIX+CFLAGS_LINK
|
||||
NIX+CXXSTDLIB_COMPILE
|
||||
NIX+CXXSTDLIB_LINK
|
||||
NIX+GNATFLAGS_COMPILE
|
||||
)
|
||||
var_templates_bool=(
|
||||
NIX+IGNORE_LD_THROUGH_GCC
|
||||
NIX+LDFLAGS
|
||||
NIX+LDFLAGS_BEFORE
|
||||
NIX+LDFLAGS_AFTER
|
||||
|
||||
NIX+SET_BUILD_ID
|
||||
NIX+DONT_SET_RPATH
|
||||
NIX+ENFORCE_NO_NATIVE
|
||||
)
|
||||
|
||||
|
@ -30,11 +35,17 @@ fi
|
|||
|
||||
# We need to mangle names for hygiene, but also take parameters/overrides
|
||||
# from the environment.
|
||||
for var in "${var_templates_list[@]}"; do
|
||||
mangleVarList "$var" "${role_infixes[@]}"
|
||||
done
|
||||
for var in "${var_templates_bool[@]}"; do
|
||||
mangleVarBool "$var" "${role_infixes[@]}"
|
||||
for var in "${var_templates[@]}"; do
|
||||
outputVar="${var/+/_@infixSalt@_}"
|
||||
export ${outputVar}+=''
|
||||
# For each role we serve, we accumulate the input parameters into our own
|
||||
# cc-wrapper-derivation-specific environment variables.
|
||||
for infix in "${role_infixes[@]}"; do
|
||||
inputVar="${var/+/${infix}}"
|
||||
if [ -v "$inputVar" ]; then
|
||||
export ${outputVar}+="${!outputVar:+ }${!inputVar}"
|
||||
fi
|
||||
done
|
||||
done
|
||||
|
||||
# `-B@out@/bin' forces cc to use ld-wrapper.sh when calling ld.
|
||||
|
@ -55,13 +66,17 @@ if [ -e @out@/nix-support/gnat-cflags ]; then
|
|||
NIX_@infixSalt@_GNATFLAGS_COMPILE="$(< @out@/nix-support/gnat-cflags) $NIX_@infixSalt@_GNATFLAGS_COMPILE"
|
||||
fi
|
||||
|
||||
if [ -e @out@/nix-support/libc-ldflags ]; then
|
||||
NIX_@infixSalt@_LDFLAGS+=" $(< @out@/nix-support/libc-ldflags)"
|
||||
fi
|
||||
|
||||
if [ -e @out@/nix-support/cc-ldflags ]; then
|
||||
# We don't import this above, but just tack this on know. binutils-wrapper's
|
||||
# add-flags will not clobber it.
|
||||
#
|
||||
# TODO(@Ericson2314): Consider `NIX_@infixSalt@_CFLAGS_LINK` instead
|
||||
NIX_@infixSalt@_LDFLAGS+=" $(< @out@/nix-support/cc-ldflags)"
|
||||
fi
|
||||
|
||||
if [ -e @out@/nix-support/libc-ldflags-before ]; then
|
||||
NIX_@infixSalt@_LDFLAGS_BEFORE="$(< @out@/nix-support/libc-ldflags-before) $NIX_@infixSalt@_LDFLAGS_BEFORE"
|
||||
fi
|
||||
|
||||
# That way forked processes will not extend these environment variables again.
|
||||
export NIX_CC_WRAPPER_@infixSalt@_FLAGS_SET=1
|
||||
|
|
|
@ -6,6 +6,7 @@ if [[ -v hardeningEnable[@] ]]; then
|
|||
hardeningFlags+=(${hardeningEnable[@]})
|
||||
fi
|
||||
hardeningCFlags=()
|
||||
hardeningLDFlags=()
|
||||
|
||||
declare -A hardeningDisableMap
|
||||
|
||||
|
@ -43,6 +44,7 @@ if [[ -z "${hardeningDisableMap[all]:-}" ]]; then
|
|||
if [[ ! ("$*" =~ " -shared " || "$*" =~ " -static ") ]]; then
|
||||
if [[ -n "${NIX_DEBUG:-}" ]]; then echo HARDENING: enabling LDFlags -pie >&2; fi
|
||||
hardeningCFlags+=('-pie')
|
||||
hardeningLDFlags+=('-pie')
|
||||
fi
|
||||
;;
|
||||
pic)
|
||||
|
@ -57,6 +59,14 @@ if [[ -z "${hardeningDisableMap[all]:-}" ]]; then
|
|||
if [[ -n "${NIX_DEBUG:-}" ]]; then echo HARDENING: enabling format >&2; fi
|
||||
hardeningCFlags+=('-Wformat' '-Wformat-security' '-Werror=format-security')
|
||||
;;
|
||||
relro)
|
||||
if [[ -n "${NIX_DEBUG:-}" ]]; then echo HARDENING: enabling relro >&2; fi
|
||||
hardeningLDFlags+=('-z' 'relro')
|
||||
;;
|
||||
bindnow)
|
||||
if [[ -n "${NIX_DEBUG:-}" ]]; then echo HARDENING: enabling bindnow >&2; fi
|
||||
hardeningLDFlags+=('-z' 'now')
|
||||
;;
|
||||
*)
|
||||
# Ignore unsupported. Checked in Nix that at least *some*
|
||||
# tool supports each flag.
|
||||
|
|
|
@ -11,18 +11,12 @@ if [[ -n "@coreutils_bin@" && -n "@gnugrep_bin@" ]]; then
|
|||
PATH="@coreutils_bin@/bin:@gnugrep_bin@/bin"
|
||||
fi
|
||||
|
||||
source @out@/nix-support/utils.sh
|
||||
|
||||
# Flirting with a layer violation here.
|
||||
if [ -z "${NIX_BINUTILS_WRAPPER_@infixSalt@_FLAGS_SET:-}" ]; then
|
||||
source @binutils@/nix-support/add-flags.sh
|
||||
fi
|
||||
|
||||
# Put this one second so libc ldflags take priority.
|
||||
if [ -z "${NIX_CC_WRAPPER_@infixSalt@_FLAGS_SET:-}" ]; then
|
||||
source @out@/nix-support/add-flags.sh
|
||||
fi
|
||||
|
||||
source @out@/nix-support/utils.sh
|
||||
|
||||
|
||||
# Parse command line options and set several variables.
|
||||
# For instance, figure out if linker flags should be passed.
|
||||
|
@ -63,6 +57,10 @@ while (( "$n" < "$nParams" )); do
|
|||
cppInclude=0
|
||||
elif [ "${p:0:1}" != - ]; then
|
||||
nonFlagArgs=1
|
||||
elif [ "$p" = -m32 ]; then
|
||||
if [ -e @out@/nix-support/dynamic-linker-m32 ]; then
|
||||
NIX_@infixSalt@_LDFLAGS+=" -dynamic-linker $(< @out@/nix-support/dynamic-linker-m32)"
|
||||
fi
|
||||
fi
|
||||
n+=1
|
||||
done
|
||||
|
|
|
@ -6,20 +6,23 @@
|
|||
# compiler and the linker just "work".
|
||||
|
||||
{ name ? "", stdenv, nativeTools, noLibc ? false, nativeLibc, nativePrefix ? ""
|
||||
, cc ? null, libc ? null, binutils, coreutils ? null, shell ? stdenv.shell
|
||||
, cc ? null, libc ? null, binutils ? null, coreutils ? null, shell ? stdenv.shell
|
||||
, zlib ? null, extraPackages ? [], extraBuildCommands ? ""
|
||||
, isGNU ? false, isClang ? cc.isClang or false, gnugrep ? null
|
||||
, buildPackages ? {}
|
||||
, useMacosReexportHack ? false
|
||||
}:
|
||||
|
||||
with stdenv.lib;
|
||||
|
||||
assert nativeTools -> nativePrefix != "";
|
||||
assert !nativeTools ->
|
||||
cc != null && coreutils != null && gnugrep != null;
|
||||
cc != null && binutils != null && coreutils != null && gnugrep != null;
|
||||
assert !(nativeLibc && noLibc);
|
||||
assert (noLibc || nativeLibc) == (libc == null);
|
||||
|
||||
assert stdenv.targetPlatform != stdenv.hostPlatform -> runCommand != null;
|
||||
|
||||
# For ghdl (the vhdl language provider to gcc) we need zlib in the wrapper.
|
||||
assert cc.langVhdl or false -> zlib != null;
|
||||
|
||||
|
@ -40,6 +43,7 @@ let
|
|||
libc_dev = if libc == null then null else getDev libc;
|
||||
libc_lib = if libc == null then null else getLib libc;
|
||||
cc_solib = getLib cc;
|
||||
binutils_bin = if nativeTools then "" else getBin binutils;
|
||||
# The wrapper scripts use 'cat' and 'grep', so we may need coreutils.
|
||||
coreutils_bin = if nativeTools then "" else getBin coreutils;
|
||||
|
||||
|
@ -55,6 +59,21 @@ let
|
|||
# unstable implementation detail, however.
|
||||
infixSalt = dashlessTarget;
|
||||
|
||||
# The dynamic linker has different names on different platforms. This is a
|
||||
# shell glob that ought to match it.
|
||||
dynamicLinker =
|
||||
/**/ if libc == null then null
|
||||
else if targetPlatform.system == "i686-linux" then "${libc_lib}/lib/ld-linux.so.2"
|
||||
else if targetPlatform.system == "x86_64-linux" then "${libc_lib}/lib/ld-linux-x86-64.so.2"
|
||||
# ARM with a wildcard, which can be "" or "-armhf".
|
||||
else if targetPlatform.isArm then "${libc_lib}/lib/ld-linux*.so.3"
|
||||
else if targetPlatform.system == "aarch64-linux" then "${libc_lib}/lib/ld-linux-aarch64.so.1"
|
||||
else if targetPlatform.system == "powerpc-linux" then "${libc_lib}/lib/ld.so.1"
|
||||
else if targetPlatform.system == "mips64el-linux" then "${libc_lib}/lib/ld.so.1"
|
||||
else if targetPlatform.system == "x86_64-darwin" then "/usr/lib/dyld"
|
||||
else if stdenv.lib.hasSuffix "pc-gnu" targetPlatform.config then "ld.so.1"
|
||||
else null;
|
||||
|
||||
expand-response-params =
|
||||
if buildPackages.stdenv.cc or null != null && buildPackages.stdenv.cc != "/dev/null"
|
||||
then import ../expand-response-params { inherit (buildPackages) stdenv; }
|
||||
|
@ -69,7 +88,7 @@ stdenv.mkDerivation {
|
|||
|
||||
preferLocalBuild = true;
|
||||
|
||||
inherit cc shell libc_bin libc_dev libc_lib binutils coreutils_bin;
|
||||
inherit cc shell libc_bin libc_dev libc_lib binutils_bin coreutils_bin;
|
||||
gnugrep_bin = if nativeTools then "" else gnugrep;
|
||||
|
||||
binPrefix = prefix;
|
||||
|
@ -83,11 +102,13 @@ stdenv.mkDerivation {
|
|||
|
||||
emacsBufferSetup = pkgs: ''
|
||||
; We should handle propagation here too
|
||||
(mapc
|
||||
(lambda (arg)
|
||||
(when (file-directory-p (concat arg "/include"))
|
||||
(setenv "NIX_${infixSalt}_CFLAGS_COMPILE" (concat (getenv "NIX_${infixSalt}_CFLAGS_COMPILE") " -isystem " arg "/include"))))
|
||||
'(${concatStringsSep " " (map (pkg: "\"${pkg}\"") pkgs)}))
|
||||
(mapc (lambda (arg)
|
||||
(when (file-directory-p (concat arg "/include"))
|
||||
(setenv "NIX_${infixSalt}_CFLAGS_COMPILE" (concat (getenv "NIX_${infixSalt}_CFLAGS_COMPILE") " -isystem " arg "/include")))
|
||||
(when (file-directory-p (concat arg "/lib"))
|
||||
(setenv "NIX_${infixSalt}_LDFLAGS" (concat (getenv "NIX_${infixSalt}_LDFLAGS") " -L" arg "/lib")))
|
||||
(when (file-directory-p (concat arg "/lib64"))
|
||||
(setenv "NIX_${infixSalt}_LDFLAGS" (concat (getenv "NIX_${infixSalt}_LDFLAGS") " -L" arg "/lib64")))) '(${concatStringsSep " " (map (pkg: "\"${pkg}\"") pkgs)}))
|
||||
'';
|
||||
};
|
||||
|
||||
|
@ -117,18 +138,45 @@ stdenv.mkDerivation {
|
|||
echo ${if targetPlatform.isDarwin then cc else nativePrefix} > $out/nix-support/orig-cc
|
||||
|
||||
ccPath="${if targetPlatform.isDarwin then cc else nativePrefix}/bin"
|
||||
ldPath="${nativePrefix}/bin"
|
||||
'' else ''
|
||||
echo $cc > $out/nix-support/orig-cc
|
||||
|
||||
ccPath="${cc}/bin"
|
||||
ldPath="${binutils_bin}/bin"
|
||||
''
|
||||
|
||||
+ optionalString (targetPlatform.isSunOS && nativePrefix != "") ''
|
||||
# Solaris needs an additional ld wrapper.
|
||||
ldPath="${nativePrefix}/bin"
|
||||
exec="$ldPath/${prefix}ld"
|
||||
wrap ld-solaris ${./ld-solaris-wrapper.sh}
|
||||
'')
|
||||
|
||||
+ ''
|
||||
# Create symlinks to everything in the binutils wrapper.
|
||||
for bbin in $binutils/bin/*; do
|
||||
mkdir -p "$out/bin"
|
||||
ln -s "$bbin" "$out/bin/$(basename $bbin)"
|
||||
done
|
||||
# Create a symlink to as (the assembler). This is useful when a
|
||||
# cc-wrapper is installed in a user environment, as it ensures that
|
||||
# the right assembler is called.
|
||||
if [ -e $ldPath/${prefix}as ]; then
|
||||
ln -s $ldPath/${prefix}as $out/bin/${prefix}as
|
||||
fi
|
||||
|
||||
'' + (if !useMacosReexportHack then ''
|
||||
wrap ${prefix}ld ${./ld-wrapper.sh} ''${ld:-$ldPath/${prefix}ld}
|
||||
'' else ''
|
||||
ldInner="${prefix}ld-reexport-delegate"
|
||||
wrap "$ldInner" ${./macos-sierra-reexport-hack.bash} ''${ld:-$ldPath/${prefix}ld}
|
||||
wrap "${prefix}ld" ${./ld-wrapper.sh} "$out/bin/$ldInner"
|
||||
unset ldInner
|
||||
'') + ''
|
||||
|
||||
if [ -e ${binutils_bin}/bin/${prefix}ld.gold ]; then
|
||||
wrap ${prefix}ld.gold ${./ld-wrapper.sh} ${binutils_bin}/bin/${prefix}ld.gold
|
||||
fi
|
||||
|
||||
if [ -e ${binutils_bin}/bin/ld.bfd ]; then
|
||||
wrap ${prefix}ld.bfd ${./ld-wrapper.sh} ${binutils_bin}/bin/${prefix}ld.bfd
|
||||
fi
|
||||
|
||||
# We export environment variables pointing to the wrapped nonstandard
|
||||
# cmds, lest some lousy configure script use those to guess compiler
|
||||
|
@ -188,7 +236,7 @@ stdenv.mkDerivation {
|
|||
ln -s $ccPath/${prefix}ghdl $out/bin/${prefix}ghdl
|
||||
'';
|
||||
|
||||
propagatedBuildInputs = [ binutils ] ++ extraPackages;
|
||||
propagatedBuildInputs = extraPackages;
|
||||
|
||||
setupHook = ./setup-hook.sh;
|
||||
|
||||
|
@ -197,7 +245,7 @@ stdenv.mkDerivation {
|
|||
set -u
|
||||
''
|
||||
|
||||
+ optionalString (libc != null) ''
|
||||
+ optionalString (libc != null) (''
|
||||
##
|
||||
## General libc support
|
||||
##
|
||||
|
@ -215,9 +263,48 @@ stdenv.mkDerivation {
|
|||
# another -idirafter is necessary to add that directory again.
|
||||
echo "-B${libc_lib}/lib/ -idirafter ${libc_dev}/include -idirafter ${cc}/lib/gcc/*/*/include-fixed" > $out/nix-support/libc-cflags
|
||||
|
||||
echo "-L${libc_lib}/lib" > $out/nix-support/libc-ldflags
|
||||
|
||||
echo "${libc_lib}" > $out/nix-support/orig-libc
|
||||
echo "${libc_dev}" > $out/nix-support/orig-libc-dev
|
||||
''
|
||||
|
||||
##
|
||||
## Dynamic linker support
|
||||
##
|
||||
|
||||
if [[ -z ''${dynamicLinker+x} ]]; then
|
||||
echo "Don't know the name of the dynamic linker for platform '${targetPlatform.config}', so guessing instead." >&2
|
||||
local dynamicLinker="${libc_lib}/lib/ld*.so.?"
|
||||
fi
|
||||
|
||||
# Expand globs to fill array of options
|
||||
dynamicLinker=($dynamicLinker)
|
||||
|
||||
case ''${#dynamicLinker[@]} in
|
||||
0) echo "No dynamic linker found for platform '${targetPlatform.config}'." >&2;;
|
||||
1) echo "Using dynamic linker: '$dynamicLinker'" >&2;;
|
||||
*) echo "Multiple dynamic linkers found for platform '${targetPlatform.config}'." >&2;;
|
||||
esac
|
||||
|
||||
if [ -n "$dynamicLinker" ]; then
|
||||
echo $dynamicLinker > $out/nix-support/dynamic-linker
|
||||
|
||||
'' + (if targetPlatform.isDarwin then ''
|
||||
printf "export LD_DYLD_PATH=%q\n" "$dynamicLinker" >> $out/nix-support/setup-hook
|
||||
'' else ''
|
||||
if [ -e ${libc_lib}/lib/32/ld-linux.so.2 ]; then
|
||||
echo ${libc_lib}/lib/32/ld-linux.so.2 > $out/nix-support/dynamic-linker-m32
|
||||
fi
|
||||
|
||||
local ldflagsBefore=(-dynamic-linker "$dynamicLinker")
|
||||
'') + ''
|
||||
fi
|
||||
|
||||
# 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).
|
||||
printWords "''${ldflagsBefore[@]}" > $out/nix-support/libc-ldflags-before
|
||||
'')
|
||||
|
||||
+ optionalString (!nativeTools) ''
|
||||
|
||||
|
@ -258,6 +345,7 @@ stdenv.mkDerivation {
|
|||
# Propagate the wrapped cc so that if you install the wrapper,
|
||||
# you get tools like gcov, the manpages, etc. as well (including
|
||||
# for binutils and Glibc).
|
||||
printWords ${cc} ${binutils_bin} ${if libc == null then "" else libc_bin} > $out/nix-support/propagated-user-env-packages
|
||||
printWords ${cc.man or ""} > $man/nix-support/propagated-user-env-packages
|
||||
''
|
||||
|
||||
|
@ -267,7 +355,14 @@ stdenv.mkDerivation {
|
|||
## Hardening support
|
||||
##
|
||||
|
||||
# some linkers on some platforms don't support specific -z flags
|
||||
export hardening_unsupported_flags=""
|
||||
if [[ "$($ldPath/${prefix}ld -z now 2>&1 || true)" =~ un(recognized|known)\ option ]]; then
|
||||
hardening_unsupported_flags+=" bindnow"
|
||||
fi
|
||||
if [[ "$($ldPath/${prefix}ld -z relro 2>&1 || true)" =~ un(recognized|known)\ option ]]; then
|
||||
hardening_unsupported_flags+=" relro"
|
||||
fi
|
||||
''
|
||||
|
||||
+ optionalString hostPlatform.isCygwin ''
|
||||
|
@ -286,7 +381,7 @@ stdenv.mkDerivation {
|
|||
''
|
||||
+ extraBuildCommands;
|
||||
|
||||
inherit expand-response-params;
|
||||
inherit dynamicLinker expand-response-params;
|
||||
|
||||
# for substitution in utils.sh
|
||||
expandResponseParams = "${expand-response-params}/bin/expand-response-params";
|
||||
|
@ -301,5 +396,7 @@ stdenv.mkDerivation {
|
|||
{ description =
|
||||
stdenv.lib.attrByPath ["meta" "description"] "System C compiler" cc_
|
||||
+ " (wrapper script)";
|
||||
} // optionalAttrs useMacosReexportHack {
|
||||
platforms = stdenv.lib.platforms.darwin;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -13,12 +13,12 @@ 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
|
||||
|
||||
source @out@/nix-support/utils.sh
|
||||
|
||||
|
||||
# Figure out if linker flags should be passed. GCC prints annoying
|
||||
# warnings when they are not needed.
|
||||
|
|
0
pkgs/build-support/binutils-wrapper/ld-solaris-wrapper.sh → pkgs/build-support/cc-wrapper/ld-solaris-wrapper.sh
Normal file → Executable file
0
pkgs/build-support/binutils-wrapper/ld-solaris-wrapper.sh → pkgs/build-support/cc-wrapper/ld-solaris-wrapper.sh
Normal file → Executable file
|
@ -10,12 +10,12 @@ if [ -n "@coreutils_bin@" ]; then
|
|||
PATH="@coreutils_bin@/bin"
|
||||
fi
|
||||
|
||||
source @out@/nix-support/utils.sh
|
||||
|
||||
if [ -z "${NIX_BINUTILS_WRAPPER_@infixSalt@_FLAGS_SET:-}" ]; then
|
||||
if [ -z "${NIX_CC_WRAPPER_@infixSalt@_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.
|
||||
expandResponseParams "$@"
|
||||
|
@ -63,21 +63,6 @@ fi
|
|||
|
||||
extraAfter+=($NIX_@infixSalt@_LDFLAGS_AFTER)
|
||||
|
||||
# Choose 32-bit dynamic linker if needed
|
||||
if [ -e @out@/nix-support/dynamic-linker-m32 ]; then
|
||||
prev=
|
||||
for p in ${params+"${params[@]}"}; do
|
||||
if [[ "$prev" = "-m" && "$p" = "elf_i386" ]]; then
|
||||
extraAfter+=(
|
||||
'-dynamic-linker'
|
||||
"$(< @out@/nix-support/dynamic-linker-m32)"
|
||||
)
|
||||
break
|
||||
fi
|
||||
prev="$p"
|
||||
done
|
||||
fi
|
||||
|
||||
declare -a libDirs
|
||||
declare -A libs
|
||||
relocatable=
|
106
pkgs/build-support/cc-wrapper/macos-sierra-reexport-hack.bash
Normal file
106
pkgs/build-support/cc-wrapper/macos-sierra-reexport-hack.bash
Normal file
|
@ -0,0 +1,106 @@
|
|||
#! @shell@
|
||||
|
||||
set -eu -o pipefail
|
||||
|
||||
path_backup="$PATH"
|
||||
if [ -n "@coreutils_bin@" ]; then
|
||||
PATH="@coreutils_bin@/bin"
|
||||
fi
|
||||
|
||||
declare -r recurThreshold=300
|
||||
|
||||
declare overflowCount=0
|
||||
for ((n=0; n < $#; ++n)); do
|
||||
case "${!n}" in
|
||||
-l*) let overflowCount+=1 ;;
|
||||
-reexport-l*) let overflowCount+=1 ;;
|
||||
*) ;;
|
||||
esac
|
||||
done
|
||||
|
||||
declare -a allArgs=()
|
||||
|
||||
if (( "$overflowCount" <= "$recurThreshold" )); then
|
||||
allArgs=("$@")
|
||||
else
|
||||
declare -a childrenLookup=() childrenLink=()
|
||||
|
||||
while (( $# )); do
|
||||
case "$1" in
|
||||
-L/*)
|
||||
childrenLookup+=("$1")
|
||||
allArgs+=("$1")
|
||||
;;
|
||||
-L)
|
||||
echo "cctools LD does not support '-L foo' or '-l foo'" >&2
|
||||
exit 1
|
||||
;;
|
||||
-l)
|
||||
echo "cctools LD does not support '-L foo' or '-l foo'" >&2
|
||||
exit 1
|
||||
;;
|
||||
-lazy_library | -lazy_framework | -lto_library)
|
||||
# We aren't linking any "azy_library", "to_library", etc.
|
||||
allArgs+=("$1")
|
||||
;;
|
||||
-lazy-l | -weak-l) allArgs+=("$1") ;;
|
||||
# We can't so easily prevent header issues from these.
|
||||
-lSystem) allArgs+=("$1") ;;
|
||||
# Special case as indirection seems like a bad idea for something
|
||||
# so fundamental. Can be removed for simplicity.
|
||||
-l?* | -reexport-l?*) childrenLink+=("$1") ;;
|
||||
*) allArgs+=("$1") ;;
|
||||
esac
|
||||
|
||||
shift
|
||||
done
|
||||
|
||||
declare n=0
|
||||
while (( $n < "${#childrenLink[@]}" )); do
|
||||
if [[ "${childrenLink[n]}" = -l* ]]; then
|
||||
childrenLink[n]="-reexport${childrenLink[n]}"
|
||||
fi
|
||||
let ++n
|
||||
done
|
||||
unset n
|
||||
|
||||
declare -r outputNameLibless=$(basename $( \
|
||||
if [[ -z "${outputName:+isUndefined}" ]]; then
|
||||
echo unnamed
|
||||
elif [[ "${outputName:0:3}" = lib ]]; then
|
||||
echo "${outputName:3}"
|
||||
else
|
||||
echo "${outputName}"
|
||||
fi))
|
||||
declare -ra children=("$outputNameLibless-reexport-delegate-0" \
|
||||
"$outputNameLibless-reexport-delegate-1")
|
||||
|
||||
mkdir -p "$out/lib"
|
||||
|
||||
PATH="$PATH:@out@/bin"
|
||||
|
||||
symbolBloatObject=$outputNameLibless-symbol-hack.o
|
||||
if [[ ! -e $symbolBloatObject ]]; then
|
||||
printf '.private_extern _______child_hack_foo\nchild_hack_foo:\n' \
|
||||
| @binPrefix@as -- -o $symbolBloatObject
|
||||
fi
|
||||
|
||||
# first half of libs
|
||||
@binPrefix@ld -macosx_version_min $MACOSX_DEPLOYMENT_TARGET -arch x86_64 -dylib \
|
||||
-o "$out/lib/lib${children[0]}.dylib" \
|
||||
-install_name "$out/lib/lib${children[0]}.dylib" \
|
||||
"${childrenLookup[@]}" "$symbolBloatObject" \
|
||||
"${childrenLink[@]:0:$((${#childrenLink[@]} / 2 ))}"
|
||||
|
||||
# second half of libs
|
||||
@binPrefix@ld -macosx_version_min $MACOSX_DEPLOYMENT_TARGET -arch x86_64 -dylib \
|
||||
-o "$out/lib/lib${children[1]}.dylib" \
|
||||
-install_name "$out/lib/lib${children[1]}.dylib" \
|
||||
"${childrenLookup[@]}" "$symbolBloatObject" \
|
||||
"${childrenLink[@]:$((${#childrenLink[@]} / 2 ))}"
|
||||
|
||||
allArgs+=("-L$out/lib" "-l${children[0]}" "-l${children[1]}")
|
||||
fi
|
||||
|
||||
PATH="$path_backup"
|
||||
exec @prog@ "${allArgs[@]}"
|
|
@ -74,6 +74,14 @@ ccWrapper_addCVars () {
|
|||
export NIX_${role}CFLAGS_COMPILE+=" ${ccIncludeFlag:--isystem} $1/include"
|
||||
fi
|
||||
|
||||
if [[ -d "$1/lib64" && ! -L "$1/lib64" ]]; then
|
||||
export NIX_${role}LDFLAGS+=" -L$1/lib64"
|
||||
fi
|
||||
|
||||
if [[ -d "$1/lib" ]]; then
|
||||
export NIX_${role}LDFLAGS+=" -L$1/lib"
|
||||
fi
|
||||
|
||||
if [[ -d "$1/Library/Frameworks" ]]; then
|
||||
export NIX_${role}CFLAGS_COMPILE+=" -F$1/Library/Frameworks"
|
||||
fi
|
||||
|
@ -108,6 +116,11 @@ if [ -n "@cc@" ]; then
|
|||
addToSearchPath _PATH @cc@/bin
|
||||
fi
|
||||
|
||||
# shellcheck disable=SC2157
|
||||
if [ -n "@binutils_bin@" ]; then
|
||||
addToSearchPath _PATH @binutils_bin@/bin
|
||||
fi
|
||||
|
||||
# shellcheck disable=SC2157
|
||||
if [ -n "@libc_bin@" ]; then
|
||||
addToSearchPath _PATH @libc_bin@/bin
|
||||
|
@ -125,5 +138,15 @@ export NIX_${role}CC=@out@
|
|||
export ${role}CC=@named_cc@
|
||||
export ${role}CXX=@named_cxx@
|
||||
|
||||
for CMD in \
|
||||
ar as nm objcopy ranlib strip strings size ld windres
|
||||
do
|
||||
if
|
||||
PATH=$_PATH type -p "@binPrefix@$CMD" > /dev/null
|
||||
then
|
||||
export "${role}$(echo "$CMD" | tr "[:lower:]" "[:upper:]")=@binPrefix@${CMD}";
|
||||
fi
|
||||
done
|
||||
|
||||
# No local scope in sourced file
|
||||
unset role
|
||||
|
|
|
@ -1,35 +1,3 @@
|
|||
mangleVarList() {
|
||||
local var="$1"
|
||||
shift
|
||||
local -a role_infixes=("$@")
|
||||
|
||||
local outputVar="${var/+/_@infixSalt@_}"
|
||||
declare -gx ${outputVar}+=''
|
||||
# For each role we serve, we accumulate the input parameters into our own
|
||||
# cc-wrapper-derivation-specific environment variables.
|
||||
for infix in "${role_infixes[@]}"; do
|
||||
local inputVar="${var/+/${infix}}"
|
||||
if [ -v "$inputVar" ]; then
|
||||
export ${outputVar}+="${!outputVar:+ }${!inputVar}"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
mangleVarBool() {
|
||||
local var="$1"
|
||||
shift
|
||||
local -a role_infixes=("$@")
|
||||
|
||||
local outputVar="${var/+/_@infixSalt@_}"
|
||||
declare -gxi ${outputVar}+=''
|
||||
for infix in "${role_infixes[@]}"; do
|
||||
local inputVar="${var/+/${infix}}"
|
||||
if [ -v "$inputVar" ]; then
|
||||
let "${outputVar} |= ${!inputVar}"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
skip () {
|
||||
if [ -n "${NIX_DEBUG:-}" ]; then
|
||||
echo "skipping impure path $1" >&2
|
||||
|
|
|
@ -59,7 +59,7 @@ in stdenv.mkDerivation {
|
|||
|
||||
while IFS= read -r -d ''$'\0' i; do
|
||||
if isELF "$i"; then
|
||||
bin=`patchelf --set-interpreter "$(cat $NIX_BINUTILS/nix-support/dynamic-linker)" "$i"; echo $?`
|
||||
bin=`patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" "$i"; echo $?`
|
||||
patchelf --set-rpath "${stdenv.lib.makeLibraryPath deps}" "$i"
|
||||
if [ "$bin" -eq 0 ]; then
|
||||
wrapProgram "$i" \
|
||||
|
|
|
@ -135,7 +135,7 @@ stdenv.mkDerivation rec {
|
|||
cp ${teensyduino_src} ./TeensyduinoInstall.${teensy_architecture}
|
||||
chmod +w ./TeensyduinoInstall.${teensy_architecture}
|
||||
upx -d ./TeensyduinoInstall.${teensy_architecture}
|
||||
patchelf --set-interpreter $(cat $NIX_BINUTILS/nix-support/dynamic-linker) \
|
||||
patchelf --set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) \
|
||||
--set-rpath "${teensy_libpath}" \
|
||||
./TeensyduinoInstall.${teensy_architecture}
|
||||
chmod +x ./TeensyduinoInstall.${teensy_architecture}
|
||||
|
@ -181,7 +181,7 @@ stdenv.mkDerivation rec {
|
|||
|
||||
preFixup = ''
|
||||
for file in $(find $out -type f \( -perm /0111 -o -name \*.so\* \) ); do
|
||||
patchelf --set-interpreter "$(cat $NIX_BINUTILS/nix-support/dynamic-linker)" "$file" || true
|
||||
patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" "$file" || true
|
||||
patchelf --set-rpath ${rpath}:$out/lib $file || true
|
||||
done
|
||||
|
||||
|
@ -203,7 +203,7 @@ stdenv.mkDerivation rec {
|
|||
${stdenv.lib.optionalString withTeensyduino ''
|
||||
# Patch the Teensy loader binary
|
||||
patchelf --debug \
|
||||
--set-interpreter $(cat $NIX_BINUTILS/nix-support/dynamic-linker) \
|
||||
--set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) \
|
||||
--set-rpath "${teensy_libpath}" \
|
||||
$out/share/arduino/hardware/tools/teensy
|
||||
''}
|
||||
|
|
|
@ -24,7 +24,7 @@ stdenv.mkDerivation {
|
|||
buildCommand = ''
|
||||
mkdir -p $out
|
||||
tar -C $out -xjf ${dist}
|
||||
patchelf --set-interpreter "$(cat $NIX_BINUTILS/nix-support/dynamic-linker)" \
|
||||
patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
|
||||
$out/bin/lisp
|
||||
'';
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ stdenv.mkDerivation rec {
|
|||
--suffix DYLD_LIBRARY_PATH : $libPath
|
||||
''
|
||||
else ''
|
||||
patchelf --set-interpreter $(cat $NIX_BINUTILS/nix-support/dynamic-linker) \
|
||||
patchelf --set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) \
|
||||
crystal-${version}-1/embedded/bin/crystal
|
||||
patchelf --set-rpath ${ stdenv.lib.makeLibraryPath [ stdenv.cc.cc ] } \
|
||||
crystal-${version}-1/embedded/bin/crystal
|
||||
|
|
|
@ -49,7 +49,7 @@ let
|
|||
echo "patching $i..."
|
||||
if [[ ! $i =~ \.so ]]; then
|
||||
patchelf \
|
||||
--set-interpreter "''$(cat $NIX_BINUTILS/nix-support/dynamic-linker)" $i
|
||||
--set-interpreter "''$(cat $NIX_CC/nix-support/dynamic-linker)" $i
|
||||
fi
|
||||
rpath2=$rpath:$lib/lib:$out/jre/lib/amd64/jli:$out/lib:$out/lib64:$out/nvvm/lib:$out/nvvm/lib64
|
||||
patchelf --set-rpath $rpath2 --force-rpath $i
|
||||
|
|
|
@ -25,7 +25,7 @@ if test "$noSysDirs" = "1"; then
|
|||
# Figure out what extra flags to pass to the gcc compilers
|
||||
# being generated to make sure that they use our glibc.
|
||||
extraFlags="$(cat $NIX_CC/nix-support/libc-cflags)"
|
||||
extraLDFlags="$(cat $NIX_BINUTILS/nix-support/libc-ldflags) $(cat $NIX_BINUTILS/nix-support/libc-ldflags-before || true)"
|
||||
extraLDFlags="$(cat $NIX_CC/nix-support/libc-ldflags) $(cat $NIX_CC/nix-support/libc-ldflags-before || true)"
|
||||
|
||||
# Use *real* header files, otherwise a limits.h is generated
|
||||
# that does not include Glibc's limits.h (notably missing
|
||||
|
|
|
@ -39,7 +39,7 @@ stdenv.mkDerivation rec {
|
|||
# find editline/gmp.
|
||||
(if stdenv.isLinux then ''
|
||||
find . -type f -perm -0100 \
|
||||
-exec patchelf --interpreter "$(cat $NIX_BINUTILS/nix-support/dynamic-linker)" \
|
||||
-exec patchelf --interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
|
||||
--set-rpath "${lib.makeLibraryPath [ libedit ncurses5 gmp ]}" {} \;
|
||||
for prog in ld ar gcc strip ranlib; do
|
||||
find . -name "setup-config" -exec sed -i "s@/usr/bin/$prog@$(type -p $prog)@g" {} \;
|
||||
|
|
|
@ -61,7 +61,7 @@ stdenv.mkDerivation rec {
|
|||
# find editline/gmp.
|
||||
stdenv.lib.optionalString stdenv.isLinux ''
|
||||
find . -type f -perm -0100 \
|
||||
-exec patchelf --interpreter "$(cat $NIX_BINUTILS/nix-support/dynamic-linker)" \
|
||||
-exec patchelf --interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
|
||||
--set-rpath "${stdenv.lib.makeLibraryPath [ ncurses5 gmp ]}" {} \;
|
||||
sed -i "s|/usr/bin/perl|perl\x00 |" ghc-${version}/ghc/stage2/build/tmp/ghc-stage2
|
||||
sed -i "s|/usr/bin/gcc|gcc\x00 |" ghc-${version}/ghc/stage2/build/tmp/ghc-stage2
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue