gcc - building a cortex-a7 cross compiler - Stack Overflow

I'm building a cross compiler environment for my cortex-a7 board. Environment is based on gcc + mu

I'm building a cross compiler environment for my cortex-a7 board. Environment is based on gcc + musl.

Problem I've got is that gcc can't compile compile libgcc, without stdio.h. stdio.h and the library lives in musl. But problem is I can't compile the musl libc, as it needs references in the libgcc. So I have a circular problem.

To be specific gcc is configured with:

../gcc-14.2.0/configure --with-sysroot=/home/summers/arm --prefix=/home/summers/arm --target=armv7l-linux-musleabihf --enable-languages=c,c++ --without-headers --with-native-system-header-dir=/include --disable-threads --disable-libssp --disable-multilib --disable-werror --disable-shared --with-arch=armv7-a --with-float=hard --with-fpu=neon-vfpv4

The build fails in building libgcc with ../../../gcc-14.2.0/libgcc/../gcc/tsystem.h:95:10: fatal error: stdio.h: No such file or directory

I can install gcc though

Inside musl:

./configure --prefix=/home/summers/arm --target=armv7l-linux-musleabihf

then ld fails with messages like dynlink.c:(.text.load_library+0x8a0): undefined reference to __aeabi_uidiv

So I've missed something here - what step have I missed, how do I get a working cross compile set up?

I'm building a cross compiler environment for my cortex-a7 board. Environment is based on gcc + musl.

Problem I've got is that gcc can't compile compile libgcc, without stdio.h. stdio.h and the library lives in musl. But problem is I can't compile the musl libc, as it needs references in the libgcc. So I have a circular problem.

To be specific gcc is configured with:

../gcc-14.2.0/configure --with-sysroot=/home/summers/arm --prefix=/home/summers/arm --target=armv7l-linux-musleabihf --enable-languages=c,c++ --without-headers --with-native-system-header-dir=/include --disable-threads --disable-libssp --disable-multilib --disable-werror --disable-shared --with-arch=armv7-a --with-float=hard --with-fpu=neon-vfpv4

The build fails in building libgcc with ../../../gcc-14.2.0/libgcc/../gcc/tsystem.h:95:10: fatal error: stdio.h: No such file or directory

I can install gcc though

Inside musl:

./configure --prefix=/home/summers/arm --target=armv7l-linux-musleabihf

then ld fails with messages like dynlink.c:(.text.load_library+0x8a0): undefined reference to __aeabi_uidiv

So I've missed something here - what step have I missed, how do I get a working cross compile set up?

Share Improve this question asked Mar 25 at 15:00 David SummersDavid Summers 111 bronze badge 3
  • OK - managed to find a way through. Not a solution, but a work around. musl-cross-make can construct a tool chain, with the relevent armv7l-linux-musleabihf prefix. This can then be used to compile musl in the new tool chain place. By default musl-cross-make builds gcc 9.4.0 - so quite old. So next compile the new gcc 14.2.0 against the libc generated by musl; the compile is then straightforward. Finally recompile the musl libc using the new gcc 14.2.0. This gets a modern tool chain for this target. Its not totally satisfactory - as had to use musl-cross-make as a start. – David Summers Commented Mar 27 at 11:29
  • Oh yes - when doing configure you also have to set --disable-libsanitizer as that doesn't work in c++ on arm ... – David Summers Commented Mar 27 at 19:27
  • It's perfectly fine to post your solution as an answer to your own question and accept it. – Mike Kinghan Commented Mar 27 at 22:10
Add a comment  | 

1 Answer 1

Reset to default 0

Just promoting my comment to a partial answer. The problem was indeed a circular dependence between compiling libgcc and the standard c library, in my case musl.

The way I found round was to use musl-cross-make: https://github/richfelker/musl-cross-make - this does succeed in compiling a cross compiler and musl with the right target triplets. This can then used to compile musl and put it in the correct place. Then gcc and libgcc can be compiled, against the musl lib c.

The one change that is needed, is when compiling c++, this includes libsanitizer, which uses 64 bit variables. Alas these didn't work on the armv7 target. So this needs to be disabled. This gives the full configure as:

../gcc-14.2.0/configure --with-sysroot=/home/summers/arm --prefix=/home/summers/arm --target=armv7l-linux-musleabihf --enable-languages=c,c++ --with-headers=/include --with-native-system-header-dir=/include --enable-threads=posix --enable-libssp --enable-multilib --disable-werror --enable-shared --disable-libsanitizer --with-arch=armv7-a --with-float=hard --with-fpu=neon-vfpv4

Finally recompile musl lib c, with the freshly compiled new gcc 14.2.0.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744187413a4562273.html

相关推荐

  • gcc - building a cortex-a7 cross compiler - Stack Overflow

    I'm building a cross compiler environment for my cortex-a7 board. Environment is based on gcc + mu

    8天前
    10

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信