Executing C Kernel #101

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Haroogan
Member
Member
Posts: 28
Joined: Thu Aug 04, 2011 1:10 pm

Re: Executing C Kernel #101

Post by Haroogan »

Alright that starts to make sense. What about this line:

Code: Select all

export PATH=$PATH:$PREFIX/bin
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: Executing C Kernel #101

Post by Combuster »

Mhm... Another subjective stereotype, Mr. Obvious?
Even experts fail to see the blatant obvious sometimes. On the other extreme we have a lot of newcomers that are complete idiots that just want to show off their (absent) skills and of course we don't want those. Which is why we have forum rules just for that. (and so far you seem to have been repeatedly breaking two of them)

So, where in that spectrum are you? Can you do something simple like following instructions? Show us! They're obvious enough that you can complete the tutorial even if you do not know what you're doing.

On another note, knowing that google exists saves you from being harassed over a lack of effort.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
Haroogan
Member
Member
Posts: 28
Joined: Thu Aug 04, 2011 1:10 pm

Re: Executing C Kernel #101

Post by Haroogan »

This forum section is intended to provide help and tips for developers including newcomers. I'm not in the "complete idiots" part of spectrum, nor in the "cool-mega-hacker" one. I've got enough experience in programming on different languages. In these latter days I was mostly developing with OpenGL using Java or C++. As you can see I was mostly concerned with application development.

Therefore, I'm not supposed to have knowledge of building 3rd party compilers with Linux Bash utilities and rules. If I knew that I would not ask for help.

So again your flame is irrelevant in this case.

BTW, these newcomer questions will never end until you add FAQ's in the end of Wiki tutorials. Those FAQ's have to depend on what "complete idiots" ask here. I've read tons of posts here before asking and most of them were ending with deathly silence and no solution or YOUR standard comments like "Phaa! What a n00b! Go to google, read wiki. GL HF!".

