Page 1 of 1

Porting gcc :SSE2 problems (invalid opcode): How to disable?

Posted: Thu Nov 23, 2017 3:50 am
by Haoud
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

Re: Porting gcc :SSE2 problems (invalid opcode): How to disa

Posted: Thu Nov 23, 2017 10:41 am
by Korona
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.

Re: Porting gcc :SSE2 problems (invalid opcode): How to disa

Posted: Thu Nov 23, 2017 11:03 am
by Haoud
OK. How i can enable SSE and support them (especially for the scheduler) ?

Re: Porting gcc :SSE2 problems (invalid opcode): How to disa

Posted: Fri Nov 24, 2017 12:10 pm
by Mikaku
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: Select all

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

Code: Select all

#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: Select all

$ 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.

Re: Porting gcc :SSE2 problems (invalid opcode): How to disa

Posted: Fri Nov 24, 2017 2:29 pm
by Haoud
Yes, it's work !! (But i have an another problem :( ).
Thank you very much