Does static library works ?
Ross Johnson
Ross.Johnson@homemail.com.au
Sat Feb 7 00:32:00 GMT 2009
Just one more piece of information: the static lib _np routines are
actually the same ones as are called via DLLmain (in dll.c), so that
code is tested via the DLL tests.
Ross
Ross Johnson wrote:
> In the distributed sources there is just one test case (self1.c) that
> runs for the static case, and it checks that the library is able to
> perform an implicit creation of a POSIX thread handle, i.e. as the
> library will do whenever a POSIX thread routine that requires a POSIX
> handle is called from a Windows native thread. Pthread_self() is the
> only routine in the library where this is done and all other pthreads
> routines call it if required.
>
> There is one other check that should be done for static linking (but
> isn't), which is to check that the destructors, for TSD etc, actually
> run as required. Otherwise, as observed, all other functionality of
> the library is tested using the DLL version.
>
> I felt that repeating all the tests for the static case is a redundant
> exercise when the additional static functions rarely if ever change.
> If Richard has successfully run all the tests with his modified
> makefile without modifying the tests sources then the implicit
> resource create and destroy logic in the static library hasn't really
> been tested because only one or two tests actually result in implicit
> resource creation.
>
> Ross
>
> John E. Bossom wrote:
>> The mechanisms of the pthreads library where originally written to
>> take advantage of the Windows DllMain for implicitly
>> creating/releasing resources.
>> However, some didn't want to use the DLL... therefore the implicit
>> creation/destruction of resources (as well as the implicit invocation
>> of TSD optional destructors) must be carried out explicitly by the
>> user in the event that they want to use a static library. These
>> methods are _np (non portable).
>>
>> I would have expected that the test cases would have been
>> conditionally compiled to accommodate the testing of the static
>> version of the library...
>>
>> John E. Bossom
>>
>> Quoting Arnaud RICHARD <arnaud.richard@st.com>:
>>
>>> I have tried with MinGW.
>>> It doesn't pass either. (but pass in dynamic of course).
>>> So it is not due to something specific to MSVC.
>>>
>>> Looking more closely... I found out than some functions must be called
>>> only when linking statically:
>>> pthread_win32_process_attach_np()
>>> pthread_win32_process_detach_np()
>>> pthread_win32_thread_attach_np()
>>> pthread_win32_thread_detach_np()
>>>
>>> There is some explanations in the file README.NONPORTABLE
>>>
>>> It's the first time ever I see code specific to static linking...
>>> maybe because I'm a newbie on MS platform.
>>> I post this solution for future
>>>
>>> Arnaud
>>>
>>>> Arnaud RICHARD <arnaud.richard@st.com> wrote:
>>>>
>>>>> Dear developers,
>>>>>
>>>>> I tried to build my program statically with pthreads.lib.
>>>>> It crash at run-time in "pthread_cond_init()".
>>>>> So I tried to run the tests.
>>>>> First surprise: the test suite only run with DLL, and not with .LIB.
>>>>> I have enhanced the makefile to run the tests in static.
>>>>> Second surprise: most tests fails (but not all).
>>>>>
>>>>> Has anyone tried to do it ?
>>>>> I attached the modified makefile, the target to run is "make clean
>>>>> VC-static"
>>>>>
>>>>> Any feedback welcome,
>>>>> Arnaud
>>>>>
>>>>> PS: I use MSVC2008, and compile "VC-static"
>>>>>
>>>>>
>>>>>
>>
>>
>
More information about the Pthreads-win32
mailing list