meator opened a new issue, #6107:
URL: https://github.com/apache/couchdb/issues/6107

   ### Version
   
   3.5.1
   
   ### Describe the problem you're encountering
   
   # Introduction
   
   I am trying to package couchdb for Void Linux. Void Linux prides itself with 
support for a plethora of architectures and glibc/musl support. It supports 
these architectures by cross compiling to them.
   
   Right of the bat, the fact that couchdb doesn't use any higher level well 
established build system is an issue. The fact that the project uses a hand 
written `configure` script and an elaborate Makefile structure do not 
necessarily have to mean that the build system is less capable than CMake for 
example, but my experience shows that there is a very strong corelation between 
such endevaurs and configure/build errors + poor or nonexistant support for 
systems not exactly matching the developer's build environment.
   
   # Problem
   I will comment on the 
[`src/couch_quickjs/quickjs/Makefile`](https://github.com/apache/couchdb/blob/78395184b02cdc9573c3536ec72721fb353d5442/src/couch_quickjs/quickjs/Makefile)
 file. I assume it is part of couchdb. If it is vendored, please say so and I 
will make an issue in the appropriate repository.
   
   This file includes a lot of hardcoded platform dependant logic which doesn't 
really belong there. This issue would be more aproachable if higher level build 
systems were used, but because Make lacks a standard mechanism to specify 
things like host and target compiler and executable wrapper (like Wine), it is 
understandable.
   
   This makefile uses a handrolled cross compilation suport, which is to my 
knowledge completely undocumented. I was surprized that there even is a 
host/target compiler distinction.
   
   Even though there is such a distinction, it doesn't seem to be that useful, 
because the `qjsc` executable is [built for target 
architecture](https://github.com/apache/couchdb/blob/78395184b02cdc9573c3536ec72721fb353d5442/src/couch_quickjs/quickjs/Makefile#L266-L267),
 even though it is later [executed as part of the build 
process](https://github.com/apache/couchdb/blob/78395184b02cdc9573c3536ec72721fb353d5442/src/couch_quickjs/build_js.escript#L76):
   
   ```
   ...
   i686-pc-linux-gnu-gcc -fstack-clash-protection -D_FORTIFY_SOURCE=2 -O2 -pipe 
-march=i686   -I/usr/i686-pc-linux-gnu/usr/include 
-ffile-prefix-map=/builddir/couchdb-3.5.2=. -g -Wall -MMD -MF .obj/qjsc.o.d 
-Wno-array-bounds -Wno-format-truncation -Wno-infinite-recursion -fwrapv  
-D_GNU_SOURCE -DCONFIG_VERSION=\"2025-09-13\" -DCONFIG_CC=\"gcc\" 
-DCONFIG_PREFIX=\"/usr\" -O2 -c -o .obj/qjsc.o qjsc.c
   i686-pc-linux-gnu-ar rcs libquickjs.a .obj/quickjs.o .obj/dtoa.o 
.obj/libregexp.o .obj/libunicode.o .obj/cutils.o .obj/quickjs-libc.o
   i686-pc-linux-gnu-gcc -Wl,-z,relro -Wl,-z,now -Wl,--as-needed    
-L/usr/i686-pc-linux-gnu/usr/lib -g -o qjsc .obj/qjsc.o .obj/quickjs.o 
.obj/dtoa.o .obj/libregexp.o .obj/libunicode.o .obj/cutils.o 
.obj/quickjs-libc.o -lm -lpthread -ldl
   make[1]: Leaving directory 
'/builddir/couchdb-3.5.2/src/couch_quickjs/quickjs'
   escript: exception error: {command_failed,"/bin/sh: line 1: 
/builddir/couchdb-3.5.2/src/couch_quickjs/quickjs/qjsc: cannot execute: 
required file not found\n",
                                    127}
     in function  os:cmd/2 (os.erl:583)
     in call from 
build_js_escript__escript__1788__778366__612935__1573:compile_bytecode/2 
(build_js.escript:76)
     in call from build_js_escript__escript__1788__778366__612935__1573:main/1 
(build_js.escript:29)
     in call from escript:run/2 (escript.erl:906)
     in call from escript:start/1 (escript.erl:420)
     in call from init:start_it/1
     in call from init:start_em/1
     in call from init:do_boot/3
   ERROR: Command [compile] failed!
   ```
   
   ```
   quickjs/qjsc: ELF 32-bit LSB pie executable, Intel i386, version 1 (SYSV), 
dynamically linked, interpreter /lib/ld-linux.so.2, 
BuildID[sha1]=788d22328f0807aa30fee65d6256c07545c64749, for GNU/Linux 3.2.0, 
with debug_info, not stripped
   ```
   
   I have little experience with erlang, but that file does not seem to include 
any support for an executable wrapper (like QEMU or Wine, which would be 
necessary to execute target built `qjsc`). I know little about couchdb't build 
system architecture, but from the little I know, I don't think `qjsc` is even 
needed to be built for target architecture, I think it is only used during the 
build process.
   
   This issue could be rectified by letting the user provide their own `qjsc`. 
For example Void Linux already packages `/usr/bin/qjsc` in its `quickjs-devel` 
package. I saw no way of doing that from a brief glance at the build system.
   
   ### Expected Behaviour
   
   `qjsc` should be built for host architecture _and/or_ there should be a way 
to provide a custom executable wrapper _and/or_ there should be a way to 
provide a custom `qjsc` system installed executable.
   
   Cross compilation support, including instructions on how to use it, like 
using `CROSS_PREFIX`, should be properly documented. If couchdb doesn't support 
cross compiling of if there is limited support for certain targets of for 
example musl, this should also be documented.
   
   ### Steps to Reproduce
   
   Try to cross compile the project.
   
   ### Your Environment
   
   I believe that I have described the issue sufficiently. My build environment 
depends on the Void Linux package builder. Reproducing that for someone 
unfamiliar with it would be difficult. But I can provide more details if 
requested.
   
   ### Additional Context
   
   _No response_


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to