OSDev.org
https://forum.osdev.org/

Cross compiler step one`
https://forum.osdev.org/viewtopic.php?f=8&t=31327
Page 1 of 2

Author:  billcu [ Tue Jan 31, 2017 1:58 pm ]
Post subject:  Cross compiler step one`

I am still a little confused on what gcc or binutils compilation options to build for the i686-elf target. I have 6.3 gcc and 2.27 binutils and I think they're the latest. I am in a linux x64 enviornment but bare bones wants i686-elf. I am considering,

--enable-multilib, i686-elf --disable-nls --without-headers

Now do I need -ffreestanding ?

I am not sure what that's for.

Author:  ndke [ Tue Jan 31, 2017 3:02 pm ]
Post subject:  Re: Cross compiler step one`

If you are building a crosscompiler for your kernel, you are not providing a standard C library and you are also not providing include headers (as you can see in your configure command). So you don't need to provide -ffreestanding.

Author:  billcu [ Tue Jan 31, 2017 3:10 pm ]
Post subject:  Re: Cross compiler step one`

ndke wrote:
If you are building a crosscompiler for your kernel, you are not providing a standard C library and you are also not providing include headers (as you can see in your configure command). So you don't need to provide -ffreestanding.


Ok so not providing the C library is what I want to do. What about this libgcc library. It's not a standard C library but you don't want it for kernel creation either do you?

Author:  dchapiesky [ Tue Jan 31, 2017 3:12 pm ]
Post subject:  Re: Cross compiler step one`

x86_64 kernel - don't forget

Code:
-mno-red-zone


libgcc multilib --- http://wiki.osdev.org/Libgcc_without_red_zone

libgcc is almost required for kernel depending on what code you write... http://wiki.osdev.org/Libgcc

In my case, it was preferable to go the full distance for a full cross compiler with sysroot

http://wiki.osdev.org/OS_Specific_Toolchain

It worth learning the options for configuring binutils and gcc

Author:  billcu [ Tue Jan 31, 2017 3:24 pm ]
Post subject:  Re: Cross compiler step one`

dchapiesky wrote:
x86_64 kernel - don't forget

Code:
-mno-red-zone


libgcc multilib --- http://wiki.osdev.org/Libgcc_without_red_zone

libgcc is almost required for kernel depending on what code you write... http://wiki.osdev.org/Libgcc

In my case, it was preferable to go the full distance for a full cross compiler with sysroot

http://wiki.osdev.org/OS_Specific_Toolchain

It worth learning the options for configuring binutils and gcc


What do you mean "x86_64 kernel..." That is my host environment yeah but I want to build a 32 bit kernel for a 32 bit OS.

Author:  dchapiesky [ Tue Jan 31, 2017 3:31 pm ]
Post subject:  Re: Cross compiler step one`

sorry - missed i686 -- but still full os specific compiler is worth it

Author:  FallenAvatar [ Tue Jan 31, 2017 10:27 pm ]
Post subject:  Re: Cross compiler step one`

Are you building a cross compiler to build your kernel? In which case see http://wiki.osdev.org/GCC_Cross-Compiler
If you are trying to build (on your host platform) a compiler that will compile programs to run on your OS, see http://wiki.osdev.org/OS_Specific_Toolchain

- Monk

Author:  ~ [ Thu Feb 02, 2017 2:55 pm ]
Post subject:  Re: Cross compiler step one`

I made a video that shows how to compile a cross compiler for your custom OS kernel step by step.

If you watch it and repeat everything you see done to make the compile, or if you watch it and then repeat, then you will be able to understand how to build your cross compiler:

OSDev.org Tutorial: Build an i686-elf Cross Compiler under 64-bit Ubuntu Desktop 16.04.1

Author:  dchapiesky [ Thu Feb 02, 2017 3:57 pm ]
Post subject:  Re: Cross compiler step one`

~ wrote:
I made a video that shows how to compile a cross compiler for your custom OS kernel step by step.



4 hours 51 minutes... sounds about right... will let play while I work.... can we get a transcript :wink:

either way your effort is acknowledged and appreciated.... =D>

Now start work on x86_64, arm, ppc, sparc, and z80....

Author:  Solar [ Mon Feb 06, 2017 2:23 am ]
Post subject:  Re: Cross compiler step one`

~ wrote:
I made a video...


...of written and annotated instructions, where people get explanations of every twist and turn involved in the process, and turned it into a five-hour video of "watch the compiler output"?

Unedited?

#-o

Author:  dozniak [ Mon Feb 06, 2017 4:22 am ]
Post subject:  Re: Cross compiler step one`

Solar wrote:
and turned it into a five-hour video of "watch the compiler output"?


Well, it's probably too slow machine; usually compiling full gnu toolchain fits into 1 hour, compiling LLVM into 1 hour and then some.

Author:  dchapiesky [ Mon Feb 06, 2017 7:54 am ]
Post subject:  Re: Cross compiler step one`

3.2ghz 2 core I3 with hyperthreading does a gcc 6.3 bootstrap compiler/cross compiler/newlib/cross compiler w/sysroot in 25 minutes....

Author:  matt11235 [ Mon Feb 06, 2017 10:16 am ]
Post subject:  Re: Cross compiler step one`

dchapiesky wrote:
3.2ghz 2 core I3 with hyperthreading does a gcc 6.3 bootstrap compiler/cross compiler/newlib/cross compiler w/sysroot in 25 minutes....
I'm sure it should be faster than that? Are you passing j4 or j5 to make?

Author:  billcu [ Mon Feb 06, 2017 11:37 am ]
Post subject:  Re: Cross compiler step one`

Well the makefile broke on me. I am using gcc-6.0.3. I build with my compiler this "isl" library, gmp, mpc, mpfr that gcc needs. The binaries I put together in a directory called 'build'. With the compiler it said no linking allowed after GCC_NO_EXECUTABLES so what's that mean. Is there a linker switch somewhere that needs turned off? I compiled with the 'configure' script these options,

--with-gmp=
--with-isl=
--with=mpc=
--with-mpfr=

To tell the compiler where they are. I also used,

--enable-languages=c --enable-multilib --without-headers --prefix=/mnt --disable-nls i686-elf

What have I left out or do I need?

Author:  Schol-R-LEA [ Mon Feb 06, 2017 11:59 am ]
Post subject:  Re: Cross compiler step one`

Let's dig a bit deeper here. Please start by telling us the development host environment - you have mentioned that it is an x86-64 CPU, but not the OS it is running under. If you could also post (or link to a repo of) the makefile and linker script, that would help as well.

Mind you, I mean the makefile and linker script for the cross-compiler build, not the one you would use for building the OS image from the cross-compiler. I have this suspicion that there is a bit of confusion there, in that it sounds as if your makefile is set to build an ELF32 file for the cross-compiler, which would not be the correct course of action if it is hosted on a 64-bit OS (and especially so if it is a host OS that doesn't use ELF as its executable format, such as Windows or MacOS). The cross-compiler might be set to target a 32-bit ELF, but the cross-compiler itself would run in the native executable format and bit width of the development host.

Page 1 of 2 All times are UTC - 6 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/