Closed rapenne-s closed 1 month ago
I'm working on reproducing; did you not see this build error?
$ make CXX=clang++
...
clang++ -DKAK_BIN_PATH="/usr/local/bin/kak" -I/usr/local/include -std=c++2a -Wall -Wextra -pedantic -Wno-unused-paramete
r -Wno-sign-compare -O3 -g3 -fsized-deallocation -O2 -pipe -MD -MP -MF src/.file.opt.d -c -o src/file.opt.o src/file.cc
src/file.cc:669:12: error: expected expression
return KAK_BIN_PATH;
^
<command line>:2:22: note: expanded from macro 'KAK_BIN_PATH'
#define KAK_BIN_PATH /usr/local/bin/kak
I'm working on reproducing; did you not see this build error?
$ make CXX=clang++ ... clang++ -DKAK_BIN_PATH="/usr/local/bin/kak" -I/usr/local/include -std=c++2a -Wall -Wextra -pedantic -Wno-unused-paramete r -Wno-sign-compare -O3 -g3 -fsized-deallocation -O2 -pipe -MD -MP -MF src/.file.opt.d -c -o src/file.opt.o src/file.cc src/file.cc:669:12: error: expected expression return KAK_BIN_PATH; ^ <command line>:2:22: note: expanded from macro 'KAK_BIN_PATH' #define KAK_BIN_PATH /usr/local/bin/kak
I needed this change to make it compile indeed
Index: Makefile
--- Makefile.orig
+++ Makefile
@@ -54,7 +52,7 @@ LDFLAGS-os-FreeBSD = -L/usr/local/lib
LIBS-os-Haiku = -lnetwork -lbe
-CPPFLAGS-os-OpenBSD = -DKAK_BIN_PATH="$(bindir)/kak" -I/usr/local/include
+CPPFLAGS-os-OpenBSD = -DKAK_BIN_PATH='"$(bindir)/kak"' -I/usr/local/include
LDFLAGS-os-OpenBSD = -L/usr/local/lib
mandir-os-OpenBSD = $(DESTDIR)$(PREFIX)/man/man1
On Sat, May 11, 2024 at 05:28:52AM -0700, Solène Rapenne wrote:
-CPPFLAGS-os-OpenBSD = -DKAK_BIN_PATH="$(bindir)/kak" -I/usr/local/include +CPPFLAGS-os-OpenBSD = -DKAK_BIN_PATH='"$(bindir)/kak"' -I/usr/local/include LDFLAGS-os-OpenBSD = -L/usr/local/lib mandir-os-OpenBSD = $(DESTDIR)$(PREFIX)/man/man1
Yeah the problem is that %val{runtime}
is derived from KAK_BIN_PATH
.
As a workaround either install kak before running make test
,
or use KAKOUNE_RUNTIME=$PWD/share/kak make test
.
Not sure what's a proper fix; how can kak detect whether it's installed or not?
On a sourcehut system there are some more failures, related to multi-byte chars. Not yet sure what's going on.
On Linux, Kakoune doesn't need to be installed; I think it looks at the path in argv[0]
and adds ../share/kak/
to find the runtime data. Does that trick not work on OpenBSD?
On Linux, Kakoune doesn't need to be installed; I think it looks at the path in
argv[0]
and adds../share/kak/
to find the runtime data. Does that trick not work on OpenBSD?
On OpenBSD it is not possible to know the path of a running binary. (explanations)
I think it looks at the path in
argv[0]
and adds../share/kak/
to find the runtime data.
It turns out this is very wrong, it uses Linux Hacks to figure out the "real" binary path (where "real" is in quotes for all the reasons OpenBSD doesn't support this feature), and other platform-specific APIs on various other platforms.
I think guessing based on argv[0]
would be a better fallback than a hard-coded path, despite (or indeed because) it not being the guaranteed "real" binary path, but I guess it's this way for a reason.
I guess one option is to hardcode the path to $PWD/src/kak
and have make install
change that (binary patch?) to $(bindir)/kak
. Then we don't need platform-specific code. But I can see how that is surprising in other ways.
I guess it's not terribly important; since this is mainly about make test
we can override KAK_RUNTIME_DIR
if on OpenBSD.
Not sure what's wrong with the remaining test failures, AIUI OpenBSD doesn't support anything other than UTF-8
The locale is C
and setting LC_ALL=C.utf-8
gives a (probably harmless) error
I don't think KAK_BIN_PATH
is a problem for the tests, if I uninstall kakoune package (thus it's not available anymore), the test suite can still be used, this mean the tests are not using the binary from KAK_BIN_PATH
location.
diff --git a/Makefile b/Makefile
index 362153ea6..f61eab84e 100644
--- a/Makefile
+++ b/Makefile
@@ -54,7 +54,7 @@ LDFLAGS-os-FreeBSD = -L/usr/local/lib
LIBS-os-Haiku = -lnetwork -lbe
-CPPFLAGS-os-OpenBSD = -DKAK_BIN_PATH="$(bindir)/kak" -I/usr/local/include
+CPPFLAGS-os-OpenBSD = -DKAK_BIN_PATH=\"$(bindir)/kak\" -I/usr/local/include
LDFLAGS-os-OpenBSD = -L/usr/local/lib
mandir-os-OpenBSD = $(DESTDIR)$(PREFIX)/man/man1
@@ -136,6 +136,9 @@ doc/kak.1.gz: doc/kak.1
check: test
test: src/kak
+ if [ $(os) = OpenBSD ]; then \
+ export KAKOUNE_RUNTIME=$$PWD/share/kak; \
+ fi && \
cd test && ./run
TAGS: tags
diff --git a/src/file.cc b/src/file.cc
index 056319b67..a293fd4c7 100644
--- a/src/file.cc
+++ b/src/file.cc
@@ -672,6 +672,7 @@ String get_kak_binary_path()
buffer[res] = '\0';
return buffer;
#elif defined(__OpenBSD__)
+ (void)buffer;
return KAK_BIN_PATH;
#elif defined(__sun__)
ssize_t res = readlink("/proc/self/path/a.out", buffer, 2048);
diff --git a/Makefile b/Makefile index 362153ea6..f61eab84e 100644 --- a/Makefile +++ b/Makefile @@ -54,7 +54,7 @@ LDFLAGS-os-FreeBSD = -L/usr/local/lib LIBS-os-Haiku = -lnetwork -lbe -CPPFLAGS-os-OpenBSD = -DKAK_BIN_PATH="$(bindir)/kak" -I/usr/local/include +CPPFLAGS-os-OpenBSD = -DKAK_BIN_PATH=\"$(bindir)/kak\" -I/usr/local/include LDFLAGS-os-OpenBSD = -L/usr/local/lib mandir-os-OpenBSD = $(DESTDIR)$(PREFIX)/man/man1 @@ -136,6 +136,9 @@ doc/kak.1.gz: doc/kak.1 check: test test: src/kak + if [ $(os) = OpenBSD ]; then \ + export KAKOUNE_RUNTIME=$$PWD/share/kak; \ + fi && \ cd test && ./run TAGS: tags diff --git a/src/file.cc b/src/file.cc index 056319b67..a293fd4c7 100644 --- a/src/file.cc +++ b/src/file.cc @@ -672,6 +672,7 @@ String get_kak_binary_path() buffer[res] = '\0'; return buffer; #elif defined(OpenBSD) + (void)buffer; return KAK_BIN_PATH; #elif defined(sun) ssize_t res = readlink("/proc/self/path/a.out", buffer, 2048);
with that diff, kakoune tests all pass, including the git one I had to disable because they were hanging.
Version of Kakoune
v2024.05.09
Reproducer
make test
Outcome