The NetBSD Project

CVS log for pkgsrc/doc/HOWTO-use-crosscompile

[BACK] Up to [cvs.NetBSD.org] / pkgsrc / doc

Request diff between arbitrary revisions


Keyword substitution: kv
Default branch: MAIN


Revision 1.19: download - view: text, markup, annotated - select for diffs
Wed Oct 21 04:55:20 2026 UTC (3 weeks, 5 days ago) by riastradh
Branches: MAIN
CVS tags: HEAD
Diff to: previous 1.18: preferred, colored
Changes since revision 1.18: +2 -2 lines
doc/HOWTO-use-crosscompile: Fix default $PACKAGES.

Revision 1.18: download - view: text, markup, annotated - select for diffs
Thu Jun 6 02:38:02 2024 UTC (2 years, 5 months ago) by riastradh
Branches: MAIN
CVS tags: pkgsrc-2026Q3-base, pkgsrc-2026Q3, pkgsrc-2026Q2-base, pkgsrc-2026Q2, pkgsrc-2026Q1-base, pkgsrc-2026Q1, pkgsrc-2025Q4-base, pkgsrc-2025Q4, pkgsrc-2025Q3-base, pkgsrc-2025Q3, pkgsrc-2025Q2-base, pkgsrc-2025Q2, pkgsrc-2025Q1-base, pkgsrc-2025Q1, pkgsrc-2024Q4-base, pkgsrc-2024Q4, pkgsrc-2024Q3-base, pkgsrc-2024Q3, pkgsrc-2024Q2-base, pkgsrc-2024Q2
Diff to: previous 1.17: preferred, colored
Changes since revision 1.17: +2 -17 lines
doc/HOWTO-use-crosscompile: Nix obsolete note about ABI.

CROSS_ABI has obsoleted it.  Should maybe document that too but it's
such a niche thing that I didn't feel inclined to work out all the
details of its semantics and intended use-cases.

Revision 1.17: download - view: text, markup, annotated - select for diffs
Thu May 16 15:48:46 2024 UTC (2 years, 6 months ago) by riastradh
Branches: MAIN
Diff to: previous 1.16: preferred, colored
Changes since revision 1.16: +2 -1 lines
doc/HOWTO-use-crosscompile: Note CROSS_OBJECT_FMT.

Revision 1.16: download - view: text, markup, annotated - select for diffs
Thu May 16 13:21:22 2024 UTC (2 years, 6 months ago) by riastradh
Branches: MAIN
Diff to: previous 1.15: preferred, colored
Changes since revision 1.15: +4 -3 lines
doc/HOWTO-use-crosscompile: Fix confusing comment in example mk.conf.

