EnterpriseDB / mysql_fdw

PostgreSQL foreign data wrapper for MySQL
Other
532 stars 163 forks source link

Build fails in Alpine #187

Open agarciamontoro opened 5 years ago

agarciamontoro commented 5 years ago

The build fails in Alpine Linux with the following error:

mysql_fdw.c: In function 'mysql_load_library':
mysql_fdw.c:217:56: error: 'RTLD_DEEPBIND' undeclared (first use in this function); did you mean 'RTLD_DEFAULT'?
  mysql_dll_handle = dlopen(_MYSQL_LIBNAME, RTLD_LAZY | RTLD_DEEPBIND);
                                                        ^~~~~~~~~~~~~
                                                        RTLD_DEFAULT
mysql_fdw.c:217:56: note: each undeclared identifier is reported only once for each function it appears in
make: *** [<builtin>: mysql_fdw.o] Error 1

A minimal Dockerfile to reproduce the error:

FROM postgres:11-alpine

ENV MYSQL_FDW_VERSION=REL-2_5_3

RUN apk add --no-cache \
    git \
    libc-dev \
    mariadb-dev \
    make \
    gcc

RUN git clone -b "$MYSQL_FDW_VERSION" https://github.com/EnterpriseDB/mysql_fdw.git /tmp/mysql_fdw

RUN cd /tmp/mysql_fdw && make USE_PGXS=1

The build succeeds when removing the RTLD_DEEPBIND flag.

youkefan18 commented 4 years ago

Hi guys, is there anyone looking into this? Seems alpine should apply same logic as freeBSD?

Currently I can only sed this line to remove RTLD_DEEPBIND as a workaround...

alexwebb-cbi commented 4 years ago

Also ran into this today. Had to add clang and llvm9 as well to get it to build and install correctly.

Here's my Dockerfile, adapted from agarciamontoro's above:

# adapted from https://github.com/EnterpriseDB/mysql_fdw/issues/187

# start with official Postgres image
FROM postgres:11.6-alpine

# version of MySQL foreign data wrapper to use
ENV MYSQL_FDW_VERSION=REL-2_5_3

# add various dependencies for mysql_fdw build process
RUN apk add --no-cache make gcc libc-dev clang llvm9 mariadb-dev

# grab mysql_fdw source (see https://github.com/EnterpriseDB/mysql_fdw)
RUN wget -c https://github.com/EnterpriseDB/mysql_fdw/archive/${MYSQL_FDW_VERSION}.tar.gz -O - | tar -xz -C /usr/local/lib/

# fix an error in mysql_fdw.c
RUN sed -i 's/ | RTLD_DEEPBIND//' /usr/local/lib/mysql_fdw-${MYSQL_FDW_VERSION}/mysql_fdw.c

# build and install the extension
RUN cd /usr/local/lib/mysql_fdw-${MYSQL_FDW_VERSION} && make USE_PGXS=1 && make USE_PGXS=1 install