RLIMIT_RSS does not work since 2.6.x+, from getrlimit(2):
RLIMIT_RSS
This is a limit (in bytes) on the process's resident set (the number of virtual pages resident in RAM). This limit has effect only in Linux 2.4.x, x < 30, and there af‐
fects only calls to madvise(2) specifying MADV_WILLNEED.
Note that before this patch RSS was to 10MB but I doubt that it is
enough for C++ compiler, this patch uses 1G limit for DATA and 10G for
AS/VIRT (but it seems that even 1G may be too small).
And see also https://code.woboq.org/linux/linux/mm/mmap.c.html#may_expand_vm
Since libtsan.a provides new/delete overrides too:
ld.lld: error: duplicate symbol: operator new[](unsigned long, std::nothrow_t const&)
>>> defined at new_delete.cpp:64 (../src/Common/new_delete.cpp:64)
>>> new_delete.cpp.o:(operator new[](unsigned long, std::nothrow_t const&)) in archive src/libclickhouse_new_delete.a
>>> defined at tsan_new_delete.o:(.text+0xE0) in archive /usr/lib/gcc/x86_64-linux-gnu/10/libtsan.a
v2: Fix order of src vs programs for clickhouse_new_delete target detection
gcc with -nodefaultlibs does not add sanitizers library during linkage
with -static-libasan and similar, fix this, by add them explicitly.
From the gcc(1) about -nodefaultlibs:
Do not use the standard system libraries when linking. Only the
libraries you specify are passed to the linker, and options specifying
linkage of the system libraries, such as -static-libgcc or
-shared-libgcc, are ignored. The standard startup files are used
normally, unless -nostartfiles is used.
Plus checked it manually, w/o -nodefaultlibs everything works without
this explicit linkage.
After this patch UBSAN under gcc compiled successfully.
v2: freebsd and darwin
Yes clickhosue set gnu++2a globally, but this will not work, since
default -std=c++11 will be added later, look:
clang++ -std=gnu++2a ... -std=c++11 -Wall -Wextra contrib/llvm/...
Use -std=gnu++2a regardless of whether UNBUNDLED or not, because __int128
is a non-standard builtin and GCC, unlike Clang, only considers it to be
an integral type when GNU extensions are enabled.