Revision 1.15: download - view: text, markup, annotated - select for diffs
Fri Apr 12 19:57:06 2024 UTC (2 years, 7 months ago) by riastradh
Branches: MAIN
Diff to: previous 1.14: preferred, colored
Changes since revision 1.14: +7 -11 lines
doc/HOWTO-use-crosscompile: `make USE_CROSS_COMPILE=yes' works now.

At least, it seems to!  Not sure what symptom I saw ages ago when I
warned users against it.

Revision 1.14: download - view: text, markup, annotated - select for diffs
Fri Apr 12 19:56:03 2024 UTC (2 years, 7 months ago) by riastradh
Branches: MAIN
Diff to: previous 1.13: preferred, colored
Changes since revision 1.13: +14 -5 lines
bsd.prefs.mk: New CROSS_VARBASE and CROSS_SYSCONFBASE.

These default to /var and /etc, respectively.

When cross-building packages, VARBASE and SYSCONFBASE are set to
these instead of whatever they were set to in mk.conf.

No change to native builds because use of these variables is
conditional on USE_CROSS_COMPILE = yes.

Revision 1.13: download - view: text, markup, annotated - select for diffs
Fri Apr 12 19:53:25 2024 UTC (2 years, 7 months ago) by riastradh
Branches: MAIN
Diff to: previous 1.12: preferred, colored
Changes since revision 1.12: +18 -17 lines
mk: New CROSS_* variable scheme for cross-compilation.

This change brings in support for cross-OS-compilation.

Caveat: Existing mk.conf files used for cross-compilation no longer
work; they must be adapted to the new scheme.

Under this new scheme, if an mk.conf variable X can be different for
native and cross builds like OPSYS, MACHINE_ARCH, LOCALBASE, &c., you
just define X in mk.conf to set it for native builds, and CROSS_X in
mk.conf to set it for cross builds.

Example:

    LOCALBASE=		/home/riastradh/pkgsrc/cross/pkg
    CROSS_LOCALBASE=	/opt/pkg
    CROSS_MACHINE_ARCH=	powerpc

For now, _all_ OS-related variables must be defined in cross-builds;
none are filled in automatically.  For NetBSD, this means:

    CROSS_OPSYS=		NetBSD
    CROSS_OS_VERSION=		10.0
    CROSS_OPSYS_VERSION=	100000
    CROSS_LOWER_OPSYS=		netbsd
    CROSS_LOWER_OPSYS_VERSUFFIX=# empty
    CROSS_LOWER_OS_VARIANT=	# empty
    CROSS_LOWER_VARIANT_VERSION=# empty
    CROSS_LOWER_VENDOR=		# empty

This new scheme may raise make(1) costs by making a lot of variables
like OPSYS expand to conditionals rather than fixed strings.  It is
difficult to make these fixed strings because:

- they can only be committed _after_ mk.conf is loaded, before which
  USE_CROSS_COMPILE isn't yet determined, but

- the conditionals must be applied _before_ the rest of bsd.own.mk
  which uses these variables.

So we can't just have conditionals in bsd.prefs.mk after loading
bsd.own.mk -- we would need to put the conditionals in the middle of
bsd.own.mk between loading mk.conf and everything else.

As a followup commit, we can consider committing the variables after
bsd.own.mk as an optimization so that the conditional expansions are
only used inside bsd.own.mk and not in any other infrastructure.  Or
we can consider putting a hook inside bsd.own.mk for committing the
variables there too.  But let's see how this works out in practice
first.

Revision 1.12: download - view: text, markup, annotated - select for diffs
Tue Jun 27 10:27:20 2023 UTC (3 years, 4 months ago) by riastradh
Branches: MAIN
CVS tags: pkgsrc-2024Q1-base, pkgsrc-2024Q1, pkgsrc-2023Q4-base, pkgsrc-2023Q4, pkgsrc-2023Q3-base, pkgsrc-2023Q3
Diff to: previous 1.11: preferred, colored
Changes since revision 1.11: +8 -4 lines
Split native and cross LOCALBASE for cross-compilation.

This way, you can use an unprivileged prefix of ~/cross/pkg to
cross-compile packages that, when installed, will go in /usr/pkg.

In mk.conf:

- Set CROSS_LOCALBASE to determine the installation prefix of
  packages that you cross-compile.

- Set LOCALBASE to determine the installation prefix of native
  packages needed for cross compilation.

Both default to /usr/pkg.  Note: CROSS_LOCALBASE defaults to /usr/pkg
even if you set LOCALBASE.  Of course, if you're not cross-compiling,
this has no effect.

When cross-compiling a package:

- LOCALBASE is where cross-compiled packages will be installed.

  (`make install' will put it in ${CROSS_DESTDIR}${LOCALBASE}, of
  course, but when you later use pkg_add to install the binary
  package on the system you're compiling it for, it will go in
  ${LOCALBASE}.  And you can still set PREFIX for an individual
  package, but LOCALBASE refers to where cross-compiled packages are
  generally installed, other than the specific ones that override
  PREFIX.)

- TOOLBASE is where tool dependencies are installed and available to
  be executed at build-time.

  For example, if you have TOOL_DEPENDS on a program that is
  installed in (say) foo/bin/xyz which is not in PATH so you have to
  refer ot its full pathname, you can execute ${TOOLBASE}/foo/bin/xyz
  instead of ${LOCALBASE}/foo/bin/xyz.

I chose this split, rather than the other way around, because I
expect that references that are baked into installed packages to be
more common than references that are executed at build-time, but I
didn't do an extensive study of the matter.  I chose the name
TOOLBASE because it's where TOOL_DEPENDS go.

Revision 1.11: download - view: text, markup, annotated - select for diffs
Sun Apr 10 19:54:02 2022 UTC (4 years, 7 months ago) by riastradh
Branches: MAIN
CVS tags: pkgsrc-2023Q2-base, pkgsrc-2023Q2, pkgsrc-2023Q1-base, pkgsrc-2023Q1, pkgsrc-2022Q4-base, pkgsrc-2022Q4, pkgsrc-2022Q3-base, pkgsrc-2022Q3, pkgsrc-2022Q2-base, pkgsrc-2022Q2
Diff to: previous 1.10: preferred, colored
Changes since revision 1.10: +21 -5 lines
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.

Revision 1.10: download - view: text, markup, annotated - select for diffs
Mon Apr 4 11:23:18 2022 UTC (4 years, 7 months ago) by riastradh
Branches: MAIN
Diff to: previous 1.9: preferred, colored
Changes since revision 1.9: +2 -10 lines
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.

Revision 1.9: download - view: text, markup, annotated - select for diffs
Mon Apr 4 11:23:06 2022 UTC (4 years, 7 months ago) by riastradh
Branches: MAIN
Diff to: previous 1.8: preferred, colored
Changes since revision 1.8: +10 -25 lines
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.

Revision 1.8: download - view: text, markup, annotated - select for diffs
Mon Apr 4 11:22:50 2022 UTC (4 years, 7 months ago) by riastradh
Branches: MAIN
Diff to: previous 1.7: preferred, colored
Changes since revision 1.7: +1 -4 lines
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.

