Boost logo

Boost :

From: John Torjo (john.lists_at_[hidden])
Date: 2004-04-19 04:38:46


Dear boosters,

As far as I've heard a while back, the only reason [thread] library
cannot be built as a static library was because of TSS.

That to me (and to others as I've seen) seems quite a show-stopper - in
a lot of apps I don't use the [thread] lib just because of this. Most of
my multi-threaded applications (around 95%) and as I know a lot of other
multi-threaded apps. don't need TSS.

Even if they do, usually they don't need advanced clean-up code (reason
for why [thread] was required to be a DLL). ***Most*** of the time, any
allocated TSS objects can be let to leak resources (which they hardly
have - mostly IMHO some small amount of allocated memory).

The above make me think that we really should enable [thread] to be a
static library again ;). It should be documented in the docs that the
static version of the [thread] runtime will leak TSS objects, and users
can choose whether they will use [thread] as a DLL or as a runtime
static lib.

What do others think?

As a side-note, allowing the [thread] lib to be a static lib is quite
simple (please you gurus out there, correct me if I'm wrong). In fact,
here's the patch.

(note: config.hpp = boost/thread/detail/config.hpp, and I did not modify
the jamfile.V2, since I can't test it)

Best,
John


// Copyright (C) 2001-2003
// William E. Kempf
//
// Permission to use, copy, modify, distribute and sell this software
// and its documentation for any purpose is hereby granted without fee,
// provided that the above copyright notice appear in all copies and
// that both that copyright notice and this permission notice appear
// in supporting documentation. William E. Kempf makes no representations
// about the suitability of this software for any purpose.
// It is provided "as is" without express or implied warranty.

#ifndef BOOST_THREAD_CONFIG_WEK01032003_HPP
#define BOOST_THREAD_CONFIG_WEK01032003_HPP

#include <boost/config.hpp>

// insist on threading support being available:
#include <boost/config/requires_threads.hpp>

#if defined(BOOST_HAS_WINTHREADS)
# if defined(BOOST_THREAD_BUILD_DLL)
# define BOOST_THREAD_DECL __declspec(dllexport)
# elif defined(BOOST_DYN_LINK) // john.torjo
# define BOOST_THREAD_DECL __declspec(dllimport)
# else
# define BOOST_THREAD_DECL // linking to library
# endif
#else
# define BOOST_THREAD_DECL
#endif // BOOST_HAS_WINTHREADS

// john.torjo
/*
//
// Automatically link to the correct build variant where possible.
//
#if !defined(BOOST_ALL_NO_LIB) && !defined(BOOST_THREAD_NO_LIB) && !defined(BOOST_THREAD_BUILD_DLL)
//
// Set the name of our library, this will get undef'ed by auto_link.hpp
// once it's done with it:
//
#define BOOST_LIB_NAME boost_thread
//
// If we're importing code from a dll, then tell auto_link.hpp about it:
//
# define BOOST_DYN_LINK
//
// And include the header that does the work:
//
#include <boost/config/auto_link.hpp>
#endif // auto-linking disabled
*/

#endif // BOOST_THREAD_CONFIG_WEK1032003_HPP


# Copyright (C) 2001-2003
# William E. Kempf
#
# Permission to use, copy, modify, distribute and sell this software
# and its documentation for any purpose is hereby granted without fee,
# provided that the above copyright notice appear in all copies and
# that both that copyright notice and this permission notice appear
# in supporting documentation. William E. Kempf makes no representations
# about the suitability of this software for any purpose.
# It is provided "as is" without express or implied warranty.
#
# Boost.Threads build Jamfile
#
# Additional configuration variables used:
# 1. PTW32 may be used on Win32 platforms to specify that the pthreads-win32
# library should be used instead of "native" threads. This feature is
# mostly used for testing and it's generally recommended you use the
# native threading libraries instead. PTW32 should be set to be a list
# of two strings, the first specifying the installation path of the
# pthreads-win32 library and the second specifying which library
# variant to link against (see the pthreads-win32 documentation).
# Example: jam -sPTW32="c:\pthreads-win32 pthreadVCE.lib"

# Declare the location of this subproject relative to the root.
subproject libs/thread/build ;

# Include threads.jam for Boost.Threads global build information.
# This greatly simplifies the Jam code needed to configure the build
# for the various Win32 build types.
import ./threads ;

{
    template thread_libs
        ## sources ##
        : <template>thread_base
        ## requirements ##
        : <sysinclude>$(BOOST_ROOT)
        ## default build ##
        :
    ;

    # Base names of the source files for libboost_thread.
    CPP_SOURCES = condition mutex recursive_mutex thread tss xtime once
                  exceptions barrier threadmon ;

    lib boost_thread
        : <template>thread_libs ../src/$(CPP_SOURCES).cpp
        : <runtime-link>static
         # the common names rule ensures that the library will
         # be named according to the rules used by the install
         # and auto-link features:
         common-variant-tag
    ;

    dll boost_thread
        : <template>thread_libs ../src/$(CPP_SOURCES).cpp
        : <define>BOOST_THREAD_BUILD_DLL=1
          <runtime-link>dynamic
         # the common names rule ensures that the library will
         # be named according to the rules used by the install
         # and auto-link features:
         common-variant-tag
    ;

    stage bin-stage
        : <dll>boost_thread <lib>boost_thread
        #: <tag><debug>"d"
        : debug release
    ;

    install thread lib
        : <dll>boost_thread <lib>boost_thread
    ;
}


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk