https://gcc.gnu.org/bugzilla/show_bug.cgi?id=129245
Bug ID: 129245
Summary: -flto-incremental does not invalidate LTRANS cache
when link-time -fdebug-prefix-map changes
Product: gcc
Version: 17.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: lto
Assignee: unassigned at gcc dot gnu.org
Reporter: luolongjuna at gmail dot com
Target Milestone: ---
With -flto-incremental, changing -fdebug-prefix-map at link time does not
invalidate the LTRANS cache, so GCC reuses the old cached .ltrans.o and
produces wrong debug paths.
Steps to reproduce in an empty directory:
mkdir cache
echo 'int main(void) { return 0; }' > main.c
gcc -g -flto -c main.c
# 1. Link with /old
gcc -g -flto -flto-incremental=cache "-fdebug-prefix-map=$PWD=/old" main.o -o
app
addr2line -e app main
# -> /old/main.c:1
# 2. Link with /new (warm cache)
gcc -g -flto -flto-incremental=cache "-fdebug-prefix-map=$PWD=/new" main.o -o
app
addr2line -e app main
# -> /old/main.c:1 (expected: /new/main.c:1)
# 3. Link with /new (without cache)
gcc -g -flto "-fdebug-prefix-map=$PWD=/new" main.o -o app
addr2line -e app main
# -> /new/main.c:1
Reproduced on x86_64 Linux with GCC 16.2.1 and GCC 17 trunk (0c5668ea94a6).