Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 19 additions & 16 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,42 +24,45 @@ jobs:
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y build-essential libdeflate-dev nasm
sudo apt-get install -y build-essential nasm

- name: build ISA-L static (Ubuntu)
if: runner.os == 'Linux'
run: |
git clone --depth=1 --branch v2.31.0 https://github.com/intel/isa-l.git /tmp/isa-l
git clone --depth=1 --branch v2.31.1 https://github.com/intel/isa-l.git /tmp/isa-l
cd /tmp/isa-l
./autogen.sh
./configure --prefix=/tmp/isal-install --enable-static --disable-shared
./configure --prefix=/usr/local --enable-static --disable-shared
make -j$(nproc)
make install
sudo make install

- name: build libdeflate static (Ubuntu)
if: runner.os == 'Linux'
run: |
git clone --depth=1 --branch v1.23 https://github.com/ebiggers/libdeflate.git /tmp/libdeflate
cd /tmp/libdeflate
cmake -B _build -DCMAKE_BUILD_TYPE=Release \
-DLIBDEFLATE_BUILD_STATIC_LIB=ON -DLIBDEFLATE_BUILD_SHARED_LIB=OFF \
-DLIBDEFLATE_BUILD_GZIP=OFF -DCMAKE_INSTALL_PREFIX=/usr/local
cmake --build _build -j$(nproc)
sudo cmake --install _build

- name: install dependencies (macOS)
if: runner.os == 'macOS'
run: brew install libdeflate isa-l

- name: build Highway static
- name: build Highway
run: |
git clone --depth=1 --branch 1.3.0 https://github.com/google/highway.git /tmp/highway
cd /tmp/highway
cmake -B _build -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF \
-DHWY_ENABLE_TESTS=OFF -DHWY_ENABLE_EXAMPLES=OFF \
-DCMAKE_INSTALL_PREFIX=/tmp/hwy-install
-DCMAKE_INSTALL_PREFIX=/usr/local
cmake --build _build -j$(nproc 2>/dev/null || sysctl -n hw.ncpu)
cmake --install _build
sudo cmake --install _build

- name: build fastp
run: |
EXTRA_INC="" EXTRA_LIB=""
for prefix in /tmp/hwy-install /tmp/isal-install; do
[ -d "$prefix/include" ] && EXTRA_INC="$EXTRA_INC $prefix/include"
[ -d "$prefix/lib" ] && EXTRA_LIB="$EXTRA_LIB $prefix/lib"
[ -d "$prefix/lib64" ] && EXTRA_LIB="$EXTRA_LIB $prefix/lib64"
done
make -j$(nproc 2>/dev/null || sysctl -n hw.ncpu) \
INCLUDE_DIRS="$EXTRA_INC" LIBRARY_DIRS="$EXTRA_LIB"
run: make -j$(nproc 2>/dev/null || sysctl -n hw.ncpu)

- name: smoke test
run: |
Expand Down
41 changes: 29 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@ BINDIR ?= $(PREFIX)/bin
INCLUDE_DIRS ?=
LIBRARY_DIRS ?=

# Auto-detect library paths via pkg-config (works with conda, brew, system packages)
PKG_CONFIG ?= pkg-config
HWY_CFLAGS := $(shell $(PKG_CONFIG) --cflags libhwy 2>/dev/null)
HWY_LIBS := $(shell $(PKG_CONFIG) --libs-only-L libhwy 2>/dev/null)
ISAL_CFLAGS := $(shell $(PKG_CONFIG) --cflags libisal 2>/dev/null)
ISAL_LIBS := $(shell $(PKG_CONFIG) --libs-only-L libisal 2>/dev/null)
DEFLATE_CFLAGS := $(shell $(PKG_CONFIG) --cflags libdeflate 2>/dev/null)
DEFLATE_LIBS := $(shell $(PKG_CONFIG) --libs-only-L libdeflate 2>/dev/null)

