Commit Graph

104 Commits

Author SHA1 Message Date
Alp Toker 9e67d594ef Cut the gold plugin README down to size
This file hasn't been updated in years. Remove old information and point to
the current documentation at GoldPlugin.rst.

llvm-svn: 196100
2013-12-02 14:17:47 +00:00
Rafael Espindola 282a47037b Use LTO_SYMBOL_SCOPE_DEFAULT_CAN_BE_HIDDEN instead of the "dso list".
There are two ways one could implement hiding of linkonce_odr symbols in LTO:
* LLVM tells the linker which symbols can be hidden if not used from native
  files.
* The linker tells LLVM which symbols are not used from other object files,
  but will be put in the dso symbol table if present.

GOLD's API is the second option. It was implemented almost 1:1 in llvm by
passing the list down to internalize.

LLVM already had partial support for the first option. It is also very similar
to how ld64 handles hiding these symbols when *not* doing LTO.

This patch then
* removes the APIs for the DSO list.
* marks LTO_SYMBOL_SCOPE_DEFAULT_CAN_BE_HIDDEN all linkonce_odr unnamed_addr
  global values and other linkonce_odr whose address is not used.
* makes the gold plugin responsible for handling the API mismatch.

llvm-svn: 193800
2013-10-31 20:51:58 +00:00
Rafael Espindola d578b69867 Check for errors when calling lto_codegen_add_module in the gold plugin.
Thanks to Milan Lenčo for noticing it.

llvm-svn: 192996
2013-10-18 19:32:06 +00:00
Rafael Espindola 143fc3b6ba [pr17595] Fix a use after free.
Destroying the codegen also frees the path of the created object. Copy the
path to a std::string.

llvm-svn: 192787
2013-10-16 12:47:04 +00:00
Rafael Espindola cda2911caa Optimize linkonce_odr unnamed_addr functions during LTO.
Generalize the API so we can distinguish symbols that are needed just for a DSO
symbol table from those that are used from some native .o.

The symbols that are only wanted for the dso symbol table can be dropped if
llvm can prove every other dso has a copy (linkonce_odr) and the address is not
important (unnamed_addr).

llvm-svn: 191922
2013-10-03 18:29:09 +00:00
Rafael Espindola fb7a0b8943 Dispose the codegen even when just writing the bitcode file.
This makes it possible to add timers to the code generator and still use them
with -plugin-opt=emit-llvm.

llvm-svn: 191866
2013-10-03 00:07:30 +00:00
Shuxin Yang 1826ae23ff Revert r188188 and r188200.
In order to appease people (in Apple) who accuse me for committing "huge change" (?) without proper review. 

Thank Eric for fixing a compile-warning. 

llvm-svn: 188204
2013-08-12 21:07:31 +00:00
Shuxin Yang 76d082b5cd Misc enhancements to LTO:
1. Add some helper classes for partitions. They are designed in a
     way such that the top-level LTO driver will not see much difference 
     with or without partitioning.

  2. Introduce work-dir. Now all intermediate files generated during 
     LTO phases will be saved under work-dir. User can specify the workdir
     via -lto-workdir=/path/to/dir. By default the work-dir will be 
     erased before linker exit. To keep the workdir, do -lto-keep, or -lto-keep=1.

    TODO: Erase the workdir, if the linker exit prematurely.  
      We are currently not able to remove directory on signal. The support 
      routines simply ignore directory.

  3. Add one new API lto_codegen_get_files_need_remove().
     Linker and LTO plugin will communicate via this API about which files
    (including directories) need to removed before linker exit.

llvm-svn: 188188
2013-08-12 18:29:43 +00:00
Rafael Espindola 3d2ac2e41a Split getOpenFile into getOpenFile and getOpenFileSlice.
The main observation is that we never need both the filesize and the map size.
When mapping a slice of a file, it doesn't make sense to request a null
terminator and that would be the only case where the filesize would be used.

There are other cleanups that should be done in this area:

* A client should not have to pass the size (even an explicit -1) to say if
  it wants a null terminator or not, so we should probably swap the argument
  order.
* The default should be to not require a null terminator. Very few clients
  require this, but many end up asking for it just because it is the default.

llvm-svn: 186984
2013-07-23 20:25:01 +00:00
Rafael Espindola bf1a918461 Fix use of the getOpenFile api.
The gold plugin was passing the desired map size as the file size. This was
working for two reasons:
* Recent version of gold provide the get_view callback, so this code was not
  used.
* In older versions, getOpenFile was called, but the file size is never used
  if we don't require null terminated buffers and map size defaults to the
  file size.

