[PATCH] D21969: [ELF] - Implemented --fatal-warnings option.
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 6 11:15:50 PDT 2016
On Mon, Jul 4, 2016 at 5:56 AM, George Rimar <grimar at accesssoftek.com>
wrote:
> grimar created this revision.
> grimar added reviewers: ruiu, rafael.
> grimar added subscribers: llvm-commits, grimar.
>
> --fatal-warnings
> Treat warnings as errors
>
> Since we temporarily switched reporting of multiple declarations of
> symbols in
> version script from error to warning, this one option seems to be usefull
> to have.
> Also it is usefull itself I think.
>
> http://reviews.llvm.org/D21969
>
> Files:
> ELF/Config.h
> ELF/Driver.cpp
> ELF/Error.cpp
> ELF/Options.td
> test/ELF/fatal-warnings.s
>
> Index: test/ELF/fatal-warnings.s
> ===================================================================
> --- test/ELF/fatal-warnings.s
> +++ test/ELF/fatal-warnings.s
> @@ -0,0 +1,16 @@
> +# REQUIRES: x86
> +# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t1.o
> +# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux
> %p/Inputs/warn-common.s -o %t2.o
> +
> +# RUN: ld.lld --warn-common %t1.o %t2.o -o %t1.out
> +# RUN: llvm-readobj %t1.out > /dev/null 2>&1
> +
> +# RUN: not ld.lld --warn-common --fatal-warnings %t1.o %t2.o -o %t2.out
> 2>&1 | \
> +# RUN: FileCheck -check-prefix=ERR %s
> +# ERR: multiple common of
> +
> +.globl _start
> +_start:
> +
> +.type arr, at object
> +.comm arr,4,4
> Index: ELF/Options.td
> ===================================================================
> --- ELF/Options.td
> +++ ELF/Options.td
> @@ -66,6 +66,9 @@
> def export_dynamic_symbol: S<"export-dynamic-symbol">,
> HelpText<"Put a symbol in the dynamic symbol table">;
>
> +def fatal_warnings: F<"fatal-warnings">,
> + HelpText<"Treat warnings as errors">;
> +
> def fini: S<"fini">, MetaVarName<"<symbol>">,
> HelpText<"Specify a finalizer function">;
>
> @@ -232,7 +235,6 @@
> def allow_shlib_undefined: F<"allow-shlib-undefined">;
> def define_common: F<"define-common">;
> def detect_odr_violations: F<"detect-odr-violations">;
> -def fatal_warnings: F<"fatal-warnings">;
> def no_add_needed: F<"no-add-needed">;
> def no_allow_shlib_undefined: F<"no-allow-shlib-undefined">;
> def no_copy_dt_needed_entries: F<"no-copy-dt-needed-entries">,
> Index: ELF/Error.cpp
> ===================================================================
> --- ELF/Error.cpp
> +++ ELF/Error.cpp
> @@ -24,7 +24,12 @@
> llvm::outs() << Msg << "\n";
> }
>
> -void warning(const Twine &Msg) { llvm::errs() << Msg << "\n"; }
> +void warning(const Twine &Msg) {
> + if (Config->FatalWarnings)
> + error(Msg);
> + else
> + llvm::errs() << Msg << "\n";
>
You don't need `llvm::`.
> +}
>
> void error(const Twine &Msg) {
> *ErrorOS << Msg << "\n";
> Index: ELF/Driver.cpp
> ===================================================================
> --- ELF/Driver.cpp
> +++ ELF/Driver.cpp
> @@ -344,6 +344,7 @@
> Config->EhFrameHdr = Args.hasArg(OPT_eh_frame_hdr);
> Config->EnableNewDtags = !Args.hasArg(OPT_disable_new_dtags);
> Config->ExportDynamic = Args.hasArg(OPT_export_dynamic);
> + Config->FatalWarnings = Args.hasArg(OPT_fatal_warnings);
>
This needs to be done earlier, probably at beginning of LinkerDriver::main.
Otherwise, warnings before this line are not going to be handled as fatal
errors.
Config->GcSections = Args.hasArg(OPT_gc_sections);
> Config->ICF = Args.hasArg(OPT_icf);
> Config->NoGnuUnique = Args.hasArg(OPT_no_gnu_unique);
> Index: ELF/Config.h
> ===================================================================
> --- ELF/Config.h
> +++ ELF/Config.h
> @@ -81,6 +81,7 @@
> bool EhFrameHdr;
> bool EnableNewDtags;
> bool ExportDynamic;
> + bool FatalWarnings;
> bool GcSections;
> bool GnuHash = false;
> bool ICF;
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160706/8a56550e/attachment.html>
More information about the llvm-commits
mailing list