SRC := $(wildcard ${DIR_SRC}/*.cpp)
OBJ := $(patsubst %.cpp,${DIR_OBJ}/%.o,$(notdir ${SRC}))

Expand All @@ -15,23 +24,31 @@ TARGET := fastp
BIN_TARGET := ${TARGET}

CXX ?= g++
CXXFLAGS := -std=c++11 -pthread -g -O3 -MD -MP -I. -I${DIR_INC} $(foreach includedir,$(INCLUDE_DIRS),-I$(includedir)) ${CXXFLAGS}
CXXFLAGS := -std=c++11 -pthread -g -O3 -MD -MP -I. -I${DIR_INC} $(foreach includedir,$(INCLUDE_DIRS),-I$(includedir)) $(HWY_CFLAGS) $(ISAL_CFLAGS) $(DEFLATE_CFLAGS) ${CXXFLAGS}
LIBS := -lisal -ldeflate -lhwy -lpthread

PKG_LDFLAGS := $(HWY_LIBS) $(ISAL_LIBS) $(DEFLATE_LIBS)

UNAME_S := $(shell uname -s)
FIND_STATIC = $(firstword $(foreach d,$(LIBRARY_DIRS),$(wildcard $(d)/lib$(1).a)) $(wildcard /usr/local/lib/lib$(1).a /opt/homebrew/lib/lib$(1).a))
STATIC_LIBS :=
DYNAMIC_LIBS :=
$(foreach lib,isal deflate hwy,\
$(if $(call FIND_STATIC,$(lib)),\
$(eval STATIC_LIBS += $(call FIND_STATIC,$(lib))),\
$(eval DYNAMIC_LIBS += -l$(lib))))

ifeq ($(UNAME_S),Linux)
# Linux: fully static binary
LD_FLAGS := $(foreach librarydir,$(LIBRARY_DIRS),-L$(librarydir)) -static -Wl,--no-as-needed -pthread $(LIBS) $(LD_FLAGS)
ifeq ($(DYNAMIC_LIBS),)
# All .a found: fully static binary (default for Linux)
LD_FLAGS := $(foreach librarydir,$(LIBRARY_DIRS),-L$(librarydir)) $(PKG_LDFLAGS) -static -Wl,--no-as-needed -pthread $(LIBS) $(LD_FLAGS)
else
# Some .a missing (e.g. conda): link .a directly + dynamic fallback
LD_FLAGS := $(foreach librarydir,$(LIBRARY_DIRS),-L$(librarydir)) $(PKG_LDFLAGS) $(STATIC_LIBS) $(DYNAMIC_LIBS) -lpthread $(LD_FLAGS)
endif
else
# macOS: link 3rd-party libs statically via .a when available, fallback to dynamic
FIND_STATIC = $(firstword $(foreach d,$(LIBRARY_DIRS),$(wildcard $(d)/lib$(1).a)) $(wildcard /usr/local/lib/lib$(1).a /opt/homebrew/lib/lib$(1).a))
STATIC_LIBS :=
DYNAMIC_LIBS :=
$(foreach lib,isal deflate hwy,\
$(if $(call FIND_STATIC,$(lib)),\
$(eval STATIC_LIBS += $(call FIND_STATIC,$(lib))),\
$(eval DYNAMIC_LIBS += -l$(lib))))
LD_FLAGS := $(foreach librarydir,$(LIBRARY_DIRS),-L$(librarydir)) $(STATIC_LIBS) $(DYNAMIC_LIBS) -lpthread $(LD_FLAGS)
# macOS: .a preferred, fallback to dynamic
LD_FLAGS := $(foreach librarydir,$(LIBRARY_DIRS),-L$(librarydir)) $(PKG_LDFLAGS) $(STATIC_LIBS) $(DYNAMIC_LIBS) -lpthread $(LD_FLAGS)
endif


Expand Down
4 changes: 0 additions & 4 deletions src/fastqreader.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,7 @@ SOFTWARE.
#include "common.h"
#include <iostream>
#include <fstream>
#if __has_include(<isa-l/igzip_lib.h>)
#include <isa-l/igzip_lib.h>
#else
#include "igzip_lib.h"
#endif
#include "readpool.h"

class FastqReader{
Expand Down
Loading
Loading