[llvm] r220198 - Revert r220174, "Always use -Wl, -gc-sections on our build."

Rafael EspĂ­ndola rafael.espindola at gmail.com
Mon Oct 20 14:37:51 PDT 2014


Thanks.

This was hitting a bfd ld bug. It was fixed by
-----------------------------------------------------------
commit 409ff343a402799563f71f938138b29f8baf7a1c
Author: Alan Modra <amodra at gmail.com>
Date:   Tue Nov 8 13:49:11 2011 +0000

        * elflink.c (bfd_elf_gc_mark_dynamic_ref_symbol): Mark syms in
        executables when export_dynamic.
------------------------------------------------------------

I think the first version to have the fix was 2.23.1 released 15 Nov 2012.

I will add a comment about it, but maybe we should just require a more
recent host linker?


On 20 October 2014 08:12, NAKAMURA Takumi <geek4civic at gmail.com> wrote:
> Author: chapuni
> Date: Mon Oct 20 07:12:21 2014
> New Revision: 220198
>
> URL: http://llvm.org/viewvc/llvm-project?rev=220198&view=rev
> Log:
> Revert r220174, "Always use -Wl,-gc-sections on our build."
>
> It dropped required functions for plugins with gnu ld 2.20 and 2.21.
>
>   Failing Tests (1):
>       LLVM :: Feature/load_module.ll
>
>   Hello: bin/opt: symbol lookup error: lib/LLVMHello.so: undefined symbol: _ZN4llvm11raw_ostream13write_escapedENS_9StringRefEb
>
>   Failing Tests (1):
>       Clang :: Frontend/plugins.c
>
>   error: unable to load plugin 'lib/PrintFunctionNames.so': 'lib/PrintFunctionNames.so: undefined symbol: _ZN5clang15PluginASTAction6anchorEv'
>
> I think we should inspect linker's version or behavior to introduce --gc-sections for --export-dynamic.
>
> Modified:
>     llvm/trunk/cmake/modules/AddLLVM.cmake
>
> Modified: llvm/trunk/cmake/modules/AddLLVM.cmake
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/cmake/modules/AddLLVM.cmake?rev=220198&r1=220197&r2=220198&view=diff
> ==============================================================================
> --- llvm/trunk/cmake/modules/AddLLVM.cmake (original)
> +++ llvm/trunk/cmake/modules/AddLLVM.cmake Mon Oct 20 07:12:21 2014
> @@ -141,18 +141,15 @@ function(add_llvm_symbol_exports target_
>  endfunction(add_llvm_symbol_exports)
>
>  function(add_dead_strip target_name)
> -  if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
> -    # ld64's implementation of -dead_strip breaks tools that use plugins.
> -    if(NOT LLVM_NO_DEAD_STRIP)
> +  if(NOT LLVM_NO_DEAD_STRIP)
> +    if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
>        set_property(TARGET ${target_name} APPEND_STRING PROPERTY
>                     LINK_FLAGS " -Wl,-dead_strip")
> +    elseif(NOT WIN32)
> +      # Object files are compiled with -ffunction-data-sections.
> +      set_property(TARGET ${target_name} APPEND_STRING PROPERTY
> +                   LINK_FLAGS " -Wl,--gc-sections")
>      endif()
> -  elseif(NOT WIN32)
> -    # Object files are compiled with -ffunction-data-sections.
> -    # On ELF --gc-sections handles --export-dynamic correctly, so we can always
> -    # use it.
> -    set_property(TARGET ${target_name} APPEND_STRING PROPERTY
> -                 LINK_FLAGS " -Wl,--gc-sections")
>    endif()
>  endfunction(add_dead_strip)
>
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits



More information about the llvm-commits mailing list