Building libgcc for kernel without SIMD

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
yr
Member
Member
Posts: 31
Joined: Sat Mar 28, 2015 12:50 pm

Building libgcc for kernel without SIMD

Post by yr »

Has anyone built libgcc successfully with -mgeneral-regs-only or equivalent? While I have been able to do so, the approach I used has significant drawbacks.

To provide some context, I need to use the libgcc unwind functionality in parts of the kernel, but prefer not to incur the complexity of supporting SIMD usage outside of user space. As things stand, with an out-of-the-box build, even the unwind portions of libgcc end up using SIMD instructions.

Building libgcc with -mgeneral-regs-only seems to fail because of all the soft-fp stuff and more. While I have been able to build it by explicitly excluding problematic bits via the below target makefile fragment, this impacts all the multilib builds (i.e., regular libgcc build as well as the build with -mcmodel=kernel,-mno-red-zone), which breaks things for user space. If it is possible to modify only one of the multilib builds, then that would be much better. Otherwise, the only options are using a chimerical mix of libgcc builds extracted from gcc built with/without the below fragment, or using separate compilers for kernel and user space.

Any tips or suggestions are welcome.

Code: Select all

HOST_LIBGCC2_CFLAGS += -mgeneral-regs-only
LIB2FUNCS_EXCLUDE += \
    _powisf2 _powidf2 _powixf2 _powitf2 \
    _mulhc3 _mulsc3 _muldc3 _mulxc3 _multc3 \
    _divhc3 _divsc3 _divdc3 _divxc3 _divtc3 \
    _floatdidf _floatdisf _fixunsdfsi _fixunssfsi \
    _fixunsdfdi _fixdfdi _fixunssfdi _fixunsxfdi _fixunsxfsi \
    _fixsfdi _floatundidf _floatundisf _floattixf _floatdixf \
    _floatuntixf _floatundixf

softfp_wrap_start := '\#if 0'
softfp_wrap_end := '\#endif'
Octocontrabass
Member
Member
Posts: 5562
Joined: Mon Mar 25, 2013 7:01 pm

Re: Building libgcc for kernel without SIMD

Post by Octocontrabass »

I would guess that ix86_libgcc_floating_mode_supported_p() should return false in a few cases where it currently returns true. I haven't tried making this change yet so I don't know if it will work or what impact it might have outside libgcc.
nullplan
Member
Member
Posts: 1789
Joined: Wed Aug 30, 2017 8:24 am

Re: Building libgcc for kernel without SIMD

Post by nullplan »

This is why I don't use libgcc. For unwinding, you might want to consider porting libunwind to your environment, or else just implementing everything yourself outright. It's not magic, and all the data structures are open and available.
Carpe diem!
yr
Member
Member
Posts: 31
Joined: Sat Mar 28, 2015 12:50 pm

Re: Building libgcc for kernel without SIMD

Post by yr »

Octocontrabass wrote:I would guess that ix86_libgcc_floating_mode_supported_p() should return false in a few cases where it currently returns true. I haven't tried making this change yet so I don't know if it will work or what impact it might have outside libgcc.
Thanks. I'll look into this when I have a bit more time. For now, I'm going with the option of building with/without -mgeneral-regs-only and then copying over the -mcmodel=kernel,-mno-red-zone libgcc from the former to the latter. It's not elegant, but it works.
nullplan wrote:This is why I don't use libgcc. For unwinding, you might want to consider porting libunwind to your environment, or else just implementing everything yourself outright. It's not magic, and all the data structures are open and available.
I've considered moving away from using libgcc, and libunwind is the obvious alternative, so I might look into that. Writing my own unwind library is something I might do eventually (it's not magic, as you said), but it requires more time than I want to invest right now.
Post Reply