2017年10月第一次给LLVM提交patch,到2019年底已经贡献两年多了。今年800 commits,灌水很多,挑出一些值得一提的。
LLVM
- LLVM binary utilities很多改進,如:清理了llvm-objdump代碼,使llvm-nm
ELF production
ready,給llvm-readobj/llvm-readelf添加
GNU_PROPERTY_X86_*輸出,給llvm-objcopy實現了ELF:--only-keep-debug, COFF:--redefine-sym --strip-debug, Mach-O:--redefine-sym - MC各種改進(ifunc、.reloc、.symver、.weakref等)、刪除廢棄代碼(
MCCodePadder等) - x86 -fno-plt
__tls_get_addr(D62106, D64304) - dominator tree、dead code elimination、global optimization等改進
- DebugInfo改進
- Legacy pass manager清理
- 刪除
llvm.{sig,}{segjmp,longjmp} - 刪除
"no-frame-pointer-elim" "no-frame-pointer-elim-non-leaf" - 簡化SelectionDAG inline assembly
- 給FreeBSD powerpc64貢獻者改patches。FreeBSD 13-CURRENT powerpc64用clang了
- ppc32 codegen改進(D63563, D71649)。FreeBSD 13-CURRENT powerpc也用clang了
Clang
-gsplit-dwarf能在非Linux非Fuchsia的OS(如FreeBSD)上用(r357150)-gz改進- 給ppc64實現inline asm constraint
"ww"(D64119) - 實現
-mlong-double-64(D64067)和-mlong-double-128(D64277)、-mabi=ibmlongdouble -mabi=ieeelongdouble(D64283) - 重構
-fomit-frame-pointer-momit-leaf-frame-pointer(D64294) - clangDriver的各種改進(libgcc簡化、
LIBRARY_PATH順序、musl search order、-fsanitize=等) - 默認禁用
-Wbitwise-op-parentheses -Wlogical-op-parentheses。這兩個diagnostics false positive很多。 - 修復
-M -MM -MD -MMD -MT -MQ的多個問題(r371917, r371918) - 默認啓用
-fuse-init-array(D71393, D71434)
lld
- 實現
--allow-shlib-undefined(D62276) - 完整實現了ppc32 port(main: D62464, TLS: D62940)。這兩個補丁是我非常滿意的,完整了解了方方面面後實現的.
- ppc64諸多改進,質量提升到production ready狀態,被FreeBSD 13-CURRENT採用。
- 移除Android Bionic的AArch64
PT_TLShack(D62055),爲此實現了幾個integrated assembler功能,又引申出一系列lld TLS改進(D62098 )。深入研究還發現了musl<1.1.23和FreeBSD ld.so的問題 - 給RISC-V port實現了PLT、GOT等(main:D63076、TLS(D63020))。再加上其他改進,RISCV-V
port達到了除
R_RISCV_ALIGN R_RISCV_RELAX外production ready狀態。 我對RISC-V linker relaxation的感受很複雜。這個功能怎麼實現需要認真思考。 - 把
PT_TLS從PT_GNU_RELRO中間移動到開頭(D56828),實現重疊PF_R|PF_W方案(D58892) STT_GNU_IFUNC處理的改進。D65651 MoveR_*_IRELATIVEfrom .rela.plt to rela.dyn。GNU ld x86和AArch64仍把R_*_IRELATIVE放置在.rela.plt中,感覺不好。D65995、D71519 Add IpltSection等。- .got和.got.plt分離的方案有些缺陷,2018年改進了一點,D59594完整解決問題
- 不同alignment
SHT_NOTE的放置(D61296),當初32-bit到64-bit的演化中,Linux、FreeBSD、NetBSD都弄錯了Elf64_Nhdr的大小,只有少數系統如Solaris弄對了。 - 簡化exportDynamic和isPreemptible (r368550 D66091)
- Linker script的改進(D62177 memory region等)
- x86-64 TLSDESC(D62513),也實現了LLVM的codegen部分(D62512)。
- 錯誤信息的改進(D59649, D61583 STT_SECTION to discarded section)
undefined symbol拼寫錯誤的提示(D67039),extern "C"的提示(D69592, D69650)-z noseparate-code(D64903 D64906)。最多給輸出節省3*maxpagesize字節(平均似乎大於1.5*maxpagesize),在x86上maxpagesize爲4096,在aarch64和ppc64上爲65536。嗯,平均給Android每個executable/shared object節省6kb。- 很多ClangBuiltLinux的改進。The
Linux kernel for arm32_7, arm64, ppc64le and x86_64 can now be linked by
lld.加了
-z separate-loadable-segments(D67481)用於Fuchsia。
binutils
給binutils報告了諸多RISC-V bugs:
- PR24673
unexpected
R_RISCV_NONEandR_RISCV_DTPMOD64。看起來是bfd/elfnn-riscv.c從MIPS抄了bug過來。 - PR24676
Redundant
R_RISCV_DTPMOD*R_RISCV_DTPREL*resulted from Global Dynamic -> Local Exec relaxation - PR24769 partial RELRO does not work
Others:
- Disallow .align .p2align .balign without operands fixed
- make objcopy use output ELF arch if -B not given fixed
- readelf --notes: left justify "Data size" fixed
- aarch64: local-exec TPREL relocations to weak undefined symbols -> assertion fail fixed
- Should --nmagic affect MAXPAGESIZE/COMMONPAGESIZE? wontfix
- [powerpc] ld can probably drop R_PPC64_UADDR64 conversion wontfix
- elf_x86_64_check_tls_transition should allow R_X86_64_GOTPCREL (-fno-plt) invalid (disagreement)
- readelf -V output is inconsistent fixed
- ld: Make /DISCARD/ discard SHF_LINK_ORDER sections fixed
- nm should not mark symbols in .init_array as "t" fixed
- Garbage collecting non-alloc SHF_LINK_ORDER sections fixed
- gold Generalize GC support for SHF_LINK_ORDER
- ld: Support --start-lib --end-lib
ABI
給ELF ABI RISC-V Processor Supplement ABI的建議:
- Support Thread-Local Storage Descriptors (TLSDESC)
R_RISCV_CALLvsR_RISCV_CALL_PLT- Define Initial Exec to Local Exec TLS relaxation。 阻止了RISC-V繼續弄TLS copy relocation https://sourceware.org/bugzilla/show_bug.cgi?id=23825
- Weak undefined symbol的處理方案
其他:
- MIPS: Drop
.dynsym symbol ordering requirement and nullify
DT_MIPS_XHASH - Hexagon: 希望實現TLSDESC
- x86: Intel Control-flow Enhancement Technology (D59780)。對Intel堅持弄
.plt.sec有點失望。 他們的說辭僅僅是早年弄MPX(已經被Linux移除,正在被Linux移除)也設計了這樣的方案,並且在沒有基準測試的情況下說這樣或許對cache locality更友好。 對ppc瞭解更深後發現.plt.sec倒是和ppc32/ppc64.glink有相似之處。ppc引入.glink是缺乏ADDPCIS時的無奈之舉。x86這樣設計則算明顯缺陷,亦不利於未來增加新的PLT格式, 爲了避免未來再發生這種binutils行爲挾持LLVM/Clang/lld實現的例子,只能多關注binutils的變化了。另外值得一提,AArch64 8.3a 8.5a也有相似的特性Pointer Authentication、Branch Target Identification。 Linker選項的語義AArch64比x86有優雅。我試圖在D59780挽救。
其他
musl commits+=3。
今年也是首次貢獻ldc,現在積攢了4 commits。D語言解決了不少C++痛點,今後需要更多學習。dmd commits++。
給Lua 5.4.0指出LUA_NOCVTN2S問題。
lsp-mode commits+=3。lsp-ui commits++。很惭愧,今年基本没有维护Emacs的這兩個套件。 希望lsp-mode和eglot能相互取長補短。我還是覺得lsp-mode實現過於臃腫了,現在用戶基數大了,有些地方不容易漸進改了。
給OSDT Weekly提供過一些情報幫助。
發佈了ccls 0.20190314.3、0.20190823.5。