Can't build GCC cross-compiler

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
Algogole
Posts: 4
Joined: Thu Mar 10, 2016 8:47 am
Location: Tours, France

Can't build GCC cross-compiler

Post by Algogole »

-- 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-mak ... er/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
Korona
Member
Member
Posts: 1000
Joined: Thu May 17, 2007 1:27 pm
Contact:

Re: Can't build GCC cross-compiler

Post by Korona »

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?
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].
Algogole
Posts: 4
Joined: Thu Mar 10, 2016 8:47 am
Location: Tours, France

Re: Can't build GCC cross-compiler

Post by Algogole »

Thanks for replying,

My current gcc (system one) can build x86_64 binaries, in fact,

Code: Select all

gcc-8 -dumpmachine
outputs

Code: Select all

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.
Post Reply