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

Is it possible to replace systemd with libuv #439

Open
HuMoran opened this issue Aug 15, 2024 · 17 comments
Open

Is it possible to replace systemd with libuv #439

HuMoran opened this issue Aug 15, 2024 · 17 comments

Comments

@HuMoran
Copy link

HuMoran commented Aug 15, 2024

Is it possible to replace systemd with libuv? Using systemd will cause the boot to start very slowly.

Here is an example:

sony/flutter-embedded-linux@595f7f5

@ardera
Copy link
Owner

ardera commented Aug 15, 2024

libsystemd is just an utility library used by systemd, it's not systemd itself. I haven't tried but I'm pretty sure you can use libsystemd without systemd.

Other than that, yeah, you could also modify it to use libuv instead

@HuMoran
Copy link
Author

HuMoran commented Aug 16, 2024

If using libsystemd, the system needs to use systemd as the init program. Did I understand it wrong?

@ardera
Copy link
Owner

ardera commented Aug 16, 2024

AFAICT, you don't need systemd:

hannes@alpaka-pi:~ $ ldd /lib/aarch64-linux-gnu/libsystemd.so.0
	linux-vdso.so.1 (0x0000007f8c837000)
	libcap.so.2 => /lib/aarch64-linux-gnu/libcap.so.2 (0x0000007f8c6d0000)
	libgcrypt.so.20 => /lib/aarch64-linux-gnu/libgcrypt.so.20 (0x0000007f8c5c0000)
	liblzma.so.5 => /lib/aarch64-linux-gnu/liblzma.so.5 (0x0000007f8c570000)
	libzstd.so.1 => /lib/aarch64-linux-gnu/libzstd.so.1 (0x0000007f8c4b0000)
	liblz4.so.1 => /lib/aarch64-linux-gnu/liblz4.so.1 (0x0000007f8c460000)
	libc.so.6 => /lib/aarch64-linux-gnu/libc.so.6 (0x0000007f8c2b0000)
	/lib/ld-linux-aarch64.so.1 (0x0000007f8c7fa000)
	libgpg-error.so.0 => /lib/aarch64-linux-gnu/libgpg-error.so.0 (0x0000007f8c260000)

https://packages.debian.org/de/sid/libsystemd0

no dependency on the actual systemd (https://packages.debian.org/de/sid/systemd), udev, etc

@HuMoran
Copy link
Author

HuMoran commented Aug 19, 2024

I use 'buildroot' to build an image, which shows that it must depend on 'systemd'` 😂
image

@ardera
Copy link
Owner

ardera commented Aug 19, 2024

That seems like an issue on their end then :) Or it's intentional, could be it's very rare to depend on libsystemd without depending on systemd, so they just bundled it together.

@HuMoran
Copy link
Author

HuMoran commented Aug 20, 2024

Thank you!

@HuMoran HuMoran closed this as completed Aug 20, 2024
@ardera
Copy link
Owner

ardera commented Aug 20, 2024

did you open an issue with buildroot? if yes, you can link it here and keep this one open. Just if someone else has the same problem in the future.

@HuMoran
Copy link
Author

HuMoran commented Aug 26, 2024

Sorry, I don't have a GitLab account, I'm from China, and Gitlab banned the China register. 😭

@ardera
Copy link
Owner

ardera commented Aug 26, 2024

@HuMoran opened an issue here: https://gitlab.com/buildroot.org/buildroot/-/issues/30

@ardera ardera reopened this Aug 26, 2024
@aduskett
Copy link

aduskett commented Aug 27, 2024

This isn't a buildroot issue. libsystemd is provided by systemd, and there isn't a way to only build and install libsystemd from the systemd package. For binary distributions, there are usually multiple binary packages generated from a single source, but that is not possible in Buildroot.

@HuMoran
Copy link
Author

HuMoran commented Aug 28, 2024

Can add the libuv feature?

@ardera
Copy link
Owner

ardera commented Aug 28, 2024

This isn't a buildroot issue. libsystemd is provided by systemd, and there isn't a way to only build and install libsystemd from the systemd package. For binary distributions, there are usually multiple binary packages generated from a single source, but that is not possible in Buildroot.

Thanks @aduskett, yeah seems like installing only libsystemd is a pretty rare use-case
Though it seems like you can in fact install libsystemd separately using meson install --tags=libsystemd. And technically you can build separately using meson compile libsystemd (or ninja) as well, however the meson install command will still continue to build the whole repo anyway. But idk how easy it is to make buildroot work with that

@ardera
Copy link
Owner

ardera commented Aug 28, 2024

Can add the libuv feature?

I don't know how likely is that I will work on it, but if you want to work on it, I'd happily accept it. I'm currently working on a refactor for multi-view and I've been switching to use my own little mt-safe sd-event wrapper there exclusively: https://github.com/ardera/flutter-pi/blob/feat/multiview/src/util/event_loop.c

For libuv you'd probably want to implement the same API using libuv in some event_loop_libuv.c file instead, and then compile that instead of event_loop.c if some cmake option is set

@HuMoran
Copy link
Author

HuMoran commented Aug 30, 2024

I'm not sure I can do it. This feature is a big project for me (I haven't written C code for many years). I am learning the relevant code. Is there any design Introduction?

@HuMoran HuMoran changed the title Is't possible to replace systemd with libuv It‘s possible to replace systemd with libuv Sep 2, 2024
@HuMoran HuMoran changed the title It‘s possible to replace systemd with libuv Is it possible to replace systemd with libuv Sep 2, 2024
@doawoo
Copy link

doawoo commented Sep 9, 2024

I've actually done a bit of work on a much much older version of flutter_pi that rips out systemd and replaces it with a very light weight event loop library:

https://github.com/troglobit/libuev

I'll perhaps try to find some time to port all these changes to the latest version if there's interest in that.

@ardera
Copy link
Owner

ardera commented Sep 12, 2024

@HuMoran I have added a bit of comments here: https://github.com/ardera/flutter-pi/blob/feat/multiview/src/util/event_loop.h let me know if that helps

@doawoo that'd be great!

@legraps
Copy link

legraps commented Sep 13, 2024

Interesting, I had the same problem with buildroot as @HuMoran. Solved it for me by removing the dependency of systemd being the init system. It works but of course is super hacky. (didnt dare to suggest it on the buildroot mailing list).

So libuev as alternativ would be very nice!

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

No branches or pull requests

5 participants