Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 946135 - dev-ml/ocaml-ctypes-0.23.0::gentoo fails to build
Summary: dev-ml/ocaml-ctypes-0.23.0::gentoo fails to build
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal major
Assignee: Gentoo Team for the ML programming language family
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-12-09 08:25 UTC by Jaco Kroon
Modified: 2024-12-22 15:47 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
build.log (build.log,48.92 KB, text/x-log)
2024-12-09 08:28 UTC, Jaco Kroon
Details
emerge --info ocaml-ctypes (ocaml-ctypes-emerge-info.txt,7.89 KB, text/plain)
2024-12-18 10:24 UTC, Jaco Kroon
Details
verbose build.log (build.log,122.54 KB, text/x-log)
2024-12-20 13:54 UTC, Jaco Kroon
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jaco Kroon 2024-12-09 08:25:30 UTC
Hi,

This might be an environment issue, but I suspect missing dependency.

>>> Emerging (2 of 163) dev-ml/ocaml-ctypes-0.23.0::gentoo
>>> Failed to emerge dev-ml/ocaml-ctypes-0.23.0, Log file:
>>>  '/var/tmp/portage/dev-ml/ocaml-ctypes-0.23.0/temp/build.log'
>>> Jobs: 1 of 163 complete, 1 failed                                   Load avg: 7.31, 3.42, 1.75

 * Package:    dev-ml/ocaml-ctypes-0.23.0:0/0.23.0
 * Repository: gentoo
 * Maintainer: ml@gentoo.org
 * USE:        abi_x86_64 amd64 elibc_glibc kernel_linux ocamlopt
 * FEATURES:   network-sandbox preserve-libs sandbox userpriv usersandbox
>>> Unpacking source...
>>> Unpacking ocaml-ctypes-0.23.0.tar.gz to /var/tmp/portage/dev-ml/ocaml-ctypes-0.23.0/work
>>> Source unpacked in /var/tmp/portage/dev-ml/ocaml-ctypes-0.23.0/work
>>> Preparing source in /var/tmp/portage/dev-ml/ocaml-ctypes-0.23.0/work/ocaml-ctypes-0.23.0 ...
>>> Source prepared.
>>> Configuring source in /var/tmp/portage/dev-ml/ocaml-ctypes-0.23.0/work/ocaml-ctypes-0.23.0 ...
>>> Source configured.
>>> Compiling source in /var/tmp/portage/dev-ml/ocaml-ctypes-0.23.0/work/ocaml-ctypes-0.23.0 ...
 * dune build @install --display=short --profile release -j 6
      ocamlc src/ctypes-top/.ctypes_top.objs/byte/ctypes_top.{cmi,cmo,cmt}
    ocamlopt src/ctypes-top/.ctypes_top.objs/native/ctypes_top.{cmx,o}
...
    discover src/ctypes-foreign/backend.sexp,src/ctypes-foreign/c_flags,src/ctypes-foreign/c_flags.sexp,src/ctypes-foreign/c_library_flags.sexp
File "src/ctypes-foreign/dune", line 25, characters 33-47:
25 |   (names dl_stubs ffi_call_stubs ffi_type_stubs foreign_threaded_stubs)
                                      ^^^^^^^^^^^^^^
x86_64-pc-linux-gnu-gcc src/ctypes-foreign/ffi_type_stubs.o (exit 1)
ffi_type_stubs.c:14:10: fatal error: ffi.h: No such file or directory
   14 | #include <ffi.h>
      |          ^~~~~~~
compilation terminated.
File "src/ctypes-foreign/dune", line 25, characters 18-32:
25 |   (names dl_stubs ffi_call_stubs ffi_type_stubs foreign_threaded_stubs)
                       ^^^^^^^^^^^^^^
x86_64-pc-linux-gnu-gcc src/ctypes-foreign/ffi_call_stubs.o (exit 1)
ffi_call_stubs.c:22:10: fatal error: ffi.h: No such file or directory
   22 | #include <ffi.h>
      |          ^~~~~~~
compilation terminated.

Full build.log will be attached momentarily.

