Lambdaカクテル

Common Lispを書くMT-03ライダー(初心者)です

Let's get arrested badge

Dockerではうまく処理系が切り変わらない?Common Lispの環境構築するときは処理系の統一に注意しよう

TL;DR

  • Roswellで処理系を指定しても,Roswellでインストールしたコマンド類はそのコマンドをビルドしたときの処理系で実行される?
  • シェルからコマンドを呼ばずにros runで実行するなどの手立てがある

Dockerで再現したがシェルで実験すると再現しないので困っている.

FROM ubuntu:16.04

ENV libs 'automake libcurl4-gnutls-dev make gcc curl bzip2 locales libev-dev tidy git'
RUN apt-get update \
  && apt-get install -y ${libs}

ENV roswell_archive_url 'https://github.com/roswell/roswell/archive/release.tar.gz'
RUN echo 'install roswell' \
  && curl -SL ${roswell_archive_url} \
  | tar -xzC /tmp/ \
  && cd /tmp/roswell-release \
  && sh bootstrap \
  && ./configure \
  && make \
  && make install \
  && rm -rf /tmp/roswell-release

# locale setting
RUN locale-gen en_US.UTF-8
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8

RUN ros setup
RUN ros install ccl-bin/1.11
RUN ros use ccl-bin/1.11

RUN ros install fukamachi/qlot
RUN ros install clack
ENV PATH /root/.roswell/bin:/usr/local/bin:$PATH

# Assuming whole application directory is mounted as /app
WORKDIR /app/
CMD ["bash"]

こういったDockerfileで環境を作る.この時点でqlotがインストールされるはず.

$ docker build -t my-roswell .
$ docker run -it --rm my-roswell bash
# echo '(format t "~S~%" *features*)' >> ~/.roswell/init.lisp
# echo 'ql alexandria :latest' >> qlfile
# qlot install
features: (:ROS.INIT :X86-64 :64-BIT :64-BIT-REGISTERS :ALIEN-CALLBACKS
           :ANSI-CL :C-STACK-IS-CONTROL-STACK :CALL-SYMBOL :COMMON-LISP
           :COMPACT-INSTANCE-HEADER :COMPARE-AND-SWAP-VOPS :COMPLEX-FLOAT-VOPS
           :CYCLE-COUNTER :ELF :FLOAT-EQL-VOPS :FP-AND-PC-STANDARD-SAVE
           :GCC-TLS :GENCGC :IEEE-FLOATING-POINT :IMMOBILE-CODE :IMMOBILE-SPACE
           :INTEGER-EQL-VOP :LARGEFILE :LINKAGE-TABLE :LINUX :LITTLE-ENDIAN
           :OS-PROVIDES-DLADDR :OS-PROVIDES-DLOPEN :OS-PROVIDES-GETPROTOBY-R
           :OS-PROVIDES-POLL :OS-PROVIDES-PUTWC :OS-PROVIDES-SUSECONDS-T
           :PACKAGE-LOCAL-NICKNAMES :RELOCATABLE-HEAP :SB-DOC :SB-EVAL
           :SB-FUTEX :SB-LDB :SB-PACKAGE-LOCKS :SB-SIMD-PACK
           :SB-SOURCE-LOCATIONS :SB-THREAD :SB-UNICODE :SBCL
           :STACK-ALLOCATABLE-CLOSURES :STACK-ALLOCATABLE-FIXED-OBJECTS
           :STACK-ALLOCATABLE-LISTS :STACK-ALLOCATABLE-VECTORS
           :STACK-GROWS-DOWNWARD-NOT-UPWARD :UNDEFINED-FUN-RESTARTS :UNIX
           :UNWIND-TO-FRAME-AND-CALL-VOP)
...

SBCLが動いてるやんか!!CCLが動いてほしいの!!

その場でできる対策としては,以下のようにqlotコマンドではなく直接qlotをロードして関数を呼び出すこと.

ros run -e "(progn (ql:quickload :qlot) (qlot:install))" -q

シェルで実験

$ ros install sbcl/1.5.0
$ ros use sbcl/1.5.0
$ ros install qlot
$ echo '(format t "~S~%" *features*)' >> ~/.roswell/init.lisp
$ echo 'ql alexandria :latest' >> qlfile
$ qlot install
(:ROS.INIT :X86-64 :64-BIT :64-BIT-REGISTERS :ALIEN-CALLBACKS :ANSI-CL :AVX2
 :C-STACK-IS-CONTROL-STACK :CALL-SYMBOL :COMMON-LISP :COMPACT-INSTANCE-HEADER
 :COMPARE-AND-SWAP-VOPS :CYCLE-COUNTER :ELF :FP-AND-PC-STANDARD-SAVE :GENCGC
 :IEEE-FLOATING-POINT :IMMOBILE-CODE :IMMOBILE-SPACE :INTEGER-EQL-VOP
 :LARGEFILE :LINKAGE-TABLE :LINUX :LITTLE-ENDIAN :OS-PROVIDES-BLKSIZE-T
 :OS-PROVIDES-DLADDR :OS-PROVIDES-DLOPEN :OS-PROVIDES-GETPROTOBY-R
 :OS-PROVIDES-POLL :OS-PROVIDES-PUTWC :OS-PROVIDES-SUSECONDS-T
 :PACKAGE-LOCAL-NICKNAMES :RELOCATABLE-HEAP :SB-CORE-COMPRESSION :SB-DOC
 :SB-EVAL :SB-FUTEX :SB-LDB :SB-PACKAGE-LOCKS :SB-SIMD-PACK :SB-SIMD-PACK-256
 :SB-SOURCE-LOCATIONS :SB-THREAD :SB-UNICODE :SBCL :STACK-ALLOCATABLE-CLOSURES
 :STACK-ALLOCATABLE-FIXED-OBJECTS :STACK-ALLOCATABLE-LISTS
 :STACK-ALLOCATABLE-VECTORS :STACK-GROWS-DOWNWARD-NOT-UPWARD
 :UNDEFINED-FUN-RESTARTS :UNIX :UNWIND-TO-FRAME-AND-CALL-VOP)
...

$ ros install ccl-bin/1.11
$ ros use ccl-bin/1.11
$ qlot install
(:ROS.INIT :PRIMARY-CLASSES :COMMON-LISP :OPENMCL :CCL :CCL-1.2 :CCL-1.3 :CCL-1.4 :CCL-1.5 :CCL-1.6 :CCL-1.7 :CCL-1.8 :CCL-1.9 :CCL-1.10 :CCL-1.11 :CLOZURE :CLOZURE-COMMON-LISP :ANSI-CL :UNIX :OPENMCL-UNICODE-STRINGS :IPV6 :OPENMCL-NATIVE-THREADS :OPENMCL-PARTIAL-MOP :MCL-COMMON-MOP-SUBSET :OPENMCL-MOP-2 :OPENMCL-PRIVATE-HASH-TABLES :STATIC-CONSES-SHOULD-WORK-WITH-EGC-IN-CCL :X86-64 :X86_64 :X86-TARGET :X86-HOST :X8664-TARGET :X8664-HOST :LINUX-HOST :LINUX-TARGET :LINUXX86-TARGET :LINUXX8664-TARGET :LINUXX8664-HOST :64-BIT-TARGET :64-BIT-HOST :LINUX :LITTLE-ENDIAN-TARGET :LITTLE-ENDIAN-HOST)
...

あれ〜・・・こんどはちゃんと処理系が切り替わってる・・・

どうしてこうなってしまうのかまるで分からないので,何か知見をお持ちの方がいらっしゃいましたら教えてください・・・