Commit Graph

115 Commits

Author SHA1 Message Date
Ahmed Charles
f4ccd11075 Replace OwningPtr<T> with std::unique_ptr<T>.
This compiles with no changes to clang/lld/lldb with MSVC and includes
overloads to various functions which are used by those projects and llvm
which have OwningPtr's as parameters. This should allow out of tree
projects some time to move. There are also no changes to libs/Target,
which should help out of tree targets have time to move, if necessary.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@203083 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-06 05:51:42 +00:00
Rafael Espindola
c540920a24 Don't mix the plain and keyword signatures of target_link_libraries.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@202299 91177308-0d34-0410-b5e6-96231b3b80d8
2014-02-26 20:39:28 +00:00
Sylvestre Ledru
6a089db385 Improve the declaration when LDPO_PIE is not available.
Thanks to İsmail Dönmez for the better declaration.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@201163 91177308-0d34-0410-b5e6-96231b3b80d8
2014-02-11 17:30:18 +00:00
Sylvestre Ledru
31575e7fec If LDPO_PIE is not defined (before binutils 2.23 version),
use the hardcoded declaration 3
See r201110 for the initial change



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@201161 91177308-0d34-0410-b5e6-96231b3b80d8
2014-02-11 17:11:32 +00:00
Rafael Espindola
256d839eed Fix an old FIXME. LDPO_PIE is available since 2.23, realeased 2012-10-22.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@201110 91177308-0d34-0410-b5e6-96231b3b80d8
2014-02-10 20:38:38 +00:00
Chandler Carruth
9f20a4c6ce Re-sort #include lines again, prior to moving headers around.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199080 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-13 08:04:33 +00:00
Tom Roeder
69051578c7 Space formatting fix for r198966.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@198971 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-10 23:17:39 +00:00
Tom Roeder
48324ba825 Fixing build break: should be in the if statement, not outside.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@198966 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-10 22:55:25 +00:00
Tom Roeder
b2c6a6c0bd Restore the library dependency of LLVMgold on LTO; this was removed recently but
is needed for LLVMgold to load in ld.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@198965 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-10 22:48:35 +00:00
Nico Weber
b6fe25c476 EXPORTED_SYMBOL_FILE support for cmake
The cmake build didn't support EXPORTED_SYMBOL_FILE. Instead, it had a
Windows-only implementation in tools/lto/CMakeLists.txt, a linux-only
implementation in tools/gold/CMakeLists.txt, and a darwin-only implementation
in tools/clang/tools/libclang/CMakeLists.txt.