Revision 1.7: download - view: text, markup, annotated - select for diffs
Tue Jul 9 15:45:35 2019 UTC (7 years, 4 months ago) by riastradh
Branches: MAIN
CVS tags: pkgsrc-2022Q1-base, pkgsrc-2022Q1, pkgsrc-2021Q4-base, pkgsrc-2021Q4, pkgsrc-2021Q3-base, pkgsrc-2021Q3, pkgsrc-2021Q2-base, pkgsrc-2021Q2, pkgsrc-2021Q1-base, pkgsrc-2021Q1, pkgsrc-2020Q4-base, pkgsrc-2020Q4, pkgsrc-2020Q3-base, pkgsrc-2020Q3, pkgsrc-2020Q2-base, pkgsrc-2020Q2, pkgsrc-2020Q1-base, pkgsrc-2020Q1, pkgsrc-2019Q4-base, pkgsrc-2019Q4, pkgsrc-2019Q3-base, pkgsrc-2019Q3
Diff to: previous 1.6: preferred, colored
Changes since revision 1.6: +4 -1 lines
Note that USE_CWRAPPERS=no is needed for now in cross-compiling.

This is a bug, just need to teach cwrappers about passing sysroot.

Revision 1.6: download - view: text, markup, annotated - select for diffs
Tue Jul 9 15:45:25 2019 UTC (7 years, 4 months ago) by riastradh
Branches: MAIN
Diff to: previous 1.5: preferred, colored
Changes since revision 1.5: +1 -6 lines
Sync cross-libtool-base with libtool-base.  Eliminate CROSSBASE.

cross-libtool-base now installs into $PREFIX/cross-$TARGET_ARCH
unconditionally.

Revision 1.5: download - view: text, markup, annotated - select for diffs
Sun Mar 5 10:36:40 2017 UTC (9 years, 8 months ago) by kamil
Branches: MAIN
CVS tags: pkgsrc-2019Q2-base, pkgsrc-2019Q2, pkgsrc-2019Q1-base, pkgsrc-2019Q1, pkgsrc-2018Q4-base, pkgsrc-2018Q4, pkgsrc-2018Q3-base, pkgsrc-2018Q3, pkgsrc-2018Q2-base, pkgsrc-2018Q2, pkgsrc-2018Q1-base, pkgsrc-2018Q1, pkgsrc-2017Q4-base, pkgsrc-2017Q4, pkgsrc-2017Q3-base, pkgsrc-2017Q3, pkgsrc-2017Q2-base, pkgsrc-2017Q2, pkgsrc-2017Q1-base, pkgsrc-2017Q1
Diff to: previous 1.4: preferred, colored
Changes since revision 1.4: +2 -2 lines
Fix path to cross-libtool-base in HOWTO

Revision 1.4: download - view: text, markup, annotated - select for diffs
Wed May 4 02:05:22 2016 UTC (10 years, 6 months ago) by riastradh
Branches: MAIN
CVS tags: pkgsrc-2016Q4-base, pkgsrc-2016Q4, pkgsrc-2016Q3-base, pkgsrc-2016Q3, pkgsrc-2016Q2-base, pkgsrc-2016Q2
Diff to: previous 1.3: preferred, colored
Changes since revision 1.3: +3 -3 lines
Fix two more tooldir punctuations.

Revision 1.3: download - view: text, markup, annotated - select for diffs
Wed May 4 02:03:13 2016 UTC (10 years, 6 months ago) by riastradh
Branches: MAIN
Diff to: previous 1.2: preferred, colored
Changes since revision 1.2: +3 -3 lines
Fix tooldir name punctuation to match NetBSD build.sh default.

Revision 1.2: download - view: text, markup, annotated - select for diffs
Sat May 11 20:15:10 2013 UTC (13 years, 6 months ago) by riastradh
Branches: MAIN
CVS tags: pkgsrc-2016Q1-base, pkgsrc-2016Q1, pkgsrc-2015Q4-base, pkgsrc-2015Q4, pkgsrc-2015Q3-base, pkgsrc-2015Q3, pkgsrc-2015Q2-base, pkgsrc-2015Q2, pkgsrc-2015Q1-base, pkgsrc-2015Q1, pkgsrc-2014Q4-base, pkgsrc-2014Q4, pkgsrc-2014Q3-base, pkgsrc-2014Q3, pkgsrc-2014Q2-base, pkgsrc-2014Q2, pkgsrc-2014Q1-base, pkgsrc-2014Q1, pkgsrc-2013Q4-base, pkgsrc-2013Q4, pkgsrc-2013Q3-base, pkgsrc-2013Q3, pkgsrc-2013Q2-base, pkgsrc-2013Q2
Diff to: previous 1.1: preferred, colored
Changes since revision 1.1: +2 -1 lines
Add $NetBSD$ tags to HOWTO-use-crosscompile & HOWTO-dev-crosscompile.

Revision 1.1: download - view: text, markup, annotated - select for diffs
Fri May 10 00:03:46 2013 UTC (13 years, 6 months ago) by riastradh
Branches: MAIN
Add some notes on how to use and develop cross-compiled packages.

ok agc

Diff request

This form allows you to request diffs between any two revisions of a file. You may select a symbolic revision name using the selection box or you may type in a numeric name using the type-in text box.

Log view options

CVSweb <webmaster@jp.NetBSD.org>