42 Commits

Author SHA1 Message Date
Rui Ueyama cc622a7000 Remove error(error_code, const Twine &).
Now we have the consistent interface for all log/warn/error/fatal functions.

git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@291847 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-12 22:18:04 +00:00
Rui Ueyama cf21982550 Remove dead code.
git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@291840 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-12 22:03:25 +00:00
Rui Ueyama 0b4c7959d9 Improve an error message and remove fatal(Error &, const Twine &)
git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@291834 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-12 21:43:58 +00:00
Eric Liu 3e8a3b719d [ELF] avoid 'invalid-noreturn' error.
Summary: elf::fatal is declared "noreturn".

Reviewers: grimar

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D28607

git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@291766 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-12 13:13:32 +00:00
George Rimar 3358d46117 [ELF] - Reuse Decompressor class.
Intention of change is to get rid of code duplication.
Decompressor was introduced in D28105.

Change allows to get rid of few methods relative to decompression.

Differential revision: https://reviews.llvm.org/D28106

git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@291758 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-12 10:53:31 +00:00
Rui Ueyama 51475eebcd Make getColorDiagnostics return a boolean value instead of an enum.
Config->ColorDiagnostics was of type enum before. Now it is just a
boolean flag. Thanks Rafael for suggestion.

git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@287978 91177308-0d34-0410-b5e6-96231b3b80d8
2016-11-26 15:10:01 +00:00
Rui Ueyama f013982e3d Do not print out ARGV0 in white because it's unreadable on white background.
git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@287950 91177308-0d34-0410-b5e6-96231b3b80d8
2016-11-25 20:37:16 +00:00
Rui Ueyama 759546f251 Support -color-diagnostics={auto,always,never}.
-color-diagnostics=auto is default because that's the same as
Clang's default. When color is enabled, error or warning messages
are colored like this.

  error:
  <bold>ld.lld</bold> <red>error:</red> foo.o: no such file

  warning:
  <bold>ld.lld</bold> <magenta>warning:</magenta> foo.o: no such file

Differential Revision: https://reviews.llvm.org/D27117

git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@287949 91177308-0d34-0410-b5e6-96231b3b80d8
2016-11-25 20:27:32 +00:00
Rui Ueyama f91e792b8d Include a hint how to see all errors if error is truncated.
This patch changes the error message from

  too many errors emitted, stopping now

to

  too many errors emitted, stopping now (use -error-limit=0 to see all errors)

Thanks for Sean for the suggestion!

git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@287900 91177308-0d34-0410-b5e6-96231b3b80d8
2016-11-24 20:31:43 +00:00
Rui Ueyama 9821c593e3 Remove HasError and use ErrorCount instead.
HasError was always true if ErrorCount > 0, so we can use ErrorCount instead.

git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@287849 91177308-0d34-0410-b5e6-96231b3b80d8
2016-11-24 01:43:21 +00:00
Rui Ueyama c9b5374a3d Make log(), error() and fatal() thread-safe.
git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@287794 91177308-0d34-0410-b5e6-96231b3b80d8
2016-11-23 18:34:28 +00:00
Rui Ueyama 8868505242 Limit default maximum number of errors to 20.
This is in the context of https://llvm.org/bugs/show_bug.cgi?id=31109.
When LLD prints out errors for relocations, it tends to print out
extremely large number of errors (like millions) because it would
print out one error per relocation.

This patch makes LLD bail out if it prints out more than 20 errors.
You can configure the limitation using -error-limit argument.
-error-limit=0 means no limit.

I chose the flag name because Clang has the same feature as -ferror-limit.
"f" doesn't make sense to us, so I omitted it.

Differential Revision: https://reviews.llvm.org/D26981

git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@287789 91177308-0d34-0410-b5e6-96231b3b80d8
2016-11-23 18:15:37 +00:00
Rui Ueyama 6d7e0dd375 Call flush() after llvm_shutdown().
llvm_shutdown could write something to outs or errs,
so we need to flush them after calling llvm_shutdown.

git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@286548 91177308-0d34-0410-b5e6-96231b3b80d8
2016-11-11 02:16:15 +00:00
Davide Italiano 96c7a8b37e [LTO] Call llvm_shutdown on early exit.
In a non-LTO build is a nop. In a LTO build, we deallocate/destroy
managed static and this allows us to get the output of, e.g.,
-time-passes without performing a full shutdown.

Differential Revision:  https://reviews.llvm.org/D26517

git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@286493 91177308-0d34-0410-b5e6-96231b3b80d8
2016-11-10 19:39:05 +00:00
Rafael Espindola a0f1fe664e Use fewer allocators.
Instead of having 3 section allocators per file, have 3 for all files.

This is a substantial performance improvement for some cases. Linking
chromium without gc speeds up by 1.065x.

This requires using _exit in fatal since we have to avoid destructing
an InputSection if fatal is called from the constructor.

Thanks to Rui for the suggestion.

git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@285290 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-27 13:32:32 +00:00
Rui Ueyama edad27f869 Include ARGV[0] in error messages.
This is what other linkers and clang driver do.

Differential Revision: https://reviews.llvm.org/D25780

git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@284634 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-19 20:05:43 +00:00
Eugene Leviant 5a8355718b [ELF] Add "error" and "warning" prefixes to linker messages
Differential revision: https://reviews.llvm.org/D25729


git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@284575 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-19 09:35:19 +00:00
George Rimar 95bcdf3b5d [ELF] - Do not crash when unable to parse ELF object file.
createELFObj() may call error(...), for example when file is too short.
In that case header is not set and following line lead to crash:

EMachine = ELFObj.getHeader()->e_machine;

Patch fixes the issue.

Differential revision: https://reviews.llvm.org/D25233

git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@283532 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-07 08:51:57 +00:00
Rui Ueyama ac911e2f18 Remove useless function.
git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@283488 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-06 20:04:54 +00:00
Rui Ueyama 4b50e10df3 Rename warning -> warn.
It's better because it's a verb.

git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@282763 91177308-0d34-0410-b5e6-96231b3b80d8
2016-09-29 21:00:23 +00:00
Rafael Espindola 2ec79a60cb Delete dead code.
And make it easier to spot code going dead by using elf::.

git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@275858 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-18 18:24:41 +00:00
Rui Ueyama 4db17a00ed Avoid writing to errs().
We should write to ErrorOS instead. Normaly, *ErrorOS == errs(),
but they can be different if LLD is embedded.

git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@275525 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-15 02:51:05 +00:00
Rui Ueyama c4c5522a24 ELF: Make error() to always set HasError.
Previously, it checked for the EC parameter and set HasError
only when there was an error. But in most places we called
error only when error had occurred, so this behavior was confusing.

git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@275517 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-15 01:38:54 +00:00
Lang Hames f83e27b899 [lld] Update LLD for Archive::child_iterator change in LLVM r275361.
git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@275362 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-14 02:35:18 +00:00
Rafael Espindola 7353c6d2c2 Use "using namespace llvm" like the rest of ELF lld.
git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@274755 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-07 14:06:38 +00:00