Commit graph

139 commits

Author SHA1 Message Date
Moritz Angermann 14996789a1
Check link type based on expanded parameters
So far we've ignored response files in arguments, and did not
check linkType against expanded parameters.  This means if
we have `-static` in a @reponse-file, linkType will not be
set to `-static` as we never check against the expanded arguments
from response files.
2022-01-01 20:30:56 +08:00
oxalica 3b069a2ef8
bintools-wrapper: add dynamicLinker for riscv 2021-11-26 00:32:33 +08:00
sterni 5d0972c63b
Merge pull request #138289 from sternenseemann/fix-non-gnu-strip
stdenv: move --enable-deterministic-archives flag into GNU wrapper
2021-10-07 12:29:59 +02:00
r-burns 16728283c3
Merge pull request #135619 from r-burns/fpie-musl-fixes
[staging] {cc,binutils}-wrapper: fixes for PIE hardening
2021-09-23 17:55:08 -07:00
Ryan Burns 37d089c1af {cc,binutils}-wrapper: match leading/trailing arguments
fixes e.g.:
pkgsMusl.libfsm
pkgsMusl.libiscsi
pkgsMusl.nsjail
pkgsMusl.pv

match strings have whitespace on either side, which wasn't
matching leading/trailing arguments previously
2021-09-20 17:24:04 -07:00
sternenseemann 11fe2fc3cf stdenv: move --enable-deterministic-archives flag into GNU wrapper
`--enable-deterministic-archives` is a GNU specific strip flag and
causes other strip implementations (for example LLVM's, see #138013)
to fail. Since strip failures are ignored, this means that stripping
doesn't work at all in certain situation (causing unnecessary
dependencies etc.).

To fix this, no longer pass `--enable-deterministic-archives`
unconditionally, but instead add it in a GNU binutils specific strip
wrapper only.

`commonStripFlags` was only used for this flag, so we can remove
it altogether.

Future work could be to make a generic strip wrapper, with support for
nix-support/strip-flags-{before,after} and NIX_STRIP_FLAGS_{BEFORE,AFTER}.
This possibly overkill and unnecessary though -- also with the
additional challenge of incorporating the darwin strip wrapper somehow.
2021-09-18 15:11:17 +02:00
sternenseemann fb1348d433 bintools-wrapper: check if bintools to wrap isGNU, not stdenv
The wrapped bintools and the one used to build the wrapper can differ.
2021-09-17 17:06:24 +02:00
github-actions[bot] 6a5e4f2c3d
Merge master into staging-next 2021-07-25 06:01:27 +00:00
Ben Siraphob 0f1204bd2b Initial implementation of s390 cross-compile 2021-07-25 10:12:18 +07:00
github-actions[bot] 859acbc1bc
Merge master into staging-next 2021-07-24 18:01:04 +00:00
Ben Siraphob 407953e9df Initial implementation of m68k cross-compile 2021-07-24 14:37:35 +07:00
github-actions[bot] 08a8809bfe
Merge staging-next into staging 2021-07-18 00:02:06 +00:00
Vladimír Čunát 4bd38c330f
Revert #127736: stdenv changes towards an alternative shell
At least for now.  Such changes are risky (we have very many packages),
and apparently it needs more testing/review without blocking other
changes.

