OS - Cross Compiler - Assembly
-
- Posts: 17
- Joined: Sun Aug 21, 2016 10:18 am
- Libera.chat IRC: Chpetrou
- Location: Cyprus, Greece
- Contact:
OS - Cross Compiler - Assembly
Hello
I want to learn how to create my own Operating System and i saw the bare bones guide, and it was required to build your own GCC Cross Compiler, but the instructions on http://wiki.osdev.org/GCC_Cross-Compiler aren't so clear for me and i can't make it work.
I have a Mac - OS X and have installed the GCC and the other software required through homebrew. I also know the basics of C, C++, Java and 5 other languages and i know Java, C++ at a more advanced level. I am also trying to learn Assembly with nasm and i think i know most of the Computer Theory.
Can you help me?
Also is this (bare bones) the best way to learn how to create a functional OS from scratch?
Also do you know a good way to learn Assembly, because i can't find very much resources to solve my questions?
Thanks in advance
I want to learn how to create my own Operating System and i saw the bare bones guide, and it was required to build your own GCC Cross Compiler, but the instructions on http://wiki.osdev.org/GCC_Cross-Compiler aren't so clear for me and i can't make it work.
I have a Mac - OS X and have installed the GCC and the other software required through homebrew. I also know the basics of C, C++, Java and 5 other languages and i know Java, C++ at a more advanced level. I am also trying to learn Assembly with nasm and i think i know most of the Computer Theory.
Can you help me?
Also is this (bare bones) the best way to learn how to create a functional OS from scratch?
Also do you know a good way to learn Assembly, because i can't find very much resources to solve my questions?
Thanks in advance
- max
- Member
- Posts: 616
- Joined: Mon Mar 05, 2012 11:23 am
- Libera.chat IRC: maxdev
- Location: Germany
- Contact:
Re: OS - Cross Compiler - Assembly
Hey,
welcome to the forum!
Greets
welcome to the forum!
What is unclear? What did you try and where did you fail?Chpetrou wrote:[...] the instructions on http://wiki.osdev.org/GCC_Cross-Compiler aren't so clear for me and i can't make it work. [...] Can you help me?
There's no "best way", and it's a long way to have something functional. But it's a good starting point.Chpetrou wrote:Also is this (bare bones) the best way to learn how to create a functional OS from scratch?
Use Google.Chpetrou wrote:Also do you know a good way to learn Assembly, because i can't find very much resources to solve my questions?
Greets
-
- Posts: 17
- Joined: Sun Aug 21, 2016 10:18 am
- Libera.chat IRC: Chpetrou
- Location: Cyprus, Greece
- Contact:
Re: OS - Cross Compiler - Assembly
Hello
Generally i get confused with the instructions of how to make the i686-elf cross compiler. I tried
and it doesn't work because i don't have a $HOME/src (so I created an src directory in the usr/local) and i don't can't make to work because i don't know what it is (i don't understand the "../binutils-x.y.z/configure" part).
Also doing the steps above this is the same by installing the required software through homebrew right? or do i have to do something else before?
Generally i get confused with the instructions of how to make the i686-elf cross compiler. I tried
Code: Select all
cd $HOME/src
mkdir build-binutils
cd build-binutils
../binutils-x.y.z/configure --target=$TARGET --prefix="$PREFIX" --with-sysroot --disable-nls --disable-werror
make
make install
Code: Select all
../binutils-x.y.z/configure --target=$TARGET --prefix="$PREFIX" --with-sysroot --disable-nls --disable-werror
Also doing the steps above this is the same by installing the required software through homebrew right? or do i have to do something else before?
Re: OS - Cross Compiler - Assembly
binutils-x.y.z is the source directory you've unpacked.
"If you don't fail at least 90 percent of the time, you're not aiming high enough."
- Alan Kay
- Alan Kay
-
- Posts: 17
- Joined: Sun Aug 21, 2016 10:18 am
- Libera.chat IRC: Chpetrou
- Location: Cyprus, Greece
- Contact:
Re: OS - Cross Compiler - Assembly
What do you mean by "source directory you've unpacked"?
I installed the software through homebrew. Should i have done it differently?
I installed the software through homebrew. Should i have done it differently?
Re: OS - Cross Compiler - Assembly
What and how you installed via Homebrew?
"If you don't fail at least 90 percent of the time, you're not aiming high enough."
- Alan Kay
- Alan Kay
-
- Posts: 17
- Joined: Sun Aug 21, 2016 10:18 am
- Libera.chat IRC: Chpetrou
- Location: Cyprus, Greece
- Contact:
Re: OS - Cross Compiler - Assembly
I wrote in the Terminal
and it installed the latest gcc, gmp, gpfr, isl, mpc, textinfo and also installed binutils, libiconv and xcode clt
Code: Select all
brew install gcc
Re: OS - Cross Compiler - Assembly
I'm not convinced that you understand why you should install a cross-compiler. Two important reasons are:
1. You want to generate code for your target processor. This may not be the same processor that your computer uses. For example, OS X uses the x86_64 processor, whereas you probably want to generate code for the 32-bit x86 processor. The compiler you have installed will be aimed at producing 64-bit programs.
2. You want to generate code that does not rely upon the OS running on your development computer.
The compiler that you have installed does not satisfy either of these conditions. The instructions on the Wiki only mention using homebrew if you are running OS X 10.7 or earlier. Is that your situation?
Read the instructions again carefully and follow them exactly.
1. You want to generate code for your target processor. This may not be the same processor that your computer uses. For example, OS X uses the x86_64 processor, whereas you probably want to generate code for the 32-bit x86 processor. The compiler you have installed will be aimed at producing 64-bit programs.
2. You want to generate code that does not rely upon the OS running on your development computer.
The compiler that you have installed does not satisfy either of these conditions. The instructions on the Wiki only mention using homebrew if you are running OS X 10.7 or earlier. Is that your situation?
Read the instructions again carefully and follow them exactly.
Re: OS - Cross Compiler - Assembly
Just replace x.y.z with your version numbers.
OS: Basic OS
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
-
- Posts: 17
- Joined: Sun Aug 21, 2016 10:18 am
- Libera.chat IRC: Chpetrou
- Location: Cyprus, Greece
- Contact:
Re: OS - Cross Compiler - Assembly
1. Isn't the GCC installed from homebrew the same as downloading from its official website? Can't we build the gcc installed from homebrew to a 32 bit one ? with the instruction? I mean, Build (ex. a program), is to take the source code and compile it with our processor to create an executable file that we can use, but that doesn't make the executable run only on the same processor architecture that was compiled?
2. So if i have understood well, up to the preparing for the build section, i only have to download the required software from the pages given? I have downloaded the software, extracted it from the .tar.bz2 and now i have the folders with the files inside, in my documents folder.
Also do i need to do these: because they don't work because of "../binutils-2.24/configure"
But on the Build section, i do successfully but on the
it doesn't accept it. Even if i write the version in "binutils-x.y.z", it says there is no such directory "../binutils-x.y.z/configure"
Is ".." like cd .. that takes you backwords? or it is the folder that the binutils-x.y.z is inside?
i tried it also from the binutils folder.
Also there is no "configure" in the folder.
Sorry for not understanding, i have a difficulty at understanding things that are not too explained for me. I work better with videos and pictures but there are not usually videos and pictures for such things.
Code: Select all
export TARGET=i686-elf
2. So if i have understood well, up to the preparing for the build section, i only have to download the required software from the pages given? I have downloaded the software, extracted it from the .tar.bz2 and now i have the folders with the files inside, in my documents folder.
Also do i need to do these:
Code: Select all
../binutils-2.24/configure --prefix=$PREFIX \
--target=$TARGET \
--enable-interwork --enable-multilib \
--disable-nls --disable-werror
../gcc-4.8.3/configure --prefix=$PREFIX \
--target=$TARGET \
--disable-nls \
--enable-languages=c,c++ --without-headers \
--enable-interwork --enable-multilib \
--with-gmp=/usr --with-mpc=/opt/local --with-mpfr=/opt/local
But on the Build section, i do
Code: Select all
export PREFIX="$HOME/opt/cross"
export TARGET=i686-elf
export PATH="$PREFIX/bin:$PATH"
Code: Select all
cd $HOME/src
mkdir build-binutils
cd build-binutils
../binutils-x.y.z/configure --target=$TARGET --prefix="$PREFIX" --with-sysroot --disable-nls --disable-werror
make
make install
Is ".." like cd .. that takes you backwords? or it is the folder that the binutils-x.y.z is inside?
i tried it also from the binutils folder.
Also there is no "configure" in the folder.
Sorry for not understanding, i have a difficulty at understanding things that are not too explained for me. I work better with videos and pictures but there are not usually videos and pictures for such things.
Re: OS - Cross Compiler - Assembly
No.Isn't the GCC installed from homebrew the same as downloading from its official website?
Code: Select all
$ /usr/local/bin/gcc-4.9 -dumpmachine
x86_64-apple-darwin16.0.0
$ x86_64-w64-mingw32-gcc -dumpmachine
x86_64-w64-mingw32
$ arm-none-eabi-gcc -dumpmachine
arm-none-eabi
"If you don't fail at least 90 percent of the time, you're not aiming high enough."
- Alan Kay
- Alan Kay
Re: OS - Cross Compiler - Assembly
I fear that if you are at the point where you are not sure what '..' means you may not be ready to write an operating system.
If a trainstation is where trains stop, what is a workstation ?
-
- Posts: 17
- Joined: Sun Aug 21, 2016 10:18 am
- Libera.chat IRC: Chpetrou
- Location: Cyprus, Greece
- Contact:
Re: OS - Cross Compiler - Assembly
I though about these in a different way and tried a few things and i found it, and i made it work.
Thanks for all the answers.
Thanks for all the answers.
- Schol-R-LEA
- Member
- Posts: 1925
- Joined: Fri Oct 27, 2006 9:42 am
- Location: Athens, GA, USA
Re: OS - Cross Compiler - Assembly
I realize that you said you have solved the issues, but I did want to explain two things you seemed unclear on.
First, the '.' and '..' entries in the directory are hidden hard links to the directory itself ('.') and its parent directory ('..'). They are actual directory entries automatically inserted into every Unix directory when it is created, as can be seen if you do a directory listing with the display hidden files option ('-a', for 'all'):
Second, $HOME is a common (but not quite universal) environment variable usually set in most Bourne-Again Shell (bash, which is a modified version of the original Bourne Shell, sh) environments in the .bashrc and/or .bash-profile scripts; Bourne-style environment variables start with a dollar sign, and are by convention written in ALL-CAPS. The usual practice is for $HOME to be an alias for the user's home directory, equivalent to '~', so if your user name is 'joeblow', then
would in most cases go to the same directory path.
Now the tutorial is written with the assumption that you are using Bash, because that's the most widely used shell in the Linux world and the default for Debian (and derivatives like Ubuntu, Mint, etc.), Gentoo, and several others, including recent versions of Mac OS X - though earlier versions (Tiger and before) used tsch instead, and I'm pretty sure both tsch, zsh, Korn Shell (ksh) are still installed by default if you want to change it. You really need to learn Bash (and Unix in general) to use the tutorial effectively, but tutorials on Bash are easy enough to come by, even if they aren't all necessarily all that good.
On the subject of tutorials, you have to also keep in mind that the Bare Bones tutorials are not intended to give you a full system, or even a working one; they are a starting point for understanding what's involved. No tutorial out there explains how to actually write an operating system, and none ever could.
First, the '.' and '..' entries in the directory are hidden hard links to the directory itself ('.') and its parent directory ('..'). They are actual directory entries automatically inserted into every Unix directory when it is created, as can be seen if you do a directory listing with the display hidden files option ('-a', for 'all'):
Code: Select all
ls -a
Code: Select all
cd ~
cd $HOME
cd /home/joeblow
Now the tutorial is written with the assumption that you are using Bash, because that's the most widely used shell in the Linux world and the default for Debian (and derivatives like Ubuntu, Mint, etc.), Gentoo, and several others, including recent versions of Mac OS X - though earlier versions (Tiger and before) used tsch instead, and I'm pretty sure both tsch, zsh, Korn Shell (ksh) are still installed by default if you want to change it. You really need to learn Bash (and Unix in general) to use the tutorial effectively, but tutorials on Bash are easy enough to come by, even if they aren't all necessarily all that good.
On the subject of tutorials, you have to also keep in mind that the Bare Bones tutorials are not intended to give you a full system, or even a working one; they are a starting point for understanding what's involved. No tutorial out there explains how to actually write an operating system, and none ever could.
Rev. First Speaker Schol-R-LEA;2 LCF ELF JAM POEE KoR KCO PPWMTF
Ordo OS Project
Lisp programmers tend to seem very odd to outsiders, just like anyone else who has had a religious experience they can't quite explain to others.
Ordo OS Project
Lisp programmers tend to seem very odd to outsiders, just like anyone else who has had a religious experience they can't quite explain to others.