Reproducible: Always
Comment 1 Jaco Kroon 2024-12-09 08:28:36 UTC
Created attachment 913617 [details]
build.log
Comment 2 Tupone Alfredo gentoo-dev 2024-12-17 20:54:57 UTC
I dropped all dev-ml packages and emerge -D ocaml-ctypes and it builds correctly

The ffi.h is in libffi that is in DEPEND/RDEPEND

So the ebuild seems good.

If you want to help drop all dev-ml packages and then try:

emerge -aDv ocaml-ctypes

List all the packages it is emerging, so I can try with your version
Comment 3 Jaco Kroon 2024-12-18 10:24:29 UTC
Created attachment 914329 [details]
emerge --info ocaml-ctypes

(In reply to Tupone Alfredo from comment #2)
> I dropped all dev-ml packages and emerge -D ocaml-ctypes and it builds
> correctly
> 
> The ffi.h is in libffi that is in DEPEND/RDEPEND

*  dev-libs/libffi
      Latest version available: 3.4.6
      Latest version installed: 3.4.6
      Size of files: 1,360 KiB
      Homepage:      https://sourceware.org/libffi/
      Description:   Portable, high level programming interface to various calling conventions
      License:       MIT

And installed, but still I get:

File "src/ctypes-foreign/dune", line 25, characters 33-47:
25 |   (names dl_stubs ffi_call_stubs ffi_type_stubs foreign_threaded_stubs)
                                      ^^^^^^^^^^^^^^
x86_64-pc-linux-gnu-gcc src/ctypes-foreign/ffi_type_stubs.o (exit 1)
ffi_type_stubs.c:14:10: fatal error: ffi.h: No such file or directory
   14 | #include <ffi.h>
      |          ^~~~~~~
compilation terminated.
x86_64-pc-linux-gnu-gcc src/ctypes-foreign/foreign_threaded_stubs.o
File "src/ctypes-foreign/dune", line 25, characters 18-32:
25 |   (names dl_stubs ffi_call_stubs ffi_type_stubs foreign_threaded_stubs)
                       ^^^^^^^^^^^^^^
x86_64-pc-linux-gnu-gcc src/ctypes-foreign/ffi_call_stubs.o (exit 1)
ffi_call_stubs.c:22:10: fatal error: ffi.h: No such file or directory
   22 | #include <ffi.h>
      |          ^~~~~~~


> So the ebuild seems good.

As mentioned, may be my environment.  But I cannot see what.

I've attached emerge --info 

> If you want to help drop all dev-ml packages and then try:
> 
> emerge -aDv ocaml-ctypes

Doesn't help.

> List all the packages it is emerging, so I can try with your version

[ebuild  rR    ] dev-ml/camlzip-1.11:1/1.11::gentoo  USE="ocamlopt" 28 KiB
[ebuild  r  U  ] dev-ml/camlbz2-0.8.0-r1:0/0.8.0::gentoo [0.7.0:0/0.7.0::gentoo] USE="ocamlopt" 17 KiB
[ebuild  r  U  ] dev-ml/ocaml-ctypes-0.23.0:0/0.23.0::gentoo [0.20.1:0/0.20.1::gentoo] USE="ocamlopt -test" 0 KiB
[ebuild  rR    ] dev-ml/parmap-1.2.5:0/1.2.5::gentoo  USE="ocamlopt" 0 KiB
[ebuild  r  U  ] dev-ml/ocamlgraph-2.1.0:0/2.1.0::gentoo [2.0.0-r1:0/2.0.0::gentoo] USE="ocamlopt" 0 KiB
[ebuild  r  U  ] dev-ml/luv-0.5.14-r1:0/0.5.14::gentoo [0.5.12:0/0.5.12::gentoo] USE="ocamlopt -test" 0 KiB
[ebuild  rR    ] dev-ml/ppx_here-0.16.0:0/0.16::gentoo  USE="ocamlopt" 0 KiB
[ebuild  rR    ] dev-ml/ppx_let-0.16.0:0/0.16::gentoo  USE="ocamlopt" 0 KiB
[ebuild  rR    ] dev-ml/ocaml-gettext-0.4.2-r1:0/0.4.2::gentoo  USE="ocamlopt -test" 0 KiB
[ebuild  rR    ] dev-ml/ocaml-gettext-stub-0.4.2-r2:0/0.4.2::gentoo  USE="ocamlopt -test" 0 KiB
[ebuild  r  U  ] dev-ml/dose3-7.0.0-r1:0/7.0.0::gentoo [7.0.0:0/7.0.0::gentoo] USE="ocamlopt" 0 KiB
[ebuild  rR    ] dev-ml/mccs-1.1.17:0/1.1.17::gentoo  USE="ocamlopt -test" 0 KiB
[ebuild  rR    ] dev-ml/opam-2.1.6:0/2.1.6::gentoo  USE="ocamlopt" 0 KiB
[ebuild  rR    ] dev-ml/opam-installer-2.1.6:0/2.1.6::gentoo  USE="ocamlopt" 0 KiB
[ebuild  rR    ] dev-ml/react-1.2.2-r1:0/1.2.2::gentoo  USE="-test" 0 KiB
[ebuild  rR    ] dev-ml/lwt-5.7.0:0/5.7.0::gentoo  USE="ocamlopt" 0 KiB
[ebuild  rR    ] dev-ml/ounit2-2.2.7-r1:0/2.2.7::gentoo  USE="ocamlopt" 0 KiB
[ebuild  rR    ] app-emulation/libguestfs-1.48.6-r1:0/1.48::gentoo  USE="fuse gtk ocaml -doc -erlang -inspect-icons -introspection -libvirt -lua -perl -python -ruby (-selinux) -static-libs -systemtap -test" LUA_SINGLE_TARGET="lua5-1" PYTHON_SINGLE_TARGET="python3_12 -python3_10 -python3_11" 0 KiB
[ebuild  rR    ] app-emulation/guestfs-tools-1.48.2:0/1.48::gentoo  USE="ocaml -doc -perl -test" 0 KiB

Failed in above mode.  Any other package lists that may be helpful?
Comment 4 Tupone Alfredo gentoo-dev 2024-12-18 11:29:59 UTC
I don't see dev-ml/dune. So I don't think you removed all the dev-ml packages.

If you want you can go to /var/db/pkg and then emerge -C dev-ml/*

And the command to get the list of dev-ml packages:

emerge -av dev-ml/ocaml-ctypes
Comment 5 Jaco Kroon 2024-12-18 11:52:43 UTC
plastiekpoot [13:48:01] ~ # emerge -C $(qlist -IC dev-ml/*)
...
>>> Unmerging (1 of 46) dev-ml/base-0.16.3-r1...
...
>>> Unmerging (46 of 46) dev-ml/xml-light-2.5...

plastiekpoot [13:49:35] ~ # emerge -aDv ocaml-ctypes
...
Dependency resolution took 4.92 s (backtrack: 0/20).

[ebuild  N     ] dev-ml/dune-3.16.0:0/3.16.0::gentoo  USE="-emacs" 0 KiB
[ebuild  N     ] dev-ml/bigarray-compat-1.1.0::gentoo  USE="ocamlopt" 0 KiB
[ebuild  N     ] dev-ml/result-1.5:0/1.5::gentoo  USE="ocamlopt" 0 KiB
[ebuild  N     ] dev-ml/stdlib-shims-0.3.0::gentoo  USE="ocamlopt" 0 KiB
[ebuild  N     ] dev-ml/integers-0.7.0:0/0.7.0::gentoo  USE="ocamlopt" 0 KiB
[ebuild  N     ] dev-ml/csexp-1.5.2-r1:0/1.5.2::gentoo  USE="ocamlopt -test" 0 KiB
[ebuild  N     ] dev-ml/dune-configurator-3.16.0-r1:0/3.16.0::gentoo  USE="ocamlopt" 0 KiB
[ebuild  N     ] dev-ml/ocaml-ctypes-0.23.0:0/0.23.0::gentoo  USE="ocamlopt -test" 0 KiB

Total: 8 packages (8 new), Size of downloads: 0 KiB

Would you like to merge these packages? [Yes/No] 

...
>>> Completed (7 of 8) dev-ml/dune-configurator-3.16.0-r1::gentoo
>>> Emerging (8 of 8) dev-ml/ocaml-ctypes-0.23.0::gentoo
...

and failure mode remains unaltered.  Happy to try more suggestions/action further trouble shooting, just need to know which rabbit hole to start down.
Comment 6 Tupone Alfredo gentoo-dev 2024-12-18 19:28:49 UTC
I have built exactly with your version of packages with ocaml-4.14.2, and all goes smooth, It does not seems a missing dependency.

I hope I could find a problem here so I can fix it, but no

When you say 
"This might be an environment issue"
what do you mean?
Comment 7 Jaco Kroon 2024-12-19 08:15:07 UTC
I mean it may be something weird on my laptop.  Having said that, I just bumped into same on another machine where I'm not quite so adventurous with setting random stuff.

arthur [09:50:18] ~ # emerge -C $(qlist -IC dev-ml/*)
... removed 7 packages.
arthur [09:50:46] ~ # emerge -aDv ocaml-ctypes
...
[ebuild  N     ] dev-ml/dune-3.16.0:0/3.16.0::gentoo  USE="-emacs" 0 KiB
[ebuild  N     ] dev-ml/bigarray-compat-1.1.0::gentoo  USE="ocamlopt" 0 KiB
[ebuild  N     ] dev-ml/result-1.5:0/1.5::gentoo  USE="ocamlopt" 0 KiB
[ebuild  N     ] dev-ml/stdlib-shims-0.3.0::gentoo  USE="ocamlopt" 0 KiB
[ebuild  N     ] dev-ml/integers-0.7.0:0/0.7.0::gentoo  USE="ocamlopt" 0 KiB
[ebuild  N     ] dev-ml/csexp-1.5.2-r1:0/1.5.2::gentoo  USE="ocamlopt -test" 0 KiB
[ebuild  N     ] dev-ml/dune-configurator-3.16.0-r1:0/3.16.0::gentoo  USE="ocamlopt" 0 KiB
[ebuild  N     ] dev-ml/ocaml-ctypes-0.23.0:0/0.23.0::gentoo  USE="ocamlopt -test" 0 KiB
...

File "src/ctypes-foreign/dune", line 25, characters 18-32:
25 |   (names dl_stubs ffi_call_stubs ffi_type_stubs foreign_threaded_stubs)
                       ^^^^^^^^^^^^^^
x86_64-pc-linux-gnu-gcc src/ctypes-foreign/ffi_call_stubs.o (exit 1)
ffi_call_stubs.c:22:10: fatal error: ffi.h: No such file or directory
   22 | #include <ffi.h>
      |          ^~~~~~~
compilation terminated.
File "src/ctypes-foreign/dune", line 25, characters 33-47:
25 |   (names dl_stubs ffi_call_stubs ffi_type_stubs foreign_threaded_stubs)
                                      ^^^^^^^^^^^^^^
x86_64-pc-linux-gnu-gcc src/ctypes-foreign/ffi_type_stubs.o (exit 1)
ffi_type_stubs.c:14:10: fatal error: ffi.h: No such file or directory
   14 | #include <ffi.h>
      |          ^~~~~~~

jkroon@plastiekpoot ~ $ find /usr/include/ -name ffi.h
/usr/include/botan-3/botan/ffi.h
/usr/include/botan-2/botan/ffi.h

However, on arthur:

arthur [10:04:39] ~ # find /usr/include/ -name ffi.h
arthur [10:09:04] ~ # 

Both systems has libffi installed (3.4.6), but neither one has a ffi.h file installed in /usr/include, however:

jkroon@plastiekpoot ~ $ equery files libffi | grep ffi[.]h
/usr/lib64/libffi/include/ffi.h

arthur [10:09:39] ~ # equery files libffi | grep ffi[.]h
/usr/lib64/libffi/include/ffi.h

So either we're missing some compile option here to *find* that location, or libffi isn't installing into the correct location (IMHO).

Looking at the libffi ebuild, it explicitly passes --includedir="${EPREFIX}"/usr/$(get_libdir)/${PN}/include to econf.

Regardless, pkg-config returns the appropriate cflags:

jkroon@plastiekpoot ~ $ pkg-config --cflags libffi
-I/usr/lib64/libffi/include

And just for completeness, --libs also seems OK.

jkroon@plastiekpoot ~ $ pkg-config --libs libffi
-lffi
jkroon@plastiekpoot ~ $ equery files libffi | grep libffi
/usr/lib64/libffi
/usr/lib64/libffi.so

I'm somewhat stumped.
Comment 8 Tupone Alfredo gentoo-dev 2024-12-20 07:52:22 UTC
Try to add the following line to the ebuild, to show the real commands dune is running. Maybe you can get some hints:

src_compile() {
       dune build @install --verbose --profile release -j 1
}
Comment 9 Jaco Kroon 2024-12-20 13:54:46 UTC
Created attachment 914496 [details]
verbose build.log

The colour output doesn't help, but there you have it, these are the two that's problematic:

Running[113]: (cd _build/default/src/ctypes-foreign && /usr/bin/x86_64-pc-linux-gnu-gcc -O2 -fno-strict-aliasing -fwrapv -pthread -fPIC -O2 -march=native -pipe -D_FILE_OFFSET_BITS=64 -fdiagnostics-color=always -g -I /usr/lib64/ocaml -I /usr/lib64/ocaml/bigarray-compat -I /usr/lib64/ocaml/integers -I /usr/lib64/ocaml/stdlib-shims -I /usr/lib64/ocaml/threads -I ../ctypes -o ffi_call_stubs.o -c ffi_call_stubs.c)
File "src/ctypes-foreign/dune", line 25, characters 18-32:
25 |   (names dl_stubs ffi_call_stubs ffi_type_stubs foreign_threaded_stubs)
                       ^^^^^^^^^^^^^^
Command [113] exited with code 1:
$ (cd _build/default/src/ctypes-foreign && /usr/bin/x86_64-pc-linux-gnu-gcc -O2 -fno-strict-aliasing -fwrapv -pthread -fPIC -O2 -march=native -pipe -D_FILE_OFFSET_BITS=64 -fdiagnostics-color=always -g -I /usr/lib64/ocaml -I /usr/lib64/ocaml/bigarray-compat -I /usr/lib64/ocaml/integers -I /usr/lib64/ocaml/stdlib-shims -I /usr/lib64/ocaml/threads -I ../ctypes -o ffi_call_stubs.o -c ffi_call_stubs.c)
ffi_call_stubs.c:22:10: fatal error: ffi.h: No such file or directory
   22 | #include <ffi.h>
      |          ^~~~~~~
compilation terminated.


Running[114]: (cd _build/default/src/ctypes-foreign && /usr/bin/x86_64-pc-linux-gnu-gcc -O2 -fno-strict-aliasing -fwrapv -pthread -fPIC -O2 -march=native -pipe -D_FILE_OFFSET_BITS=64 -fdiagnostics-color=always -g -I /usr/lib64/ocaml -I /usr/lib64/ocaml/bigarray-compat -I /usr/lib64/ocaml/integers -I /usr/lib64/ocaml/stdlib-shims -I /usr/lib64/ocaml/threads -I ../ctypes -o ffi_type_stubs.o -c ffi_type_stubs.c)
File "src/ctypes-foreign/dune", line 25, characters 33-47:
25 |   (names dl_stubs ffi_call_stubs ffi_type_stubs foreign_threaded_stubs)
                                      ^^^^^^^^^^^^^^
Command [114] exited with code 1:
$ (cd _build/default/src/ctypes-foreign && /usr/bin/x86_64-pc-linux-gnu-gcc -O2 -fno-strict-aliasing -fwrapv -pthread -fPIC -O2 -march=native -pipe -D_FILE_OFFSET_BITS=64 -fdiagnostics-color=always -g -I /usr/lib64/ocaml -I /usr/lib64/ocaml/bigarray-compat -I /usr/lib64/ocaml/integers -I /usr/lib64/ocaml/stdlib-shims -I /usr/lib64/ocaml/threads -I ../ctypes -o ffi_type_stubs.o -c ffi_type_stubs.c)
ffi_type_stubs.c:14:10: fatal error: ffi.h: No such file or directory
   14 | #include <ffi.h>
      |          ^~~~~~~
compilation terminated.

Definitely missing the -I for libffi.
Comment 10 Tupone Alfredo gentoo-dev 2024-12-20 14:46:43 UTC
Here it is mine:

cd _build/default/src/ctypes-foreign && /usr/bin/x86_64-pc-linux-gnu-gcc -O2 -fno-strict-aliasing -fwrapv -pthread -fPIC -march=native -O2 -pipe -fomit-frame-pointer -D_FILE_OFFSET_BITS=64 -fdiagnostics-color=always -I/usr/lib64/libffi/include -g -I /usr/lib64/ocaml -I /usr/lib64/ocaml/bigarray-compat -I /usr/lib64/ocaml/integers -I /usr/lib64/ocaml/stdlib-shims -I /usr/lib64/ocaml/threads -I ../ctypes -o ffi_call_stubs.o -c ffi_call_stubs.c
Comment 11 Tupone Alfredo gentoo-dev 2024-12-20 19:24:49 UTC
try 
src_compile() {
    strace -f dune build @install --verbose --profile release -j 1 \
        2> ctypes.strace
}

You should find something like 
"/usr/bin/pkg-config", "--cflags", "libffi"

take note of the pid and wait for changes. Some line above you should see 

"-I/usr/lib64/libffi/include\n"
Comment 12 Jaco Kroon 2024-12-21 05:36:33 UTC
Hi,

Generated file (as expected) is quite big, not going to upload unless specifically requested.

plastiekpoot [07:12:49] /var/tmp/portage/dev-ml/ocaml-ctypes-0.23.0/work/ocaml-ctypes-0.23.0 # grep pkg-config ctypes.strace 
[pid   589] newfstatat(AT_FDCWD, "/var/tmp/portage/dev-ml/ocaml-ctypes-0.23.0/work/ocaml-ctypes-0.23.0/_build/install/default/bin//usr/bin/pkg-config", 0x7ffd76de45d0, 0) = -1 ENOENT (No such file or directory)
[pid   589] newfstatat(AT_FDCWD, "/usr/lib/portage/python3.12/ebuild-helpers/xattr//usr/bin/pkg-config", 0x7ffd76de45d0, 0) = -1 ENOENT (No such file or directory)
[pid   589] newfstatat(AT_FDCWD, "/usr/lib/portage/python3.12/ebuild-helpers//usr/bin/pkg-config", 0x7ffd76de45d0, 0) = -1 ENOENT (No such file or directory)
[pid   589] newfstatat(AT_FDCWD, "/usr/local/sbin//usr/bin/pkg-config", 0x7ffd76de45d0, 0) = -1 ENOENT (No such file or directory)
[pid   589] newfstatat(AT_FDCWD, "/usr/local/bin//usr/bin/pkg-config", 0x7ffd76de45d0, 0) = -1 ENOENT (No such file or directory)
[pid   589] newfstatat(AT_FDCWD, "/usr/sbin//usr/bin/pkg-config", 0x7ffd76de45d0, 0) = -1 ENOENT (No such file or directory)
[pid   589] newfstatat(AT_FDCWD, "/usr/bin//usr/bin/pkg-config", 0x7ffd76de45d0, 0) = -1 ENOENT (No such file or directory)
[pid   589] newfstatat(AT_FDCWD, "/sbin//usr/bin/pkg-config", 0x7ffd76de45d0, 0) = -1 ENOENT (No such file or directory)
[pid   589] newfstatat(AT_FDCWD, "/bin//usr/bin/pkg-config", 0x7ffd76de45d0, 0) = -1 ENOENT (No such file or directory)
[pid   589] newfstatat(AT_FDCWD, "/opt/bin//usr/bin/pkg-config", 0x7ffd76de45d0, 0) = -1 ENOENT (No such file or directory)
[pid   589] newfstatat(AT_FDCWD, "/usr/lib/llvm/18/bin//usr/bin/pkg-config", 0x7ffd76de45d0, 0) = -1 ENOENT (No such file or directory)
[pid   589] newfstatat(AT_FDCWD, "/usr/lib/llvm/17/bin//usr/bin/pkg-config", 0x7ffd76de45d0, 0) = -1 ENOENT (No such file or directory)
[pid   589] newfstatat(AT_FDCWD, "/etc/eselect/wine/bin//usr/bin/pkg-config", 0x7ffd76de45d0, 0) = -1 ENOENT (No such file or directory)

No matter how I look at that, it looks broken.  So my analysis op how we got to pid 589:

[pid    26] clone(child_stack=NULL, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLDstrace: Process 589 attached
, child_tidptr=0x7f1c61286e50) = 589

Lots of setup and then:

[pid   589] execve("config/discover.exe", ["config/discover.exe"], 0x55ff262b0400 /* 280 vars */ <unfinished ...>

pid 26 seems to be the top-most process in this case:

clone3({flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID, child_tid=0x7f1c60bad990, parent_tid=0x7f1c60bad990, exit_signal=0, stack=0x7f1c603ad000, stack_size=0x7fff80, tls=0x7f1c60bad6c0} => {parent_tid=[27]}, 88) = 27
rt_sigprocmask(SIG_SETMASK, [INT QUIT TERM CONT TSTP WINCH], NULL, 8) = 0
mmap(NULL, 8392704, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_STACK, -1, 0strace: Process 27 attached
) = 0x7f1c5fbac000
[pid    26] mprotect(0x7f1c5fbad000, 8388608, PROT_READ|PROT_WRITE) = 0
[pid    27] rseq(0x7f1c60badfe0, 0x20, 0, 0x53053053 <unfinished ...>


Since pid=27 is the child here, 26 has to be topmost (initially strace didn't output the pid  XXX portions of the output).

So back to configure.exe:

plastiekpoot [07:25:06] /var/tmp/portage/dev-ml/ocaml-ctypes-0.23.0/work/ocaml-ctypes-0.23.0 # ldd ./_build/default/src/ctypes-foreign/config/discover.exe
	linux-vdso.so.1 (0x00007fa5595f8000)
	libm.so.6 => /lib64/libm.so.6 (0x00007fa5593d3000)
	libc.so.6 => /lib64/libc.so.6 (0x00007fa559200000)
	/lib64/ld-linux-x86-64.so.2 (0x00007fa5595fa000)

So nothing strange there, but looking at strings, I cannot find any of the PATHs it looks at in the binary.

From _build/log:

109 $ (cd _build/default && /usr/bin/ocamlopt.opt -w -40 -g -I src/ctypes-foreign/config/.discover.eobjs/byte -I src/ctypes-foreign/config/.discover.eobjs/native -I /usr/lib64/ocaml/dune-configurator -I /usr/lib64/ocaml/dune-configurator/csexp -intf-suffix .ml -no-alias-deps -o src/ctypes-foreign/config/.discover.eobjs/native/dune__exe__Discover.cmx -c -impl src/ctypes-foreign/config/discover.ml)


119 $ (cd _build/default && /usr/bin/ocamlopt.opt -w -40 -g -o src/ctypes-foreign/config/discover.exe /usr/lib64/ocaml/unix.cmxa -I /usr/lib64/ocaml /usr/lib64/ocaml/dune-configurator/csexp/csexp.cmxa /usr/lib64/ocaml/dune-configurator/configurator.cmxa src/ctypes-foreign/config/.discover.eobjs/native/dune__exe__Discover.cmx)

126 $ (cd _build/default/src/ctypes-foreign && config/discover.exe)

Inspecting default/src/ctypes-foreign/config/discover.ml it seems to look for pkg_config (last looked at Prolog ML more than 20 years back, so rusty at best) and then has some fallbacks.

The other two "sources":

plastiekpoot [07:33:20] ~ # equery belongs /usr/lib64/ocaml/dune-configurator/csexp/csexp.cmxa /usr/lib64/ocaml/dune-configurator/configurator.cmxa
 * Searching for /usr/lib64/ocaml/dune-configurator/csexp/csexp.cmxa,/usr/lib64/ocaml/dune-configurator/configurator.cmxa ... 
dev-ml/dune-configurator-3.16.0-r1 (/usr/lib64/ocaml/dune-configurator/csexp/csexp.cmxa)
dev-ml/dune-configurator-3.16.0-r1 (/usr/lib64/ocaml/dune-configurator/configurator.cmxa)

Looking at all files in /usr/lib64/ocaml/dune-configurator I still don't get where those odd paths are coming from, what's the possibility that something somewhere is messing with the PATH variable prior to trying to compile ocaml-ctypes?
Comment 13 Tupone Alfredo gentoo-dev 2024-12-21 07:49:59 UTC
I see /usr/bin//usr/bin/pkg-config

Maybe you have some definition of PKG_CONFIG=/usr/bin/pkg-config or similar around

as the executable path is the $PATH concatenated to /usr/bin/pkg-config

I don't know if that is accepted, but that is not work with this package actually
Comment 14 Tupone Alfredo gentoo-dev 2024-12-21 11:15:18 UTC
(In reply to Tupone Alfredo from comment #13)
> I see /usr/bin//usr/bin/pkg-config
> 
> Maybe you have some definition of PKG_CONFIG=/usr/bin/pkg-config or similar
> around
> 
> as the executable path is the $PATH concatenated to /usr/bin/pkg-config
> 
> I don't know if that is accepted, but that is not work with this package
> actually

I was able to replicate with 

PKG_CONFIG=/usr/bin/pkg-config ebuild ocaml-ctypes-0.23.0.ebuild clean compile
Comment 15 Larry the Git Cow gentoo-dev 2024-12-21 11:34:04 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=88128d8561ad1f2d6fdf2a96aad24116e3f8a144

commit 88128d8561ad1f2d6fdf2a96aad24116e3f8a144
Author:     Alfredo Tupone <tupone@gentoo.org>
AuthorDate: 2024-12-21 11:33:14 +0000
Commit:     Alfredo Tupone <tupone@gentoo.org>
CommitDate: 2024-12-21 11:33:43 +0000

    dev-ml/dune-configurator: add 3.17.1
    
    Bug: https://bugs.gentoo.org/946135
    Signed-off-by: Alfredo Tupone <tupone@gentoo.org>

 dev-ml/dune-configurator/Manifest                  |  1 +
 .../dune-configurator-3.17.1.ebuild                | 39 ++++++++++++++++++++++
 2 files changed, 40 insertions(+)
Comment 16 Tupone Alfredo gentoo-dev 2024-12-21 11:35:16 UTC
Can use this version of dune.configurator (3.17.1) to build with that PKG_CONFIG
Comment 17 Jaco Kroon 2024-12-22 15:47:07 UTC
jkroon@plastiekpoot /etc/portage $ grep -C 1 -r PKG_CONFIG
bashrc-# Some bug in (at least) the htop ./configure script.
bashrc:export PKG_CONFIG=/usr/bin/pkg-config
bashrc-

Well, there we go.  Good call.

That went into our bashrc with the following commit:

commit f6b60ceabc8f1803a2dc9f5a06b81e1a1e5f8ab5
Author: Jaco Kroon <jaco@uls.co.za>
Date:   Tue Jan 10 15:51:58 2017 +0200

    Work around braindeadness in htop configure script that doesn't
    automatically pick up the pkg-config command.  There may be others too.


And *that* is something with the environment :).

With *only* removing that one export line I've managed to remerge ocaml-ctypes, and htop works correctly, so I've reverted that commit from our own tree as well.

I *suspect* the new dune-configurator package checks for an absolute path in PKG_CONFIG ... so that'll give it too, thank you for the effort, really thankful you managed to track down the root cause.