Subject: turning linker options into an environment variable with buildlink3
To: None <>
From: Klaus Heinz <>
List: tech-pkg
Date: 04/20/2004 02:15:03

the native linker on Unixware does not provide an option to specify
the library search paths to be recorded in the executable. It knows "-L"
but not "-R". The only way to do it is through the environment variable

So I need to turn the library options given to gcc or ld (I will set
_USE_RPATH=yes and _OPSYS_RPATH_NAME=-R in into this

To test that this is feasible I changed buildcmd and in
mk/buildlink3/ like this

  --- buildcmd.orig       Sat Jan 31 19:14:48 2004
  +++ buildcmd    Tue Apr 20 01:25:35 2004
  @@ -24,6 +24,12 @@
                  # they're given.  All other instances are redundant.
                  case $arg in
  +               -R*)
  +                       _BLNK_LD_RUN_PATH="${_BLNK_LD_RUN_PATH}:${arg#-R}"
  +                       ;;
  +               -Wl,-R*)
  +                       _BLNK_LD_RUN_PATH="${_BLNK_LD_RUN_PATH}:${arg#-Wl,-R}"
  +                       ;;
                          case "$ldflags" in
                          *" "$arg|*" "$arg" "*)     ;;

  ---     Sat Feb 14 01:03:08 2004
  +++  Tue Apr 20 01:24:52 2004
  @@ -88,8 +88,12 @@

   cmd="$cmd $ldflags $libs"

  +if [ -n "${_BLNK_LD_RUN_PATH}" ]; then
  +       LD_RUN_PATH=${_BLNK_LD_RUN_PATH#:}
  +       export LD_RUN_PATH

  -$echo "<.>" $cmd >> $wrapperlog
  +$echo "<.>" LD_RUN_PATH=\"${LD_RUN_PATH}\" $cmd >> $wrapperlog
   eval exec $cmd

I could successfully build devel/patch and /opt/pkg/lib was recorded in the
ELF header.

The final patch will look a bit different but I need help to do it right.

- Obviously I need buildlink3 for this, but there are some (many?)
  packages still using buildlink2 (or not using any buildlink framwwork
  at all). Incidentally devel/patch is one of them. Is it intended to
  convert _every_ package to buildlink3?

- Is buildcmd/ the right place or is there some better way to
  achieve the desired result?

- Is it ok to alter the files so all wrappers will
  end up with the changes or should I try to restrict this to the cc/gcc
  and ld wrappers?

- Since this is a special case only needed for Unixware I think about
  creating and checking for${OPSYS} in
  Should I avoid duplicating the files and create appropriate @_BLNK_...@
  variables instead, to be filled in with the code (on Unixware) or
  nothing (all other systems) in the original files