[GRASS-dev] [GRASS GIS] #1757: LD_SEARCH_FLAGS incorrect for NetBSD

#1757: LD_SEARCH_FLAGS incorrect for NetBSD
-------------------------+--------------------------------------------------
Reporter: brook | Owner: grass-dev@…
     Type: defect | Status: new
Priority: critical | Milestone: 6.4.3
Component: Default | Version: 6.4.2
Keywords: | Platform: Other Unix
      Cpu: Unspecified |
-------------------------+--------------------------------------------------
The value of LD_SEARCH_FLAGS in include/Make/Platform.make for NetBSD is
incorrect. Rather than just -rpath it should be -Wl,-rpath.

The necessary patches against the 6.4.2 release are attached; these have
been compile tested. Since they only affect NetBSD systems, there should
be no risk applying them and pulling them up to more recent versions.

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/1757&gt;
GRASS GIS <http://grass.osgeo.org>

#1757: LD_SEARCH_FLAGS incorrect for NetBSD
-------------------------+--------------------------------------------------
Reporter: brook | Owner: grass-dev@…
     Type: defect | Status: new
Priority: critical | Milestone: 7.0.0
Component: Default | Version: svn-trunk
Keywords: | Platform: Other Unix
      Cpu: Unspecified |
-------------------------+--------------------------------------------------
Changes (by neteler):

  * version: 6.4.2 => svn-trunk
  * milestone: 6.4.3 => 7.0.0

Comment:

Thanks, fixed for G6.4 and 6.5 in r53323 and r53324.

No idea about GRASS 7's aclocal.m4 which has a different structure.

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/1757#comment:1&gt;
GRASS GIS <http://grass.osgeo.org>

#1757: LD_SEARCH_FLAGS incorrect for NetBSD
-------------------------+--------------------------------------------------
Reporter: brook | Owner: grass-dev@…
     Type: defect | Status: new
Priority: critical | Milestone: 7.0.0
Component: Default | Version: svn-trunk
Keywords: | Platform: Other Unix
      Cpu: Unspecified |
-------------------------+--------------------------------------------------

Comment(by glynn):

Replying to [comment:1 neteler]:

> No idea about GRASS 7's aclocal.m4 which has a different structure.

7.0 doesn't support any BSD systems yet. New platforms need to be added by
people who actually have access to (and preferably knowledge of) the
platform in question.

The platforms currently supported in 7.0 are:
{{{
*-linux-*
*-pc-cygwin
*-pc-mingw32
*-apple-darwin*
*-sun-solaris*
}}}
Also, the Solaris section is hearsay (copied verbatim from 6.x).

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/1757#comment:2&gt;
GRASS GIS <http://grass.osgeo.org>

#1757: LD_SEARCH_FLAGS incorrect for NetBSD
-------------------------+--------------------------------------------------
Reporter: brook | Owner: grass-dev@…
     Type: defect | Status: new
Priority: critical | Milestone: 7.0.0
Component: Default | Version: svn-trunk
Keywords: | Platform: Other Unix
      Cpu: Unspecified |
-------------------------+--------------------------------------------------

Comment(by mmetz):

Replying to [comment:2 glynn]:
> 7.0 doesn't support any BSD systems yet. New platforms need to be added
by people who actually have access to (and preferably knowledge of) the
platform in question.

7.0 supports now FreeBSD.

However, I do not get 7.0 compiled on NetBSD 6.0.1, the error is

{{{
ld: unrecognized option '-Wl,-rpath,/home/metz/src/grass-7.0.svn/dist.i386
-unknown-netbsdelf6.0.1/lib'
}}}

ld is GNU ld (NetBSD Binutils nb1) 2.21.1

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/1757#comment:3&gt;
GRASS GIS <http://grass.osgeo.org>

#1757: LD_SEARCH_FLAGS incorrect for NetBSD
-------------------------+--------------------------------------------------
Reporter: brook | Owner: grass-dev@…
     Type: defect | Status: new
