Commit Graph

347 Commits

Author SHA1 Message Date
Logan Smith
a52aea0ba6 Use INTERFACE_COMPILE_OPTIONS to disable -Wsuggest-override for any target that links to gtest
This cleans up several CMakeLists.txt's where -Wno-suggest-override was manually specified. These test targets now inherit this flag from the gtest target.

Some unittests CMakeLists.txt's, in particular Flang and LLDB, are not touched by this patch. Flang manually adds the gtest sources itself in some configurations, rather than linking to LLVM's gtest target, so this fix would be insufficient to cover those cases. Similarly, LLDB has subdirectories that manually add the gtest headers to their include path without linking to the gtest target, so those subdirectories still need -Wno-suggest-override to be manually specified to compile without warnings.

Differential Revision: https://reviews.llvm.org/D84554
2020-07-27 08:37:01 -07:00
Logan Smith
77e0e9e17d Reapply "Try enabling -Wsuggest-override again, using add_compile_options instead of add_compile_definitions for disabling it in unittests/ directories."
add_compile_options is more sensitive to its location in the file than add_definitions--it only takes effect for sources that are added after it. This updated patch ensures that the add_compile_options is done before adding any source files that depend on it.

Using add_definitions caused the flag to be passed to rc.exe on Windows and thus broke Windows builds.
2020-07-22 17:50:19 -07:00
Logan Smith
97a0f80c46 Revert "Try enabling -Wsuggest-override again, using add_compile_options instead of add_compile_definitions for disabling it in unittests/ directories."
This reverts commit 388c9fb1af.
2020-07-22 15:07:01 -07:00
Logan Smith
388c9fb1af Try enabling -Wsuggest-override again, using add_compile_options instead of add_compile_definitions for disabling it in unittests/ directories.
Using add_compile_definitions caused the flag to be passed to rc.exe on Windows and thus broke Windows builds.
2020-07-22 14:19:34 -07:00
Hans Wennborg
3eec657825 Revert "Enable -Wsuggest-override in the LLVM build" and the follow-ups.
After lots of follow-up fixes, there are still problems, such as
-Wno-suggest-override getting passed to the Windows Resource Compiler
because it was added with add_definitions in the CMake file.

Rather than piling on another fix, let's revert so this can be re-landed
when there's a proper fix.

This reverts commit 21c0b4c1e8.
This reverts commit 81d68ad27b.
This reverts commit a361aa5249.
This reverts commit fa42b7cf29.
This reverts commit 955f87f947.
This reverts commit 8b16e45f66.
This reverts commit 308a127a38.
This reverts commit 274b6b0c7a.
This reverts commit 1c7037a2a5.
2020-07-22 20:23:58 +02:00
Logan Smith
81d68ad27b [lld] Disable -Wsuggest-override for unittests 2020-07-21 17:40:59 -07:00
Eric Christopher
256e4d46a6 Fix signed vs unsigned comparison warnings a different way. 2020-07-10 22:52:50 -07:00
Eric Christopher
98eec7700c Temporarily Revert "Fix [-Werror,-Wsign-compare] warnings arising from subsection symbols patch."
as it's causing build errors with another clang so I'll need to approach
this differently.

This reverts commit c282708316.
2020-07-09 13:46:59 -07:00
Eric Christopher
c282708316 Fix [-Werror,-Wsign-compare] warnings arising from subsection symbols patch. 2020-07-09 11:14:00 -07:00
Benjamin Kramer
adcd026838 Make llvm::StringRef to std::string conversions explicit.
This is how it should've been and brings it more in line with
std::string_view. There should be no functional change here.

This is mostly mechanical from a custom clang-tidy check, with a lot of
manual fixups. It uncovers a lot of minor inefficiencies.

This doesn't actually modify StringRef yet, I'll do that in a follow-up.
2020-01-28 23:25:25 +01:00
Igor Kudrin
6b4f86f65f Reapply: [MachO] Add a test for detecting reserved unit length.
The test in the origin patch did not create a __debug_str section.
An UBSan check triggered when the corresponding pointer was dereferenced.

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

