add secure compile options for libevhtp

Signed-off-by: wujing <wujing50@huawei.com>
This commit is contained in:
wujing 2021-03-19 07:49:53 +08:00
parent abab53a6c7
commit 6123b9ea55
2 changed files with 57 additions and 3 deletions

View File

@ -0,0 +1,46 @@
From cb1d37837d76928670c414d3b498d898ee0b32ae Mon Sep 17 00:00:00 2001
From: wujing <wujing50@huawei.com>
Date: Tue, 16 Mar 2021 10:37:07 +0800
Subject: [PATCH] libevhtp: add securce compile options
Signed-off-by: wujing <wujing50@huawei.com>
---
CMakeLists.txt | 7 ++++++-
cmake/options.cmake | 3 +++
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index fbb0f50..5bc89d5 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -110,7 +110,12 @@ elseif(EVHTP_ALLOCATOR STREQUAL "tcmalloc")
endif()
endif()
-add_library(evhtp SHARED ${LIBEVHTP_SOURCE_FILES})
+if (NOT EVHTP_BUILD_SHARED)
+ add_library(evhtp ${LIBEVHTP_SOURCE_FILES})
+else()
+ add_library(evhtp SHARED ${LIBEVHTP_SOURCE_FILES})
+ target_link_options(evhtp PUBLIC "-Wl,-z,now -s")
+endif()
target_link_libraries(evhtp PUBLIC ${LIBEVHTP_EXTERNAL_LIBS})
target_include_directories(evhtp PUBLIC ${LIBEVHTP_EXTERNAL_INCLUDES})
diff --git a/cmake/options.cmake b/cmake/options.cmake
index 1738642..e781110 100644
--- a/cmake/options.cmake
+++ b/cmake/options.cmake
@@ -11,6 +11,9 @@ option (EVHTP_DISABLE_REGEX "Disable regex support" OFF)
# -DEVHTP_DEBUG=ON
option (EVHTP_DEBUG "Enable verbose debug logging" OFF)
+# -DEVHTP_BUILD_SHARED=ON
+option (EVHTP_BUILD_SHARED "Build shared libraries" OFF)
+
# can be overwritten by new set_alloc functions
set(EVHTP_ALLOCATOR CACHE STRING "Allocator library")
set_property(CACHE EVHTP_ALLOCATOR PROPERTY STRINGS "jemalloc;tcmalloc")
--
2.29.2

View File

@ -1,6 +1,8 @@
%global debug_package %{nil}
Name: libevhtp
Version: 1.2.18
Release: 2
Release: 3
Summary: Libevent based HTTP API.
License: BSD3
@ -10,6 +12,7 @@ Patch9000: 0001-decrease-numbers-of-fd-for-shared-pipe-mode.patch
Patch9001: 0002-evhtp-enable-dynamic-thread-pool.patch
Patch9002: 0003-close-open-ssl.-we-do-NOT-use-it-in-lcrd.patch
Patch9003: 0004-Use-shared-library-instead-static-one.patch
Patch9004: 0005-libevhtp-add-securce-compile-options.patch
BuildRequires: git gcc-c++ cmake libevent-devel
@ -28,8 +31,6 @@ Requires: %{name} = %{version}-%{release}
%{name}-devel contains the header files for developing
applications that want to make use of %{name}.
%global debug_package %{nil}
%prep
%autosetup -n %{name}-%{version} -p1
@ -46,6 +47,7 @@ cd build
%delete_la_and_a
find %{buildroot} -name '*.cmake' -exec rm -f {} ';'
find %{buildroot} -name '*.so.*' -exec strip {} ';'
%ldconfig_scriptlets
@ -63,6 +65,12 @@ find %{buildroot} -name '*.cmake' -exec rm -f {} ';'
/usr/lib/pkgconfig/evhtp.pc
%changelog
* Fri Mar 19 2021 wujing <wujing50@huawei.com> - 1.2.18-3
- Type:enhancement
- ID:NA
- SUG:NA
- DESC: add secure compile options
* Tue Sep 01 2020 openeuler Buildteam <buildteam@openeuler.org> - 1.2.18-2
- Type:enhancement
- ID:NA