Problem building GCC 8.2.0 amd64-to-i386 cross-compiler

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Problem building GCC 8.2.0 amd64-to-i386 cross-compiler

Luigi30
I need to build a GCC cross-compiler targeting i386-pc-elf. I'm running
into problems with the build on OpenBSD 6.3.

I've already successfully built a binutils-2.31.1 for i386-pc-elf.

Trying to use the GCC 4.9.4 package (as GCC 4.2 is too old to build GCC
8), my configure is:

CC=egcc CXX=eg++ ../gcc-8.2.0/configure --prefix=/usr/local/gcc-i386
--target=i386-pc-elf --with-gmp=/usr/local

And I'm just running gmake -j7. The error I get is in this build log:
https://pastebin.com/k0ygAN5t

***
/usr/bin/ld: build/genmodes.o: relocation R_X86_64_32 against `a local
symbol' can not be used when making a shared object; recompile with -fPIC
***

If I use the clang that's built into OpenBSD, I get a bunch of C errors
that presumably mean that you can't do it with clang. Here is the build
log: https://pastebin.com/Dv5gQ4aS

My configure for that is:

CC=clang CXX=clang ../gcc-8.2.0/configure --prefix=/usr/local/gcc-i386
--target=i386-pc-elf --with-gmp=/usr/local

Has anyone ran into this problem before, and if so, what do I need to do
to build my cross-compiler on OpenBSD? Apologies if this is not the
right place to ask.

Reply | Threaded
Open this post in threaded view
|

Re: Problem building GCC 8.2.0 amd64-to-i386 cross-compiler

Daniel Corbe-2
at 11:43 PM, Katherine Rohl <[hidden email]> wrote:

>
>
> ***
> /usr/bin/ld: build/genmodes.o: relocation R_X86_64_32 against `a local  
> symbol' can not be used when making a shared object; recompile with -fPIC
> ***
>

Have you tried following the compiler’s advice and rebuilding with -fPIC


Reply | Threaded
Open this post in threaded view
|

Re: Problem building GCC 8.2.0 amd64-to-i386 cross-compiler

Todd C. Miller-2
In reply to this post by Luigi30
On Mon, 24 Sep 2018 23:43:20 -0400, Katherine Rohl wrote:

> I need to build a GCC cross-compiler targeting i386-pc-elf. I'm running
> into problems with the build on OpenBSD 6.3.
>
> I've already successfully built a binutils-2.31.1 for i386-pc-elf.
>
> Trying to use the GCC 4.9.4 package (as GCC 4.2 is too old to build GCC
> 8), my configure is:
>
> CC=egcc CXX=eg++ ../gcc-8.2.0/configure --prefix=/usr/local/gcc-i386
> --target=i386-pc-elf --with-gmp=/usr/local

You might need to disable PIE when building gcc.  Try setting
"CFLAGS=-fno-pie -g -O2" and "LDFLAGS=-nopie" when running configure
and see if that helps.

 - todd

Reply | Threaded
Open this post in threaded view
|

Re: Problem building GCC 8.2.0 amd64-to-i386 cross-compiler

Luigi30
That was it - thank you. My GCC cross-compiler now works.

—Katherine

> On Sep 25, 2018, at 8:25 AM, Todd C. Miller <[hidden email]> wrote:
>
>> On Mon, 24 Sep 2018 23:43:20 -0400, Katherine Rohl wrote:
>>
>> I need to build a GCC cross-compiler targeting i386-pc-elf. I'm running
>> into problems with the build on OpenBSD 6.3.
>>
>> I've already successfully built a binutils-2.31.1 for i386-pc-elf.
>>
>> Trying to use the GCC 4.9.4 package (as GCC 4.2 is too old to build GCC
>> 8), my configure is:
>>
>> CC=egcc CXX=eg++ ../gcc-8.2.0/configure --prefix=/usr/local/gcc-i386
>> --target=i386-pc-elf --with-gmp=/usr/local
>
> You might need to disable PIE when building gcc.  Try setting
> "CFLAGS=-fno-pie -g -O2" and "LDFLAGS=-nopie" when running configure
> and see if that helps.
>
> - todd