[Newlib 1.20.0-cygwin] : are you experienced in porting ?

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
denilsson31
Posts: 11
Joined: Thu Jun 10, 2010 4:47 am

[Newlib 1.20.0-cygwin] : are you experienced in porting ?

Post by denilsson31 »

Hi,

I'm preparing myself to port newlib to an environment of my own.

Before all, I'm just trying to build newlib in cygwin...
and I'm impressed by the number of difficulties I encounted.
Then, I've tried to join the newlib mailing-list but seems to be dead.

The origin of boring is that a newlib maintainer had the bright idea to create a dirent.h file in the newlib source with the following content :

Code: Select all

/* <dirent.h> includes <sys/dirent.h>, which is this file.  On a
   system which supports <dirent.h>, this file is overridden by
   dirent.h in the libc/sys/.../sys directory.  On a system which does
   not support <dirent.h>, we will get this file which uses #error to force
   an error.  */

#ifdef __cplusplus
extern "C" {
#endif
#error "<dirent.h> not supported"
#ifdef __cplusplus
}
#endif
The problem is that it always overrides the regular sys/dirent.h from /usr/include, because in seach paths strategy, it is always the -I's and -isystem's paths which are scanned before standard system libraries. So, the compilation always fails whatever the soft config.
:-k I doubt this piece of code has been tested by the maintainer.

But, trying to find a solution, I invoked GNU configure with the following :
CFLAGS="-nostdinc" CPPFLAGS="-I/usr/include ..."

Then, if CFLAGS is taken into account, CPPFLAGS, not. If I gather CPPFLAGS content with CFLAGS, these compilation options are at the end of the gcc command line, after the newlib includes paths.

Does someone have a solution ?

Thanks for your attention and the suggestion you could make.
User avatar
bubach
Member
Member
Posts: 1223
Joined: Sat Oct 23, 2004 11:00 pm
Location: Sweden
Contact:

Re: [Newlib 1.20.0-cygwin] : are you experienced in porting

Post by bubach »

I have no experience in this whatsoever, but have you tried looking at the source of other hobby OS's that has it ported already? It can give inspiration to how to solve some of the difficult parts.
"Simplicity is the ultimate sophistication."
http://bos.asmhackers.net/ - GitHub
denilsson31
Posts: 11
Joined: Thu Jun 10, 2010 4:47 am

Re: [Newlib 1.20.0-cygwin] : are you experienced in porting

Post by denilsson31 »

bubach wrote:I have no experience in this whatsoever, but have you tried looking at the source of other hobby OS's that has it ported already? It can give inspiration to how to solve some of the difficult parts.
(I have checked my problem doesn't depend on #ifdef _CYGWIN.)

It's a good idea. I don't know how to find out such an OS but I'm to the point to search for.
Last edited by denilsson31 on Sun Apr 15, 2012 8:56 am, edited 1 time in total.
User avatar
bluemoon
Member
Member
Posts: 1761
Joined: Wed Dec 01, 2010 3:41 am
Location: Hong Kong

Re: [Newlib 1.20.0-cygwin] : are you experienced in porting

Post by bluemoon »

I do not see such error but I'm using gcc cross compiler.
What command you use to build newlib with cygwin?

my build script for newlib:

Code: Select all

# fetch newlib
cvs -z 9 -d :pserver:[email protected]:/cvs/src co newlib

# build it
mkdir build-i586-elf
cd build-i586-elf
../src/configure --target=i586-elf --prefix=`pwd`/../../../libc/
make
make install
cd ..
This build a minimal newlib and I just need to provide libgloss.a for the glue.
denilsson31
Posts: 11
Joined: Thu Jun 10, 2010 4:47 am

Re: [Newlib 1.20.0-cygwin] : are you experienced in porting

Post by denilsson31 »

I let 'configure' guessing host and target.
The command line I used is the following :

Initially :

Code: Select all

configure --with-newlib
Starting by printing :
checking build system type... i686-pc-cygwin
checking host system type... i686-pc-cygwin
checking target system type... i686-pc-cygwin


I'm beginning to understand what the newlib package expects.
I think, it expects an implementation of dirent in a libc/cygwin/ directory.
dirent is implemented in cygwin, but newlib compilation chain is configured to expect one in its own paths.
denilsson31
Posts: 11
Joined: Thu Jun 10, 2010 4:47 am

Re: [Newlib 1.20.0-cygwin] : are you experienced in porting

Post by denilsson31 »

@bluemoon, I'm trying what you suggest to do.
Thanks a lot.
[-o< Cross the fingers.
denilsson31
Posts: 11
Joined: Thu Jun 10, 2010 4:47 am

Re: [Newlib 1.20.0-cygwin] : are you experienced in porting

Post by denilsson31 »

Humm ... trying to launch i586-elf-cc and so, fails

I must use CC variable, I guess
denilsson31
Posts: 11
Joined: Thu Jun 10, 2010 4:47 am

Re: [Newlib 1.20.0-cygwin] : are you experienced in porting

Post by denilsson31 »

No way : Makefile still invokes i586-elf-cc

What a story !
denilsson31
Posts: 11
Joined: Thu Jun 10, 2010 4:47 am

Re: [Newlib 1.20.0-cygwin] : are you experienced in porting

Post by denilsson31 »

OK. Not documented but found out.

Just insert cygwin source tree in the newlib source tree. For example, create a soft link at the root of newlib source tree to winsup cygwin sub-directory.
gerryg400
Member
Member
Posts: 1801
Joined: Thu Mar 25, 2010 11:26 pm
Location: Melbourne, Australia

Re: [Newlib 1.20.0-cygwin] : are you experienced in porting

Post by gerryg400 »

Start by building a cross-compiler for your O/S. You will then be able to build your OS (including newlib) on Cygwin, MacOSX and Linux and have none of these issues. You won't need any CC= or CFLAGS= stuff, it all just works. Don't use libgloss, add a dir for your OS under sys.

The key is to use a cross-compiler. If you don't use a cross-compiler then it will never work correctly.
If a trainstation is where trains stop, what is a workstation ?
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re: [Newlib 1.20.0-cygwin] : are you experienced in porting

Post by Solar »

Re: [Newlib 1.20.0-cygwin] : are you experienced in porting ?

I only just now realize what the thread title actually says.

I'd daresay the reason why your newlib drags in Cygwin specifics is the fact that you are using the Cygwin-patched sources...
Every good solution is obvious once you've found it.
Post Reply