OSDev.org

The Place to Start for Operating System Developers
It is currently Tue Apr 16, 2024 12:51 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: Problem creating my own Hosted GCC Cross Compiler
PostPosted: Wed Apr 18, 2018 3:28 pm 
Offline
Member
Member

Joined: Tue Oct 29, 2013 1:13 pm
Posts: 207
Hi,

I was trying to create my own Hosted GCC Cross Compiler, and I followed the following tutorials on OSDev:

https://wiki.osdev.org/OS_Specific_Toolchain
https://wiki.osdev.org/Hosted_GCC_Cross-Compiler

I reviewed the steps many times but there must be something that I did wrong.

I used binutils-2.30 and gcc-7.3.0, and my OS name is nuos, so I substituted all "myos" with "nuos" in the above two tutorials.

I have created my sysroot under $HOME/nuos/sysroot/, and under that I created "usr/include/" and I stored the header files from the git repo mentioned in
https://wiki.osdev.org/Hosted_GCC_Cross-Compiler : errno.h, stdio.h, stdlib.h, string.h, time.h, unistd.h, sys/types.h

The binutils compile and install successfully.

In case of GCC I use the following commands:
Code:
mkdir build-gcc
cd build-gcc
../gcc-7.3.0-nuos/configure --target=x86_64-nuos --prefix="$PREFIX" --with-sysroot=$HOME/nuos/sysroot --enable-languages=c,c++
make all-gcc
make all-target-libgcc


After some compilation processing of the last command "make all-target-libgcc", I got the following error:

Code:
checking for special C compiler options needed for large files... no
checking for _FILE_OFFSET_BITS value needed for large files... unknown
checking for _LARGE_FILES value needed for large files... unknown
checking size of double... 8
checking size of long double... 16
checking for inttypes.h... no
checking for stdint.h... no
checking for stdlib.h... yes
checking for ftw.h... no
checking for unistd.h... yes
checking for sys/stat.h... no
checking for sys/types.h... yes
checking for string.h... yes
checking for strings.h... no
checking for memory.h... no
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for ANSI C header files... no
checking whether decimal floating point is supported... no
configure: WARNING: decimal float is not supported for this target, ignored
checking whether fixed-point is supported... no
checking whether the compiler is configured for setjmp/longjmp exceptions... no
checking if the linker (/home/..../crossenv/src/build-gcc/./gcc/collect-ld) is GNU ld... yes
checking for thread model used by GCC... single
checking whether assembler supports CFI directives... yes
checking for target glibc version... 0.0
*** Configuration x86_64-pc-nuos not supported
Makefile:13391: recipe for target 'configure-target-libgcc' failed
make: *** [configure-target-libgcc] Error 1



Note: I was able to build a cross compiler from the same sources following https://wiki.osdev.org/GCC_Cross-Compiler.

I appreciate If anyone went through this problem or know how to fix that can help.

Thanks,
Karim.


Top
 Profile  
 
 Post subject: Re: Problem creating my own Hosted GCC Cross Compiler
PostPosted: Wed Apr 18, 2018 3:44 pm 
Offline
Member
Member

Joined: Sat Oct 16, 2010 3:38 pm
Posts: 587
It sounds like you forgot to add your OS to the list in "config.sub", near "First accept the basic system types..."


Top
 Profile  
 
 Post subject: Re: Problem creating my own Hosted GCC Cross Compiler
PostPosted: Thu Apr 19, 2018 10:24 am 
Offline
Member
Member

Joined: Tue Oct 29, 2013 1:13 pm
Posts: 207
Hi,

No I did, here:

Code:
   # First accept the basic system types.
   # The portable systems comes first.
   # Each alternative MUST END IN A *, to match a version number.
   # -sysv* is not here because it comes later, after sysvr4.
   -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \
         | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\
         | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \
         | -sym* | -kopensolaris* | -plan9* \
         | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
         | -aos* | -aros* | -cloudabi* | -sortix* \
         | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
         | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
         | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \
         | -bitrig* | -openbsd* | -solidbsd* | -libertybsd* \
         | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \
         | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
         | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
         | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
         | -chorusos* | -chorusrdb* | -cegcc* | -glidix* \
         | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
         | -midipix* | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \
         | -linux-newlib* | -linux-musl* | -linux-uclibc* \
         | -uxpv* | -beos* | -mpeix* | -udk* | -moxiebox* \
         | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
         | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
         | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \
         | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \
         | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \
         | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \
         | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es* \
         | -onefs* | -tirtos* | -phoenix* | -fuchsia* | -redox* | -nuos*)


I have done that to all config.sub as well (gmp, isl, mpfr).
It must be something else.

Thanks,
Karim.