This reverts the whole range 4d0e3984918^..8752c327377,
except for one commit that got reverted in 6f239d7309 already.
(that MR didn't even get its merge commit)
2021-07-17 20:39:47 +02:00
Matthew Bauer f5074933b7
bintools: disable -pie when -r or -Ur are used (#128674)
* bintools: disable -pie when -r or -Ur are used

ld’s -r allows you to partially link object files. When -pie is passed with -r, though, we get:

  ld: -r and -pie may not be used together

Most build systems are intelligent enough to pass -no-pie before -r, but we might as well support those that
don’t.

Note: -pie is not enabled by default in Nixpkgs, but it is when you are using musl. So this solution is really
only useful for musl toolchains.

* bintools-wrapper: Add incremental -i check for pie
2021-07-15 20:08:33 -05:00
happysalada 6d52db43d4 setup-hook.sh: use eval for dynamic variable export 2021-07-06 09:27:18 +09:00
github-actions[bot] 5b7fbb07b8
Merge staging-next into staging 2021-06-07 18:48:37 +00:00
Alyssa Ross 1dcba17714
wrapBintoolsWith: fix final stage NetBSD
Fixes "bintools" on NetBSD -- without this only the version in stdenv
would work, not the one from the final stage.

Andi tried to warn me about this[1].  Andi, I'm sorry for doubting you.

[1]: https://github.com/NixOS/nixpkgs/pull/124499#discussion_r641949801
2021-06-07 11:49:31 +00:00
github-actions[bot] abef57f931
Merge staging-next into staging 2021-05-31 19:44:15 +00:00
Alyssa Ross 35a0e15ff6 bintools: fix dynamic linker for NetBSD cross
This will fail with an assertion error on native NetBSD, but it
wouldn't have worked anyway.  We can fix that later.
2021-05-31 14:59:14 +00:00
John Ericson 603f80066e bintools-wrapper: Add sharedLibraryLoader parameter
This is used instead of `libc_lib` in case the shared library loader /
"interpreter" is not provided by the libc derivation.
2021-05-31 14:59:14 +00:00
Jörg Thalheim 602b5f8747
Update pkgs/build-support/bintools-wrapper/ld-wrapper.sh
Co-authored-by: John Ericson <git@JohnEricson.me>
2021-05-24 15:44:01 +01:00
Jörg Thalheim 166948d479 cc-wrapper: don't set rpath on static-pie executables 2021-05-23 17:38:17 +00:00
Andrew Childs 772b66531a darwin: wrap strip and install_name_tool to codesign modified files
Co-authored-by: Moritz Angermann <moritz.angermann@gmail.com>
2021-05-17 00:27:02 +09:00
Andrew Childs 15637fe621 bintools-wrapper: support post linker hooks 2021-05-17 00:27:01 +09:00
Andrew Childs 6ee72dd5ab bintools-wrapper: ensure roles are set before mangling variables 2021-04-11 10:27:16 +09:00
Andrew Childs 6c4ce7960e bintools-wrapper, cc-wrapper: parameterize darwin min version variable
These variables are the ones that the standard toolchain uses, so we
should use those and not always use MACOSX_DEPLOYMENT_TARGET.

See 236a426c12/cctools/ld64/src/ld/PlatformSupport.cpp (L54-L55)
2021-04-11 09:47:10 +09:00
Andrew Childs 2a9b3b4943 cc-wrapper, bintools-wrapper: support MACOSX_DEPLOYMENT_TARGET with roles
In a typical build environment the toolchain will use the value of the
MACOSX_DEPLOYMENT_TARGET environment variable to determine the version
of macOS to support. When cross compiling there are two distinct
toolchains, but they will look at this single environment variable. To
avoid contamination, we always set the equivalent command line flag
which effectively disables the toolchain's internal handling.

Prior to this change, the MACOSX_DEPLOYMENT_TARGET variable was
ignored, and the toolchains always used the Nix platform
definition (`darwinMinVersion`) unless overridden with command line
arguments.

This change restores support for MACOSX_DEPLOYMENT_TARGET, and adds
nix-specific MACOSX_DEPLOYMENT_TARGET_FOR_BUILD and
MACOSX_DEPLOYMENT_TARGET_FOR_TARGET for cross compilation.
2021-04-11 09:47:10 +09:00
Andrew Childs 6605fadc68 bintools-wrapper: default platform versions for darwin
Instead of always supplying flags, apply the flags as defaults. Use
clang's native flags instead of lifting the linker flags from binutils
with `-Wl,`.

If a project is using clang to drive linking, make clang do the right
thing with MACOSX_DEPLOYMENT_TARGET. This can be overridden by command
line arguments. This will cause modern clang to pass
`-platform_version 10.12 0.0.0`, since it doesn't know about the SDK
settings. Older versions of clang will pass down `-macos_version_min`
flags with no sdk version.

At the linker layer, apply a default value for anything left
ambiguous. If nothing is specified, pass a full
`-platform_version`. If only `-macos_version_min` is specified, then
lock down the sdk_version explicitly with `-sdk_version`. If a min
version and sdk version is passed, do nothing.
2021-04-11 09:47:09 +09:00
Jan Tojnar 6d1958ad2d
Merge branch 'staging-next' into staging 2021-03-04 22:16:45 +01:00
s1341 aee60bef7a android_prebuilt: Fix eval 2021-03-04 18:17:39 +00:00
Andrew Childs b26e0bac8d bintools-wrapper: set -arch on darwin 2021-03-02 17:21:08 +09:00
Ashish SHUKLA 1c39662e63
stdenv: Improve/fix FreeBSD support
Able to bootstrap stdenv on FreeBSD by compiling various dependencies
using built-in FreeBSD tools so mostly works now

Closes: https://github.com/NixOS/nixpkgs/pull/81459
2021-02-07 15:24:16 +00:00
Vladimír Čunát a648a07c19
Merge #104742: linux bootstrap tools: fix tests on ppc64 2021-01-26 08:09:59 +01:00
Ben Siraphob aa8868c7cc pkgs/build-support: stdenv.lib -> lib 2021-01-24 19:07:54 -08:00
John Ericson 9c213398b3 lib: Clean up how linux and gcc config is specified
Second attempt of 8929989614589ee3acd070a6409b2b9700c92d65; see that
commit for details.

This reverts commit 0bc275e634.
2021-01-23 10:01:28 -05:00
Jonathan Ringer 0bc275e634
Revert "lib: Clean up how linux and gcc config is specified"
This is a stdenv-rebuild, and should not be merged
into master

This reverts commit 8929989614.
2021-01-22 14:07:06 -08:00
John Ericson 8929989614 lib: Clean up how linux and gcc config is specified
The `platform` field is pointless nesting: it's just stuff that happens
to be defined together, and that should be an implementation detail.

This instead makes `linux-kernel` and `gcc` top level fields in platform
configs. They join `rustc` there [all are optional], which was put there
and not in `platform` in anticipation of a change like this.

`linux-kernel.arch` in particular also becomes `linuxArch`, to match the
other `*Arch`es.

The next step after is this to combine the *specific* machines from
`lib.systems.platforms` with `lib.systems.examples`, keeping just the
"multiplatform" ones for defaulting.
2021-01-21 22:44:09 -05:00
Jörg Thalheim 61bbbcd1af
bintools-wrapper: skip dynamic linker for static binaries 2020-12-27 16:42:11 +01:00
Vladimír Čunát 363175cd99
Revert "bintools-wrapper: skip dynamic linker for static binaries"
This reverts commit ccfd26ef14.

These toolchain changes are too problematic, so reverting for now; see
https://github.com/NixOS/nixpkgs/pull/107086#issuecomment-749196366
2020-12-21 22:27:48 +01:00
Vladimír Čunát bf444739ec
Revert "Merge #107253: bintools-wrapper: fix inverted link32 check"
This reverts commit 241c391255, reversing
changes made to ab8c2b2b2c.

These toolchain changes are too problematic, so reverting for now; see
https://github.com/NixOS/nixpkgs/pull/107086#issuecomment-749196366
2020-12-21 22:26:50 +01:00
Rouven Czerwinski eee562ffb5 bintools-wrapper: fix inverted link32 check
The new skip for the dynamic linker introduced in
ccfd26ef14 ("bintools-wrapper: skip dynamic linker for static
binaries") includes a change in behaviour, previously the $link32
variable was checked using an arithmetic expression via (( )). This
returns zero if the output of the arithmetic expression is nonzero, i.e.
link32=1 would return zero and the if condition would be executed.
The code refactored this to use "$link32" = "0" which is incorrect in
this case, since we want this if conditional to run if $link32 is 1.

Small shell excerpt for clarity:

$ export link32=1
$ export cookie=1
$ if [[ "$cookie" = "1" ]] && (( "$link32" )); then echo "do some stuff"; fi;
do some stuff
$ if [[ "$cookie" = "1" && "$link32" = "0" ]]; then echo "do some stuff"; fi;
$

Change it to check for $link32 = "1", as the previous code did.
2020-12-20 17:27:16 +01:00
Jörg Thalheim ccfd26ef14 bintools-wrapper: skip dynamic linker for static binaries
Currently we set dynamic-linker unconditionally. This breaks
however some static binaries i.e. rust binaries linked against musl.
There is no reason we should set an elf interpreter for static binaries
hence this is skipped if `-static` or `-static-pie` is either passed to
our cc or ld wrapper.
2020-12-14 15:42:54 +00:00
John Ericson 04f6973200 lib, binutils: Move Risc-V bfdEmulation to be by the others 2020-11-29 00:03:51 +00:00
Ryan Burns 9682c1d0da linux bootstrap tools: fix tests on ppc64
The dynamic loader on powerpc64 is called ld64.so.2 rather than
ld-linux.so.*, and was not matched by the existing pattern.

We reuse the dynamicLinker name from binutils to match a wider set
of platforms and to avoid specifying this information in two places.
2020-11-24 18:32:12 -08:00
Frederik Rietdijk da12fc6838 Merge staging-next into staging 2020-11-18 15:36:56 +01:00
Frederik Rietdijk 986c2d36da Merge master into staging-next 2020-11-16 09:01:53 +01:00
zowoq 473b341fb1 bintools-wrapper: remove redundant arg
cctools 949.0.1 warns if min version is passed twice.
2020-11-14 07:11:29 +10:00
Samuel Dionne-Riel 6d8327ea96 Initial support for OpenRISC 1000 (or1k) 2020-11-09 22:32:11 -05:00
Ben Siraphob 445dde6304 Initial implementation of mmix cross-compile 2020-11-09 19:49:55 +07:00
Frederik Rietdijk e560459c5b Revert "utils.bash: revert #93560 for darwin, unblocks channels"
Revert the hack and the original faulty commit.

This reverts commit 48264ee506105a2f5e61e5d327599e9f301bd77f.

Revert "Purity checking should accept $TMP and not just /tmp"

This reverts commit fb777be7d2.
2020-09-06 18:16:14 +02:00