Clang does not produce full .debug_aranges section with ThinLTO

Thank you for the answer!
Yes, you are right for this particular case!

However there is still some issue (and actually I came up to this from a ~2GB binary that has almost empty .debug_aranges, but just trying to reduce the scope)

Like I wrote you are right about my first example, since .debug_info also empty for it.

However if I will add __attribute__((optnone)):

void __attribute__((optnone)) bar()
{
}
void __attribute__((optnone)) foo()
{
        bar();
}
int main()
{
        foo();
}

And compile it with -flto=thin:

clang -flto=thin -gdwarf-aranges -g -O3 test.c

Entries for foo and bar should exist, right? However they are not:

$ eu-readelf -waranges a.out  | fgrep -c -e foo -e bar
0

However .debug_info contains entry for them:

$ llvm-dwarfdump --debug-info a.out | fgrep -e foo -e bar
                DW_AT_name      ("bar")
                DW_AT_name      ("foo")