From 05f8783fb2d196a11fa8ecd404d3043ed8f80854 Mon Sep 17 00:00:00 2001 From: Vladimir Prus Date: Mon, 23 Aug 2004 12:40:23 +0000 Subject: [PATCH] Fix the static property on gcc. [SVN r24665] --- v2/test/searched_lib.py | 2 +- v2/tools/gcc.jam | 54 ++++++++++++++++++++++++++++++++++++++--- 2 files changed, 51 insertions(+), 5 deletions(-) diff --git a/v2/test/searched_lib.py b/v2/test/searched_lib.py index 8d1eca4f2..7e6cc5d76 100644 --- a/v2/test/searched_lib.py +++ b/v2/test/searched_lib.py @@ -134,7 +134,7 @@ t.write("a.cpp", "") t.write("Jamfile", """ project a : requirements static ; -lib a : a.cpp l ; +static-lib a : a.cpp l ; lib l : : l_f ; """) diff --git a/v2/tools/gcc.jam b/v2/tools/gcc.jam index d89e40278..b64e80696 100644 --- a/v2/tools/gcc.jam +++ b/v2/tools/gcc.jam @@ -99,6 +99,51 @@ actions compile.c "$(CONFIG_COMMAND)" $(LANG) -Wall $(OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -c -o "$(<)" "$(>)" } +# The class which check that we don't try to use +# the static property while creating or using shared library, +# since it's not supported by gcc/libc. +class gcc-linking-generator : unix-linking-generator +{ + rule generated-targets ( sources + : property-set : project name ? ) + { + if static in [ $(property-set).raw ] + { + local m ; + if [ id ] = "gcc.link.dll" + { + m = "on gcc, DLL can't be build with static" ; + } + if ! $(m) { + for local s in $(sources) + { + local type = [ $(s).type ] ; + if $(type) && [ type.is-derived $(type) SHARED_LIB ] + { + m = "on gcc, using DLLS together with the static options is not possible " ; + } + } + } + if $(m) + { + errors.user-error $(m) : + "it's suggested to use static together with the static" ; + } + + } + + return [ unix-linking-generator.generated-targets + $(sources) : $(property-set) : $(property-set) $(name) ] ; + } +} + +generators.register [ new gcc-linking-generator gcc.link : LIB OBJ : EXE + : gcc ] ; + +generators.register [ new gcc-linking-generator gcc.link.dll : LIB OBJ : SHARED_LIB + : gcc ] ; + + + # Declare flags and action for linking flags gcc.link OPTIONS on : -g ; @@ -113,8 +158,9 @@ flags gcc.link LINKPATH ; flags gcc.link FINDLIBS-ST ; flags gcc.link FINDLIBS-SA ; flags gcc.link LIBRARIES ; -flags gcc.link LINK-RUNTIME static : static ; -flags gcc.link LINK-RUNTIME shared : dynamic ; +# For static we made sure there are no dynamic libraries +# in the link +flags gcc.link OPTIONS static : -static ; flags gcc.link RPATH ; flags gcc.link RPATH_LINK ; @@ -131,7 +177,7 @@ rule link ( targets * : sources * : properties * ) actions link bind LIBRARIES { - "$(CONFIG_COMMAND)" $(OPTIONS) -L"$(LINKPATH)" -Wl,-R$(SPACE)-Wl,"$(RPATH)" -Wl,-rpath-link$(SPACE)-Wl,"$(RPATH_LINK)" -o "$(<)" "$(>)" "$(LIBRARIES)" -Wl,-Bdynamic -l$(FINDLIBS-SA) -Wl,-Bstatic -l$(FINDLIBS-ST) -Wl,-B$(LINK-RUNTIME) + "$(CONFIG_COMMAND)" $(OPTIONS) -L"$(LINKPATH)" -Wl,-R$(SPACE)-Wl,"$(RPATH)" -Wl,-rpath-link$(SPACE)-Wl,"$(RPATH_LINK)" -o "$(<)" "$(>)" "$(LIBRARIES)" -l$(FINDLIBS-ST) -l$(FINDLIBS-SA) } # Declare action for creating static libraries @@ -149,7 +195,7 @@ rule link.dll ( targets * : sources * : properties * ) # Differ from 'link' above only by -shared. actions link.dll bind LIBRARIES { - "$(CONFIG_COMMAND)" $(OPTIONS) -L"$(LINKPATH)" -Wl,-R$(SPACE)-Wl,"$(RPATH)" -o "$(<)" -Wl,-h$(SPACE)-Wl,$(<[1]:D=) -shared "$(>)" "$(LIBRARIES)" -Wl,-Bdynamic -l$(FINDLIBS-SA) -Wl,-Bstatic -l$(FINDLIBS-ST) -Wl,-B$(LINK-RUNTIME) + "$(CONFIG_COMMAND)" $(OPTIONS) -L"$(LINKPATH)" -Wl,-R$(SPACE)-Wl,"$(RPATH)" -o "$(<)" -Wl,-h$(SPACE)-Wl,$(<[1]:D=) -shared "$(>)" "$(LIBRARIES)" -l$(FINDLIBS-ST) -l$(FINDLIBS-SA) } # Set up threading support. It's somewhat contrived, so perform it at the end,