Hello
It looks like a little bug in mkmf.rb
DLDFLAGS comes out empty in the Makefile
There is code that is too complex to for writing just an empty string:
--- ruby-1.8.2/lib/mkmf.rb Tue Sep 7 17:30:59 2004
+++ /sw/src/ruby18-1.8.2-0preview2/ruby-1.8.2/lib/mkmf.rb Tue Sep 7 21:22:21 2004
@@ -738,9 +738,9 @@
LIBRUBYARG_STATIC = #$LIBRUBYARG_STATIC
CFLAGS = #{CONFIG['CCDLFLAGS'] unless $static} #$CFLAGS #$ARCH_FLAG
-CPPFLAGS = -I. -I$(topdir) -I$(hdrdir) -I$(srcdir) #{$defs.join(" ")} #{$CPPFLAGS}
+CPPFLAGS = -I. -I$(topdir) -I$(hdrdir) -I$(srcdir) #{$defs.join(" ")} #{CONFIG['CPPFLAGS']}
CXXFLAGS = $(CFLAGS) #{CONFIG['CXXFLAGS']}
-DLDFLAGS = #$LDFLAGS #$DLDFLAGS #$ARCH_FLAG
+DLDFLAGS = #{CONFIG['LDFLAGS']} #{CONFIG['DLDFLAGS']} #{CONFIG['ARCH_FLAG']}
LDSHARED = #{CONFIG['LDSHARED']}
AR = #{CONFIG['AR']}
EXEEXT = #{CONFIG['EXEEXT']}
Hi,
At Wed, 8 Sep 2004 04:29:41 +0900,
Michal 'hramrach' Suchanek wrote in [ruby-talk:111782]:
It looks like a little bug in mkmf.rb
DLDFLAGS comes out empty in the Makefile
DLDFLAGS is different from LDFLAGS. Use DLDFLAGS to pass
options to the linker for shared objects.
···
--
Nobu Nakada
A better fix adding LDFLAGS also for mkmf link tests:
--- ruby-1.8.2/lib/mkmf.rb~ Tue Sep 7 17:30:59 2004
+++ ruby-1.8.2/lib/mkmf.rb Thu Sep 9 11:08:59 2004
@@ -960,7 +960,7 @@
$CFLAGS = with_config("cflags", arg_config("CFLAGS",
config["CFLAGS"])).dup
$ARCH_FLAG = with_config("arch_flag", arg_config("ARCH_FLAG",
config["ARCH_FLAG"])).dup
$CPPFLAGS = with_config("cppflags", arg_config("CPPFLAGS",
config["CPPFLAGS"])).dup
- $LDFLAGS = (with_config("ldflags") || "").dup
+ $LDFLAGS = with_config("ldflags", arg_config("LDFLAGS",
config["LDFLAGS"])).dup
$INCFLAGS = "-I$(topdir)"
$DLDFLAGS = with_config("dldflags", arg_config("DLDFLAGS",
config["DLDFLAGS"])).dup
$LIBEXT = config['LIBEXT'].dup
Thanks
Michal Suchanek
···
On Wed, Sep 08, 2004 at 04:29:41AM +0900, Michal 'hramrach' Suchanek wrote:
Hello
It looks like a little bug in mkmf.rb
DLDFLAGS comes out empty in the Makefile
There is code that is too complex to for writing just an empty string:
--- ruby-1.8.2/lib/mkmf.rb Tue Sep 7 17:30:59 2004
+++ /sw/src/ruby18-1.8.2-0preview2/ruby-1.8.2/lib/mkmf.rb Tue Sep 7 21:22:21 2004
@@ -738,9 +738,9 @@
LIBRUBYARG_STATIC = #$LIBRUBYARG_STATIC
CFLAGS = #{CONFIG['CCDLFLAGS'] unless $static} #$CFLAGS #$ARCH_FLAG
-CPPFLAGS = -I. -I$(topdir) -I$(hdrdir) -I$(srcdir) #{$defs.join(" ")} #{$CPPFLAGS}
+CPPFLAGS = -I. -I$(topdir) -I$(hdrdir) -I$(srcdir) #{$defs.join(" ")} #{CONFIG['CPPFLAGS']}
CXXFLAGS = $(CFLAGS) #{CONFIG['CXXFLAGS']}
-DLDFLAGS = #$LDFLAGS #$DLDFLAGS #$ARCH_FLAG
+DLDFLAGS = #{CONFIG['LDFLAGS']} #{CONFIG['DLDFLAGS']} #{CONFIG['ARCH_FLAG']}
LDSHARED = #{CONFIG['LDSHARED']}
AR = #{CONFIG['AR']}
EXEEXT = #{CONFIG['EXEEXT']}
I know it is different and I do not use it directly, it is used when
building the bundled ruby extensions.
And the problem is it is empty which is definitely bad given how complex
expression was used to construct the empty string.
Thanks
Michal Suchanek
···
On Wed, Sep 08, 2004 at 10:27:59AM +0900, Nobuyoshi Nakada wrote:
Hi,
At Wed, 8 Sep 2004 04:29:41 +0900,
Michal 'hramrach' Suchanek wrote in [ruby-talk:111782]:
> It looks like a little bug in mkmf.rb
> DLDFLAGS comes out empty in the Makefile
DLDFLAGS is different from LDFLAGS. Use DLDFLAGS to pass
options to the linker for shared objects.
Since nobody seems interested I should probably add some
explanation. I am in the situation that I have some set of libraries in
/usr/lib and other in /somewhere-else/lib.
The libraries in somewhere-else are newer than those in /usr and include
some that are not in /usr at all.
Now I run
CPPFLAGS=/somewhere-else/include LDFLAGS=/somewhere-else/lib ./configure
and make.
The CPPFLAGS are propagated into extension builds (by mkmf.rb) but the
ldflags are not.
One of the problems that results from this is caused by my other change
that removes the -undefined suppress or similar option that causes linker
to ignore unresolved symbols. Now if the lib is not found the extension
won't link.
I am not sure it is possible to suppress undefined symbols on all
platforms and in general I do not like the idea but this is mostly just
a matter of taste.
However, the ldflags aren't passed to test either. So the tests in
extensions will find only the libraries in /usr although they will see
the headers in /somewhere-else. This is going to cause linking with
different library than the one for which headers were included and
failure to detect libraries in /somewhere-else completely.
Thanks
Michal Suchanek
···
On Thu, Sep 09, 2004 at 07:12:03PM +0900, Michal 'hramrach' Suchanek wrote:
A better fix adding LDFLAGS also for mkmf link tests:
--- ruby-1.8.2/lib/mkmf.rb~ Tue Sep 7 17:30:59 2004
+++ ruby-1.8.2/lib/mkmf.rb Thu Sep 9 11:08:59 2004
@@ -960,7 +960,7 @@
$CFLAGS = with_config("cflags", arg_config("CFLAGS",
config["CFLAGS"])).dup
$ARCH_FLAG = with_config("arch_flag", arg_config("ARCH_FLAG",
config["ARCH_FLAG"])).dup
$CPPFLAGS = with_config("cppflags", arg_config("CPPFLAGS",
config["CPPFLAGS"])).dup
- $LDFLAGS = (with_config("ldflags") || "").dup
+ $LDFLAGS = with_config("ldflags", arg_config("LDFLAGS",
config["LDFLAGS"])).dup
$INCFLAGS = "-I$(topdir)"
$DLDFLAGS = with_config("dldflags", arg_config("DLDFLAGS",
config["DLDFLAGS"])).dup
$LIBEXT = config['LIBEXT'].dup
Hi,
At Wed, 8 Sep 2004 23:24:20 +0900,
Michal 'hramrach' Suchanek wrote in [ruby-talk:111872]:
> > It looks like a little bug in mkmf.rb
> > DLDFLAGS comes out empty in the Makefile
>
> DLDFLAGS is different from LDFLAGS. Use DLDFLAGS to pass
> options to the linker for shared objects.
I know it is different and I do not use it directly, it is used when
building the bundled ruby extensions.
And the problem is it is empty which is definitely bad given how complex
expression was used to construct the empty string.
$ ./configure DLDFLAGS="..."
Or, you can override it by --with-dldflags option at running
extconf.rb.
···
--
Nobu Nakada
Hi,
At Sat, 11 Sep 2004 01:10:56 +0900,
Michal 'hramrach' Suchanek wrote in [ruby-talk:112183]:
CPPFLAGS=/somewhere-else/include LDFLAGS=/somewhere-else/lib ./configure
CPPFLAGS=/somewhere-else/include LDFLAGS=/somewhere-else/lib \
DLDFLAGS=/somewhere-else/lib ./configure
···
--
Nobu Nakada
No, you cannot. Or at least should not.
That is the problem.
Look at the original mail with the patch and description. It makes the
DLDFLAGS actually contain something.
Thanks
Michal Suchanek
···
On Thu, Sep 09, 2004 at 11:48:44AM +0900, nobu.nokada@softhome.net wrote:
Hi,
At Wed, 8 Sep 2004 23:24:20 +0900,
Michal 'hramrach' Suchanek wrote in [ruby-talk:111872]:
> > > It looks like a little bug in mkmf.rb
> > > DLDFLAGS comes out empty in the Makefile
> >
> > DLDFLAGS is different from LDFLAGS. Use DLDFLAGS to pass
> > options to the linker for shared objects.
>
> I know it is different and I do not use it directly, it is used when
> building the bundled ruby extensions.
>
> And the problem is it is empty which is definitely bad given how complex
> expression was used to construct the empty string.
$ ./configure DLDFLAGS="..."
Or, you can override it by --with-dldflags option at running
extconf.rb.
You seem to be fixated on DLDFLAGS 
- you should not need that, that's what LDFLAGS are for
- DLDFLAGS are not touched in the later patch
- it is not going to fix the tests and so would not detect libraries in
/somewhere-else because afaict only LDFLAGS are used in the tests and
that are empty without the later patch.
Thanks
Michal Suchanek
···
On Mon, Sep 13, 2004 at 01:02:05AM +0900, nobu.nokada@softhome.net wrote:
Hi,
At Sat, 11 Sep 2004 01:10:56 +0900,
Michal 'hramrach' Suchanek wrote in [ruby-talk:112183]:
> CPPFLAGS=/somewhere-else/include LDFLAGS=/somewhere-else/lib ./configure
CPPFLAGS=/somewhere-else/include LDFLAGS=/somewhere-else/lib \
DLDFLAGS=/somewhere-else/lib ./configure