diff --git a/programs/CMakeLists.txt b/programs/CMakeLists.txt index 152da46ebf2..31943ef7dae 100644 --- a/programs/CMakeLists.txt +++ b/programs/CMakeLists.txt @@ -322,6 +322,12 @@ endif() clickhouse_add_executable (clickhouse main.cpp) +if (NOT USE_STATIC_LIBRARIES AND SPLIT_SHARED_LIBRARIES) + # Shared split (dev) build: In CI, the server is run with custom LD_LIBRARY_PATH. This makes the harmful env check re-execute the + # process in a clean environment but as in CI the containing directory is not included in DT_RUNPATH/DT_RPATH, the server won't come up. + target_compile_definitions(clickhouse PRIVATE DISABLE_HARMFUL_ENV_VAR_CHECK) +endif () + # A library that prevent usage of several functions from libc. if (ARCH_AMD64 AND OS_LINUX AND NOT OS_ANDROID) set (HARMFUL_LIB harmful) diff --git a/programs/main.cpp b/programs/main.cpp index 175504a85fa..27e17cfd2e0 100644 --- a/programs/main.cpp +++ b/programs/main.cpp @@ -345,6 +345,7 @@ struct Checker ; +#ifndef DISABLE_HARMFUL_ENV_VAR_CHECK /// NOTE: We will migrate to full static linking or our own dynamic loader to make this code obsolete. void checkHarmfulEnvironmentVariables(char ** argv) { @@ -396,6 +397,7 @@ void checkHarmfulEnvironmentVariables(char ** argv) _exit(error); } } +#endif } @@ -422,7 +424,9 @@ int main(int argc_, char ** argv_) /// will work only after additional call of this function. updatePHDRCache(); +#ifndef DISABLE_HARMFUL_ENV_VAR_CHECK checkHarmfulEnvironmentVariables(argv_); +#endif /// Reset new handler to default (that throws std::bad_alloc) /// It is needed because LLVM library clobbers it.