Project Home
Project Home
Source Code
Source Code
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - Magic, black or white?: (3 Items)
   
Magic, black or white?  
A while back Xiodian made a remark about magic that goes on in bmake.
Well it is pretty difficult to figure out what is going on in there, what with includes inside of includes and all.  

I've easily spent two days tracking down something that goes on in there, and now that I've found it, I think I need to 
sit back and ask some questions, because what I found is really screwy.

The problem starts out that when running bmake for lang/php5,
somewhere into the configure script, an if statement goes haywire, and tells the script that our compiler supports a -R 
option, which it doesn't.
A little while later the script stops cold because of this.   If I ran the configure script myself from the work/php***/
 directory, there was no problem, so what was different?

The first thing I found was that the problem was related to env variables being used by bmake to run configure.   
Specifically it was the PATH variable.

Further investigation found that it was the directory work/.wrapper in the PATH>
Even further investigation found that the problem was a script work/.wrapper/cc.   If I remove this cc, there is no 
longer a problem.

So why on earth is pkgsrc interfering in such a low level way, subverting the existing local cc?   There are a number of
 other scripts in this directory, similarly subverting c++, g++, ld, and libtool.    What's especially annoying is that 
this 'cc' script masks an error, that then turns up later.   

Ok, I think I've ranted enough, and I feel better now, but what sort of patch should I be making?   There's no "patch-
delete-file" that I know of. 
Re: Magic, black or white?  
We (I mean people here in QNX, including me) are still not pkgsrc expert yet. :)

Here is my understanding of how it works.

When you try to build a package, say lang/php5, bmake go through several phases. According the pkgsrc doc (chap 17), 
these are:

"fetch", to get the packet on to you machine,  
"checksum", to make sure downloaded package are correct 
"extract", un-tar the package 
"patch", to apply the patch 
"tools",  to make sure tools to build the package are all there
"wrapper", creating the compiler, linker wrapper tools !! 
"configure", really started to run "configure" script 
"build", build the package 
"test", "install", "package"

You can actually "bmake configure" to ask bmake just do the configure for you. except everytime it finish a phase, it 
will create a work/.<phase>_done file, so you need to remove this file to force a re-"configure".

Now back to those magic "wrappers".

pkgsrc setup a environment to build packages, with these wrappers. So work/.wrapper/bin/cc is a shell script, it deals 
with all kinds of cc option, and turns it into whatever option your native compiler would understand. (in our case, qcc)
.

For example, gcc --version would give you the version of the compiler, qcc don't do this, how do you cover the 
difference? The magic is in these wrapper shell scripts, and the "work/.wrapper/tmp/*sind*, *transform* files. 

Sean worked very hard in early days to create these qcc related scripts and files, so the package configure/make 
wouldn't know they are deal with an unknown compiler.

So, qcc don't support -R, but .wrapper/bin/cc does support -R. That's why you always want to bmake at lang/php5, not 
work/php5client-* directory, to let wrappers kick in.

Oh, and also, the work/.work.log let you know the magic command it gone through, so you might dig something useful there
.

Being said all that, we still have a few things we can't cover with the scripts and transform/sink. Sean and I are 
talking, to see if we could go with gcc (instead of qcc) directly. Hopefully, this could make life easier. (mind you, 
even gcc are also have wrappers).

I think I almost get 3.3.5 going, Sean is playing with gcc4, hopefully we will have a solution in a couple of days.
Re: Magic, black or white?  
Xiaodan,

    That actually explains a lot.  It also suggests that the -R problem I was having with the script is revealing a bug 
in the wrapper, so maybe you might want to take a look at it.   My suggestion to delete work/.wrapper/bin/cc is just a 
work around, so if the problem is solved, the build will go all the better.

    I'm not really sure of what to think about the libtool issue.   The libtool that is distributed with php5 gets 
flustered when trying to build the shared library for use with Apache22.   Thankfully the more recent version that is 
part of pkgsrc solves this problem.    The missing php-cgi program is also a bit of a mystery.   I've read elsewhere on 
the net, information that indicates it might be a wrapper for php, but that still doesn't explain while the install 
script is looking for it, but it is not there.

Mitchell