[PATCH] <<Proposed Driver Update>>
kledzik at apple.com
kledzik at apple.com
Thu Feb 28 17:42:51 PST 2013
Hi Bigcheese, shankarke,
At this stage, I'm looking for high level design feedback. This is a bunch of changes.
I wanted to do this in smaller chunks but could not find any good stopping points (and there is still lots to do).
The impetus of the changes were:
* Add support parsing darwin linker command line options.
* Clarify how in-process linking would be done vs command line linking
With these changes we will have four kinds of clients:
1) drop in replacements for existing linkers (e.g. use DarwinDriver::main() or GnuLdDriver::main()).
2) a new "universal" linker "lld" which can do all cross platform linking. You specify which command line language to use via the name of the tool or the first option (-flavor) (lld uses UniversalDriver::main()).
3) the test suite will use "lld -core" (aka "lld -flavor core") which has a simplified set of command line options and just reads and writes yaml.
4) in-process linking is done by filling in a struct which specifies the files and options to link, then passing that to a driver (e.g. to link an ELF file, fill out ELFLinkerOptions and call GnuLdDriver::linkELF()).
Some rules of thumb I used in this refactoring:
* the command line tools use the exact same interface to linking as in-process
code would do.
* only options needed by core linking are in the base LinkerOptions
* options needed in a particular platform go in LinkerOption and TargetInfo
subclass used by that platform.
Remaining work:
* I'm still not happy with the LinkerOptions usage. I think a better model would be to rename it to
TargetInfoParameters, and just use it as input when creating a TargetInfo object. The Resolver
will then call methods on the TargetInfo object instead of looking a values in the TargetInfoParameters
struct. The reasoning is that many of these flags are fixed per TargetInfo. Also, In-process clients should
not need to know what values to set. A variant model is that is that clients (include command line tools) first
create a XXXTargetInfo object which defaults to reasonable link settings, then the clients call
"setter" methods on the targetInfo object to set flags (e.g. enable dead code stripping). In this
model there is no LinkerOptions or TargetInfoParameters. They are subsumed into the TargetInfo
classes.
* Most of the elf/* tests in the test suite will need tweaking to pass with the new universal driver
* This change passes around a raw_osstream for writing any diagnostics. We will want to improve
this to be some better "Diagnostics" object being passed, so that an in-process linker doesn't have to
parse error strings.
* Each TargetInfo class should have a dump() or print() method that can be used to print out what would
be linked. This can be used in unit tests to verify specific command line arguments are parsed properly.
http://llvm-reviews.chandlerc.com/D481
Files:
test/darwin/hello-world.objtxt
test/Driver/trivial-driver.test
test/Driver/lib-search.test
test/elf/init_array.test
tools/lld-core/lld-core.cpp
tools/lld-core/CMakeLists.txt
tools/lld/lld.cpp
include/lld/ReaderWriter/ELFTargetInfo.h
include/lld/ReaderWriter/MachOTargetInfo.h
include/lld/Core/LinkerOptions.h
include/lld/Core/TargetInfo.h
include/lld/Driver/Driver.h
include/lld/Driver/LinkerInvocation.h
include/lld/Driver/ELFLinkerOptions.h
include/lld/Driver/MachOLinkerOptions.h
lib/ReaderWriter/ELF/PPC/PPCTargetInfo.h
lib/ReaderWriter/ELF/X86/X86TargetInfo.h
lib/ReaderWriter/ELF/Hexagon/HexagonTargetInfo.h
lib/ReaderWriter/ELF/X86_64/X86_64TargetInfo.cpp
lib/ReaderWriter/ELF/X86_64/X86_64TargetInfo.h
lib/ReaderWriter/ELF/File.h
lib/ReaderWriter/ELF/ELFTargetInfo.cpp
lib/ReaderWriter/ELF/TargetHandler.h
lib/ReaderWriter/MachO/WriterMachO.cpp
lib/ReaderWriter/MachO/MachOFormat.hpp
lib/ReaderWriter/MachO/ReferenceKinds.cpp
lib/ReaderWriter/MachO/ExecutableAtoms.hpp
lib/ReaderWriter/MachO/MachOTargetInfo.cpp
lib/ReaderWriter/MachO/ReferenceKinds.h
lib/ReaderWriter/MachO/StubsPass.hpp
lib/Core/LinkerOptions.cpp
lib/Core/Resolver.cpp
lib/Core/TargetInfo.cpp
lib/Core/CMakeLists.txt
lib/Driver/Drivers.cpp
lib/Driver/LinkerInvocation.cpp
lib/Driver/LDOptions.td
lib/Driver/DarwinLdDriver.cpp
lib/Driver/CoreDriver.cpp
lib/Driver/UniversalDriver.cpp
lib/Driver/DarwinOptions.td
lib/Driver/GnuLdDriver.cpp
lib/Driver/ELFLinkerOptions.cpp
lib/Driver/MachOLinkerOptions.cpp
lib/Driver/CoreOptions.td
lib/Driver/Driver.cpp
lib/Driver/CMakeLists.txt
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D481.1.patch
Type: text/x-patch
Size: 104858 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130228/8de7256e/attachment.bin>
More information about the llvm-commits
mailing list