LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 12-03-2018, 03:30 AM   #1
Unturned3
Member
 
Registered: Jan 2018
Posts: 35

Rep: Reputation: Disabled
How to install a native gcc toolchain onto the target platform?


Hello,
I built myself a cross toolchain targeting the generic x86_64 platform with musl-libc & gcc. So far, it worked quite well and I managed to install musl and busybox onto the target platform. Now I'm trying to install a gcc toolchain that will run natively on the target. How can I use my existing cross-toolchain to install a toolchain onto the target?

Currently, I have a folder named "targetfs" where all the cross-compiled libraries and headers are (this is basically the root file system that gets stuffed into QEMU). How can I install a toolchain into this targetfs folder?

Thanks for helping.
 
Old 12-03-2018, 10:56 AM   #2
hazel
Senior Member
 
Registered: Mar 2016
Location: Harrow, UK
Distribution: LFS, AntiX, Slackware
Posts: 4,838
Blog Entries: 14

Rep: Reputation: 2727Reputation: 2727Reputation: 2727Reputation: 2727Reputation: 2727Reputation: 2727Reputation: 2727Reputation: 2727Reputation: 2727Reputation: 2727Reputation: 2727
The way Linux From Scratch/Cross Linux From Scratch does it is to use the cross-compiled gcc, binutils and libc to build fully native versions. I notice that you don't mention binutils but you will definitely need a cross-compiled version of that package.

After that, the cross-versions aren't used any more. You use the second-stage native versions to build a more complete toolchain, then use those tools to build your final system.
 
1 members found this post helpful.
Old 12-04-2018, 01:22 AM   #3
Unturned3
Member
 
Registered: Jan 2018
Posts: 35

Original Poster
Rep: Reputation: Disabled
Hello,
Yes I forgot to mention binutils. I built my toolchain by following the CLFS book (but with binutils-2.30, gcc-7.3.0, and musl-1.1.20 instead) and this is how I configured gcc when trying to install it onto the targetfs with my cross toolchain:

Code:
../configure --prefix=$CLFS/targetfs/usr \
--host=$CLFS_TARGET --enable-languages=c,c++ \
--disable-multilib --disable-bootstrap \
--disable-libsanitizer
(I had to disable libsanitizer because it doesn't work with musl-libc)

When I only enabled the C language, the C compiler installed on the targetfs ran without problems. However, the problem is that when I add c++ compiler support with "--enable-languages=c,c++", the build process fails with this error message:

Code:
ctype_members.cc: In constructor 'std::ctype_byname<char>::ctype_byname(const char*, std::size_t)':
ctype_members.cc:50:44: error: cannot convert 'const short unsigned int*' to 'const mask*' {aka 'const unsigned int*'} in assignment
  this->_M_table = this->_M_c_locale_ctype->__ctype_b;
                                            ^~~~~~~~~
make[5]: *** [Makefile:562: ctype_members.lo] Error 1
I mean, errors such as "undefined references" are understandable if my toolchain are missing files/components, but how can a conversion error happen? Does the language rules allow or disallow this syntax? Is it possible that my toolchain is missing some components that causes it to disallow this syntax?

Thanks!

Last edited by Unturned3; 12-04-2018 at 04:28 AM.
 
Old 12-04-2018, 12:11 PM   #4
hazel
Senior Member
 
Registered: Mar 2016
Location: Harrow, UK
Distribution: LFS, AntiX, Slackware
Posts: 4,838
Blog Entries: 14

Rep: Reputation: 2727Reputation: 2727Reputation: 2727Reputation: 2727Reputation: 2727Reputation: 2727Reputation: 2727Reputation: 2727Reputation: 2727Reputation: 2727Reputation: 2727
Did you build the libstdc++ library? It's in the gcc sources. I think the second build of gcc needs it.
http://www.linuxfromscratch.org/lfs/...libstdc++.html
 
Old 12-04-2018, 08:29 PM   #5
Unturned3
Member
 
Registered: Jan 2018
Posts: 35

Original Poster
Rep: Reputation: Disabled
Hello,
I didn't explicitly build the libstdc++ library (as instructed around the "pass 2" stage in the LFS book), because I built the musl toolchain following the CLFS book. The CLFS book said that if I needed a c++ compiler, I just need to add "--enable-language=c,c++" to the configure options. I wondered why I didn't need to explicitly build libstdc++ before that, and I found this blog post that explained it as follows:
Quote:
You may wonder why we didn't have to build a libstdc++ between the first and second pass, like the libc.
The source code for the libstdc++ comes with the G++ compiler and is built automatically like libgcc.
I checked inside the "lib" and "include" folders inside my cross toolchain's sysroot directory and all the libstdc++ header files & library files are present. I can also use the g++ compiler from my cross toolchain to build c++ programs that runs with no problem. However I just can't use this cross toolchain to build & install libstdc++ onto my target system. It generates that "conversion" error I posted previously.

Thanks!

Last edited by Unturned3; 12-04-2018 at 08:30 PM.
 
Old 12-05-2018, 07:36 AM   #6
hazel
Senior Member
 
Registered: Mar 2016
Location: Harrow, UK
Distribution: LFS, AntiX, Slackware
Posts: 4,838
Blog Entries: 14

Rep: Reputation: 2727Reputation: 2727Reputation: 2727Reputation: 2727Reputation: 2727Reputation: 2727Reputation: 2727Reputation: 2727Reputation: 2727Reputation: 2727Reputation: 2727
I think it would have to depend on how you built the cross-gcc. In LFS, this has practically all its libraries including stdlibc++ disabled. Then you build a separate stdlibc++ after libc and before rebuilding gcc. I'm sure there's a good reason why it is done this way.

I know there are parts of gcc that only gcc can build. Perhaps there are parts of gcc that only a stdlibc++-enabled gcc can build. I can't think of anything else; I've come to the end of my knowledge. The LFS forum might be the best place to pursue the question .
 
  


Reply

Tags
cross-compile, gcc, musl


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Install non native programs as native Vpcghostlinux elementary OS 2 12-26-2017 03:58 AM
Installation (Linux) RISCV GNU Toolchain error: C compiler cannot create executables, recipe for target 'configure-target-libgomp' failed riscv Linux - Newbie 2 03-23-2017 09:36 AM
g++ toolchain for ARM platform yuchankit Slackware 3 10-07-2012 01:33 AM
cross compiling a driver on fedora12-i686 for the target ppc860 using ELDK toolchain saidi08 Linux - Newbie 1 01-01-2011 10:42 AM
Trouble with build and install GCC-toolchain for ARM _oligarch Programming 2 04-27-2009 12:03 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 02:20 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration