OSDev.org

The Place to Start for Operating System Developers
It is currently Mon Jul 23, 2018 9:51 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Can't build GCC cross-compiler
PostPosted: Thu Jul 12, 2018 6:52 pm 
Offline

Joined: Thu Mar 10, 2016 8:47 am
Posts: 4
-- I'm not sure about the section; I'm French so my English might not be perfect --

Hi,

I'm trying to build a cross-compiler, I'm following precisely the wiki article. Being on Mac, I installed gcc with homebrew and mapped every calling method possible to gcc-8 (export CC=gcc-8, alias gcc=gcc-8) same with $CXX/g++, $CPP/cpp and $LD/ld(=gcc-8).

However, when I try to "make" binutils after using the exact configure line from the wiki, I get a linking error, some .a files are not being included for some reason and thus, some symbols are unresolved.

I note that this happen to other non-osdev project when I try linking with .a files (ld says "ignoring file [...].a, file was built for archive which is not the architecture being linked (x86_64): [...].a")

make output here https://github.com/DKQuant/binutils-make/blob/master/log.txt

Thanks in advance !

PS:
- I tried to compile version 2.28 to see if it was a problem with 2.30, it failed in the same way.
- ld seems to be connected to llvm and brew doesn't install ld, same with as


Top
 Profile  
 
 Post subject: Re: Can't build GCC cross-compiler
PostPosted: Thu Jul 12, 2018 10:32 pm 
Offline
Member
Member

Joined: Thu May 17, 2007 1:27 pm
Posts: 488
I am not a MacOS user but I know that linking on MacOS can be confusing when you come from a Linux world. Does the gcc you're using actually build x86_64 binaries or does it maybe need a flag like -m64? Why do you want to build with gcc? Building with Apple's clang should work fine AFAIK.

EDIT: Mixing Apple's ld with gcc might just not work due to different expectations regarding object files. Is the no binutils equivalent that you can get from homebrew?


Top
 Profile  
 
 Post subject: Re: Can't build GCC cross-compiler
PostPosted: Thu Jul 12, 2018 10:59 pm 
Offline

Joined: Thu Mar 10, 2016 8:47 am
Posts: 4
Thanks for replying,

My current gcc (system one) can build x86_64 binaries, in fact,
Code:
gcc-8 -dumpmachine
outputs
Code:
x86_64-apple-darwin17.5.0


Homebrew already installs binutils-2.30 but strips ld, as and gprof as they appear to not be compatible with macOS.

As of building with clang (and removing any gcc or binutils installed by homebrew), it gives back the same result, ignoring certain .a files and reporting unresolved references.

EDIT: after rethinking about your response, you might have meant build my project with clang and not gcc, I'll think of that, but since I'm not able to compile binutils, I won't have a sysroot-enabled ld, as it is recommended on the wiki page of llvm cross-compiler. And I'm not sure about llvm linker to accept linker scripts.


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

All times are UTC - 6 hours


Who is online

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