# FreeBSD, Apple and GNU



## x-com (Oct 31, 2016)

Well,

before I start let me state this: 
This is NOT intended as the beginning of a flamewar, a crusade or something alike! It is meant as an honest question or discussion!

So after a some time using FreeBSD and/or Linux one discovers pretty soon, there are some strong opinions about certain foundations, licences and philosophies. There is the permanent statement FreeBSD would be like Linux should be.
Another controversy is the licencing issue. Especially after GPLv3 was released which seemed to urge the FreeBSD project to switch to the llvm/clang toolchain rather than upgrade to newer version of the gcc. At this point in history I asked myself why it was better to stick to an Apple related project while having an open source project like gcc around and ready for use and being a de facto standard for most open source projects?

To me sometimes it looks like pure ideological decisions throwing back the FreeBSD project. So I went on searching the net (and this forum) for threads and discussions about it. But as always the first hits are mostly "holy wars" and heated discussions about those topics.

Are the communities having that much odds with each over?
Why is the llvm chosen over the gcc? The llvm is stronly influenced by a proprietary company while there may be some influence on the gcc either but at least it seems it is more open?
Why is the GPLv3 considerd that "evil" from the FreeBSD project?

Can someone provide a neutral webpage about this or has someone an insight view for me to enlighten that topic?

Thanks


----------



## kpa (Oct 31, 2016)

The BSD license has always been about business friendliness and promotes closed source proprieritary products built on BSD licensed software. It doesn't say this explicitly but it has been written to suit these goals. This is as it has always been and hasn't changed over the years. The philosophy is simply put "use this software as you wish as long as you acknowledge the original license and copyright, no other strings attached".

I personally haven't seen much ideological debate from the BSD side, the arguments we tend to give are more practical rather than ideological. I would also say that most of the toxicity is coming from the GNU camp because they can't stand the idea that the BSD side is "giving away too easily" same caliber and quality software as they are under a much more restricting license.

GPLv3 is completely incompatible with the goals of the FreeBSD project and the licensing model because it places restrictions on reuse of the code that are impossible to meet in a commercial operating environment.


----------



## Remington (Oct 31, 2016)

Much of has to do with GPLv3 license that forced many developers to switch to Clang.  Apple and Google are strongly behind Clang as they are more focused on development for ARM processors.  There are more developers including those from Apple and Google working on Clang than GCC so basically GCC shot their own foot by adopting GPLv3.


----------



## x-com (Oct 31, 2016)

Remington 
Well, I see your point, but compiling ports usually leads to the point where an actual gcc is needed. Especially when one is building a desktop system. Some dependencies of Python, XFCE or LibreOffice for example pull in the gcc. So llvm/clang and gcc aren't equal at least not now. Isn't it to early to declare llvm the default while there are ports which simply not build with it? That is the ideological part which I meant. (kpa)


----------



## kpa (Oct 31, 2016)

I wouldn't say that defaulting to Clang was premature. The ports system has quite well working methods for ports to ask for GCC when it's required. The difficult part in the process has been to guarantee that binaries and libraries built with Clang are compatible with the ones built with GCC. GCC has some runtime dependencies that it pulls in and CLang has to provide the same environment exactly. The situation is even more hairy with C++ code because of the stack unwinding mechanism (and few other details) that both compilers have to implement in a compatible way.


----------



## x-com (Oct 31, 2016)

So basically it all boils down to the licensing issue, if I get this right?


----------



## kpa (Oct 31, 2016)

Yes pretty much. The last version of GCC that was acceptable by the GPL licensing to include in the FreeBSD base system was 4.2.1 and that is pre-historical when put to the time scale of how fast GCC has developed over the years. The options were either to look at non-GPL alternatives or go completely with external toolchains with compilers installed from ports and packages. FreeBSD went with the first option.


----------



## ANOKNUSA (Oct 31, 2016)

x-com said:


