Commit Graph

53 Commits

Author SHA1 Message Date
Aliaksey Kandratsenka
38d741710b drop unused pwd.h/grp.h checks 2024-03-24 16:59:58 -04:00
Aliaksey Kandratsenka
ae31e6afa3 drop unused LT_OBJDIR from cmake config.h template 2024-03-24 16:59:57 -04:00
Aliaksey Kandratsenka
b65b9e3e61 amputate unused AC_INSTALL_PREFIX 2024-03-24 16:59:57 -04:00
Aliaksey Kandratsenka
93380fc754 drop dependency on sys/resource.h
Biggest part of it is removal of SetTestResourceLimit. The reasoning
behind it is, we don't do it on windows. Tests pass just fine. So,
there is no reason to bother.
2024-03-20 16:05:06 -04:00
Aliaksey Kandratsenka
9dfab2cdce cmake: refactor CMakeLists.txt
It is still somewhat broken and somewhat of a mess, but it is much
lesser mess now.

As part of this change I also amputated a number of unnecessary or too
complicated bits. Like attempt to build both static and shared
versions of tcmalloc libraries at the same time. We stick to cmake's
"common" (seemingly) behavior of defaulting to something (in our case
shared library) and letting users override BUILD_SHARED_LIBS.

All the "install" bits are amputated as well, they're not ready.
2024-02-27 17:00:35 -05:00
Aliaksey Kandratsenka
6691226953 split and rewrite TLS access for thread caches
Logic was removed from thread_cache.{h,cc} into
thread_cache_ptr.{h,cc}.

Separation will help possible future evolution, and we already changed
the logic quite a bit:

