OSDev.org

The Place to Start for Operating System Developers
It is currently Wed Apr 17, 2024 11:51 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: [Guide] Porting newlib with less hacks
PostPosted: Sat Apr 07, 2018 5:32 pm 
Offline

Joined: Sun Jun 26, 2016 7:56 pm
Posts: 9
Hello everyone,
Since Porting_Newlib wiki page is full of hacks and exact versions, it's been hard(er) for some people to port other versions of newlib and/or incorporate newlib in a proper build system. I tried to figure out how to port it without so much hassle and successfully ported newlib-3.0.0 (latest). Also I build libpthread as part of newlib (exported separately as libpthread.a).

A bit of background:
Newlib requires automake with cygnus-style trees support, which has been deprecated by GNU Automake, but the official documentation says the exact versions of automake to use, which is confusing. Cygnus was a company that was purchased by Red Hat, so either a) they have their own version of automake, b) are keeping an internal fork of GNU Automake with cygnus-style trees support or c) GNU Automake still supports building automake with cygnus-style trees (I've tried working with that later option but couldn't find any reference to it and the configure script doesn't mention cygnus trees at all).
So in theory, you need automake that supports --cygnus trees, but the latest GNU version that supports it is automake-1.12.1.
Luckily though, autoconf doesn't necessarily depend on automake version and an older version could be used (will give you some warnings though).
For newlib-3.0.0 for example, the README file (found in newlib/README) says that the exact versions to use are autoconf 2.69, aclocal 1.13.4, and automake 1.13.4, we can instead use autoconf 2.69, aclocal 1.12.1, and automake 1.12.1

Steps:
1) Follow everything in the wiki except when it says to use any automake/aclocal/autoconf/autoreconf tools, just ignore these until you're ready to build.
2) According to README you need to generate aclocal.m4 in every directory you modify or create (in our case it would be newlib/libc/sys/myos) so in that directory, run the commands
Code:
aclocal -I ../../..
automake --cygnus Makefile

With aclocal 1.12.1 and automake 1.12.1
Note: DO NOT run autoconf, you won't be able to use automake afterwards. (We are essentially tricking newlib as if automake version was the appropriate one)
3) run autoconf (exact version from README) inside newlib/sys (To regerenate configuration files with "myos" directory included)
4) run autoconf (exact version from README) inside newlib/sys/myos to generate configure files in myos directory.
5) That's it, continue steps in Compiling section in the wiki and it should build successfully.

Notes:
step 2) needs only to be done once for the source tree (it will generate aclocal.m4 and autom4te.cache/ - they are relevant to newlib version and should not be changed). You will need to run automake command again if you change Makefile.am (but it won't work due to version mismatch, so you'd need to start over :"D).
steps 3) and 4) generate "configure" file in each directory, they depend on configure.in and can be run multiple times if you change it.

Disclaimer: I'm not sure how any of this works, I'm not an expert on autotools, so I might be doing something terribly wrong or something, but it builds on my system, so if some of you try and confirm that it works for other versions of newlib (I tried 2.1.0, 2.2.0 and 3.0.0 and they all work fine) we can update the wiki.

_________________
Working on AquilaOS, a POSIX-compliant OS.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot], Google [Bot], SemrushBot [Bot] and 241 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group