OSDev.org

The Place to Start for Operating System Developers
It is currently Wed Apr 24, 2024 3:10 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 12 posts ] 
Author Message
 Post subject: Toolchain Issues - GCC 9.2.1 & Binutils 2.33.1
PostPosted: Tue Dec 03, 2019 3:18 am 
Offline
Member
Member
User avatar

Joined: Sat Mar 22, 2014 1:14 pm
Posts: 65
Location: /bin
Hello everyone,

I tried to upgrade my toolchain to use GCC 9.2.1 & Binutils 2.33.1 (mainly due to GCC requiring autoconf 2.64 to build, which the distro I use upgraded to 2.69), and although the executables build as expected, compiling anything with the toolchain yields the following:

Code:
/tmp/cc6Hmkvc.s: Assembler messages:
/tmp/cc6Hmkvc.s:26: Error: invalid instruction suffix for `push'
.
.
.
/tmp/cc6Hmkvc.s:200: Error: invalid instruction suffix for `push'


If I understand the error message correctly, I have 32bit capable Binutils but GCC is producing 64bit assemblies, which of course is not going to work. However, my GCC compilation method is the same I was using for 8.3.0, which worked as expected.

Did something major change in 9.x, enough to break the build process?

I am not exactly sure what I am missing here. Any help appreciated.

Thank you in advance,
Nick

_________________
"Programming is an art form that fights back."
-Kudzu


Top
 Profile  
 
 Post subject: Re: Toolchain Issues - GCC 9.2.1 & Binutils 2.33.1
PostPosted: Tue Dec 03, 2019 4:33 am 
Offline
Member
Member
User avatar

Joined: Sat Mar 31, 2012 3:07 am
Posts: 4594
Location: Chichester, UK
What command are you using to compile 32-bit code?


Top
 Profile  
 
 Post subject: Re: Toolchain Issues - GCC 9.2.1 & Binutils 2.33.1
PostPosted: Tue Dec 03, 2019 5:27 am 
Offline
Member
Member
User avatar

Joined: Sat Mar 22, 2014 1:14 pm
Posts: 65
Location: /bin
iansjack wrote:
What command are you using to compile 32-bit code?


Here are the relevant parts of my Makefile.

Code:
CFLAGS=-nostdlib -nostdinc -fno-builtin -fno-stack-protector -std=c11 -I ./inc -D DEBUG -g
CC=./toolchain/bin/i686-elf-gcc

.c.o:
    @$(CC) $(CFLAGS) -o $@ -c $<



_________________
"Programming is an art form that fights back."
-Kudzu


Top
 Profile  
 
 Post subject: Re: Toolchain Issues - GCC 9.2.1 & Binutils 2.33.1
PostPosted: Tue Dec 03, 2019 5:49 am 
Offline
Member
Member
User avatar

Joined: Sat Mar 22, 2014 1:14 pm
Posts: 65
Location: /bin
One other thing I am suspecting is that during compilation, my cross-compiler resorts to my system install of Binutils instead of the i686-target one. How can I easily check this?

_________________
"Programming is an art form that fights back."
-Kudzu


Top
 Profile  
 
 Post subject: Re: Toolchain Issues - GCC 9.2.1 & Binutils 2.33.1
PostPosted: Tue Dec 03, 2019 6:01 am 
Offline
Member
Member
User avatar

