OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 2:03 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 12 posts ] 
Author Message
 Post subject: SOLVED: Building a GCC 11.2.0 Cross Compiler
PostPosted: Sat Apr 23, 2022 3:55 pm 
Offline
Member
Member

Joined: Mon Aug 27, 2018 12:50 pm
Posts: 54
Hello,

I'm currently trying to build a toolchain for my OS, and I've got stuck while compiling GCC. I've already got a i686-elf GCC working, and I've got binutils compiled to target my OS.
The issue, however, is when I compile GCC. I get:
Code:
gcc-11.2.0/gcc/configure: line 4543: syntax error near unexpected token `-I"$srcdir"/ada/libgnat'
which causes make all-gcc to fail.

There are also some warnings earlier:
Code:
gcc-11.2.0/gcc/configure: line 3070: ACX_NONCANONICAL_HOST: command not found
gcc-11.2.0/gcc/configure: line 3073: ACX_NONCANONICAL_TARGET: command not found
gcc-11.2.0/gcc/configure: line 3080: GCC_TOPLEV_SUBDIRS: command not found

I'm configuring like this:
Code:
../gcc-11.2.0/configure --target=$TARGET --prefix="$PREFIX" --with-sysroot=$SYSROOT --disable-nls --enable-languages=c
and that runs without errors.

Has anyone built GCC 11.2.0 to target their OS, and had similar problems? What was the solution?
Am I just missing some dependency, or forgot to do an autoconf somewhere?

The wiki article for this topic is pretty outdated (it targets GCC 7.2.0), so I'll probably update that afterwards, if I can get 11.2.0 to build.

Thanks,
Barry


Last edited by Barry on Tue Apr 26, 2022 7:30 pm, edited 3 times in total.

Top
 Profile  
 
 Post subject: Re: Building a GCC 11.2.0 Cross Compiler
PostPosted: Sat Apr 23, 2022 4:17 pm 
Offline
Member
Member

Joined: Mon Aug 27, 2018 12:50 pm
Posts: 54
UPDATE:

I've just spotted this in the configure output:
Code:
*** This configuration is not supported in the following subdirectories:
     target-libgomp target-libatomic target-libitm target-libsanitizer target-libvtv target-libphobos gnattools gotools target-libada target-libhsail-rt target-libstdc++-v3 target-zlib target-libbacktrace target-libgfortran target-libgo target-libffi target-libobjc target-liboffloadmic
    (Any other directories should still work fine.)
I'm looking into it further, but I think I haven't set up these directories to target my OS, so they can't be built with the TARGET I specified.

If anyone knows how to configure these, I'd appreciate if you could give me some advice.
Otherwise, I'm going to keep trying, and I'll update the wiki page when I figure it out.


Top
 Profile  
 
 Post subject: Re: Building a GCC 11.2.0 Cross Compiler
PostPosted: Sat Apr 23, 2022 8:43 pm 
Offline
Member
Member

Joined: Mon Aug 27, 2018 12:50 pm
Posts: 54
FINAL UPDATE:

I fixed the issue.
I got a clean copy of the binutils & gcc source code, patched them again, and compiled and it worked. I also had a few things missing from my libc headers. I'll probably add those to the wiki article too when I've confirmed my build is fully functional.

Thanks,
Barry


Top
 Profile  
 
 Post subject: Re: Building a GCC 11.2.0 Cross Compiler
PostPosted: Sat Apr 23, 2022 9:51 pm 
Offline
Member
Member

Joined: Mon Jul 05, 2021 6:57 pm
Posts: 118
Just FYI GCC 11.3 has been released so you might want to consider using that instead. It has a ton of bug-fixes over 11.2.


Top
 Profile  
 
 Post subject: Re: Building a GCC 11.2.0 Cross Compiler
PostPosted: Sun Apr 24, 2022 11:08 am 
Offline
Member
Member

Joined: Mon Aug 27, 2018 12:50 pm
Posts: 54
Ah thanks, I'll go ahead and try to build that today. Any idea which version of binutils will be compatible? I assume probably the latest one too.

I have one slight issue with my current build: GCC doesn't seem to be providing stdint.h. My gcc-11.2.0/gcc/config.gcc has a line for my target with use_gcc_stdint=wrap. But when I compile GCC I can't #include <stdint.h> in any of my source files, it's a missing header. I can make it myself in my include dir, but then I won't have any of the types. This actually caused an issue when building libgcc because it couldn't find intptr_t. To get the build to complete I just defined it as an int in my sys/types.h header, but I'm not a big fan of this sort of work around.
Any idea why GCC isn't providing stdint.h?

Once I've got 11.3.0 built successfully, I'll update the wiki.

Thanks,
Barry


Top
 Profile  
 
 Post subject: Re: Building a GCC 11.2.0 Cross Compiler
PostPosted: Sun Apr 24, 2022 11:23 am 
Offline
Member
Member

Joined: Mon Feb 02, 2015 7:11 pm
Posts: 898
You probably don't want to use_gcc_stdint=wrap. This is telling that you want GCC's version of stdint.h to be a wrapper around your existing one. But you don't have one, so it doesn't work.

Let GCC provide stdint.h for you (use_gcc_stdint=provide) and you should be good.

_________________
https://github.com/kiznit/rainbow-os


Top
 Profile  
 
 Post subject: Re: Building a GCC 11.2.0 Cross Compiler
PostPosted: Sun Apr 24, 2022 11:40 am 
Offline
Member
Member

Joined: Mon Aug 27, 2018 12:50 pm
Posts: 54
Thanks,

I actually had this thought, and I do have a blank version of stdint.h in my include dir, but still not much luck.
I'll just switch to provide, as it'll almost certainly cover my use-case.

Thanks for that,
Barry


Top
 Profile  
 
 Post subject: Re: Building a GCC 11.2.0 Cross Compiler
PostPosted: Sun Apr 24, 2022 11:56 am 
Offline
Member
Member

Joined: Mon Aug 27, 2018 12:50 pm
Posts: 54
Well, that fixed the #include <stdint.h> issue, but libgcc is still complaining about intptr_t not being declared/defined.
This seems like something that it should have defined by itself, and it even says
Code:
gcc-11.3.0/libgcc/libgcov.h:186:1: note: 'intptr_t' is defined in header '<stdint.h>'; did you forget to '#include <stdint.h>'?
But I have to define it manually in my headers to get the build to finish. :?
Any ideas?


Top
 Profile  
 
 Post subject: Re: Building a GCC 11.2.0 Cross Compiler
PostPosted: Sun Apr 24, 2022 12:03 pm 
Offline
Member
Member

Joined: Mon Feb 02, 2015 7:11 pm
Posts: 898
You could go back to the wrapper if you wanted to... But your own version of stdint.h can't be blank, it needs to define everything that needs to be defined. Using the wrapper means that GCC won't define anything and it's up to you to do so.

As to why GCC is not defining intptr_t in it's own stdint.h, I have no idea. Have you looked what's in that file to see if there is any clue?

_________________
https://github.com/kiznit/rainbow-os


Top
 Profile  
 
 Post subject: Re: Building a GCC 11.2.0 Cross Compiler
PostPosted: Sun Apr 24, 2022 12:32 pm 
Offline
Member
Member

Joined: Mon Aug 27, 2018 12:50 pm
Posts: 54
Question: If GCC provides stdint.h for me when it's built, how can I compile binutils (which requires stdint.h) before GCC has provided the header, or compile GCC before it provides the header?
I think there's a bit of a bootstrapping issue here, and I don't know how I got into this situation.
I'm tempted to try building binutils/GCC on a completely fresh install.


Top
 Profile  
 
 Post subject: Re: Building a GCC 11.2.0 Cross Compiler
PostPosted: Sun Apr 24, 2022 12:47 pm 
Offline
Member
Member

Joined: Wed Aug 30, 2017 8:24 am
Posts: 1593
Barry wrote:
Question: If GCC provides stdint.h for me when it's built, how can I compile binutils (which requires stdint.h) before GCC has provided the header, or compile GCC before it provides the header?
You compile binutils with the host compiler. It does not require the target's stdint.h.

_________________
Carpe diem!


Top
 Profile  
 
 Post subject: Re: Building a GCC 11.2.0 Cross Compiler
PostPosted: Sun Apr 24, 2022 12:54 pm 
Offline
Member
Member

Joined: Mon Aug 27, 2018 12:50 pm
Posts: 54
Yeah, this makes sense. I've been investigating further, and it appears that the stdint.h error is actually caused by my linux install not having the right headers. I might have to do a fresh install to get this to work. I can't even compile the latest GCC to target my host system, so it's definitely a system error.
Sorry for how long this has been drawn-out.


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

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 64 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