Answering these questions once and simply adding them to FAQ's in the proper sections of wiki would save your forum from flooding of "complete idiots". I know you have FAQ's in some sections (and that's great!) but not too much...
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: Executing C Kernel #101

Post by Combuster »

You are wrong and more wrong:
Therefore, I'm not supposed to have knowledge of building 3rd party compilers with Linux Bash utilities and rules
Required knowledge rule wrote:UNIX experience:
You will soon notice that many of the tools used in OS development are developed for Unix, and later ported over to Windows. The Linux kernel is often used as reference or example for how things can be done, and many of the hobby operating systems have some resemblance to Unix. Having some experience with the Unix command line (bash or ksh) is a minimum. (Cygwin provides an easy-to-install Unix command line for Windows.)
Answering these questions once and simply adding them to FAQ's in the proper sections of wiki would save your forum from flooding of "complete idiots". I know you have FAQ's in some sections (and that's great!) but not too much...
The more accessible we make things, the more morons will try and use them. OS development is not easy. Stop pretending it is.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
xenos
Member
Member
Posts: 1121
Joined: Thu Aug 11, 2005 11:00 pm
Libera.chat IRC: xenos1984
Location: Tartu, Estonia
Contact:

Re: Executing C Kernel #101

Post by xenos »

Haroogan wrote:

Code: Select all

export PATH=$PATH:$PREFIX/bin
I guess you can deduce this yourself from what I wrote about environment variables. But anyway: Windows uses a variable named PATH which contains a list of directories where executable programs are searched. So for example, if you enter "gcc" in the command line, it will search all directories in the PATH variable for a file named gcc.exe (or gcc.bat). The code above appends the directory $PREFIX/bin (which should be something like /usr/local/cross/bin after setting PREFIX to /usr/local/cross) to the contents of the PATH variable. This is the location where the build scripts places the cross compiler executables (such as gcc, ld, as...).
Programmers' Hardware Database // GitHub user: xenos1984; OS project: NOS
Haroogan
Member
Member
Posts: 28
Joined: Thu Aug 04, 2011 1:10 pm

Re: Executing C Kernel #101

Post by Haroogan »

I guess you can deduce this yourself from what I wrote about environment variables. But anyway: Windows uses a variable named PATH which contains a list of directories where executable programs are searched. So for example, if you enter "gcc" in the command line, it will search all directories in the PATH variable for a file named gcc.exe (or gcc.bat). The code above appends the directory $PREFIX/bin (which should be something like /usr/local/cross/bin after setting PREFIX to /usr/local/cross) to the contents of the PATH variable. This is the location where the build scripts places the cross compiler executables (such as gcc, ld, as...).
Yeah, I thought so. Just got confused by ":" operation. I guess I can also set PATH variable within standard way in Windows through Computer Properties like I did it for MinGW.

BTW, compiling binutils right now :wink:
User avatar
xenos
Member
Member
Posts: 1121
Joined: Thu Aug 11, 2005 11:00 pm
Libera.chat IRC: xenos1984
Location: Tartu, Estonia
Contact:

Re: Executing C Kernel #101

Post by xenos »

Ah, I forgot to mention the ":". Unix uses colons to separate the different directories in the PATH variable. Windows uses semicolons instead. So yes, you can use the Computer Properties settings, but you need to use a ";" in this case.
Programmers' Hardware Database // GitHub user: xenos1984; OS project: NOS
Haroogan
Member
Member
Posts: 28
Joined: Thu Aug 04, 2011 1:10 pm

Re: Executing C Kernel #101

Post by Haroogan »

Binutils were installed successfully. Now I'm stuck on the following:

Image

So there is no info about this in the tutorial. Do I have to download additional libs or did I miss something?

Edit: Currently installing those additional libs, shall see how it goes...
User avatar
xenos
Member
Member
Posts: 1121
Joined: Thu Aug 11, 2005 11:00 pm
Libera.chat IRC: xenos1984
Location: Tartu, Estonia
Contact:

Re: Executing C Kernel #101

Post by xenos »

Indeed, the newest versions of GCC require a few libraries (GMP, MPFR, MPC) to compile successfully. It should be possible to install them as part of your MinGW distribution. I don't know much about MinGW, so I don't know how to do it this way, but it should be rather simple.

Alternatively you can download their sources from the ftp.gnu.org website and compile them by hand. I think I should upload my "cross compiler toolchain script" to the wiki once I have some time, because it automatically downloads all required sources, builds the libraries and finally builds binutils and gcc for all requested targets... (I have toolchains for i686-elf, x86_64-elf, m68k-elf and arm-elf - all done in one script.)

Once you have the libraries on your system, you can try to build GCC again to see whether it finds the libraries automatically. If not, you need to tell the configure script where to find them. For example, if you installed them in /usr/local, you would need to add "--with-gmp=/usr/local --with-mpfr=/usr/local --with-mpc=/usr/local" to GCC's configure command line.
Programmers' Hardware Database // GitHub user: xenos1984; OS project: NOS
Haroogan
Member
Member
Posts: 28
Joined: Thu Aug 04, 2011 1:10 pm

Re: Executing C Kernel #101

Post by Haroogan »

Unfortunately I can't compile GMP by hand... It says something like: "m4" is not in PATH bla-bla... I also found precompiled DLL's in MinGW repository for all those 3 libs, but it seems like DLL's won't do. I think I need static libs right?

Edit 1: Gonna try compiling m4 right now...
Edit 2: So the m4 is installed, gonna add it to PATH now and try installing GMP again...
Edit 3: Kewl GMP was installed successfully. Now gonna install other libs and finally build Cross Compiler :wink:
User avatar
xenos
Member
Member
Posts: 1121
Joined: Thu Aug 11, 2005 11:00 pm
Libera.chat IRC: xenos1984
Location: Tartu, Estonia
Contact:

Re: Executing C Kernel #101

Post by xenos »

As far as I know, m4 is some kind of a macro scripting language - I didn't even know that it's used by GMP... But indeed it is very common. It is also used by some tool named "autoconf", which generates configure scripts from a simple set of rules - written in m4.

In principle it should be possible to compile gcc with the shared libraries that come with your MinGW distribution. Where did you find them / in which directory would they be installed? I suppose it's something like /somepath/lib, in which case you would need to add "--with-gmp=/somepath" (and similarly for mpfr and mpc), without the lib-directory to gcc's configure command. But this is rather a guess...
Programmers' Hardware Database // GitHub user: xenos1984; OS project: NOS
User avatar
Owen
Member
Member
Posts: 1700
Joined: Fri Jun 13, 2008 3:21 pm
Location: Cambridge, United Kingdom
Contact:

Re: Executing C Kernel #101

Post by Owen »

GMP, MPFR and MPC can be built just by extracting the archives in the GCC directory and renaming the resulting directories to "gmp", "mpfr" and "mpc".

You can also integrate the Binutils and Newlib builds by symlinking their files into the GCC source directory. I'd always start with the GCC directory; it contains the latest version of the Sourceware build system (don't overwrite any files which exist). I believe you can also do the same with GDB.
Haroogan
Member
Member
Posts: 28
Joined: Thu Aug 04, 2011 1:10 pm

Re: Executing C Kernel #101

Post by Haroogan »

Phew, I finally made it :D :

Image

So the Cross Compiler is up and running for "i386-elf" as you can see. I could contribute with the tutorial on how to build Cross Compiler under Windows with MinGW if that's needed.

Big thanks for XenOS's tips!
User avatar
xenos
Member
Member
Posts: 1121
Joined: Thu Aug 11, 2005 11:00 pm
Libera.chat IRC: xenos1984
Location: Tartu, Estonia
Contact:

Re: Executing C Kernel #101

Post by xenos »

Congratulations! And have fun with your cross compiler :)
Programmers' Hardware Database // GitHub user: xenos1984; OS project: NOS
Haroogan
Member
Member
Posts: 28
Joined: Thu Aug 04, 2011 1:10 pm

Re: Executing C Kernel #101

Post by Haroogan »

Congratulations! And have fun with your cross compiler :)
TY mate :wink:

Code: Select all

    .bss: {
        sbss = .;
        *(COMMON)
        *(.bss)
        ebss = .;
    }
What are "sbss = ." and "ebss = ."? Something like start - end? I can't find proper explanation in manuals.
Post Reply