Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prune unused artifacts from non-static builds #59

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft

Commits on Oct 17, 2024

  1. ioc: prune modules from non-static builds.

    Remove EPICS modules that do not have a dynamic library linked to any
    executables in the target IOC. This shrinks the final image size by
    removing useless artifacts. We introduce to REPONAME the semantics of
    specifying the path where relevant binaries are, when no-build target is
    used, so that the proper clean-up can happen in such cases as well.
    Previously, REPONAME was not used at all.
    
    The clean up phase must be executed in the build stage (before the final
    copy), otherwise the COPY layer would still make the image size big.
    This implies `no-build` target needs to copy from a pruned version of
    the base image, which is a new stage.
    
    The list of modules to be removed is taken from the RELEASE file, so
    that it contains a valid mapping of all modules that have been
    installed. EPICS base is assumed to be always needed, even though some
    binaries in it can certainly be thrown away given the linkage of the IOC
    (for instance, PVAccess binaries when the IOC uses only Channel Access).
    
    Linkage information is taken from ldd(1), which assumes the inspected
    binaries are safe to be potentially executed. It is assumed we are using
    glibc implementation, which provides a straightforward way to query all
    binaries at once.
    henriquesimoes committed Oct 17, 2024
    Configuration menu
    Copy the full SHA
    2669fb9 View commit details
    Browse the repository at this point in the history
  2. ioc: remove static libraries from non-static builds.

    Static libraries are not used neither during compile time nor runtime
    for non-static builds. On the other hand, they take up a large amount of
    storage: about 312MB for EPICS base and 222MB for modules.
    
    Remove them all right before finishing the build stages, avoiding their
    copy to IOC images.
    
    All AR archives are assumed to be static libraries, which should be a
    good assumption in GNU/Linux. Other static artifacts, such as object
    files, are correctly removed by the build system clean target and are
    not handled explictly here for simplification. A lint script for the
    build system can be implemented in the future if this eventually becomes
    false.
    henriquesimoes committed Oct 17, 2024
    Configuration menu
    Copy the full SHA
    4abe19d View commit details
    Browse the repository at this point in the history

Commits on Oct 18, 2024

  1. ioc: prune shared libraries from non-static builds.

    Shared libraries may be installed either in /opt or /usr/local/lib but
    may not be used by the target binaries from the IOC image. Remove them
    during the prune phase before copying both directories to resulting
    image to shrink the final image size.
    
    Both actual versioned binary and its symbolic links are removed to keep
    the filesystem consistent.
    henriquesimoes committed Oct 18, 2024
    Configuration menu
    Copy the full SHA
    fb51e90 View commit details
    Browse the repository at this point in the history
  2. ioc: prune module directories from non-static builds.

    Modules may contain several artifacts, including configuration files,
    graphical interface files and other repository artifacts that do not
    need to be in the IOC image.
    
    Remove them all except the ones containing EPICS database (`.db` and
    `.template`) or autosave requirement (`.req`) files, besides shared
    libraries. Binaries directory (`bin`) is also removed, as only $REPONAME
    and $RUNDIR should contain target executables, which are filtered out
    from the list.
    henriquesimoes committed Oct 18, 2024
    Configuration menu
    Copy the full SHA
    c20a97d View commit details
    Browse the repository at this point in the history
  3. ioc: prune EPICS base directories from non-static builds.

    EPICS base has rather large configuration files for build, and other
    repository files, which are not needed in the IOC images. Prune them
    after building the IOCs, shrinking about 40MB the final image size.
    
    Prune is performed with the same script as modules, which discards all
    executables in `bin` (~15MB), as well as Perl scripts. This should be
    fine considering that `static-link` target also does not preserve EPICS
    binaries in the resulting image.
    henriquesimoes committed Oct 18, 2024
    Configuration menu
    Copy the full SHA
    a0fcdf2 View commit details
    Browse the repository at this point in the history