Right now in case of LTO the section is not emited:
$ cat test.c void __attribute__((optnone)) bar() { } void __attribute__((optnone)) foo() { bar(); } int main() { foo(); } $ clang -flto=thin -gdwarf-aranges -g -O3 test.c $ eu-readelf -waranges a.out | fgrep -c -e foo -e bar 0 $ clang -gdwarf-aranges -g -O3 test.c $ eu-readelf -waranges a.out | fgrep -c -e foo -e bar 2
Fix this by passing explicitly --plugin-opt=-generate-arange-section.
But as mentioned by @dblaikie:
the better solution would be to encode this in IR metadata (DICompileUnit) if it's reasonable to respect this option on a per-CU basis (which it probably is, though that'd be a bit of backend work) - or to set it as IR global metadata (like how the DWARF version is encoded - probably using the same IR linker merging strategy, of choosing the highest value (so if any module has aranges, then a linked module has aranges too - even for the CUs that had it turned off) if it's really not feasible to support on a per-CU basis) but probably OK-enough, given that aranges is hopefully on the way out & not worth all the work of the deeper fix
This is the resubmit, previous submission [1], got reverted, due to test
failures, that had been addressed in [2] and [3].
[1]: https://reviews.llvm.org/D133092
[3]: https://reviews.llvm.org/D133841
[4]: https://reviews.llvm.org/D133847
Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
Suggested-by: OCHyams <orlando.hyams@sony.com>