LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
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 05-27-2018, 10:14 AM   #1
Michele13
LQ Newbie
 
Registered: May 2018
Distribution: Debian Jessie 8.10 (x86_64)
Posts: 26

Rep: Reputation: 0
Question How to build a pcc toolchain?


Hello everybody

Today I'm trying to build a i486-linux-musl toolchain using Portable C Compiler instead of GCC.

Here are the steps that I've made in that precise order:

replace ${PREFIX} with /home/michele/cross and ${TRIPLE} with i486-linux-musl

CREATE DIRECTORIES

Code:
mkdir -p ${PREFIX}/${TRIPLE}
	ln -s . ${PREFIX}/${TRIPLE}/usr
CONFIGURE ENVIRONMENT

Code:
export PATH=${PREFIX}/bin:$PATH
LINUX HEADERS

Code:
make mrproper
	ARCH=i386 make headers_check
	ARCH=i386 make INSTALL_HDR_PATH=${PREFIX}/${TRIPLE} headers_install
BINUTILS

Configure:

Code:
../configure --prefix=${PREFIX}  --target=${TRIPLE} --disable-nls \
	--disable-shared --disable-multilib
Install it:

Code:
make configure-host
	make
	make install
PCC

Code:
./configure --target=${TRIPLE} --prefix=${PREFIX}
	make
	make install
PCC-LIBS

Code:
./configure --target=${TRIPLE} --prefix=${PREFIX}
	make
	make install
MUSL LIBC

Code:
	CC=${TRIPLE}-pcc ./configure --target=${TRIPLE} --prefix=${PREFIX} --disable-shared \
	--disable-debug
	make && make install
Now when I try to compile "Hello World" it gives me this herror. Do you know how could I fix that? Do you need other informations?

Code:
/home/michele/cross/i486-linux-musl/lib/crt1.o: In function `_start':
crt1.c:(.text+0x11): undefined reference to `_DYNAMIC'
/home/michele/cross/i486-linux-musl/lib//libc.a(__init_tls.o): In function `static_init_tls':
__init_tls.c:(.text+0x123): undefined reference to `_DYNAMIC'
__init_tls.c:(.text+0x12a): undefined reference to `_DYNAMIC'
i486-linux-musl-ld: a.out: hidden symbol `_DYNAMIC' isn't defined
i486-linux-musl-ld: final link failed: Bad value
error: i486-linux-musl-ld terminated with status 1
Some web pages that might help

I'm using:

  • pcc-20180523
  • pcc-libs-20180523
  • linux-4.4.21
  • binutils-2.27
  • musl-1.1.19

Last edited by Michele13; 05-28-2018 at 07:56 AM. Reason: adjusting typos
 
Old 05-28-2018, 12:11 AM   #2
AwesomeMachine
LQ Guru
 
Registered: Jan 2005
Location: USA and Italy
Distribution: Debian testing/sid; OpenSuSE; Fedora; Mint
Posts: 5,524

Rep: Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015
The one link supplies a script to do the entire job for you. Did you apply the suggested patches? Those are important. Otherwise you have to use the exact libc version specified.
 
Old 05-28-2018, 02:16 AM   #3
Michele13
LQ Newbie
 
Registered: May 2018
Distribution: Debian Jessie 8.10 (x86_64)
Posts: 26

Original Poster
Rep: Reputation: 0
I read the patches files and checked the upstream sources, looks like we won't need to use a couple of them anymore
 
Old 05-28-2018, 07:44 AM   #4
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,804

Rep: Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306
I don't know which shell did you use, but for bash the export command you posted is not valid. You missed an = sign:
export VAR=VALUE
 
Old 05-28-2018, 07:54 AM   #5
Michele13
LQ Newbie
 
Registered: May 2018
Distribution: Debian Jessie 8.10 (x86_64)
Posts: 26

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by pan64 View Post
I don't know which shell did you use, but for bash the export command you posted is not valid. You missed an = sign:
export VAR=VALUE
Sorry pan64, that was a typo that I did while writing the topic
 
Old 05-29-2018, 01:25 AM   #6
AwesomeMachine
LQ Guru
 
Registered: Jan 2005
Location: USA and Italy
Distribution: Debian testing/sid; OpenSuSE; Fedora; Mint
Posts: 5,524

Rep: Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015
I would say you have an incompatible libc version.
 
1 members found this post helpful.
Old 05-31-2018, 05:00 AM   #7
Michele13
LQ Newbie
 
Registered: May 2018
Distribution: Debian Jessie 8.10 (x86_64)
Posts: 26

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by AwesomeMachine View Post
I would say you have an incompatible libc version.
Yes, indeed.. if I use musl-1.1.10 it builds everything successfully, however if I try to run libc.so or any dynamic linked executable it goes in segmentation fault, it I try to run a statically linked executable it runs fine. Do you know why this might happen?

Unfortunately this cross compiler is not even capable to compile tar, busybox (it depends on GCC to build) or toybox (fails to build hostname.c)

Last edited by Michele13; 05-31-2018 at 05:01 AM. Reason: added a question
 
Old 05-31-2018, 05:06 AM   #8
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,804

Rep: Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306
most probably a function has changed in a library, it has different kind/number of parameters (when comparing the new/old ones)
 
Old 05-31-2018, 05:56 AM   #9
Michele13
LQ Newbie
 
Registered: May 2018
Distribution: Debian Jessie 8.10 (x86_64)
Posts: 26

Original Poster
Rep: Reputation: 0
What can I do to improve those projects (musl and pcc)?
 
Old 05-31-2018, 06:05 AM   #10
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,804

Rep: Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306
what kind of improvement do you mean?
segfault usually caused by using incompatible libraries and you will never know which one is the correct and which one was the incorrectly compiled one (because both of them are ok, just they cannot be used together).
Sometimes the libraries have versions (like libstdc++.so.6.0.19) which may help you to catch those problems, but there is no general solution to avoid that.
 
Old 05-31-2018, 06:15 AM   #11
Michele13
LQ Newbie
 
Registered: May 2018
Distribution: Debian Jessie 8.10 (x86_64)
Posts: 26

Original Poster
Rep: Reputation: 0
For example I would like to make the latest version of musl to get along with the latest version of PCC (see problems above) and maybe improve the compiler so it can build little projects like tar. The problem with that is that I don't know how to program in C or any program language beyond a certain level
 
  


Reply



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
error in Toolchain build for ARM anuradha jain Linux - Embedded & Single-board computer 2 12-14-2011 07:21 AM
Final Phase GCC build fails for ARM cross compiler toolchain bencpeters Linux - Embedded & Single-board computer 1 11-13-2011 05:23 PM
How to build Cross Compiler Toolchain on Fedora for other Linux distributions? drroot Programming 8 04-25-2011 04:35 PM
Trouble with build and install GCC-toolchain for ARM _oligarch Programming 2 04-26-2009 11:03 PM

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

All times are GMT -5. The time now is 02:57 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