pkgsrc-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

pkg/57685: Pkgsrc bootstrap does not correctly apply custom LDFLAGS to binaries



>Number:         57685
>Category:       pkg
>Synopsis:       Pkgsrc bootstrap does not  correctly apply custom LDFLAGS to binaries
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    pkg-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Nov 07 12:20:00 +0000 2023
>Originator:     Sad Clouds
>Release:        pkgsrc-2023Q3
>Organization:
>Environment:
SunOS pkgsrc 5.11 11.3 sun4v sparc SUNW,SPARC-Enterprise-T5220
>Description:
I have a custom GCC compiler installed under /opt/gcc-13.2.0/

I use the following script to bootstrap pkgsrc:

MAKE_JOBS=64
GCC_VER="13.2.0"
GCC_BASE="/opt/gcc-${GCC_VER:?}"
NETBSD_BASE="/opt/netbsd"
PKGSRC_VER="2023Q3"
PKGSRC_BASE="${NETBSD_BASE:?}/pkgsrc-${PKGSRC_VER:?}"
PKG_BASE="/opt/pkg-${PKGSRC_VER:?}"
PATH="${GCC_BASE:?}/bin:${GCC_BASE:?}/devutils/bin:${PKG_BASE:?}/bin:${PKG_BASE:?}/sbin:/bin:/usr/bin:/sbin:/usr/sbin"
export PATH

env \
MAKECONF="" \
DISTDIR="${NETBSD_BASE:?}/pkg.distfiles" \
PKGSRC_COMPILER=gcc \
USE_NATIVE_GCC=yes \
CC=gcc \
CXX=g++ \
CFLAGS="-O2 -mcpu=v9" \
CXXFLAGS="-O2 -mcpu=v9" \
LDFLAGS="\
-L${GCC_BASE:?}/lib \
-R${GCC_BASE:?}/lib \
-L${GCC_BASE:?}/lib/sparcv9 \
-R${GCC_BASE:?}/lib/sparcv9" \
"${PKGSRC_BASE:?}/bootstrap/bootstrap" \
--prefer-pkgsrc yes \
--make-jobs "${MAKE_JOBS:?}" \
--workdir "${NETBSD_BASE:?}/pkg.objects/bootstrap" \
--prefix "${PKG_BASE:?}" \
--pkgdbdir "${PKG_BASE:?}/db/pkg"

However LDFLAGS are not applied correctly and bootstrap binaries reference wrong GCC libssp.so under /usr/lib/64

# ldd /opt/pkg-2023Q3/bin/bmake
        libssp.so.0 =>   /usr/lib/64/libssp.so.0
        libc.so.1 =>     /lib/64/libc.so.1

# elfdump -d /opt/pkg-2023Q3/bin/bmake | grep PATH
      [4]  RUNPATH         0x1c12       /opt/pkg-2023Q3/lib
      [5]  RPATH           0x1c12       /opt/pkg-2023Q3/lib

So my custom RPATH is stripped and only pkgsrc lib remains there.
>How-To-Repeat:

>Fix:
Workaround is to create the following GCC wrappers:

# cat /tmp/gcc /tmp/g++
#!/bin/sh
GCC_BASE="/opt/gcc-13.2.0"
exec ${GCC_BASE:?}/bin/gcc "$@" \
  -L${GCC_BASE:?}/lib -R${GCC_BASE:?}/lib \
  -L${GCC_BASE:?}/lib/sparcv9 -R${GCC_BASE:?}/lib/sparcv9
#!/bin/sh
GCC_BASE="/opt/gcc-13.2.0"
exec ${GCC_BASE:?}/bin/g++ "$@" \
  -L${GCC_BASE:?}/lib -R${GCC_BASE:?}/lib \
  -L${GCC_BASE:?}/lib/sparcv9 -R${GCC_BASE:?}/lib/sparcv9

This results in correct linkage:
# ldd /opt/pkg-2023Q3/bin/bmake
        libssp.so.0 =>   /opt/gcc-13.2.0/lib/sparcv9/libssp.so.0
        libc.so.1 =>     /lib/64/libc.so.1

However, pkgsrc make files need proper fix in order to correctly use custom LDFLAGS.

PS. I have used GCC wrapper scripts for years with pkgsrc, due to these types of issues, but recently decided to try LDFLAGS again, hoping this was fixed. Alas, the issue is still there.



Home | Main Index | Thread Index | Old Index