This reapplies fcc08aa835
which was reverted in b16f82ad3b.
2020-01-21 16:59:44 +07:00
Mitch Phillips
b16f82ad3b Revert "[MachO] Add a test for detecting reserved unit length."
This change broke the UBSan buildbots. More information available in the
original Phabricator review: https://reviews.llvm.org/D72695

This reverts commit fcc08aa835.
2020-01-20 22:39:24 -08:00
Igor Kudrin
fcc08aa835 [MachO] Add a test for detecting reserved unit length.
This is a follow-up for D71546 to add a corresponding unit test.

Differential Revision: https://reviews.llvm.org/D72695
2020-01-15 16:55:11 +07:00
Rui Ueyama
b11386f9be Make it possible to redirect not only errs() but also outs()
This change is for those who use lld as a library. Context:
https://reviews.llvm.org/D70287

This patch adds a new parmeter to lld::*::link() so that we can pass
an raw_ostream object representing stdout. Previously, lld::*::link()
took only an stderr object.

Justification for making stdoutOS and stderrOS mandatory: I wanted to
make link() functions to take stdout and stderr in that order.
However, if we change the function signature from

  bool link(ArrayRef<const char *> args, bool canExitEarly,
            raw_ostream &stderrOS = llvm::errs());

to

  bool link(ArrayRef<const char *> args, bool canExitEarly,
            raw_ostream &stdoutOS = llvm::outs(),
            raw_ostream &stderrOS = llvm::errs());

, then the meaning of existing code that passes stderrOS silently
changes (stderrOS would be interpreted as stdoutOS). So, I chose to
make existing code not to compile, so that developers can fix their
code.

Differential Revision: https://reviews.llvm.org/D70292
2019-11-18 11:18:06 +09:00
Chandler Carruth
2946cd7010 Update the file headers across all of the LLVM projects in the monorepo
to reflect the new license.

We understand that people may be surprised that we're moving the header
entirely to discuss the new license. We checked this carefully with the
Foundation's lawyer and we believe this is the correct approach.

Essentially, all code in the project is now made available by the LLVM
project under our new license, so you will see that the license headers
include that license only. Some of our contributors have contributed
code under our old license, and accordingly, we have retained a copy of
our old license notice in the top-level files in each project and
repository.

llvm-svn: 351636
2019-01-19 08:50:56 +00:00
Brian Gesiak
b9f7f4b87c [Darwin] Use errorHandler from liblldCommon
Summary:
Error handling in liblldCore and the Darwin toolchain prints to an
output stream. A TODO in the project explained that a diagnostics
interface resembling Clang's should be added.

For now, the simple diagnostics interface defined in liblldCommon seems
like an improvement. It prints colors when they're available, uses locks
for thread-safety, and abstracts away the `"error: "` and newline
literal strings that litter the Darwin toolchain code.

To use the liblldCommon error handler, a link dependency is added to
the liblldDriver library.

Test Plan:
1. check-lld
2. Invoke `ld64.lld -r` in a terminal that supports color output.
   Confirm that "ld64.lld: error: -arch not specified and could not be inferred"
   is output, and that the "error:" is colored red!

Reviewers: ruiu, smeenai

Reviewed By: ruiu

Subscribers: mgorny, llvm-commits

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

llvm-svn: 334466
2018-06-12 02:34:04 +00:00
Fangrui Song
c505e06134 Remove \brief commands from doxygen comments.
Summary: This is similar to D46290 D46320.

Reviewers: ruiu, grimar

Subscribers: mehdi_amini, llvm-commits

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

llvm-svn: 332372
2018-05-15 16:40:54 +00:00
Martin Storsjo
5fb6437012 [MachO] Don't write test files to /tmp, remove them afterwards.
This matches what is done in MachONormalizedFileBinaryWriterTests.cpp
already.

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

