mk: Use CWRAPPERS_PREPEND for --sysroot.

Looks like maybe the -Wl,-rpath-link business isn't necessary after
all -- will leave this as is until I find evidence otherwise.  (joerg
says it was a workaround for NetBSD toolchain parts that weren't
properly adapted to use sysroot.)

With this, revert cwrappers version dependency to what it was before.
But keep it as TOOL_DEPENDS, not BUILD_DEPENDS.
This commit is contained in:
riastradh 2022-04-10 19:54:02 +00:00
parent a64ed5a9a2
commit a649e3b771
3 changed files with 33 additions and 11 deletions

View file

@ -1,7 +1,7 @@
Cross-compilation in pkgsrc (user's guide) -*- outline -*-
Taylor R. Campbell <riastradh@NetBSD.org>
$NetBSD: HOWTO-use-crosscompile,v 1.10 2022/04/04 11:23:18 riastradh Exp $
$NetBSD: HOWTO-use-crosscompile,v 1.11 2022/04/10 19:54:02 riastradh Exp $
The following steps enable you to build binary packages for a machine
architecture other than the one you are building on. For example, you
@ -61,14 +61,30 @@ In addition to whatever else you want in your mk.conf for pkgsrc, add:
MACHINE_ARCH= powerpc
.endif
You can bootstrap pkgsrc or not; it shouldn't make a difference for
cross-compilation. If you do, replace `make' by `bmake' below, of
course.
XXX Some variables, notably LOCALBASE and other paths that get baked
into packages, cannot currently be set differently for native and
target packages.
** Bootstrapped pkgsrc
You can bootstrap pkgsrc or not; it shouldn't make a difference for
cross-compilation. If you do:
- Replace `make' by `bmake' below.
- Make sure any ABI setting in mk.conf is conditionally set
appropriately.
For example, bootstrap on amd64 leaves ABI=64 in mk.conf, which must
be left empty or undefined for earmv7hf cross-builds. So you might
need:
.if empty(USE_CROSS_COMPILE:M[yY][eE][sS])
ABI= 64 # set for native amd64 build
.else
ABI= # empty for earmv7hf cross-build
.endif
* Make some packages
Now packages you build normally will be cross-compiled for the target:

View file

@ -1,4 +1,4 @@
# $NetBSD: compiler.mk,v 1.96 2021/12/03 07:40:26 wiz Exp $
# $NetBSD: compiler.mk,v 1.97 2022/04/10 19:54:02 riastradh Exp $
#
# This Makefile fragment implements handling for supported C/C++/Fortran
# compilers.
@ -220,6 +220,15 @@ _WRAP_EXTRA_ARGS.CC+= ${_CTF_CFLAGS}
CWRAPPERS_APPEND.cc+= ${_CTF_CFLAGS}
.endif
# Add sysroot if using cross-compilation tools.
#
.if !empty(TOOLS_USE_CROSS_COMPILE:M[yY][eE][sS])
CWRAPPERS_PREPEND.cc+= --sysroot=${TOOLS_CROSS_DESTDIR:Q}
CWRAPPERS_PREPEND.cxx+= --sysroot=${TOOLS_CROSS_DESTDIR:Q}
CWRAPPERS_PREPEND.ld+= --sysroot=${TOOLS_CROSS_DESTDIR:Q}
# XXX cross fortran
.endif
# If the languages are not requested, force them not to be available
# in the generated wrappers.
#

View file

@ -1,11 +1,11 @@
# $NetBSD: cwrappers.mk,v 1.35 2022/04/04 11:23:06 riastradh Exp $
# $NetBSD: cwrappers.mk,v 1.36 2022/04/10 19:54:02 riastradh Exp $
#
# This Makefile fragment implements integration of pkgtools/cwrappers.
.include "../../mk/wrapper/wrapper-defs.mk"
.include "../../mk/buildlink3/bsd.buildlink3.mk"
TOOL_DEPENDS+= cwrappers>=20220403:../../pkgtools/cwrappers
TOOL_DEPENDS+= cwrappers>=20150314:../../pkgtools/cwrappers
# XXX This should be PREFIX, but USE_CROSSBASE overrides it.
CWRAPPERS_SRC_DIR= ${LOCALBASE}/libexec/cwrappers
@ -101,9 +101,6 @@ generate-cwrappers:
. endfor
. endif
. endif
. if !empty(TOOLS_USE_CROSS_COMPILE:M[yY][eE][sS])
${RUN}echo sysroot=${TOOLS_CROSS_DESTDIR:Q} >> ${CWRAPPERS_CONFIG_DIR}/${CWRAPPERS_CONFIG.${wrappee}}
. endif
.endfor
PREPEND_PATH+= ${WRAPPER_BINDIR}