Page 1 of 1

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

Posted: Sun Apr 15, 2012 8:19 am
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.

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

Posted: Sun Apr 15, 2012 8:24 am
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.

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

Posted: Sun Apr 15, 2012 8:46 am
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.

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

Posted: Sun Apr 15, 2012 8:56 am
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.

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

Posted: Sun Apr 15, 2012 9:07 am
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.

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

Posted: Sun Apr 15, 2012 9:11 am
by denilsson31
@bluemoon, I'm trying what you suggest to do.
Thanks a lot.
[-o< Cross the fingers.

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

Posted: Sun Apr 15, 2012 9:27 am
by denilsson31
Humm ... trying to launch i586-elf-cc and so, fails

I must use CC variable, I guess

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

Posted: Sun Apr 15, 2012 9:58 am
by denilsson31
No way : Makefile still invokes i586-elf-cc

What a story !

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

Posted: Sun Apr 15, 2012 3:43 pm
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.

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

Posted: Sun Apr 15, 2012 3:57 pm
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.

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

Posted: Sun Apr 15, 2012 10:36 pm
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...