llvm-svn: 332114
2018-05-11 18:19:02 +00:00
Shoaib Meenai
d806af3499 [CMake] Use PRIVATE in target_link_libraries for executables
We currently use target_link_libraries without an explicit scope
specifier (INTERFACE, PRIVATE or PUBLIC) when linking executables.
Dependencies added in this way apply to both the target and its
dependencies, i.e. they become part of the executable's link interface
and are transitive.

Transitive dependencies generally don't make sense for executables,
since you wouldn't normally be linking against an executable. This also
causes issues for generating install export files when using
LLVM_DISTRIBUTION_COMPONENTS. For example, clang has a lot of LLVM
library dependencies, which are currently added as interface
dependencies. If clang is in the distribution components but the LLVM
libraries it depends on aren't (which is a perfectly legitimate use case
if the LLVM libraries are being built static and there are therefore no
run-time dependencies on them), CMake will complain about the LLVM
libraries not being in export set when attempting to generate the
install export file for clang. This is reasonable behavior on CMake's
part, and the right thing is for LLVM's build system to explicitly use
PRIVATE dependencies for executables.

Unfortunately, CMake doesn't allow you to mix and match the keyword and
non-keyword target_link_libraries signatures for a single target; i.e.,
if a single call to target_link_libraries for a particular target uses
one of the INTERFACE, PRIVATE, or PUBLIC keywords, all other calls must
also be updated to use those keywords. This means we must do this change
in a single shot. I also fully expect to have missed some instances; I
tested by enabling all the projects in the monorepo (except dragonegg),
and configuring both with and without shared libraries, on both Darwin
and Linux, but I'm planning to rely on the buildbots for other
configurations (since it should be pretty easy to fix those).

Even after this change, we still have a lot of target_link_libraries
calls that don't specify a scope keyword, mostly for shared libraries.
I'm thinking about addressing those in a follow-up, but that's a
separate change IMO.

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

llvm-svn: 319840
2017-12-05 21:49:56 +00:00
Rui Ueyama
3f851704c1 Move new lld's code to Common subdirectory.
New lld's files are spread under lib subdirectory, and it isn't easy
to find which files are actually maintained. This patch moves maintained
files to Common subdirectory.

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

llvm-svn: 314719
2017-10-02 21:00:41 +00:00
Zachary Turner
264b5d9e88 Move Object format code to lib/BinaryFormat.
This creates a new library called BinaryFormat that has all of
the headers from llvm/Support containing structure and layout
definitions for various types of binary formats like dwarf, coff,
elf, etc as well as the code for identifying a file from its
magic.

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

llvm-svn: 304864
2017-06-07 03:48:56 +00:00
Zachary Turner
3a57fbd6db [Support] Move Parallel algorithms from LLD to LLVM.
Differential Revision: https://reviews.llvm.org/D33024

llvm-svn: 302748
2017-05-11 00:03:52 +00:00
Zachary Turner
092c767745 [Core] Make parallel algorithms match C++ Parallelism TS.
Differential Revision: https://reviews.llvm.org/D33016

llvm-svn: 302613
2017-05-10 01:16:22 +00:00
Zachary Turner
f7ca8fcd6a Split up Parallel and LLVM'ize naming conventions.
This is one step in preparation of raising this up to
LLVM.  This hides all of the Executor stuff in a private
implementation file, leaving only the core algorithms and
the TaskGroup class exposed.  In doing so, fix up all the
variable names to conform to LLVM style.

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

llvm-svn: 302288
2017-05-05 21:09:26 +00:00
James Henderson
db664b6c86 Fix signed/unsigned comparison warning in a unit test. This was appearing on
lld-x86_64-darwin13.

llvm-svn: 299749
2017-04-07 08:48:17 +00:00
James Henderson
8abda20a9f [Core] Fix parallel_for for Linux
r299635 exposed a latent bug in the Linux implementation of parallel_for, which
resulted in it calling the function outside of the range requested, resulting
later in a segmentation fault. This change fixes this issue and adds a unit test.

