owncast
owncast copied to clipboard
Update source build instructions to not be specific about GCC
Hello,
Request: Update README.md so that "Building from Source" section does not imply that Owncast runs only on glibc systems. I thought it was glibc exclusive, but I tried anyway and it works on Musl as well.
Long story short: Owncast can be compiled on Void Linux (Musl)
Long story long: I have Void Linux (Musl) on my server.
in "Building from Source" section in README.md it is stated that:
- Ensure you have the gcc compiler installed.
I understand, that You meant that it is required to have A COMPILER installed, but it can just as well be Musl. Go is the important piece of software here and it is available for Musl version of Void Linux.
After installing go with
xbps-install go
I did
git clone https://github.com/owncast/owncast cd owncast go run main.go
After downloading dependencies, Owncast started without a problem.
I then created a binary file with
go build
and "owncast" binary appeared, that could be started on a Musl system.
I totally understand, that going with just GCC, saves Your time in terms of support, but it would be nice if you (at least) gave a hint that Musl systems are also capable of running Owncast.
- Ensure you have a compiler installed (GCC or Musl)
Sure. We actually use Musl in our build. But GCC is more common and easy to talk about, since it's something that's supported and used everywhere.
I think there's some confusion:
- GCC is a compiler
- glibc is a c standard library implementation
- musl is also a c standard library implementation (it's not a compiler like stated in the issue)
You can use GCC with glibc, GCC with musl, and other libc's, like dietlibc, uclibc, etc. There's no sense in saying "GCC or musl".
You may be able to generalize the instructions to state you need Go with a C compiler since the build requires CGO - odds are this should work with other compiler + libc combos, like Clang + musl.
Yeah, if it actually throws people off by saying "GCC" I was just going to say "a c compiler".
It's just that (obviously) when I downloaded Owncast binary, it did not work on a musl-based system. Then, when I started reading the instructions for Building from source, the first thing I saw was "GCC" and then I was like "well this is just great. Nice. I guess I won't be having Owncast on my musl server." But then I tried anyway and it works.
All I would like to achieve from this Issue is so that other people wouldn't have such an hopeless initial feeling when trying to build owncast on a non-glibc system.
Perhaps it's just me. I don't know.
It's just that (obviously) when I downloaded Owncast binary, it did not work on a musl-based system.
Woah, that wasn't obvious from your comment at all. That sounds like a real problem. What happened when you download and ran an Owncast binary?
Yeah the original comment didn't mention downloading the binary, just the build process. That's really a separate issue, I wouldn't classify that as obvious.
Like I mentioned earlier GCC != glibc, going forward don't assume if build instructions mention GCC that it will only work on glibc. Your musl-based system is likely using GCC to compile as well.
@gabek the binaries provided aren't statically-linked, they're dynamically linked with glibc. I downloaded owncast-0.0.12-linux-64bit.zip
and extracted it:
$ file owncast
owncast: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=1fdcffa78b88995b56e7fbcd9f75eed6962a8373, for GNU/Linux 3.2.0, stripped
$ readelf -d owncast
Dynamic section at offset 0x2c00dd0 contains 26 entries:
Tag Type Name/Value
0x0000000000000001 (NEEDED) Shared library: [libdl.so.2]
0x0000000000000001 (NEEDED) Shared library: [libpthread.so.0]
0x0000000000000001 (NEEDED) Shared library: [libc.so.6]
(cut for brevity)
That interpreter (ld-linux-x86-64.so.2
) is the glibc dynamic linker, on a musl system it's ld-musl-x86_64.so.1
, plus it relies on the local libc (listing libc.so.6
in the dynamic section).
Systems that use musl as the only libc aren't able to load the program. I think it's technically possible to have glibc and musl installed side-by-side (I'm pretty certain NixOS does that?), providing a true static binary would work on any linux system.
Go compiles as static binaries by default - unless you're building with CGO. Since CGO is enabled due to SQLite, the binary is built dynamically. I haven't tested this but I think you can create a static binary with a command like:
go build -ldflags="-extldflags=-static" -tags sqlite_omit_load_extension
That -tags sqlite_omit_load_extension
is due to SQLite forcing a dependency on libdl
for dynamically loading SQLite extensions, which I don't think owncast is using anyway, so you can build with that disabled.
It's just that (obviously) when I downloaded Owncast binary, it did not work on a musl-based system.
Woah, that wasn't obvious from your comment at all. That sounds like a real problem. What happened when you download and ran an Owncast binary?
[void@D525 testing]$ ./owncast
-bash: ./owncast: No such file or directory
Oh I did not expect that to be a surprise. Glibc programs don't run on musl systems.
I just wanted to give a little "background" to the story of why I created this Issue.
Everything @jprjr wrote about owncast
file from owncast-0.0.12-linux-64bit.zip
is correct.
When I download something from the Internet I assume it is made for glibc, that's why I assumed the binary
won't work on a musl system (and I was correct). But when I saw that the building instructions precisely
state "GCC compiler" I thought the code uses some GCC-specific stuff that would need work-arounds in order to
compile with musl.
I just thought the manual could use different wording. That's all. That's the issue, not the binary.
But when I saw that the building instructions precisely state "GCC compiler" I thought the code uses some GCC-specific stuff that would need work-arounds in order to compile with musl.
Again you're thinking of glibc-specific stuff, not GCC-specific stuff.
GCC has it's own extensions but those are language-specific or platform-specific extensions like __atomic
built-ins, but those work on musl as well, because that's dealing with how the code is compiled for the hardware architecture, and not dealing with using library functions.
glibc extensions are more around adding library function that aren't part of the C standard library or POSIX, and macros like __BEGIN_DECLS
/__END_DECLS
- but not like, language extensions. Patching software to compile with musl involves patching out glibc-isms, not GCC-isms. I'm pretty certain void is using GCC as the default compiler, but it's admittedly been a while since I last used it.
I actually helped get llvm + clang to compile under void linux w/ musl, and postfix - none of the patching really has to do with GCC, it's glibc.
For reference, going forward the shipped binary is statically linked, so it should be in better shape on that front. I never thought much how the previous builds weren't. This Earthly
powered build is new. I'll certainly take advantage of sqlite_omit_load_extension
because yeah, we're not using any of sqlite's extensions that need to be loaded.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If this was a feature request that others have shown no interest in then it's likely to not get implemented due to lack of interest. If others also want to see this feature then now is the time to say something! Thank you for your contributions.
Good First Issue
This item was marked as a good first issue because of the following:
- It's self contained as a single feature or change.
- Is clear when it's complete.
- You do not need deep knowledge of Owncast to accomplish it.
Next Steps
- Comment on this issue before starting work so it can be assigned to you. Also, this issue may have been filed with limited detail or changes may have occured that are worth sharing with you before you start work.
- Drop by our community chat if you'd like to be involved in more real-time discussion around Owncast to talk about this change.
- Follow the project's getting started tips to make sure you can build and run the project from source.
Notes
- Current web work is taking place in the
webv2
branch and it is very much work in progress. Read the README for this branch to get the web project running. But it's mostly just anpm install
andnpm run dev
. - We use Storybook for testing and developing React components.
npm run storybook
. - If you need to install the Go programming language to run the Owncast backend it's simple from here.
- Active contributors get an Owncast t-shirt! Ask about it if you feel like you've been contributing and haven't yet been given one.
I fixed this before asking to have it assigned to me. How does that work?
Done, thanks!
@gabek can this issue be #hacktoberfest too?
Of course!