* early access (when TLS isn't initialized yet) now uses global
ThreadCache instance. We therefore have ThreadCachePtr instances
managing required locking. This eliminates unnecessary complication of
PTHREADS_CRASHES_IF_RUN_TOO_EARLY logic, and any other danger of
touching TLS too early. BTW previous implementation actually leaked
initial early-initialized ThreadCache instance(!)

* old configure-time HAVE_TLS logic is amputated. Config-time part of
it made little sense as C++ 17 guarantees availability of
thread_local, but we have manually curated deny-list of "bad" OSes,
that we tested (via compile checks!) at configure time. Now this
is all compile time. There is now compile-time kHaveGoodTLS variable
and we're using it mostly via if constexpr.

* kHaveGoodTLS case of creating thread cache is simplified and made
more straightforward (no need to have in_setspecific logic).

* !kHaveGoodTLS case if fixed and improved too. We avoid
std:🧵:get_id, as it deadlocks on mingw. We use errno address as
a portable and (usually) async-signal safe 'my thread' identifier. We
also eliminate linear searching of thread's cache and replace it with
straightforward hash table lookup.
2024-02-03 15:57:14 -05:00
Aliaksey Kandratsenka
82a36a6fcd bump required c++ standard to c++-17 2024-01-30 15:54:24 -05:00
Aliaksey Kandratsenka
d6728a0b4c drop unused PACKAGE_XYZ defines from {cmake/vsproject}/config.h
Automake or autoconf adds them automagically, but we don't really need
them. Main effect of this change is that MSVC version of config.h
doesn't duplicate package version.
2024-01-29 20:58:02 -05:00
lennoxho
9a6848de8a A number of cleanups
* Remove build dependency on HAVE_PTHREAD
* Remove build dependency on HAVE_STD_ALIGNED_VAL_T and ENABLE_ALIGNED_NEW_DELETE
* Remove redundant tcmalloc.h files & ensure there are no cross-build-tool references
* Adopt automake commit 26927d1 in the CMake build
2024-01-29 17:15:53 -08:00
lennoxho
96f34120fe Several build fixes and cleanups
- Fix CMake builds for MinGW and MSVC
- Ensure the Autotools, CMake and VSProj builds do not reference each others' config.h
- Use std:🧵:id instead of our own thread ID wrappers
- Moved explicit TLS wrapper functions into the tcmalloc:: namespace and change their visibility to hidden
Resolves #1486
2024-01-26 16:56:17 -05:00
Aliaksey Kandratsenka
79b6ad2ab5 amputate HAVE_FORK checking
Pretty much everything has fork, except windows. Which is much simpler
to test at compile time, then duplicating and complicating the test at
configure time.
2024-01-25 16:10:30 -05:00
lennoxho
5cab8f3f77 Convert MinGW builds to always use WinAPI based threading facilities. See ##1483 2024-01-24 21:47:06 -05:00
Mateusz Jakub Fila
ad4a6ff8de added missing gcc unwinder preference option in cmake 2023-12-27 01:57:46 +01:00
Mateusz Jakub Fila
8987d08f79 fixed setting pagesize and pageshift in cmake 2023-12-24 01:51:00 +01:00
Mateusz Jakub Fila
b8e75ae6fe Add mallinfo2 function 2023-12-07 14:10:51 +01:00
Aliaksey Kandratsenka
a9b734e3fa perform ucontext->pc variants testing in compile-time
As part of cpu profiler we're extracting current PC (program counter)
of out signal's ucontext. Different OS and hardware combinations have
different ways for that. We had a list of variants that we tested at
compile time and populated PC_FROM_UCONTEXT macro into config.h. It
caused duplication and occasional mismatches between our autoconf and
cmake bits.

So this commit changes testing to be compile-time. We remove
complexity from build system and add some to C++ source.

We use SFINAE to find which of those variants compile (and we silently
assume that 'compiles' implies 'works'; this is what config-time
testing did too). Occasionally we'll face situations where several
variants compile. And we couldn't handle this case in pure C++. So we
have a small Ruby program that generates chain of inheritance among
SFINAE-specialized class templates. This handles prioritization among
variants.

List of ucontext->pc extraction variants is mostly same. We dropped
super-obsolete (circa Linux kernel 2.0) arm variant. And NetBSD case
is now improved. We now use their nice architecture-independent macro
instead of x86-specific access.
2023-12-02 18:58:45 -05:00
Sergey Fedorov
8edeea4e83 DefineTargetVariables.cmake: fix for macOS 2023-11-25 16:05:47 +08:00
Sergey Fedorov
0ae8fe9650 PCFromUContext.cmake: fix macOS uc_mcontext 2023-11-25 15:27:20 +08:00
Ivan Dlugos
7ad1dc7693 fix: cmake config.h defines declaration 2023-09-08 14:38:21 -04:00
Aliaksey Kandratsenka
f06ccc6f79 dont test HAVE_{STDINT,INTTYPES}_H
Those are fairly standard by now. We already require C++11 or later
compiler.
2023-07-22 14:32:40 -04:00
Aliaksey Kandratsenka
cc4e289a83 drop weakening from cmake build
Weakening is optional and in github issue #1392 we apparently tried to
weaken on windows and failed. So lets not even try.
2023-07-03 13:02:59 -04:00
Aliaksey Kandratsenka
a25e7fa8b0 cleanup cmake's config.h stuff
Some header defines were not cmakedefine01.
2023-07-02 22:30:00 -04:00
Aliaksey Kandratsenka
ae4aafa468 freebsd+x86-64 pc-from-ucontext is not untested 2023-07-02 22:30:00 -04:00
Aliaksey Kandratsenka
a39073886a unbreak symbol weakening
It is kinda minor feature, and apparently we never had it working. But
is a nice to have. Allows our users to override malloc/free/etc while
still being able to link to us (for tc_malloc for example). With
broken weakening we had this use-case broken for static library
case. And it should now work.
2023-07-02 22:30:00 -04:00
Aliaksey Kandratsenka
e78238d94d reworked heap leak checker for more portability
In most practical terms, this expands "official" heap leak checker
support to Linux/arm64 and Linux/riscv (mips-en and legacy arm are
likely to work & pass tests too now).

The code is now explicitly Linux-only, without trying to pretend
otherwise. Main goal of this change is to finally amputate
linux_syscall_support.h, which we historically had trouble maintaining
well. Biggest challenge was around thread listing facility which uses
clone (ptrace explicitly fails between threads) and that causes
difficulties around parent and child tasks sharing
errno. linux_syscall_support stuff had special feature to "redirect"
errno accesses. But it caused us for more trouble. We switched to
regular syscalls, and errno stamping avoidance is now simply via
careful programming.

A number of other cleanups is made (such us thread finding codes in
procfs which clearly was built for some ages old and odd kernels).

sem_post/sem_wait synchronization was previously potentially prone to
deadlock (if parent died at bad time). We now use pipe pair for this
synchronization and it is fully robust.
2023-07-02 22:30:00 -04:00
Aliaksey Kandratsenka
54605b8a58 amputate old atomic ops implementation 2023-07-02 22:30:00 -04:00
Aliaksey Kandratsenka
0451d21e83 use libunwind when it actually works
Previously we blindly tried to use libunwind whenever header is
detected. Even if actually working libunwind library is missing. This
is now fixed, so we attempt to use libunwind when it actually works.

Somehow recent freebsd ships libunwind.h (which seems to belong to
llvm's implementation), but apparently without matching .so. So then building
and linking failed.
2023-07-02 21:28:30 -04:00
Aliaksey Kandratsenka
e003e91b74 drop dependency on PTHREAD_CREATE_JOINABLE 2023-07-02 21:28:30 -04:00
Aliaksey Kandratsenka
c37f6c4c7c fix deprecated autoconf bits
As part of that we also upgrade required autoconf version to 2.69
which is what I see in rhel/centos 7 and ubuntu 14.04. Both are old
enough. And, of course, .tar.gz releases still ship "packaged" configure,
so will work on older distros.

This fixes issue #1335.
2023-07-02 21:28:30 -04:00
Aliaksey Kandratsenka
f06052d736 synchronize ucontext-from-pc tests autoconf -> cmake
Refers to github issue #1398.
2023-06-21 10:25:14 -04:00
Henrik Reinstädtler
5e923877aa Fix uc_mcontext for apple silicon 2023-06-19 18:11:10 +02:00
Aliaksey Kandratsenka
9d44463380 Remove basic support for Elbrus 2000 (e2k)
This reverts commit 3b1c60cc4e.
2022-05-30 20:33:18 -07:00
stdpain
c25941200e fix cmake gperftools_enable_libunwind invalid 2021-06-20 10:07:42 -07:00
Aliaksey Kandratsenka
c2f60400a8 prefer backtrace() on OSX
It seems to work and _Unwind_Backtrace which is configured otherwise
doesn't.
2021-02-28 17:52:17 -08:00
Aliaksey Kandratsenka
17bab484ae always respect --enable-frame-pointers
Previously it only was respected on x86_64, but this days lots of modern
ABIs are without frame pointers by default (e.g. arm64 and riscv, and
even older mips).
2021-02-14 16:44:28 -08:00
Aliaksey Kandratsenka
419c85814d amputate unused dynamic annotations support 2021-02-14 16:09:17 -08:00
Aliaksey Kandratsenka
73a72cdb61 don't check for snprintf 2021-02-14 15:44:14 -08:00
Aliaksey Kandratsenka
95b52b0504 don't check for unused uname symbol 2021-02-14 15:44:14 -08:00
Aliaksey Kandratsenka
ac68c97187 don't check for useless __builtin_stack_pointer
It doesn't seem to be supported anyways, and we're not using it too.
2021-02-14 15:44:14 -08:00
Aliaksey Kandratsenka
7c106ca241 don't bother checking for stl namespace and use std
Because there are no compilers left that don't do std namespace.
2021-02-14 15:44:14 -08:00
Aliaksey Kandratsenka
0d6f32b9ce use standard way to print size_t-sized ints
I.e. just use zu/zd/zx instead of finding out right size and defining
PRI{u,x,d}S defines. Compilers have long caught up to this part of
standard.
2021-02-14 15:44:14 -08:00
Aliaksey Kandratsenka
0c11d35f4a amputate checking for __int64
Since everything supports stdint.h this days.
2021-02-14 15:44:14 -08:00
Aliaksey Kandratsenka
92718aaaeb amputate checking for conflict-signal.h
It was never found or used.
2021-02-14 15:12:19 -08:00
Aliaksey Kandratsenka
9bb2937261 amputate checking for inline keyword support
It is supported everywhere now.
2021-02-14 15:12:19 -08:00
SSE4
3b1c60cc4e Add support for Elbrus 2000 (e2k) 2021-01-30 13:45:18 -08:00
okhowang(王沛文)
6bbf2ed150 Update cmake 2020-12-19 18:52:40 -08:00
Isaac Hier
913d3eb7d7 Fix a few macros for Apple 2020-12-19 18:52:40 -08:00
Isaac Hier
64a73b1cb8 Work on fixing linking errors in stacktrace 2020-12-19 18:52:40 -08:00
Isaac Hier
11dc65c3c4 Fix config headers, add more unit tests 2020-12-19 18:52:40 -08:00
Isaac Hier
6078fe40d9 Finish configure.ac conversion to CMake, start on Makefile.am 2020-12-19 18:52:40 -08:00