Priority: critical | Milestone: 7.0.0
Component: Default | Version: svn-trunk
Keywords: | Platform: Other Unix
      Cpu: Unspecified |
-------------------------+--------------------------------------------------

Comment(by glynn):

Replying to [comment:3 mmetz]:
> Replying to [comment:2 glynn]:
> > 7.0 doesn't support any BSD systems yet. New platforms need to be
added by people who actually have access to (and preferably knowledge of)
the platform in question.

> However, I do not get 7.0 compiled on NetBSD 6.0.1, the error is
>
{{{
ld: unrecognized option '-Wl,-rpath,/home/metz/src/grass-7.0.svn/dist.i386
-unknown-netbsdelf6.0.1/lib'
}}}

Do NetBSD shared libraries support rpath? If not, the linker probably
won't accept the switch.

Also, -rpath is bad, as it hard-codes library paths, overriding
LD_LIBRARY_PATH (and it will probably result in hard-coding the build
directory into the installed binaries). -rpath-link is preferable, as that
just sets the path for dependency checking without storing it in the
binary.

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/1757#comment:4&gt;
GRASS GIS <http://grass.osgeo.org>

#1757: LD_SEARCH_FLAGS incorrect for NetBSD
-------------------------+--------------------------------------------------
Reporter: brook | Owner: grass-dev@…
     Type: defect | Status: new
Priority: critical | Milestone: 7.0.0
Component: Default | Version: svn-trunk
Keywords: | Platform: Other Unix
      Cpu: Unspecified |
-------------------------+--------------------------------------------------

Comment(by mmetz):

Replying to [comment:4 glynn]:
> Replying to [comment:3 mmetz]:
> > Replying to [comment:2 glynn]:
> > > 7.0 doesn't support any BSD systems yet. New platforms need to be
added by people who actually have access to (and preferably knowledge of)
the platform in question.
>
> > However, I do not get 7.0 compiled on NetBSD 6.0.1, the error is
> >
{{{
ld: unrecognized option '-Wl,-rpath,/home/metz/src/grass-7.0.svn/dist.i386
-unknown-netbsdelf6.0.1/lib'
}}}
>
> Do NetBSD shared libraries support rpath? If not, the linker probably
won't accept the switch.

Yes, NetBSD shared libraries support rpath.
>
> Also, -rpath is bad, as it hard-codes library paths, overriding
LD_LIBRARY_PATH (and it will probably result in hard-coding the build
directory into the installed binaries). -rpath-link is preferable, as that
just sets the path for dependency checking without storing it in the
binary.

NetBSD is a bit difficult, I have to check. Some more insights from
working with NetBSD:

I think I discovered inconsistencies, if not errors, in the G7 Make
system: flags meant for cc are also passed to ld and vice versa, probably
because it is assumed that ld = cc. For example, linking flags for cc must
have the form
{{{
-Wl,-rpath,${LIB_RUNTIME_DIR}
}}}

the equivalent to ld, if ld != cc, is

{{{
-rpath ${LIB_RUNTIME_DIR}
}}}

But Shlib.make does
{{{
LDFLAGS += $(SHLIB_LDFLAGS)
}}}
even though LDFLAGS are meant for cc and SHLIB_LDFLAGS are meant for ld,
at least aclocal.m4 says so. Shlib.make might also need LD_SEARCH_FLAGS.

Grass.make does
{{{
LDFLAGS = $(LIBPATH) $(LINK_FLAGS) $(LD_SEARCH_FLAGS)
}}}
even though LDFLAGS are meant for cc and LD_SEARCH_FLAGS are meant for ld,
at least aclocal.m4 says so.

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/1757#comment:5&gt;
GRASS GIS <http://grass.osgeo.org>

#1757: LD_SEARCH_FLAGS incorrect for NetBSD
-------------------------+--------------------------------------------------
Reporter: brook | Owner: grass-dev@…
     Type: defect | Status: new