Thanks to Eli Bendersky for noticing this.

I will try to make this api a bit less error prone.

llvm-svn: 186978
2013-07-23 18:44:31 +00:00
Rafael Espindola d9a5608dd7 Fix the build with gcc 4.7 and -std=c++11.
The error message was:

/home/espindola/llvm/llvm/tools/gold/gold-plugin.cpp: In function ‘ld_plugin_status cleanup_hook()’:
/home/espindola/llvm/llvm/tools/gold/gold-plugin.cpp:461:30: error: cannot pass objects of non-trivially-copyable type ‘std::string {aka class std::basic_string<char>}’ through ‘...’

I will check if this was a clang or gcc issue.

llvm-svn: 184138
2013-06-17 22:24:06 +00:00
Rafael Espindola 55ab87f151 Don't use PathV1.h in tools/gold/gold-plugin.cpp.
llvm-svn: 184099
2013-06-17 18:38:18 +00:00
Rafael Espindola 7c1023ad27 Avoid using PathV1.h in Program.h.
llvm-svn: 183940
2013-06-13 20:25:38 +00:00
Chandler Carruth 4d88a1c233 Sort the #include lines for tools/...
Again, tools are trickier to pick the main module header for than
library source files. I've started to follow the pattern of using
LLVMContext.h when it is included as a stub for program source files.

llvm-svn: 169252
2012-12-04 10:44:52 +00:00
Rafael Espindola a339e47689 libLTO has a bug in that it will keep every symbol if none is needed. We used
to hack around this in the gold plugin by deleting a module if no symbol was
needed. Unfortunately, the hack is wrong in the case of o module having no
visible symbols but still having side effects via static constructors.

The bug will have to be fixed in libLTO itself.

llvm-svn: 166745
2012-10-26 00:29:57 +00:00
Rafael Espindola 5e892a7a03 Pass -lLTO after gold-plugin.o so that it gets used in systems that default to
--as-needed.
Patch by Felix Geyer. Fixes pr13262.

llvm-svn: 162652
2012-08-27 03:03:07 +00:00
Rafael Espindola 9aa1fcce58 Use LTO_CODEGEN_PIC_MODEL_DYNAMIC for PIE. This requirest a git version of
gold to work. Since the enum value LDPO_PIE has just been added to plugin-api.h,
use a numeric constant for now so that we don't require an unreleased
version of gold to build.

llvm-svn: 158402
2012-06-13 13:30:24 +00:00
Dylan Noblesmith 9e5b178ecc drop unneeded config.h includes
llvm-svn: 147197
2011-12-22 23:04:07 +00:00
Rafael Espindola 5d03d46127 Point to libLTO with -L/PATH/ -lLTO so that it is found in the install
directory.
Patch by Markus Trippelsdorf.

llvm-svn: 145095
2011-11-23 03:07:25 +00:00
Peter Collingbourne 00221ce63d Use absolute path to exportsfile in gold plugin CMake build.
(Ninja generator requirement.)

llvm-svn: 143783
2011-11-05 04:17:20 +00:00
Daniel Dunbar 96d812a68d build: Tidy up a bunch of tool Makefiles, and simplify where possible using the
new all-targets pseudo-component.

llvm-svn: 142401
2011-10-18 19:27:24 +00:00
Ivan Krasin 639222d090 use 64-bit types instead of off_t/size_t to avoid the issue when
gold plugin is built with Large File Support (sizeof(off_t) == 64 on i686)
and the rest of LLVM is built w/o Large File Support
(sizeof(off_t) == 32 on i686) which corrupts the stack.

llvm-svn: 139873
2011-09-15 23:13:00 +00:00
Ivan Krasin 5021af51d9 gold plugin: don't report error on non-bitcode (e.g. ELF) files.
llvm-svn: 139544
2011-09-12 21:47:50 +00:00
Ivan Krasin d5f2d8c341 gold plugin: report errors occured in lto_module_create_from_*
llvm-svn: 139340
2011-09-09 00:14:04 +00:00
Nick Lewycky 1fcd0f1581 Don't try to dereference syms[0] on an empty vector. Reported by Todd Jackson
and Jeffrey Bosboom!

llvm-svn: 136066
2011-07-26 08:40:36 +00:00
Nick Lewycky 42bdfc0708 Also remove -lLTO which should have been in r132349. I failed to apply this
from David Meyer's patch!

