Commit Graph

9 Commits

Author SHA1 Message Date
zinzilulo
481208bdff cc-wrapper, gcc, gnat, gnat-bootstrap: fix GCC 13 and GNAT 13/14/15 builds on darwin 2026-05-27 18:35:39 +01:00
Maximilian Bosch
00105a15ea gcc13,gcc14: fix build w/ glibc-2.42 2025-12-30 14:57:14 +01:00
Sergei Trofimovich
ce5cc26328 gcc13: 13.2.0 -> 13.3.0
Changes: https://gcc.gnu.org/gcc-13/changes.html
2024-05-30 09:52:02 +01:00
Sergei Trofimovich
be41f86a80 gcc: amend __FILE__ mangling patch to only affect -fmacro-prefix-map=
THe initial intent of the change was to only affect
`-fmacro-prefix-map=` option.

Due to the bug of `if (maps == macro_prefix_maps)` condition of initial
setting all three of:

    static file_prefix_map *macro_prefix_maps; /* -fmacro-prefix-map  */
    static file_prefix_map *debug_prefix_maps; /* -fdebug-prefix-map  */
    static file_prefix_map *profile_prefix_maps; /* -fprofile-prefix-map  */

matches the comparison and applied the mangling (as long as on options
were passed into those before).

As a result not only (intended) `__FILE__` embedding happened in `.data`
section, but also (unintended) debugging symbols (`-fdebug-prefix-map`)
and profiling data (`-fprofile-prefix-map`) were broken by mangling.

The patch update fixes it by explicitly passing a boolean that controls
the mangling in a single call site relevant to `-fmacro-prefix-map`.

While at it fixed `int / size_t` mismatch that caused build failure on
upcoming `gcc-14`.

Tested as:

- `nix` still has no `nlohmann_json` retention
- `gdb` can now resolve `stdc++` debugging symbols in templates
- `--coverage` has working source file paths
2024-02-02 20:59:41 +00:00
Weijia Wang
b384f04673 gcc13: add patch for PR110280 2024-01-12 20:54:25 +01:00
Guillaume Girol
9cb3614007 gcc: prevent runtime references via __FILE__ but in a reversible manner
the mangling done by mangle-NIX_STORE-in-__FILE__.patch also applies to
source paths embedded in debug symbols. When putting a breakpoint in a
template instanciation from another lib, the path that gdb looks for is
therefore mangled (/nix/store/eeeeeee;...-the-lib-dev/include/foo.h)
This severely degrades the debugging experience. To alleviate that, it's
possible to make the mangling reversible: a debuginfod server can then
reverse the mangling. I plan to implement that in nixseparatedebuginfod.
The reversible mangling that was chosen in making the hash of the store
path uppercase.
2024-01-07 12:00:00 +00:00
Sergei Trofimovich
68aaaec7d2 gcc12, gcc13: fix typos in comments around __FILE__ patch
Noticed by Robert Schütz.
2023-11-30 10:24:57 +00:00
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
Adam Joseph
93d63aaa05 gcc: if atLeast 13, use deduplicated version 2023-08-20 23:00:00 -07:00