summaryrefslogtreecommitdiff
path: root/pkgs/build-support/bintools-wrapper (follow)
Commit message (Expand)AuthorAgeFilesLines
* Merge remote-tracking branch 'upstream/master' into openbsd-staticJohn Ericson2024-07-091-0/+1
|\
| * stdenv: promote zerocallusedregs to defaultHardeningFlagsRobert Scott2024-06-021-0/+1
* | openbsd: Add static linking support•••I've had better luck creating statically-linked binaries that work than dynamically-linked ones, so this is needed quite practically. John Ericson2024-07-091-10/+14
* | Revert #320852: Clean up cross bootstrapping•••It rebuilt stdenv on *-darwin; we can't do that in nixpkgs master. This reverts commit 2f20501c5f188ab0c4c430519ce77bc6b988202b, reversing changes made to fd469c24af2e16aad2c2b4fc90fc8c74af36e773. Vladimír Čunát2024-06-211-4/+4
* | Clean up cross bootstrapping•••For a long time, we've had `crossLibcStdenv`, `*Cross` libc attributes, and `*bsdCross` pre-libc package sets. This was always bad because having "cross" things is "not declarative": the naming doesn't reflect what packages *need* but rather how we *provide* something. This is ugly, and creates needless friction between cross and native building. Now, almost all of these `*Cross` attributes are gone: just these are kept: - Glibc's and Musl's are kept, because those packages are widely used and I didn't want to risk changing the native builds of those at this time. - generic `libcCross`, `theadsCross`, and friends, because these relate to the convolulted GCC bootstrap which still needs to be redone. The BSD and obscure Linux or freestnanding libcs have conversely all been made to use a new `stdenvNoLibc`, which is like the old `crossLibcStdenv` except: 1. It usable for native and cross alike 2. It named according to what it *is* ("a standard environment without libc but with a C compiler"), rather than some non-compositional jargon ("the stdenv used for building libc when cross compiling", yuck). I should have done this change long ago, but I was stymied because of "infinite recursions". The problem was that in too many cases we are overriding `stdenv` to *remove* things we don't need, and this risks cyles since those more minimal stdenvs are used to build things in the more maximal stdenvs. The solution is to pass `stage.nix` `stdenvNoCC`, so we can override to *build up* rather than *tear down*. For now, the full `stdenv` is also passed, so I don't need to change the native bootstraps, but I can see this changing as we make things more uniform and clean those up. Finally, the BSDs also had to be cleaned up, since they have a few pre-libc dependencies, demanding a systematic approach. I realized what rhelmot did in 61202561d92cf1cd74532fcbd8b9d6662c5bc57b (specify what packages just need `stdenvNoLibc`) is definitely the right approach for this, and adjusted NetBSD and OpenBSD to likewise use it. John Ericson2024-06-181-4/+4
|/
* bintools: Add dynamic loader path for FreeBSD nativeAudrey Dutcher2024-05-211-1/+1
* bintools: Add an assertion which produces better error messagesAudrey Dutcher2024-05-211-0/+1
* wrapCC, wrapBintools: move expand-response-params bootstrapping out•••The cc and bintools wrapper contained ad hoc bootstrapping logic for expand-response-params (which was callPackage-ed in a let binding). This lead to the strange situation that the bootstrapping logic related to expand-response-params is split between the wrapper derivations (where it is duplicated) and the actual stdenv bootstrapping. To clean this up, the wrappers simply should take expand-response-params as an ordinary input: They need an adjacent expand-response-params (i.e. one that runs on their host platform), but don't care about the how. Providing this is only problematic during stdenv bootstrapping where we have to pull it from the previous stage at times. sternenseemann2024-04-181-5/+2
* wrapCC, wrapBintools: use runtimeShell instead of stdenv shell•••We don't need to artificially make sure that we can execute the wrapper scripts on the build platform by using stdenv's shell (which comes from buildPackages) since our cross infrastructure will get us the wrapper from buildPackages. The upside of this change is that cross-compiled wrappers (e.g. pkgsCross.aarch64-multiplatform.gcc) will actually work when executed! For bootstrapping this is also not a problem, since we have a long build->build platform chain so runtimeShell is just as good as stdenvNoCC.shell. We do fall back to old ways, though, by explicitly using the bootstrap-tools shell in stage2, so the adjacent bash is only used from stage4 onwards. This is unnecessary in principle (I'll try removing this hack in the future), but ensures this change causes zero rebuilds. sternenseemann2024-04-181-2/+4
* wrapCC, wrapBintools: remove unnecessary indexing into platform sets•••`targetPlatform` and `hostPlatform` are already in scope, so it is unnecessary to index into `stdenvNoCC`. sternenseemann2024-04-151-4/+4
* wrapCC, wrapBintools: don't alias stdenvNoCC to stdenv•••In delicate code like this, it seems unwise to pass something of as something it isn't for convenience's (?) sake. It causes a slight possibility for confusion with `buildPackages.stdenv`. However, it should be possible to eliminate the need for this in a separate change. sternenseemann2024-04-151-7/+6
* Avoid top-level `with ...;` in pkgs/build-support/bintools-wrapper/default.nixPhilip Taron2024-03-191-25/+40
* Revert "avrlibc: hook up libdir for cc-wrapper"•••This reverts commit b2844f89d10d4a2665aed231144950c354f275a6. It broke simavr: $ nix-build -A simavr [...] /nix/store/3k4djrsq23m2yg9ar4h1lkkz1ijv0ghv-avr-binutils-2.41/bin/avr-ld: /nix/store/3rpyzla18mbj690hv7j5dang0kd3c1fq-avr-libc-avr-2.1.0/avr/lib/libc.a(vfprintf_std.o): in function `.L15': vfprintf.c:(.text.avr-libc+0xd8): undefined reference to `__mulqi3' /nix/store/3k4djrsq23m2yg9ar4h1lkkz1ijv0ghv-avr-binutils-2.41/bin/avr-ld: /nix/store/3rpyzla18mbj690hv7j5dang0kd3c1fq-avr-libc-avr-2.1.0/avr/lib/libc.a(vfprintf_std.o): in function `.L18': vfprintf.c:(.text.avr-libc+0xe4): undefined reference to `__mulqi3' collect2: error: ld returned 1 exit status make[1]: *** [../Makefile.common:161: atmega644_adc_test.axf] Error 1 make[1]: Leaving directory '/build/source/tests' make: *** [Makefile:21: build-tests] Error 2 Fixes #295610. Bjørn Forsman2024-03-141-0/+6
* bintools: disable relro/bindnow hardening on windowsWeijia Wang2024-01-121-1/+1
* bintools-wrapper: fix static check platform•••This was moved in https://github.com/nixOS/nixpkgs/commit/1a5bd697adecf27385b69352485baa52a6e02fe9, the preceding check was updated from hostPlatform to targetPlatform, but these got missed. K9002024-01-061-1/+1
* mkDerivation, bintools-wrapper: move defaultHardeningFlags determination to b...•••this makes it a lot easier to create a modified stdenv with a different set of defaultHardeningFlags and as a bonus allows us to inject the correct defaultHardeningFlags into toolchain wrapper scripts, reducing repetition. while most hardening flags are arguably more of a compiler thing, it works better to put them in bintools-wrapper because cc-wrapper can easily refer to bintools but not vice-versa. mkDerivation can still easily refer to either when it is constructed. this also switches fortran-hook.sh to use the same defaults for NIX_HARDENING_ENABLE as for C. previously NIX_HARDENING_ENABLE defaults were apparently used to avoid passing problematic flags to a fortran compiler, but this falls apart as soon as mkDerivation sets its own NIX_HARDENING_ENABLE - cc.hardeningUnsupportedFlags is a more appropriate mechanism for this as it actively filters out flags from being used by the wrapper, so switch to using that instead. this is still an imperfect mechanism because it doesn't handle a compiler which has both langFortran *and* langC very well - applying the superset of the two's hardeningUnsupportedFlags to either compiler's invocation. however this is nothing new - cc-wrapper already poorly handles a langFortran+langC compiler, applying two setup hooks that have contradictory options. Robert Scott2023-12-092-1/+26
* Merge remote-tracking branch 'origin/master' into staging-next•••Fixed conflict in pkgs/applications/graphics/krita/ krita: 5.1.5 -> 5.2.0 7a40fdc288e69ba94947c1c4ec29c0f24e461eef , and treewide: use kde mirror everywhere, don't use pname in download urls aa15f5066d695de4c4027bd8bdcf4cedcf58d058 Fabián Heredia Montiel2023-12-041-6/+0
|\
| * avrlibc: hook up libdir for cc-wrapper•••-B must be set to the root directory of avrlibc, otherwise gcc cannot locate crt objects for some attiny devices. -L trains as set by bintools-wrapper are not necessary with -B set correctly because gcc takes care of that, and likewise we can drop the -B train from cc-wrapper because the one spec is enough. pennae2023-12-031-6/+0
* | Merge pull request #188347 from zhaofengli/darwin-uuidBernardo Meurer2023-11-301-2/+2
|\ \ | |/ |/|
| * bintools-wrapper: Set ZERO_AR_DATE and re-enable LC_UUID on Darwin•••The LC_UUID is a hash over the output file contents. Zhaofeng Li2022-08-251-2/+2
* | bintools-wrapper: fix dynamic linker for powerpc64 big-endian•••fixes #245162 Minijackson2023-09-111-1/+2
* | Merge pull request #239624 from Stunkymonkey/use-optionalString-then•••treewide: use optionalString instead of 'then ""'Felix Bühler2023-07-221-8/+8
|\ \
| * | treewide: use optionalString instead of 'then ""'Felix Buehler2023-06-241-8/+8
* | | Merge pull request #239331 from pwaller/fix-pie-hardeningArtturi2023-07-061-5/+5
|\ \ \
| * | | build-support: Use response-expanded params in pie test•••When a response file is in use, "$*" contains the response file and not the parameters; both the linker and compiler wrappers are updated to use the response-expanded params. The compiler driver likes to pass parameters to the linker via a response file, including -shared. LLD rejects the combination of (-shared -pie), whereas other linkers silently ignore the contradiction: ``` ld.lld: error: -shared and -pie may not be used together ``` This breaks certain configurations using LLD as a linker. Changing `add-hardening.sh` results in a full rebuild. To avoid the rebuild, here is a quick test case which shows the new hardening script allows the link to succeed: ``` { pkgs ? import <nixpkgs> {} }: let # gcc silently accepts -shared -pie together, lld does not. linker = pkgs.wrapBintoolsWith { bintools = pkgs.llvmPackages.lld; }; patchWrapper = prev: prev.overrideAttrs (final: prev: let prevScript = builtins.match (".*(/nix/store/[a-z0-9]+-add-hardening.sh).*") prev.postFixup; in { postFixup = (builtins.replaceStrings prevScript ["${./new-add-hardening.sh}"] prev.postFixup); }); in pkgs.stdenv.mkDerivation { name = "nixpkgs-hardening-bug"; src = pkgs.writeText "src.c" "int main(int argc, char* argv[]) { return 0; }"; NIX_HARDENING_ENABLE = "pie"; unpackPhase = ":"; buildPhase = '' $CC -c -o src.o $src bash -x ${patchWrapper linker}/bin/ld.lld -o $out @${pkgs.writeText "responsefile" "-shared"} src.o ''; } ``` Fixes: #178162 Signed-off-by: Peter Waller <p@pwaller.net> Peter Waller2023-06-231-5/+5
| |/ /
* / / treewide: use optionalAttrs instead of 'else {}'Felix Buehler2023-06-251-2/+2
|/ /
* | wrapBintoolsWith: support LINK.EXE-style args in purity checks•••LLD supports Windows-style linker arguments, but these previously triggered purity check false positives, because it saw that they started with a '/' and assumed they were paths. This tweaks the path detection to allow through certain values that could be paths, but are much more likely to be LINK.EXE-style flags. The risk of false negatives here is low — the only things we'd now fail to catch would be attempts to link with libraries in the root directory, which doesn't happen in practice. We also teach the wrapper how to apply its purity checks to library paths specified with the /LIBPATH: option. Tested that paths we expect to be rejected (like /lib/libfoo.so) still are. Alyssa Ross2023-04-291-4/+6
* | Merge pull request #227560 from jackyliu16/loongnix-commit•••lib.platforms.loongarch64: initWeijia Wang2023-04-281-0/+1
|\ \
| * | bintools: set dynamic linkerjackyliu162023-04-281-0/+1
* | | gnatboot: rename to gnat-bootstrap•••Most other bootstrap compilers are named -bootstrap so lets follow that pattern. Manuel Mendez2023-04-151-1/+1
* | | Merge pull request #216992 from SuperSandro2000/stdenvNative-fix-eval•••{bintools,cc}-wrapper: don't fallback to version = null Sandro2023-04-141-1/+1
|\ \ \ | |/ / |/| |
| * | {bintools,cc}-wrapper: don't fallback to version = null•••mkDerivation cannot handle that Sandro Jäckel2023-04-121-1/+1
* | | bintools-wrapper: specify SHA1 as the `build-id` hash style explicitly•••NixOS/nixpkgs#146275 has more discussion on this; the abridged version is that `lld` defaults to using `--build-id=fast` while GNU `ld` defaults to `--build-id=sha1`. These differ in length and so `separate-debug-info.sh`, as of this writing, errors on `lld`'s shorter `--build-id=fast`-generated hashes. `lld` offers the following `build-id` styles: - UUID (random; fast but bad for reproducibility) - fast (xxhash; fast but shorter hashes) - user provided hexstring - SHA1 - MD5 GNU `ld` supports the latter three options, `mold` supports all of these plus SHA256. UUID is out because it's not reproducible, fast isn't supported by GNU `ld` Using a nix provided (sourced from the output base hash) hash as the `build-id` seems tempting but would require a little extra work (we have to include some characteristic of the binary being hashed so that binaries within a derivation still have unique hashes; it seems easy to get this wrong; i.e. a path based approach would make two otherwise identical binaries that reside at different paths have different `build-id` hashes) That leaves SHA1 and MD5 and GNU `ld` already defaults to the former. This commit adds `$NIX_BUILD_ID_STYLE` as an escape hatch, in case any packages have strong opinions about which hash to use. ---- Note that if/when NixOS/nixpkgs#146275 goes through, this change can be reverted if linker speed is a priority. Rahul Butani2023-02-251-1/+4
* | | bintools: Add response file support to `ld-wrapper` (#213831)•••The motivation behind this is to alleviate the problem described in https://github.com/NixOS/nixpkgs/issues/41340. I'm not sure if this completely fixes the problem, but it eliminates one more area where we can exceed command line length limits. This is essentially the same change as in #112449, except for `ld-wrapper.sh` instead of `cc-wrapper.sh`. However, that change alone was not enough; on macOS the `ld` provided by `darwin.cctools` fails if you use process substitution to generate the response file, so I put up a PR to fix that: https://github.com/tpoechtrager/cctools-port/pull/131 … and I included a patch referencing that fix so that the new `ld-wrapper` still works on macOS.Gabriella Gonzalez2023-02-232-5/+16
* | | Merge pull request #216383 from Artturin/bintoolswrappermold••• Artturi2023-02-171-5/+6
|\ \ \ | |/ / |/| |
| * | bintools-wrapper: dont wrap ld if it doesn't exist•••not all linkers have a ld binary in bin also note the '${ld:-}' which allows users to set the ld path with a env var > '${foo:-val}' $foo, or val if unset (or null) Artturin2023-02-171-1/+3
| * | bintools-wrapper: wrap all 'ld.*'•••allows using wrapBintoolsWith with all linkers ``` $ nix build ".#binutils" $ ls ./result/bin/ld* ./result/bin/ld* ./result/bin/ld.bfd* ./result/bin/ld.gold* $ nix build "nixpkgs#binutils" $ ls ./result/bin/ld* ./result/bin/ld* ./result/bin/ld.bfd* ./result/bin/ld.gold* ``` Artturin2023-02-151-4/+3
* | | treewide: use optionalStringFelix Buehler2023-02-131-3/+2
|/ /
* | bintools: add isGNU and isLLVM attributesAlyssa Ross2023-01-201-1/+2
* | Merge master into staging-nextgithub-actions[bot]2023-01-131-0/+13
|\ \
| * | bintoolsDualAs: Add package•••For reasons explained in the commit contents, in order to build the native gnat package for x86_64-darwin, the native gnatboot package for x86_64-darwin must have access to both the Clang integrated assembler and the cctools GNU assembler for that platform. This commit creates a package with both of those assemblers that x86_64-darwin gnatboot can then be wrapped with. Boey Maun Suang2023-01-071-0/+13
* | | treewide: fix some core package structuredAttrsArtturin2022-12-081-8/+6
* | | allow derivation attributes in env•••derivations can be coerced to their output paths Artturin2022-12-081-9/+9
* | | stdenv: support opt-in __structuredAttrs•••Co-authored-by: Robin Gloster <mail@glob.in> stdenv: print message if structuredAttrs is enabled stdenv: add _append reduces the chance of a user doing it wrong fix nix develop issue output hooks don't work yet in nix develop though making $outputs be the same on non-structuredAttrs and structuredAttrs is too much trouble. lets instead make a function that gets the output names reading environment file '/nix/store/2x7m69a2sm2kh0r6v0q5s9z1dh41m4xf-xz-5.2.5-env-bin' nix: src/nix/develop.cc:299: std::string Common::makeRcScript(nix::ref<nix::Store>, const BuildEnvironment&, const Path&): Assertion `outputs != buildEnvironment.vars.end()' failed. use a function to get all output names instead of using $outputs copy env functionality from https://github.com/NixOS/nixpkgs/pull/76732/commits Artturin2022-12-081-2/+2
|/ /
* | bintools-wrapper: add dlltool, dllwrap, windmc, and windresZane van Iperen2022-12-031-1/+2
* | build-support: Use equivalent valid exit code•••`exit -1` is equivalent to `exit 255`, since Bash does modulo 256 on the number. As per ShellCheck: > SC2242 (error): Can only exit with status 0-255. Other data should be > written to stdout/stderr. Victor Engmark2022-11-291-1/+1
|/
* bintools-wrapper, cc-wrapper: avoid invalid export of 'expand-response-params'•••POSIX sh (and `bash`) impose a restriction on environment variable name format and disallow hypheps in the names. Normally it's not a problem as nothing usually tries to refer nyphenated names. One exception is `nix develop` (https://github.com/NixOS/nix/issues/6848): $ nix develop -f. gcc -L gcc-wrapper> ...-get-env.sh: line 70: expand-response-params: bad substitution Note that bash usually uses explicitly created `expandResponseParams` variant of the same variable. To work the problem around let's avoid environment variable export and move it to `passthru` for `cc` (used ina few places) and remove it completely for `binutils` (does not seem to be used at all). Sergei Trofimovich2022-07-311-1/+1
* Merge master into staging-nextgithub-actions[bot]2022-07-301-0/+1
|\
| * Merge pull request #183415 from dramforever/uclibc-dyld•••bintools-wrapper: Add dynamicLinker for uClibcSergei Trofimovich2022-07-301-0/+1
| |\
| | * bintools-wrapper: Add dynamicLinker for uClibcdramforever2022-07-291-0/+1