From accb698f6687ceb7b7a5db38cedf2bb11769a393 Mon Sep 17 00:00:00 2001 From: difcsi Date: Mon, 8 Jun 2026 23:45:36 +0100 Subject: [PATCH 1/2] feat: migrate container setup --- .circleci/build-dependencies.txt | 31 ++++++++++++++ .circleci/config.yml | 10 +---- .devcontainer/devcontainer.json | 14 +++++++ Dockerfile | 40 +++++++++++++++++++ buildtest/Dockerfile.template | 34 ---------------- buildtest/Makefile | 3 -- buildtest/circleci-default/Makefile | 6 --- buildtest/circleci-default/README | 2 - .../circleci-default/scrape-circleci.awk | 35 ---------------- buildtest/debian-buster/Dockerfile | 30 -------------- buildtest/debian-stretch/Dockerfile | 30 -------------- buildtest/rules.mk | 6 --- buildtest/ubuntu-18.04/Dockerfile | 30 -------------- buildtest/ubuntu-20.04/Dockerfile | 30 -------------- 14 files changed, 86 insertions(+), 215 deletions(-) create mode 100644 .circleci/build-dependencies.txt create mode 100644 .devcontainer/devcontainer.json create mode 100644 Dockerfile delete mode 100644 buildtest/Dockerfile.template delete mode 100644 buildtest/Makefile delete mode 100644 buildtest/circleci-default/Makefile delete mode 100644 buildtest/circleci-default/README delete mode 100644 buildtest/circleci-default/scrape-circleci.awk delete mode 100644 buildtest/debian-buster/Dockerfile delete mode 100644 buildtest/debian-stretch/Dockerfile delete mode 100644 buildtest/rules.mk delete mode 100644 buildtest/ubuntu-18.04/Dockerfile delete mode 100644 buildtest/ubuntu-20.04/Dockerfile diff --git a/.circleci/build-dependencies.txt b/.circleci/build-dependencies.txt new file mode 100644 index 00000000..708d01cb --- /dev/null +++ b/.circleci/build-dependencies.txt @@ -0,0 +1,31 @@ +build-essential +libbsd-dev +libelf-dev +libdw-dev +binutils-dev +zlib1g-dev +autoconf +automake +libtool +pkg-config +autoconf-archive +opam +libgmp-dev +default-jdk-headless +python3 +make +git +gawk +gdb +wget +libc6-dbg +libunwind-dev +libunwind-dev:i386 +linux-libc-dev-i386-cross +libc6-dev-i386 +libboost-iostreams-dev +libboost-regex-dev +libboost-serialization-dev +libboost-filesystem-dev +libffi-dev +gettext-base \ No newline at end of file diff --git a/.circleci/config.yml b/.circleci/config.yml index 772a4d02..6b5f83d3 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -13,15 +13,7 @@ jobs: apt update # MARKER BEGIN PACKAGES +1 [[:blank:]]([^#]+)# DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt install -y \ - build-essential libbsd-dev libelf-dev libdw-dev binutils-dev zlib1g-dev \ - autoconf automake libtool pkg-config autoconf-archive \ - opam libgmp-dev \ - default-jdk-headless python3 \ - make git gawk gdb wget libc6-dbg \ - libunwind-dev libunwind-dev:i386 linux-libc-dev-i386-cross libc6-dev-i386 \ - libboost-iostreams-dev libboost-regex-dev \ - libboost-serialization-dev libboost-filesystem-dev libffi-dev \ - gettext-base # for envsubst + $(cat .circleci/build-dependencies.txt) # MARKER END PACKAGES - checkout - run: diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 00000000..c5ab4f95 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,14 @@ +{ + "name": "liballocs", + "build": { + "dockerfile": "../Dockerfile", + "context": "..", + "target": "base", + "args": { + "user": "user" + } + }, + "workspaceFolder": "/usr/local/src/liballocs", + "remoteUser": "user", + "postCreateCommand": "git submodule update --init --recursive && make -C contrib -j$(nproc) && ./autogen.sh && (. contrib/env.sh && ./configure --prefix=/usr/local) && make -j$(nproc)" +} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..feea2355 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,40 @@ +ARG DISTRIBUTION=ubuntu:24.04 +FROM ${DISTRIBUTION} AS base + +ARG user=user +ARG MAKE_PARALLELISM=4 + +RUN apt-get update && apt-get install -y sudo adduser +RUN adduser ${user} && \ + echo "${user} ALL=(root) NOPASSWD:ALL" > /etc/sudoers && \ + chmod 0440 /etc/sudoers +RUN mkdir -p /usr/local/src && chown root:${user} /usr/local/src && \ + chmod g+w /usr/local/src +RUN mkdir -p /usr/lib/meta && chown root:staff /usr/lib/meta && \ + chmod g+w /usr/lib/meta +RUN dpkg --add-architecture i386 +COPY .circleci/build-dependencies.txt /tmp/ +RUN apt-get update && \ + env DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get install -y \ + $(cat /tmp/build-dependencies.txt) +USER ${user} + +FROM base AS full +ARG user=user +ARG MAKE_PARALLELISM=4 + +COPY --chown=${user}:${user} . /usr/local/src/liballocs/ +RUN cd /usr/local/src/liballocs && \ + git submodule update --init --recursive && \ + make -C contrib -j${MAKE_PARALLELISM} +RUN cd /usr/local/src/liballocs && \ + ./autogen.sh && \ + (. contrib/env.sh && ./configure --prefix=/usr/local) && \ + make -j${MAKE_PARALLELISM} +RUN sudo mkdir -p /usr/lib/meta && sudo chown root:${user} /usr/lib/meta && \ + sudo chmod g+w /usr/lib/meta +# XXX: skip doing this for now, since the distro's pre-built libc will often +# use DWARF 5 and our tools can't hack it. +#RUN cd /usr/local/src/liballocs && \ +# make -f tools/Makefile.meta \ +# $(for libname in `ldd /bin/true | sed -En '/[[:blank:]]*([^[:blank:]]* => )?(.*) \(0x[0-9a-f]+\)/ {s//\2/;p}' | egrep 'libc\.so\.6|ld-linux.*\.so' | xargs readlink -f`; do echo "/usr/lib/meta${libname}-meta.so"; done) diff --git a/buildtest/Dockerfile.template b/buildtest/Dockerfile.template deleted file mode 100644 index cc766770..00000000 --- a/buildtest/Dockerfile.template +++ /dev/null @@ -1,34 +0,0 @@ -FROM $DISTRIBUTION - -ARG user -RUN apt-get update && apt-get install -y sudo adduser -RUN adduser ${user:-user} && \ - echo "${user:-user} ALL=(root) NOPASSWD:ALL" > /etc/sudoers && \ - chmod 0440 /etc/sudoers -RUN mkdir -p /usr/local/src && chown root:user /usr/local/src && \ - chmod g+w /usr/local/src -USER ${user:-user} -RUN sudo mkdir -p /usr/lib/meta && sudo chown root:staff /usr/lib/meta && \ - sudo chmod g+w /usr/lib/meta -RUN sudo dpkg --add-architecture i386 -RUN sudo apt-get update -RUN sudo env DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get install -y $PACKAGES -# We have a few options. -# - clone from GitHub (done here) -# - clone the repo this Dockerfile exists within -# - the same but applying any staged changes -RUN cd /usr/local/src && git clone https://github.com/stephenrkell/liballocs.git -RUN cd /usr/local/src/liballocs && \ - git submodule update --init --recursive && \ - make -C contrib -j${MAKE_PARALLELISM:-4} -RUN cd /usr/local/src/liballocs && \ - ./autogen.sh && \ - (. contrib/env.sh && ./configure --prefix=/usr/local) && \ - make -j4 -RUN sudo mkdir -p /usr/lib/meta && sudo chown root:user /usr/lib/meta && \ - sudo chmod g+w /usr/lib/meta -# XXX: skip doing this for now, since the distro's pre-built libc will often -# use DWARF 5 and, and our tools can't hack it. -#RUN cd /usr/local/src/liballocs && \ -# make -f tools/Makefile.meta \ -# $(for libname in `ldd /bin/true | sed -En '/[[:blank:]]*([^[:blank:]]* => )?(.*) \(0x[0-9a-f]+\)/ {s//\2/;p}' | egrep 'libc\.so\.6|ld-linux.*\.so' | xargs readlink -f`; do echo "/usr/lib/meta${libname}-meta.so"; done) diff --git a/buildtest/Makefile b/buildtest/Makefile deleted file mode 100644 index b8343f57..00000000 --- a/buildtest/Makefile +++ /dev/null @@ -1,3 +0,0 @@ -.PHONY: default -default: - for d in $(shell find -mindepth 1 -maxdepth 1 -type d); do $(MAKE) -C $$d -f ../rules.mk `if [ -e $$d/Makefile ]; then printf "%s" "-f Makefile"; fi` Dockerfile ; done diff --git a/buildtest/circleci-default/Makefile b/buildtest/circleci-default/Makefile deleted file mode 100644 index c17dff93..00000000 --- a/buildtest/circleci-default/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -# we use a twist on the default rules: scrape the packages and distro from -# the CircleCI config -# FIXME: the rest of the logic is duplicated so liable to shift... ideally -# we would generate more -Dockerfile.env: ../../.circleci/config.yml - cat $< | awk -f scrape-circleci.awk > $@ || (rm -f $@; false) diff --git a/buildtest/circleci-default/README b/buildtest/circleci-default/README deleted file mode 100644 index 0fe3b7a0..00000000 --- a/buildtest/circleci-default/README +++ /dev/null @@ -1,2 +0,0 @@ -This directory lets you build a Dockerfile that *should* mirror the -CircleCI config that gets tested with each push. diff --git a/buildtest/circleci-default/scrape-circleci.awk b/buildtest/circleci-default/scrape-circleci.awk deleted file mode 100644 index 7459683a..00000000 --- a/buildtest/circleci-default/scrape-circleci.awk +++ /dev/null @@ -1,35 +0,0 @@ -BEGIN { - begin_marker_marker = "# MARKER BEGIN ([A-Z_]*)( +\\+([0-9]+)( +([^[:blank:]]+))?)?" - end_marker_marker = "# MARKER END ([A-Z_]*)" - skipctr=0 - regex="" -} - -$0 ~ begin_marker_marker { - curvar=gensub("[[:blank:]]*" begin_marker_marker, "\\1", 1) - skipctr=0 + gensub("[[:blank:]]*" begin_marker_marker, "\\3", 1) - regex=gensub("[[:blank:]]*" begin_marker_marker, "\\5", 1) - printf("applying regex %s\n", regex)>"/dev/stderr" - lines="" - next -} - -$0 ~ end_marker_marker { - print_one(); -} - -function print_one() { - printf("export %s=\"%s\"\n", curvar, lines); - lines="" - curvar="" - regex="" -} - -{ - if (curvar && skipctr == 0) { lines = (lines ? (lines "\n") : "") gensub(regex ? ".*" regex ".*" : "(.*)", "\\1", 1); } - else if (curvar && skipctr > 0) { --skipctr; } -} - -END { - if (curvar) print_one(); -} diff --git a/buildtest/debian-buster/Dockerfile b/buildtest/debian-buster/Dockerfile deleted file mode 100644 index 4783f470..00000000 --- a/buildtest/debian-buster/Dockerfile +++ /dev/null @@ -1,30 +0,0 @@ -FROM debian:buster - -ARG user -RUN apt-get update && apt-get install -y sudo adduser -RUN adduser ${user:-user} && \ - echo "${user:-user} ALL=(root) NOPASSWD:ALL" > /etc/sudoers && \ - chmod 0440 /etc/sudoers -RUN mkdir -p /usr/local/src && chown root:user /usr/local/src && \ - chmod g+w /usr/local/src -USER ${user:-user} -RUN sudo mkdir -p /usr/lib/meta && sudo chown root:staff /usr/lib/meta && \ - sudo chmod g+w /usr/lib/meta -RUN sudo dpkg --add-architecture i386 -RUN sudo apt-get update -RUN sudo env DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get install -y git build-essential libelf-dev libdw-dev binutils-dev autoconf automake libtool pkg-config autoconf-archive g++ ocaml ocamlbuild ocaml-findlib default-jdk-headless python3 python3-distutils python make git gawk gdb wget libunwind-dev libc6-dev-i386 zlib1g-dev libc6-dbg libboost-iostreams-dev libboost-regex-dev libboost-serialization-dev libboost-filesystem-dev -RUN cd /usr/local/src && git clone https://github.com/stephenrkell/liballocs.git -RUN cd /usr/local/src/liballocs && \ - git submodule update --init --recursive && \ - make -C contrib -j${MAKE_PARALLELISM:-4} -RUN cd /usr/local/src/liballocs && \ - ./autogen.sh && \ - (. contrib/env.sh && ./configure --prefix=/usr/local) && \ - make -j4 -RUN sudo mkdir -p /usr/lib/meta && sudo chown root:user /usr/lib/meta && \ - sudo chmod g+w /usr/lib/meta -# XXX: skip doing this for now, since the distro's pre-built libc will often -# use DWARF 5 and, and our tools can't hack it. -#RUN cd /usr/local/src/liballocs && \ -# make -f tools/Makefile.meta \ -# $(for libname in `ldd /bin/true | sed -En '/[[:blank:]]*([^[:blank:]]* => )?(.*) \(0x[0-9a-f]+\)/ {s//\2/;p}' | egrep 'libc\.so\.6|ld-linux.*\.so' | xargs readlink -f`; do echo "/usr/lib/meta${libname}-meta.so"; done) diff --git a/buildtest/debian-stretch/Dockerfile b/buildtest/debian-stretch/Dockerfile deleted file mode 100644 index 5010f6ab..00000000 --- a/buildtest/debian-stretch/Dockerfile +++ /dev/null @@ -1,30 +0,0 @@ -FROM debian:stretch - -ARG user -RUN apt-get update && apt-get install -y sudo adduser -RUN adduser ${user:-user} && \ - echo "${user:-user} ALL=(root) NOPASSWD:ALL" > /etc/sudoers && \ - chmod 0440 /etc/sudoers -RUN mkdir -p /usr/local/src && chown root:user /usr/local/src && \ - chmod g+w /usr/local/src -USER ${user:-user} -RUN sudo mkdir -p /usr/lib/meta && sudo chown root:staff /usr/lib/meta && \ - sudo chmod g+w /usr/lib/meta -RUN sudo dpkg --add-architecture i386 -RUN sudo apt-get update -RUN sudo env DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get install -y git build-essential libelf-dev libdw-dev binutils-dev autoconf automake libtool pkg-config autoconf-archive g++ ocaml ocaml-findlib default-jdk-headless python3 python make git gawk gdb wget libunwind-dev libc6-dev-i386 zlib1g-dev libc6-dbg libboost-iostreams-dev libboost-regex-dev libboost-serialization-dev libboost-filesystem-dev -RUN cd /usr/local/src && git clone https://github.com/stephenrkell/liballocs.git -RUN cd /usr/local/src/liballocs && \ - git submodule update --init --recursive && \ - make -C contrib -j${MAKE_PARALLELISM:-4} -RUN cd /usr/local/src/liballocs && \ - ./autogen.sh && \ - (. contrib/env.sh && ./configure --prefix=/usr/local) && \ - make -j4 -RUN sudo mkdir -p /usr/lib/meta && sudo chown root:user /usr/lib/meta && \ - sudo chmod g+w /usr/lib/meta -# XXX: skip doing this for now, since the distro's pre-built libc will often -# use DWARF 5 and, and our tools can't hack it. -#RUN cd /usr/local/src/liballocs && \ -# make -f tools/Makefile.meta \ -# $(for libname in `ldd /bin/true | sed -En '/[[:blank:]]*([^[:blank:]]* => )?(.*) \(0x[0-9a-f]+\)/ {s//\2/;p}' | egrep 'libc\.so\.6|ld-linux.*\.so' | xargs readlink -f`; do echo "/usr/lib/meta${libname}-meta.so"; done) diff --git a/buildtest/rules.mk b/buildtest/rules.mk deleted file mode 100644 index ef9f65b2..00000000 --- a/buildtest/rules.mk +++ /dev/null @@ -1,6 +0,0 @@ -# the dockerfile template lives in the same dir as these makerules -vpath Dockerfile.template $(dir $(lastword $(MAKEFILE_LIST))) - -Dockerfile: Dockerfile.template Dockerfile.env - cat $< | (. ./$(filter Dockerfile.env,$+) && \ - envsubst '$$DISTRIBUTION $$PACKAGES $$MAKE_PARALLELISM' ) > $@ || (rm -f "$@"; false) diff --git a/buildtest/ubuntu-18.04/Dockerfile b/buildtest/ubuntu-18.04/Dockerfile deleted file mode 100644 index e51085a3..00000000 --- a/buildtest/ubuntu-18.04/Dockerfile +++ /dev/null @@ -1,30 +0,0 @@ -FROM ubuntu:18.04 - -ARG user -RUN apt-get update && apt-get install -y sudo adduser -RUN adduser ${user:-user} && \ - echo "${user:-user} ALL=(root) NOPASSWD:ALL" > /etc/sudoers && \ - chmod 0440 /etc/sudoers -RUN mkdir -p /usr/local/src && chown root:user /usr/local/src && \ - chmod g+w /usr/local/src -USER ${user:-user} -RUN sudo mkdir -p /usr/lib/meta && sudo chown root:staff /usr/lib/meta && \ - sudo chmod g+w /usr/lib/meta -RUN sudo dpkg --add-architecture i386 -RUN sudo apt-get update -RUN sudo env DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get install -y build-essential libbsd-dev libelf-dev libdw-dev binutils-dev autoconf automake libtool pkg-config autoconf-archive g++ ocaml ocamlbuild ocaml-findlib default-jdk-headless python3 python make git gawk gdb wget libunwind-dev libc6-dev-i386 zlib1g-dev libc6-dbg libboost-iostreams-dev libboost-regex-dev libboost-serialization-dev libboost-filesystem-dev libffi6 libffi-dev -RUN cd /usr/local/src && git clone https://github.com/stephenrkell/liballocs.git -RUN cd /usr/local/src/liballocs && \ - git submodule update --init --recursive && \ - make -C contrib -j${MAKE_PARALLELISM:-4} -RUN cd /usr/local/src/liballocs && \ - ./autogen.sh && \ - (. contrib/env.sh && ./configure --prefix=/usr/local) && \ - make -j4 -RUN sudo mkdir -p /usr/lib/meta && sudo chown root:user /usr/lib/meta && \ - sudo chmod g+w /usr/lib/meta -# XXX: skip doing this for now, since the distro's pre-built libc will often -# use DWARF 5 and, and our tools can't hack it. -#RUN cd /usr/local/src/liballocs && \ -# make -f tools/Makefile.meta \ -# $(for libname in `ldd /bin/true | sed -En '/[[:blank:]]*([^[:blank:]]* => )?(.*) \(0x[0-9a-f]+\)/ {s//\2/;p}' | egrep 'libc\.so\.6|ld-linux.*\.so' | xargs readlink -f`; do echo "/usr/lib/meta${libname}-meta.so"; done) diff --git a/buildtest/ubuntu-20.04/Dockerfile b/buildtest/ubuntu-20.04/Dockerfile deleted file mode 100644 index 7b6d92b4..00000000 --- a/buildtest/ubuntu-20.04/Dockerfile +++ /dev/null @@ -1,30 +0,0 @@ -FROM ubuntu:20.04 - -ARG user -RUN apt-get update && apt-get install -y sudo adduser -RUN adduser ${user:-user} && \ - echo "${user:-user} ALL=(root) NOPASSWD:ALL" > /etc/sudoers && \ - chmod 0440 /etc/sudoers -RUN mkdir -p /usr/local/src && chown root:user /usr/local/src && \ - chmod g+w /usr/local/src -USER ${user:-user} -RUN sudo mkdir -p /usr/lib/meta && sudo chown root:staff /usr/lib/meta && \ - sudo chmod g+w /usr/lib/meta -RUN sudo dpkg --add-architecture i386 -RUN sudo apt-get update -RUN sudo env DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get install -y build-essential libbsd-dev libelf-dev libdw-dev binutils-dev autoconf automake libtool pkg-config autoconf-archive g++ ocaml ocamlbuild ocaml-findlib libnum-ocaml-dev default-jdk-headless python3 make git gawk gdb wget libunwind-dev libc6-dev-i386 zlib1g-dev libc6-dbg libboost-iostreams-dev libboost-regex-dev libboost-serialization-dev libboost-filesystem-dev libffi-dev ca-certificates pkg-config libglib2.0-dev -RUN cd /usr/local/src && git clone https://github.com/stephenrkell/liballocs.git -RUN cd /usr/local/src/liballocs && \ - git submodule update --init --recursive && \ - make -C contrib -j${MAKE_PARALLELISM:-4} -RUN cd /usr/local/src/liballocs && \ - ./autogen.sh && \ - (. contrib/env.sh && ./configure --prefix=/usr/local) && \ - make -j4 -RUN sudo mkdir -p /usr/lib/meta && sudo chown root:user /usr/lib/meta && \ - sudo chmod g+w /usr/lib/meta -# XXX: skip doing this for now, since the distro's pre-built libc will often -# use DWARF 5 and, and our tools can't hack it. -#RUN cd /usr/local/src/liballocs && \ -# make -f tools/Makefile.meta \ -# $(for libname in `ldd /bin/true | sed -En '/[[:blank:]]*([^[:blank:]]* => )?(.*) \(0x[0-9a-f]+\)/ {s//\2/;p}' | egrep 'libc\.so\.6|ld-linux.*\.so' | xargs readlink -f`; do echo "/usr/lib/meta${libname}-meta.so"; done) From c77aa13a3526d2254b842a59b3ad9db89a53f8d9 Mon Sep 17 00:00:00 2001 From: difcsi Date: Tue, 9 Jun 2026 00:00:26 +0100 Subject: [PATCH 2/2] feat: move to system opamswitch --- .circleci/config.yml | 15 ++++++++----- Dockerfile | 5 +++++ config.mk.in | 2 -- configure.ac | 1 - contrib/Makefile | 44 ++++++++++++++++----------------------- tools/lang/c/Makefile | 5 ----- tools/lang/c/bin/allocscc | 7 +------ 7 files changed, 34 insertions(+), 45 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 6b5f83d3..2e881168 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,24 +1,29 @@ version: 2.0 jobs: build: + environment: + BASH_ENV: /root/.bash_env docker: - # MARKER BEGIN DISTRIBUTION +0 [[:blank:]]([-a-z0-9\.]+:[-a-z0-9\.]+) - image: ubuntu:24.04 - # MARKER END DISTRIBUTION steps: + - checkout - run: name: Install dependencies command: | dpkg --add-architecture i386 apt update - # MARKER BEGIN PACKAGES +1 [[:blank:]]([^#]+)# DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt install -y \ $(cat .circleci/build-dependencies.txt) - # MARKER END PACKAGES - - checkout - run: name: Update submodules command: git submodule update --init --recursive + - run: + name: Set up OCaml 5.1.0 switch + no_output_timeout: 1h + command: | + opam init --no-setup --disable-sandboxing --bare -y + opam switch create 5.1.0 + opam env >> $BASH_ENV - run: name: Build submodules command: make -C contrib -j 2 diff --git a/Dockerfile b/Dockerfile index feea2355..51489045 100644 --- a/Dockerfile +++ b/Dockerfile @@ -18,6 +18,9 @@ RUN apt-get update && \ env DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get install -y \ $(cat /tmp/build-dependencies.txt) USER ${user} +RUN opam init --no-setup --disable-sandboxing --bare -y && \ + opam switch create 5.1.0 +ENV OPAMSWITCH=5.1.0 FROM base AS full ARG user=user @@ -26,8 +29,10 @@ ARG MAKE_PARALLELISM=4 COPY --chown=${user}:${user} . /usr/local/src/liballocs/ RUN cd /usr/local/src/liballocs && \ git submodule update --init --recursive && \ + eval $(opam env) && \ make -C contrib -j${MAKE_PARALLELISM} RUN cd /usr/local/src/liballocs && \ + eval $(opam env) && \ ./autogen.sh && \ (. contrib/env.sh && ./configure --prefix=/usr/local) && \ make -j${MAKE_PARALLELISM} diff --git a/config.mk.in b/config.mk.in index b23a51a1..d8ab2141 100644 --- a/config.mk.in +++ b/config.mk.in @@ -7,14 +7,12 @@ TOOLSUB := @toolsub@ ELFTIN := @elftin@ CIL_INSTALL := @cil_install@ LIBALLOCSTOOL_CFLAGS := @liballocstool_cflags@ -LIBALLOCS_OCAML_PREFIX := @liballocs_ocaml_prefix@ # export anything needed during build of liballocs-enabled executables export CIL_INSTALL export TOOLSUB export ELFTIN export LIBMALLOCHOOKS export LIBALLOCSTOOL_CFLAGS -export LIBALLOCS_OCAML_PREFIX XWRAP_LDPLUGIN := $(ELFTIN)/xwrap-ldplugin/xwrap-ldplugin.so export XWRAP_LDPLUGIN diff --git a/configure.ac b/configure.ac index 69783658..be22e1fc 100644 --- a/configure.ac +++ b/configure.ac @@ -249,7 +249,6 @@ AC_SUBST([toolsub], [$ac_toolsub]) AC_SUBST([elftin], [$ac_elftin]) AC_SUBST([cil_install], [$ac_cil_install]) AC_SUBST([liballocstool_cflags], [$LIBALLOCSTOOL_CFLAGS]) -AC_SUBST([liballocs_ocaml_prefix], [$LIBALLOCS_OCAML_PREFIX]) AM_CONDITIONAL(DEBUG, [test "x$enable_debug" = "xyes"]) AM_CONDITIONAL(USE_FAKE_LIBUNWIND, [test "x$enable_fake_libunwind" = "xyes"]) diff --git a/contrib/Makefile b/contrib/Makefile index d925dace..75da7a7d 100644 --- a/contrib/Makefile +++ b/contrib/Makefile @@ -1,14 +1,6 @@ THIS_MAKEFILE := $(realpath $(lastword $(MAKEFILE_LIST))) CONTRIB := $(realpath $(dir $(THIS_MAKEFILE))) -export LIBALLOCS_OCAML_PREFIX := $(abspath $(CONTRIB)/../lib/ocaml) -CONFIG_MK += \nLIBALLOCS_OCAML_PREFIX := ${LIBALLOCS_OCAML_PREFIX}\n -varlist += LIBALLOCS_OCAML_PREFIX - -export OCAML_LIBDEST := ${LIBALLOCS_OCAML_PREFIX}/lib -export OCAMLPATH = ${OCAML_LIBDEST} - -export PATH := ${PATH}:${LIBALLOCS_OCAML_PREFIX}/bin export CC := gcc export CIL_CC := ${CC} @@ -136,35 +128,35 @@ export CIL_ROOT := $(CONTRIB)/cil CONFIG_MK += \nCIL_ROOT := $(CIL_ROOT)\n varlist += CIL_ROOT -export CIL_INSTALL := $(LIBALLOCS_OCAML_PREFIX)/lib/goblint-cil +export CIL_INSTALL := $(shell opam var lib 2>/dev/null)/goblint-cil CONFIG_MK += \nCIL_INSTALL := $(CIL_INSTALL)\n varlist += CIL_INSTALL -export OPAMROOT := $(CONTRIB)/opamroot -CONFIG_MK += \nOPAMROOT := $(OPAMROOT)\n -varlist += OPAMROOT - -export OPAMSWITCH := $(CIL_ROOT) -CONFIG_MK += \nOPAMSWITCH := $(OPAMSWITCH)\n -varlist += OPAMSWITCH +# goblint-cil requires OCaml >= 4.12.0. The active opam switch is used for +# building; run 'eval $(opam env)' before invoking make, or set OPAMSWITCH. +CIL_MIN_OCAML := 4.12.0 -export OCAMLFIND := opam exec -- ocamlfind +export OCAMLFIND := ocamlfind CONFIG_MK += \nOCAMLFIND := $(OCAMLFIND)\n varlist += OCAMLFIND -export OPAMYES = 1 +.PHONY: check-ocaml-version +check-ocaml-version: + @ocaml_ver=$$(ocaml -vnum 2>/dev/null) \ + || { echo "ERROR: ocaml not found in PATH; run 'eval \$$(opam env)' first"; exit 1; }; \ + printf '%s\n%s\n' "$(CIL_MIN_OCAML)" "$$ocaml_ver" | sort -V -C \ + || { echo "ERROR: OCaml >= $(CIL_MIN_OCAML) required, found $$ocaml_ver"; exit 1; }; \ + echo "OCaml $$ocaml_ver ok (>= $(CIL_MIN_OCAML))" .PHONY: build-cil -build-cil: - opam init --bare --no-setup --disable-sandboxing - cd ${CIL_ROOT} && if [ ! -d ${OPAMSWITCH}/_opam ]; then opam switch create . 5.4.0 --no-install; fi - cd ${CIL_ROOT} && opam install . --destdir=${LIBALLOCS_OCAML_PREFIX} +build-cil: check-ocaml-version + cd ${CIL_ROOT} && opam install --deps-only --yes . + cd ${CIL_ROOT} && dune build @install + cd ${CIL_ROOT} && dune install clean:: - cd ${CIL_ROOT} && opam remove . --destdir=${LIBALLOCS_OCAML_PREFIX} || true - cd ${CIL_ROOT} && opam switch remove . || true - rm -rf ${OPAMSWITCH}/_opam - rm -rf ${OPAMROOT} + cd ${CIL_ROOT} && dune uninstall || true + cd ${CIL_ROOT} && dune clean || true # ----------------------------toolsub diff --git a/tools/lang/c/Makefile b/tools/lang/c/Makefile index f6c4f6fe..dd9dafed 100644 --- a/tools/lang/c/Makefile +++ b/tools/lang/c/Makefile @@ -6,11 +6,6 @@ OCAMLFIND ?= ocamlfind ifeq ($(CIL_INSTALL),) $(error "Expected CIL_INSTALL to be set") endif -ifeq ($(LIBALLOCS_OCAML_PREFIX),) -$(error "Expected LIBALLOCS_OCAML_PREFIX to be set") -endif - -export OCAMLPATH := $(LIBALLOCS_OCAML_PREFIX)/lib:$(OCAMLPATH) CILLY ?= $(CIL_INSTALL)/../bin/cilly CIL_TOOLS ?= cilallocs dumpallocs monalloca dumpmemacc trapptrwrites diff --git a/tools/lang/c/bin/allocscc b/tools/lang/c/bin/allocscc index bf44a1a8..bfea6f27 100755 --- a/tools/lang/c/bin/allocscc +++ b/tools/lang/c/bin/allocscc @@ -12,17 +12,12 @@ import os, sys, re, subprocess, tempfile REAL_FILE = os.path.realpath(__file__) REAL_DIR = os.path.realpath(os.path.dirname(REAL_FILE)) liballocs_base = os.path.realpath(REAL_DIR + "/../../../..") -ocaml_prefix = os.environ.get("LIBALLOCS_OCAML_PREFIX", liballocs_base + "/lib/ocaml") -cilly_cmd = ocaml_prefix + "/bin/cilly" +cilly_cmd = "cilly" sys.path.append(liballocs_base + "/tools") from allocscompilerwrapper import * existing_elftin = os.environ.get("ELFTIN") if existing_elftin == None: os.putenv("ELFTIN", liballocs_base + "/contrib/elftin") -existing_ocamlpath = os.environ.get("OCAMLPATH") -if existing_ocamlpath == None: - existing_ocamlpath = "" -os.putenv("OCAMLPATH", ocaml_prefix + "/lib:" + existing_ocamlpath) os.putenv("LANG", "C") # Allow allocscc to be called with non-english locales class AllocsCC(AllocsCompilerWrapper):