|
From: | Bob Friesenhahn |
Subject: | Re: libtool problem on FreeBSD 4.1 with -pthread |
Date: | Mon, 8 Nov 2004 10:39:50 -0600 (CST) |
On Mon, 8 Nov 2004, Ralf Wildenhues wrote:
A build system for a program that uses threads should compile _every_ _source_ _file_ with platform-appropriate CPPFLAGS (e.g. -D_REENTRANT -D_THREAD_SAFE).This is what the whole question boils down to. Even if the main program does not use threads (only a shared lib it uses), is it necessary for it to be compiled with those flags (as opposed to only be linked with)?
Usually. Linux seems to incorporate thread-safe errno and other features in single-threaded programs. Other operating systems may encounter situations where a thread-safe library uses thread-specific errno wrapper functions while the program and other libraries use a static global errno variable, leading to potentially improper behavior. Interfaces like stdio usually require special compilation since they rely on macros or may even change their binary interface. Under Solaris, many functions used to support thread-safety use "weak" linkage so if the pthread library is not supplied, the application runs with dummy versions which do nothing.
What we could do now, however, is complain if a library uses threads and the other program sources weren't compiled with the thread-safe flag. Not too brilliant, but better than nothing if at the end of your build it says
Sounds great, but it would incur the wrath of many. Violations of thread-safe principles are rampant.
Bob ====================================== Bob Friesenhahn address@hidden http://www.simplesystems.org/users/bfriesen
[Prev in Thread] | Current Thread | [Next in Thread] |