How does GNU software development sustain economically? I apologise if this question is out of topic, but it is simultaneously an economy and a programming question. If it should go to another SE communality, please indicate me.

In theory, GNU software is entirely developed by volunteers during their free time, or by companies that voluntary fund programmers to develop GNU software (by using income from another sector of their activity).

I understand how it can work perfectly fine for small-scale project that can be done in a couple of rainy weekends by a single individual (let's say for example a sudoku game), because after all computer programming is an extremely fun and rewarding hobby, and I have no problem seeing people developing small or medium programs during their free time and sharing them to the world.

The problem is that this scales extremely poorly for larger programs for the following reasons:


As fun as programming is, as the project that have to be implemented becomes larger, the time it takes to implement the desired functionality grows extremely quickly. A larger scale program takes an incredible amount of time to develop, for instance it could easily take 15 years of free time and vacation time for an individual to program an operating system, and by the time his software is released it'll be completely obsolete.
As other people write programs in another way that the way you would have done it, reading and understanding someone else's code takes a lot of time, in most cases as much as would writing your own code from scratch. Modifying another people's code and try to improve it, as it is encouraged by the GNU philosophy, is almost just as time consuming as developing your own clone of the said program with the functionality you'd like to add.
As soon as 2 or more people will have to collaborate to develop a larger program, this creates lots of decision-taking issues that would never arose on a single-developer project. The result is that, for example if a group of 2 programmers collaborate for a project that would take 10 years for a single man to make, they won't make it in 5 years but probably in 8.
If people that collaborate for the same project meets on the internet solely, it is easy for one member of the project to vanish suddenly (either because he lost interest or because he physically can't be on the internet anymore), thus making collaboration even harder


So, while I understand perfectly how simple programs can be developed with the GNU mindset, I absolutely don't see how such huge programs such as GNU/Linux or gcc are possible on this model. gcc is around 7 million lines of code. I know lines of code does not mean much, as in a later stage of a project the more productive programmer is the one that will actually remove lines of code (simplifying and/or optimizing the project), but this gives an overwiew how massive of a project gcc is.

So in theory, anyone can freely modify gcc during their free time, but in practice? It was developed by very professional people as a job, not as a hobby. Anyone making a compiler as a hobby will eventually give up as the cost/benefit is not worth it:


Developing a large program is such a long term huge project, they'd rather use their free time to have other activities that are more rewarding or more enjoyable in the short term
If they were to develop a large program anyway, they'd rather do it for a company that will pay them than doing it for free


In order to get people interested at developing a program such as GNU/Linux, gcc or Open Office in the long run, it should be rewarding. So my question is: Why is there people contributing to large GNU project, if they aren't getting a salary for it?
I would like to start by saying that I'm not a programmer and I have never contributed to any open source project. However, I have been interested in open source for a long time and I believe that I understand the general concepts of open source and how it works. 

To start of, I would like to say that open source does not mean that you cannot make money on the software. It just means that the code has to be publicly available. Companies like Red Hat and Canonical make money not by selling the software, but by selling their expertise. If i wan't my company to run a Linux server, I can get the software for free. But I need somebody to install it, set it up and give support. This is where specialist from e.g. Red Hat comes in and makes money. For the company it makes sense, because hiring their own specialist would probably be much more expensive. This also gives these companies an incentive to contribute the the code. They want their product to be good so people will use it and by their services. 

But lets talk about your points about scalability. 


The cool thing about open source is that you do not have to develop everything from scratch. An operating system like Ubuntu has not been build by a single person. Instead a lot of people has contributed to different parts of the system (actually I think it would be hard to find one person with all the skills to make and effective operating system). For example, the Ubuntu people does not develop the Linux kernel. They just use one developed by others. So what was without open source probably impossible, is now possible,because you can build on other peoples work. 
Reading and understanding others code it not more time consuming than writing your own. At least not in many cases. Beyond that, you do not have to understand all the code you use. If I want to write a program for Linux, I do not have to understand how all the parts in that program works in detail. I just have to know what they do. I can then take these parts and put them together with other parts to create my program. Or I can take an existing program and modify it for my needs.
tools like git and github makes it incredibly easy to collaborate. You just get the code and make modifications. You then submit them to the person in charge of the project. If it is good, it will be accepted.  
people go in and out of projects all the time. But if the project is popular, enough will be working on it. 


Here are some reasons why open source works. 


I think the main reason that open source software has become so good is that the  large number of people working on the a project, insures a level of expertise that i hard to archive in a small team of developers. While it might seem weird, this single fact, seems to outweigh all the negative problems that can arise in open source. 
In commercial programming, the project dies with the firm. Lets say you  by some software from a company that then closes. Then your screwed, as you will not receive updates and bug fixes, and you will need to by new software to keep up. With open source you can just find another company to support you software or develop it yourself. 


If you are still interested, I suggest you read 
The Cathedral and the Bazaar