Building GCC 13.1 (and beyond) for C and C++
Вставка
- Опубліковано 30 чер 2024
- ►(GCC 9 video is here: • Building GCC-9.1.0 fro... )
►Find full courses on: courses.mshah.io/
►Join as member to get perks: / @mikeshah
►Lesson Description:
This is an updated video on how to build large source projects, specifically the gcc compiler for version 11. I build for the C, C++, and Dlang frontend programming languages and show you how to fix few dependencies errors and install the missing dependencies. In total, it took around 80 minutes for me to figure out how to build from scratch (including the time to compile the software from scratch).
Note: I probably should have run 'sudo make install' in order to creating the correct links to default to gcc-11 for instance.
00:00 Introduction
00:25 GCC 13 updates
02:40 Pre-requisites for installation
03:20 Checking your gcc version
04:19 Downloading GCC from git version control system
05:20 Setting up the source and build directory
07:37 Running configure
10:59 Building dependencies and some tips
12:13 Observing and running 'make' (About 35 minutes later)
13:24 Running make install
14:30 Running GCC 13 (I mean 14 experimental!)
15:30 Recap of the steps we ran
17:20 Wrap up and Conclusion
►Please like and subscribe to help the channel!
►UA-cam Channel: / mikeshah
►Join our free community: courses.mshah.io/communities/... - Наука та технологія
Back in the day (in the 90s) I did a bootstrap installation of gcc on a microVAX running Ultrix32. Now *that* was an experience, all Ultrix32 had was a K&R C compiler, and somehow vi didn't want to recognize our original DEC VT102 terminal, so all I had to fix non-working stuff (because DEC's K&R C was not 100% K&R C, missing tools etc. pp.) had to be done in vi's so-called "open mode", which is basically ed with vi keybindings. You can try it with modern vi like eg. vim with ":open". Just remember ":visual" to regain your sanity :P
Oh, and it took *days*, not "half an hour". Remember, the microVAX was just 0.9 VUP (VAX unit of performance), with contemporary "big VAXen" having 2-3 per processor (and of course the microVAX only had one processor, unlike the bigger ones).
But anyway, I got it running, and that experience will stay with me forever!
Very cool -- waiting days is something I have a hard time processing 🙃
Haha, nice one with the -j 65536👍
😁
Fascinating, thanks so much
You are most welcome!
Thank you so much.
You are most welcome!
hi, could you talk aout the something about the common bug: clang: error: linker command failed with exit code 1 (use -v to see invocation) ? It seems that it some times work and sometimes not
very nice, many thanks. One question, this build also provides libstdc++ and so on. However when using the binaries of the compiler of this build (and for example using them in a cmake project where cmake was instructed to these binaries -DCMAKE_CXX_COMPILER=/full/path/to/g++) it seems the linking is still done with the system versions installed (by inspecting ldd output), and not the brand new ones created ...
Any suggestions ?
Q5. Can you show me the contents of contrib directory.. I want to se if there is. Gmp resources there? I am facing the same problem with the gcc 12.0 instalation
Q4. You are cloning from git repository. Does this equally applicable to ftp server tarballs packages?
Hi Mike any suggestions for those who are learning c++20 modules on linux(vs code) ?
I changed to Windows because of this - MSVC Modules support is good. The other compilers still suck at supporting the new features.
MSVC is indeed leading the way right now. Can keep an eye on this for now: en.cppreference.com/w/cpp/compiler_support/23 When modules support comes, I think it will be wonderful -- but might have to wait a bit.
Build essential can be run offline??
Does it then use the new compiler to compile itself?? Or there will be no optimisations inside the binary of itself.
I believe it is bootstrapping and using a previous compiler to compile it the first time, then rebuilding a second time with the compiler as you suggest (perhaps adding in any new optimizations, improvements, etc.)
Gmp source is in which directory
Q2. Ubuntu 22.04.02 jammy jellyfish comes with a gcc compiler? If not why
Q1. In the prerequisite section you need some version of gcc to install some other version. What if u don't have any??
A1. then you can't compile gcc until you get one
Hi!! any idea on how to make mingw for windows from linux. I did try out using "--host=x86_64-mingw32" but cant figure out the "--target=" for windows
I haven't played around with building for mingw , will have to revisit that!
Ok...I have built myself...trust me it was a nightmare experience 💀...but finally managed to build one.
@@debankurdas6104 glad to hear it! Hmm lots of dependencies to get working?
@@MikeShah Yeah a lot🙃, GCC and G++ needed to be pre-installed, MPFR, GMP, MPC had to be built from official source and GCC 13.1.0 MinGW-w64 and Binutils had to be downloaded from official websites using "wget" and then "tar -xf" for unpacking
Important: While "make install" for GMP,MPFR,MPC I had to use "sudo make install" instead else it would not be able to install in internal directory (usr/local)
All this just to make my own GCC C,C++ only compiler for college first semester
@@debankurdas6104 Good to know, at some point I'll go through the process and make a video as well. I guess the install deps script doesn't work for windows then and that is the bottleneck?
Q5. How to get build essential package offline
Q3. What's diff between gcc and gdc
C23 .. wow! 🦏
It seems to be updating every 6 years or so :)
Did someone also accidentally typed make in build dir instead of make -j [num] ....?
Still no P1689R5🤦🏽♂️ [-fdep (module dependency scan)]
Oh, boy...
Maybe the next major release? Will look forward to more module support in the future
@@MikeShah basically the lack of Modules Support is what made me switch to using MSVC exclusively, for I just can't go back to using headers - I freaking love the way Modules let me organise my code.
Clang does have dependency scan, but still has, for example, problems with `std::format`, so, yeah, MSVC is like years ahead of them. It has C++20 done and even some C++23.
I use the Preview Version of Visual Studio, and I even have `import std;` already. And yes, I can do `std::print(...)`☺️😁😁😁
Anyways...
Looking forward to your next videos✌🏽
Greetings from Germany.
@@theintjengineer 🥂 cheers!
Hi, thanks for the video but I get an error after "make -j 24" like this:
cc1plus: fatal error: gengtype-lex.cc: No such file or directory
compilation terminated.
make[3]: *** [Makefile:2977: build/gengtype-lex.o] Error 1
make[3]: *** Waiting for unfinished jobs....
echo timestamp > s-options
rm gfdl.pod gcc.pod gcov-dump.pod gcov-tool.pod fsf-funding.pod gpl.pod cpp.pod gcov.pod lto-dump.pod
Anyone else got the same error ? what is the solution here?
I have ubuntu 22.04
Same error if you just try with 'make' ?
@@MikeShah Yes, I just tried it with "make"
, but the error is the same. I use the same commands as in the video.
@@omerfaiq2487 Probably missing flex library (apt-get install flex) See: gibsonic.org/tools/2019/08/08/gcc_building.html