[201811][dhcp] enable building dhcpmon and dhcp6relay debug symbols (#9959)

* dhcp6relay: Save the dbgsym package into the target folder (#9013)

This makes it possible to install the debug symbols if needed. Also install
the package into the debug version of sonic-dhcp-relay container.

Signed-off-by: Saikrishna Arcot <sarcot@microsoft.com>

* Package debugging and hardening for dhcpmon and dhcp6relay (#9862)

Enable dbgsym package for dhcpmon.

Allow CFLAGS and LDFLAGS from environment variables to be used
in the dhcp6relay build. This makes sure that the -O2 flag from
dpkg-buildflags gets used.

Finally, enable all hardening flags in dpkg-buildflags for
dhcp6relay and dhcpmon. The change from the default set of flags is that
during linking, immediate binding of symbols is done instead of lazy
binding.

Signed-off-by: Saikrishna Arcot <sarcot@microsoft.com>

* [201811][dhcp] update debian build rules

Signed-off-by: Ying Xie <ying.xie@microsoft.com>

Co-authored-by: Saikrishna Arcot <sarcot@microsoft.com>
This commit is contained in:
Ying Xie 2022-02-10 20:57:10 -08:00 committed by GitHub
parent 8e6d08a6b5
commit 76af3dc148
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 47 additions and 5 deletions

View File

@ -7,3 +7,6 @@ SONIC_DHCP6RELAY = sonic-$(SONIC_DHCP6RELAY_PKG_NAME)_$(SONIC_DHCP6RELAY_VERSION
$(SONIC_DHCP6RELAY)_DEPENDS = $(LIBSWSSCOMMON) $(LIBHIREDIS) $(LIBSWSSCOMMON_DEV) $(LIBHIREDIS_DEV) $(SONIC_DHCP6RELAY)_DEPENDS = $(LIBSWSSCOMMON) $(LIBHIREDIS) $(LIBSWSSCOMMON_DEV) $(LIBHIREDIS_DEV)
$(SONIC_DHCP6RELAY)_SRC_PATH = $(SRC_PATH)/$(SONIC_DHCP6RELAY_PKG_NAME) $(SONIC_DHCP6RELAY)_SRC_PATH = $(SRC_PATH)/$(SONIC_DHCP6RELAY_PKG_NAME)
SONIC_DPKG_DEBS += $(SONIC_DHCP6RELAY) SONIC_DPKG_DEBS += $(SONIC_DHCP6RELAY)
SONIC_DHCP6RELAY_DBG = sonic-$(SONIC_DHCP6RELAY_PKG_NAME)-dbg_$(SONIC_DHCP6RELAY_VERSION)_amd64.deb
$(eval $(call add_derived_package,$(SONIC_DHCP6RELAY),$(SONIC_DHCP6RELAY_DBG)))

View File

@ -6,3 +6,6 @@ SONIC_DHCPMON_PKG_NAME = dhcpmon
SONIC_DHCPMON = sonic-$(SONIC_DHCPMON_PKG_NAME)_$(SONIC_DHCPMON_VERSION)_amd64.deb SONIC_DHCPMON = sonic-$(SONIC_DHCPMON_PKG_NAME)_$(SONIC_DHCPMON_VERSION)_amd64.deb
$(SONIC_DHCPMON)_SRC_PATH = $(SRC_PATH)/$(SONIC_DHCPMON_PKG_NAME) $(SONIC_DHCPMON)_SRC_PATH = $(SRC_PATH)/$(SONIC_DHCPMON_PKG_NAME)
SONIC_DPKG_DEBS += $(SONIC_DHCPMON) SONIC_DPKG_DEBS += $(SONIC_DHCPMON)
SONIC_DHCPMON_DBG = sonic-$(SONIC_DHCPMON_PKG_NAME)-dbg_$(SONIC_DHCPMON_VERSION)_amd64.deb
$(eval $(call add_derived_package,$(SONIC_DHCPMON),$(SONIC_DHCPMON_DBG)))

View File

@ -8,7 +8,7 @@ $(DOCKER_DHCP_RELAY)_PATH = $(DOCKERS_PATH)/docker-dhcp-relay
$(DOCKER_DHCP_RELAY)_DEPENDS += $(ISC_DHCP_COMMON) $(ISC_DHCP_RELAY) $(REDIS_TOOLS) $(SONIC_DHCPMON) $(SONIC_DHCP6RELAY) $(LIBSWSSCOMMON) $(DOCKER_DHCP_RELAY)_DEPENDS += $(ISC_DHCP_COMMON) $(ISC_DHCP_RELAY) $(REDIS_TOOLS) $(SONIC_DHCPMON) $(SONIC_DHCP6RELAY) $(LIBSWSSCOMMON)
$(DOCKER_DHCP_RELAY)_DBG_DEPENDS = $($(DOCKER_CONFIG_ENGINE)_DBG_DEPENDS) $(DOCKER_DHCP_RELAY)_DBG_DEPENDS = $($(DOCKER_CONFIG_ENGINE)_DBG_DEPENDS)
$(DOCKER_DHCP_RELAY)_DBG_DEPENDS += $(ISC_DHCP_DBG) $(DOCKER_DHCP_RELAY)_DBG_DEPENDS += $(ISC_DHCP_DBG) $(SONIC_DHCP6RELAY_DBG) $(SONIC_DHCPMON_DBG)
$(DOCKER_DHCP_RELAY)_DBG_IMAGE_PACKAGES = $($(DOCKER_CONFIG_ENGINE)_DBG_IMAGE_PACKAGES) $(DOCKER_DHCP_RELAY)_DBG_IMAGE_PACKAGES = $($(DOCKER_CONFIG_ENGINE)_DBG_IMAGE_PACKAGES)
$(DOCKER_DHCP_RELAY)_LOAD_DOCKERS = $(DOCKER_CONFIG_ENGINE) $(DOCKER_DHCP_RELAY)_LOAD_DOCKERS = $(DOCKER_CONFIG_ENGINE)

View File

@ -4,8 +4,8 @@ CP := cp
MKDIR := mkdir MKDIR := mkdir
CC := g++ CC := g++
MV := mv MV := mv
LIBS := -levent -lswsscommon -pthread -lboost_thread -lboost_system -I $(PWD)/../sonic-swss-common/common LIBS := -levent -lhiredis -lswsscommon -pthread -lboost_thread -lboost_system
CFLAGS = -g -Wall -std=gnu11 CFLAGS += -Wall -std=c++14 -fPIE -I$(PWD)/../sonic-swss-common/common
PWD := $(shell pwd) PWD := $(shell pwd)
ifneq ($(MAKECMDGOALS),clean) ifneq ($(MAKECMDGOALS),clean)
@ -21,7 +21,7 @@ all: sonic-dhcp6relay
sonic-dhcp6relay: $(OBJS) sonic-dhcp6relay: $(OBJS)
@echo 'Building target: $@' @echo 'Building target: $@'
@echo 'Invoking: G++ Linker' @echo 'Invoking: G++ Linker'
$(CC) -o $(DHCP6RELAY_TARGET) $(OBJS) $(LIBS) $(CC) $(LDFLAGS) -o $(DHCP6RELAY_TARGET) $(OBJS) $(LIBS)
@echo 'Finished building target: $@' @echo 'Finished building target: $@'
@echo ' ' @echo ' '

View File

@ -15,3 +15,13 @@ Depends: libevent-2.0-5,
libboost-thread1.55.0, libboost-thread1.55.0,
libboost-system1.55.0 libboost-system1.55.0
Description: SONiC DHCPv6 Relay Description: SONiC DHCPv6 Relay
Package: sonic-dhcp6relay-dbg
Architecture: any
Section: debug
Priority: extra
Built-Using: ${misc:Built-Using}
Depends: libevent-2.0-5,
libboost-thread1.55.0,
libboost-system1.55.0
Description: SONiC DHCPv6 Relay debug symbols

View File

@ -1,4 +1,12 @@
#!/usr/bin/make -f #!/usr/bin/make -f
export DEB_BUILD_MAINT_OPTIONS=hardening=+all
%: %:
dh $@ --parallel dh $@ --parallel
override_dh_strip:
dh_strip --dbg-package=sonic-dhcp6relay-dbg
override_dh_auto_install:
dh_auto_install --destdir=debian/sonic-dhcp6relay

View File

@ -18,6 +18,6 @@ C_DEPS += \
src/%.o: src/%.cpp src/%.o: src/%.cpp
@echo 'Building file: $<' @echo 'Building file: $<'
@echo 'Invoking: GCC C++ Compiler' @echo 'Invoking: GCC C++ Compiler'
$(CC) -std=c++14 -D__FILENAME__="$(subst src/,,$<)" $(LIBS) -Wall -c -fmessage-length=0 -fPIC -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@)" -o "$@" "$<" $(CC) -D__FILENAME__="$(subst src/,,$<)" $(CFLAGS) -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@)" -o "$@" "$<"
@echo 'Finished building: $<' @echo 'Finished building: $<'
@echo ' ' @echo ' '

View File

@ -10,6 +10,16 @@ XS-Go-Import-Path: github.com/Azure/sonic-buildimage
Package: sonic-dhcpmon Package: sonic-dhcpmon
Architecture: any Architecture: any
Section: devel
Priority: optional
Built-Using: ${misc:Built-Using} Built-Using: ${misc:Built-Using}
Depends: libevent-2.0-5 Depends: libevent-2.0-5
Description: SONiC DHCP Monitor Description: SONiC DHCP Monitor
Package: sonic-dhcpmon-dbg
Architecture: any
Section: debug
Priority: extra
Built-Using: ${misc:Built-Using}
Depends: libevent-2.0-5
Description: SONiC DHCP Monitor debug symbols

View File

@ -1,7 +1,15 @@
#!/usr/bin/make -f #!/usr/bin/make -f
export DEB_BUILD_MAINT_OPTIONS=hardening=+all
DEB_CFLAGS_APPEND=-std=gnu11 DEB_CFLAGS_APPEND=-std=gnu11
export DEB_CFLAGS_APPEND export DEB_CFLAGS_APPEND
%: %:
dh $@ --parallel dh $@ --parallel
override_dh_strip:
dh_strip --dbg-package=sonic-dhcpmon-dbg
override_dh_auto_install:
dh_auto_install --destdir=debian/sonic-dhcpmon