287 points · by gcoleman · 6y ago · 176 comments
This is effectively an administrative change. (Not to downplay the work!)
Suggested alternative title: FreeBSD has Removed GCC from Build Infrastructure.
[0] https://github.com/freebsd/freebsd-ports/blob/master/Mk/bsd....
As others have pointed out "FreeBSD has removed GCC from the. base system" would be a better title.
It's as if MacOS decided to stop shipping bash by default. Of course you'll still be able to install it yourself, but it's not part of the OS anymore and you can't rely on it being available and supported.
FreeBSD is not Linux, it's a full OS, not just a kernel. There's a very clear line between what's part of the base system and what's not.
That excludes the bulk of this site's readers.
Imagine this:
"Microsoft has removed Notepad from Windows!"
"You dummy, no it hasn't; you can still get a Notepad for Windows from the Microsoft Store! Microsoft only removed it from the base installation of Windows, not from Windows as such."
Doh? If that happened, you would no longer be able to rely on any installation of Windows to have Notepad.
Maybe we could compromise with "FreeBSD has removed GCC from its base system" or something similar.
Edit: This comment was not meant to be snarky.
Title was clear to me - yes, perhaps more clear as you say it though.
More precisely, it’s as if macOS stopped shipping GCC in the CLT.
Oh wait, they did exactly that already, the last one being gcc 4.2 on Darwin 11, after that a GCC command is still present but it’s just a front to llvm.
https://github.com/archmac/packages/blob/master/core/apple-g...
They switched from tcsh to bash, so it's not out of the question.
edit: looks like tcsh is still available, but not the default.
Is there a reason that you’d be relying on what’s included in the FreeBSD base system? If I were building a piece of software and developing a FreeBSD target for it, I’d probably just write a port manifest for it and contribute it; and in so doing, I can have my port manifest declare a dependency on the GCC port.
Just like if I create an Ubuntu PPA, I can depend on Ubuntu system packages, or even other people’s PPAs. (And it’s even less arduous than the Ubuntu PPA case, because PPAs are all their own third-party package repos that you have to add, while Ports is one flat namespace. As long as it’s “in ports”, you can depend on it without asking the user to do the equivalent of `sudo apt-repository add ...`)
Yes, they are -- your understanding was correct. The FreeBSD OS now exclusively builds with clang, and clang is also the compiler shipped with the system.
You can, of course, still install GCC, and many other packages, from the ports tree, but it is no longer part of the OS.
% bash -version
=> GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin19)
Indeed- "external toolchain" includes gcc6[0] and gcc9[1] ports that can be used specifically for building the FreeBSD base system. These are mostly easy to use, install the flavor for whatever architecture you're building and specify CROSS_TOOLCHAIN=<arch>-gcc6 when you build. More/better/complete information (and examples!) at [2].
[0] https://www.freshports.org/devel/freebsd-gcc6
lapack, for example, has USES=fortran[1]. That invokes Uses/fortran.mk[2] and accepts the ports-default fortran compiler, FORTRAN_DEFAULT, which is definedin bsd.default-versions.mk[3] as gfortran (GCC).
[1]: https://svnweb.freebsd.org/ports/head/math/lapack/Makefile?r...
[2]: https://svnweb.freebsd.org/ports/head/Mk/Uses/fortran.mk?rev...
[3]: https://svnweb.freebsd.org/ports/head/Mk/bsd.default-version...
That said: it's good to remember how much of a breath of fresh air clang was way back when. Error messages in that era of GCC were _terrible_. Clang showed up with colorized error messages and ASCII art arrows and it felt like magic. So, sure, licensing alone would have been a fine reason for base to do what it did, but I don't think it's fair to characterize it as _just_ licensing. GCC has made huge improvements since then, but those are only visible in ports (which has always had and continues to have modern GCC). Which I guess you could argue makes it a licensing issue? :-)
The default colour is restored after the newline, rather than before it.
* https://github.com/llvm-mirror/clang/blob/6803cc1958b56e0bd5...
I have recently set DECSCNM on in my terminal(s), which inverts everything, effectively swapping the foreground and background colours. The clang error messages now come out with unsightly large streaks of extraneous colour, as freshly erased lines caused by scrolling fill with the colour that clang has not yet turned off. clang was always doing this. But when it's the background colour it's more visible.
It would be such a simple fix, that's actually in line with code elsewhere in the same class. I wonder how many years it will take to get it changed.
I disagree; I think clang set a trend and now GCC's error message are worse than they used to be. In the recent days I've seriously considered patching them out because I'm getting really tired of the wall of text of useless suggestions, macro expansion, etc. that hides the actual error. 99% of the time I just need to see which line my error originates from (before any macro expansion) and I can follow the chain manually in the remaining 1% of cases.
What's happening now is that I have a line with an error, and I get 50 lines of trash output among which the actual error is buried. And trying to jump to the error in my editor has me jump through headers, #include rows, and other garbage, sometimes missing the original error line entirely!
It's ridiculous. The suggestions are also largely either wrong or so obvious that they have only negative value. It's just clutter. Same goes for the ascii art arrows. Just clutter, making it harder to see relevant things.
I can see these messages being helpful for a total newbie who's still acquainting themselves with the standard library and figuring out the basics of the language, but for me (writing C daily for a living, and as a hobby for the past 15+ years) it's just getting in the way.
I have heard that the LLD (LLVM linker) is much faster than either ld.bfd or ld.gold.
Not only that, but even proprietary software can be built with a GPL compiler, the binaries produced by the compiler are not considered derived work that must be covered by the same GPL license, so if Microsoft wanst to build Windows with GCC for example they can do that, provided that they don't link in the executable produced GPL code (e.g. glibc).
Is there some tipping point where gcc has too few significant end users to stay relevant? I'd hate to lose the diversity.
It is primarily non-GPL platforms/systems/companies that are switching to clang for it's much friendlier license.
Edit: "~now" rather than "now"
"With support for asm goto, the mainline Linux kernel for x86_64 is now buildable (and bootable) with Clang 9. Other architectures that don’t require CONFIG_JUMP_LABEL=y such as arm, aarch64, ppc32, ppc64le, (and possibly mips) have been supported with older releases of Clang (Clang 4 was first used with aarch64).
The Android and ChromeOS Linux distributions have moved to building their Linux kernels with Clang, and Google is currently testing Clang built kernels for their production Linux kernels."
That was in September 2019
Yes. There will be a tipping point, as with any economic theory of sustainability. No, we wont reach that tipping point in the foreseeable future. It is still extremely widely used, and continue to be actively developed.
LLVM and GCC will likely enjoy duopoly in the Open Source Space for a very long time.
As clang implements more and more of GCC's extensions, though, I could see things reaching that tipping point.
Sony, Apple, IBM, and plenty of other embedded vendors don't contribute 100% their improvements back to LLVM.
What's missing for sparc64 in Clang? We have Clang on sparc64 in Debian Ports.
IIRC powerpc32 is currently using clang with old bfd ld, but lld in llvm 10 may be quickly reaching the point where it's suitable for powerpc32 as well.
Care to elaborate?
We're maintaining sparc64 in Debian Ports and we have smashed quite a number of bugs in the SPARC backend in LLVM.
Are there any issues you are seeing?
This is mostly just an observation, I'm not sure how I feel about it. Compiler diversity doesn't seem more important than OS diversity to me, and none of these feel particularly important. As a user I was happy to switch to clang for the better error messages.
I think GCC will remain relevant for as long as there are people who care about free software.
- just like chrome becoming the only browser, one compiler isn't good either. The implementation starts to define the language instead of the standard
- separate projects can use different methodologies and tradeoffs.
- if there is a bug or exploit that only applies to that complier and not all programs
I don't think we should have 20 major C++ compilers but we shouldn't have one.
Apparently not in practice, because LLVM's copyleft license hasn't stopped large amounts of free software from being created (for example, rustc).
Also, a monoculture isn't great for security/exploits.
https://android-review.googlesource.com/q/topic:%22rm_gcc%22...
Apparently the reason for this is GCC's move to GPL v3. So FreeBSD was forced to remain using GCC 4.2.1, GPL v2.
As far as Clang goes, is FreeBSD tracking/upgrading to newer Clang versions? I assume the answer is yes but I don't know.
Clang/LLVM was imported into FreeBSD base in FreeBSD 9, released in 2012[1]. I don't believe it was the system compiler for any arch at that time, but could be wrong. In FreeBSD 10 (2014) it became the default compiler for amd64/i386[2].
Gcc still produces better=faster machine code. So why the hate? Are there political reasons involved?
GCC is more spaghetti than Clang, less modular. But yeah, it's mostly political/business/legal related. A lot of people hate copyleft with a passion like Apple and Google, who hire lots of people to work on LLVM.
The idea seems to be that LLVM will eventually catch up to GCC on quality of generated code.
That's totally fine if you're talking about a workstation, laptop, or server. But it's a big security risk on an embedded system like a smart TV, mobile phone, or game console - both from an IP protection point of view, and also from a botnet/pwning point of view.
FreeBSD (and others presumably) don't want their users to need to worry about accidentally installing something from the core system and finding themselves in violation of the GPL.
- ld.bfd on 32-bit powerpc (should go when lld 10.0 is in FreeBSD)
- GNU as on i386 and amd64 (expected by some ports, and needed to assemble one file in the base system on amd64)
- objdump (expected by some ports, but not used in the base system)
These should be removed in FreeBSD 13.0. More details are on our Wiki, https://wiki.freebsd.org/GPLinBase