[PATCH] D85474: Add -fbinutils-version= to gate ELF features on the specified binutils version

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 6 13:46:43 PDT 2020


MaskRay created this revision.
MaskRay added reviewers: jyknight, pcc, phosek.
Herald added subscribers: llvm-commits, cfe-commits, dang, steven.zhang, atanasyan, hiraditya, arichardson, sdardis.
Herald added a reviewer: rengolin.
Herald added projects: clang, LLVM.
MaskRay requested review of this revision.

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
Fuchsia has an immediate use case for mixed SHF_LINK_ORDER and
non-SHF_LINK_ORDER components (D76802 <https://reviews.llvm.org/D76802>; will be supported by LLD in D84001 <https://reviews.llvm.org/D84001>;
GNU ld feature request https://sourceware.org/bugzilla/show_bug.cgi?id=16833 is pending).

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 does not care about GNU as<2.35 compatibility.

-fbinutils-version=future means that we can freely use unimplemented GNU
as/ld features.

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).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D85474

Files:
  clang/include/clang/Basic/CodeGenOptions.h
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  llvm/include/llvm/MC/MCAsmInfo.h
  llvm/include/llvm/Target/TargetMachine.h
  llvm/include/llvm/Target/TargetOptions.h
  llvm/lib/CodeGen/LLVMTargetMachine.cpp
  llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
  llvm/lib/Target/TargetMachine.cpp
  llvm/test/CodeGen/X86/explicit-section-mergeable.ll
  llvm/tools/llc/llc.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D85474.283726.patch
Type: text/x-patch
Size: 12175 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200806/2e3f7136/attachment.bin>


More information about the llvm-commits mailing list