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/...
  • Наука та технологія

КОМЕНТАРІ • 42

  • @hinzster
    @hinzster 9 місяців тому +3

    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!

    • @MikeShah
      @MikeShah  9 місяців тому

      Very cool -- waiting days is something I have a hard time processing 🙃

  • @dookshi
    @dookshi Рік тому +5

    Haha, nice one with the -j 65536👍

  • @VoidloniXaarii
    @VoidloniXaarii Рік тому +2

    Fascinating, thanks so much

    • @MikeShah
      @MikeShah  Рік тому +1

      You are most welcome!

  • @vishalrao7010
    @vishalrao7010 8 місяців тому +1

    Thank you so much.

    • @MikeShah
      @MikeShah  8 місяців тому

      You are most welcome!

  • @kafuu1
    @kafuu1 10 місяців тому

    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

  • @lievendecock5836
    @lievendecock5836 2 місяці тому

    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 ?

  • @fmm5322
    @fmm5322 11 місяців тому

    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

  • @fmm5322
    @fmm5322 11 місяців тому

    Q4. You are cloning from git repository. Does this equally applicable to ftp server tarballs packages?

  • @miguelalbertooxa8699
    @miguelalbertooxa8699 Рік тому +2

    Hi Mike any suggestions for those who are learning c++20 modules on linux(vs code) ?

    • @theintjengineer
      @theintjengineer Рік тому +1

      I changed to Windows because of this - MSVC Modules support is good. The other compilers still suck at supporting the new features.

    • @MikeShah
      @MikeShah  Рік тому +3

      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.

  • @fmm5322
    @fmm5322 11 місяців тому

    Build essential can be run offline??

  • @lolerie
    @lolerie 11 місяців тому

    Does it then use the new compiler to compile itself?? Or there will be no optimisations inside the binary of itself.

    • @MikeShah
      @MikeShah  11 місяців тому

      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.)

  • @fmm5322
    @fmm5322 11 місяців тому

    Gmp source is in which directory

  • @fmm5322
    @fmm5322 11 місяців тому

    Q2. Ubuntu 22.04.02 jammy jellyfish comes with a gcc compiler? If not why

  • @fmm5322
    @fmm5322 11 місяців тому

    Q1. In the prerequisite section you need some version of gcc to install some other version. What if u don't have any??

    • @dimaweber
      @dimaweber 5 місяців тому

      A1. then you can't compile gcc until you get one

  • @debankurdas6104
    @debankurdas6104 Рік тому

    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

    • @MikeShah
      @MikeShah  Рік тому

      I haven't played around with building for mingw , will have to revisit that!

    • @debankurdas6104
      @debankurdas6104 Рік тому +1

      Ok...I have built myself...trust me it was a nightmare experience 💀...but finally managed to build one.

    • @MikeShah
      @MikeShah  Рік тому

      @@debankurdas6104 glad to hear it! Hmm lots of dependencies to get working?

    • @debankurdas6104
      @debankurdas6104 Рік тому +1

      @@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

    • @MikeShah
      @MikeShah  Рік тому

      @@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?

  • @fmm5322
    @fmm5322 11 місяців тому

    Q5. How to get build essential package offline

  • @fmm5322
    @fmm5322 11 місяців тому

    Q3. What's diff between gcc and gdc

  • @GaryChike
    @GaryChike Рік тому +1

    C23 .. wow! 🦏

    • @MikeShah
      @MikeShah  Рік тому +1

      It seems to be updating every 6 years or so :)

  • @Leisery
    @Leisery 11 місяців тому

    Did someone also accidentally typed make in build dir instead of make -j [num] ....?

  • @theintjengineer
    @theintjengineer Рік тому +1

    Still no P1689R5🤦🏽‍♂️ [-fdep (module dependency scan)]
    Oh, boy...

    • @MikeShah
      @MikeShah  Рік тому +1

      Maybe the next major release? Will look forward to more module support in the future

    • @theintjengineer
      @theintjengineer Рік тому +1

      @@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.

    • @MikeShah
      @MikeShah  Рік тому

      @@theintjengineer 🥂 cheers!

  • @omerfaiq2487
    @omerfaiq2487 8 місяців тому +1

    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

    • @MikeShah
      @MikeShah  8 місяців тому

      Same error if you just try with 'make' ?

    • @omerfaiq2487
      @omerfaiq2487 8 місяців тому +1

      @@MikeShah Yes, I just tried it with "make"
      , but the error is the same. I use the same commands as in the video.

    • @MikeShah
      @MikeShah  8 місяців тому +1

      @@omerfaiq2487 Probably missing flex library (apt-get install flex) See: gibsonic.org/tools/2019/08/08/gcc_building.html