seL4 / sel4-tutorials

Tutorials for working with seL4 and/or CAmkES.

Home Page:https://docs.sel4.systems/Tutorials

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`capdl_linker.py` is not executable

maybe-sybr opened this issue · comments

capDL is introduced in the threads tutorial but it appears that the logic for running the capdl_linker.py script via cmake may be broken. AFAICT a clean checkout of the tutorials and capdl repositories, and a clean ../init --tut threads results in a build error when we try to execute the script with its #! rather than explicitly via python.

[1/12] cd /path/to/sel4-tutorials/threads_build && /usr/bin/cmake -E env PYTHONPATH=/path/to/sel4-tutorials/projects/capdl/python-capdl-tool /path/to/sel4-tutorials/projects/capdl/cdl_utils/capdl_linker.py --arch=x86_64 --object-sizes /path/to/sel4-tutorials/threads_build/capdl/object_sizes/object_sizes.yaml build_cnode --manifest-in=/path/to/sel4-tutorials/threads/.manifest.obj --elffile threads --ccspace /path/to/sel4-tutorials/threads_build/cspace_threads.c
FAILED: cspace_threads.c
cd /path/to/sel4-tutorials/threads_build && /usr/bin/cmake -E env PYTHONPATH=/path/to/sel4-tutorials/projects/capdl/python-capdl-tool /path/to/sel4-tutorials/projects/capdl/cdl_utils/capdl_linker.py --arch=x86_64 --object-sizes /path/to/sel4-tutorials/threads_build/capdl/object_sizes/object_sizes.yaml build_cnode --manifest-in=/path/to/sel4-tutorials/threads/.manifest.obj --elffile threads --ccspace /path/to/sel4-tutorials/threads_build/cspace_threads.c
Permission denied
ninja: build stopped: subcommand failed.

chmod u+x .../capdl_linker.py fixes the build. It's unclear to me if this is the the tutorial's cmake logic's fault or if the capdl repo should be changed to make the script executable.

That command is defined as set(python_with_capdl ${CMAKE_COMMAND} -E env PYTHONPATH=${PYTHON_CAPDL_PATH} ${PYTHON3}) and it appears that PYTHON3 isn't set to anything. It is assumed that this variable is set here: https://github.com/seL4/seL4/blob/master/CMakeLists.txt#L36, but the sel4-tutorials cmake scripts could be updated to redefine it anyway I guess.

Looks like it's an ordering thing. I made cmake explode to tell me what PYTHON3 is set to just after sel4-tutorials/cmake/helpers.cmake:L170 which is where capdl_linker_tool gets set. In a fresh build it's empty at that moment, when I re-run it in a fully constructed build tree it's subsequently learned that PYTHON3 is python3, presumably from the line you linked in the main seL4/CMakeLists.txt.

Right, the kernel's CMakeLists.txt file is supposed to be evaluated as early as possible in the build process, but helpers.cmake gets imported into the threads tutorial slightly beforehand. Because capdl_linker_tool is set when the file is imported, it is relying on an unset PYTHON3. I think the solution is to also define python3 at that point which is less of a code smell too.

I added a PR for the issue