Ticket #6684: clang-libtool.2.patch

File clang-libtool.2.patch, 3.6 KB (added by Bruno Santos <bsantos@…>, 11 years ago)
  • tools/build/v2/tools/clang-darwin.jam

    From 3c2c36abf304d7c7138902a1819cad46073c7773 Mon Sep 17 00:00:00 2001
    From: Bruno Santos <bsantos@av.it.pt>
    Date: Thu, 15 Mar 2012 11:31:31 +0000
    Subject: [PATCH] Use libtool for the archiver
    
    libtool can handle LTO
    ---
     tools/build/v2/tools/clang-darwin.jam |   60 +++++++++------------------------
     1 file changed, 15 insertions(+), 45 deletions(-)
    
    diff --git a/tools/build/v2/tools/clang-darwin.jam b/tools/build/v2/tools/clang-darwin.jam
    index e43d933..b63f00d 100644
    a b rule init ( version ? : command * : options * )  
    5454    command = [ common.get-invocation-command clang-darwin : clang++
    5555        : $(command) ] ;
    5656
    57     # Determine the version
     57    local bin ;
    5858    local command-string = $(command:J=" ") ;
    5959    if $(command)
    6060    {   
     61        bin ?= [ common.get-absolute-tool-path $(command[1]) ] ;
    6162        version ?= [ MATCH "^([0-9.]+)"
    6263            : [ SHELL "$(command-string) -dumpversion" ] ] ;
    6364    }
    rule init ( version ? : command * : options * )  
    6970
    7071    gcc.init-link-flags clang-darwin darwin $(condition) ;
    7172
     73    local archiver =
     74        [ common.get-invocation-command clang-darwin
     75            : libtool : [ feature.get-values <archiver> : $(options) ] : $(bin) : search-path ] ;
     76    flags clang-darwin.archive .LIBTOOL $(condition) : $(archiver[1]) ;
     77    if $(.debug-configuration)
     78    {
     79        ECHO notice: using archiver for $(condition) at $(archiver[1]) ;
     80    }
    7281}
    7382
    7483SPACE = " " ;
    actions compile.c++  
    116125    "$(CONFIG_COMMAND)" -x c++ $(OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" $(FRAMEWORK_PATH) -c -o "$(<)" "$(>)"
    117126}
    118127
    119 flags clang-darwin ARFLAGS <archiveflags> ;
    120 
    121 # Default value. Mostly for the sake of clang-linux
    122 # that inherits from gcc, but does not has the same
    123 # logic to set the .AR variable. We can put the same
    124 # logic in clang-linux, but that's hardly worth the trouble
    125 # as on Linux, 'ar' is always available.
    126 .AR = ar ;
    127 
    128 rule archive ( targets * : sources * : properties * )
    129 {
    130   # Always remove archive and start again. Here's rationale from
    131   # Andre Hentz:
    132   #
    133   # I had a file, say a1.c, that was included into liba.a.
    134   # I moved a1.c to a2.c, updated my Jamfiles and rebuilt.
    135   # My program was crashing with absurd errors.
    136   # After some debugging I traced it back to the fact that a1.o was *still*
    137   # in liba.a
    138   #
    139   # Rene Rivera:
    140   #
    141   # Originally removing the archive was done by splicing an RM
    142   # onto the archive action. That makes archives fail to build on NT
    143   # when they have many files because it will no longer execute the
    144   # action directly and blow the line length limit. Instead we
    145   # remove the file in a different action, just before the building
    146   # of the archive.
    147   #
    148   local clean.a = $(targets[1])(clean) ;
    149   TEMPORARY $(clean.a) ;
    150   NOCARE $(clean.a) ;
    151   LOCATE on $(clean.a) = [ on $(targets[1]) return $(LOCATE) ] ;
    152   DEPENDS $(clean.a) : $(sources) ;
    153   DEPENDS $(targets) : $(clean.a) ;
    154   common.RmTemps $(clean.a) : $(targets) ;
    155 }
    156 
    157 actions piecemeal archive
    158 {
    159   "$(.AR)" $(AROPTIONS) rc "$(<)" "$(>)"
    160   "ranlib" -cs "$(<)"
    161 }
    162 
    163128flags clang-darwin.link USER_OPTIONS <linkflags> ;
    164129flags clang-darwin.link FRAMEWORK <framework> ;
    165130
    actions link.dll bind LIBRARIES  
    182147{
    183148    "$(CONFIG_COMMAND)" $(USER_OPTIONS) -L"$(LINKPATH)" -o "$(<)" -single_module -dynamiclib -install_name "$(<[1]:D=)" "$(>)"  "$(LIBRARIES)" -l$(FINDLIBS-SA) -l$(FINDLIBS-ST) $(FRAMEWORK_PATH) -framework$(SPACE)$(FRAMEWORK:D=:S=) $(OPTIONS)
    184149}
     150
     151actions piecemeal archive
     152{
     153  "$(.LIBTOOL)" -static -o "$(<:T)"  $(ARFLAGS)  "$(>:T)"
     154}