Are there any risks or disadvantages to building software from source, compared to installing a package? Can it mess with my system in any way?
I usually avoid it because I've found it to be a faff and often doesn't work anyway but in a couple of cases it has been necessary.
28 Comments
Aiwendil@lemmy.ml · 22 pts · 304d
Gentoo user....but assuming now it's about building on distributions that don't automate it like gentoo.
Disadvantages:
Of course you also gain a lot of advantages...but that wasn't asked ;)
You can "escape" most of the mentioned disadvantages by using a distro like gentoo that automates much of this. It's probably worth a look if you plan on doing this regularly.
edit:typos
Shimitar@downonthestreet.eu · 12 pts · 304d
Gentoo user here.
Of course I always build every package from source because that's how Gentoo works.
Well, you get well optimized software for your specific cpu and architecture that often will not run on a different CPU. At the cost of lots of time.
For big ones like Firefox or rust I always choose the prebuilt ones... But everything else is from sources.
Also, another great advantage is to customize package features to your likings, like disable an audio backend or enable another, and such.
lengau@midwest.social · 8 pts · 304d
The irony is that big things like Firefox can get the most advantages from building for your specific CPU variant, especially if you use them frequently.
iopq@lemmy.world · 7 pts · 304d
Yeah, but only when you build with lto+pgo which will take even longer
https://wiki.gentoo.org/wiki/Project:Mozilla/Firefox_Benchmarks_2025_Q1
lengau@midwest.social · 12 pts · 304d
Look I don't have heat in the winter so I compile Firefox for various processors to keep my bedroom warm okay?
ragas@lemmy.ml · 1 pts · 304d
As far as I can see, this comparison always uses the 'native' target. So you can't even compare a generic LTO build with a native (non LTO) build from this.
Auli@lemmy.ca · 1 pts · 302d
I thought the optimizations didn't actually do they much.
lengau@midwest.social · 1 pts · 302d
They don't in general, but things that do heavily detailed graphics work (like your compositor or browser) or lots of cryptography work on the CPU can get a bit more out of those newer instructions than many other programs.
Very approximately, things that Gentoo offers prebuilt versions of because compiling them is so resource intensive are often the things that can get the best benefit out of your architecture variant. (Not singling out Gentoo here as an example of "doing it badly" - they do the sensible thing by providing these prebuilt binaries, but in some ways it defeats the purpose of optimised source distributions.)
It's a Hard Problemâ„¢ to solve.
oeuf@slrpnk.net · 1 pts · 304d
That's really cool. How does that work?
balsoft@lemmy.ml · 4 pts · 304d
All x86_64 CPUs support a certain "base" set of instructions. But most of them also support some additional instruction sets: SIMD (single instruction multiple data - operations on vectors and matrices), crypto (encryption/hashing), virtualization (for running VMs), etc. Each of those instructions replaces dozens or hundreds of "base" instructions, speeding certain specific operations dramatically.
When compiling source code into binary form (which is basically a bunch of CPU instructions plus extra fluff), you have to choose which instructions to use for certain operations. E.g. if you want to multiply a vector by a matrix (which is a very common operation in like a dozen branches of computer science), you can either do the multiplication one operation at a time (almost as you would when doing it by hand), or just call a single instruction which "just does it" in hardware.
The problem is "which instruction sets do I use". If you use none, your resulting binary will be dogshit slow (by modern standards). If you use all, it will likely not work at all on most CPUs because very few will support some bizarre instruction set. There are also certain workarounds. The main one is shipping two versions of your code: one which uses the extensions, the other which doesn't; and choosing between them at runtime by detecting whether the CPU supports the extension or not. This doubles your binary size and has other drawbacks too. So, in most cases, it falls on whoever is packaging the software for your distro to choose which instruction sets to use. Typically the packager will try to be conservative so that it runs on most CPUs, at the expense of some slowdown. But when you the user compile the source code yourself, you can just tell the compiler to use whatever instruction sets your CPU supports, to get the fastest possible binary (which might not run on other computers).
In the past this all was very important because many SIMD extensions weren't as common as they are today, and most distros didn't enable them when compiling. But nowadays the instruction sets on most CPUs are mostly similar with minor exceptions, and so distro packagers enable most of them, and the benefits you get when compiling yourself are minor. Expect a speed improvement in the range of 0%-5%, with 0% being the most common outcome for most software.
TL;DR it used to matter a lot in the past, today it's not worth bothering unless you are compiling everything anyways for other reasons.
thingsiplay@beehaw.org · 11 pts · 304d
The best would be to ask a Gentoo user. :D
Disadvantage (besides the update procedure mentioned by the other answers here) is, it might take lot of time, download lot of dependencies and files and need additional space on your drive to compile. It can be a hassle to install and setup the required tools and libraries too. This highly depends on the project itself if its worth it. In example nobody in their right mind wants to compile their web browser (Firefox, Chromium, whatever) themselves (sorry if I offended someone with that. :D). But a simple and short C program is as simple as running
makecommand in example (given the dependencies are installed, which are most likely for simple programs after a few programs have been compiled).Most of the time you don't need to compile software. Especially if you trust the source or its in the official repositories of your distribution.
Depends on what you mean by that.
Nibodhika@lemmy.world · 8 pts · 303d
Like many have said, the main disadvantages are:
The main advantages are:
If you're interested in compiling your own software maybe consider using a distro whose package manager allows to compile stuff, Gentoo is the obvious choice, but Debian based distros can also do that.
thevoidzero@lemmy.world · 2 pts · 302d
Arch also kinda allows that if you write custom PKGBUILD file. It's easy to write for simple stuffs that are based on make/cargo etc.
It's time consuming if some program gives you 100s of lines of code in bash script to install their program though.
Edit:
Another disadvantage of building from source is dependency management. You might accidentally uninstall some dependencies, the standard library versions might change and break your packages, etc.
Using package manager mitigates that.
neox_@sh.itjust.works · 1 pts · 302d
Using GNU Guix to build can solve the "difficult to install" issue and also help with dependency management, however compilation time can't be avoided. Advantages remain, however, thanks to package transformation options!
just_another_person@lemmy.world · 6 pts · 304d
Just convenience. That's what packages provide. There's no special magic under the hood in most cases as a downside to packages, and in most cases for specific projects, this is why stacks have containers, because you set the build steps to include the things you need in a pragmatic way, but now have to mess with static files on a filesystem.
MyNameIsRichard@lemmy.ml · 6 pts · 304d
The only disadvantage is that you have to manually update, unless you've installed it from the aur.
jaypatelani@lemmy.ml · 5 pts · 304d
If you are using pkgsrc like system it will be easier. Even NASA uses it with their OpenSUSE system for NAS. Compiling has it's own advantages but normal people don't need it
balsoft@lemmy.ml · 4 pts · 304d
Well, compiling from source is the "installing dodgy freeware .exe" of the Linux world. You have to trust whoever is distributing that particular version of the source code, and ideally vet it yourself. When installing a binary package from your distro's repositories, presumably someone else did the vetting for you already. Another slight risk is that technically you are running some extra build scripts before you can even run the application, which is a slight security risk.
Yeah, unless you take precautions and compile in a container or at least a sandbox, the build scripts have complete unadulterated access to your user account, which is pretty much game over if they turn out to be malicious (see: https://xkcd.com/1200). Hopefully most FOSS software is not malicious, but it's still a risk.
If you "install" the software on your system, it also becomes difficult to uninstall or update, because those files are no longer managed from any centralized location.
I recommend using a source-based package manager, and package your software with it (typically won't be any more difficult than just building from source) to mitigate all of those (as typically source-based PMs will use sandboxing and keep track of the installed files for you).
communism@lemmy.ml · 4 pts · 304d
The main disadvantage is that it's less automated, and also you don't get automatic updates without any other package management system in place. If you're using something like e.g. source packages from the AUR then that solves both those problems and there's no downsides (beyond extra computational power/time you spend waiting) so long as the package maintainer does their job correctly.
Not... really? I guess if you're downloading random tarballs off the internet and running make install without checking the integrity or trustworthiness of what you're downloading then you could get a virus. But if you're certain the source you're getting is legitimate, then I suppose the only way building from source could "mess up your system" is if you mess up your system libraries or something whilst trying to install dependencies.
TMP_NKcYUEoM7kXg4qYe@lemmy.world · 3 pts · 304d
The only potential downside is that software is not handled by your package manager, so uninstalling or upgrading can be pain. But there are ways around it like source based package managers or manually building binary packages and then installing them.
MonkderVierte@lemmy.zip · 3 pts · 304d
Uninstalling can be a pain, so better build a package of it too.
matcha_addict@lemy.lol · 3 pts · 303d
Not with gentoo!
MonkderVierte@lemmy.zip · 1 pts · 303d
Or Source Mage.
HubertManne@piefed.social · 2 pts · 302d
Its just a pain. You have to know what flags and such you need to use and might have to install specific libraries and such. Granted. Its been a long time since I have done that.
fruitycoder@sh.itjust.works · 1 pts · 302d
Time. Your build environment can be potentially compromised. Takes more tools to build then install increase maintance, chances for failure to update, and increase attack surface area.
Removing software can be much harder if not installed by a package manager as well, which can make upgrades a PITA
That said yeah I do it from time to time. Build in one container, install in an other, and you mitigate some of that concern.
hades@feddit.uk · 1 pts · 304d
Think about it this way: you're downloading someone else's code and running it on your system. The OS doesn't care: it will give it access to everything your user has access to, but won't give access to anything else.
So (under the caveat below) the software won't be able to mess with your system because your user generally can't mess with your system. However, you still need to trust the software, since it will be able to access e.g. your saved passwords, SSH keys, install a keylogger, etc. In comparison, the binary packages can be seen as safer, because they have more "eyes" on them, and there is more time between the code being published and you running that code on your system.
Caveat: if you run something like
sudo make install, then, of course the risk is way higher, and the package definitely will be able to mess with your system up to and including destroying it.bacon_pdp@lemmy.world · 0 pts · 304d
oeuf@slrpnk.net · 1 pts · 304d
What are the security advantages?
bacon_pdp@lemmy.world · 1 pts · 304d
1984@lemmy.today · 1 pts · 302d
There are flags to disable things, like pulseaudio or whatever, so its not even included in the binary. Which means its 100% safe against vulnerabilities in that piece of code since its not inside the binary at all.