OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 3:20 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Porting gcc :SSE2 problems (invalid opcode): How to disable?
PostPosted: Thu Nov 23, 2017 3:50 am 
Offline
Member
Member

Joined: Wed Aug 10, 2016 3:07 am
Posts: 31
Hello every one,
I'm ported GCC to my OS with my toolchain i386-haoudos. GCC seems to work correctly( i can use gcc --version in my os).But when i try to compile a file, cc1 throws an invalid opcode because it try to use sse2 instructions.My OS doesn't support sse2, only i387 fpu. How i can disable sse2 instruction for all gcc code?
The invalide opcode is in libcpp/lex.c/search-line-sse2
If you need more informations, don't hesitate to ask me.
Thank you

Sorry for my english but i'm french


Top
 Profile  
 
 Post subject: Re: Porting gcc :SSE2 problems (invalid opcode): How to disa
PostPosted: Thu Nov 23, 2017 10:41 am 
Offline
Member
Member

Joined: Thu May 17, 2007 1:27 pm
Posts: 999
Supporting SSE in your OS probably requires less SLoC than your post. Instead of figuring out how to disable SSE in gcc (and all of its libraries) just enable SSE.

_________________
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  
 
 Post subject: Re: Porting gcc :SSE2 problems (invalid opcode): How to disa
PostPosted: Thu Nov 23, 2017 11:03 am 
Offline
Member
Member

Joined: Wed Aug 10, 2016 3:07 am
Posts: 31
OK. How i can enable SSE and support them (especially for the scheduler) ?


Top
 Profile  
 
 Post subject: Re: Porting gcc :SSE2 problems (invalid opcode): How to disa
PostPosted: Fri Nov 24, 2017 12:10 pm 
Offline
Member
Member
User avatar

Joined: Sat Jun 25, 2016 8:29 am
Posts: 42
Location: Catalonia
I was also porting (now already successfully ported) GCC and Binutils to my OS, and I had _exactly_ the same problem, it took me some weeks to fix it.

Indeed the problem is in libcpp/lex.c file, and I solved it just including an exception for my OS (fiwix) in the line 277. I'm using GCC v4.7.1 so if you are using a different version the line number might vary.

Original line:
Code:
#if (GCC_VERSION >= 4005) && (defined(__i386__) || defined(__x86_64__)) && !(defined(__sun__) && defined(__svr4__))


Patched line which includes my OS:
Code:
#if (GCC_VERSION >= 4005) && (defined(__i386__) || defined(__x86_64__)) && !(defined(__sun__) && defined(__svr4__)) && !defined(__fiwix__)


So now, ported GCC v4.7.1 is able to compile natively in my OS and produce pure i386 executables:

Code:
$ gcc -v
Using built-in specs.
COLLECT_GCC=./gcc
COLLECT_LTO_WRAPPER=./../libexec/gcc/i386-fiwix/4.7.1/lto-wrapper
Target: i386-fiwix
Configured with: ../gcc-4.7.1/configure --host=i386-fiwix --target=i386-fiwix --prefix=/usr --with-arch=i386 -with-buid-sysroot=/home/mikaku/fiwix/sysroot --with-sysroot=/ --with-gmp=/home/mikaku/fiwix/sysroot --with-mpfr=/home/mikaku/fiwix/sysroot --with-mpc=/home/mikaku/fiwix/sysroot --enable-languages=c,c++ --disable-lto --disable-shared --disable-multilib --with-newlib --disable-nls --disable-werror
Thread model: single
gcc version 4.7.1 (GCC)


I hope that helped you.

_________________
https://www.fiwix.org


Last edited by Mikaku on Fri Nov 24, 2017 5:37 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: Porting gcc :SSE2 problems (invalid opcode): How to disa
PostPosted: Fri Nov 24, 2017 2:29 pm 
Offline
Member
Member

Joined: Wed Aug 10, 2016 3:07 am
Posts: 31
Yes, it's work !! (But i have an another problem :( ).
Thank you very much


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

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 46 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