1
0
Fork 0
mirror of https://github.com/dragonflydb/dragonfly.git synced 2024-12-15 17:51:06 +00:00
dragonflydb-dragonfly/Makefile
Shahar Mike 69f269e808
feat(makefile): Build with full debug symbols and strip in make package (#2343)
Before this PR, using `make` for building releases used `-g1 -gz` to
provide some level of debug symbols (mostly function names in stack
traces).

We want to be able to have binaries with full debug symbols (for
coredumps etc), but not in the public releases.

This PR builds with full debug symbols, but changes `make package` to
strip most debug symbols, while keeping `.debug_line` (and keeping them
compressed as if with `-gz`). This will allow a single build command for
public releases as well as releases with full symbols.
2023-12-27 17:48:29 +02:00

61 lines
1.7 KiB
Makefile

BUILD_ARCH := $(shell uname -m)
RELEASE_NAME := "dragonfly-${BUILD_ARCH}"
HELIO_RELEASE := $(if $(HELIO_RELEASE),y,)
HELIO_RELEASE_FLAGS = -DHELIO_RELEASE_FLAGS="-g"
HELIO_USE_STATIC_LIBS = ON
HELIO_OPENSSL_USE_STATIC_LIBS = ON
HELIO_ENABLE_GIT_VERSION = ON
HELIO_WITH_UNWIND = OFF
# Some distributions (old fedora) have incorrect dependencies for crypto
# so we add -lz for them.
LINKER_FLAGS=-lz
# equivalent to: if $(uname_m) == x86_64 || $(uname_m) == amd64
ifneq (, $(filter $(BUILD_ARCH),x86_64 amd64))
HELIO_MARCH_OPT := -march=core2 -msse4.1 -mpopcnt -mtune=skylake
endif
# For release builds we link statically libstdc++ and libgcc. Currently,
# all the release builds are performed by gcc.
ifeq ($(HELIO_RELEASE),y)
LINKER_FLAGS += -static-libstdc++ -static-libgcc
endif
HELIO_FLAGS = $(if $(HELIO_RELEASE),-release $(HELIO_RELEASE_FLAGS),) \
-DCMAKE_EXE_LINKER_FLAGS="$(LINKER_FLAGS)" \
-DBoost_USE_STATIC_LIBS=$(HELIO_USE_STATIC_LIBS) \
-DOPENSSL_USE_STATIC_LIBS=$(HELIO_OPENSSL_USE_STATIC_LIBS) \
-DENABLE_GIT_VERSION=$(HELIO_ENABLE_GIT_VERSION) \
-DWITH_UNWIND=$(HELIO_WITH_UNWIND) -DMARCH_OPT="$(HELIO_MARCH_OPT)"
.PHONY: default
configure:
./helio/blaze.sh $(HELIO_FLAGS)
build:
cd build-opt; \
ninja dragonfly && ldd dragonfly
build-debug:
cd build-dbg; \
ninja dragonfly && ldd dragonfly
package:
cd build-opt; \
objcopy \
--remove-section=".debug_*" \
--remove-section="!.debug_line" \
--compress-debug-sections \
dragonfly \
$(RELEASE_NAME); \
tar cvfz $(RELEASE_NAME).tar.gz $(RELEASE_NAME) ../LICENSE.md
release: configure build
release-debug: configure build-debug
default: release