Commit graph

11 commits

Author SHA1 Message Date
riastradh
a649e3b771 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.
2022-04-10 19:54:02 +00:00
riastradh
d8bc697ded mk: For cross-builds, use work.$ARCH and packages.$ARCH by default.
Otherwise it is mandatory to set these in mk.conf anyway, so let's
save the trouble.
2022-04-04 11:23:18 +00:00
riastradh
a1abd9761c mk: Cross-eyed hacks to support cross-libtool.
For a long time, when cross-building, say from native=amd64 to
target=powerpc, it was necessary to:

1. cross-build a _powerpc_ package called cross-libtool-base-powerpc,
   and then

2. install the powerpc package _natively_ with `pkg_add -m x86_64' to
   override the architecture check that normally forbids this kind of
   shenanigans,

in order to cross-build anything that uses libtool as a tool.

This is partly because libtool doesn't follow the normal GNU
convention of `./configure --build=<native platform> --host=<platform
package will run on> --target=<platform package is configured to
operate on>' -- in this example, build=amd64, host=amd64,
target=powerpc.

Instead, libtool expects to be cross-built itself, even if it's going
to run as a tool.  It's not as bonkers as it sounds at first: libtool
is just a shell script, and it caches various information about the
(cross-building!) toolchain it is built with so it can use that
information later when it is run as a tool itself to cross-compile
other software.

To make this work, we need to create the toolchain wrappers for
libtool _as if_ we were cross-building even if we are building a
native package.  So mk/tools uses a new flag TOOLS_USE_CROSS_COMPILE
instead of USE_CROSS_COMPILE, and libtool internally sets
MACHINE_ARCH=${TARGET_ARCH} (in the example above, powerpc) to make
it look like we're cross-building.  The new TOOLS_CROSS_DESTDIR is an
alias for the (defaulted) CROSS_DESTDIR, which must now be set
unconditionally in mk.conf in order for libtool to know where the
cross-destdir will be; _CROSS_DESTDIR remains empty when building any
native packages (including the native cross-libtool package).

Finally, we need to make the resulting package be a native package,
with MACHINE_ARCH set to the one that it will be installed on (in the
example above, amd64), so I added an indirection _BUILD_DEFS.${var}
to replace var on its own in the build definitions that get baked
into the package, shown by `pkg_info -B'.  Setting
_BUILD_DEFS.MACHINE_ARCH=${NATIVE_MACHINE_ARCH} ensures that this
mutant hybrid cross-built libtool still produces a native package.

All of this logic is gated on setting USE_CROSS_COMPILE in mk.conf or
LIBTOOL_CROSS_COMPILE in the package makefile, so it should be safe
for non-cross-builds -- when USE_CROSS_COMPILE=no and you're not
building cross-libtool, everything is as before.
2022-04-04 11:23:06 +00:00
riastradh
81729c2501 cwrappers: Add cross-compilation support.
- New option `sysroot=<dir>':
  . Wrapper will add `--sysroot=<dir>' as first argument.
  . For every rpath argument, e.g. -Wl,-R<path> to cc, wrapper will
    pass `-rpath-link <dir><path>' to the linker.
  This matches the old mk/wrapper/cmd-sink-cross-* logic.

- Create wrappers for the ${MACHINE_GNU_PLATFORM}-cc style of command,
  as in ${CC}, ${CXX}, ${LD} for cross-builds.

- Bump version.

- Use TOOL_DEPENDS, not BUILD_DEPENDS, for cwrappers.
2022-04-04 11:22:50 +00:00
riastradh
9551dea8e3 Note that USE_CWRAPPERS=no is needed for now in cross-compiling.
This is a bug, just need to teach cwrappers about passing sysroot.
2019-07-09 15:45:35 +00:00
riastradh
f36aab5cd5 Sync cross-libtool-base with libtool-base. Eliminate CROSSBASE.
cross-libtool-base now installs into $PREFIX/cross-$TARGET_ARCH
unconditionally.
2019-07-09 15:45:25 +00:00
kamil
9984914689 Fix path to cross-libtool-base in HOWTO 2017-03-05 10:36:40 +00:00
riastradh
e9eb06fc0a Fix two more tooldir punctuations. 2016-05-04 02:05:22 +00:00
riastradh
4d910c9346 Fix tooldir name punctuation to match NetBSD build.sh default. 2016-05-04 02:03:13 +00:00
riastradh
fd0a490387 Add $NetBSD$ tags to HOWTO-use-crosscompile & HOWTO-dev-crosscompile. 2013-05-11 20:15:10 +00:00
riastradh
31391265c5 Add some notes on how to use and develop cross-compiled packages.
ok agc
2013-05-10 00:03:46 +00:00