Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 4 May 2022 13:47:04 -0700
From:      John Baldwin <jhb@FreeBSD.org>
To:        sgk@troutmask.apl.washington.edu
Cc:        Ed Maste <emaste@freebsd.org>, FreeBSD Current <freebsd-current@freebsd.org>
Subject:   Re: Profiled libraries on freebsd-current
Message-ID:  <1ab2b5dc-c98b-5a4d-de34-7472e936d395@FreeBSD.org>
In-Reply-To: <YnLkTCl5GzqJFrvM@troutmask.apl.washington.edu>
References:  <Ymt%2BICLaQPxx2knx@troutmask.apl.washington.edu> <CAPyFy2CuSFd7zm8BvrWYDv%2BEgM0Ryz-bxwWNzUEMEkm0fruokA@mail.gmail.com> <Ym1XE9QSSvIy/4uo@troutmask.apl.washington.edu> <CAPyFy2AcKcT3NmpA5cs0WG4B7gPCJwdax%2BPp02YHEQBmJ10ZtQ@mail.gmail.com> <Ym6tJn60RmqQVsrv@troutmask.apl.washington.edu> <CAPyFy2DJp6ycnqsZMH%2B094B%2BhykYrF4T5PN3qHm9qogVkQm9dQ@mail.gmail.com> <YnAWvEvQaNgzTFYn@troutmask.apl.washington.edu> <80e38cf3-0d53-fce6-76e6-936c47d95c91@FreeBSD.org> <YnLZraesrXQJdgy3@troutmask.apl.washington.edu> <4b128639-f233-acfe-aeb4-5830aa973cb6@FreeBSD.org> <YnLkTCl5GzqJFrvM@troutmask.apl.washington.edu>

next in thread | previous in thread | raw e-mail | index | archive | help
On 5/4/22 1:38 PM, Steve Kargl wrote:
> On Wed, May 04, 2022 at 01:22:57PM -0700, John Baldwin wrote:
>> On 5/4/22 12:53 PM, Steve Kargl wrote:
>>> On Wed, May 04, 2022 at 11:12:55AM -0700, John Baldwin wrote:
>>>
>>> I don't know the entire FreeBSD ecosystem.  Do people
>>> use FreeBSD on embedded systems (e.g., nanobsd) where
>>> libthr may be stripped out?  Thus, --enable-threads=no
>>> is needed.
>>
>> If they do, they are also using a constrained userland and
>> probably are not shipping a GCC binary either.  However, it's
>> not clear to me what --enable-threads means.
>>
>> Does this enable -pthread as an option?  If so, that should
>> definitely just always be on.  It's still an option users have
>> to opt into via a command line flag and doesn't prevent
>> building non-threaded programs.
>>
>> If it's enabling use of threads at runtime within GCC itself,
>> I'd say that also should probably just be allowed to be on.
>>
>> I can't really imagine what else it might mean (and I doubt
>> it means the latter).
>>
> 
> AFAICT, it controls whether -lpthread is automatically added to
> the command line.  In the case of -pg, it is -lpthread_p.
> The relevant lines are
> 
> #ifdef FBSD_NO_THREADS
> #define FBSD_LIB_SPEC "							\
>    %{pthread: %eThe -pthread option is only supported on FreeBSD when gcc \
> is built with the --enable-threads configure-time option.}		\
>    %{!shared:								\
>      %{!pg: -lc}								\
>      %{pg:  -lc_p}							\
>    }"
> #else
> #define FBSD_LIB_SPEC "							\
>    %{!shared:								\
>      %{!pg: %{pthread:-lpthread} -lc}					\
>      %{pg:  %{pthread:-lpthread_p} -lc_p}				\
>    }									\
>    %{shared:								\
>      %{pthread:-lpthread} -lc						\
>    }"
> #endif
> 
> Ed is wondering if one can get rid of FBSD_NO_THREADS. With the
> pending removal of WITH_PROFILE, the above reduces to
> 
> #define FBSD_LIB_SPEC "                                                 \
>    %{!shared:                                                            \
>      %{pthread:-lpthread} -lc                                            \
>    }                                                                     \
>    %{shared:                                                             \
>      %{pthread:-lpthread} -lc                                            \
>    }"
> 
> If one can do the above, then freebsd-nthr.h is no longer needed
> and can be deleted and config.gcc's handling of --enable-threads
> can be updated/removed.

Ok, so it's just if -pthread is supported (%{pthread:-lpthread} only
adds -lpthread if -pthread was given on the command line).  That can just
be on all the time and Ed is correct that it is safe to remove the
FBSD_NO_THREADS case and assume it is always present instead.

-- 
John Baldwin



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1ab2b5dc-c98b-5a4d-de34-7472e936d395>