> Well, I see your point, but compiling ports usually leads to the point where an actual gcc is needed. Especially when one is building a desktop system.



Yes, because the FreeBSD community allows _users_ the liberty of choosing what software they want to run on their own systems. The license a program was released under has little bearing on who uses the end-product or what it's used for. The GPL mandates that _developers_ using GNU-licensed code accept that using that code automatically confers an irrevocable GNU license on their own derivative project. That's the split: the GNU license seeks to prevent third-party interests from controlling the code, while the BSD license seeks to prevent third-party interests from controlling the people who write the code. (The implication that the BSD license therefore allows third-party interests to control the code is unfounded, however.)

People are still free to choose whatever license they want, and the creators of the desktop ports you're referring to have chosen the GPL. That doesn't place any real restrictions on your use of the program, but it does place restrictions on the use of the code that program is built from---restrictions that some people find onerous. So the GPL may be required for some ports, but that doesn't mean we should use it for all ports until Clang is "ready." I mean, how will you know Clang is "ready" if you don't put it through some real-world stress-testing, like building most of the ports tree?



x-com said:


> So basically it all boils down to the licensing issue, if I get this right?



Not entirely, but it's a major factor. If you're still looking at this from an end-user's perspective, you might get the (mistaken) impression that people are just fighting over whose words look more eloquent on paper. But there are very significant differences in the licensing that have real-world effects. There are all sorts of back-and-forth arguments you can make about the pros and cons of each license. I personally prefer the sort of freedom the BSD license allows, but as an end-user I don't much care what the licensing says as long as I'm free to use the program itself. From a coding perspective, though, I tend to look down on the GPL for practical reasons as much as ideological ones. For example: I'm not sure if this is true in the latest version of GPLv3, but the GPL once mandated that using GNU-licensed code conferred a GPL _of the same version_ onto derivative code. This meant that two GNU-licensed projects could each consist of "free" code, but would be unable to share code with each other, as each project was released under a GPL version incompatible with the other. As I recall, the FFMPEG project got hit with that problem a few years back, and FFMPEG is not a minor project in the FOSS world. That's a case of strict ideology getting in the way of practicality. It's great to want software to be free, but one must ask how sensible it is to keep code "free" by preventing anyone from using it to their own ends.


----------



## Remington (Oct 31, 2016)

Original developers can develop software for FreeBSD under GPLv3 license, however, maintainers or third-party cannot apply patches to software with GPLv3 license in ports so it'll work in FreeBSD.  There are some software written for Linux or other OSes which will not work in FreeBSD unless if its patched.  You will notice some ports have patches especially /databases/mysql56-server as its license is not specified.  If it was under GPLv3 then MySQL will not be allowed in ports by third-party unless if Oracle maintains or develop MySQL for FreeBSD.

Linux kernel is still under GPLv2 license.  If they switched to GPLv3 license then all software that ships with Linux kernel must be GPLv3 licensed.  That will cause major headaches and expenses for Linux software developers.  GPLv2 and GPLv3 are simply incompatible.


----------



## x-com (Oct 31, 2016)

ANOKNUSA said:


> That's the split: the GNU license seeks to prevent third-party interests from controlling the code, while the BSD license seeks to prevent third-party interests from controlling the people who write the code. (The implication that the BSD license therefore allows third-party interests to control the code is unfounded, however.)



Ok, this is new way of thinking about it, and a quite interesting one.



ANOKNUSA said:


> I mean, how will you know Clang is "ready" if you don't put it through some real-world stress-testing, like building most of the ports tree?



That's true either, sometimes it just looks a little bit queer when the system compiler is one thing and you need a second compiler for the same language, just to get software running. 



Remington said:


> Original developers can develop software for FreeBSD under GPLv3 license, however, maintainers or third-party cannot apply patches to software with GPLv3 license in ports so it'll work in FreeBSD.


GPLv3 forbids patching for third-party developers? Or do you mean just in case you don't want to share those patch via source?


----------



## kpa (Oct 31, 2016)

