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

Add a static binary workflow #966

Merged
merged 26 commits into from
Jul 7, 2020
Merged

Add a static binary workflow #966

merged 26 commits into from
Jul 7, 2020

Conversation

tobim
Copy link
Member

@tobim tobim commented Jul 6, 2020

Adds a new workflow that uses nix to build a static binary. It runs after every push to master and can be manually triggered by the repository_dispatch event.

TODO:

  • Add a script to trigger the manual event

tobim added 10 commits July 3, 2020 16:03
This commit moves the nix expression for vast into an overlay.
It also adds a package for zeek's broker library to make it possible
to build zeek-to-vast.

At the smae time, overrides for CAF and Apache Arrow are added to
fix their build with a compiler that only targets static binaries,
and link-time optimization in case of CAF.

Lastly, the shell.nix file has been updated to work with the new
overlay and make use of the CMake changes that were added in the
previous commits.
@tobim tobim added the feature New functionality label Jul 6, 2020
@tobim tobim requested review from a team July 6, 2020 06:11
.github/workflows/static-binary.yml Outdated Show resolved Hide resolved
.github/workflows/static-binary.yml Outdated Show resolved Hide resolved
.github/workflows/static-binary.yml Outdated Show resolved Hide resolved
.github/workflows/static-binary.yml Outdated Show resolved Hide resolved
.github/workflows/static-binary.yml Outdated Show resolved Hide resolved
.github/workflows/static-binary.yml Outdated Show resolved Hide resolved
Comment on lines +85 to +86
option(VAST_STATIC_EXECUTABLE "Link VAST statically" $ENV{VAST_STATIC_EXECUTABLE})
option(VAST_USE_JEMALLOC "Use jemalloc instead of libc malloc" "${VAST_STATIC_EXECUTABLE}")
Copy link
Member

Choose a reason for hiding this comment

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

Changed by mistake? This doesn't look right to me.

Copy link
Member Author

Choose a reason for hiding this comment

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

The intention is to use the environment variable if the option has not been given explicitly. The order of precedence is now:
explicit option > environment > default (implicitly off because the empty string is treated as False).

The reason I changed these is that I can use nix to set up an environment for a static build like so:

nix-shell -E 'let pkgs = import ./nix { }; in import ./shell.nix {pkgs = pkgs.pkgsStatic;}'

The toolchain in this environment is not capable to produce shared libraries, so one has to pass several options to CMake to get a working build tree with a configuration similar to the static build in CI:

cmake -Bbuild -S . -DVAST_STATIC_EXECUTABLE=ON -DZSTD_ROOT="$(nix-build ./nix --no-out-link -A pkgsStatic.zstd)" -DVAST_USE_JEMALLOC=ON

With the changes to CMake adding these options is not required, while the regular build is not affected.

Copy link
Member

Choose a reason for hiding this comment

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

I really don't like how inconsistent this is. Can you create a follow-up story for a) prefixing all CMake variables that the user can set with VAST_, and b) for exposing them on the command line like this?

Comment on lines +27 to +30
# We look for an environment variable of the same name too, because
# that can be provided by a tool like nix-shell or docker. Wo do this
# so the user doesn't have to remember to add "-DZSTD_ROOT=..." to their
# cmake invocations.
Copy link
Member

Choose a reason for hiding this comment

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

Having this for some variables but not all is really confusing and makes maintenance of the CMake way harder. I'm already always afraid to change CMake code because it might break the Nix build.

Copy link
Member Author

Choose a reason for hiding this comment

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

This is essentially a workaround for a bug in the generated .pc files in ZSTD. We can probably get rid of FindZSTD.cmake when upgrading to the next Arrow release thanks to apache/arrow#7388.

nix/overlay.nix Show resolved Hide resolved
nix/pinned.nix Show resolved Hide resolved
@lava
Copy link
Member

lava commented Jul 6, 2020

Add a script to trigger the manual event

The script already exists in event-horizon, maybe it's even fine to leave it there since only tenzir developers will have permissions to trigger manual dispatches anyways. However, it will not be possible to test the manual trigger until the workflow that responds to it lands on master, so not in this PR.

tobim and others added 2 commits July 6, 2020 12:43
Co-authored-by: Dominik Lohmann <mail@dominiklohmann.de>
scripts/trigger-static-build Outdated Show resolved Hide resolved
scripts/trigger-action Show resolved Hide resolved
@tobim tobim force-pushed the story/ch17797/static-binary branch from 237535f to 4fa59f2 Compare July 6, 2020 12:19
@mavam
Copy link
Member

mavam commented Jul 6, 2020

The name for the workflow seems still pretty cryptic. Can we strip the technical details?

@tobim
Copy link
Member Author

tobim commented Jul 6, 2020

The name for the workflow seems still pretty cryptic. Can we strip the technical details?

The name is now "VAST Static / Static Binary (trigger)".

@tobim tobim force-pushed the story/ch17797/static-binary branch from 1627cab to 11986e9 Compare July 6, 2020 14:35
With this change the links
will always point to a tarball with the latest release build.
CHANGELOG.md Outdated Show resolved Hide resolved
@tobim tobim force-pushed the story/ch17797/static-binary branch from 58b4fa5 to 2847264 Compare July 6, 2020 15:19
Copy link
Member

@lava lava left a comment

Choose a reason for hiding this comment

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

I successfully built a static binary tarball using this PR, and verified that the created binary seems to work.

Copy link
Member

@dominiklohmann dominiklohmann left a comment

Choose a reason for hiding this comment

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

Can you rename the new workflow from .yml to .yaml for consistency?

CHANGELOG.md Outdated Show resolved Hide resolved
.github/workflows/vast.yaml Outdated Show resolved Hide resolved
tobim and others added 3 commits July 6, 2020 20:51
Co-authored-by: Dominik Lohmann <mail@dominiklohmann.de>
Co-authored-by: Dominik Lohmann <mail@dominiklohmann.de>
Copy link
Member

@dominiklohmann dominiklohmann left a comment

Choose a reason for hiding this comment

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

One last thing.

.github/workflows/static-binary.yaml Outdated Show resolved Hide resolved
Co-authored-by: Dominik Lohmann <mail@dominiklohmann.de>
Copy link
Member

@dominiklohmann dominiklohmann left a comment

Choose a reason for hiding this comment

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

Excited to have this.

@tobim tobim merged commit 8b469a7 into master Jul 7, 2020
@tobim tobim deleted the story/ch17797/static-binary branch July 7, 2020 06:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants