Ticket #6684: clang-libtool.2.patch
File clang-libtool.2.patch, 3.6 KB (added by , 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 * ) 54 54 command = [ common.get-invocation-command clang-darwin : clang++ 55 55 : $(command) ] ; 56 56 57 # Determine the version57 local bin ; 58 58 local command-string = $(command:J=" ") ; 59 59 if $(command) 60 60 { 61 bin ?= [ common.get-absolute-tool-path $(command[1]) ] ; 61 62 version ?= [ MATCH "^([0-9.]+)" 62 63 : [ SHELL "$(command-string) -dumpversion" ] ] ; 63 64 } … … rule init ( version ? : command * : options * ) 69 70 70 71 gcc.init-link-flags clang-darwin darwin $(condition) ; 71 72 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 } 72 81 } 73 82 74 83 SPACE = " " ; … … actions compile.c++ 116 125 "$(CONFIG_COMMAND)" -x c++ $(OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" $(FRAMEWORK_PATH) -c -o "$(<)" "$(>)" 117 126 } 118 127 119 flags clang-darwin ARFLAGS <archiveflags> ;120 121 # Default value. Mostly for the sake of clang-linux122 # that inherits from gcc, but does not has the same123 # logic to set the .AR variable. We can put the same124 # logic in clang-linux, but that's hardly worth the trouble125 # 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 from131 # 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.a138 #139 # Rene Rivera:140 #141 # Originally removing the archive was done by splicing an RM142 # onto the archive action. That makes archives fail to build on NT143 # when they have many files because it will no longer execute the144 # action directly and blow the line length limit. Instead we145 # remove the file in a different action, just before the building146 # 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 archive158 {159 "$(.AR)" $(AROPTIONS) rc "$(<)" "$(>)"160 "ranlib" -cs "$(<)"161 }162 163 128 flags clang-darwin.link USER_OPTIONS <linkflags> ; 164 129 flags clang-darwin.link FRAMEWORK <framework> ; 165 130 … … actions link.dll bind LIBRARIES 182 147 { 183 148 "$(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) 184 149 } 150 151 actions piecemeal archive 152 { 153 "$(.LIBTOOL)" -static -o "$(<:T)" $(ARFLAGS) "$(>:T)" 154 }