Can't build kernel on one computer, but can on another.

Programming, for all ages and all languages.
Post Reply
j4cobgarby
Member
Member
Posts: 64
Joined: Fri Jan 26, 2018 11:43 am

Can't build kernel on one computer, but can on another.

Post by j4cobgarby »

I have a main desktop computer, and an laptop. They're both running the exact same operating system (manjaro linux), and I have the exact same cross compiler installed (i686-elf-gcc, from the AUR).

My problem only occurs when building on my laptop.

My makefile runs a few commands to compile my kernel. It first assembles the main assembly, which works fine.

It then tries to compile the main C file, with the following command:

Code: Select all

i686-elf-gcc -c kern.c -o build/kern.o -std=gnu99 -ffreestanding -O2 -Wall -Wextra
For some reason, this doesn't work, and throws the following error:

Code: Select all

/tmp/ccLtKHxr.s: Assembler messages:
/tmp/ccLtKHxr.s:52: Error: invalid instruction suffix for `push'
/tmp/ccLtKHxr.s:55: Error: invalid instruction suffix for `push'
/tmp/ccLtKHxr.s:57: Error: register save offset not a multiple of 8
/tmp/ccLtKHxr.s:74: Error: invalid instruction suffix for `pop'
/tmp/ccLtKHxr.s:78: Error: invalid instruction suffix for `pop'
/tmp/ccLtKHxr.s:99: Error: invalid instruction suffix for `push'
/tmp/ccLtKHxr.s:102: Error: invalid instruction suffix for `push'
/tmp/ccLtKHxr.s:104: Error: register save offset not a multiple of 8
/tmp/ccLtKHxr.s:185: Error: invalid instruction suffix for `push'
/tmp/ccLtKHxr.s:194: Error: invalid instruction suffix for `pop'
/tmp/ccLtKHxr.s:197: Error: invalid instruction suffix for `pop'
make: *** [Makefile:4: all] Error 1
First of all, I'm not really sure why these are assembler messages. I know that somewhere down the line my C code will be assembled, but it seems odd to me.
It also seems weird that it compiles fine on my main computer, but not my laptop.

I can provide the source files if necessary, but it's difficult to find a relevant piece of code. The entire source is available at https://github.com/j4cobgarby/atomic-kernel, if that helps.
User avatar
iansjack
Member
Member
Posts: 4688
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: Can't build kernel on one computer, but can on another.

Post by iansjack »

It sounds to me as if there is a mismatch between C compiler and assembler (i.e. using a 64-bit assembler with a 32-bit compiler). Whatever you may think, the Linux installations are not identical. Try using the -v switch with GCC to see exactly what commands are being executed.
Post Reply