Skip to content

Commit 39eb541

Browse files
committed
static linking on os x
1 parent e4ae585 commit 39eb541

File tree

3 files changed

+17
-20
lines changed

3 files changed

+17
-20
lines changed

.travis.yml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,14 @@ env:
1010
- secure: J1ta2/K8lj5dbHRvk+jTUAMICSnepfyc8ILCfM/HFCRaXMJQJTX1HDzEMwK3tAzzKaKEp9Tbm2b3IwE1tCtFaAfYUGozmHLirkFfKqCu/jNUkxL807M8NiqMx+H7tu2aR6t9opYyBjNhtuthbIdir3c42nldYdpse0ZLhzQTLfs=
1111

1212
before_install:
13-
- brew tap homebrew/science
14-
- brew install htslib
13+
- brew install ldc
1514
- git submodule update --init --recursive
16-
- wget https://dl.dropboxusercontent.com/u/7916095/ldc2-0.13.0-osx-x86_64.tar.bz2
17-
- tar xjf ldc2-0.13.0-osx-x86_64.tar.bz2
18-
- export PATH=ldc2-0.13.0-osx-x86_64/bin:$PATH
1915
- wget https://github.com/craigcitro/r-travis/raw/master/scripts/dropbox.sh
2016
- chmod +x dropbox.sh
2117
- curl -L "https://dl.dropboxusercontent.com/u/7916095/shunit2-2.0.3.tgz" | tar zx
2218

2319
script:
24-
- make sambamba-ldmd2-64-osx
20+
- make sambamba-ldmd2-64
2521
- ./.run_tests.sh
2622

2723
after_success:

Makefile

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,37 @@ HTSLIB_PATH=-Lhtslib
55
HTSLIB_SUBCMD=$(HTSLIB_PATH) -Wl,-Bstatic -lhts -Wl,-Bdynamic
66
RDMD_FLAGS=--force --build-only --compiler=$(D_COMPILER) $(D_FLAGS)
77

8+
# Linux & DMD only - this goal is used because of fast compilation speed, during development
89
all: htslib-static
910
mkdir -p build/
1011
rdmd --force --build-only $(D_FLAGS) -c -ofbuild/sambamba.o main.d
1112
gcc -Wl,--gc-sections -o build/sambamba build/sambamba.o $(HTSLIB_SUBCMD) -l:libphobos2.a -lrt -lpthread -lm
1213

14+
PLATFORM := $(shell uname -s)
15+
16+
ifeq "$(PLATFORM)" "Darwin"
17+
LINK_CMD=gcc -dead_strip -lphobos2-ldc -ldruntime-ldc -lm -lpthread htslib/libhts.a build/sambamba.o -o build/sambamba
18+
else
19+
LINK_CMD=gcc -Wl,--gc-sections -o build/sambamba build/sambamba.o $(HTSLIB_SUBCMD) -l:libphobos2-ldc.a -l:libdruntime-ldc.a -lrt -lpthread -lm
20+
endif
21+
22+
# This is the main Makefile goal, used for building releases (best performance)
1323
sambamba-ldmd2-64: htslib-static
1424
mkdir -p build/
1525
ldmd2 @sambamba-ldmd-release.rsp
16-
gcc -Wl,--gc-sections -o build/sambamba build/sambamba.o $(HTSLIB_SUBCMD) -l:libphobos2-ldc.a -l:libdruntime-ldc.a -lrt -lpthread -lm
26+
$(LINK_CMD)
1727

28+
# For debugging; GDB & Valgrind are more friendly to executables created using LDC/GDC than DMD
1829
sambamba-ldmd2-debug: htslib-static
1930
mkdir -p build/
2031
ldmd2 @sambamba-ldmd-debug.rsp
21-
gcc -Wl,--gc-sections -o build/sambamba build/sambamba.o $(HTSLIB_SUBCMD) -l:libphobos2-ldc.a -l:libdruntime-ldc.a -lrt -lpthread -lm
32+
$(LINK_CMD)
2233

2334
htslib-static:
2435
cd htslib && $(MAKE)
2536

2637
# all below link to libhts dynamically for simplicity
2738

28-
sambamba-ldmd2-64-osx:
29-
mkdir -p build/
30-
rdmd --force --build-only --compiler=ldmd2 -IBioD -O -L-lhts -release -inline -noboundscheck -ofbuild/sambamba main.d
31-
3239
sambamba-flagstat:
3340
mkdir -p build/
3441
rdmd $(RDMD_FLAGS) -L-lhts -version=standalone -ofbuild/sambamba-flagstat sambamba/flagstat.d

README.md

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,17 +51,11 @@ which targets LLVM.
5151

5252
## Compiling for Mac OS X
5353

54-
(The Dropbox archive differs from the official LDC release in that it also contains `rdmd` executable from DMD distribution.)
55-
5654
```sh
57-
brew tap homebrew/science
58-
brew install htslib
59-
wget https://dl.dropboxusercontent.com/u/7916095/ldc2-0.13.0-osx-x86_64.tar.bz2
60-
tar xjf ldc2-0.13.0-osx-x86_64.tar.bz2
55+
brew install ldc
6156
git clone --recursive https://github.com/lomereiter/sambamba.git
6257
cd sambamba
63-
export PATH=../ldc2-0.13.0-osx-x86_64/bin:$PATH
64-
make sambamba-ldmd2-64-osx
58+
make sambamba-ldmd2-64
6559
```
6660

6761
## Compiling for Linux using Docker

0 commit comments

Comments
 (0)