seL4 / microkit

Microkit - A simple operating system framework for the seL4 microkernel
Other
70 stars 37 forks source link

The SDK build fails with "crypt.h: No such file or directory" #13

Closed podhrmic closed 4 months ago

podhrmic commented 1 year ago

Hello!

I am very excited about the new core platform! I tried to build the SDK following the instructions, but I am getting this error:

generating custom link library containing Python...
deriving custom config.c from 101 extension modules
compiling custom config.c to object file
running: "musl-gcc" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-m64" "-I" "/tmp/libpython58Y2ML" "-Wall" "-Wextra" "-std=c99" "-DNDEBUG" "-DPy_BUILD_CORE" "-o" "/tmp/pyoxidizer-build-exe-packagingQ0Ofjv/config.o" "-c" "/tmp/libpython58Y2ML/config.c"
cargo:warning=In file included from /tmp/libpython58Y2ML/config.c:1:
cargo:warning=/tmp/libpython58Y2ML/Python.h:44:10: fatal error: crypt.h: No such file or directory
cargo:warning=   44 | #include <crypt.h>
cargo:warning=      |          ^~~~~~~~~
cargo:warning=compilation terminated.
exit status: 1

error occurred: Command "musl-gcc" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-m64" "-I" "/tmp/libpython58Y2ML" "-Wall" "-Wextra" "-std=c99" "-DNDEBUG" "-DPy_BUILD_CORE" "-o" "/tmp/pyoxidizer-build-exe-packagingQ0Ofjv/config.o" "-c" "/tmp/libpython58Y2ML/config.c" with args "musl-gcc" did not execute successfully (status code exit status: 1).

Not quite sure where is the problem coming from, libcrypt-dev is installed, and a simple call to import crypt succeeds:

# ./pyenv/bin/python                           
Python 3.10.6 (main, Nov 14 2022, 16:10:14) [GCC 11.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import crypt
>>> 

I am building this on ubuntu:latest:

# cat /etc/lsb-release 
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=22.04
DISTRIB_CODENAME=jammy
DISTRIB_DESCRIPTION="Ubuntu 22.04.1 LTS
Ivan-Velickovic commented 1 year ago

I found that upgrading pyoxidizer to at least version 0.20.0 fixes the issue. I'm trying to find out why that works but hopefully upgrading the package fixes the issue so you can at least try out seL4CP.

podhrmic commented 1 year ago

Thanks, that helped. I haven't found a list of platform dependencies, so I ended up making a docker image that lets you build the SDK.

Save the following into Dockerfile somewhere:

FROM ubuntu:latest

WORKDIR /sel4cp
ADD seL4 /seL4
ADD sel4cp /sel4cp
ARG DEBIAN_FRONTEND=noninteractive

# Deps
RUN apt-get update
RUN apt-get upgrade -y
RUN apt-get install -y python3 make git python3-venv \
    musl-dev musl-tools vim pandoc \
    texlive-latex-base texlive-fonts-recommended texlive-fonts-extra \
    texlive-latex-extra \
    cmake wget curl \
    xz-utils \
    gcc-aarch64-linux-gnu \
    device-tree-compiler \
    libxml2-utils
RUN python3 -m venv pyenv

RUN wget -qO /usr/local/bin/ninja.gz https://github.com/ninja-build/ninja/releases/latest/download/ninja-linux.zip
RUN gunzip /usr/local/bin/ninja.gz
RUN chmod a+x /usr/local/bin/ninja
RUN ninja --version

# Build prep
RUN ./pyenv/bin/pip install --upgrade pip setuptools wheel
RUN ./pyenv/bin/pip install -r /sel4cp/requirements.txt

# ARM toolchain
RUN curl -Lo gcc-aarch64-linux-gnu.tar.xz "https://developer.arm.com/-/media/Files/downloads/gnu-a/10.2-2020.11/binrel/gcc-arm-10.2-2020.11-x86_64-aarch64-none-elf.tar.xz?revision=79f65c42-1a1b-43f2-acb7-a795c8427085&hash=61BBFB526E785D234C5D8718D9BA8E61"
RUN mkdir /opt/gcc-aarch64-linux-gnu
RUN tar -xf gcc-aarch64-linux-gnu.tar.xz --strip-components=1 -C /opt/gcc-aarch64-linux-gnu
ENV PATH="${PATH}:/opt/gcc-aarch64-linux-gnu/bin"
RUN rm -rf gcc-aarch64-linux-gnu.tar.xz

# Build SDK
RUN ./pyenv/bin/python /sel4cp/build_sdk.py --sel4=/seL4

And then in the same directory, run:

git clone git@github.com:BreakawayConsulting/seL4.git -b sel4cp-core-support
git clone git@github.com:BreakawayConsulting/sel4cp.git
docker build -t sel4cp .

I can build the ethernet example, haven't really tested if it runs.

axel-h commented 1 year ago

Thanks for the docker file. Could be a fist step towards a github CI action. I wonder, what is the reason to pick ninja from the source and not install the package ninja-build?

podhrmic commented 1 year ago

I didn't realize there is ninja-build package (the Docker image was a rather hasty work), so indeed that should be equivalent. Happy to help with the CI stub if you would like? it should be pretty straightforward.

Ivan-Velickovic commented 1 year ago

Okay I've looked into this again. I'm now not convinced that upgrading the pyoxidizer is the right solution. I've just tested musl-1.2.2 on a fresh Ubuntu 22.04, and the SDK builds. The libpython Python.h that the newer pyoxidizer uses does not include crypt.h which is why it works to just upgrade pyoxidizer, I think it might just be a coincidence that it works? Not sure.

Since the seL4CP README says that musl-1.2.2 should be used, there does not seem to be anything wrong there as it works on Ubuntu 22.04. I suspect that installing musl from apt install musl-tools on Ubuntu 22.04 installs a version of musl that is not compatible with musl-1.2.2, hence the error you've run into.

Ivan-Velickovic commented 4 months ago

This specific issue has been solved (I can't really do anything about how Ubuntu packages dependencies though). But, the general issue of making it easier to build Microkit from source should happen so people don't run into similar kinds of issues (e.g Nix or Docker).