jts / sga

de novo sequence assembler using string graphs
http://genome.cshlp.org/content/22/3/549
237 stars 82 forks source link

Fix gcc6 issues - made code C++14 friendly #110

Closed mateidavid closed 8 years ago

mateidavid commented 8 years ago

As per https://gcc.gnu.org/gcc-6/changes.html , the default C++ dialect in GCC 6 is updated from GNU++98 all the way to GNU++14. This causes compile errors for C++ programs that are not C++14 (or C++11) compliant, and do not request a specific dialect.

With this pull request, SGA can be compiled by GCC 6.0.0 using dialects C++98, C++11, and C++14. I also checked older GCC versions (4.8.4 on Trusty and 5.2.1 on Wily) for C++98 and C++11, but not C++14.

Note- SGA depends on BamTools, which has its own share of GCC 6 problems, which I addressed here: https://github.com/pezmaster31/bamtools/pull/116 . If I understand correctly, the proposed fix forces libbamtools.a to be built using the C++98 ABI. With the default configuration, SGA would then be built using the C++14 ABI. Sample differences are here: https://gcc.gnu.org/wiki/Cxx11AbiCompatibility (couldn't find one about C++14 ABI). A quick glance suggests there are no problematic symbols being used.

mateidavid commented 8 years ago

Here is a Dockerfile demonstrating the build on Debian Experimental using GCC 6.0.0 (thanks @mr-c ):

# BamTools and SGA version 2.4.0 on Debian Experimental
#
FROM debian:experimental

# install g++, make
RUN apt-get update && apt-get install -y -t experimental build-essential

# install other build tools
RUN apt-get update && apt-get install -y automake cmake git libsparsehash-dev zlib1g-dev

# download BamTools
RUN mkdir /src && \
    cd /src && \
    git clone --branch add-c++98-compile-and-link-flag --depth 1 https://github.com/mateidavid/bamtools.git
#    git clone --branch v2.4.0 --depth 1 https://github.com/pezmaster31/bamtools.git

# build and install BamTools
RUN mkdir -p /src/bamtools/build && \
    cd /src/bamtools/build && \
    cmake .. && \
    make && \
    make install

# download SGA
RUN cd /src && \
    git clone --branch fix-gcc6-c++14-friendly --depth 1 https://github.com/mateidavid/sga.git
#    git clone https://github.com/jts/sga.git

# build and install SGA
RUN cd /src/sga/src && \
    ./autogen.sh && \
    ./configure --with-bamtools=/usr/local && \
    make && \
    make install