CASAVÍDEOSCURSOSESTUDANTESPATROCINADORESDOAÇÕESEVENTOSTUTORIAISLINKSNOTÍCIACONTATO


TUTORIALS 》 Compiling a C Compiler with a C Compilter | Compile gcc with gcc

As we know the fundamental aspect of a programming language compiler is to translate code written from language to other. But most commonly compilers will compile(i.e translate) code written in high-level human friendly language such as C, C++, Java, etc. to native CPU architecture specific (machine understandable) binary code which is nothing but sequence of CPU instructions.

If we see that way we should able to perfectly compile a source-code of a C compiler with another C compiler run-time binaries. In that way we should able to perfectly compile an entire gcc compiler source-code with an installed gcc compiler. We can get the gcc compiler sources via github: https://github.com/gcc-mirror/gcc or in a Ubuntu system we can get the desired gcc source code for a specific version via:

$ apt source gcc-9

NOTE: since we are getting sources via apt-get(or apt) command, we do not have to provide sudo access.

However it is important to know that source code downloaded via github may require different run-time dependencies vs what is currently installed in your Linux system, vs when you get gcc source via Ubuntu apt command and choose a version which is close to your installed gcc compiler, then the run-time dependencies which are required for this source may match with whatever currently installed on your Ubuntu OS install.

Like any open-source project you can browse through any compilation/installation steps/documentation. Typially you should get in files such as README, or INSTALL, etc. But in the case of gcc, they provided few user-friendly web html documentation (as should below) which you can open in a browser and follow the steps and mainly various options and prerequisites.
gcc soruce code and Installation Guide
gcc HTML Installation Guide page 1
gcc HTML Installation Guide page 2
gcc HTML Installation Guide page 3
gcc HTML Installation Guide page 4
gcc HTML Installation Guide page 5

You can now proceed compilation and before that install dependencies(i.e third-party libraries) if any. Once everything is done, you can see the the custom compiled gcc binaries are installed in a custom directory path so as to not disturb the Ubuntu OS module installed gcc binaries.

kiran@1TBSGBR:/code/gcc/install$ ls
test  test.c  usr
kiran@1TBSGBR:/code/gcc/install$ ./usr/local/bin/gcc -v
Using built-in specs.
COLLECT_GCC=./usr/local/bin/gcc
COLLECT_LTO_WRAPPER=/code/gcc/install/usr/local/bin/../libexec/gcc/x86_64-pc-linux-gnu/9.2.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ./configure --disable-multilib
Thread model: posix
gcc version 9.2.0 (GCC) 

You can now do a test compilation of a sample C source-code file (test.c) with the current compiled gcc compiler (i.e ./usr/local/bin/gcc) as shown below:

kiran@1TBSGBR:/code/gcc/install$ ./usr/local/bin/gcc -o test test.c
kiran@1TBSGBR:/code/gcc/install$ ./test
hello world
kiran@1TBSGBR:/code/gcc/install$ cat test.c
#include 
void main()
{	
	printf("hello world\n");
}
kiran@1TBSGBR:/code/gcc/install$

Here is my two-part Youtube video episode series which shows you all the steps from start to finish in a live demo screen capture.
If you have any queries or anything to discuss, kindly send me a mail to: [email protected]

Also recommend to watch:


Featured Video:



Suggested Topics:


☆ Tutorials :: Arduino UNO Projects ↗


☆ Tutorials :: Network Software Development ↗


☆ Tutorials :: Research and Projects ↗


☆ Tutorials :: Linux (user-space), Systems Architecture ↗


☆ Tutorials :: Linux Kernel Software Development ↗


☆ Tutorials :: Linux Kernel Internals (PDFs) - by Ramin Farajpour ↗


☆ Tutorials :: Software Development (Programming) Tools ↗


☆ Tutorials :: Embedded Projects ↗

Join The Linux Channel :: Facebook Group ↗

Visit The Linux Channel :: on Youtube ↗


💗 Help shape the future: Sponsor/Donate