Priority: critical | Milestone: 7.0.0
Component: Default | Version: svn-trunk
Keywords: | Platform: Other Unix
      Cpu: Unspecified |
-------------------------+--------------------------------------------------

Comment(by glynn):

Replying to [comment:5 mmetz]:

> I think I discovered inconsistencies, if not errors, in the G7 Make
system: flags meant for cc are also passed to ld and vice versa, probably
because it is assumed that ld = cc.

Programs written in C are linked with $(CC). Programs written in C++ are
linked with $(CXX). Shared libraries are linked with $(SHLIB_LD). All
three are passed $(LDFLAGS). $(SHLIB_LD) is additionally passed
$(SHLIB_LDFLAGS).

In practical terms, this requires that both programs and shared libraries
are linked using the compiler front-end. The build system doesn't use
$(LD) (which is normally the underlying linker).

The main problem with separating the two is that configure doesn't attempt
to maintain any distinction, e.g. it only has one LDFLAGS variable.
Simlarly, "pkg-config --libs ..." will generate switches suitable for
passing to the compiler (i.e. with the -Wl, prefix).

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/1757#comment:6&gt;
GRASS GIS <http://grass.osgeo.org>

#1757: LD_SEARCH_FLAGS incorrect for NetBSD
-------------------------+--------------------------------------------------
Reporter: brook | Owner: grass-dev@…
     Type: defect | Status: new
Priority: critical | Milestone: 7.0.0
Component: Default | Version: svn-trunk
Keywords: | Platform: Other Unix
      Cpu: Unspecified |
-------------------------+--------------------------------------------------

Comment(by mmetz):

Replying to [comment:6 glynn]:
> Replying to [comment:5 mmetz]:
>
> > I think I discovered inconsistencies, if not errors, in the G7 Make
system: flags meant for cc are also passed to ld and vice versa, probably
because it is assumed that ld = cc.
>
> Programs written in C are linked with $(CC). Programs written in C++ are
linked with $(CXX). Shared libraries are linked with $(SHLIB_LD). All
three are passed $(LDFLAGS). $(SHLIB_LD) is additionally passed
$(SHLIB_LDFLAGS).

In this case the documentation in aclocal.m4 needs to be updated, because
there flags for building shared libraries are separate from flags for
building and linking programs.

In any case, with SHLIB_LD="${CC} -shared" I got G7 compiled and running
on NetBSD 6.

Markus M

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/1757#comment:7&gt;
GRASS GIS <http://grass.osgeo.org>

#1757: LD_SEARCH_FLAGS incorrect for NetBSD
-------------------------+--------------------------------------------------
Reporter: brook | Owner: grass-dev@…
     Type: defect | Status: new
Priority: critical | Milestone: 7.0.0
Component: Default | Version: svn-trunk
Keywords: | Platform: Other Unix
      Cpu: Unspecified |
-------------------------+--------------------------------------------------

Comment(by mlennert):

Is this still an open ticket ?

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/1757#comment:8&gt;
GRASS GIS <http://grass.osgeo.org>

#1757: LD_SEARCH_FLAGS incorrect for NetBSD
-------------------------+--------------------------------------------------
  Reporter: brook | Owner: grass-dev@…
      Type: defect | Status: closed
  Priority: critical | Milestone: 7.0.0
Component: Default | Version: svn-trunk
Resolution: fixed | Keywords:
  Platform: Other Unix | Cpu: Unspecified
-------------------------+--------------------------------------------------
Changes (by mmetz):

  * status: new => closed
  * resolution: => fixed

Comment:

Replying to [comment:8 mlennert]:
> Is this still an open ticket ?

The configure script has been updated accordingly. G7 compiles and runs
fine for me on NetBSD 6. Closing ticket.

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/1757#comment:9&gt;
GRASS GIS <http://grass.osgeo.org>