Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve windows build. #1380

Merged
merged 1 commit into from
Feb 4, 2022
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
2 changes: 1 addition & 1 deletion .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ install:
- set MSYSTEM=MINGW64
- set PATH=C:/msys64/usr/bin;C:/msys64/mingw64/bin;%PATH%
- set MINGWPREFIX=x86_64-w64-mingw32
- "sh -lc \"pacman -S --noconfirm --needed base-devel mingw-w64-x86_64-toolchain mingw-w64-x86_64-autotools mingw-w64-x86_64-zlib mingw-w64-x86_64-bzip2 mingw-w64-x86_64-xz mingw-w64-x86_64-curl\""
- "sh -lc \"pacman -S --noconfirm --needed base-devel mingw-w64-x86_64-toolchain mingw-w64-x86_64-autotools mingw-w64-x86_64-zlib mingw-w64-x86_64-bzip2 mingw-w64-x86_64-xz mingw-w64-x86_64-curl mingw-w64-x86_64-tools-git\""

build_script:
- set HOME=.
Expand Down
17 changes: 17 additions & 0 deletions INSTALL
Original file line number Diff line number Diff line change
Expand Up @@ -269,3 +269,20 @@ OpenSUSE
--------

sudo zypper install autoconf automake make gcc perl zlib-devel libbz2-devel xz-devel libcurl-devel libopenssl-devel

Windows MSYS2/MINGW64
---------------------

Follow MSYS2 installation instructions at
https://www.msys2.org/wiki/MSYS2-installation/

Then relaunch to MSYS2 shell using the "MSYS2 MinGW x64" executable.
Once in that environment (check $MSYSTEM equals "MINGW64") install the
compilers using pacman -S and the following package list:

base-devel mingw-w64-x86_64-toolchain
mingw-w64-x86_64-libdeflate mingw-w64-x86_64-zlib mingw-w64-x86_64-bzip2
mingw-w64-x86_64-xz mingw-w64-x86_64-curl mingw-w64-x86_64-autotools
mingw-w64-x86_64-tools-git

(The last is only needed for building libraries compatible with MSVC.)
39 changes: 37 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -282,10 +282,10 @@ SHLIB_FLAVOUR = cygdll
lib-shared: cyghts-$(LIBHTS_SOVERSION).dll
else ifeq "$(findstring MSYS,$(PLATFORM))" "MSYS"
SHLIB_FLAVOUR = dll
lib-shared: hts-$(LIBHTS_SOVERSION).dll
lib-shared: hts-$(LIBHTS_SOVERSION).dll hts-$(LIBHTS_SOVERSION).def hts-$(LIBHTS_SOVERSION).lib
else ifeq "$(findstring MINGW,$(PLATFORM))" "MINGW"
SHLIB_FLAVOUR = dll
lib-shared: hts-$(LIBHTS_SOVERSION).dll
lib-shared: hts-$(LIBHTS_SOVERSION).dll hts-$(LIBHTS_SOVERSION).def hts-$(LIBHTS_SOVERSION).lib
else
SHLIB_FLAVOUR = so
lib-shared: libhts.so
Expand Down Expand Up @@ -330,6 +330,41 @@ cyghts-$(LIBHTS_SOVERSION).dll libhts.dll.a: $(LIBHTS_OBJS)
hts-$(LIBHTS_SOVERSION).dll hts.dll.a: $(LIBHTS_OBJS)
$(CC) -shared -Wl,--out-implib=hts.dll.a -Wl,--enable-auto-import -Wl,--exclude-all-symbols $(LDFLAGS) -o $@ -Wl,--whole-archive $(LIBHTS_OBJS) -Wl,--no-whole-archive $(LIBS) -lpthread

hts-$(LIBHTS_SOVERSION).def: hts-$(LIBHTS_SOVERSION).dll
gendef hts-$(LIBHTS_SOVERSION).dll

hts-$(LIBHTS_SOVERSION).lib: hts-$(LIBHTS_SOVERSION).def
dlltool -m i386:x86-64 -d hts-$(LIBHTS_SOVERSION).def -l hts-$(LIBHTS_SOVERSION).lib

# Bundling libraries, binaries, dll dependencies, and licenses into a
# single directory. NB: This is not needed for end-users, but a test bed
# for maintainers building binary distributions.
#
# NOTE: only tested on the supported MSYS2/MINGW64 environment.
dist-windows: DESTDIR=
dist-windows: prefix=dist-windows
dist-windows: install
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make dist-windows brought up the following error with MINGW64.

cp: cannot stat '/mingw64/share/licenses/libdeflate': No such file or directory
make: *** [Makefile:349: dist-windows] Error 1

Do we require libdeflate for the Windows build?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Require - no. However it's useful. The purpose really for dist-windows is for maintainers (eg us) producing decent windows binaries. My thought was we may want this to be part of a CI build artifact.

So I'm not really expecting end-users to have this as a requirement for building, but for us wanting to produce binaries (and Windows is really the only system where there aren't easy alternatives available to people), then it's easier done as a Makefile rule than a completely separate repository as we use right now for the distribution code.

I suspect we should, for now, just not document the existance of the dist-windows target.

cp hts-$(LIBHTS_SOVERSION).def hts-$(LIBHTS_SOVERSION).lib dist-windows/lib
cp `ldd hts-$(LIBHTS_SOVERSION).dll| awk '/mingw64/ {print $$3}'` dist-windows/bin
mkdir -p dist-windows/share/licenses/htslib
-cp -r /mingw64/share/licenses/mingw-w64-libraries \
/mingw64/share/licenses/brotli \
/mingw64/share/licenses/bzip2 \
/mingw64/share/licenses/gcc-libs \
/mingw64/share/licenses/libdeflate \
/mingw64/share/licenses/libpsl \
/mingw64/share/licenses/libtre \
/mingw64/share/licenses/libwinpthread \
/mingw64/share/licenses/openssl \
/mingw64/share/licenses/xz \
/mingw64/share/licenses/zlib \
/mingw64/share/licenses/zstd \
dist-windows/share/licenses/
-cp -r /usr/share/licenses/curl \
dist-windows/share/licenses/
cp LICENSE dist-windows/share/licenses/htslib/


# Target to allow htslib.mk to build all the object files before it
# links the shared and static libraries.
hts-object-files: $(LIBHTS_OBJS)
Expand Down