llvm-svn: 299748
2017-04-07 08:11:28 +00:00
Eric Fiselier
87c87f4c30 [CMake] Fix pthread handling for out-of-tree builds
LLVM defines `PTHREAD_LIB` which is used by AddLLVM.cmake and various projects
to correctly link the threading library when needed. Unfortunately
`PTHREAD_LIB` is defined by LLVM's `config-ix.cmake` file which isn't installed
and therefore can't be used when configuring out-of-tree builds. This causes
such builds to fail since `pthread` isn't being correctly linked.

This patch attempts to fix that problem by renaming and exporting
`LLVM_PTHREAD_LIB` as part of`LLVMConfig.cmake`. I renamed `PTHREAD_LIB`
because It seemed likely to cause collisions with downstream users of
`LLVMConfig.cmake`.

llvm-svn: 294690
2017-02-10 01:59:20 +00:00
Davide Italiano
3582242aa3 [Cmake] Use Cmake's default RPATH for unittest.
Similarly to what was done in r280791 for llvm/.
This should fix a bunch of failures I saw while
trying a BUILD_SHARED_LIBS build on MacOS.
Still there are some failures, but this is a step
forward.

Thanks a lot to Chris Bieneman for the suggested
fix (in PR30345)

llvm-svn: 281256
2016-09-12 20:44:53 +00:00
Rui Ueyama
951cfb6aae Fix potential test failures.
Windows does not allow opened files to be removed. This patch
fixes two types of errors.

 - Output file being the same as input file. Because LLD itself
   holds a file descriptor of the input file, it cannot create an
   output file with the same name as a new file.

 - Removing files before releasing MemoryBuffer objects.

These tests are not failing no because MemoryBuffer happens to
decide not to use mmap on these files. But we shouldn't rely on
that behavior.

llvm-svn: 280507
2016-09-02 17:19:28 +00:00
Eugene Zelenko
1a299eab32 Fix Clang-tidy misc-unused-using-decls and Include What You Use warnings.
Differential revision: http://reviews.llvm.org/D19348

llvm-svn: 267008
2016-04-21 17:14:10 +00:00
Pete Cooper
4b35a64cb1 Fix test which failed Error migration on Windows bots.
Note, this is https://llvm.org/bugs/show_bug.cgi?id=27187.

The problem here was that just converting an error to a bool doesn't
always set the checked bit.  We only set that bit if the Error didn't
actually contain an error.  Otherwise we'd end potentially up silently
dropping it.

Instead just use the consumeError method which is designed to allow us
to drop an error.

llvm-svn: 265311
2016-04-04 16:56:09 +00:00
Pete Cooper
2f6216c181 Use Expected<T> instead of ErrorOr<T>in yaml reader. NFC
llvm-svn: 264981
2016-03-31 01:13:04 +00:00
Pete Cooper
c6e7b8146a Convert readBinary to llvm::Error. NFC
llvm-svn: 264973
2016-03-30 23:58:24 +00:00
Pete Cooper
ec4e166a5a Convert normalized file to atoms methods to new error handling. NFC.
This converts almost all of the error handling in atom creation
to llvm::Error instead of std::error_code.

llvm-svn: 264968
2016-03-30 23:43:27 +00:00
Pete Cooper
8eaf62ca5d Fix MachO test which is failing on a Windows bot.
This is breaking http://lab.llvm.org:8011/builders/lld-x86_64-win7/builds/31647/steps/test%20lld/logs/stdio.

The issue seems to be that it can't write to a file in /tmp, probably because that path doesn't
exist on Windows.  This was failing after I added EXPECT_FALSE(ec) in r264961 for the error
handling migration.

llvm-svn: 264962
2016-03-30 23:28:49 +00:00
Pete Cooper
fefbd22814 Convert lld file writing to llvm::Error. NFC.
This converts the writeFile method, as well as some of the ones it calls
in the normalized binary file writer and yaml writer.

