llvm-project/clang/lib
Fangrui Song 34b60d8a56 Add -fbinutils-version= to gate ELF features on the specified binutils version
There are two use cases.

Assembler
We have accrued some code gated on MCAsmInfo::useIntegratedAssembler().  Some
features are supported by latest GNU as, but we have to use
MCAsmInfo::useIntegratedAs() because the newer versions have not been widely
adopted (e.g. SHF_LINK_ORDER 'o' and 'unique' linkage in 2.35, --compress-debug-sections= in 2.26).

Linker
We want to use features supported only by LLD or very new GNU ld, or don't want
to work around older GNU ld. We currently can't represent that "we don't care
about old GNU ld".  You can find such workarounds in a few other places, e.g.
Mips/MipsAsmprinter.cpp PowerPC/PPCTOCRegDeps.cpp X86/X86MCInstrLower.cpp
AArch64 TLS workaround for R_AARCH64_TLSLD_MOVW_DTPREL_* (PR ld/18276),
R_AARCH64_TLSLE_LDST8_TPREL_LO12 (https://bugs.llvm.org/show_bug.cgi?id=36727 https://sourceware.org/bugzilla/show_bug.cgi?id=22969)

Mixed SHF_LINK_ORDER and non-SHF_LINK_ORDER components (supported by LLD in D84001;
GNU ld feature request https://sourceware.org/bugzilla/show_bug.cgi?id=16833 may take a while before available).
This feature allows to garbage collect some unused sections (e.g. fragmented .gcc_except_table).

This patch adds `-fbinutils-version=` to clang and `-binutils-version` to llc.
It changes one codegen place in SHF_MERGE to demonstrate its usage.
`-fbinutils-version=2.35` means the produced object file does not care about GNU
ld<2.35 compatibility. When `-fno-integrated-as` is specified, the produced
assembly can be consumed by GNU as>=2.35, but older versions may not work.

`-fbinutils-version=none` means that we can use all ELF features, regardless of
GNU as/ld support.

Both clang and llc need `parseBinutilsVersion`. Such command line parsing is
usually implemented in `llvm/lib/CodeGen/CommandFlags.cpp` (LLVMCodeGen),
however, ClangCodeGen does not depend on LLVMCodeGen. So I add
`parseBinutilsVersion` to `llvm/lib/Target/TargetMachine.cpp` (LLVMTarget).

Differential Revision: https://reviews.llvm.org/D85474
2021-01-26 12:28:23 -08:00
..
APINotes APINotes: annotate dump methods (NFC) 2021-01-08 20:49:28 +00:00
ARCMigrate ARCMigrate: Migrate ObjCMT.cpp over to FileEntryRef 2020-12-09 14:16:05 -08:00
AST Revert "Support for instrumenting only selected files or functions" 2021-01-26 12:25:28 -08:00
ASTMatchers Implement dynamic mapAnyOf in terms of ASTNodeKinds 2021-01-20 15:53:05 +00:00
Analysis [Sema] Fix an assertion failure in -Wcompletion-handler 2021-01-25 13:02:02 -05:00
Basic Revert "Support for instrumenting only selected files or functions" 2021-01-26 12:25:28 -08:00
CodeGen Add -fbinutils-version= to gate ELF features on the specified binutils version 2021-01-26 12:28:23 -08:00
CrossTU Revert "Revert "Revert "Revert "Revert "[analyzer] NFC: Move path diagnostic consumer implementations to libAnalysis.""""" 2021-01-08 14:17:18 +01:00
DirectoryWatcher Revert "ADT: Migrate users of AlignedCharArrayUnion to std::aligned_union_t, NFC" 2020-12-14 17:04:06 -08:00
Driver Add -fbinutils-version= to gate ELF features on the specified binutils version 2021-01-26 12:28:23 -08:00
Edit [clang] Use SourceLocation as key in hash maps, NFCI 2020-10-20 16:24:09 +01:00
Format Revert "[clang-format] add case aware include sorting" 2021-01-26 11:58:56 +01:00
Frontend Add -fbinutils-version= to gate ELF features on the specified binutils version 2021-01-26 12:28:23 -08:00
FrontendTool [NFC] Refactor Registry loops to range for 2020-06-19 00:40:10 +01:00
Headers [X86] Correct some cross references in avxintrin.h. 2021-01-25 18:49:28 -08:00
Index Revert "Following up on PR48517, fix handling of template arguments that refer" 2021-01-20 15:55:35 +01:00
IndexSerialization [index-while-building] Fix build with -DBUILD_SHARED_LIBS=True 2020-08-20 15:12:56 +01:00
Lex Restore GNU , ## __VA_ARGS__ behavior in MSVC mode 2021-01-25 22:34:49 +00:00
Parse [OpenCL] Refactor of targets OpenCL option settings 2021-01-25 19:50:23 +03:00
Rewrite SourceManager: Clarify that FileInfo always has a ContentCache, NFC 2020-10-23 12:38:53 -04:00
Sema [Sema] diagnoseEquivalentInternalLinkageDeclarations - assert for non-null NamedDecl. NFCI. 2021-01-26 15:51:49 +00:00
Serialization SourceManager: Migrate to FileEntryRef in getOrCreateContentCache, NFC 2021-01-25 17:03:12 -08:00
StaticAnalyzer Fix null dereference static analysis warning. NFCI. 2021-01-26 16:19:18 +00:00
Testing Fix MSVC "not all control paths return a value" warning. NFC. 2020-06-05 10:45:59 +01:00
Tooling [clang][Tooling] Get rid of a hack in SymbolOccurrences, NFCI 2021-01-22 13:01:41 +00:00
CMakeLists.txt APINotes: add APINotesYAMLCompiler 2020-11-05 18:55:13 +00:00