From 3c2c36abf304d7c7138902a1819cad46073c7773 Mon Sep 17 00:00:00 2001 From: Bruno Santos 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/tools/build/v2/tools/clang-darwin.jam +++ b/tools/build/v2/tools/clang-darwin.jam @@ -54,10 +54,11 @@ rule init ( version ? : command * : options * ) command = [ common.get-invocation-command clang-darwin : clang++ : $(command) ] ; - # Determine the version + local bin ; local command-string = $(command:J=" ") ; if $(command) { + bin ?= [ common.get-absolute-tool-path $(command[1]) ] ; version ?= [ MATCH "^([0-9.]+)" : [ SHELL "$(command-string) -dumpversion" ] ] ; } @@ -69,6 +70,14 @@ rule init ( version ? : command * : options * ) gcc.init-link-flags clang-darwin darwin $(condition) ; + local archiver = + [ common.get-invocation-command clang-darwin + : libtool : [ feature.get-values : $(options) ] : $(bin) : search-path ] ; + flags clang-darwin.archive .LIBTOOL $(condition) : $(archiver[1]) ; + if $(.debug-configuration) + { + ECHO notice: using archiver for $(condition) at $(archiver[1]) ; + } } SPACE = " " ; @@ -116,50 +125,6 @@ actions compile.c++ "$(CONFIG_COMMAND)" -x c++ $(OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" $(FRAMEWORK_PATH) -c -o "$(<)" "$(>)" } -flags clang-darwin ARFLAGS ; - -# Default value. Mostly for the sake of clang-linux -# that inherits from gcc, but does not has the same -# logic to set the .AR variable. We can put the same -# logic in clang-linux, but that's hardly worth the trouble -# as on Linux, 'ar' is always available. -.AR = ar ; - -rule archive ( targets * : sources * : properties * ) -{ - # Always remove archive and start again. Here's rationale from - # Andre Hentz: - # - # I had a file, say a1.c, that was included into liba.a. - # I moved a1.c to a2.c, updated my Jamfiles and rebuilt. - # My program was crashing with absurd errors. - # After some debugging I traced it back to the fact that a1.o was *still* - # in liba.a - # - # Rene Rivera: - # - # Originally removing the archive was done by splicing an RM - # onto the archive action. That makes archives fail to build on NT - # when they have many files because it will no longer execute the - # action directly and blow the line length limit. Instead we - # remove the file in a different action, just before the building - # of the archive. - # - local clean.a = $(targets[1])(clean) ; - TEMPORARY $(clean.a) ; - NOCARE $(clean.a) ; - LOCATE on $(clean.a) = [ on $(targets[1]) return $(LOCATE) ] ; - DEPENDS $(clean.a) : $(sources) ; - DEPENDS $(targets) : $(clean.a) ; - common.RmTemps $(clean.a) : $(targets) ; -} - -actions piecemeal archive -{ - "$(.AR)" $(AROPTIONS) rc "$(<)" "$(>)" - "ranlib" -cs "$(<)" -} - flags clang-darwin.link USER_OPTIONS ; flags clang-darwin.link FRAMEWORK ; @@ -182,3 +147,8 @@ actions link.dll bind LIBRARIES { "$(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) } + +actions piecemeal archive +{ + "$(.LIBTOOL)" -static -o "$(<:T)" $(ARFLAGS) "$(>:T)" +} -- 1.7.9.4