llvm-svn: 132352
2011-05-31 20:00:45 +00:00
Nick Lewycky a0484fcef1 Make the gold plugin build on Cygwin as well as Linux. Patch by David Meyer!
llvm-svn: 132349
2011-05-31 19:53:26 +00:00
Oscar Fuentes a4445d6a51 CMake builds gold by default since revision 127466. This is
inconsistent with autoconf, which by default set BINUTILS_INCDIR to
empty and exclude gold from target list.

Based on a patch by Haitao Li!

llvm-svn: 131229
2011-05-12 11:26:21 +00:00
Duncan Sands 9aa54fef84 Remove an unused variable.
llvm-svn: 130860
2011-05-04 19:13:01 +00:00
Rafael Espindola ece7c9c282 If present, use gold's support for getting a file view. This prevents having
to map the file both in the linker and in the plugin.

llvm-svn: 129109
2011-04-07 21:11:00 +00:00
Rafael Espindola 26b57ffa27 Add a lto_codegen_compile_to_file to avoid producing a file, reading it to
memory and writing it back to disk.

llvm-svn: 128108
2011-03-22 20:57:13 +00:00
Rafael Espindola b39c7c7b17 Add support in the LTO library for loading an object from the middle
of an file.

llvm-svn: 127781
2011-03-17 00:36:11 +00:00
Oscar Fuentes 0122841626 Force re-linking of LLVMgold.so when its exports file changes.
llvm-svn: 127473
2011-03-11 18:27:13 +00:00
Oscar Fuentes 87e4a4da0d Fix processing of gold.exports.
llvm-svn: 127471
2011-03-11 18:07:46 +00:00
Oscar Fuentes 64d05bc281 Add LTO and gold plugin to the CMake build. Linux-only, support for
other systems pending.

PR9456.

llvm-svn: 127466
2011-03-11 15:44:24 +00:00
Rafael Espindola 7e5fe6ce1c Gold now rescans archives as needed, so the pass-through options are not
necessary anymore.

llvm-svn: 126580
2011-02-27 20:30:22 +00:00
Rafael Espindola 92c06ba158 bfd was fixed, remove the work around.
llvm-svn: 126579
2011-02-27 20:15:37 +00:00
Rafael Espindola 908d391bd2 LTO uses MC now.
llvm-svn: 126546
2011-02-26 16:44:13 +00:00
Rafael Espindola 9ef90d5b35 Dispose modules early and only create codegen when the plugin is being
used by the linker and not by nm or ar.

llvm-svn: 126089
2011-02-20 18:28:29 +00:00
Rafael Espindola d4f34d840e Add modules to codegen as soon as possible. This reduces the link time
of libxul from 12m31.084s to 7m1.359s.

llvm-svn: 126052
2011-02-19 21:49:57 +00:00
Rafael Espindola 6b6ed5d1f9 Add a debug obj-path option to make it easy to keep the .o produce by LTO.
llvm-svn: 125663
2011-02-16 11:19:44 +00:00
Rafael Espindola 70d8015063 Switch llvm to using comdats. For now always use groups with a single
section.

llvm-svn: 125526
2011-02-14 22:23:49 +00:00
Rafael Espindola 56e41f7f0b Don't open the file again in the gold plugin. To be able to do this, update
MemoryBuffer::getOpenFile to not close the file descriptor.

llvm-svn: 125128
2011-02-08 22:40:47 +00:00
Michael J. Spencer 06f5223621 gold: MinGW fix.
llvm-svn: 123886
2011-01-20 05:43:16 +00:00
Charles Davis 54c9eb6fff Now to chant the magical incantation that will exorcise the System library
from LLVM forever:

grep -lR "llvm/System" * | grep -v .svn | xargs sed -ie 's#llvm/System#llvm/Support#g'

llvm-svn: 120314
2010-11-29 19:44:50 +00:00
Michael J. Spencer ab425d8360 I swear I did a make clean and make before committing all this...
llvm-svn: 120304
2010-11-29 18:47:54 +00:00
Dan Gohman 0df7ea4c24 Move tool_output_file into its own file.
llvm-svn: 115973
2010-10-07 20:32:40 +00:00
NAKAMURA Takumi 217cadd434 Don't build redundant libLLVMgold.a.
Building archive would be executed due to definition of BUILD_ARCHIVE,
even if BUILD_ARCHIVE = "0".

llvm-svn: 113578
2010-09-10 06:26:57 +00:00
Nick Lewycky 3e19542ed3 Fix compile errors.
llvm-svn: 112808
2010-09-02 05:44:31 +00:00
Dan Gohman 8525fe7155 Convert tools to use tool_output_file, and introduce error
checking to places which previously lacked it.

llvm-svn: 111651
2010-08-20 16:59:15 +00:00