LLVM ERROR when cross-compiling to arm64 with -g -flto
Getting a bunch of
definition subprograms cannot be nested within DICompositeType when enabling ODR
!31214 = distinct !DISubprogram(name: "toString", linkageName: "_D3vox3lib6format14testFormattingFNbNiZ1B8toStringMxFNbNiMDFNbNiMAxaZvSQCrQCqQCp10FormatSpecZv", scope: !31094, file: !142, line: 665, type: !132, scopeLine: 665, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !168, retainedNodes: !31215)
lines followed by
LLVM ERROR: Broken module found, compilation aborted!
Exception Code: 0xC000001D
#0 0x00007ff606816236 (D:\ldc2\bin\ldc2.exe+0x3e6236)
#1 0x00007ff6096bbefe (D:\ldc2\bin\ldc2.exe+0x328befe)
#2 0x00007ff6096b1214 (D:\ldc2\bin\ldc2.exe+0x3281214)
#3 0x00007ff606af9a5f (D:\ldc2\bin\ldc2.exe+0x6c9a5f)
#4 0x00007ff606af9835 (D:\ldc2\bin\ldc2.exe+0x6c9835)
#5 0x00007ff606820009 (D:\ldc2\bin\ldc2.exe+0x3f0009)
#6 0x00007ff609398191 (D:\ldc2\bin\ldc2.exe+0x2f68191)
#7 0x00007ff606b95ce6 (D:\ldc2\bin\ldc2.exe+0x765ce6)
#8 0x00007ff6090fd93e (D:\ldc2\bin\ldc2.exe+0x2ccd93e)
#9 0x00007ff6090fe1c2 (D:\ldc2\bin\ldc2.exe+0x2cce1c2)
#10 0x00007ff608c51fc9 (D:\ldc2\bin\ldc2.exe+0x2821fc9)
#11 0x00007ff608c516c5 (D:\ldc2\bin\ldc2.exe+0x28216c5)
#12 0x00007ff608c8ffdc (D:\ldc2\bin\ldc2.exe+0x285ffdc)
#13 0x00007ff607cf96a4 (D:\ldc2\bin\ldc2.exe+0x18c96a4)
#14 0x00007ff607cf57d3 (D:\ldc2\bin\ldc2.exe+0x18c57d3)
#15 0x00007ff607ce6d2d (D:\ldc2\bin\ldc2.exe+0x18b6d2d)
#16 0x00007ff607ce550b (D:\ldc2\bin\ldc2.exe+0x18b550b)
#17 0x00007ff609303ae7 (D:\ldc2\bin\ldc2.exe+0x2ed3ae7)
#18 0x00007ff6096739ec (D:\ldc2\bin\ldc2.exe+0x32439ec)
#19 0x00007ff6092f6ff8 (D:\ldc2\bin\ldc2.exe+0x2ec6ff8)
#20 0x00007ff60940b35a (D:\ldc2\bin\ldc2.exe+0x2fdb35a)
#21 0x00007ff60940afb1 (D:\ldc2\bin\ldc2.exe+0x2fdafb1)
#22 0x00007ff60940b2b6 (D:\ldc2\bin\ldc2.exe+0x2fdb2b6)
#23 0x00007ff6092f06f0 (D:\ldc2\bin\ldc2.exe+0x2ec06f0)
#24 0x00007ff60969bfd0 (D:\ldc2\bin\ldc2.exe+0x326bfd0)
#25 0x00007ffb07f37344 (C:\Windows\System32\KERNEL32.DLL+0x17344)
#26 0x00007ffb098bcc91 (C:\Windows\SYSTEM32\ntdll.dll+0x4cc91)
On linux CI, different stack trace: https://github.com/MrSmith33/nihlang/actions/runs/9784739291/job/27016304311
Details
> ldc2
| -I=/home/runner/work/nihlang/nihlang/source
| --platformlib=
| -betterC
| -wi
| -d-debug
| -g
| -vcolumns
| -verrors-context
| -verror-style=gnu
| -link-internally
| -O3
| -boundscheck=off
| -enable-inlining
| -flto=full
| -i
| -L--entry=exe_main
| -d-version=NO_DEPS
| -d-version=EXECUTABLE
| -mtriple=aarch64-linux-gnu
| -of=/home/runner/work/nihlang/nihlang/bin/nih
| /home/runner/work/nihlang/nihlang/source/nihcli.d
| /home/runner/work/nihlang/nihlang/source/custom_object.d
definition subprograms cannot be nested within DICompositeType when enabling ODR
!865 = distinct !DISubprogram(name: "hasZero", linkageName: "_D3vox3lib6format10FormatSpec7hasZeroMFNbNiZb", scope: !366, file: !21, line: 571, type: !242, scopeLine: 571, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !52, retainedNodes: !866)
definition subprograms cannot be nested within DICompositeType when enabling ODR
!1894 = distinct !DISubprogram(name: "get", linkageName: "_D3vox3lib3mem9allocator8FreeList3getMFNbNimZAh", scope: !1895, file: !89, line: 59, type: !212, scopeLine: 59, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !52, retainedNodes: !1898)
definition subprograms cannot be nested within DICompositeType when enabling ODR
!1913 = distinct !DISubprogram(name: "put", linkageName: "_D3vox3lib3mem9allocator8FreeList3putMFNbNiAhZv", scope: !1895, file: !89, line: 67, type: !16, scopeLine: 67, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !52, retainedNodes: !1914)
definition subprograms cannot be nested within DICompositeType when enabling ODR
!1923 = distinct !DISubprogram(name: "alloc", linkageName: "_D3vox3lib3mem9allocator14BlockAllocator5allocMFNbNimZAh", scope: !1924, file: !89, line: 84, type: !212, scopeLine: 84, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !52, retainedNodes: !1930)
definition subprograms cannot be nested within DICompositeType when enabling ODR
!1986 = distinct !DISubprogram(name: "free", linkageName: "_D3vox3lib3mem9allocator14BlockAllocator4freeMFNbNiAhZv", scope: !1924, file: !89, line: 103, type: !16, scopeLine: 103, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !52, retainedNodes: !1987)
definition subprograms cannot be nested within DICompositeType when enabling ODR
!1998 = distinct !DISubprogram(name: "allocBlock", linkageName: "_D3vox3lib3mem9allocator12VoxAllocator10allocBlockMFNbNimZAh", scope: !1999, file: !89, line: 120, type: !212, scopeLine: 120, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !52, retainedNodes: !2005)
definition subprograms cannot be nested within DICompositeType when enabling ODR
!2027 = distinct !DISubprogram(name: "sizeToIndex", linkageName: "_D3vox3lib3mem9allocator12VoxAllocator11sizeToIndexMFNbNimZk", scope: !1999, file: !89, line: 141, type: !881, scopeLine: 141, flags: DIFlagPrototyped, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition | DISPFlagOptimized, unit: !52, retainedNodes: !2028)
definition subprograms cannot be nested within DICompositeType when enabling ODR
!2066 = distinct !DISubprogram(name: "freeBlock", linkageName: "_D3vox3lib3mem9allocator12VoxAllocator9freeBlockMFNbNiAhZv", scope: !1999, file: !89, line: 130, type: !16, scopeLine: 130, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !52, retainedNodes: !2067)
definition subprograms cannot be nested within DICompositeType when enabling ODR
!2119 = distinct !DISubprogram(name: "ticksPerSecond", linkageName: "_D3vox3lib4time8MonoTime14ticksPerSecondFNbNiZl", scope: !2120, file: !3, line: 27, type: !2123, scopeLine: 27, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !52)
definition subprograms cannot be nested within DICompositeType when enabling ODR
!2126 = distinct !DISubprogram(name: "toString", linkageName: "_D3vox3lib4time8Duration8toStringMxFNbNiMDFNbNiMAxaZvSQCaQBz6format10FormatSpecZv", scope: !2127, file: !3, line: 43, type: !16, scopeLine: 43, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !52, retainedNodes: !2130)
definition subprograms cannot be nested within DICompositeType when enabling ODR
!2754 = distinct !DISubprogram(name: "this", linkageName: "_D3vox3lib4math12SizeAndAlign6__ctorMFNbNcNikkZSQBuQBtQBsQBq", scope: !2755, file: !135, line: 86, type: !2758, scopeLine: 86, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !52, retainedNodes: !2760)
definition subprograms cannot be nested within DICompositeType when enabling ODR
!2789 = distinct !DISubprogram(name: "size", linkageName: "_D3vox3lib4math12SizeAndAlign4sizeMxFNbNiZk", scope: !2755, file: !135, line: 97, type: !881, scopeLine: 97, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !52, retainedNodes: !2790)
definition subprograms cannot be nested within DICompositeType when enabling ODR
!2794 = distinct !DISubprogram(name: "alignmentPower", linkageName: "_D3vox3lib4math12SizeAndAlign14alignmentPowerMxFNbNiZk", scope: !2755, file: !135, line: 98, type: !881, scopeLine: 98, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !52, retainedNodes: !2795)
definition subprograms cannot be nested within DICompositeType when enabling ODR
!2799 = distinct !DISubprogram(name: "alignment", linkageName: "_D3vox3lib4math12SizeAndAlign9alignmentMxFNbNiZk", scope: !2755, file: !135, line: 99, type: !881, scopeLine: 99, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !52, retainedNodes: !2800)
definition subprograms cannot be nested within DICompositeType when enabling ODR
!2807 = distinct !DISubprogram(name: "toString", linkageName: "_D3vox3lib4math12SizeAndAlign8toStringMxFNbNiMDFNbNiMAxaZvSQCfQCe6format10FormatSpecZv", scope: !2755, file: !135, line: 101, type: !16, scopeLine: 101, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !52, retainedNodes: !2808)
definition subprograms cannot be nested within DICompositeType when enabling ODR
!3711 = distinct !DISubprogram(name: "hasSpace", linkageName: "_D3vox3lib6format10FormatSpec8hasSpaceMFNbNiZb", scope: !366, file: !21, line: 572, type: !242, scopeLine: 572, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !52, retainedNodes: !3712)
definition subprograms cannot be nested within DICompositeType when enabling ODR
!3905 = distinct !DISubprogram(name: "hasDash", linkageName: "_D3vox3lib6format10FormatSpec7hasDashMFNbNiZb", scope: !366, file: !21, line: 570, type: !242, scopeLine: 570, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !52, retainedNodes: !3906)
definition subprograms cannot be nested within DICompositeType when enabling ODR
!3910 = distinct !DISubprogram(name: "hasPlus", linkageName: "_D3vox3lib6format10FormatSpec7hasPlusMFNbNiZb", scope: !366, file: !21, line: 573, type: !242, scopeLine: 573, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !52, retainedNodes: !3911)
definition subprograms cannot be nested within DICompositeType when enabling ODR
!3915 = distinct !DISubprogram(name: "hasHash", linkageName: "_D3vox3lib6format10FormatSpec7hasHashMFNbNiZb", scope: !366, file: !21, line: 574, type: !242, scopeLine: 574, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !52, retainedNodes: !3916)
definition subprograms cannot be nested within DICompositeType when enabling ODR
!5259 = distinct !DISubprogram(name: "toString", linkageName: "_D3vox3lib6format14testFormattingFNbNiZ1B8toStringMxFNbNiMDFNbNiMAxaZvSQCrQCqQCp10FormatSpecZv", scope: !4604, file: !21, line: 665, type: !16, scopeLine: 665, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !52, retainedNodes: !5260)
LLVM ERROR: Broken module found, compilation aborted!
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0 ldc2 0x000055c1d15d9d97 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 39
1 ldc2 0x000055c1d15d7b8c llvm::sys::RunSignalHandlers() + 188
2 ldc2 0x000055c1d15da43f
3 libc.so.6 0x00007f91b6c42520
4 libc.so.6 0x00007f91b6c969fc pthread_kill + 300
5 libc.so.6 0x00007f91b6c42476 raise + 22
6 libc.so.6 0x00007f91b6c287f3 abort + 211
7 ldc2 0x000055c1d1542a72 llvm::report_fatal_error(llvm::Twine const&, bool) + 450
8 ldc2 0x000055c1d15428a6
9 ldc2 0x000055c1d13d1c9c
10 ldc2 0x000055c1d18b4ced
11 ldc2 0x000055c1d13a8904 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) + 356
12 ldc2 0x000055c1ce716e04 llvm::lto::opt(llvm::lto::Config const&, llvm::TargetMachine*, unsigned int, llvm::Module&, bool, llvm::ModuleSummaryIndex*, llvm::ModuleSummaryIndex const*, std::vector<unsigned char, std::allocator<unsigned char>> const&) + 8260
13 ldc2 0x000055c1ce7171fd llvm::lto::backend(llvm::lto::Config const&, std::function<llvm::Expected<std::unique_ptr<llvm::CachedFileStream, std::default_delete<llvm::CachedFileStream>>> (unsigned int, llvm::Twine const&)>, unsigned int, llvm::Module&, llvm::ModuleSummaryIndex&) + 157
14 ldc2 0x000055c1ce70a5a5 llvm::lto::LTO::runRegularLTO(std::function<llvm::Expected<std::unique_ptr<llvm::CachedFileStream, std::default_delete<llvm::CachedFileStream>>> (unsigned int, llvm::Twine const&)>) + 1237
15 ldc2 0x000055c1ce709e4c llvm::lto::LTO::run(std::function<llvm::Expected<std::unique_ptr<llvm::CachedFileStream, std::default_delete<llvm::CachedFileStream>>> (unsigned int, llvm::Twine const&)>, std::function<llvm::Expected<std::function<llvm::Expected<std::unique_ptr<llvm::CachedFileStream, std::default_delete<llvm::CachedFileStream>>> (unsigned int, llvm::Twine const&)>> (unsigned int, llvm::StringRef, llvm::Twine const&)>) + 732
16 ldc2 0x000055c1ce4ed1ee lld::elf::BitcodeCompiler::compile() + 1086
17 ldc2 0x000055c1ce44d036 void lld::elf::LinkerDriver::compileBitcodeFiles<llvm::object::ELFType<(llvm::endianness)1, true>>(bool) + 198
18 ldc2 0x000055c1ce44917c lld::elf::LinkerDriver::link(llvm::opt::InputArgList&) + 25116
19 ldc2 0x000055c1ce437df5 lld::elf::LinkerDriver::linkerMain(llvm::ArrayRef<char const*>) + 5749
20 ldc2 0x000055c1ce43671f lld::elf::link(llvm::ArrayRef<char const*>, llvm::raw_ostream&, llvm::raw_ostream&, bool, bool) + 1871
21 ldc2 0x000055c1d1935802 linkObjToBinaryGcc(llvm::StringRef, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>> const&) + 690
22 ldc2 0x000055c1d1934e56 linkObjToBinary() + 854
23 ldc2 0x000055c1ce33a57f mars_mainBody(Param&, Array<char const*>&, Array<char const*>&) + 6607
24 ldc2 0x000055c1ce381de3 cppmain() + 9459
25 ldc2 0x000055c1d1afb89d _D2rt6dmain212_d_run_main2UAAamPUQgZiZ6runAllMFZv + 77
26 ldc2 0x000055c1d1afb678 _d_run_main2 + 472
27 ldc2 0x000055c1d1afb48d _d_run_main + 141
28 ldc2 0x000055c1d193d728 main + 680
29 libc.so.6 0x00007f91b6c29d90
30 libc.so.6 0x00007f91b6c29e40 __libc_start_main + 128
31 ldc2 0x000055c1ce38593e _start + 46
Command exited with -6
Repro (remove |):
git clone https://github.com/MrSmith33/nihlang.git
cd nihlang
git checkout 28837325aaf6a935a34b08eb1215d0e316207a92
ldc2
| -I=source
| --platformlib=
| -betterC
| -wi
| -d-debug
| -g
| -vcolumns
| -verrors-context
| -verror-style=gnu
| -link-internally
| -O3
| -boundscheck=off
| -enable-inlining
| -flto=full
| -i
| -L--entry=exe_main
| -d-version=NO_DEPS
| -d-version=EXECUTABLE
| -mtriple=aarch64-linux-gnu
| -of=bin/nih
| source/nihcli.d
| source/custom_object.d
No issue if either -g or -flto=full is removed.
Tested on ldc-1.38.0 and ldc2-1.39.0-beta1.
Such warnings are also seen when compiling the ldc2 unittest executable with LTO for Linux x86_64. It's non-fatal there though, e.g., from https://github.com/ldc-developers/ldc/actions/runs/9791860098/job/27036496349?pr=4693:
[542/3441] Generating bin/ldc2-unittest
definition subprograms cannot be nested within DICompositeType when enabling ODR
!4392 = distinct !DISubprogram(name: "number", linkageName: "_D3dmd5lexer5Lexer6numberMFNbPSQBd6tokens5TokenZEQBvQs3TOK", scope: !3909, file: !123, line: 2401, type: !4393, scopeLine: 2401, flags: DIFlagPrototyped, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition | DISPFlagOptimized, unit: !4006, retainedNodes: !4395)
definition subprograms cannot be nested within DICompositeType when enabling ODR
!4430 = distinct !DISubprogram(name: "cnumber", linkageName: "_D3dmd5lexer5Lexer7cnumberMFNbimZEQBg6tokens3TOK", scope: !3909, file: !123, line: 2719, type: !4393, scopeLine: 2719, flags: DIFlagPrototyped, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition | DISPFlagOptimized, unit: !4006, retainedNodes: !4431)
definition subprograms cannot be nested within DICompositeType when enabling ODR
!4648 = distinct !DISubprogram(name: "cparseDeclarationSpecifiers", linkageName: "_D3dmd6cparse__T7CParserTSQy10astcodegen10ASTCodegenZQBl27cparseDeclarationSpecifiersMFEQDiQDh__TQDdTQCyZQDl3LVLKSQEiQEh__TQEdTQDyZQEl9SpecifierZCQFo5mtype4Type", scope: !4590, file: !4589, line: 2360, type: !4649, scopeLine: 2360, flags: DIFlagPrototyped, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition | DISPFlagOptimized, unit: !4006, retainedNodes: !4651)
definition subprograms cannot be nested within DICompositeType when enabling ODR
!4003 = distinct !DISubprogram(name: "generateIdWithLoc", linkageName: "_D3dmd10identifier10Identifier17generateIdWithLocFNbAyaKxSQCe8location3LocZCQCwQCvQCm", scope: !408, file: !409, line: 218, type: !4004, scopeLine: 218, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !4006, retainedNodes: !9138)
ld: warning: ignoring invalid debug info in /home/runner/work/ldc/build/obj/ldc2-unittest.o
No such warnings for the macOS arm64 job, which uses LLVM 17. So this might be related/introduced in LLVM 18.
Just ran into the same issue with internal builds when I tried to use -flto=thin. I think it actually failed due to some maybe-unrelated linker errors though.