pkgsrc-Changes archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
CVS commit: pkgsrc
Module Name: pkgsrc
Committed By: riastradh
Date: Mon Apr 4 11:22:51 UTC 2022
Modified Files:
pkgsrc/doc: HOWTO-use-crosscompile
pkgsrc/mk: cwrappers.mk
pkgsrc/pkgtools/cwrappers: Makefile
pkgsrc/pkgtools/cwrappers/files/bin: base-wrapper.c common.c common.h
normalise-cc.c normalise-ld.c
Log Message:
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.
To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 pkgsrc/doc/HOWTO-use-crosscompile
cvs rdiff -u -r1.33 -r1.34 pkgsrc/mk/cwrappers.mk
cvs rdiff -u -r1.26 -r1.27 pkgsrc/pkgtools/cwrappers/Makefile
cvs rdiff -u -r1.6 -r1.7 pkgsrc/pkgtools/cwrappers/files/bin/base-wrapper.c \
pkgsrc/pkgtools/cwrappers/files/bin/normalise-cc.c
cvs rdiff -u -r1.10 -r1.11 pkgsrc/pkgtools/cwrappers/files/bin/common.c
cvs rdiff -u -r1.9 -r1.10 pkgsrc/pkgtools/cwrappers/files/bin/common.h
cvs rdiff -u -r1.4 -r1.5 pkgsrc/pkgtools/cwrappers/files/bin/normalise-ld.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: pkgsrc/doc/HOWTO-use-crosscompile
diff -u pkgsrc/doc/HOWTO-use-crosscompile:1.7 pkgsrc/doc/HOWTO-use-crosscompile:1.8
--- pkgsrc/doc/HOWTO-use-crosscompile:1.7 Tue Jul 9 15:45:35 2019
+++ pkgsrc/doc/HOWTO-use-crosscompile Mon Apr 4 11:22:50 2022
@@ -1,7 +1,7 @@
Cross-compilation in pkgsrc (user's guide) -*- outline -*-
Taylor R. Campbell <riastradh%NetBSD.org@localhost>
-$NetBSD: HOWTO-use-crosscompile,v 1.7 2019/07/09 15:45:35 riastradh Exp $
+$NetBSD: HOWTO-use-crosscompile,v 1.8 2022/04/04 11:22:50 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
@@ -66,9 +66,6 @@ In addition to whatever else you want in
# XXX Should not need this.
PACKAGES= ${PKGSRCDIR}/packages.${MACHINE_ARCH}
WRKDIR_BASENAME= work.${MACHINE_ARCH}
-
- # XXX cwrappers needs to be taught to pass --sysroot.
- USE_CWRAPPERS= no
.endif
You can bootstrap pkgsrc or not; it shouldn't make a difference for
Index: pkgsrc/mk/cwrappers.mk
diff -u pkgsrc/mk/cwrappers.mk:1.33 pkgsrc/mk/cwrappers.mk:1.34
--- pkgsrc/mk/cwrappers.mk:1.33 Sun Mar 13 06:26:57 2022
+++ pkgsrc/mk/cwrappers.mk Mon Apr 4 11:22:50 2022
@@ -1,11 +1,11 @@
-# $NetBSD: cwrappers.mk,v 1.33 2022/03/13 06:26:57 nia Exp $
+# $NetBSD: cwrappers.mk,v 1.34 2022/04/04 11:22:50 riastradh Exp $
#
# This Makefile fragment implements integration of pkgtools/cwrappers.
.include "../../mk/wrapper/wrapper-defs.mk"
.include "../../mk/buildlink3/bsd.buildlink3.mk"
-BUILD_DEPENDS+= cwrappers>=20150314:../../pkgtools/cwrappers
+TOOL_DEPENDS+= cwrappers>=20220403:../../pkgtools/cwrappers
# XXX This should be PREFIX, but USE_CROSSBASE overrides it.
CWRAPPERS_SRC_DIR= ${LOCALBASE}/libexec/cwrappers
@@ -37,6 +37,12 @@ CWRAPPERS_ALIASES.ld= ld
CWRAPPERS_ALIASES.libtool= libtool
CWRAPPERS_ALIASES.shlibtool= shlibtool
+.if !empty(USE_CROSS_COMPILE:M[yY][eE][sS])
+CWRAPPERS_ALIASES.cc+= ${CC:T}
+CWRAPPERS_ALIASES.cxx+= ${CXX:T}
+CWRAPPERS_ALIASES.ld+= ${LD:T}
+.endif
+
CWRAPPERS_WRAPPEE.as= ${AS:Ufalse}
CWRAPPERS_WRAPPEE.cxx= ${PKG_CXX:Ufalse}
CWRAPPERS_WRAPPEE.cc= ${PKG_CC:Ufalse}
@@ -95,6 +101,9 @@ generate-cwrappers:
. endfor
. endif
. endif
+. if !empty(USE_CROSS_COMPILE:M[yY][eE][sS])
+ ${RUN}echo sysroot=${_CROSS_DESTDIR:Q} >> ${CWRAPPERS_CONFIG_DIR}/${CWRAPPERS_CONFIG.${wrappee}}
+. endif
.endfor
PREPEND_PATH+= ${WRAPPER_BINDIR}
Index: pkgsrc/pkgtools/cwrappers/Makefile
diff -u pkgsrc/pkgtools/cwrappers/Makefile:1.26 pkgsrc/pkgtools/cwrappers/Makefile:1.27
--- pkgsrc/pkgtools/cwrappers/Makefile:1.26 Tue Jun 2 19:46:00 2020
+++ pkgsrc/pkgtools/cwrappers/Makefile Mon Apr 4 11:22:51 2022
@@ -1,6 +1,6 @@
-# $NetBSD: Makefile,v 1.26 2020/06/02 19:46:00 rillig Exp $
+# $NetBSD: Makefile,v 1.27 2022/04/04 11:22:51 riastradh Exp $
-PKGNAME= cwrappers-20180325
+PKGNAME= cwrappers-20220403
CATEGORIES= pkgtools sysutils
MAINTAINER= joerg%NetBSD.org@localhost
Index: pkgsrc/pkgtools/cwrappers/files/bin/base-wrapper.c
diff -u pkgsrc/pkgtools/cwrappers/files/bin/base-wrapper.c:1.6 pkgsrc/pkgtools/cwrappers/files/bin/base-wrapper.c:1.7
--- pkgsrc/pkgtools/cwrappers/files/bin/base-wrapper.c:1.6 Fri Oct 27 20:59:59 2017
+++ pkgsrc/pkgtools/cwrappers/files/bin/base-wrapper.c Mon Apr 4 11:22:51 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: base-wrapper.c,v 1.6 2017/10/27 20:59:59 khorben Exp $ */
+/* $NetBSD: base-wrapper.c,v 1.7 2022/04/04 11:22:51 riastradh Exp $ */
/*-
* Copyright (c) 2007, 2017 Joerg Sonnenberger <joerg%NetBSD.org@localhost>.
@@ -99,6 +99,18 @@ libtool_mode(struct arglist *args)
}
#endif
+static void
+apply_sysroot(struct arglist *args)
+{
+ struct argument *arg;
+
+ if (sysroot == NULL)
+ return;
+
+ arg = argument_new(concat("--sysroot=", sysroot));
+ TAILQ_INSERT_HEAD(args, arg, link);
+}
+
int
main(int argc, char **argv)
{
@@ -136,6 +148,13 @@ main(int argc, char **argv)
operation_mode_cc(&args);
#endif
arglist_apply_config(&args);
+#if !defined(WRAPPER_LIBTOOL) && !defined(WRAPPER_SHLIBTOOL)
+ /*
+ * The --sysroot argument will be applied only to the compiler
+ * or linker that libtool invokes, not to libtool itself.
+ */
+ apply_sysroot(&args);
+#endif
#if defined(WRAPPER_LD)
normalise_ld(&args);
#else
Index: pkgsrc/pkgtools/cwrappers/files/bin/normalise-cc.c
diff -u pkgsrc/pkgtools/cwrappers/files/bin/normalise-cc.c:1.6 pkgsrc/pkgtools/cwrappers/files/bin/normalise-cc.c:1.7
--- pkgsrc/pkgtools/cwrappers/files/bin/normalise-cc.c:1.6 Sun Nov 7 12:38:12 2021
+++ pkgsrc/pkgtools/cwrappers/files/bin/normalise-cc.c Mon Apr 4 11:22:51 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: normalise-cc.c,v 1.6 2021/11/07 12:38:12 christos Exp $ */
+/* $NetBSD: normalise-cc.c,v 1.7 2022/04/04 11:22:51 riastradh Exp $ */
/*-
* Copyright (c) 2009, 2017 Joerg Sonnenberger <joerg%NetBSD.org@localhost>.
@@ -38,7 +38,8 @@
static void
normalise_path_list(struct arglist *args, struct argument *arg,
- const char *prefix, const char *val, int strip_relative)
+ const char *prefix, const char *sysroot_prefix, const char *val,
+ int strip_relative)
{
const char *sep;
struct argument *arg2;
@@ -51,6 +52,14 @@ normalise_path_list(struct arglist *args
arg2 = argument_new(concat2(prefix, val, sep - val));
TAILQ_INSERT_AFTER(args, arg, arg2, link);
arg = arg2;
+ if (sysroot_prefix && sysroot) {
+ char *sysroot_val = concat2(sysroot, val, sep - val);
+ arg2 = argument_new(concat(sysroot_prefix,
+ sysroot_val));
+ free(sysroot_val);
+ TAILQ_INSERT_AFTER(args, arg, arg2, link);
+ arg = arg2;
+ }
val = sep + 1;
}
if (val[0] == '\0' || (strip_relative && !isabs(val[0])))
@@ -58,6 +67,13 @@ normalise_path_list(struct arglist *args
arg2 = argument_new(concat(prefix, val));
TAILQ_INSERT_AFTER(args, arg, arg2, link);
arg = arg2;
+ if (sysroot_prefix && sysroot) {
+ char *sysroot_val = concat(sysroot, val);
+ arg2 = argument_new(concat(sysroot_prefix, sysroot_val));
+ free(sysroot_val);
+ TAILQ_INSERT_AFTER(args, arg, arg2, link);
+ arg = arg2;
+ }
}
void
@@ -201,7 +217,8 @@ normalise_cc(struct arglist *args)
if (strcmp(arg->val, "-Wl,-rpath-link") == 0) {
if (arg2 == NULL || strncmp(arg2->val, "-Wl,", 4))
errx(255, "Missing argument for %s", arg->val);
- normalise_path_list(args, arg, "-Wl,-rpath-link,",
+ normalise_path_list(args, arg,
+ "-Wl,-rpath-link,", NULL,
arg2->val + 4, 0);
argument_unlink(args, &arg);
argument_unlink(args, &arg2);
@@ -210,7 +227,8 @@ normalise_cc(struct arglist *args)
if (strcmp(arg->val, "-R") == 0) {
if (arg2 == NULL || arg2->val[0] == '-')
errx(255, "Missing argument for %s", arg->val);
- normalise_path_list(args, arg, "-Wl,-rpath,",
+ normalise_path_list(args, arg,
+ "-Wl,-rpath,", "-Wl,-rpath-link,"/*sysroot*/,
arg2->val, 1);
argument_unlink(args, &arg);
argument_unlink(args, &arg2);
@@ -221,26 +239,30 @@ normalise_cc(struct arglist *args)
strcmp(arg->val, "-Wl,--rpath") == 0) {
if (arg2 == NULL || strncmp(arg2->val, "-Wl,", 4))
errx(255, "Missing argument for %s", arg->val);
- normalise_path_list(args, arg, "-Wl,-rpath,",
+ normalise_path_list(args, arg,
+ "-Wl,-rpath,", "-Wl,-rpath-link,"/*sysroot*/,
arg2->val + 4, 1);
argument_unlink(args, &arg);
argument_unlink(args, &arg2);
continue;
}
if (strncmp(arg->val, "-Wl,-R", 6) == 0) {
- normalise_path_list(args, arg, "-Wl,-rpath,",
+ normalise_path_list(args, arg,
+ "-Wl,-rpath,", "-Wl,-rpath-link,"/*sysroot*/,
arg->val + 6, 1);
argument_unlink(args, &arg);
continue;
}
if (strncmp(arg->val, "-R", 2) == 0) {
- normalise_path_list(args, arg, "-Wl,-rpath,",
+ normalise_path_list(args, arg,
+ "-Wl,-rpath,", "-Wl,-rpath-link,"/*sysroot*/,
arg->val + 2, 1);
argument_unlink(args, &arg);
continue;
}
if (strncmp(arg->val, "-Wl,-rpath,", 10) == 0) {
- normalise_path_list(args, arg, "-Wl,-rpath,",
+ normalise_path_list(args, arg,
+ "-Wl,-rpath,", "-Wl,-rpath-link,"/*sysroot*/,
arg->val + 10, 1);
argument_unlink(args, &arg);
continue;
Index: pkgsrc/pkgtools/cwrappers/files/bin/common.c
diff -u pkgsrc/pkgtools/cwrappers/files/bin/common.c:1.10 pkgsrc/pkgtools/cwrappers/files/bin/common.c:1.11
--- pkgsrc/pkgtools/cwrappers/files/bin/common.c:1.10 Sun Mar 25 20:45:25 2018
+++ pkgsrc/pkgtools/cwrappers/files/bin/common.c Mon Apr 4 11:22:51 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: common.c,v 1.10 2018/03/25 20:45:25 joerg Exp $ */
+/* $NetBSD: common.c,v 1.11 2022/04/04 11:22:51 riastradh Exp $ */
/*-
* Copyright (c) 2009, 2017 Joerg Sonnenberger <joerg%NetBSD.org@localhost>.
@@ -48,6 +48,7 @@ static char *real_path;
char *exec_path;
char *exec_name;
char *wrksrc;
+char *sysroot;
int debug;
enum operation_mode current_operation_mode = mode_unknown;
@@ -294,6 +295,11 @@ parse_config(const char *wrapper)
wrksrc = xstrdup(line + 7);
continue;
}
+ if (strncmp(line, "sysroot=", 8) == 0) {
+ free(sysroot);
+ sysroot = xstrdup(line + 8);
+ continue;
+ }
if (strncmp(line, "unwrap=", 7) == 0) {
register_unwrap(line + 7);
continue;
Index: pkgsrc/pkgtools/cwrappers/files/bin/common.h
diff -u pkgsrc/pkgtools/cwrappers/files/bin/common.h:1.9 pkgsrc/pkgtools/cwrappers/files/bin/common.h:1.10
--- pkgsrc/pkgtools/cwrappers/files/bin/common.h:1.9 Sun Nov 7 12:38:12 2021
+++ pkgsrc/pkgtools/cwrappers/files/bin/common.h Mon Apr 4 11:22:51 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: common.h,v 1.9 2021/11/07 12:38:12 christos Exp $ */
+/* $NetBSD: common.h,v 1.10 2022/04/04 11:22:51 riastradh Exp $ */
/*-
* Copyright (c) 2009, 2017 Joerg Sonnenberger <joerg%NetBSD.org@localhost>.
@@ -42,6 +42,7 @@ extern const char library_name_chars[];
extern char *exec_path;
extern char *exec_name;
extern char *wrksrc;
+extern char *sysroot;
extern int debug;
enum operation_mode {
Index: pkgsrc/pkgtools/cwrappers/files/bin/normalise-ld.c
diff -u pkgsrc/pkgtools/cwrappers/files/bin/normalise-ld.c:1.4 pkgsrc/pkgtools/cwrappers/files/bin/normalise-ld.c:1.5
--- pkgsrc/pkgtools/cwrappers/files/bin/normalise-ld.c:1.4 Tue Nov 7 16:49:22 2017
+++ pkgsrc/pkgtools/cwrappers/files/bin/normalise-ld.c Mon Apr 4 11:22:51 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: normalise-ld.c,v 1.4 2017/11/07 16:49:22 khorben Exp $ */
+/* $NetBSD: normalise-ld.c,v 1.5 2022/04/04 11:22:51 riastradh Exp $ */
/*-
* Copyright (c) 2009, 2017 Joerg Sonnenberger <joerg%NetBSD.org@localhost>.
@@ -62,6 +62,29 @@ operation_mode_ld(struct arglist *args)
}
}
+/*
+ * append_rpath_link(args, path, &lastarg)
+ *
+ * If sysroot is enabled, append `-rpath-link ${sysroot}${path}'
+ * to the argument list after lastarg, and update lastarg to be
+ * the last argument appended.
+ */
+static void
+append_rpath_link(struct arglist *args, const char *path,
+ struct argument **lastargp)
+{
+ struct argument *arg_opt, *arg_val;
+
+ if (sysroot == NULL)
+ return;
+
+ arg_opt = argument_new(xstrdup("-rpath-link"));
+ arg_val = argument_new(concat(sysroot, path));
+ TAILQ_INSERT_AFTER(args, *lastargp, arg_opt, link);
+ TAILQ_INSERT_AFTER(args, arg_opt, arg_val, link);
+ *lastargp = arg_val;
+}
+
void
normalise_ld(struct arglist *args)
{
@@ -83,12 +106,20 @@ normalise_ld(struct arglist *args)
if (arg2 == NULL || arg2->val[0] == '-')
errx(255, "Missing argument for %s", arg->val);
argument_update(arg, xstrdup("-rpath"));
+ append_rpath_link(args, arg2->val, &arg2);
+ continue;
+ }
+ if (sysroot && strcmp(arg->val, "-rpath") == 0) {
+ if (arg2 == NULL || arg2->val[0] == '-')
+ errx(255, "Missing argument for %s", arg->val);
+ append_rpath_link(args, arg2->val, &arg2);
continue;
}
if (strncmp(arg->val, "-R", 2) == 0) {
argument_update(arg, xstrdup(arg->val + 2));
arg3 = argument_copy("-rpath");
TAILQ_INSERT_BEFORE(arg, arg3, link);
+ append_rpath_link(args, arg->val, &arg2);
continue;
}
}
Home |
Main Index |
Thread Index |
Old Index