[lld] r325413 - Remove "--full-shutdown" and instead use an environment variable LLD_IN_TEST.
Rafael Avila de Espindola via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 16 17:47:32 PST 2018
Nice!
Thanks,
Rafael
Rui Ueyama via llvm-commits <llvm-commits at lists.llvm.org> writes:
> Author: ruiu
> Date: Fri Feb 16 15:41:48 2018
> New Revision: 325413
>
> URL: http://llvm.org/viewvc/llvm-project?rev=325413&view=rev
> Log:
> Remove "--full-shutdown" and instead use an environment variable LLD_IN_TEST.
>
> We are running lld tests with "--full-shutdown" option because we don't
> want to call _exit() in lld if it is running tests. Regular shutdown
> is needed for leak sanitizer.
>
> This patch changes the way how we tell lld that it is running tests.
> Now "--full-shutdown" is removed, and LLD_IN_TEST environment variable
> is used instead.
>
> This patch enables full shutdown on all ports, e.g. ELF, COFF and wasm.
> Previously, we enabled it only for ELF.
>
> Differential Revision: https://reviews.llvm.org/D43410
>
> Modified:
> lld/trunk/ELF/Config.h
> lld/trunk/ELF/Driver.cpp
> lld/trunk/ELF/Driver.h
> lld/trunk/ELF/Options.td
> lld/trunk/test/ELF/lto/timepasses.ll
> lld/trunk/test/lit.cfg.py
> lld/trunk/tools/lld/lld.cpp
>
> Modified: lld/trunk/ELF/Config.h
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Config.h?rev=325413&r1=325412&r2=325413&view=diff
> ==============================================================================
> --- lld/trunk/ELF/Config.h (original)
> +++ lld/trunk/ELF/Config.h Fri Feb 16 15:41:48 2018
> @@ -165,7 +165,6 @@ struct Configuration {
> bool ZRodynamic;
> bool ZText;
> bool ZRetpolineplt;
> - bool ExitEarly;
> bool ZWxneeded;
> DiscardPolicy Discard;
> OrphanHandlingPolicy OrphanHandling;
>
> Modified: lld/trunk/ELF/Driver.cpp
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Driver.cpp?rev=325413&r1=325412&r2=325413&view=diff
> ==============================================================================
> --- lld/trunk/ELF/Driver.cpp (original)
> +++ lld/trunk/ELF/Driver.cpp Fri Feb 16 15:41:48 2018
> @@ -77,7 +77,9 @@ bool elf::link(ArrayRef<const char *> Ar
> "too many errors emitted, stopping now (use "
> "-error-limit=0 to see all errors)";
> errorHandler().ErrorOS = &Error;
> + errorHandler().ExitEarly = CanExitEarly;
> errorHandler().ColorDiagnostics = Error.has_colors();
> +
> InputSections.clear();
> OutputSections.clear();
> Tar = nullptr;
> @@ -92,12 +94,12 @@ bool elf::link(ArrayRef<const char *> Ar
> Symtab = make<SymbolTable>();
> Config->ProgName = Args[0];
>
> - Driver->main(Args, CanExitEarly);
> + Driver->main(Args);
>
> // Exit immediately if we don't need to return to the caller.
> // This saves time because the overhead of calling destructors
> // for all globally-allocated objects is not negligible.
> - if (Config->ExitEarly)
> + if (CanExitEarly)
> exitLld(errorCount() ? 1 : 0);
>
> freeArena();
> @@ -309,7 +311,7 @@ static bool hasZOption(opt::InputArgList
> return false;
> }
>
> -void LinkerDriver::main(ArrayRef<const char *> ArgsArr, bool CanExitEarly) {
> +void LinkerDriver::main(ArrayRef<const char *> ArgsArr) {
> ELFOptTable Parser;
> opt::InputArgList Args = Parser.parse(ArgsArr.slice(1));
>
> @@ -347,9 +349,6 @@ void LinkerDriver::main(ArrayRef<const c
> if (Args.hasArg(OPT_version))
> return;
>
> - Config->ExitEarly = CanExitEarly && !Args.hasArg(OPT_full_shutdown);
> - errorHandler().ExitEarly = Config->ExitEarly;
> -
> if (const char *Path = getReproduceOption(Args)) {
> // Note that --reproduce is a debug option so you can ignore it
> // if you are trying to understand the whole picture of the code.
>
> Modified: lld/trunk/ELF/Driver.h
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Driver.h?rev=325413&r1=325412&r2=325413&view=diff
> ==============================================================================
> --- lld/trunk/ELF/Driver.h (original)
> +++ lld/trunk/ELF/Driver.h Fri Feb 16 15:41:48 2018
> @@ -26,7 +26,7 @@ extern class LinkerDriver *Driver;
>
> class LinkerDriver {
> public:
> - void main(ArrayRef<const char *> Args, bool CanExitEarly);
> + void main(ArrayRef<const char *> Args);
> void addFile(StringRef Path, bool WithLOption);
> void addLibrary(StringRef Name);
>
>
> Modified: lld/trunk/ELF/Options.td
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Options.td?rev=325413&r1=325412&r2=325413&view=diff
> ==============================================================================
> --- lld/trunk/ELF/Options.td (original)
> +++ lld/trunk/ELF/Options.td Fri Feb 16 15:41:48 2018
> @@ -144,9 +144,6 @@ defm fini: Eq<"fini">,
> def fix_cortex_a53_843419: F<"fix-cortex-a53-843419">,
> HelpText<"Apply fixes for AArch64 Cortex-A53 erratum 843419">;
>
> -def full_shutdown : F<"full-shutdown">, Flags<[HelpHidden]>,
> - HelpText<"Perform a full shutdown instead of calling _exit">;
> -
> defm format: Eq<"format">,
> HelpText<"Change the input format of the inputs following this option">,
> MetaVarName<"<input-format>">;
>
> Modified: lld/trunk/test/ELF/lto/timepasses.ll
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/lto/timepasses.ll?rev=325413&r1=325412&r2=325413&view=diff
> ==============================================================================
> --- lld/trunk/test/ELF/lto/timepasses.ll (original)
> +++ lld/trunk/test/ELF/lto/timepasses.ll Fri Feb 16 15:41:48 2018
> @@ -1,8 +1,7 @@
> -; We use lld -flavor gnu because llvm-lit will append --full-shutdown to
> -; the ld.lld invocation.
> ; REQUIRES: x86
> ; RUN: llvm-as %s -o %t.o
> -; RUN: lld -flavor gnu %t.o -o %t.so -shared -mllvm -time-passes 2>&1 | FileCheck %s
> +; RUN: env LLD_IN_TEST=0 ld.lld %t.o -o %t.so -shared -mllvm \
> +; RUN: -time-passes 2>&1 | FileCheck %s
>
> target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
> target triple = "x86_64-unknown-linux-gnu"
> @@ -11,5 +10,5 @@ define void @patatino() {
> ret void
> }
>
> -; We should get the output of -time-passes even when --full-shutdown is not specified.
> +; We should get the output of -time-passes even when full shutdown is not specified.
> ; CHECK: Total Execution Time
>
> Modified: lld/trunk/test/lit.cfg.py
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/lit.cfg.py?rev=325413&r1=325412&r2=325413&view=diff
> ==============================================================================
> --- lld/trunk/test/lit.cfg.py (original)
> +++ lld/trunk/test/lit.cfg.py Fri Feb 16 15:41:48 2018
> @@ -73,6 +73,7 @@ llvm_config.feature_config(
>
> # Set a fake constant version so that we get consitent output.
> config.environment['LLD_VERSION'] = 'LLD 1.0'
> +config.environment['LLD_IN_TEST'] = '1'
>
> # Indirectly check if the mt.exe Microsoft utility exists by searching for
> # cvtres, which always accompanies it. Alternatively, check if we can use
>
> Modified: lld/trunk/tools/lld/lld.cpp
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/tools/lld/lld.cpp?rev=325413&r1=325412&r2=325413&view=diff
> ==============================================================================
> --- lld/trunk/tools/lld/lld.cpp (original)
> +++ lld/trunk/tools/lld/lld.cpp Fri Feb 16 15:41:48 2018
> @@ -24,6 +24,7 @@
> #include "llvm/Support/Path.h"
> #include "llvm/Support/PrettyStackTrace.h"
> #include "llvm/Support/Signals.h"
> +#include <cstdlib>
>
> using namespace lld;
> using namespace llvm;
> @@ -102,6 +103,14 @@ static Flavor parseFlavor(std::vector<co
> return parseProgname(Arg0);
> }
>
> +// If this function returns true, lld calls _exit() so that it quickly
> +// exits without invoking destructors of globally allocated objects.
> +//
> +// We don't want to do that if we are running tests though, because
> +// doing that breaks leak sanitizer. So, lit sets this environment variable,
> +// and we use it to detect whether we are running tests or not.
> +static bool canExitEarly() { return StringRef(getenv("LLD_IN_TEST")) != "1"; }
> +
> /// Universal linker main(). This linker emulates the gnu, darwin, or
> /// windows linker based on the argv[0] or -flavor option.
> int main(int Argc, const char **Argv) {
> @@ -115,13 +124,13 @@ int main(int Argc, const char **Argv) {
> case Gnu:
> if (isPETarget(Args))
> return !mingw::link(Args);
> - return !elf::link(Args, true);
> + return !elf::link(Args, canExitEarly());
> case WinLink:
> - return !coff::link(Args, true);
> + return !coff::link(Args, canExitEarly());
> case Darwin:
> return !mach_o::link(Args);
> case Wasm:
> - return !wasm::link(Args, true);
> + return !wasm::link(Args, canExitEarly());
> default:
> die("lld is a generic driver.\n"
> "Invoke ld.lld (Unix), ld64.lld (macOS) or lld-link (Windows) instead.");
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
More information about the llvm-commits
mailing list