From 1621ed113ca77ade5d8418d99545b75eaa976dd7 Mon Sep 17 00:00:00 2001 From: Pjotr Prins Date: Sat, 15 Jan 2022 07:40:56 -0600 Subject: [PATCH] build static and optimized version works --- INSTALL.md | 2 ++ Makefile | 17 ++++++----------- Makefile.guix | 10 +--------- 3 files changed, 9 insertions(+), 20 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index 476344c..47bb4f1 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -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 diff --git a/Makefile b/Makefile index 321c566..14b2c08 100644 --- a/Makefile +++ b/Makefile @@ -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): # @@ -24,6 +24,7 @@ # D_COMPILER=ldc2 +CC=gcc UNAME_S := $(shell uname -s) ifeq ($(UNAME_S),Darwin) @@ -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 @@ -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 diff --git a/Makefile.guix b/Makefile.guix index 8194061..878f98c 100644 --- a/Makefile.guix +++ b/Makefile.guix @@ -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