From 9ce942b0c5cb3e5bda209dd9dbf15e63ec5c4e59 Mon Sep 17 00:00:00 2001 From: Rene Rivera Date: Sun, 26 Mar 2006 06:28:51 +0000 Subject: [PATCH] Fixes for MinGW compilation. * Configuration prefers using the AR in the compiler specific bin dir. * Fix pre-delete of archives so it uses it's own action, and hence allows the archive action to be a single command. * That fixes the problem of command line limits on the CMD shell, for archives that have many source files. [SVN r33475] --- v2/tools/gcc.jam | 71 +++++++++++++++++++++++++++++++++--------------- 1 file changed, 49 insertions(+), 22 deletions(-) diff --git a/v2/tools/gcc.jam b/v2/tools/gcc.jam index 28ad9c0ae..6a05c9e6a 100644 --- a/v2/tools/gcc.jam +++ b/v2/tools/gcc.jam @@ -63,27 +63,38 @@ rule init ( version ? : command * : options * ) } init-link-flags gcc $(linker) $(condition) ; + local root = [ feature.get-values : $(options) ] ; + local bin ; + if $(command) + { + bin ?= [ common.get-absolute-tool-path $(command[-1]) ] ; + root ?= $(bin:D) ; + } + # If gcc is installed in non-standard location, we'd need to # add LD_LIBRARY_PATH when running programs created with it # (for unit-test/run rules). if $(command) { - local root = [ feature.get-values : $(options) ] ; - if ! $(root) - { - root = [ common.get-absolute-tool-path $(command[-1]) ] ; - root = $(root:D) ; - } local lib_path = $(root)/lib ; if $(.debug-configuration) { - ECHO "notice: gcc lib directory for version" $(condition) ; - ECHO "notice: is" $(lib_path) ; + ECHO notice: using gcc libraries :: $(condition) :: $(lib_path) ; } flags gcc.link RUN_PATH $(condition) : $(lib_path) ; } - + #~ If it's not a system gcc install we should adjust the various + #~ programs as needed to prefer using the install specific versions. + #~ This is essential for correct use of MinGW and for cross-compiling. + local archiver = + [ common.get-invocation-command gcc + : ar : [ feature.get-values : $(options) ] : $(bin) : PATH ] ; + flags gcc.archive .AR $(condition) : $(archiver[1]) ; + if $(.debug-configuration) + { + ECHO notice: using gcc archiver :: $(condition) :: $(archiver[1]) ; + } } if [ os.name ] = NT @@ -338,21 +349,38 @@ actions link bind LIBRARIES } -# 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 -RM = [ common.rm-command ] ; +flags gcc.archive AROPTIONS ; -if [ os.name ] = NT +rule archive ( targets * : sources * : properties * ) { - RM = "if exist \"$(<[1])\" DEL \"$(<[1])\"" ; + # 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) ; } - # Declare action for creating static libraries # The 'r' letter means to add files to the archive with replacement # Since we remove archive, we don't care about replacement, but @@ -362,8 +390,7 @@ if [ os.name ] = NT # some platforms, for whatever reasons. actions piecemeal archive { - $(RM) "$(<)" - ar rc "$(<)" "$(>)" + "$(.AR)" $(AROPTIONS) rc "$(<)" "$(>)" }