Skip to content

add docker-helper.sh to lift examples using pac-nix docker image#514

Merged
katrinafyi merged 5 commits intomainfrom
docker-helper
Aug 4, 2025
Merged

add docker-helper.sh to lift examples using pac-nix docker image#514
katrinafyi merged 5 commits intomainfrom
docker-helper

Conversation

@katrinafyi
Copy link
Member

@katrinafyi katrinafyi commented Jul 17, 2025

this introduces the src/test/make/docker-helper.sh script which is
a (hopefully) developer-friendly method for lifting examples in a Docker
container provided by pac-nix.

to ensure reproducibility, this uses an x86_64-linux docker container
with cross-compiler provided by nix. for more details, see #288 which the
docker-helper.sh is stolen from.

the usage is comprehensively documented in readme.
the general flow is:

  1. activate the docker-helper.sh environment: eval $(docker-helper.sh env).
    (you will need to re-run this if you close your terminal)
  2. pull the docker image: docker-helper.sh pull
  3. start the docker container: docker-helper.sh start
  4. (optional) clean the directory you want to lift:
    make SUBDIRS=extraspec_incorrect/malloc_memcpy_strlen_memset_free clean
  5. compile and lift the directory:
    make SUBDIRS=extraspec_incorrect/malloc_memcpy_strlen_memset_free
  6. commit the results (eventually, we want to move the binaries into
    an out-of-repo location. but until then, committing is probably fine.)

this PR does not make any changes to the existing examples. it only serves to make the Docker container available and accessible for people who want to use it as a uniform lifting environment.

I do think that all examples should eventually be re-lifted using a consistent method, but this will come later.

this introduces the src/test/make/docker-helper.sh script which is
a (hopefully) developer-friendly method for lifting examples in a Docker
container provided by [pac-nix][].

to ensure reproducibility, this uses an x86_64-linux docker container
with cross-compiler provided by nix. for more details, also see
#288.

the usage is comprehensively documented in [nix-docker-build readme].
the general flow is:
1. activate the docker-helper.sh environment: `eval $(docker-helper.sh env)`.
   (you will need to re-run this if you close your terminal)
2. pull the docker image: `docker-helper.sh pull`
3. start the docker container: `docker-helper.sh start`
4. (optional) clean the directory you want to lift:
   `make SUBDIRS=extraspec_incorrect/malloc_memcpy_strlen_memset_free clean`
5. compile and lift the directory:
   `make SUBDIRS=extraspec_incorrect/malloc_memcpy_strlen_memset_free`
6. commit the results (eventually, we want to move the binaries into
   another repo. but until then, committing is fine.)

[pac-nix]: https://github.com/katrinafyi/pac-nix/
[nix-docker-build readme]: https://github.com/UQ-PAC/BASIL/blob/nix-docker-build/src/test/readme.md
Copy link
Contributor

@ailrst ailrst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, it also works with liftmake.sh if you manually set CC=$GCC after docker-helper.sh env, it might be a good idea to set CC to a default with the env command so it works a bit smoothly.

@@ -0,0 +1,413 @@
# Writing and Running Tests

See [docs/development/readme.md](../../docs/development/readme.md) for context.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder whether this would be better placed in /docs/ for visibility.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I think so too.

i don't want to set $CC in `docker-helper.sh env` because i think
$CC is a default variable read by cmake and such, so setting it to
a cross-compiler might break things unexpectedly
@katrinafyi katrinafyi merged commit 0c806ff into main Aug 4, 2025
12 checks passed
@katrinafyi katrinafyi deleted the docker-helper branch August 4, 2025 05:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants