OSDev.org
https://forum.osdev.org/

Can't build GCC cross-compiler
https://forum.osdev.org/viewtopic.php?f=1&t=33072
Page 1 of 1

Author:  Algogole [ Thu Jul 12, 2018 6:52 pm ]
Post subject:  Can't build GCC cross-compiler

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

Author:  Korona [ Thu Jul 12, 2018 10:32 pm ]
Post subject:  Re: Can't build GCC cross-compiler

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?

Author:  Algogole [ Thu Jul 12, 2018 10:59 pm ]
Post subject:  Re: Can't build GCC cross-compiler

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.

Page 1 of 1 All times are UTC - 6 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/