Can't build libgcc for kernel mode

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
primoze
Posts: 2
Joined: Sat May 11, 2019 1:31 pm

Can't build libgcc for kernel mode

Post by primoze »

Hi.

I'm trying to build libgcc by following https://wiki.osdev.org/Building_libgcc_ ... l%3Dkernel. The sed command doesn't help at all (it does what it's supposed to, but looks like that's not what has to be done) and the build fails again for the same reason. I have followed the https://wiki.osdev.org/GCC_Cross-Compiler article up to this point.
I have also tried with this multilib setup

Code: Select all

MULTILIB_OPTIONS += mno-red-zone mcmodel=kernel/fpic
but the result is the same.

I'm using gcc 7.4.0 on ubuntu, first tried compiling gcc 8.3, then 9.1, same results both times. Although I didn't try the multilib thing on 8.3.

A web search returns a bunch of posts about not being able to compile the linux kernel, and suggests adding -fno-pie to some flags, but that was supposed to be what the sed command in the libgcc article does.

Has anyone else had issues with this?
User avatar
thomtl
Member
Member
Posts: 66
Joined: Mon Sep 03, 2018 2:25 am

Re: Can't build libgcc for kernel mode

Post by thomtl »

I dealt with this problem a short while ago and made a small build script for it, maybe it can help you

https://github.com/sigma-os/bootstrap/b ... ompiler.sh
primoze
Posts: 2
Joined: Sat May 11, 2019 1:31 pm

Re: Can't build libgcc for kernel mode

Post by primoze »

I dealt with this problem a short while ago and made a small build script for it, maybe it can help you
I took a look at it. While it's essentially the same as the way the article does it, it did work and set me on the path to finding the root of my issue. Looks like the problem was my gcc directory still had the modifications I made from following https://wiki.osdev.org/Libgcc_without_red_zone. I removed those and it worked. Thanks.

Does anyone know if this can be done with multilib configuration? It seems really hackish using sed to modify makefiles, and I would preferably not have to have two gccs to build my kernel and stuff that runs in the lower address space. As far as I understand it that's basically the other way to do it. Unless I'm missing something?
Post Reply