This attempts to consolidate these one-offs into a single place. Clients can now
just set LLVM_EXPORTED_SYMBOL_FILE and things (hopefully) Just Work, like in
the make build.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@198136 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-28 23:31:44 +00:00
NAKAMURA Takumi
64cd49e624 gold-plugin.cpp: Use form of <plugin-api.h>, since it is external header.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@197997 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-25 02:24:38 +00:00
Alp Toker
c7cf4869a7 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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@196100 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-02 14:17:47 +00:00
Rafael Espindola
7e667c56cf 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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193800 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-31 20:51:58 +00:00
Rafael Espindola
2d8a1d677c Check for errors when calling lto_codegen_add_module in the gold plugin.
Thanks to Milan Lenčo for noticing it.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192996 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-18 19:32:06 +00:00
Rafael Espindola
648a2e6714 [pr17595] Fix a use after free.
Destroying the codegen also frees the path of the created object. Copy the
path to a std::string.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192787 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-16 12:47:04 +00:00
Rafael Espindola
438900938c 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).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191922 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-03 18:29:09 +00:00
Rafael Espindola
75a641c910 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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191866 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-03 00:07:30 +00:00
Shuxin Yang
cfaa636a1d 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. 


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188204 91177308-0d34-0410-b5e6-96231b3b80d8
2013-08-12 21:07:31 +00:00
Shuxin Yang
67d135ae40 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.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188188 91177308-0d34-0410-b5e6-96231b3b80d8
2013-08-12 18:29:43 +00:00
Rafael Espindola
70c7e48545 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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186984 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-23 20:25:01 +00:00
Rafael Espindola
963cf75e1c 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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186978 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-23 18:44:31 +00:00
Rafael Espindola
b317987c2b 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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@184138 91177308-0d34-0410-b5e6-96231b3b80d8
2013-06-17 22:24:06 +00:00
Rafael Espindola
b339411070 Don't use PathV1.h in tools/gold/gold-plugin.cpp.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@184099 91177308-0d34-0410-b5e6-96231b3b80d8
2013-06-17 18:38:18 +00:00
Rafael Espindola
675e0ac0bf Avoid using PathV1.h in Program.h.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@183940 91177308-0d34-0410-b5e6-96231b3b80d8
2013-06-13 20:25:38 +00:00
Chandler Carruth
f010c464a1 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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169252 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-04 10:44:52 +00:00
Rafael Espindola
fffb72470d 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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@166745 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-26 00:29:57 +00:00
Rafael Espindola
a16c2e3493 Pass -lLTO after gold-plugin.o so that it gets used in systems that default to
--as-needed.
Patch by Felix Geyer. Fixes pr13262.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@162652 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-27 03:03:07 +00:00
Rafael Espindola
4f81768d44 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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@158402 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-13 13:30:24 +00:00
Dylan Noblesmith
9421406aad drop unneeded config.h includes
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@147197 91177308-0d34-0410-b5e6-96231b3b80d8
2011-12-22 23:04:07 +00:00
Rafael Espindola
60e06d6ac2 Point to libLTO with -L/PATH/ -lLTO so that it is found in the install
directory.
Patch by Markus Trippelsdorf.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@145095 91177308-0d34-0410-b5e6-96231b3b80d8
2011-11-23 03:07:25 +00:00
Peter Collingbourne
5d0f76199b Use absolute path to exportsfile in gold plugin CMake build.
(Ninja generator requirement.)

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@143783 91177308-0d34-0410-b5e6-96231b3b80d8
2011-11-05 04:17:20 +00:00
Daniel Dunbar
8c39c9647d build: Tidy up a bunch of tool Makefiles, and simplify where possible using the
new all-targets pseudo-component.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@142401 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-18 19:27:24 +00:00
Ivan Krasin
71280b55a3 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.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139873 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-15 23:13:00 +00:00
Ivan Krasin
ccb7c906d1 gold plugin: don't report error on non-bitcode (e.g. ELF) files.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139544 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-12 21:47:50 +00:00
Ivan Krasin
c170f5f31c gold plugin: report errors occured in lto_module_create_from_*
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139340 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-09 00:14:04 +00:00
Nick Lewycky
5e0ac58bef Don't try to dereference syms[0] on an empty vector. Reported by Todd Jackson
and Jeffrey Bosboom!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136066 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-26 08:40:36 +00:00
Nick Lewycky
5d98c9ae71 Also remove -lLTO which should have been in r132349. I failed to apply this
from David Meyer's patch!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132352 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-31 20:00:45 +00:00
Nick Lewycky
471fa149d1 Make the gold plugin build on Cygwin as well as Linux. Patch by David Meyer!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132349 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-31 19:53:26 +00:00
Oscar Fuentes
be5d9b0bdc 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!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131229 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-12 11:26:21 +00:00
Duncan Sands
2abb82b1d3 Remove an unused variable.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@130860 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-04 19:13:01 +00:00
Rafael Espindola
e578252c27 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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129109 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-07 21:11:00 +00:00
Rafael Espindola
6421a8815e Add a lto_codegen_compile_to_file to avoid producing a file, reading it to
memory and writing it back to disk.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@128108 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-22 20:57:13 +00:00
Rafael Espindola
f21b1058a1 Add support in the LTO library for loading an object from the middle
of an file.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@127781 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-17 00:36:11 +00:00
Oscar Fuentes
4839ded3bd Force re-linking of LLVMgold.so when its exports file changes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@127473 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-11 18:27:13 +00:00
Oscar Fuentes
aa1fbb40ad Fix processing of gold.exports.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@127471 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-11 18:07:46 +00:00
Oscar Fuentes
1dc550b383 Add LTO and gold plugin to the CMake build. Linux-only, support for
other systems pending.

PR9456.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@127466 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-11 15:44:24 +00:00
Rafael Espindola
d36fb9b5d4 Gold now rescans archives as needed, so the pass-through options are not
necessary anymore.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@126580 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-27 20:30:22 +00:00
Rafael Espindola
35358e02bb bfd was fixed, remove the work around.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@126579 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-27 20:15:37 +00:00
Rafael Espindola
981b1c4c62 LTO uses MC now.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@126546 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-26 16:44:13 +00:00
Rafael Espindola
8e04fc3adf Dispose modules early and only create codegen when the plugin is being
used by the linker and not by nm or ar.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@126089 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-20 18:28:29 +00:00