Top
 Profile  
 
 Post subject: Re: Problem creating my own Hosted GCC Cross Compiler
PostPosted: Thu Apr 19, 2018 11:58 am 
Offline
Member
Member

Joined: Tue Oct 29, 2013 1:13 pm
Posts: 207
Hi,

I digged a little bit and looked at found ./x86_64-nuos/libgcc/config.log and here is the part indicating the error:

Code:
configure:4929:  /home/kmsobh/crossenv/src/build-gcc/./gcc/xgcc -B/home/kmsobh/crossenv/src/build-gcc/./gcc/ -B/home/kmsobh/crossenv/x86_64-nuos/bin/ -B/home/kmsobh/crossenv/x86_64-nuos/lib/ -isystem /home/kmsobh/crossenv/x86_64-nuos/include -isystem /home/kmsobh/crossenv/x86_64-nuos/sys-include    -c -g -O2  conftest.c >&5
conftest.c:16:10: fatal error: features.h: No such file or directory
#include <features.h>
          ^~~~~~~~~~~~
compilation terminated.
configure:4929: $? = 1
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME "GNU C Runtime Library"
| #define PACKAGE_TARNAME "libgcc"
| #define PACKAGE_VERSION "1.0"
| #define PACKAGE_STRING "GNU C Runtime Library 1.0"
| #define PACKAGE_BUGREPORT ""
| #define PACKAGE_URL "http://www.gnu.org/software/libgcc/"
| #define SIZEOF_DOUBLE 8
| #define SIZEOF_LONG_DOUBLE 16
| #define HAVE_STDLIB_H 1
| #define HAVE_UNISTD_H 1
| #define HAVE_SYS_TYPES_H 1
| #define HAVE_STRING_H 1
| #define HAVE_GETIPINFO 1
| /* end confdefs.h.  */
| #include <features.h>
| int
| main ()
| {
| static int test_array [1 - 2 * !((__GLIBC_MINOR__) < 0)];
| test_array [0] = 0
|
|   ;
|   return 0;
| }
configure:4937: result: 0.0


features.h is not one of the files included in https://wiki.osdev.org/Hosted_GCC_Cross-Compiler in the git folder https://gist.github.com/sortie/9a64aa53 ... 324a75b474 that has the libc stub header files.

As you can see from the error, obviously the configuration process assumes that I use GLIBC, and the whole reason that I am following these tutorials is to be able to get a toolchain specific compiler for my kernel and to build incrementally my libc from scratch. I know that I can use glibc but I am doing this for learning purpose so I would like to do the whole thing from scratch.

Basically, I have my kernel up and running with complete system call infrastructure for I/O and interrupt handling, simple memory and process management, and simple read-only file system, but all my user-space programs are compiled statically outside my OS using the cross compiler without any support of any libc. What I am trying to do is to be able to compile UNIX-complaint user-space programs for my OS that can invoke my own libc (which I will build incrementally) and issue system calls from within, and of course I know that I will need to write some elf loader to be able to run my program.

Now how can I tell the toolchain specific compiler that I am not using glibc and that I will be using my own?

Thanks,
Karim.


Top
 Profile  
 
 Post subject: Re: Problem creating my own Hosted GCC Cross Compiler
PostPosted: Fri Apr 20, 2018 1:38 pm 
Offline
Member
Member

Joined: Fri Aug 19, 2016 10:28 pm
Posts: 360
The instructions on the wiki may be outdated, although I cannot say what amount of additional configuration is necessary.

The check in the configure script was apparently introduced in the gcc source trunk about 3 years ago in a rather unrelated attempt to introduce functionality. Now gcc checks for the libc version. There appear to be two ways to handle this, speaking just out of common sense. One is to add a bare-bones features.h to your libc includes and it must contain at least the __GLIBC__ and __GLIBC_MINOR__ macros, to define the supported functionally equivalent version of your library - major and minor number correspondingly. It must end up in sysroot/usr/include. Another is to pass the --with-glibc-version=major.minor configure parameter, which will force-skip those checks.

For reference - here is the revision which introduces the check.
And here is the version definition in features.h from glibc (which, of course you can find on your machine.)


Top
 Profile  
 
 Post subject: Re: Problem creating my own Hosted GCC Cross Compiler
PostPosted: Mon Apr 23, 2018 7:30 am 
Offline
Member
Member

Joined: Tue Oct 29, 2013 1:13 pm
Posts: 207
Thanks a lot for your reply.

The new GCC (>=7) configuration is a little bit different and I have updated the libgcc/config.host in the wrong place.

I have fixed that and now it is working.

Thanks a lot,
Karim.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: 0xY, DotBot [Bot] and 70 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group