Tópicos recomendados:
Featured Video:
Assista no Youtube - [1950//0] 157 Wireshark - Investigate TCP-Connections with Wireshark Flow Graph feature ↗

libpcap Library | Linux User-space Network Stack Development ↗
Sunday' 06-Aug-2023
libpcap is a very popular user-space networking library, with which you can capture and or generate packets. libpcap is the underlying framework for many popular packet capture tools such as tcpdump, Wireshark and so on. In fact libpcap is a part of tcpdump project. But besides just using it as a packet capture tool, you can use libpcap in various applications, such as user-space based networking stack development, etc. In some cases libpcap is yet another alternative to raw-sockets and tun/tap interfaces.

The Linux Channel :: Sponsors ↗
Monday' 30-May-2022
Here is a list of all The Linux Channel sponsors/donors (individual/companies).

Inline Programming | Assembly | Scripts | php, python, shell, etc | Rust in Linux Kernel ↗
Friday' 12-May-2023
Inline programming is a technique where code statements are included directly in the text of a program, instead of being contained in separate files or modules. Inline programming can be useful for small or simple tasks, as it can eliminate the need for a separate script or function. One common example of inline programming is using JavaScripts, Php, etc in HTML documents to create dynamic content. Similarly in Linux Kernel we can find lot of instances where we can find inline programming such as inline assembly and now Rust within the Kernel source.

Linux Kernel /sysfs Interface ↗
Saturday' 14-May-2022
/sysfs is one of the most popular kernel to user-space interface which you can leverage to add an interface to your Kernel code such as Kernel modules, Kernel Device Drivers, etc. Although personally I prefer /proc interface than other alternatives such as /sysfs, ioctl() and so on for my personal Kernel modules/stack. So here is my detailed multi-episode Youtube video series on /sysfs Interface.

Rockchip ROC-RK3566-PC from Firefly | OpenWRT ↗
Thursday' 19-Oct-2023
Here is my multi-episode video series on evaluation of Rockchip ROC-RK3566-PC from Firefly with stock OpenWRT firmware.

What is purpose of Kernel Development - Example SMOAD Networks SDWAN Orchestrator Firewall Kernel Engine ↗
Monday' 18-Jul-2022
Often aspiring students may have this question, that what is the purpose of Linux Kernel Development. Since Linux Kernel is very mature and it has almost everything one would need. Usually, we need custom kernel development in the case of any new driver development for new upcoming hardware. And this happens on and on. But at times we may also come across few features/modules/components which are already provided by the Linux Kernel which are not adequate or atleast not the way we exactly intended to use. So, this is the real-world example, sometimes no matter what Linux Kernel provides as a part of stock Kernel/OS features, sometimes we have to write our own custom kernel stack or module(s) which can specifically cater our exact needs.

Linux Kernel Driver Device Trees ↗
Tuesday' 17-Jan-2023
The Linux kernel is the backbone of the Linux operating system. A device tree is a hierarchical tree structure that describes the various devices that are present in a system, including their properties and relationships to one another. The device tree is used by the Linux kernel to identify and initialize the different devices on a system, and to provide a consistent interface for interacting with them.

Linux Kernel vs User-space - Library APIs - Linux Kernel Programming ↗
Friday' 27-Oct-2023
One of the important aspects a beginner who is into Linux Kernel space systems software development has to understand is that unlike user-space C/C++ programming, where you can freely include any library APIs via respective #include files (which are dynamically linked during run-time via those /lib .so files), in the case of Kernel space programming, these library APIs are written within the Kernel source itself. These are the fundamental APIs which we commonly use, such as memcpy(), memcmp(), strlen(), strcpy(), strcpy() and so on. So here is my detailed Youtube video episode on the same with live demo, walk-through and examples.

Porting Sample libpcap C code to Raw Sockets | User-space Network Stack Framework ↗
Monday' 04-Sep-2023
Here is my multi-episode video series where I demonstrate how you can port the my libpcap sample code, discussed in the earlier episode to raw-socket. This code should further help you to design and architect your own user-space Network stack on top of this fundamental framework.

Roadmap - How to become Systems Software Developer ↗
Friday' 13-May-2022
When you are at the beginning of your career or a student, and aspire to become a software developer, one of the avenues to choose is to become a hard-core Systems Software Developer. However it is easier said than done, since there are many aspects to it as you explore further. As a part of systems developer, you can get into core kernel space developer, kernel device drivers developer, embedded developer and get into things like board bring-up, porting, etc, or can become a user-space systems programmer, and so on. So here is my detailed multi-episode Youtube video series on Roadmap - How to become Systems Software Developer.


Trending Video:
Assista no Youtube - [393//0] x262 Kernel Crashes | FAQ | while working on sk_buff data-structure | Kernel Network Programming ↗

Data Profiling and Visual Analysis tool for Deep Learning and AI - VLOG - The Linux Channel ↗
Saturday' 13-Mar-2021



Recommended Video:
Assista no Youtube - [1039//0] x258 tp-link UE300 Linux Kernel Realtek Driver Codewalk rtl8153a-3 r8152 USB 3.0 to Gigabit - Part2 ↗