nixpkgs/pkgs/development/compilers/gcc/patches
Sergei Trofimovich 537176760c gcc12, gcc13: always mangle __FILE__ into invalid store path
Without the change `__FILE__` used in static inline functions in headers
embed paths to header files into executable images. For local headers
it's not a problem, but for headers in `/nix/store` this causes `-dev`
inputs to be retained in runtime closure.

Typical examples are `nix` -> `nlonhmann_json` and `pipewire` ->
`lttng-ust.dev`.

Ideally we would like to use `-fmacro-prefix-map=` feature of `gcc` as:

  -fmacro-prefix-map=/nix/store/$hash1-nlohmann-json-ver=/nix/store/eeee.eee-nlohmann-json-ver
  -fmacro-prefix-map=/nix/...

In practice it quickly exhausts argument lengtth limit due to `gcc`
deficiency: https://gcc.gnu.org/PR111527

Until it;s fixed let's hardcode header mangling if $NIX_STORE variable
is present in the environment.

Tested as:

    $ printf "# 0 \"/nix/store/01234567890123456789012345678901-pppppp-vvvvvvv\" \nconst char * f(void) { return __FILE__; }" | NIX_STORE=/nix/store ./gcc/xgcc -Bgcc -x c - -S -o -
    ...
    .string "/nix/store/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-pppppp-vvvvvvv"
    ...

Mangled successfully.
2023-10-04 21:16:13 +01:00
..
4.9 gcc: if atLeast 4.9, use deduplicated version 2023-08-20 22:59:16 -07:00
6 gcc: if atLeast 6, use deduplicated version 2023-08-20 22:59:16 -07:00
7 gcc: if atLeast 7, use deduplicated version 2023-08-20 22:59:15 -07:00
8 gcc: if atLeast 8, use deduplicated version 2023-08-20 22:59:15 -07:00
9 gcc: if atLeast 9, use deduplicated version 2023-08-20 22:59:15 -07:00
10 gcc: if atLeast 10, use deduplicated version 2023-08-20 22:59:15 -07:00
11 gcc: if atLeast 11, use deduplicated version 2023-08-20 22:59:14 -07:00
12 gcc12, gcc13: always mangle __FILE__ into invalid store path 2023-10-04 21:16:13 +01:00
13 gcc12, gcc13: always mangle __FILE__ into invalid store path 2023-10-04 21:16:13 +01:00
ada-cctools-as-detection-configure.patch gcc: move patches attribute into patches/ subdirectory 2023-08-20 22:59:19 -07:00
default.nix gcc12, gcc13: always mangle __FILE__ into invalid store path 2023-10-04 21:16:13 +01:00
fix-bug-80431.patch gcc: move patches attribute into patches/ subdirectory 2023-08-20 22:59:19 -07:00
gcc-12-gfortran-driving.patch gcc: move patches attribute into patches/ subdirectory 2023-08-20 22:59:19 -07:00
gcc-12-no-sys-dirs.patch gcc: move patches attribute into patches/ subdirectory 2023-08-20 22:59:19 -07:00
gfortran-darwin-NXConstStr.patch gcc: move patches attribute into patches/ subdirectory 2023-08-20 22:59:19 -07:00
gfortran-driving.patch gcc: move patches attribute into patches/ subdirectory 2023-08-20 22:59:19 -07:00
gnat-cflags-11.patch gcc: move patches attribute into patches/ subdirectory 2023-08-20 22:59:19 -07:00
gnat-cflags.patch gcc: move patches attribute into patches/ subdirectory 2023-08-20 22:59:19 -07:00
gnat-darwin-dylib-install-name.patch gcc: move patches attribute into patches/ subdirectory 2023-08-20 22:59:19 -07:00
libgomp-dont-force-initial-exec.patch gcc: move patches attribute into patches/ subdirectory 2023-08-20 22:59:19 -07:00
libphobos.patch gcc: move patches attribute into patches/ subdirectory 2023-08-20 22:59:19 -07:00
libsanitizer-no-cyclades-9.patch gcc: move patches attribute into patches/ subdirectory 2023-08-20 22:59:19 -07:00
libsanitizer-no-cyclades.patch gcc: move patches attribute into patches/ subdirectory 2023-08-20 22:59:19 -07:00
libstdc++-netbsd-ctypes.patch gcc: move patches attribute into patches/ subdirectory 2023-08-20 22:59:19 -07:00
libstdc++-target.patch gcc: move patches attribute into patches/ subdirectory 2023-08-20 22:59:19 -07:00
no-sys-dirs-riscv-gcc9.patch gcc: move patches attribute into patches/ subdirectory 2023-08-20 22:59:19 -07:00
no-sys-dirs-riscv.patch gcc: move patches attribute into patches/ subdirectory 2023-08-20 22:59:19 -07:00
no-sys-dirs.patch gcc: move patches attribute into patches/ subdirectory 2023-08-20 22:59:19 -07:00
parallel-bconfig.patch gcc: move patches attribute into patches/ subdirectory 2023-08-20 22:59:19 -07:00
ppc-musl.patch gcc: move patches attribute into patches/ subdirectory 2023-08-20 22:59:19 -07:00
res_state-not-declared.patch gcc: move patches attribute into patches/ subdirectory 2023-08-20 22:59:19 -07:00
sigsegv-not-declared.patch gcc: move patches attribute into patches/ subdirectory 2023-08-20 22:59:19 -07:00
struct-sigaltstack-4.9.patch gcc: move patches attribute into patches/ subdirectory 2023-08-20 22:59:19 -07:00
struct-sigaltstack.patch gcc: move patches attribute into patches/ subdirectory 2023-08-20 22:59:19 -07:00
struct-ucontext-4.5.patch gcc: move patches attribute into patches/ subdirectory 2023-08-20 22:59:19 -07:00
struct-ucontext-4.8.patch gcc: move patches attribute into patches/ subdirectory 2023-08-20 22:59:19 -07:00
struct-ucontext-libjava.patch gcc: move patches attribute into patches/ subdirectory 2023-08-20 22:59:19 -07:00
struct-ucontext.patch gcc: move patches attribute into patches/ subdirectory 2023-08-20 22:59:19 -07:00
update-mcfgthread-patches.sh gcc: move patches attribute into patches/ subdirectory 2023-08-20 22:59:19 -07:00
use-source-date-epoch.patch gcc: move patches attribute into patches/ subdirectory 2023-08-20 22:59:19 -07:00