NetBSD / pkgsrc

Automatic conversion of the NetBSD pkgsrc CVS module, use with care
https://www.pkgsrc.org
310 stars 164 forks source link

Cross-compiling on Linux (native) for QNX (target) #109

Closed raymanfx closed 2 years ago

raymanfx commented 2 years ago

I am trying to compile several packages (including pkgin) for QNX. Following the cross-compile docs here: https://github.com/NetBSD/pkgsrc/blob/trunk/doc/HOWTO-use-crosscompile lead me to the following config in pkg/etc/mk.conf:

# Example ... mk.conf file produced by bootstrap-pkgsrc
# Thu 30 Jun 2022 09:51:16 AM CEST

.ifdef BSD_PKG_MK   # begin pkgsrc settings

.if empty(USE_CROSS_COMPILE:M[yY][eE][sS])
ABI=    64 # set for native amd64 build
.else
ABI=    # empty for earmv7hf cross-build
.endif

UNPRIVILEGED=       yes
PKG_DBDIR=      /home/chesse/work/qnx/pkg/env/pkg/pkgdb
LOCALBASE=      /home/chesse/work/qnx/pkg/env/pkg
SYSCONFBASE=        /home/chesse/work/qnx/pkg/env/pkg/etc
VARBASE=        /home/chesse/work/qnx/pkg/env/pkg/var
PKG_TOOLS_BIN=      /home/chesse/work/qnx/pkg/env/pkg/sbin
PKGINFODIR=     info
PKGMANDIR=      man

# WARNING: Changing PREFER_* after bootstrap will require rebuilding all
# packages with a dependency that switched between native/pkgsrc.
PREFER_PKGSRC=      yes

TOOLS_PLATFORM.awk?=        /home/chesse/work/qnx/pkg/env/pkg/bin/nawk

# Cross-compile by default.
#
# XXX This currently can't be set to `yes' on the command line,
# which is a bug.
USE_CROSS_COMPILE?=  yes

# Point pkgsrc at the NetBSD tooldir and destdir.  These are used
# only for cross-builds.
#
# XXX There is no obvious variable that is set to amd64 so that we
# could use
#
#    TOOLDIR=        /usr/obj/tooldir.${OPSYS}-${OS_VERSION}-${NATIVE_xyz}
#
# MACHINE is amd64 but, since it's not NATIVE_xyz, it's wrong.
# NATIVE_MACHINE_ARCH is x86_64, not amd64.
TOOLDIR=             /home/chesse/qnx710-dup/host/linux/x86_64
CROSS_DESTDIR=       /home/chesse/qnx710-dup/target/qnx7

# Specify the machine architecture of target packages.
#
# XXX This currently can't be set on the command line, which is a
# bug.
.if !empty(USE_CROSS_COMPILE:M[yY][eE][sS])
MACHINE_ARCH=        amd64
.endif

# Specify QNX OS.
OPSYS=               QNX
OPSYS_VERSION=       710
OS_VERSION=          7.1.0

.endif          # end pkgsrc settings

My procedure consists of the following:

  1. Bootstrap to get bmake for my host (Linux): ./bootstrap/bootstrap --prefix /home/chesse/work/qnx/pkg/env/pkg --unprivileged
  2. Modify mk.conf so it looks like the above.
  3. Attempt to compile a package (e.g. pkgtools/pkgin).

What I then see is the following issue:

[...]
===> Installing for digest-20220214
WARNING: Your umask is ``0022''.
WARNING: If this is not desired, set it to an appropriate value (0002) and install
WARNING: this package again by ``/home/chesse/work/qnx/pkg/env/pkg/bin/bmake deinstall reinstall''.
=> Generating pre-install file lists
/bin/sh ./mkinstalldirs /home/chesse/work/qnx/pkg/pkgsrc/pkgtools/digest/work/.destdir/home/chesse/work/qnx/pkg/env/pkg/bin
mkdir /home/chesse/work/qnx/pkg/pkgsrc/pkgtools/digest/work/.destdir/home/chesse/work/qnx/pkg/env/pkg/bin
/usr/bin/install -c -s -o chesse -g domusers -m 755 digest /home/chesse/work/qnx/pkg/pkgsrc/pkgtools/digest/work/.destdir/home/chesse/work/qnx/pkg/env/pkg/bin/digest
/bin/sh ./mkinstalldirs /home/chesse/work/qnx/pkg/pkgsrc/pkgtools/digest/work/.destdir/home/chesse/work/qnx/pkg/env/pkg/man/man1
mkdir /home/chesse/work/qnx/pkg/pkgsrc/pkgtools/digest/work/.destdir/home/chesse/work/qnx/pkg/env/pkg/man
mkdir /home/chesse/work/qnx/pkg/pkgsrc/pkgtools/digest/work/.destdir/home/chesse/work/qnx/pkg/env/pkg/man/man1
/usr/bin/install -c -o chesse -g domusers -m 644 digest.1 /home/chesse/work/qnx/pkg/pkgsrc/pkgtools/digest/work/.destdir/home/chesse/work/qnx/pkg/env/pkg/man/man1/digest.1
=> Automatic manual page handling
=> Generating post-install file lists
pkg_info: missing package name(s)
usage: pkg_info [-BbcDdFfhIikLmNnpqRrSsVvX] [-E pkg-name] [-e pkg-name]
                [-K pkg_dbdir] [-l prefix] pkg-name ...
       pkg_info [-a | -u] [flags]
       pkg_info [-Q variable] pkg-name ...
=> Checking file-check results for digest-20220214
=> Creating binary package /home/chesse/work/qnx/pkg/pkgsrc/pkgtools/digest/work/.packages/digest-20220214.tgz
===> Building binary package for digest-20220214
=> Creating binary package /home/chesse/work/qnx/pkg/pkgsrc/packages/All/digest-20220214.tgz
===> Installing binary package of digest-20220214
pkg_add: Warning: package `digest-20220214' was built for a platform:
pkg_add: QNX/x86_64 7.1.0 (pkg) vs. Linux/x86_64 5.13.0 (this host)
pkg_add: 1 package addition failed
*** Error code 1

At a first glance, this looks fine. I am not bootstrapping on the target system (QNX) but just want to cross-compile packages for it. Ideally, I would like to build pkgin and friends for the target, so I can just install packages there from a binary repository. The packages itself should only be built on Linux (where I have the QNX toolchain etc. set up).

Obviously the build system still thinks this is an error. What am I missing here?

alarixnia commented 2 years ago

I'm quite sure cross-compiling is only expected to work for NetBSD.

raymanfx commented 2 years ago

Indeed, that appears to be the case. I bit the bullet and bootstrapped pkgsrc on the target, which appears to work (after doing some modifications to get it up to speed with QNX 7.1). pkgin is working fine already.