unofficial mirror of meta@public-inbox.org
 help / color / mirror / Atom feed
* [PATCH 0/2] xap_helper: some NetBSD fixes
@ 2023-09-04 23:49 Eric Wong
  2023-09-04 23:49 ` [PATCH 1/2] xap_helper: use rpath for libxapian on NetBSD Eric Wong
  2023-09-04 23:49 ` [PATCH 2/2] xap_helper: allow non-standard file description flags Eric Wong
  0 siblings, 2 replies; 3+ messages in thread
From: Eric Wong @ 2023-09-04 23:49 UTC (permalink / raw)
  To: meta

There's still some outstanding problems on NetBSD, but these are
the easy ones to publish while I still have working Internet and
power; not sure how long that'll last...

Eric Wong (2):
  xap_helper: use rpath for libxapian on NetBSD
  xap_helper: allow non-standard file description flags

 lib/PublicInbox/XapHelperCxx.pm |  9 +++++++++
 lib/PublicInbox/xap_helper.h    | 15 +++++++--------
 2 files changed, 16 insertions(+), 8 deletions(-)

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 1/2] xap_helper: use rpath for libxapian on NetBSD
  2023-09-04 23:49 [PATCH 0/2] xap_helper: some NetBSD fixes Eric Wong
@ 2023-09-04 23:49 ` Eric Wong
  2023-09-04 23:49 ` [PATCH 2/2] xap_helper: allow non-standard file description flags Eric Wong
  1 sibling, 0 replies; 3+ messages in thread
From: Eric Wong @ 2023-09-04 23:49 UTC (permalink / raw)
  To: meta

While rpath is frowned upon by Debian and other distro packagers; it
appears embraced by in the world of NetBSD ports and packages.  This is
because ldconfig(8) on NetBSD doesn't put /usr/pkg/lib in its search
path by default.  This behavior differs from the ports and packaging
systems of FreeBSD and OpenBSD which do search library paths of
pkg*-installed packages (and presumably ports).
---
 lib/PublicInbox/XapHelperCxx.pm | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/lib/PublicInbox/XapHelperCxx.pm b/lib/PublicInbox/XapHelperCxx.pm
index a22dda1e..1c9a314f 100644
--- a/lib/PublicInbox/XapHelperCxx.pm
+++ b/lib/PublicInbox/XapHelperCxx.pm
@@ -54,6 +54,15 @@ sub build () {
 	my $cmd = "$pkg_config --libs --cflags xapian-core";
 	chomp(my $fl = `$cmd`);
 	die "$cmd failed: \$?=$?" if $?;
+
+	# Using rpath seems acceptable/encouraged in the NetBSD packaging world
+	# since /usr/pkg/lib isn't searched by the dynamic loader by default.
+	# Not sure if other OSes need this, but rpath seems fine for JAOT
+	# binaries (like this one) even if other distros discourage it for
+	# distributed packages.
+	$^O eq 'netbsd' and $fl =~ s/(\A|[ \t])\-L([^ \t]+)([ \t]|\z)/
+				"$1-L$2 -Wl,-rpath=$2$3"/egsx;
+
 	my $cxx = $ENV{CXX} // 'c++';
 	$cmd = "$cxx $src $fl $xflags -o $tmp/$prog";
 	system($cmd) and die "$cmd failed: \$?=$?";

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 2/2] xap_helper: allow non-standard file description flags
  2023-09-04 23:49 [PATCH 0/2] xap_helper: some NetBSD fixes Eric Wong
  2023-09-04 23:49 ` [PATCH 1/2] xap_helper: use rpath for libxapian on NetBSD Eric Wong
@ 2023-09-04 23:49 ` Eric Wong
  1 sibling, 0 replies; 3+ messages in thread
From: Eric Wong @ 2023-09-04 23:49 UTC (permalink / raw)
  To: meta

pipe2(.., O_CLOEXEC) on NetBSD sets the O_CLOEXEC file description
flag along with the FD_CLOEXEC file descriptor flag, so we must
not attempt to do exact matches on the file description flags.
---
 lib/PublicInbox/xap_helper.h | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/lib/PublicInbox/xap_helper.h b/lib/PublicInbox/xap_helper.h
index 0f16d316..73590efd 100644
--- a/lib/PublicInbox/xap_helper.h
+++ b/lib/PublicInbox/xap_helper.h
@@ -636,18 +636,17 @@ static bool recv_req(struct req *req, char *rbuf, size_t *len)
 			int fd = *fdp++;
 			const char *mode = NULL;
 			int fl = fd_ok ? fcntl(fd, F_GETFL) : 0;
-			switch (fl) {
-			case 0: break; // hit previous error
-			case -1:
+			if (fl == 0) {
+				continue; // hit previous error
+			} else if (fl == -1) {
 				warnx("invalid fd=%d", fd);
 				fd_ok = false;
-				break;
-			case O_WRONLY: mode = "w"; break;
-			case O_RDWR:
+			} else if (fl & O_WRONLY) {
+				mode = "w";
+			} else if (fl & O_RDWR) {
 				mode = "r+";
 				if (i == 0) req->has_input = true;
-				break;
-			default:
+			} else {
 				warnx("invalid mode from F_GETFL: 0x%x", fl);
 				fd_ok = false;
 			}

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-09-04 23:49 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-04 23:49 [PATCH 0/2] xap_helper: some NetBSD fixes Eric Wong
2023-09-04 23:49 ` [PATCH 1/2] xap_helper: use rpath for libxapian on NetBSD Eric Wong
2023-09-04 23:49 ` [PATCH 2/2] xap_helper: allow non-standard file description flags Eric Wong

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).