llvm-svn: 264961
2016-03-30 23:10:39 +00:00
Eugene Zelenko
2bf5ed5670 Fix Clang-tidy modernize-deprecated-headers warnings; other minor fixes.
Differential revision: http://reviews.llvm.org/D18232

llvm-svn: 263968
2016-03-21 18:32:35 +00:00
Rui Ueyama
a453c0a5ad Merge DarwinLdDriver and Driver.
Now that DarwinLdDriver is the only derived class of Driver.
This patch merges them and actually removed the class because
they can now just be non-member functions. This change simplifies
a common header, Driver.h.

http://reviews.llvm.org/D17788

llvm-svn: 262502
2016-03-02 19:08:05 +00:00
Rafael Espindola
3006daadb2 Fix BUILD_SHARED_LIBS build.
llvm-svn: 262485
2016-03-02 14:12:37 +00:00
Rui Ueyama
7a963bf02c Tidy up CMakefiles.
llvm-svn: 262434
2016-03-02 00:31:34 +00:00
Rafael Espindola
393877d51b Fix BUILD_SHARED_LIBS build.
llvm-svn: 262345
2016-03-01 15:56:53 +00:00
Rui Ueyama
3b9388f456 Remove DriverTest.h.
Because the class is used only by one instance, we do not have to
use template there in DriverTest.h. Everything can be moved to
DarwinLdDriverTest.cpp.

llvm-svn: 262192
2016-02-28 20:56:34 +00:00
Rui Ueyama
e7b330052f Move functionality of UniversalDriver to the entry point file.
UniversalDriver was used as a dispatcher to each platform-specific driver.
It had its own Options.td file. It was not just too much to parse only a
few options (we only want to parse -core, -flavor or argv[0]),
but also interpreted arguments too early. For example, if you invoke lld as
"lld -flavor gnu ... -help", then you'd get the UniversalDriver's help
message instead of GnuDriver's. This patch eliminates the use of Options
from the dispatcher.

http://reviews.llvm.org/D17686

llvm-svn: 262190
2016-02-28 19:50:14 +00:00
Rui Ueyama
18c6d313af Remove lld/Core/range.h.
IIUC, range was an experiment to see how N3350 would work in LLD.
It turned out it didn't get traction, and it is basically duplicate
of iterator_range in ADT. We have only two occurrences of range,
and all of them are easily rewritten without it.

http://reviews.llvm.org/D17687

llvm-svn: 262171
2016-02-28 04:03:01 +00:00
Rafael Espindola
3a4d0a7c17 Remove the old ELF linker.
I think it is clear by now that the new linker is viable.

llvm-svn: 262158
2016-02-28 00:10:58 +00:00
Pete Cooper
351164504a Add support for export_dynamic cmdline option and behaviour.
This option matches the behaviour of ld64, that is it prevents globals
from being dead stripped in executables and dylibs.

Reviewed by Lang Hames

Differential Revision: http://reviews.llvm.org/D16026

llvm-svn: 258554
2016-01-22 21:13:24 +00:00
Pete Cooper
6e319c7b42 Fix DarwinLdDriverTest.cpp to pass real llvm options.
After r255819, parse() actually parses what you pass it.

This test was failing because it passed '--debug-only' which isn't in
release builds, but also 'foo' which isn't an option at all.

We now pass -enable-tbaa and -enable-misched which are real options.

llvm-svn: 255822
2015-12-16 21:24:46 +00:00
Rafael Espindola
7477e99af7 Make ELF2 the default.
With this the only way to get the old elf linker is "-flavor old-elf".

llvm-svn: 253318
2015-11-17 07:19:44 +00:00
Rafael Espindola
97a8695aa1 Rename gnu2 to gnu.
This is the second step in making ELF2 the default.

llvm-svn: 253270
2015-11-16 23:21:55 +00:00
Simon Atanasyan
9638d7d162 [Mips] Support two more MIPS linking emulation options elf32btsmipn32/elf32ltsmipn32
llvm-svn: 246336
2015-08-28 21:39:13 +00:00