From fcbe7ddf707983569ce04069e0bb146729badb6e Mon Sep 17 00:00:00 2001 From: Jelte Fennema Date: Thu, 19 Mar 2020 15:40:36 +0100 Subject: [PATCH] Revert "Merge pull request #3626 from citusdata/vendor-new-directory" This reverts commit 30ada54f6ab2b89a22cd9dafb1b0d132b437d837, reversing changes made to 6ff79c5ea96d830b1ec9a146079c93cfd7f8ca51. --- ci/editorconfig.sh | 1 - src/backend/distributed/Makefile | 25 +++++++++++++++---- src/backend/distributed/safeclib | 1 - vendor/README.md | 2 +- vendor/safestringlib/CMakeLists.txt | 9 ++++--- .../safeclib/mem_primitives_lib.c | 2 -- .../safestringlib/safeclib/safeclib_private.h | 1 - .../safestringlib/safeclib/snprintf_support.c | 1 - 8 files changed, 27 insertions(+), 15 deletions(-) delete mode 120000 src/backend/distributed/safeclib diff --git a/ci/editorconfig.sh b/ci/editorconfig.sh index 427c45061..661aec1a7 100755 --- a/ci/editorconfig.sh +++ b/ci/editorconfig.sh @@ -4,7 +4,6 @@ for f in $(git ls-tree -r HEAD --name-only); do if [ "$f" = "${f%.out}" ] && [ "$f" = "${f%.data}" ] && [ "$f" = "${f%.png}" ] && - [ -f "$f" ] && [ "$(echo "$f" | cut -d / -f1)" != "vendor" ] && [ "$(dirname "$f")" != "src/test/regress/output" ] then diff --git a/src/backend/distributed/Makefile b/src/backend/distributed/Makefile index 82e11cd11..e3803dbdf 100644 --- a/src/backend/distributed/Makefile +++ b/src/backend/distributed/Makefile @@ -7,6 +7,13 @@ safestringlib_builddir = $(citus_top_builddir)/vendor/safestringlib/build safestringlib_a = $(safestringlib_builddir)/libsafestring_static.a safestringlib_sources = $(wildcard $(safestringlib_srcdir)/safeclib/*) +# Use cmake3 if it exists, otherwise just use the string "cmake" and let bash +# figure out its exact path later. +# Using "which cmake" instead will make the error very hard to understand if +# you have neither "cmake3" or "cmake" in path. In that case the "CMAKE3" +# variable would be an empty string. +CMAKE3 = $(shell which cmake3 || echo cmake) + MODULE_big = citus EXTENSION = citus @@ -16,11 +23,7 @@ generated_sql_files = $(patsubst %,$(citus_abs_srcdir)/build/%,$(template_sql_fi DATA_built = $(generated_sql_files) # directories with source files -SUBDIRS = . commands connection ddl deparser executor master metadata planner progress relay safeclib test transaction utils worker - -# Symlinks are not copied over to the build directory if a separete build -# directory is used during configure (such as on CI) -ENSURE_SUBDIRS_EXIST := $(shell mkdir -p $(SUBDIRS)) +SUBDIRS = . commands connection ddl deparser executor master metadata planner progress relay test transaction utils worker # That patsubst rule searches all directories listed in SUBDIRS for .c # files, and adds the corresponding .o files to OBJS @@ -47,11 +50,23 @@ utils/citus_version.o: $(CITUS_VERSION_INVALIDATE) SHLIB_LINK += $(filter -lssl -lcrypto -lssleay32 -leay32, $(LIBS)) +override LDFLAGS += $(safestringlib_a) override CPPFLAGS += -I$(libpq_srcdir) -I$(safestringlib_srcdir)/include SQL_DEPDIR=.deps/sql SQL_BUILDDIR=build/sql +$(safestringlib_a): $(safestringlib_sources) + rm -rf $(safestringlib_builddir) + mkdir -p $(safestringlib_builddir) + @# exports of LDFLAGS and CPPFLAGS are to make sure the ones from this + @# Makefile are not used + +cd $(safestringlib_builddir) && \ + export LDFLAGS='' && export CPPFLAGS='' && \ + $(CMAKE3) $(safestringlib_srcdir) && make + +citus.so: $(safestringlib_a) + $(generated_sql_files): $(citus_abs_srcdir)/build/%: % @mkdir -p $(citus_abs_srcdir)/$(SQL_DEPDIR) $(citus_abs_srcdir)/$(SQL_BUILDDIR) cd $(citus_abs_srcdir) && cpp -undef -w -P -MMD -MP -MF$(SQL_DEPDIR)/$(*F).Po -MT$@ $< > $@ diff --git a/src/backend/distributed/safeclib b/src/backend/distributed/safeclib deleted file mode 120000 index c4da5b7ad..000000000 --- a/src/backend/distributed/safeclib +++ /dev/null @@ -1 +0,0 @@ -../../../vendor/safestringlib/safeclib/ \ No newline at end of file diff --git a/vendor/README.md b/vendor/README.md index 43b27ead1..e6da4b639 100644 --- a/vendor/README.md +++ b/vendor/README.md @@ -6,5 +6,5 @@ git clone https://github.com/intel/safestringlib rm -rf safestringlib/{.git,unittests} git add safestringlib/ git commit -m "Update safestringlib" -git cherry-pick -x dc2a371d9f8b28ad0e68c5230bb998b4463d8131 +git cherry-pick -x 92d7a40d1de472d23d05967be9b77eda30af85cb ``` diff --git a/vendor/safestringlib/CMakeLists.txt b/vendor/safestringlib/CMakeLists.txt index 213d5a8f5..41d236591 100644 --- a/vendor/safestringlib/CMakeLists.txt +++ b/vendor/safestringlib/CMakeLists.txt @@ -145,14 +145,14 @@ set_target_properties(${PROJECT_NAME}_objlib target_compile_definitions(${PROJECT_NAME}_objlib PRIVATE -DSTDC_HEADERS) +target_compile_options(${PROJECT_NAME}_objlib + PRIVATE -Wall -Wextra -Wsign-compare -Wformat-security) target_compile_options(${PROJECT_NAME}_objlib PRIVATE -Wno-unknown-pragmas -Wno-unused-parameter) if(CMAKE_COMPILER_IS_GNUCC AND CMAKE_C_COMPILER_VERSION VERSION_GREATER 7) target_compile_options(${PROJECT_NAME}_objlib PRIVATE -Wno-implicit-fallthrough) endif() -target_compile_options(${PROJECT_NAME}_objlib - PRIVATE -Wall -Wextra -Wsign-compare -Wformat-security) target_compile_options(${PROJECT_NAME}_objlib PRIVATE -Wstack-protector -Winit-self) target_compile_options(${PROJECT_NAME}_objlib @@ -166,7 +166,10 @@ target_compile_options(${PROJECT_NAME}_objlib PRIVATE -fPIE -fPIC) if(CMAKE_COMPILER_IS_GNUCC AND CMAKE_C_COMPILER_VERSION VERSION_GREATER 6) target_compile_options(${PROJECT_NAME}_objlib PRIVATE -mmitigate-rop) endif() -set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -z noexecstack -z relro -z now") +if(APPLE) +elseif(UNIX) + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -z noexecstack -z relro -z now") +endif() option(BUILD_ERROR_ON_WARNING "Fail compilation on warning" OFF) diff --git a/vendor/safestringlib/safeclib/mem_primitives_lib.c b/vendor/safestringlib/safeclib/mem_primitives_lib.c index 54b596d02..cc189e5ea 100644 --- a/vendor/safestringlib/safeclib/mem_primitives_lib.c +++ b/vendor/safestringlib/safeclib/mem_primitives_lib.c @@ -31,8 +31,6 @@ #include "mem_primitives_lib.h" -#pragma GCC diagnostic ignored "-Wpragmas" -#pragma GCC diagnostic ignored "-Wimplicit-fallthrough" /* * mem_primitives_lib.c provides unguarded memory routines * that are used by the safe_mem_library. These routines diff --git a/vendor/safestringlib/safeclib/safeclib_private.h b/vendor/safestringlib/safeclib/safeclib_private.h index 89ee97727..7280e879a 100644 --- a/vendor/safestringlib/safeclib/safeclib_private.h +++ b/vendor/safestringlib/safeclib/safeclib_private.h @@ -32,7 +32,6 @@ #ifndef __SAFECLIB_PRIVATE_H__ #define __SAFECLIB_PRIVATE_H__ -#include "citus_config.h" #ifdef __KERNEL__ /* linux kernel environment */ diff --git a/vendor/safestringlib/safeclib/snprintf_support.c b/vendor/safestringlib/safeclib/snprintf_support.c index 8b482c1a4..52a0739f8 100644 --- a/vendor/safestringlib/safeclib/snprintf_support.c +++ b/vendor/safestringlib/safeclib/snprintf_support.c @@ -54,7 +54,6 @@ #define CHK_FORMAT(X,Y) (((X)==(Y))?1:0) -#pragma GCC diagnostic ignored "-Wmissing-prototypes" unsigned int parse_format(const char *format, char pformatList[], unsigned int maxFormats)