gcc: prevent runtime references via __FILE__ but in a reversible manner#279455
gcc: prevent runtime references via __FILE__ but in a reversible manner#279455symphorien merged 1 commit intoNixOS:stagingfrom
Conversation
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.
|
hum the merge was a misclick. Given that it was already approved I'll not open a revert right now but feel free to request one. Sorry |
|
This patch breaks coverage. The simple example would be: $ cat main.c flake-rewqork*%=
#include <stdio.h>
int main() {
printf("Hello\n");
return 0;
}
$ gcc --coverage main.c flake-rewqork*%=
$ ./a.out flake-rewqork*%=
Hello
$ gcovr . flake-rewqork*%=
(ERROR) GCOV produced the following errors processing /home/cynerd/elektroline/template-c/b/a-main.gcda:
Cannot open source file /nix/store/3MMVGB08QY8N6N37MNPRF77FNP4RSSI9-glibc-2.38-27-dev/include/bits/stdio2.h
(gcovr could not infer a working directory that resolved it.)
To ignore this error use option --gcov-ignore-errors=no_working_dir_found.
Traceback (most recent call last):
File "/nix/store/8dn974lnyrn3qgbmckax1s8wmdjbzh6r-python3.11-gcovr-6.0/lib/python3.11/site-packages/gcovr/workers.py", line 80, in worker
work(*args, **kwargs)
File "/nix/store/8dn974lnyrn3qgbmckax1s8wmdjbzh6r-python3.11-gcovr-6.0/lib/python3.11/site-packages/gcovr/gcov.py", line 351, in process_datafile
raise RuntimeError(errors_output)
RuntimeError: GCOV produced the following errors processing /home/cynerd/elektroline/template-c/b/a-main.gcda:
Cannot open source file /nix/store/3MMVGB08QY8N6N37MNPRF77FNP4RSSI9-glibc-2.38-27-dev/include/bits/stdio2.h
(gcovr could not infer a working directory that resolved it.)
To ignore this error use option --gcov-ignore-errors=no_working_dir_found.
Traceback (most recent call last):
File "/nix/store/8dn974lnyrn3qgbmckax1s8wmdjbzh6r-python3.11-gcovr-6.0/lib/python3.11/site-packages/gcovr/workers.py", line 80, in worker
work(*args, **kwargs)
File "/nix/store/8dn974lnyrn3qgbmckax1s8wmdjbzh6r-python3.11-gcovr-6.0/lib/python3.11/site-packages/gcovr/gcov.py", line 351, in process_datafile
raise RuntimeError(errors_output)
RuntimeError: GCOV produced the following errors processing /home/cynerd/elektroline/template-c/b/a-main.gcda:
Cannot open source file /nix/store/3MMVGB08QY8N6N37MNPRF77FNP4RSSI9-glibc-2.38-27-dev/include/bits/stdio2.h
(gcovr could not infer a working directory that resolved it.)
To ignore this error use option --gcov-ignore-errors=no_working_dir_found.
(ERROR) Uncaught EXCEPTION
Traceback (most recent call last):
File "/nix/store/8dn974lnyrn3qgbmckax1s8wmdjbzh6r-python3.11-gcovr-6.0/bin/.gcovr-wrapped", line 9, in <module>
sys.exit(main())
^^^^^^
File "/nix/store/8dn974lnyrn3qgbmckax1s8wmdjbzh6r-python3.11-gcovr-6.0/lib/python3.11/site-packages/gcovr/__main__.py", line 328, in main
covdata = collect_coverage_from_gcov(options)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/nix/store/8dn974lnyrn3qgbmckax1s8wmdjbzh6r-python3.11-gcovr-6.0/lib/python3.11/site-packages/gcovr/__main__.py", line 380, in collect_coverage_from_gcov
with Workers(
File "/nix/store/8dn974lnyrn3qgbmckax1s8wmdjbzh6r-python3.11-gcovr-6.0/lib/python3.11/site-packages/gcovr/workers.py", line 173, in __exit__
self.wait()
File "/nix/store/8dn974lnyrn3qgbmckax1s8wmdjbzh6r-python3.11-gcovr-6.0/lib/python3.11/site-packages/gcovr/workers.py", line 164, in wait
raise self.exceptions[0][1]
File "/nix/store/8dn974lnyrn3qgbmckax1s8wmdjbzh6r-python3.11-gcovr-6.0/lib/python3.11/site-packages/gcovr/__main__.py", line 387, in collect_coverage_from_gcov
contexts = pool.wait()
^^^^^^^^^^^
File "/nix/store/8dn974lnyrn3qgbmckax1s8wmdjbzh6r-python3.11-gcovr-6.0/lib/python3.11/site-packages/gcovr/workers.py", line 164, in wait
raise self.exceptions[0][1]
File "/nix/store/8dn974lnyrn3qgbmckax1s8wmdjbzh6r-python3.11-gcovr-6.0/lib/python3.11/site-packages/gcovr/workers.py", line 80, in worker
work(*args, **kwargs)
File "/nix/store/8dn974lnyrn3qgbmckax1s8wmdjbzh6r-python3.11-gcovr-6.0/lib/python3.11/site-packages/gcovr/gcov.py", line 351, in process_datafile
raise RuntimeError(errors_output)
RuntimeError: GCOV produced the following errors processing /home/cynerd/elektroline/template-c/b/a-main.gcda:
Cannot open source file /nix/store/3MMVGB08QY8N6N37MNPRF77FNP4RSSI9-glibc-2.38-27-dev/include/bits/stdio2.h
(gcovr could not infer a working directory that resolved it.)
To ignore this error use option --gcov-ignore-errors=no_working_dir_found.Edit: @symphorien just for my curiosoty, why isn't stripping enough? |
|
|
Ok but is that a correct approach? Shouldn't there be rather a patch that reverts it directly for the |
|
One thing that gets me confused is that originally This probably comes from the fact that I'll try to come up with something that only affects |
|
Proposed the tweak as: Now it only affects |
|
@trofi thank you. I tested coverage generation with your patch (your nixpkgs branch exactly) and it works as expected. 👍 |
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.
cc @trofi @Artturin #255192
will undraft after I rebuild gcc13
Description of changes
Things done
nix.conf? (See Nix manual)sandbox = relaxedsandbox = truenix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/)Add a 👍 reaction to pull requests you find important.