[llvm] r291719 - Add -Wl, -color-diagnostics if a linker supports the option.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 5 15:18:47 PDT 2017


Do you know why it uses gold only for a particular link invocation?

On Mon, May 29, 2017 at 5:11 PM, Davide Italiano <davide at freebsd.org> wrote:

> On Wed, Jan 11, 2017 at 2:55 PM, Rui Ueyama via llvm-commits
> <llvm-commits at lists.llvm.org> wrote:
> > Author: ruiu
> > Date: Wed Jan 11 16:55:35 2017
> > New Revision: 291719
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=291719&view=rev
> > Log:
> > Add -Wl,-color-diagnostics if a linker supports the option.
> >
> > Differential Revision: https://reviews.llvm.org/D28046
> >
> > Added:
> >     llvm/trunk/cmake/modules/CheckLinkerFlag.cmake
> > Modified:
> >     llvm/trunk/cmake/modules/HandleLLVMOptions.cmake
> >
> > Added: llvm/trunk/cmake/modules/CheckLinkerFlag.cmake
> > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/cmake/
> modules/CheckLinkerFlag.cmake?rev=291719&view=auto
> > ============================================================
> ==================
> > --- llvm/trunk/cmake/modules/CheckLinkerFlag.cmake (added)
> > +++ llvm/trunk/cmake/modules/CheckLinkerFlag.cmake Wed Jan 11 16:55:35
> 2017
> > @@ -0,0 +1,8 @@
> > +include(CheckCXXCompilerFlag)
> > +
> > +function(check_linker_flag flag out_var)
> > +  set(OLD_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
> > +  set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${flag}")
> > +  check_cxx_compiler_flag("" ${out_var})
> > +  set(CMAKE_REQUIRED_FLAGS ${OLD_CMAKE_REQUIRED_FLAGS})
> > +endfunction()
> >
> > Modified: llvm/trunk/cmake/modules/HandleLLVMOptions.cmake
> > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/cmake/
> modules/HandleLLVMOptions.cmake?rev=291719&r1=291718&r2=291719&view=diff
> > ============================================================
> ==================
> > --- llvm/trunk/cmake/modules/HandleLLVMOptions.cmake (original)
> > +++ llvm/trunk/cmake/modules/HandleLLVMOptions.cmake Wed Jan 11
> 16:55:35 2017
> > @@ -597,6 +597,14 @@ if (UNIX AND
> >    append("-fcolor-diagnostics" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
> >  endif()
> >
> > +# lld doesn't print colored diagnostics when invoked from Ninja
> > +if (UNIX AND CMAKE_GENERATOR STREQUAL "Ninja")
> > +  include(CheckLinkerFlag)
> > +  check_linker_flag("-Wl,-color-diagnostics" LINKER_SUPPORTS_COLOR_
> DIAGNOSTICS)
> > +  append_if(LINKER_SUPPORTS_COLOR_DIAGNOSTICS "-Wl,-color-diagnostics"
> > +    CMAKE_EXE_LINKER_FLAGS CMAKE_MODULE_LINKER_FLAGS
> CMAKE_SHARED_LINKER_FLAGS)
> > +endif()
> > +
> >  # Add flags for add_dead_strip().
> >  # FIXME: With MSVS, consider compiling with /Gy and linking with
> /OPT:REF?
> >  # But MinSizeRel seems to add that automatically, so maybe disable these
> >
>
> This has the unfortunate side effect of breaking the swift build on
> FreeBSD.
> The link of `swift-demangle` fails with `unknown option -color-diagnostic`.
> It's the result of a series of events:
>
> 1) lld is used as system linker:
> $ ld --version
> LLD (not GNU) 5.0.0
> $ ld --help |grep colo
>   --color-diagnostics=<value>
>                           Use colors in diagnostics
>   --color-diagnostics     Use colors in diagnostics
>   --no-color-diagnostics  Do not use colors in diagnostics
>
> The particular build uses gold (so it passes around -fuse-ld=gold).
> Once that CMake check is hit, we think it passes (as it's tested with
> lld) but then we switch to gold and it fails.
> I'm not sure whether it's an issue in the `swift` build system or in
> your patch, but I wanted to make you aware of this.
>
> Thanks,
>
> --
> Davide
>
> "There are no solved problems; there are only problems that are more
> or less solved" -- Henri Poincare
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170605/a17cd69a/attachment.html>


More information about the llvm-commits mailing list