about summary refs log tree commit diff
path: root/pkgs/build-support/cc-wrapper
AgeCommit message (Collapse)AuthorFilesLines
2023-04-10julia{18,19,}: fix build by a temporary hackVladimír Čunát1-1/+6
This is a low-rebuild version of PR #225273 /cc the proper and hopefully complete fix in PR #225220
2023-04-04Merge #169327: cc-wrapper: fix minor problemsVladimír Čunát1-0/+2
...into staging
2023-04-03Merge pull request #209870 from ↵Bernardo Meurer1-3/+39
amjoseph-nixpkgs/pr/stdenv/external-gcc-bootstrap
2023-04-02stdenv: Nix-driven bootstrap of gccAdam Joseph1-2/+33
#### Summary By default, when you type `make`, GCC will compile itself three times. This PR inhibits that behavior by configuring GCC with `--disable-bootstrap`, and reimplements the triple-rebuild using Nix rather than `make`/`sh`. #### Immediate Benefits - Allow `gcc11` and `gcc12` on `aarch64` (without needing new `bootstrapFiles`) - Faster stdenv rebuilds: the third compilation of gcc (i.e. stageCompare) is no longer a `drvInput` of the final stdenv. This allows Nix to build stageCompare in parallel with the rest of nixpkgs instead of in series. - No more copying `libgcc_s` out of the bootstrap-files or other derivations - No more Frankenstein compiler: the final gcc and the libraries it links against (mpfr, mpc, isl, glibc) are all built by the same compiler (xgcc) instead of a mixture of the bootstrapFiles' compiler and xgcc. - No more [static lib{mpfr,mpc,gmp,isl}.a hack] - Many other small `stdenv` hacks eliminated - `gcc` and `clang` share the same codepath for more of `cc-wrapper`. #### Future Benefits - This should allow using a [foreign] `bootstrap-files` so long as `hostPlatform.canExecute bootstrapFiles`. - This should allow each of the libraries that ship with `gcc` (lib{backtrace, atomic, cc1, decnumber, ffi, gomp, iberty, offloadatomic, quadmath, sanitizer, ssp, stdc++-v3, vtv}) to be built in separate (one-liner) derivations which `inherit src;` from `gcc`, much like https://github.com/NixOS/nixpkgs/pull/132343 #### Incorporates - https://github.com/NixOS/nixpkgs/pull/210004 - https://github.com/NixOS/nixpkgs/pull/36948 (unreverted) - https://github.com/NixOS/nixpkgs/pull/210325 - https://github.com/NixOS/nixpkgs/pull/210118 - https://github.com/NixOS/nixpkgs/pull/210132 - https://github.com/NixOS/nixpkgs/pull/210109 - https://github.com/NixOS/nixpkgs/pull/213909 - https://github.com/NixOS/nixpkgs/pull/216136 - https://github.com/NixOS/nixpkgs/pull/216237 - https://github.com/NixOS/nixpkgs/pull/210019 - https://github.com/NixOS/nixpkgs/pull/216232 - https://github.com/NixOS/nixpkgs/pull/216016 - https://github.com/NixOS/nixpkgs/pull/217977 - https://github.com/NixOS/nixpkgs/pull/217995 #### Closes - Closes #108305 - Closes #108111 - Closes #201254 - Closes #208412 #### Credits This project was made possible by three important insights, none of which were mine: 1. @ericson2314 was the first to advocate for this change, and probably the first to appreciate its advantages. Nix-driven (external) bootstrap is "cross by default". 2. @trofi has figured out a lot about how to get gcc to not mix up the copy of `libstdc++` that it depends on with the copy that it builds, by moving the `bootstrapFiles`' `libstdc++` into a [versioned directory]. This allows a Nix-driven bootstrap of gcc without the final gcc would still having references to the `bootstrapFiles`. 3. Using the undocumented variable [`user-defined-trusted-dirs`] when building glibc. When glibc `dlopen()`s `libgcc_s.so`, it uses a completely different and totally special set of rules for finding `libgcc_s.so`. This trick is the only way we can put `libgcc_s.so` in its own separate outpath without creating circular dependencies or dependencies on the bootstrapFiles. I would never have guessed to use this (or that it existed!) if it were not for a [comment in guix] which @Mic92 [mentioned]. My own role in this PR was basically: being available to go on a coding binge at an opportune moment, so we wouldn't waste a [crisis]. [aarch64-compare-ofborg]: https://github.com/NixOS/nixpkgs/pull/209870/checks?check_run_id=10662822938 [amd64-compare-ofborg]: https://github.com/NixOS/nixpkgs/pull/209870/checks?check_run_id=10662825857 [nonexistent sysroot]: https://github.com/NixOS/nixpkgs/pull/210004 [versioned directory]: https://github.com/NixOS/nixpkgs/pull/209054 [`user-defined-trusted-dirs`]: https://sourceware.org/legacy-ml/libc-help/2013-11/msg00026.html [comment in guix]: https://github.com/guix-mirror/guix/blob/5e4ec8218142eee8e6e148e787381a5ef891c5b1/gnu/packages/gcc.scm#L253 [mentioned]: https://github.com/NixOS/nixpkgs/pull/210112#issuecomment-1379608483 [crisis]: https://github.com/NixOS/nixpkgs/issues/108305 [foreign]: https://github.com/NixOS/nixpkgs/pull/170857#issuecomment-1170558348 [static lib{mpfr,mpc,gmp,isl}.a hack]: https://github.com/NixOS/nixpkgs/blob/2f1948af9c984ebb82dfd618e67dc949755823e2/pkgs/stdenv/linux/default.nix#L380
2023-04-02cc-wrapper: if isClang, add -L${gccForLibs.libgcc}/libAdam Joseph1-1/+6
When wrapping `clang` and using a `gccForLibs` whose `libgcc` is in its own output (rather than the `lib` output), this commit will adds `-L${gccForLibs.libgcc}/lib` to `cc-ldflags`. If that flag is not added, `firefox` will fail to compile because it invokes `clang-wrapper` with `-fuse-ld=lld` and passes `-lgcc_s` to `lld`, but does not tell `lld` where to find `libgcc_s.so`. In that situation, firefox will fail to link.
2023-03-17cc-wrapper: make $tool-prefixed `cpp` wrapping unconditionalSergei Trofimovich1-5/+3
2023-03-17cc-wrapper: wrap `cpp` for cross lust like to nativeSergei Trofimovich1-0/+4
Without this change $target-cpp is used unwrapped and is missing standard header search paths among other things). Example failure: $ nix build -f. -L pkgsStatic.netbsd.compat ... > checking how to run the C preprocessor... x86_64-unknown-linux-musl-cpp > configure: error: in `/build/cvs-export/tools/compat': > configure: error: C preprocessor "x86_64-unknown-linux-musl-cpp" fails sanity check > See `config.log' for more details
2023-02-21Merge pull request #216232 from amjoseph-nixpkgs/pr/cc-wrapper/useCcForLibsSergei Trofimovich1-2/+4
cc-wrapper: allow non-clang compilers to use gccForLibs codepath
2023-02-20cc-wrapper: allow non-clang compilers to use gccForLibs codepathAdam Joseph1-2/+4
cc-wrapper has essentially two separate codepaths: the `gccForLibs` codepath, used only by non-gcc (i.e. clang) compilers, and the "other" codepath. This PR allows non-clang compilers to opt-in to the `gccForLibs` codepath (off by default). To allow this, a new parameter `ccForLibs` is exposed, since it would be extremely confusing for gcc to be able to use `gccForLibs` but not do so by default.
2023-02-21cc-wrapper: fix inverted logic around fortify & fortify3 mutual exclusionRobert Scott1-1/+1
2023-02-16Merge pull request #212498 from risicle/ris-fortify3Robert Scott1-3/+24
hardening flags: add `FORTIFY_SOURCE=3` support
2023-02-13treewide: use optionalStringFelix Buehler1-3/+1
2023-01-31cc-wrapper: revert change to `-isystem`wrvsrx1-3/+3
2023-01-31cc-wrapper: add -cxx-isystem to libcxx-cxxflags instead of libc-cflagswrvsrx1-3/+3
2023-01-31cc-wrapper: add the '-xc++' and `-x*-header` case to the wrapperwrvsrx1-0/+2
2023-01-31cc-wrapper: replace "-isystem" by "-cxx-isystem" for c++ headerwrvsrx1-3/+3
2023-01-29build-support/cc-wrapper: revert "pass in non-existent --sysroot= to ↵Sergei Trofimovich1-7/+0
untangle from libc" This reverts commit 8c80bd08b7e39229947d55104d1871f5066437d9 ("build-support/cc-wrapper: pass in non-existent --sysroot= to untangle from libc"). This change was good in spirit: we caught a few genuine problems with `scons` based packages (`godot`, `fluxus`) and unexpected `-idirafter` includes in various boot loadres (`ipxe`, wimboot`): https://github.com/NixOS/nixpkgs/pull/210004#issuecomment-1407162693 Unfortunately `--sysroot=` also has a negative impact on libary search order for DT_NEEDED libraries and RUNPATHs of linked libraries. This unexpectedly broke `dmd`, `d-seams`, `llvmPackages_rocm.compiler-rt`). An interesting case of unexpected breakage is `usbmuxd2` where the bug exposed incomplete library move on `libstdc++fs` in `gcc`. The library breakage is very non-intuitive (on top of already unusual layout of `cc-wrapper` driver). Let's revert this change for now. Once it lands we can undo `--sysroot=/` workarounds merged for `staging-next`.
2023-01-28build-support/cc-wrapper: add libstdc++fs into default library path for clangSergei Trofimovich1-0/+5
After https://github.com/NixOS/nixpkgs/pull/210004 `usbmuxd2` started failing to build as: usbmuxd2-unstable> .../ld: cannot find -lstdc++fs: No such file or directory usbmuxd2-unstable> clang-11: error: linker command failed with exit code 1 (use -v to see invocation) This started happening because #210004 exposed a long-standing bug in `gcc` derivation: `cc.lib` is missing `libstdc++fs` library: $ find $(nix-build --no-link -A stdenv.cc.cc.lib) | fgrep libstdc | unnix /<<NIX>>/gcc-11.3.0-lib/lib/libstdc++fs.la /<<NIX>>/gcc-11.3.0-lib/lib/libstdc++.la /<<NIX>>/gcc-11.3.0-lib/lib/libstdc++.so.6.0.29 /<<NIX>>/gcc-11.3.0-lib/lib/libstdc++.so /<<NIX>>/gcc-11.3.0-lib/lib/libstdc++.so.6 It was not moved from `cc.out` output: $ find $(nix-build --no-link -A stdenv.cc.cc) | fgrep libstdc | unnix /<<NIX>>/gcc-11.3.0/lib/libstdc++.a /<<NIX>>/gcc-11.3.0/lib/libstdc++fs.a This change adds `cc` library lookup path back to `staging-next` until `gcc` is fixed.`
2023-01-25Merge master into staging-nextgithub-actions[bot]1-3/+3
2023-01-24cc-wrapper: add support for fortify3 flagRobert Scott1-3/+24
2023-01-24llvmPackages: use libcxxrt on FreeBSDAlyssa Ross1-3/+3
FreeBSD doesn't use LLVM's cxxabi implementation, for backwards compatibility reasons. Software expects the libcxxrt API when building on FreeBSD. This fixes the build of pkgsCross.x86_64-freebsd.boost.
2023-01-20Merge remote-tracking branch 'origin/staging-next' into stagingSergei Trofimovich2-0/+12
Conflicts: pkgs/development/libraries/qt-6/modules/qtbase.nix pkgs/stdenv/linux/make-bootstrap-tools.nix
2023-01-20gccgo: wrap go binary (#207670)Yureka2-0/+12
2023-01-14Merge remote-tracking branch 'origin/staging-next' into stagingSergei Trofimovich3-17/+64
Conflicts: pkgs/development/libraries/audio/roc-toolkit/default.nix
2023-01-14Merge pull request #210004 from trofi/cc-fake-sysrootSergei Trofimovich1-0/+7
build-support/cc-wrapper: pass in non-existent --sysroot= to untangle…
2023-01-13Merge master into staging-nextgithub-actions[bot]3-17/+64
2023-01-13Merge #209423: gnat12: add for x86_64-darwinVladimír Čunát3-17/+64
2023-01-11Merge remote-tracking branch 'origin/master' into staging-nextMartin Weinelt1-2/+4
2023-01-10cc-wrapper: -march= is not allowed on powerpcAdam Joseph1-2/+4
Gcc does not allow `-march=` on PowerPC: https://gcc.gnu.org/onlinedocs/gcc-12.2.0/gcc/RS_002f6000-and-PowerPC-Options.html#RS_002f6000-and-PowerPC-Options Instead, `-mcpu=` should be used to set the minimum instruction set and `-mtune=` is used to optimize instruction scheduling for a specific processor. Both flags take the same set of valid values, which includes `native`. This commit causes `isGccArchSupported` to return `false` for PowerPC targets so we never pass an `-march=` flag, since that will always be rejected by gcc.
2023-01-10build-support/cc-wrapper: pass in non-existent --sysroot= to untangle from libcSergei Trofimovich1-0/+7
I would like to add an extra `gcc` build step during linux bootstrap (https://github.com/NixOS/nixpkgs/issues/208412). This makes it early bootstrap compiler linked and targeted against `bootstrapTools` `glibc` including it's headers. Without this change `gcc`'s spec files always prefer `bootstrapTools` `glibc` for header search path (passed in as --with-native-system-header-dir=). We'can't override it with: - `-I` option as it gets stacked before gcc-specific headers, we need to keep glibc headers after gcc as gcc cleans namespace up for C standard by using #include_next and by undefining system macros. - `-idirafter` option as it gets appended after existing `glibc`-includes This `--sysroot=/nix/store/does/not/exist` hack allows us to remove existing `glibc` headers and add new ones with `-idirafter`. We use `cc-cflags-before` instead of `libc-cflags` to allow user to define their own `--sysroot=` (like `firefox` does). To keep it working prerequisite cross-symlink in gcc.libs is required: https://github.com/NixOS/nixpkgs/pull/209153
2023-01-07cc-wrapper: Wrap/link all other GNAT commandsBoey Maun Suang2-17/+34
2023-01-07cc-wrapper: Fix gnatmake wrapperBoey Maun Suang3-1/+31
Switches that gnatmake needs to pass to gcc must be given as "-cargs <gcc_switches>" after at least the files to compile (see the gnatmake docs for all the subtleties). This commit makes that happen, in a way that triggers rebuilds only for things that actually depend on GNAT, and not the other compilers contained in GCC.
2022-12-08treewide: fix some core package structuredAttrsArtturin1-11/+8
2022-12-08allow derivation attributes in envArtturin1-6/+9
derivations can be coerced to their output paths
2022-11-30cc-wrapper: fix path to libcxx includes for cross compilersNick Cao1-2/+2
2022-10-28Merge pull request #197937 from danielbarter/cc-wrapper-hookJohn Ericson1-0/+6
cc-wrapper: adding a cc-wrapper-hook to the cc-wrapper
2022-10-28Revert "Merge #191724: cc-wrapper: remove duplicate include flags"Vladimír Čunát3-125/+1
Let's redo this later, with more testing and less bugs. This reverts commits 4f6e99870b6f05 and d700d8e8a264.
2022-10-26cc-wrapper: adding a cc-wrapper-hook to the cc-wrapperDaniel Barter1-0/+6
2022-10-16Merge pull request #191134 from Et7f3/remove-duplicate-code-cc-wrapperSergei Trofimovich1-2/+0
cc-wrapper: remove duplicate C{C,XX}${role_post}
2022-10-14stdenv cc-wrapper: revert a problematic change for non-LinuxVladimír Čunát2-1/+123
The change from 0bea4a194f71 (PR #191724) broke stdenv bootstap on *-darwin, and I didn't want to drop the *-linux binaries that we have already.
2022-10-08Merge pull request #193871 from trofi/FORTIFY-unset-and-setSergei Trofimovich1-1/+3
cc-wrapper/add-hardening.sh: always unset _FORTIFY_SOURCE before re-s…
2022-10-05Merge #191724: cc-wrapper: remove duplicate include flagsVladimír Čunát1-0/+2
...into staging
2022-10-01cc-wrapper/add-hardening.sh: always unset _FORTIFY_SOURCE before re-setting itSergei Trofimovich1-1/+3
On darwin clang driver always sets -D_FORTIFY_SOURCE=0 under asan. This causes -Werror to trip over macro redefinition: <command line>:1:9: error: '_FORTIFY_SOURCE' macro redefined [-Werror,-Wmacro-redefined] #define _FORTIFY_SOURCE 2 ^ To avoid it let's always explicitly undefine it first before redefining.
2022-09-28cc-wrapper/setup-hook.sh: remove duplicate flags in NIX_CFLAGS_COMPILEDaniel Barter1-0/+2
2022-09-26Add `stdenv.cc.libcxx` to detect the standard C++ libraryYang, Bo1-1/+1
2022-09-22cc-wrapper: fix linking against GCC libs for non-GCCDaniel Fullmer1-1/+3
Currently, clang++ statically links against libstdc++ instead of dynamically links, because the -L path included in the cc-wrapper is incorrect. The gccForLibs.lib output only contains the architecture subdirectory if the target and host platform are not the same. (See targetConfig set in gcc/<version>/default.nix and the gcc/builder.nix) This fixes the incorrect linking by using the correct path for both the cross and native cases. This also matches the cc_solib set above in cc-wrapper/default.nix Tested by compiling a simple cpp binary and noting that it now correctly dynamically links against libstdc++, natively on x86_64 and arm64, as well as x86_64 -> arm64 cross compilation. Co-Authored-By: Sebastian Ullrich <sebasti@nullri.ch>
2022-09-20cc-wrapper: comment explaining C++ stdlib orderTheodore Ni1-0/+25
There is context here that I needed when resolving an issue in which libc was added to NIX_CFLAGS_COMPILE before the C++ stdlib that took me awhile to understand. It was suggested to me that this context be included as a comment, since it is not obvious and could help others in the future.
2022-09-14cc-wrapper: remove duplicate C{C,XX}${role_post}Et7f31-2/+0
This might be typo but I don't know which other variable was intended to be named. This can also come from a merge conflict.
2022-08-25Merge staging-next into staginggithub-actions[bot]1-0/+2
2022-08-25cc-wrapper: disable stackprotector for MicroBlazeMinijackson1-0/+2
This option doesn't seem to be supported in the cross-compiler