diff options
author | Mehdi Amini <mehdi.amini@apple.com> | 2016-12-14 04:56:42 +0000 |
---|---|---|
committer | Mehdi Amini <mehdi.amini@apple.com> | 2016-12-14 04:56:42 +0000 |
commit | 8e13bc4562c2b921b0bd4e46a1c119f6ddfba07e (patch) | |
tree | e7e7d67361279bfebc522363479b781ccfb5c632 /llvm/tools | |
parent | 378b8c8f012bacb85a4057e29a4e6b522842e94d (diff) | |
download | bcm5719-llvm-8e13bc4562c2b921b0bd4e46a1c119f6ddfba07e.tar.gz bcm5719-llvm-8e13bc4562c2b921b0bd4e46a1c119f6ddfba07e.zip |
[ThinLTO] Add an API to trigger file-based API for returning objects to the linker
Summary:
The motivation is to support better the -object_path_lto option on
Darwin. The linker needs to write down the generate object files on
disk for later use by lldb or dsymutil (debug info are not present
in the final binary). We're moving this into libLTO so that we can
be smarter when a cache is enabled and hard-link when possible
instead of duplicating the files.
Reviewers: tejohnson, deadalnix, pcc
Subscribers: dexonsmith, llvm-commits
Differential Revision: https://reviews.llvm.org/D27507
llvm-svn: 289631
Diffstat (limited to 'llvm/tools')
-rw-r--r-- | llvm/tools/llvm-lto/llvm-lto.cpp | 12 | ||||
-rw-r--r-- | llvm/tools/lto/lto.cpp | 15 | ||||
-rw-r--r-- | llvm/tools/lto/lto.exports | 5 |
3 files changed, 31 insertions, 1 deletions
diff --git a/llvm/tools/llvm-lto/llvm-lto.cpp b/llvm/tools/llvm-lto/llvm-lto.cpp index 2f0a1dfb9fa..ece0130c9fb 100644 --- a/llvm/tools/llvm-lto/llvm-lto.cpp +++ b/llvm/tools/llvm-lto/llvm-lto.cpp @@ -130,6 +130,11 @@ static cl::opt<std::string> ThinLTOSaveTempsPrefix( cl::desc("Save ThinLTO temp files using filenames created by adding " "suffixes to the given file path prefix.")); +static cl::opt<std::string> ThinLTOGeneratedObjectsDir( + "thinlto-save-objects", + cl::desc("Save ThinLTO generated object files using filenames created in " + "the given directory.")); + static cl::opt<bool> SaveModuleFile("save-merged-module", cl::init(false), cl::desc("Write merged LTO module to file before CodeGen")); @@ -707,6 +712,13 @@ private: if (!ThinLTOSaveTempsPrefix.empty()) ThinGenerator.setSaveTempsDir(ThinLTOSaveTempsPrefix); + + if (!ThinLTOGeneratedObjectsDir.empty()) { + ThinGenerator.setGeneratedObjectsDirectory(ThinLTOGeneratedObjectsDir); + ThinGenerator.run(); + return; + } + ThinGenerator.run(); auto &Binaries = ThinGenerator.getProducedBinaries(); diff --git a/llvm/tools/lto/lto.cpp b/llvm/tools/lto/lto.cpp index 2f0dd26d64d..aa61f2ad2ff 100644 --- a/llvm/tools/lto/lto.cpp +++ b/llvm/tools/lto/lto.cpp @@ -488,6 +488,16 @@ LTOObjectBuffer thinlto_module_get_object(thinlto_code_gen_t cg, MemBuffer->getBufferSize()}; } +unsigned int thinlto_module_get_num_object_files(thinlto_code_gen_t cg) { + return unwrap(cg)->getProducedBinaryFiles().size(); +} +const char *thinlto_module_get_object_file(thinlto_code_gen_t cg, + unsigned int index) { + assert(index < unwrap(cg)->getProducedBinaryFiles().size() && + "Index overflow"); + return unwrap(cg)->getProducedBinaryFiles()[index].c_str(); +} + void thinlto_codegen_disable_codegen(thinlto_code_gen_t cg, lto_bool_t disable) { unwrap(cg)->disableCodeGen(disable); @@ -551,6 +561,11 @@ void thinlto_codegen_set_savetemps_dir(thinlto_code_gen_t cg, return unwrap(cg)->setSaveTempsDir(save_temps_dir); } +void thinlto_set_generated_objects_dir(thinlto_code_gen_t cg, + const char *save_temps_dir) { + unwrap(cg)->setGeneratedObjectsDirectory(save_temps_dir); +} + lto_bool_t thinlto_codegen_set_pic_model(thinlto_code_gen_t cg, lto_codegen_model model) { switch (model) { diff --git a/llvm/tools/lto/lto.exports b/llvm/tools/lto/lto.exports index 74091c2641b..2e09026ae50 100644 --- a/llvm/tools/lto/lto.exports +++ b/llvm/tools/lto/lto.exports @@ -64,4 +64,7 @@ thinlto_codegen_add_must_preserve_symbol thinlto_codegen_add_cross_referenced_symbol thinlto_codegen_set_final_cache_size_relative_to_available_space thinlto_codegen_set_codegen_only -thinlto_codegen_disable_codegen
\ No newline at end of file +thinlto_codegen_disable_codegen +thinlto_module_get_num_object_files +thinlto_module_get_object_file +thinlto_set_generated_objects_dir
\ No newline at end of file |