public inbox for pthreads-win32@sourceware.org
 help / color / mirror / Atom feed
From: Ross Johnson <Ross.Johnson@homemail.com.au>
To: pthreads-win32@sourceware.org
Subject: Re: Does static library works ?
Date: Sat, 07 Feb 2009 00:24:00 -0000	[thread overview]
Message-ID: <498CD498.1050303@homemail.com.au> (raw)
In-Reply-To: <20090206080622.86fffqqxcc4ws0k8@webmail.pioneerwireless.ca>

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"
>>>>
>>>>
>>>>
>
>

  reply	other threads:[~2009-02-07  0:24 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-02-06  9:53 Arnaud RICHARD
2009-02-06 10:11 ` MaaTt
2009-02-06 12:21   ` Arnaud RICHARD
2009-02-06 12:51   ` Arnaud RICHARD
2009-02-06 13:06     ` John E. Bossom
2009-02-07  0:24       ` Ross Johnson [this message]
2009-02-07  0:32         ` Ross Johnson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=498CD498.1050303@homemail.com.au \
    --to=ross.johnson@homemail.com.au \
    --cc=pthreads-win32@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).