Skip to content

Commit

Permalink
build static and optimized version works
Browse files Browse the repository at this point in the history
  • Loading branch information
pjotrp committed Jan 15, 2022
1 parent df1b7e0 commit 1621ed1
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 20 deletions.
2 changes: 2 additions & 0 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ this way all dependencies are isolated. To create a static release use

env CC=gcc make -f Makefile.guix static -j 4 (FIXME)

Note that the static build is not working on GNU Guix right now because the Phobos libs are missing (shared lib only).

Alternatively use the meson+ninja build with

rm -rf build/ ; env D_LD=gold CC=gcc meson build --buildtype release
Expand Down
17 changes: 6 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
# Note that this make file generates the most optimal binary for
# sambamba (as a single run of ldc2 with aggressive inlining). For
# development you may want to opt for meson+ninja instead.
# development you may want to opt for meson+ninja or Makefile.guix instead.
#
# Targets (64-bit):
#
Expand All @@ -24,6 +24,7 @@
#

D_COMPILER=ldc2
CC=gcc

UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Darwin)
Expand All @@ -34,16 +35,15 @@ endif

DFLAGS = -wi -I. -IBioD -g -J.

DLIBS = $(LIBRARY_PATH)/libphobos2-ldc.a $(LIBRARY_PATH)/libdruntime-ldc.a
# DLIBS = $(LIBRARY_PATH)/libphobos2-ldc.a $(LIBRARY_PATH)/libdruntime-ldc.a
DLIBS_DEBUG = $(LIBRARY_PATH)/libphobos2-ldc-debug.a $(LIBRARY_PATH)/libdruntime-ldc-debug.a
LIBS = -L-L$(LIBRARY_PATH) -L-lpthread -L-lm -L-lz -L-llz4
LIBS_STATIC = $(LIBRARY_PATH)/libc.a $(DLIBS) -L-llz4 -L-lz
# LIBS_STATIC = $(LIBRARY_PATH)/libc.a $(DLIBS) -L-llz4 -L-lz
LIBS_STATIC = $(DLIBS) -L-lz -L-llz4 -L-lphobos2-ldc -L-ldruntime-ldc
SRC = utils/ldc_version_info_.d utils/lz4.d utils/strip_bcf_header.d $(sort $(wildcard BioD/contrib/undead/*.d BioD/contrib/undead/*/*.d)) utils/version_.d $(sort $(wildcard thirdparty/*.d) $(wildcard BioD/bio/*/*.d BioD/bio/*/*/*.d BioD/bio/*/*/*/*.d BioD/bio/*/*/*/*/*.d) $(wildcard sambamba/*.d sambamba/*/*.d sambamba/*/*/*.d))
OBJ = $(SRC:.d=.o)
OUT = bin/sambamba-$(shell cat VERSION)

STATIC_LIB_PATH=-Llz4

.PHONY: all debug release static clean test

all: release
Expand All @@ -56,15 +56,10 @@ coverage: DFLAGS += -cov

release static pgo-static: DFLAGS += -O3 -release -enable-inlining -boundscheck=off -L-lz

static: DFLAGS += -static -L-Bstatic -link-defaultlib-shared=false
static: DFLAGS += -static -L-Bstatic -link-defaultlib-shared=false $(LIBS_STATIC)

pgo-static: DFLAGS += -fprofile-instr-use=profile.data

lz4-static: lz4/lib/liblz4.a

lz4/lib/liblz4.a: lz4/lib/lz4.c lz4/lib/lz4hc.c lz4/lib/lz4frame.c lz4/lib/xxhash.c
cd lz4/lib && $(CC) -O3 -c lz4.c lz4hc.c lz4frame.c xxhash.c && $(AR) rcs liblz4.a lz4.o lz4hc.o lz4frame.o xxhash.o

utils/ldc_version_info_.d:
python3 ./gen_ldc_version_info.py $(shell which ldmd2) > utils/ldc_version_info_.d
cat utils/ldc_version_info_.d
Expand Down
10 changes: 1 addition & 9 deletions Makefile.guix
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,9 @@
# standard Makefile instead because it compiles into a singleobj which
# gives better performance. This Makefile is for development purposes.
#
# To build sambamba on GNU Guix:
#
# env LIBRARY_PATH= make -f Makefile.guix GUIX=~/opt/sambamba-dev-env
#
# run with
#
# ./bin/sambamba
#
# But it is preferred to run in a Guix environment/container. For more
# information see INSTALL.md
#

D_COMPILER=ldc2
CC=gcc
CPP=gcc
Expand Down

0 comments on commit 1621ed1

Please sign in to comment.