Joined: Sat Mar 31, 2012 3:07 am
Posts: 4594
Location: Chichester, UK
My suspicion is that you are trying to assemble with the system 64- bit assembler, which would imply that you did something wrong when building the cross compiler (but I'm not sure what). Did you follow exactly the instructions in the Wiki?

I believe that specifying -v when compiling will show the commands being called. I've also read that there is a -B option to specify the location of binutils, but I've never had to use that.


Top
 Profile  
 
 Post subject: Re: Toolchain Issues - GCC 9.2.1 & Binutils 2.33.1
PostPosted: Tue Dec 03, 2019 7:08 am 
Offline
Member
Member
User avatar

Joined: Sat Mar 22, 2014 1:14 pm
Posts: 65
Location: /bin
iansjack wrote:
My suspicion is that you are trying to assemble with the system 64- bit assembler, which would imply that you did something wrong when building the cross compiler (but I'm not sure what). Did you follow exactly the instructions in the Wiki?

I believe that specifying -v when compiling will show the commands being called. I've also read that there is a -B option to specify the location of binutils, but I've never had to use that.


I might have wrongly ordered the fresh-built binutils in my PATH when building the cross-gcc, causing it to pick up my system's Binutil install, which targets 64bit. The thing is, I believe I have made the same mistake in the past, but on a 32bit host system and it is quite surprising that nothing broke, causing me to think this was the correct way to do this.

I am rebuilding right now, I'll get back to the thread to post if that was the solution.

Thank you for the info, much appreciated!

_________________
"Programming is an art form that fights back."
-Kudzu


Top
 Profile  
 
 Post subject: Re: Toolchain Issues - GCC 9.2.1 & Binutils 2.33.1
PostPosted: Wed Dec 04, 2019 2:52 am 
Offline
Member
Member
User avatar

Joined: Sat Mar 22, 2014 1:14 pm
Posts: 65
Location: /bin
Turns out the issue was a combination of multiple different sub-issues, one of which are very peculiar (at least to me):

    - I was building Binutils with make -k, which caused part of the build to fail, and only part of the toolchain to build.
    - I was messing up the PATH, causing the GCC build process to pick up my host system Binutils install.
    - I was automating the process with a build script, which I in turn called as a target of my Makefile, which somehow screwed up the process due to a Makefile using make ( :shock: ). I would like to hear any insight on this.

Thank you for the help!
-Nick

_________________
"Programming is an art form that fights back."
-Kudzu


Top
 Profile  
 
 Post subject: Re: Toolchain Issues - GCC 9.2.1 & Binutils 2.33.1
PostPosted: Wed Dec 04, 2019 7:01 am 
Offline
Member
Member
User avatar

Joined: Thu Nov 16, 2006 12:01 pm
Posts: 7614
Location: Germany
I fear you'd have to be a bit more specific on that third issue. Or, in StackExchange parlance, "unclear what you're asking; please provide a minimal example". 8)

_________________
Every good solution is obvious once you've found it.


Top
 Profile  
 
 Post subject: Re: Toolchain Issues - GCC 9.2.1 & Binutils 2.33.1
PostPosted: Thu Dec 05, 2019 1:53 am 
Offline
Member
Member
User avatar

Joined: Sat Mar 22, 2014 1:14 pm
Posts: 65
Location: /bin
Solar wrote:
I fear you'd have to be a bit more specific on that third issue. Or, in StackExchange parlance, "unclear what you're asking; please provide a minimal example". 8)


So what used to happen is that I had a "toolchain" target in my Makefile, which was supposed to build the toolchain. It was literally just
Code:
bash build-toolchain.sh
. Now comes the weird part, while running the script itself in a terminal session produces a working toolchain without any compilation issues whatsoever, running make toolchain, which one would suppose will work, breaks the compilation of Binutils. More specifically, configure works as expected, and during make it errors out on being unable to find Multilib.am (Error 127).

I can try to provide a minimal reproduction example, but I think this might be a usual issue/limitation of make which I don't know of.

_________________
"Programming is an art form that fights back."
-Kudzu


Top
 Profile  
 
 Post subject: Re: Toolchain Issues - GCC 9.2.1 & Binutils 2.33.1
PostPosted: Mon Dec 16, 2019 8:58 am 
Offline
Member
Member

Joined: Thu Jul 05, 2007 8:58 am
Posts: 223
My best guess at what might be causing it would be that it has something to do with Gnu make's recursive make support. It might be that somehow the outermost makefile of one of the built components is detecting that it is already being recursively called, and changes its behaviour in such a way that it fails in the way you describe.


Top
 Profile  
 
 Post subject: Re: Toolchain Issues - GCC 9.2.1 & Binutils 2.33.1
PostPosted: Mon Dec 16, 2019 4:42 pm 
Offline
Member
Member

Joined: Wed Mar 30, 2011 12:31 am
Posts: 676
Quote:
CC=./toolchain/bin/i686-elf-gcc


This suggests to me that your toolchain is not in your $PATH and thus gcc is unable to find an equivalent "i686-elf-as" and friends and is falling back to just "as".

_________________
toaruos on github | toaruos.org | gitlab | twitter | bim - a text editor


Top
 Profile  
 
 Post subject: Re: Toolchain Issues - GCC 9.2.1 & Binutils 2.33.1
PostPosted: Tue Dec 17, 2019 1:00 am 
Offline
Member
Member

Joined: Thu May 17, 2007 1:27 pm
Posts: 999
Note that the bug that klange is mentioning can be fixed by adding links like we do here: click me.

_________________
managarm: Microkernel-based OS capable of running a Wayland desktop (Discord: https://discord.gg/7WB6Ur3). My OS-dev projects: [mlibc: Portable C library for managarm, qword, Linux, Sigma, ...] [LAI: AML interpreter] [xbstrap: Build system for OS distributions].


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: No registered users and 122 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