Skip to content
This repository was archived by the owner on Oct 10, 2023. It is now read-only.

Build fsm statically#10

Merged
cole-h merged 11 commits intomainfrom
cole/ds-215
Aug 16, 2022
Merged

Build fsm statically#10
cole-h merged 11 commits intomainfrom
cole/ds-215

Conversation

@cole-h
Copy link
Copy Markdown
Member

@cole-h cole-h commented Aug 11, 2022

This is now built completely statically :)

@linear
Copy link
Copy Markdown

linear Bot commented Aug 11, 2022

DS-215 Pre-build an fsm which runs on ubuntu without any nix dependencies

Ideally we can either build with musl or patchelf the binary to run on Ubuntu. We can't ask the user to build fsm themselves, it takes too much time to the runthrough and wastes time.

Let's do this as part of the Github Actions so every PR / merge gets a prebuilt executable.

@Hoverbear
Copy link
Copy Markdown
Contributor

This works on Ubuntu?

@cole-h
Copy link
Copy Markdown
Member Author

cole-h commented Aug 11, 2022

Yep:

image

@cole-h
Copy link
Copy Markdown
Member Author

cole-h commented Aug 11, 2022

Also on 16.04:

image

@grahamc
Copy link
Copy Markdown
Member

grahamc commented Aug 11, 2022

This doesn't quite work yet on an Ubuntu machine without Nix installed. Note that it is trying to find the interpreter in the Nix store:

root@ubuntu-s-1vcpu-1gb-amd-nyc1-01:~# ldd ./fsm
	linux-vdso.so.1 (0x00007fffe01e7000)
	libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fb9ec831000)
	libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fb9ec74a000)
	libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fb9ec522000)
	/nix/store/7fz6dhhriwv6n4kdg05qi8cwf7mfqza9-glibc-2.35-163/lib/ld-linux-x86-64.so.2 => /lib64/ld-linux-x86-64.so.2 (0x00007fb9ed429000)

root@ubuntu-s-1vcpu-1gb-amd-nyc1-01:~# ./fsm
-bash: ./fsm: No such file or directory

I think this should be using patchelf to point its interpreter to /lib64/ld-linux-x86-64.so.2, and perhaps test that ./fsm shell runs successfully in a follow-up GitHub Action?

@cole-h
Copy link
Copy Markdown
Member Author

cole-h commented Aug 11, 2022

It seems weird to me that we want to make it work on machines without Nix? How will nix develop work, then? But yeah, I can do that.

@grahamc
Copy link
Copy Markdown
Member

grahamc commented Aug 11, 2022

It isn't necessarily about having Nix / not having Nix, but more that this specific path to the interpreter is not likely to actually be present, it just happens to be so today.

@Hoverbear
Copy link
Copy Markdown
Contributor

How will nix develop work, then?

It's my impression a mature version of fsm may install nix if it's not already installed during runtime maybe?

@cole-h cole-h force-pushed the cole/ds-215 branch 2 times, most recently from 2c5f7a1 to c42c731 Compare August 12, 2022 18:18
Comment thread flake.nix
'';

cargoLock.lockFile = ./Cargo.lock;
override = { preBuild ? "", ... }: {
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This should be overrideMain since we don't really want to propagate this to all dependencies, but for some reason, it doesn't appear to work with our setup. Once we open-source this repo, I'll be able to file an issue for this, but I can't reproduce on any of their example projects (maybe it's an interaction with naersk and fenix that's being problematic?).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Opened #14 so I don't forget.

@cole-h cole-h marked this pull request as ready for review August 12, 2022 18:31
Comment thread flake.nix Outdated
in
{
package = pkgs.rustPlatform.buildRustPackage rec {
package = naerskLib.buildPackage rec {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is moving to Naersk required for this?

Copy link
Copy Markdown
Member Author

@cole-h cole-h Aug 12, 2022

Choose a reason for hiding this comment

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

Yes -- old nixpkgs versions don't have good support for building fast-changing repos from source (cargoLock.lockFile is very new functionality that is definitely not present in 20.09; otherwise).

ETA: And we need an old nixpkgs to build against an old gllibc.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Note that the cargoLock.lockFile functionaly in Nixpkgs was just copied from my import-cargo flake so we could also use that.

@edolstra
Copy link
Copy Markdown
Contributor

Can't we provide a statically linked fsm? That avoids any problems with /lib64 and mixing Nixpkgs versions.

@cole-h
Copy link
Copy Markdown
Member Author

cole-h commented Aug 15, 2022

(We're going to try making this actually-static.)

@cole-h cole-h mentioned this pull request Aug 15, 2022
@lucperkins
Copy link
Copy Markdown
Member

lucperkins commented Aug 15, 2022

I can confirm that as of eda976e the aarch64-darwin build on this branch is A-okay. Running cargo build in the Nix shell, however, fails (and likely failed in my branch for #17 but I didn't check). Depending on our goals, that state of affairs may be fine but I wanted to pass that along.

@cole-h cole-h changed the title Switch to using vendored openssl for the cargo crate Build fsm statically Aug 16, 2022
@grahamc
Copy link
Copy Markdown
Member

grahamc commented Aug 16, 2022

The fsm I downloaded from the build runs perfectly well on an Ubuntu 22.04 machine, nicely done!

cole-h added 8 commits August 16, 2022 09:49
* nixos-20.09 for glibc 2.31
* fenix for the toolchain stuff (since 20.09 is old and some of our dependencies specify a newer MSRV)
* naersk for building Rust (since 20.09 is missing some of the nice things for rustPlatform.buildRustPackage)
…s a library

This allows us to have an actually-successful build of fsmStatic without
weirdness due to openssl.
@cole-h cole-h enabled auto-merge August 16, 2022 16:52
@cole-h cole-h disabled auto-merge August 16, 2022 16:54
@cole-h cole-h enabled auto-merge August 16, 2022 16:56
@cole-h cole-h merged commit 5a2f734 into main Aug 16, 2022
@cole-h cole-h deleted the cole/ds-215 branch August 16, 2022 17:02
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants