SFTtech / nyan

Typesafe hierarchical key-value database with inheritance and dynamic patching :smiley_cat:
Other
209 stars 29 forks source link

Building nyan with GCC #3

Closed inakoll closed 8 years ago

inakoll commented 8 years ago

nyan uses advanced C++ features (c++14 relaxed constexpr) which are only available in recent compiler releases (gcc>=5 && clang>=3.4).

I successfully built nyan with clang++-3.8 but failed with g++5.3.0 because some virtual functions in nyan_object.h are not defined. clang doesn't bother but g++ can't link libnyan.so and is complaining about missing vtables.

Bellow the Dockerfile used to investigate this issue :

from ubuntu:14.04

RUN apt-get install -y software-properties-common wget && \ 
    add-apt-repository ppa:ubuntu-toolchain-r/test && \
    echo deb http://llvm.org/apt/trusty/ llvm-toolchain-trusty-3.8 main >> /etc/apt/sources.list && \
    wget -O - http://llvm.org/apt/llvm-snapshot.gpg.key|sudo apt-key add - && \
    apt-get update && \
    apt-get install -y \
    git gcc-5 g++-5 make libtool autoconf automake flex bison clang-3.8 clang++-3.8

WORKDIR /
RUN git clone https://github.com/SFTtech/nyan.git nyan-gcc && cp -r /nyan-gcc /nyan-clang

# GCC Build
# Build doesn't work with GCC yet
# WORKDIR /nyan-gcc
# RUN ./autogen.sh && libtoolize && aclocal && autoheader && autoconf && automake && ./configure CC=gcc-5 CXX=g++-5 && make

# Clang Build
WORKDIR /nyan-clang
RUN ./autogen.sh && libtoolize && aclocal && autoheader && autoconf && automake && ./configure CC=clang-3.8 CXX=clang++-3.8 && make
# FIXME: We shouldn't have to call every single autocancer tool. The following command line should be just enough to build nyan.
# RUN ./autogen.sh && ./configure CC=clang-3.8 CXX=clang++-3.8 && make

Additionally it seems there is also a minor issue with the autogen.sh script. ./autogen.sh && ./configure should do the job but I wasn't able to build nyan without calling every single autotool script : ./autogen.sh && libtoolize && aclocal && autoheader && autoconf && automake && ./configure

I'm not an expert on that matter but should we add libtoolize && aclocal && autoheader && autoconf && automake to./autogen.sh` ? What is the established practice here ?

TheJJ commented 8 years ago

On my system the current master can be build with just ./autogen.sh, ./configure, make. I have automake 1.15, autoconf 2.69, gcc 5.3.0. Can you try again? I fixed the c++ coding errors i hope.

inakoll commented 8 years ago

OK now it builds with GCC too. I've got :

I'll try as soon as I can with automake 1.15 then. Are you sure your building from a clean directory ?

TheJJ commented 8 years ago

I cloned it to /tmp/, so it was pretty clean :) But if automake-1.14 doesn't work, we should fix it, many distros still have it.

inakoll commented 8 years ago

OK so I've [dirtily] installed automake 1.15 on 14.04 and it worked. automake 1.15 comes with ubuntu 15.10 so I've tried a clean install on 15.10 and it failed, go figure..

from ubuntu:15.10

RUN apt-get install -y software-properties-common wget && \
    add-apt-repository ppa:ubuntu-toolchain-r/test && \
    echo deb http://llvm.org/apt/wily/ llvm-toolchain-wily-3.8 main >> /etc/apt/sources.list && \
    wget -O - http://llvm.org/apt/llvm-snapshot.gpg.key|apt-key add - && \
    apt-get update && \
    apt-get install -y \
    git gcc-5 g++-5 make libtool autoconf automake flex bison clang-3.8 clang++-3.8

WORKDIR /
RUN git clone https://github.com/SFTtech/nyan.git nyan-gcc && cp -r /nyan-gcc /nyan-clang

# GCC Build
# Build doesn't work with GCC yet
WORKDIR /nyan-gcc
#RUN ./autogen.sh && libtoolize && aclocal && autoheader && autoconf && automake && ./configure CC=gcc-5 CXX=g++-5 && make
RUN ./autogen.sh ./configure CC=gcc-5 CXX=g++-5 && make
inakoll commented 8 years ago

Ho but wait! This time it works out of the box with ubuntu 15.10 clang-3.8 and automake 1.15 ! This is driving me crazy :)

inakoll commented 8 years ago

TL;DR : Everything is fixed now!

I was really too tired to think straight yesterday. If you look closely at the last line of the last Dockerfile you might spot a missing '&&' between autogen.sh and configure... I've fixed this and it now I can build with gcc-5 or clang-3.5 on ubuntu 14.04 or 15.10 :

from ubuntu:14.04

RUN apt-get install -y software-properties-common wget && \
    add-apt-repository ppa:ubuntu-toolchain-r/test && \
    echo deb http://llvm.org/apt/trusty/ llvm-toolchain-trusty-3.5 main >> /etc/apt/sources.list && \
    wget -O - http://llvm.org/apt/llvm-snapshot.gpg.key|apt-key add - && \
    apt-get update && \
    apt-get install -y \
    git gcc-5 g++-5 make libtool autoconf automake flex bison clang-3.5 clang++-3.5

WORKDIR /
RUN git clone https://github.com/SFTtech/nyan.git nyan-gcc && cp -r /nyan-gcc /nyan-clang

# GCC Build
# Build doesn't work with GCC yet
WORKDIR /nyan-gcc
RUN ./autogen.sh && ./configure CC=gcc-5 CXX=g++-5 && make

# Clang Build
WORKDIR /nyan-clang
RUN ./autogen.sh && ./configure CC=clang-3.5 CXX=clang++-3.5 && make
from ubuntu:15.10

RUN apt-get update && \
    apt-get install -y \
    git gcc-5 g++-5 make libtool autoconf automake flex bison clang-3.5 clang++-3.5

WORKDIR /
RUN git clone https://github.com/SFTtech/nyan.git nyan-gcc && cp -r /nyan-gcc /nyan-clang

# GCC Build
WORKDIR /nyan-gcc
RUN ./autogen.sh && ./configure CC=gcc-5 CXX=g++-5 && make

# Clang Build
WORKDIR /nyan-clang
RUN ./autogen.sh && ./configure CC=clang-3.5 CXX=clang++-3.5 && make

Conclusion :

Verified minimum requirements (as of today 2016-04-05) :

I really don't know what happened to me yesterday. Sorry for the burden! :D

TheJJ commented 8 years ago

Nice. We should figure out how we can add -std=c++1y if clang has 3.4 but -std=c++14 if it's more recent. In the openage buildsystem we already did this, i have no idea how to do that with autocancer though.

inakoll commented 8 years ago

Piece of cake, really. See #4 and #5 ;)

inakoll commented 8 years ago

For the record, I've updated my test dockerfile for Ubuntu 14.04 that now use clang-3.4 instead of clang-3.5 :

from ubuntu:14.04

RUN apt-get install -y software-properties-common && \ 
    add-apt-repository ppa:ubuntu-toolchain-r/test && \
    apt-get update && \
    apt-get install -y \
    git gcc-5 g++-5 make libtool autoconf automake flex bison clang-3.4 clang++-3.4

WORKDIR /
RUN git clone https://github.com/SFTtech/nyan.git nyan-gcc && cp -r /nyan-gcc /nyan-clang

# GCC Build
# Build doesn't work with GCC yet
WORKDIR /nyan-gcc
RUN ./autogen.sh && ./configure CC=gcc-5 CXX=g++-5 && make

# Clang Build
WORKDIR /nyan-clang
RUN ./autogen.sh && ./configure CC=clang CXX=clang++ && make

Also, not a big surprise but the project builds fine on Archlinux : :+1:

from pritunl/archlinux:2016-03-26

RUN pacman -Sy && pacman -S --noconfirm gcc clang make autoconf automake libtool flex git

RUN git clone https://github.com/SFTtech/nyan.git nyan-gcc && cp -r /nyan-gcc /nyan-clang

# GCC Build
WORKDIR /nyan-gcc
RUN ./autogen.sh && ./configure CC=gcc CXX=g++ && make

# Clang Build
WORKDIR /nyan-clang
#RUN ./autogen.sh && ./configure CC=clang CXX=clang++ && make
TheJJ commented 8 years ago

I guess we can close this now as it's working? :)

inakoll commented 8 years ago

Yes we can!