GPLv3 licensed software in our ports is totally fine, no matter how much we patch it in order to make it work on FreeBSD. Our patches are also fine regardless of their status because we certainly do make them public for everyone to see and use. What we can't do is import GPLv3 licensed software into the FreeBSD base system and distribute FreeBSD with the GPLv3 licensed software directly included. This would turn the FreeBSD base system also into a GPLv3 licensed piece of software because that's what the GPLv3 license says in a nutshell. This is why GPLv3 license is called a "viral license" because it "infects" everything it touches.


----------



## kpa (Oct 31, 2016)

Something to keep also in mind. FreeBSD's use of GPL licensed software is covered by the exception made to the GPL license that allows non-GPL runtime libraries to be loaded to the process at runtime, effectively stating that linking against non-GPL dynamic link libraries does not create a derived work that would be otherwise treated as GNU licensed as a whole. Without this exception you wouldn't have been able to use GPL'ed software on any of the commercial UNIX OSes such as Solaris.


----------



## x-com (Oct 31, 2016)

Ok, sounds like laywers once again made a bad situation worse 

So basically the FreeBSD project tries to keep the base system clear of GPL'd software so it can be used more willingly by companies (Apple, Google, Whatsapp and so on) but the final decision which software I want to run is solely up to me. Is there a "risk" that someday all GPL'd software will be dropped from the ports tree?


----------



## Remington (Oct 31, 2016)

Yes, lawyers like to play with wordings of the license. No risks for software to be dropped from ports.  Software will be dropped if its no longer maintained, discontinued development, riddled with bugs or more restrictive license terms.

There are some GPLv2 and GPLv3 software in ports.  Who knows if GPLv4 or future versions will be less or more restrictive.  Licenses will evolve over time so one day GPL, BSD, Oracle's CDDL, AGPL, etc. could be replaced by something else entirely.  It's the developers who decide which license to adopt.


----------



## kpa (Oct 31, 2016)

It's hard to imagine how they could make GPL even more restrictive. The GPLv3 was all about guaranteeing that a derived work remains available to its users and the users can build it themselves and they can use it in the intended use of the derived work. This was their response to the TiVo case:

https://en.wikipedia.org/wiki/Tivoization

What next? Well, they could start making exceptions to the shared library exception


----------



## BSD-Kitsune (Nov 1, 2016)

FreeBSD is a great OS and community in that it gives people the choice to run whatever kind of software they want. Clang isn't so much an Apple product as a project they started and funded and then it became its own thing. 

The fact the base contains so little GPL software is to allow the user the choice of what they want on their system, in my case I have no issue with GPLv2 code, if there's no decent alternative, and GPLv3 is okay if its a buildtime dependency. I used to be flagrantly anti-GPL, and now I still don't really like it but I tolerate its existence because it's not undergone a steep enough decline, however, the future is permissive licensing and if GNU doesn't adapt it will become irrelevant. Linux is already seeing more competition from other OSes on the market. 

I also have no issue with proprietary software as I've used proprietary UNIX, Windows and other software that is only proprietary for years. There's nothing wrong with it, proprietary software has its uses and I'd say a highly secured OS like VMS or Stratus VOS probably is more than on par with OpenBSD, for example.


----------



## wblock@ (Nov 1, 2016)

Clang has done a lot of good by providing viable competition to gcc.  That was needed.


----------



## BSD-Kitsune (Nov 1, 2016)

wblock@ said:


> Clang has done a lot of good by providing viable competition to gcc.  That was needed.



Competition is needed to drive people to do their very best. GCC had a monopoly for YEARS.


----------



## Oko (Nov 1, 2016)

x-com said:


> Well,
> 
> before I start let me state this:
> This is NOT intended as the beginning of a flamewar, a crusade or something alike! It is meant as an honest question or discussion!


I don't believe you for a second but my respond will be of technical nature.



x-com said:


> Another controversy is the licencing issue. Especially after GPLv3 was released which seemed to urge the FreeBSD project to switch to the llvm/clang toolchain rather than upgrade to newer version of the gcc. At this point in history I asked myself why it was better to stick to an Apple related project while having an open source project like gcc around and ready for use and being a de facto standard for most open source projects?



System compiler issue is one of the most difficult issues in the Open Source Community (which predates Linux and GNU for almost 20 years). Original BSD system compiler is Portable C Compiler (PCC) written by a fellow mathematician Stephen C. Johnson. PCC was dropped out of BSDs due to political reasons in early 90s and replaced with GCC. GCC was a bad choice from the very beginning. It was intentionally designed without clear separation between front and back-ends, full of bugs and community which was hostile to open source diversity. Things took turn from bad to worse after release 2.7 when GCC start dropping support for multiple "obsolete" architectures.   Currently OpenBSD ships with two GCC version for that very reason GCC 4.2.1 (+ patches) and 3.3.6 (+ patches).

However in spite of the noise about resurrecting PCC from NetBSD camp nobody was willing serious to step up and take care of the compilers and even worse BSD licensed binary tools.

FreeBSD took the path of the list resistance and switched to LLVM (Clang is just front end) which started as a research project at the University of Illinois Urbana-Champaign. Personally I disliked the decision not because of Apple involvement (by the way I see no fundamental difference between OSX/Apple and Linux/Red Hat (75% of all kernel work) but because LLVM is written in C++ (C++ != C and C should be the only language use for system programming in anything which pretends to be UNIX).
However after the things with GCC took the turn for worse even OpenBSD imported LLVM into the base system. Then came a big surprise. Bunch of developers who were too young to remember how XFree86 died within couple of months from license change decided to change LLVM license from accademic Urbana-Champaign (comparable to MIT, BSD, ISC) to non-free Apache 2 license (Apache 2 is non-free regardless of what pfSense bunch who is policing this website thinks about it).

So long story short all BSDs have a serious problem with a system compiler. Short of resurrecting PPC  the only other alternative is   Andy's Amsterdam Compiler Kit, the default system compiler of MINIX. There is another interesting compiler called Tiny C compiler with the wrong license GPL3 (which prevents commercial use) but written by the brightest (true genious actually) and most charismatic GNU programmer/mathematician Fabrice Bellard.

So the big hope is that LLVM will have to go through the same catharsis XFree86 went and earlier BSDs (fun times right before the closure of  the Computer Systems Research Group (CSRG)) to become free again.

Alternative is that faced with the fact that there is no working compiler somebody from OpenBSD camp (or maybe FreeBSD camp for the change) step up and resurrect PPC.


----------



## x-com (Nov 1, 2016)

Oko said:


> I don't believe you for a second but my respond will be of technical nature.


Don't know what made you believe I want to start that kind of thing. I was just curious about the whole thing. I have a Linux background, Debian, RedHat and Slackware, and some others along the (very long) way. I will not deny that I don't like Apple and was highly concerned when they hired the guy that did cups. But I think I can agree with you about RedHat and Linux, and Canonical, they are both not only "good people" giving everything to help humanity to reach its best. 
I was wondering about using a compiler that can't compile really everything in the ports tree and gave me some hard times "just" because of a licence which is considered free in the linux world. kpa and remington have made some good points about it. And I can agree with wblock and teamblackfox that competition can yield to something good. 
If I really need a flamewar I can have that just by searching google and clicking on the first few entries. 
Meanwhile I've done some researching on my own and I only can say this: both sides have valid points, I most certainly wouldn't want to decide on that issue while maintaining a whole operating system. I found FreeBSD an interesting alternative to Linux because of various reasons and the licence from now on is one more of them.


----------



## obsigna (Nov 1, 2016)

x-com said:


> ... I will not deny that I don't like Apple and ...



For me LLVM/clang is the best that could happen. I do all FreeBSD (server) programming (daemons and cli tools) on the Mac using Xcode, and I am quite happy with the smooth workflow. And the best of all, I don't need to hire specialist lawyers who explain to me the pitfalls of the GPL when shipping my BSD systems with my software.

I won't deny that I do like Apple, and that I hate GNU & Linux. My aversion starts with all the ugly/funny names and designs and does not end with the GPL.

Anyway, I guess everything has been said on the given topic in hundreds of similar threads about FreeBSD, Apple, GNU, ..., hasn't it?


----------



## x-com (Nov 1, 2016)

obsigna said:


> I won't deny that I do like Apple, and that I hate GNU & Linux. My aversion starts with all the ugly/funny names and designs and does not end with the GPL.


You're free to do so, so am I.

Let me put this thing to the right perspective: I don't care if its llvm by Apple or a compiler xy made by whatever company. My core question was: Why jump from an open source compiler to a compiler more influenced by some companies (no matter which). Just out of ideology or because of some serious concerns.

The anwser was because of some serious concerns about the GPL3. I'm ok with that now that its clear to me.



obsigna said:


> Anyway, I guess everything has been said on the given topic in hundreds of similar threads about FreeBSD, Apple, GNU, ..., hasn't it?



The hundred similar threads beginning and ending in "holy wars". As I stated I'd just wanted to ask and understand that topic, or is this forbidden?


----------



## ANOKNUSA (Nov 1, 2016)

x-com said:


> Don't know what made you believe I want to start that kind of thing.



Oko's default setting is to punch the first thing that makes a sound, then blame it for not running OpenBSD and not being old enough to remember Henny Youngman.


----------



## x-com (Nov 1, 2016)

ANOKNUSA said:


> ... enough to remember Henny Youngman.


Ok, I had to jump to wikipedia for this one  Thanks for the hint


----------



## kpedersen (Nov 21, 2016)

Oko said:


> PCC was dropped out of BSDs due to political reasons in early 90s and replaced with GCC



It is odd, some internet sources seems to mention it was removed in 2012 but the CVS agrees with you it was quite a bit before that.

I have also read the following from the OpenBSD Journal that in 2007 it was imported back into the OpenBSD CVS repo. (http://undeadly.org/cgi?action=article&sid=20070915195203&mode=flat).
The CVS commit log indeed shows ragge@ has imported it but I can only find the old attic'ed files in the CVS when I looked just now. I guess this suggests that it was removed again (probably in 2012).
Looking at the PCC website it seems that ragge@ has updated it mentioning he is the maintainer and has updated it to C99. Other than that I am not sure what is going on.



Oko said:


> Tiny C compiler with the wrong license GPL3 (which prevents commercial use) but written by the brightest (true genious actually) and most charismatic GNU programmer/mathematician Fabrice Bellard.


I am a massive fan of Fabrice's work. Not only for his Qemu which I use extensively as part of my PhD but also his TCC. It provides really clean output and comes with tiny_impdef which is the only tool that seems to successfully generate .def files when I am stuck on Windows. With just one tweak to the Gtk+ header files TCC also manages to build Gtk+ projects on Windows too so it can certainly handle some (overly) complex code well.

I would love to see either of these compilers replace gcc on OpenBSD and even clang on FreeBSD since even though I am primarily a C++ developer, I really don't see why a C++ compiler needs to be in the base OS. I especially don't see why a C++ compiler should be needed to build a C compiler. That seems really awkward to me. Though I guess it is symptomatic of simply re-purposing a generic compiler for an OS rather than one built from the ground up for the OS.

One other option could potentially be Ken's C compiler from Bell Lab's Plan 9. It is extremely simple and yet very functional and portable. Whilst I have run into one bug, it still seems pretty stable. I know up until a short while ago, Google's Go bundled a tweaked build of it for Linux, Mac, Windows etc... because it was used to compile the Go output. I guess this means it has been supported. Arguably it also supports the most architectures of any compiler but I don't know how true this is in practice.


----------

