Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save x-yuri/38785d5757133c1a8b8b0aaebb0ad7e1 to your computer and use it in GitHub Desktop.
Save x-yuri/38785d5757133c1a8b8b0aaebb0ad7e1 to your computer and use it in GitHub Desktop.
Building mecab (with its perl module) with debug symbols

Building mecab (with its perl module) with debug symbols

Dockerfile:

FROM alpine:3.20.3
RUN set -x && apk add git build-base autoconf gdb automake libtool gettext-dev perl-dev \
    && git clone https://github.com/taku910/mecab \
    && cd mecab \
    && git checkout 05481e751dd5aa536a2bace46715ce54568b972a \
    && sed -Ei '/if test -n "\$GCC"/,/fi/ s/^/# /' mecab/configure.in \
    && cd mecab \
    && autoreconf -i \
    && ./configure CXXFLAGS='-g3 -O0' \
    && make install \
    && cd perl \
    && sed -Ei '/CC/a"CCFLAGS" => "-g3", "OPTIMIZE" => "-O0",' Makefile.PL \
    && perl Makefile.PL \
    && { grep -E '^(CCFLAGS|OPTIMIZE|LDDLFLAGS) =' Makefile || true; } \
    && make install
$ docker build -t i .
...
+ grep -E '^(CCFLAGS|OPTIMIZE|LDDLFLAGS) =' Makefile
LDDLFLAGS = -shared -Os -fstack-clash-protection -Wformat -Werror=format-security -fno-plt -O2 -L/usr/local/lib -fstack-protector-strong
CCFLAGS = -g3
OPTIMIZE = -O0
+ make install
...
g++ -c  -I/usr/local/include -g3 -O0   -DVERSION=\"0.996\" -DXS_VERSION=\"0.996\" -fPIC "-I/usr/lib/perl5/core_perl/CORE"   MeCab_wrap.cxx
...
LD_RUN_PATH="/usr/local/lib:/usr/lib" g++  -shared -Os -fstack-clash-protection -Wformat -Werror=format-security -fno-plt -O2 -L/usr/local/lib -fstack-protector-strong  MeCab_wrap.o  -o blib/arch/auto/MeCab/MeCab.so  \
   -L/usr/local/lib -lmecab -lstdc++   \
...

To change LDDLFLAGS:

Dockerfile:

FROM alpine:3.20.3
RUN set -x && apk add git build-base autoconf gdb automake libtool gettext-dev perl-dev \
    && git clone https://github.com/taku910/mecab \
    && cd mecab \
    && git checkout 05481e751dd5aa536a2bace46715ce54568b972a \
    && sed -Ei '/if test -n "\$GCC"/,/fi/ s/^/# /' mecab/configure.in \
    && cd mecab \
    && autoreconf -i \
    && ./configure CXXFLAGS='-g3 -O0' \
    && make install \
    && cd perl \
    && sed -Ei '/CC/a"CCFLAGS" => "-g3", "OPTIMIZE" => "-O0", "LDDLFLAGS" => "-shared",' Makefile.PL \
    && sed -Ei '/foreach my \$m /anext if $m eq "lddlflags";' /usr/share/perl5/core_perl/ExtUtils/MM_Unix.pm \
    && perl Makefile.PL \
    && { grep -E '^(CCFLAGS|OPTIMIZE|LDDLFLAGS) =' Makefile || true; } \
    && make install
$ docker build -t i .
...
+ grep -E '^(CCFLAGS|OPTIMIZE|LDDLFLAGS) =' Makefile
LDDLFLAGS = -shared
CCFLAGS = -g3
OPTIMIZE = -O0
+ make install
...
g++ -c  -I/usr/local/include -g3 -O0   -DVERSION=\"0.996\" -DXS_VERSION=\"0.996\" -fPIC "-I/usr/lib/perl5/core_perl/CORE"   MeCab_wrap.cxx
...
LD_RUN_PATH="/usr/local/lib:/usr/lib" g++  -shared  MeCab_wrap.o  -o blib/arch/auto/MeCab/MeCab.so  \
   -L/usr/local/lib -lmecab -lstdc++   \
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment