Problem
When I use ThinLTO, ThinLTOCodeGenerator will generate object file whose filename looks like this:
0.x86_64.thinlto.o 1.x86_64.thinlto.o 2.x86_64.thinlto.o 3.x86_64.thinlto.o
So when I use -map option during linking, the generated link map file will contain these object files. It looks like:
# Path: ... # Arch: x86_64 # Object files: [ 0] linker synthesized ... [ 10] /Users/xushuangqing/Library/Developer/Xcode/DerivedData/XSQLTODemo-flxqbdftarzrkoeyxgvupfvnvbue/Build/Intermediates.noindex/XSQLTODemo.build/Release-iphonesimulator/XSQLTODemo.build/Objects-normal/x86_64/XSQLTODemo_lto.o/0.x86_64.thinlto.o [ 11] /Users/xushuangqing/Library/Developer/Xcode/DerivedData/XSQLTODemo-flxqbdftarzrkoeyxgvupfvnvbue/Build/Intermediates.noindex/XSQLTODemo.build/Release-iphonesimulator/XSQLTODemo.build/Objects-normal/x86_64/XSQLTODemo_lto.o/1.x86_64.thinlto.o [ 12] /Users/xushuangqing/Library/Developer/Xcode/DerivedData/XSQLTODemo-flxqbdftarzrkoeyxgvupfvnvbue/Build/Intermediates.noindex/XSQLTODemo.build/Release-iphonesimulator/XSQLTODemo.build/Objects-normal/x86_64/XSQLTODemo_lto.o/2.x86_64.thinlto.o [ 13] /Users/xushuangqing/Library/Developer/Xcode/DerivedData/XSQLTODemo-flxqbdftarzrkoeyxgvupfvnvbue/Build/Intermediates.noindex/XSQLTODemo.build/Release-iphonesimulator/XSQLTODemo.build/Objects-normal/x86_64/XSQLTODemo_lto.o/3.x86_64.thinlto.o [ 14] /Users/xushuangqing/Library/Developer/Xcode/DerivedData/XSQLTODemo-flxqbdftarzrkoeyxgvupfvnvbue/Build/Intermediates.noindex/XSQLTODemo.build/Release-iphonesimulator/XSQLTODemo.build/Objects-normal/x86_64/XSQLTODemo_lto.o/4.x86_64.thinlto.o # Sections: # Address Size Segment Section ... # Symbols: # Address Size File Name ... # Dead Stripped Symbols: # Size File Name ...
If I want to figure out each source file's size in the binary file, the 0.x86_64.thinlto.o confuses me. It contains few information about the original source file.
Optimize
As filenames like 0.x86_64.thinlto.o are joint in ThinLTOCodeGenerator::writeGeneratedObject, we can append the original object file name to it.
So the file name would looks like:
[ 10] /Users/xushuangqing/Library/Developer/Xcode/DerivedData/XSQLTODemo-flxqbdftarzrkoeyxgvupfvnvbue/Build/Intermediates.noindex/XSQLTODemo.build/Release-iphonesimulator/XSQLTODemo.build/Objects-normal/x86_64/XSQLTODemo_lto.o/0.x86_64.ViewController.o0.thinlto.o [ 11] /Users/xushuangqing/Library/Developer/Xcode/DerivedData/XSQLTODemo-flxqbdftarzrkoeyxgvupfvnvbue/Build/Intermediates.noindex/XSQLTODemo.build/Release-iphonesimulator/XSQLTODemo.build/Objects-normal/x86_64/XSQLTODemo_lto.o/1.x86_64.AppDelegate.o1.thinlto.o [ 12] /Users/xushuangqing/Library/Developer/Xcode/DerivedData/XSQLTODemo-flxqbdftarzrkoeyxgvupfvnvbue/Build/Intermediates.noindex/XSQLTODemo.build/Release-iphonesimulator/XSQLTODemo.build/Objects-normal/x86_64/XSQLTODemo_lto.o/2.x86_64.main.o2.thinlto.o [ 13] /Users/xushuangqing/Library/Developer/Xcode/DerivedData/XSQLTODemo-flxqbdftarzrkoeyxgvupfvnvbue/Build/Intermediates.noindex/XSQLTODemo.build/Release-iphonesimulator/XSQLTODemo.build/Objects-normal/x86_64/XSQLTODemo_lto.o/3.x86_64.SceneDelegate.o3.thinlto.o [ 14] /Users/xushuangqing/Library/Developer/Xcode/DerivedData/XSQLTODemo-flxqbdftarzrkoeyxgvupfvnvbue/Build/Intermediates.noindex/XSQLTODemo.build/Release-iphonesimulator/XSQLTODemo.build/Objects-normal/x86_64/XSQLTODemo_lto.o/4.x86_64.libXSQStaticLib.a(XSQObject.o)4.thinlto.o
When we analyze the link map, we can figure out each source file's size in the binary file.