From ripley at stats.ox.ac.uk  Wed May 17 18:49:49 2006
From: ripley at stats.ox.ac.uk (Prof Brian Ripley)
Date: Wed, 17 May 2006 17:49:49 +0100 (BST)
Subject: [Rd] R CMD SHLIB
In-Reply-To: <Pine.GSO.4.56.0605170934570.17220@durian.statsci.com>
References: <Pine.LNX.4.64.0605161737400.20542@gannet.stats.ox.ac.uk>
	<Pine.LNX.4.64.0605161013270.30229@homer22.u.washington.edu>
	<17514.50498.635200.940425@stat.math.ethz.ch>
	<Pine.GSO.4.56.0605170934570.17220@durian.statsci.com>
Message-ID: <Pine.LNX.4.64.0605171746510.30505@gannet.stats.ox.ac.uk>

On Wed, 17 May 2006, Bill Dunlap wrote:

> On Wed, 17 May 2006, Martin Maechler wrote:
>
>>>>>>> "TL" == Thomas Lumley <tlumley at u.washington.edu>
>>>>>>>     on Tue, 16 May 2006 10:15:11 -0700 (PDT) writes:
>>
>>     TL> On Tue, 16 May 2006, Prof Brian Ripley wrote:
>>    >> It is possible to do things like
>>    >>
>>    >> env PKG_LIB="-L/opt/foo/lib -lbar" R CMD SHLIB *.c
>>    >>
>>    >> to add libraries to the creation of a shared object, but
>>    >> I have from time to time wondered if we should allow
>>    >>
>>    >> R CMD SHLIB *.c -L/opt/foo/lib -lbar
>>    >>
>>    >> not least as users seems to expect it to work.  It looks
>>    >> simple to do (at least under Unix) if we pass -L* -l* *.a
>>    >> directly to the link command.
>>    >>
>>    >> Would this be worthwhile?
>>
>>     TL> Yes.
>>
>>     TL> My only reservation is that users may then expect all
>>     TL> compiler/linker flags to work, not just -L/-l
>>
>> I had exactly the same thought.
>>
>> Maybe Brian's proposal can be extended into
>>
>>   "all switches that are not recognized by 'R CMD SHLIB' are
>>    passed to compiler / linker  ...."
>>
>> hmm, or maybe not, since the question quickly become *which* are
>> passed to compiler and which to linker (and which to both ?) ...
>
> I'd rather have SHLIB complain if it sees a -flag
> that SHLIB doesn't recognize.  Otherwise we get
> portability problems.  E.g., when using the Microsoft
> C compiler and linker a SHLIB that knows about the
> -l and -L flags can translate
>    -lfoo -L/dir/subdir
> into LDFLAGS that link.exe knows about:
>    foo.lib /libpath:\dir\subdir
>
> If you need other linker flags, could they be in compiler/platform-
> specific Makevars-<compiler/platform>?  I think other
> ones are not very common.

In R, we are not dealing with such compilers/linkers (fortunately). Given 
that there are plenty of ways to hang oneself here, I do not want to be 
unduly restrictive as to what one can pass.  (All the autoconf etc 
mechanisms assume flags like -L and -l, and also that some reordering is 
done by the frontends.)

> ----------------------------------------------------------------------------
> Bill Dunlap
> Insightful Corporation
> bill at insightful dot com
> 360-428-8146
>
> "All statements in this message represent the opinions of the author and do
> not necessarily reflect Insightful Corporation policy or position."
>
>

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



[Rd] R CMD SHLIB
Prof Brian Ripley