aboutsummaryrefslogtreecommitdiff
path: root/lib/libthr/Makefile
Commit message (Collapse)AuthorAgeFilesLines
* libthr.so: mark as -z initfirstKonstantin Belousov2025-05-061-0/+1
| | | | | | | PR: 286537 Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D50133
* Retire MK_PROFILE infrastructureEd Maste2024-11-121-3/+0
| | | | | | | | | | It was disabled by default in fe52b7f60ef4. We planned to (but did not) remove the option before FreeBSD 14. Remove it now, for FreeBSD 15. Relnotes: Yes Reviewed by: imp Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D31558
* Remove residual blank line at start of MakefileWarner Losh2024-07-151-1/+0
| | | | | | | This is a residual of the $FreeBSD$ removal. MFC After: 3 days (though I'll just run the command on the branches) Sponsored by: Netflix
* rtld: actually resolve memcpy pltRyan Libby2024-07-071-0/+4
| | | | | | | | | | The call to memcpy() meant to cause plt resolution in _thr_rtld_init() was getting optimized by the compiler. Tell the compiler not to use its builtins in thr_rtld.c. We could avoid just the memcpy builtin but disabling all will be more robust against future changes. Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D45891
* Add a build knob for _FORTIFY_SOURCEKyle Evans2024-05-131-0/+3
| | | | | | | | | | | | | | | | | In the future, we will Default to _FORTIFY_SOURCE=2 if SSP is enabled, otherwise default to _FORTIFY_SOURCE=0. For now we default it to 0 unconditionally to ease bisect across older versions without the new symbols, and we'll put out a call for testing. include/*.h include their ssp/*.h equivalents as needed based on the knob. Programs and users are allowed to override FORTIFY_SOURCE in their Makefiles or src.conf/make.conf to force it off. Reviewed by: des, markj Relnotes: yes Sponsored by: Stormshield Sponsored by: Klara, Inc. Differential Revision: https://reviews.freebsd.org/D32308
* libthr: remove explicit sys/cdefs.h includesKonstantin Belousov2024-03-061-5/+0
| | | | | Sponsored by: The FreeBSD Foundation MFC after: 1 week
* lib{c,thr}: add DT_RUNPATH for gcc -m32Brooks Davis2024-02-191-0/+5
| | | | | | | | | | | | To allow gcc -m32 to work, link libc and libthr with --rpath-/usr/lib32. When called with -m32, gcc is currently unable to communicate to the bfd linker that it should look in /usr/lib32 to resolve needed (as opposed to explicitly linked) libraries so we need to provide a hint. See also: https://sourceware.org/bugzilla/show_bug.cgi?id=31395 Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D43910
* lib{c,sys}: move auxargs more firmly into libsysBrooks Davis2024-02-191-0/+2
| | | | | | | | | | | | | | | | | Continue to filter the public interface (elf_aux_info()), but entierly relocate the private interfaces (_elf_aux_info(), __init_elf_aux_vector(), and __elf_aux_vector) to libsys. This ensures that rtld updates the correct (only) copy of __elf_aux_vector. After 968a18975adc9c2a619bb52aa2f009de99fc9e24 updates were confused and __getosreldate was failing, causing the system to fall back to compat compat12 syscalls in some cases. Return to explicitly linking libc to libsys and link libthr with libc and libsys (in that order). Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D43910
* libthr: filter rather than link with libsysBrooks Davis2024-02-071-3/+2
| | | | | | | | | | | | | | The allows gcc + GNU ld to link programs with -m32 -pthread without erroring out due to _umtx_op_err being undefined (unless -lsys is added to the link command. We now always link _umtx_op_err into libthr (not just when it's static) and filter it with libsys so we call that implementation. The dynamic implementations (at least the assembly ones) should likely become stubs as a further refinement. Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D43783
* libthr: move _umtx_op_err() to libsysBrooks Davis2024-02-051-0/+11
| | | | | | | | | | | Declare in sys/umtx.h and implement in libsys. Explicitly link libthr with libsys. When building libthr static include _umtx_op_err so we don't break static linkage with -lpthread. Reviewed by: kib, emaste, imp Pull Request: https://github.com/freebsd/freebsd-src/pull/908
* Remove $FreeBSD$: one-line sh patternWarner Losh2023-08-161-1/+0
| | | | Remove /^\s*#[#!]?\s*\$FreeBSD\$.*$\n/
* libthr: Add src.conf variable WITHOUT_PTHREADS_ASSERTIONSGreg Becker2023-07-071-0/+2
| | | | | | | | | | | | | | This patch fixes a bug which prevents building libthr without _PTHREADS_INVARIANTS defined. The default remains to build libthr with -D_PTHREADS_INVARIANTS. However, with this patch, if one builds libthr with WITHOUT_PTHREADS_ASSERTIONS=true then the latency to acquire+release a default pthread mutex is reduced by roughly 5%, and a robust mutex by roughly 18% (as measured by a simple synthetic test on a Xeon E5-2697a based machine). Reviewed by: jhb, kib, mjg MFC after: 1 week Differential revision: https://reviews.freebsd.org/D40900
* libthr: Disable stack unwinding on ARM.John Baldwin2022-02-101-0/+4
| | | | | | | | | | | | | | | | When a thread exits, _Unwind_ForcedUnwind() is used to walk up stack frames executing pending cleanups pushed by pthread_cleanup_push(). The cleanups are popped by thread_unwind_stop() which is passed as a callback function to _Unwind_ForcedUnwind(). LLVM's libunwind uses a different function type for the callback on 32-bit ARM relative to all other platforms. The previous unwind.h header (as well as the unwind.h from libcxxrt) use the non-ARM type on all platforms, so this has likely been broken on 32-bit arm since it switched to using LLVM's libunwind. For now, just disable stack unwinding on 32-bit arm to unbreak the build until a proper fix is tested.
* Install unwind.h into /usr/includeJohn Baldwin2022-02-101-1/+0
| | | | | | | | | | | | Install headers from LLVM's libunwind in place of the headers from libcxxrt and allow C applications to use the library. As part of this, remove include/unwind.h and switch libthr over to using the installed unwind.h. Reviewed by: dim, emaste MFC after: 10 days Differential Revision: https://reviews.freebsd.org/D34065
* libthr: work around an ASAN false-positiveAlex Richardson2021-08-021-0/+6
| | | | | | | | | | | | | | | | | | | | | | | I got the following error with an ASAN-instrument libthr: ==803==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7fffffffcdb0 at pc 0x000801863396 bp 0x7ff8 READ of size 4 at 0x7fffffffcdb0 thread T0 #0 0x801863395 in handle_signal /local/scratch/alr48/cheri/freebsd/lib/libthr/thread/thr_sig.c:262:2 #1 0x801860da2 in thr_sighandler /local/scratch/alr48/cheri/freebsd/lib/libthr/thread/thr_sig.c:246:2 Address 0x7fffffffcdb0 is located in stack of thread T0 at offset 208 in frame #0 0x80186080f in thr_sighandler /local/scratch/alr48/cheri/freebsd/lib/libthr/thread/thr_sig.c:213 This frame has 1 object(s): [32, 64) 'act' (line 216) <== Memory access at offset 208 overflows this variable HINT: this may be a false positive if your program uses some custom stack This seems like a false-positive since the line in question is `SIGSETOR(actp->sa_mask, ucp->uc_sigmask);` and it complains about a read operation (from the ucontext_t argument) so this indicates to me that ASAN does not understand that thr_sighandler() is a signal handler. Differential Revision: https://reviews.freebsd.org/D31074
* Don't add -Winline for WARNS=6Alex Richardson2021-03-221-1/+0
| | | | | | | | | | | | | | This warning is very rarely useful (inline is a hint and not mandatory). This flag results in many warnings being printed when compiling C++ code that uses the standard library with GCC. This flag was originally added in back in r94332 but the flag is a no-op in Clang ("This diagnostic flag exists for GCC compatibility, and has no effect in Clang"). Removing it should make the GCC build output slightly more readable. Reviewed By: jrtc27, imp Differential Revision: https://reviews.freebsd.org/D29235
* Remove tests for obsolete compilers in the build systemEric van Gyzen2020-05-121-3/+0
| | | | | | | | | | | | | | Assume gcc is at least 6.4, the oldest xtoolchain in the ports tree. Assume clang is at least 6, which was in 11.2-RELEASE. Drop conditions for older compilers. Reviewed by: imp (earlier version), emaste, jhb MFC after: 2 weeks Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D24802 Notes: svn path=/head/; revision=360964
* Fix initial exec TLS mode for dynamically loaded shared objects.Konstantin Belousov2019-03-291-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | If dso uses initial exec TLS mode, rtld tries to allocate TLS in static space. If there is no space left, the dlopen(3) fails. If space if allocated, initial content from PT_TLS segment is distributed to all threads' pcbs, which was missed and caused un-initialized TLS segment for such dso after dlopen(3). The mode is auto-detected either due to the relocation used, or if the DF_STATIC_TLS dynamic flag is set. In the later case, the TLS segment is tried to allocate earlier, which increases chance of the dlopen(3) to succeed. LLD was recently fixed to properly emit the flag, ld.bdf did it always. Initial test by: dumbbell Tested by: emaste (amd64), ian (arm) Tested by: Gerald Aryeetey <aryeeteygerald_rogers.com> (arm64) Sponsored by: The FreeBSD Foundation MFC after: 2 weeks Differential revision: https://reviews.freebsd.org/D19072 Notes: svn path=/head/; revision=345703
* revert r341429 "disable BIND_NOW in libc, libthr, and rtld"Ed Maste2019-03-281-1/+0
| | | | | | | | | | | r345620 by kib@ fixed the rtld issue that caused a crash at startup during resolution of libc's ifuncs with BIND_NOW. PR: 233333 Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=345625
* Rename rtld-elf/malloc.c to rtld-elf/rtld_malloc.c.Konstantin Belousov2019-01-301-2/+2
| | | | | | | | | | Then malloc.c file name is too generic to use it for libthr.a. Sponsored by: The FreeBSD Foundation MFC after: 13 days Notes: svn path=/head/; revision=343580
* Untangle jemalloc and mutexes initialization.Konstantin Belousov2019-01-291-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | The need to use libc malloc(3) from some places in libthr always caused issues. For instance, per-thread key allocation was switched to use plain mmap(2) to get storage, because some third party mallocs used keys for implementation of calloc(3). Even more important, libthr calls calloc(3) during initialization of pthread mutexes, and jemalloc uses pthread mutexes. Jemalloc provides some way to both postpone the initialization, and to make initialization to use specialized allocator, but this is very fragile and often breaks. See the referenced PR for another example. Add the small malloc implementation used by rtld, to libthr. Use it in thr_spec.c and for mutexes initialization. This avoids the issues with mutual dependencies between malloc and libthr in principle. The drawback is that some more allocations are not interceptable for alternate malloc implementations. There should be not too much memory use from this allocator, and the alternative, direct use of mmap(2) is obviously worse. PR: 235211 MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential revision: https://reviews.freebsd.org/D18988 Notes: svn path=/head/; revision=343566
* disable BIND_NOW in libc, libthr, and rtldEd Maste2018-12-031-0/+1
| | | | | | | | | | | | | | | An issue remains with BIND_NOW and processes using threads. For now, restore libc's BIND_NOW disable, and also disable BIND_NOW in rtld and libthr. A patch is in review (D18400) that likely fixes this issue, but just disable BIND_NOW pending further testing after it is committed. PR: 233333 Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=341429
* Remove references to the LIBC_SCCS and SYSLIBC_SCCS C macros.John Baldwin2018-05-231-4/+1
| | | | | | | | | This language dates back to when libthr was libc_r that included its own syscalls and replaced libc entirely. It hasn't been relevant for a long time. Notes: svn path=/head/; revision=334107
* Add HAS_TESTS to all Makefiles that are currently using theEnji Cooper2017-08-021-0/+1
| | | | | | | | | `SUBDIR.${MK_TESTS}+= tests` idiom. This is a follow up to r321912. Notes: svn path=/projects/make-check-sandbox/; revision=321914
* Convert traditional ${MK_TESTS} conditional idiom for including testEnji Cooper2017-08-021-3/+1
| | | | | | | | | | | | | | directories to SUBDIR.${MK_TESTS} idiom This is being done to pave the way for future work (and homogenity) in ^/projects/make-check-sandbox . No functional change intended. MFC after: 1 weeks Notes: svn path=/head/; revision=321912
* libthr: increase WARNS to the default (6)Eric van Gyzen2017-05-261-1/+1
| | | | | | | | | | | | ...and silence cast-align warnings from gcc. Reviewed by: kib MFC after: 3 days Sponsored by: Dell EMC Differential Revision: https://reviews.freebsd.org/D10935 Notes: svn path=/head/; revision=318956
* Revert r318583 (libthr: use default WARNS level of 6)Eric van Gyzen2017-05-221-0/+1
| | | | | | | | | | | | Revert this while I fix RISC-V, SPARC, and probably all architectures that use GCC. Reported by: kib Pointy hat to: vangyzen Sponsored by: Dell EMC Notes: svn path=/head/; revision=318641
* libthr: Use CLI flags instead of pragmas to disable warningsEric van Gyzen2017-05-201-0/+6
| | | | | | | | | | | | | | | | | | People tweaking the build system or compilers tend to look into the Makefile and not into the source. Having some warning controls in the Makefile and some in the source code is surprising. Pragmas have the advantage that they leave the warnings enabled for more code, but that advantage isn't very relevant in these cases. Requested by: kib Reviewed by: kib MFC after: 3 days Sponsored by: Dell EMC Differential Revision: https://reviews.freebsd.org/D10832 Notes: svn path=/head/; revision=318584
* libthr: use default WARNS level of 6Eric van Gyzen2017-05-201-1/+0
| | | | | | | | | | Reviewed by: kib MFC after: 3 days Sponsored by: Dell EMC Differential Revision: https://reviews.freebsd.org/D10832 Notes: svn path=/head/; revision=318583
* libthr: disable thread-safety warningsEric van Gyzen2017-05-201-0/+1
| | | | | | | | | | | | | These warnings don't make sense for code that implements the locking primitives. Reviewed by: kib MFC after: 3 days Sponsored by: Dell EMC Differential Revision: https://reviews.freebsd.org/D10832 Notes: svn path=/head/; revision=318580
* Use SRCTOP-relative paths to other directories instead of .CURDIR-relative onesEnji Cooper2017-01-201-6/+6
| | | | | | | | | | This implifies pathing in make/displayed output MFC after: 3 weeks Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=312474
* MFHGlen Barber2016-04-041-1/+1
|\ | | | | | | | | | | | | Sponsored by: The FreeBSD Foundation Notes: svn path=/projects/release-pkg/; revision=297567
| * Fix typo.Konstantin Belousov2016-03-211-1/+1
| | | | | | | | | | | | | | MFC after: 3 days Notes: svn path=/head/; revision=297137
| * Revert r284417 it is not necessary anymoreBaptiste Daroussin2015-06-151-1/+1
| | | | | | | | Notes: svn path=/head/; revision=284421
| * Enforce overwritting SHLIBDIRBaptiste Daroussin2015-06-151-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | Since METAMODE has been added, sys.mk loads bsd.mkopt.mk which ends load loading bsd.own.mk which then defines SHLIBDIR before all the Makefile.inc everywhere. This makes /lib being populated again. Reported by: many Notes: svn path=/head/; revision=284417
* | Remove libc, librtld_db, libthr packages, and further increaseGlen Barber2016-02-051-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | the constraints on what needs to be installed in a specific to maintain consistency during upgrades. Create a new clibs package containing libraries that are needed as a bare minimum for consistency. With much help and input from: kib Sponsored by: The FreeBSD Foundation Notes: svn path=/projects/release-pkg/; revision=295337
* | First pass through library packaging.Glen Barber2016-02-041-0/+1
|/ | | | | | | Sponsored by: The FreeBSD Foundation Notes: svn path=/projects/release-pkg/; revision=295278
* Build/install libc, librt, libthr, and msun NetBSD test suites on allEnji Cooper2015-04-271-1/+3
| | | | | | | | | architectures MFC after: 1 week Notes: svn path=/head/; revision=282057
* The lseek(2), mmap(2), truncate(2), ftruncate(2), pread(2), andKonstantin Belousov2015-04-181-4/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | pwrite(2) syscalls are wrapped to provide compatibility with pre-7.x kernels which required padding before the off_t parameter. The fcntl(2) contains compatibility code to handle kernels before the struct flock was changed during the 8.x CURRENT development. The shims were reasonable to allow easier revert to the older kernel at that time. Now, two or three major releases later, shims do not serve any purpose. Such old kernels cannot handle current libc, so revert the compatibility code. Make padded syscalls support conditional under the COMPAT6 config option. For COMPAT32, the syscalls were under COMPAT6 already. Remove WITHOUT_SYSCALL_COMPAT build option, which only purpose was to (partially) disable the removed shims. Reviewed by: jhb, imp (previous versions) Discussed with: peter Sponsored by: The FreeBSD Foundation MFC after: 1 week Notes: svn path=/head/; revision=281714
* Merge all the copies of _tcb_ctor and _tcb_dtor.Andrew Turner2015-01-211-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The amd64, i386, and sparc64 versions were identical, with the one difference where the former two used inline asm instead of _tcb_get. I have compared the function before and after replacing the asm with _tcb_get and found the object files to be identical. The arm, mips, and powerpc versions were almost identical. The only difference was the powerpc version used an alignment of 1 where arm and mips used 16. As this is an increase in alignment is will be safe. Along with this arm, mips, and powerpc all passed, when initial was true, the value returned from _tcb_get as the first argument to _rtld_allocate_tls. This would then return this pointer back to the caller. We can remove these extra calls by checking if initial is set and setting the thread control block directly. As this is what the sparc64 code does we can use it directly. As after these observations all the architectures can now have identical code we can merge them into a common file. Differential Revision: https://reviews.freebsd.org/D1556 Reviewed by: kib Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=277490
* Fix known issues which blow up the process after dlopen("libthr.so")Konstantin Belousov2015-01-031-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (or loading a dso linked to libthr.so into process which was not linked against threading library). - Remove libthr interposers of the libc functions, including __error(). Instead, functions calls are indirected through the interposing table, similar to how pthread stubs in libc are already done. Libc by default points either to syscall trampolines or to existing libc implementations. On libthr load, libthr rewrites the pointers to the cancellable implementations already in libthr. The interposition table is separate from pthreads stubs indirection table to not pull pthreads stubs into static binaries. - Postpone the malloc(3) internal mutexes initialization until libthr is loaded. This avoids recursion between calloc(3) and static pthread_mutex_t initialization. - Reinstall signal handlers with wrapper on libthr load. The _rtld_is_dlopened(3) is used to avoid useless calls to sigaction(2) when libthr is statically referenced from the main binary. In the process, fix openat(2), swapcontext(2) and setcontext(2) interposing. The libc symbols were exported at different versions than libthr interposers. Export both libc and libthr versions from libc now, with default set to the higher version from libthr. Remove unused and disconnected swapcontext(3) userspace implementation from libc/gen. No objections from: deischen Tested by: pho, antoine (exp-run) (previous versions) Sponsored by: The FreeBSD Foundation MFC after: 1 week Notes: svn path=/head/; revision=276630
* Add reachover Makefiles for contrib/netbsd-tests/lib/libpthread asEnji Cooper2014-11-161-0/+2
| | | | | | | | | | | | | | | lib/libthr/tests A variant of this code has been tested on amd64/i386 for some time by EMC/Isilon on 10-STABLE/11-CURRENT. It builds on other architectures, but the code will remain off until it's proven it works on virtual hardware or real hardware on other architectures Original work by: pho Sponsored by: EMC / Isilon Storage Division Notes: svn path=/head/; revision=274578
* Use src.opts.mk in preference to bsd.own.mk except where we need stuffWarner Losh2014-05-061-1/+1
| | | | | | | from the latter. Notes: svn path=/head/; revision=265420
* Convert from WITHOUT_SYSCALL_COMPAT to MK_SYSCALL_COMPAT.Warner Losh2014-04-051-1/+1
| | | | Notes: svn path=/head/; revision=264155
* Oops, don't remove -fexceptions flag.David Xu2010-10-081-0/+1
| | | | Notes: svn path=/head/; revision=213541
* unwind.h was imported, gcc directory is no longer needed.David Xu2010-10-081-1/+0
| | | | Notes: svn path=/head/; revision=213539
* To support stack unwinding for cancellation points, add -fexceptions flagDavid Xu2010-09-251-3/+1
| | | | | | | | | | for them, two functions _pthread_cancel_enter and _pthread_cancel_leave are added to let thread enter and leave a cancellation point, it also makes it possible that other functions can be cancellation points in libraries without having to be rewritten in libthr. Notes: svn path=/head/; revision=213153
* add code to support stack unwinding when thread exits. note that onlyDavid Xu2010-09-151-0/+8
| | | | | | | | | defer-mode cancellation works, asynchrnous mode does not work because it lacks of libuwind's support. stack unwinding is not enabled unless LIBTHR_UNWIND_STACK is defined in Makefile. Notes: svn path=/head/; revision=212630
* Merge from tbemd, with a small amount of rework:Warner Losh2010-09-131-1/+3
| | | | | | | | | | | | | For all libthr contexts, use ${MACHINE_CPUARCH} for all libc contexts, use ${MACHINE_ARCH} if it exists, otherwise use ${MACHINE_CPUARCH} Move some common code up a layer (the .PATH statement was the same in all the arch submakefiles). # Hope she hasn't busted powerpc64 with this... Notes: svn path=/head/; revision=212516
* Unify 32-bit and 64-bit PowerPC libthr support. This reduces codeNathan Whitehorn2010-08-241-2/+2
| | | | | | | | | duplication, and simplifies the TBEMD import. Requested by: imp Notes: svn path=/head/; revision=211773