timed-c/ktc

Docker: Error when running docker with a mounted volume

Closed this issue · 4 comments

I am running the following command:

docker run --name=ktc-docker -v /home/john/GitRepos/obcsw/build:/src ktc --out=/src/main-gen.c -w --enable-ext1 --save-temps -Dat91sam9g20 -I/src/include/ /src/src/__main__.timedc.c

The mounted build directory looks as follows:

build
├── include/
└── src
    ├── __main__.timedc.c
    ├── obcmain.timedc.c
    └── testdir
        └── testtask.timedc.c

The __main__.timedc.c file is just a file generated on the fly by my build script that includes all the timed C files into a single compilation unit:

/* __main__.timed.c */
#include "obcmain.timedc.c"
#include "testdir/testtask.timedc.c"

The compilation appears to have worked since the main-gen.c file is generated with reasonable contents. However, after generating the main-gen.c the following error is printed:

(test_task 1)(alive_print 1)(main 1)DonestartstartDonetask 1task 2task 3task 4task5task 1task 2task 3task 4task5startDonestartstartgcc: error: ./__main__.timedc.cil.c: No such file or directory
gcc: fatal error: no input files
compilation terminated.

I made the following changes to the dockerfile in order to get the command above to work:

diff --git a/Dockerfile b/../Forks/ktc/Dockerfile
index 777b467..62bcd12 100644
--- a/Dockerfile
+++ b/../Forks/ktc/Dockerfile
@@ -30,7 +30,7 @@ ENV PERL5LIB="/root/.opam/system/lib/perl5"
 ENV OCAML_TOPLEVEL_PATH="/root/.opam/system/lib/toplevel"
 ENV PATH="/root/.opam/system/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
 
-WORKDIR /opt/ktc/bin
+WORKDIR /src
 
-#ENTRYPOINT [ "/opt/ktc/bin/ktc" ]
-#CMD [ "--help" ]
+ENTRYPOINT [ "/opt/ktc/bin/ktc" ]
+CMD [ "--help" ]

I get the same error if I build the docker with the upstream Dockerfile and run with ./ktc added to the command.

cc @saranya-natarajan @berezovskyi

Side Note: Building the docker and running the command on the Docker Quickstart Terminal on Windows yields the following error:

C:\Program Files\Docker Toolbox\docker.exe: Error response from daemon: invalid mode: /src.
See 'C:\Program Files\Docker Toolbox\docker.exe run --help'.

Building the docker and running the command on the Docker Quickstart Terminal on Windows yields the following error:

The mounted folder shall be under C:\Users or be manually mapped in Virtualbox first on Windows: https://headsigned.com/posts/mounting-docker-volumes-with-docker-toolbox-for-windows/

gcc: fatal error: no input files

I am unable to reproduce the error. On top of that I am limited by #9

Update: It works without errors now if I change the outfile parameter to --out=/src/__main__.timedc.cil.c, though would be nice to not have to limit the outfile name to this.

Good to know, thank you @berezovskyi! Will try it out tomorrow. (Windows is wierd...)

@berezovskyi The issue was a combination of what you were describing along with a necessary extra forward-slash before the mount directory. The new command is somewhere along the lines of

docker run -v //c/Users/Public/OBCSWBuild:/src ktc ...

It works now, but it would be nice to have the choice to choose a different out name than the default *.cil.c suffix.