Skip to content
New issue

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

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

Already on GitHub? # to your account

Use musl-libc instead of system libc #77

Closed
osresearch opened this issue Dec 29, 2016 · 5 comments
Closed

Use musl-libc instead of system libc #77

osresearch opened this issue Dec 29, 2016 · 5 comments

Comments

@osresearch
Copy link
Collaborator

Building with alpine linux didn't work well (issue #54), but it appears that it is easier to do a hybrid build of linux and coreboot with the regular gcc, and the initrd tools with the musl-gcc wrapper.

@osresearch osresearch added this to the reproduciblebuilds milestone Dec 29, 2016
osresearch added a commit that referenced this issue Dec 29, 2016
This adds compilations modules for musl-libc and kernel-headers.
The entire initrd (busybox, cryptsetup, gpgv, kexec, etc) can be built
with the much smaller libc and it appears to work with chroot.

Library paths are not set correctly and files are installed into
heads/install to make them accessible to other modules.  This prevents
the initrd from working without manual fixup; need to fix before
merging into master.

Build times have gone up since everything is being rebuilt more
often for some reason.
@rofl0r
Copy link
Contributor

rofl0r commented Dec 30, 2016

you might as well try sabotage linux https://github.com/sabotage-linux/sabotage .
our current initrd is 1.3 MB with full busybox, cryptsetup and lvm (everything static linked).

@Kokokokoka
Copy link

Kokokokoka commented Dec 30, 2016

And what about buildroot? It is used by jeltka, coreboot payload, one can choose between uclibc-ng, musl,
there are external projects like https://github.com/xSmurf/coreboot_buildroot_project I'm trying to add zfs
package here as zfs will soon have native encryption so I'll try to use it with TPM and my payload will
be busybox+zfs-tools+xen, then I'll install Qubes. Now I'm using buildroot with patches from this
repo, and it works fine.

@osresearch
Copy link
Collaborator Author

Buildroot looks promising, especially since it includes (experimental) support for reproducible builds.One concern is that it doesn't seem to fit -- xSmurf says "Installing on the X220 requires hardware modification as the flash has to be upgraded to 16MiB." With the Heads bundler the entire runtime fits into the 4MB of the top SPI flash (and my experimental musl-libc branch has 400 KB free).

@Kokokokoka
Copy link

Kokokokoka commented Dec 30, 2016

Buildroot looks promising, especially since it includes (experimental) support for reproducible builds.One concern is that it doesn't seem to fit -- xSmurf says "Installing on the X220 requires hardware modification as the flash has to be upgraded to 16MiB." With the Heads bundler the entire runtime fits into the 4MB of the top SPI flash (and my experimental musl-libc branch has 400 KB free).

This assumption is wrong, I'm using buildroot with uclibc-ng, and I've got about 1.6 mb payload (don't remember for sure), with wpa-supplicant and dropbear and me 1.5mb. (I'll tell what is the real size of the payload later and I'll remove wpa-supplicant as I took it from jeltka and it's not really needed.)
I'll share my config if it's needed, I don't remember for sure, but there was plenty of the free space; with
bloated config there was about 200 kb free.
Also there is reproducible build option. And a rather good strip option.
So, I've removed the wpa-supplicant and dropbear and I've switched again to musl libc, now my payload is
1.3 mb also I've got libnl compiled and lspci, the only thing that I had troubles with was the nvramtool:
accessors/cmos-hw-unix.o: In function cmos_hal_write':
cmos-hw-unix.c:(.text+0x51): undefined reference to outb' accessors/cmos-hw-unix.o: In function cmos_hal_read':
cmos-hw-unix.c:(.text+0xb6): undefined reference to outb' cmos-hw-unix.c:(.text+0xc0): undefined reference to inb'
accessors/cmos-hw-unix.o: In function cmos_hal_write': cmos-hw-unix.c:(.text+0x63): undefined reference to outb'
`

osresearch added a commit that referenced this issue Jan 4, 2017
Pass in the --host argument to all of the various programs
that need to treat the configure scripts as cross compilation
targets.

This removes all dependencies on the host libc (issue #7)
and adds some tools to the initrd (cryptsetup #46).
@osresearch
Copy link
Collaborator Author

Thanks for the review on the musl-libc branch merge. sabotage looks intriguing as a future platform; I had run across it earlier as a way to build busybox with musl-libc and we're using its kernel headers package to host the gcc wrapper.

The changes are now in master and appear to build from a clean checkout (on ubuntu and fedora). This doesn't satisfy the reproducible build goal yet (issue #2), but it does close out dependency on the system libc (issue #7).

tlaurion pushed a commit to tlaurion/heads that referenced this issue May 3, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

3 participants