bluesky / libhkl

Build the hkl library for hklpy
https://people.debian.org/~picca/hkl/hkl.html
GNU General Public License v3.0
0 stars 0 forks source link

new APS POLAR geometry #13

Closed prjemian closed 1 month ago

prjemian commented 4 months ago

APS is developing support for its POLAR 6-circle diffractometer that is not covered by existing geometries in the libhkl library.

prjemian commented 4 months ago

Built a version of libhkl with added APS POLAR geometry for testing. Problems with loading the library on APS RedHat workstations.

python: symbol lookup error: ..../libhkl.so.5: undefined symbol: g_once_init_enter_pointer

The library is found but a symbol is undefined. This missing symbol is confirmed missing in the VM (this repo & branch) where the libhkl library is built.

prjemian commented 4 months ago

Examining the new libhkl library, I see it has reference to the undefined symbols. I can diagnose further in the VMs where that is built and tested.

(bluesky_2024_1) jemian@otz ~/Downloads $ nm /home/beams/JEMIAN/.conda/envs/bluesky_2024_1/lib/python3.11/site-packages/gi/../../../././libhkl.so.5 | grep once
                 U g_once_init_enter_pointer
                 U g_once_init_leave_pointer
0000000000053b00 t hkl_detector_get_type_once
0000000000053b30 t hkl_engine_get_type_once
0000000000053b60 t hkl_engine_list_get_type_once
0000000000053b90 t hkl_factory_get_type_once
0000000000053bc0 t hkl_geometry_get_type_once
0000000000053bf0 t hkl_geometry_list_get_type_once
0000000000053c20 t hkl_geometry_list_item_get_type_once
0000000000053c50 t hkl_lattice_get_type_once
0000000000053c80 t hkl_matrix_get_type_once
0000000000053cb0 t hkl_parameter_get_type_once
0000000000053ce0 t hkl_quaternion_get_type_once
0000000000053d10 t hkl_sample_get_type_once
0000000000053d40 t hkl_sample_reflection_get_type_once
0000000000053d70 t hkl_unit_get_type_once
0000000000053da0 t hkl_vector_get_type_once
prjemian commented 4 months ago

Confirm that gobject-introspection versions are the same:

in the source code builder (base) prjemian@arf:~/.../libhkl/builder$ git grep GOBJECT_INTROSPECTION_TAG Dockerfile:ENV GOBJECT_INTROSPECTION_TAG=1.78.1 Dockerfile:RUN echo "gobject-introspection version: ${GOBJECT_INTROSPECTION_TAG}" README.md:ENV GOBJECT_INTROSPECTION_TAG=1.78.1 step1b-build-local-libraries.sh:git checkout "${GOBJECT_INTROSPECTION_TAG}"

In my python at the office workstation gobject-introspection 1.78.1 py311h86ed371_1 conda-forge

prjemian commented 4 months ago

Poking around the gobject-introspection source code further, symbol g_once_init_enter_pointer is in their XML files:

root@f01e4cd88b36:/home/gobject-introspection# grep -R g_once_init_enter_pointer 2>&1 | grep -v binar | grep gir
_build/gir/GLib-2.0.gir:                c:identifier="g_once_init_enter_pointer"
_build/gir/GLib-2.0.gir:  if (g_once_init_enter_pointer (&interesting_struct))
_build/gir/GLib-2.0.gir:             line="726">Counterpart to g_once_init_enter_pointer(). Expects a location of a static
_build/gir/GLib-2.0.gir:releases concurrent threads blocking in g_once_init_enter_pointer() on this
_build/gir/GLib-2.0.gir:              c:identifier="g_once_init_enter_pointer"
_build/gir/GLib-2.0.gir:  if (g_once_init_enter_pointer (&interesting_struct))
_build/gir/GLib-2.0.gir:           line="726">Counterpart to g_once_init_enter_pointer(). Expects a location of a static
_build/gir/GLib-2.0.gir:releases concurrent threads blocking in g_once_init_enter_pointer() on this
_build/gir/GObject-2.0.gir:  if (g_once_init_enter_pointer (&static_g_define_type_id))
prjemian commented 4 months ago

But not in the Python directory:

(bluesky_2024_1) jemian@otz ~/Downloads $ pushd $CONDA_PREFIX/share/gir-1.0/
~/.conda/envs/bluesky_2024_1/share/gir-1.0 ~/Downloads
(bluesky_2024_1) jemian@otz ~/.../share/gir-1.0 $ ls
DBus-1.0.gir          GObject-2.0.gir        GstBase-1.0.gir        GstPbutils-1.0.gir  HarfBuzz-0.0.gir    gir-1.2.rnc      xrandr-1.3.gir
DBusGLib-1.0.gir      Gio-2.0.gir            GstCheck-1.0.gir       GstRtp-1.0.gir      Hkl-5.0.gir         libxml2-2.0.gir
GIRepository-2.0.gir  Gst-1.0.gir            GstController-1.0.gir  GstRtsp-1.0.gir     Vulkan-1.0.gir      win32-1.0.gir
GL-1.0.gir            GstAllocators-1.0.gir  GstGL-1.0.gir          GstSdp-1.0.gir      cairo-1.0.gir       xfixes-4.0.gir
GLib-2.0.gir          GstApp-1.0.gir         GstGLX11-1.0.gir       GstTag-1.0.gir      fontconfig-2.0.gir  xft-2.0.gir
GModule-2.0.gir       GstAudio-1.0.gir       GstNet-1.0.gir         GstVideo-1.0.gir    freetype2-2.0.gir   xlib-2.0.gir
(bluesky_2024_1) jemian@otz ~/.../share/gir-1.0 $ grep g_once_init_leave_pointer *
(bluesky_2024_1) jemian@otz ~/.../share/gir-1.0 $ grep g_once_init_enter_pointer *
prjemian commented 4 months ago

In the builder:

root@f01e4cd88b36:/home/gobject-introspection# ll _build/gir/GLib-2.0.gir 
-rw-r--r-- 1 root root 3.8M Apr 15 17:07 _build/gir/GLib-2.0.gir

In the conda environment

(bluesky_2024_1) jemian@otz ~/.../share/gir-1.0 $ ll GLib-2.0.gir
-rw------- 3 jemian aesbc 4.3M Oct  1  2023 GLib-2.0.gir

Those files are not identical. Some differences are due to how conda environments mangle the path names. Not entirely. Number of lines in each is different.

prjemian commented 4 months ago

Comparing versions of glibc2

builder

root@05a609600464:/opt/hkl# ldd --version
ldd (Debian GLIBC 2.31-13+deb11u8) 2.31
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Written by Roland McGrath and Ulrich Drepper.

local workstation

(base) prjemian@arf:~/.../libhkl/builder$ ldd --version
ldd (Ubuntu GLIBC 2.35-0ubuntu3.6) 2.35
Copyright (C) 2022 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Written by Roland McGrath and Ulrich Drepper.

office workstation

(base) jemian@otz ~ $ ldd --version
ldd (GNU libc) 2.34
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Written by Roland McGrath and Ulrich Drepper.
prjemian commented 4 months ago

In the builder, the symbol is defined in libglib-2.0:

root@3023b896498a:/home# nm  /usr/lib/x86_64-linux-gnu/libglib-2.0.so | grep g_once_init_enter_pointer
0000000000086a70 T g_once_init_enter_pointer
prjemian commented 4 months ago

more details (in the builder)

root@3023b896498a:/home# ll /usr/lib/x86_64-linux-gnu/libglib-2.0. libglib-2.0.a libglib-2.0.so libglib-2.0.so.0 libglib-2.0.so.0.6600.8 libglib-2.0.so.0.8100.0
root@3023b896498a:/home# nm /usr/lib/x86_64-linux-gnu/libglib-2.0 | grep g_once_init_enter_pointer nm: '/usr/lib/x86_64-linux-gnu/libglib-2.0': No such file root@3023b896498a:/home# nm /usr/lib/x86_64-linux-gnu/libglib-2.0.so | grep g_once_init_enter_pointer 0000000000086a70 T g_once_init_enter_pointer root@3023b896498a:/home# nm /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.8100.0 | grep g_once_init_enter_pointer 0000000000086a70 T g_once_init_enter_pointer

prjemian commented 4 months ago

In the builder

root@3023b896498a:/home# ll /usr/lib/x86_64-linux-gnu | grep libglib-2
-rw-r--r-- 1 root root 2.1M Sep 30 2023 libglib-2.0.a lrwxrwxrwx 1 root root 16 Apr 15 17:07 libglib-2.0.so -> libglib-2.0.so.0 lrwxrwxrwx 1 root root 23 Apr 15 17:07 libglib-2.0.so.0 -> libglib-2.0.so.0.8100.0 -rw-r--r-- 1 root root 1.2M Sep 30 2023 libglib-2.0.so.0.6600.8 -rwxr-xr-x 1 root root 5.7M Apr 15 17:07 libglib-2.0.so.0.8100.0*

prjemian commented 4 months ago

on office workstation:

(base) jemian@otz ~ $ ll /usr/lib64 | grep libglib-2 lrwxrwxrwx 1 root root 16 Jul 19 2023 libglib-2.0.so -> libglib-2.0.so.0 lrwxrwxrwx 1 root root 23 Jul 19 2023 libglib-2.0.so.0 -> libglib-2.0.so.0.6800.4 -rwxr-xr-x 1 root root 1.3M Jul 19 2023 libglib-2.0.so.0.6800.4*

on local workstation

(bluesky_2024_2) prjemian@arf:/tmp/hours$ ll /usr/lib/x86_64-linux-gnu/ | grep libglib-2 lrwxrwxrwx 1 root root 23 Jun 8 2023 libglib-2.0.so.0 -> libglib-2.0.so.0.7200.4 -rw-r--r-- 1 root root 1.3M Jun 8 2023 libglib-2.0.so.0.7200.4

prjemian commented 4 months ago

find /usr/ -iname "*libglib*so"

prjemian commented 4 months ago

In the builder, it's the gobject-introspection steps that make the switch between these two versions:

-rw-r--r-- 1 root root 1.2M Sep 30 2023 libglib-2.0.so.0.6600.8 <- originally-installed -rwxr-xr-x 1 root root 5.7M Apr 15 17:07 libglib-2.0.so.0.8100.0* <- revised when building gobject-introspection

prjemian commented 4 months ago

The upgrade (change in symlinks) happens in the meson-build step, due to this configuration of /home/gobject-introspection/_build/compile_commands.json:

    "directory": "/home/gobject-introspection/_build",
    "command": "cc -Isubprojects/glib/glib/libglib-2.0.so.0.8100.0.p -Isubprojects/glib/glib -I../subprojects/glib/glib -Isubprojects/glib -I../subprojects/glib -fvisibility=hidden -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -Wpedantic -std=gnu99 -O2 -g -D_GNU_SOURCE -fno-strict-aliasing -DG_DISABLE_CAST_CHECKS -Wduplicated-branches -Wimplicit-fallthrough -Wmisleading-indentation -Wmissing-field-initializers -Wnonnull -Wnull-dereference -Wunused -Wno-unused-parameter -Wno-cast-function-type -Wno-pedantic -Wno-format-zero-length -Wno-variadic-macros -Werror=format=2 -Werror=init-self -Werror=missing-include-dirs -Werror=pointer-arith -Werror=unused-result -Wstrict-prototypes -Wno-bad-function-cast -Werror=implicit-function-declaration -Werror=missing-prototypes -Werror=pointer-sign -fPIC -pthread '-DG_LOG_DOMAIN=\"GLib\"' -DGLIB_COMPILATION -MD -MQ subprojects/glib/glib/libglib-2.0.so.0.8100.0.p/deprecated_gallocator.c.o -MF subprojects/glib/glib/libglib-2.0.so.0.8100.0.p/deprecated_gallocator.c.o.d -o subprojects/glib/glib/libglib-2.0.so.0.8100.0.p/deprecated_gallocator.c.o -c ../subprojects/glib/glib/deprecated/gallocator.c",
    "file": "../subprojects/glib/glib/deprecated/gallocator.c",
    "output": "subprojects/glib/glib/libglib-2.0.so.0.8100.0.p/deprecated_gallocator.c.o"
  },

Next step is to avoid re-writing the symlink.

prjemian commented 4 months ago

https://discourse.gnome.org/t/glib-linking-problem-on-installation-of-gobject-introspection/20200

prjemian commented 4 months ago

Will installing latest libglib from anaconda help? 2.80.0 at this time.

prjemian commented 4 months ago

Installation at APS conda create -y -n hklpy conda-forge::hklpy includes:

libglib-2.80.0       | 3.8 MB    | ################################# | 100% 

Also need to define this env var to locate the libglib needed.

export LD_LIBRARY_PATH=$CONDA_PREFIX/lib
prjemian commented 4 months ago

At APS, without the LD_LIBRARY_PATH defined,

(hklpy) jemian@otz ~/Downloads $ ldd $CONDA_PREFIX/lib/libhkl.so
    linux-vdso.so.1 (0x00007ffc5fd59000)
    libgsl.so.25 => /lib64/libgsl.so.25 (0x00007f5473000000)
    libgslcblas.so.0 => /lib64/libgslcblas.so.0 (0x00007f54732ed000)
    libm.so.6 => /lib64/libm.so.6 (0x00007f5472f25000)
    libgobject-2.0.so.0 => /lib64/libgobject-2.0.so.0 (0x00007f5472eca000)
    libglib-2.0.so.0 => /lib64/libglib-2.0.so.0 (0x00007f5472d8f000)
    libc.so.6 => /lib64/libc.so.6 (0x00007f5472a00000)
    /lib64/ld-linux-x86-64.so.2 (0x00007f54733c8000)
    libffi.so.8 => /lib64/libffi.so.8 (0x00007f54732df000)
    libpcre.so.1 => /lib64/libpcre.so.1 (0x00007f5472d17000)

Note that necessary libraries came from the OS library directory /lib64/

prjemian commented 4 months ago

With the env var,

(hklpy) jemian@otz ~/Downloads $ export LD_LIBRARY_PATH=$CONDA_PREFIX/lib
(hklpy) jemian@otz ~/Downloads $ ldd $CONDA_PREFIX/lib/libhkl.so
    linux-vdso.so.1 (0x00007fff1b5fd000)
    libgsl.so.25 => /home/beams/JEMIAN/.conda/envs/hklpy/lib/libgsl.so.25 (0x00007f70d1fc7000)
    libgslcblas.so.0 => /home/beams/JEMIAN/.conda/envs/hklpy/lib/libgslcblas.so.0 (0x00007f70cfdee000)
    libm.so.6 => /lib64/libm.so.6 (0x00007f70cfcf7000)
    libgobject-2.0.so.0 => /home/beams/JEMIAN/.conda/envs/hklpy/lib/libgobject-2.0.so.0 (0x00007f70cfc94000)
    libglib-2.0.so.0 => /home/beams/JEMIAN/.conda/envs/hklpy/lib/libglib-2.0.so.0 (0x00007f70cfb49000)
    libc.so.6 => /lib64/libc.so.6 (0x00007f70cf800000)
    libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f70cfb42000)
    libgfortran.so.5 => /home/beams/JEMIAN/.conda/envs/hklpy/lib/./libgfortran.so.5 (0x00007f70cf655000)
    /lib64/ld-linux-x86-64.so.2 (0x00007f70d234b000)
    libffi.so.8 => /home/beams/JEMIAN/.conda/envs/hklpy/lib/./libffi.so.8 (0x00007f70cfb36000)
    libiconv.so.2 => /home/beams/JEMIAN/.conda/envs/hklpy/lib/./libiconv.so.2 (0x00007f70cfa4f000)
    libpcre2-8.so.0 => /home/beams/JEMIAN/.conda/envs/hklpy/lib/./libpcre2-8.so.0 (0x00007f70cf5af000)
    librt.so.1 => /lib64/librt.so.1 (0x00007f70cfa48000)
    libquadmath.so.0 => /home/beams/JEMIAN/.conda/envs/hklpy/lib/././libquadmath.so.0 (0x00007f70cfa0f000)
    libgcc_s.so.1 => /home/beams/JEMIAN/.conda/envs/hklpy/lib/././libgcc_s.so.1 (0x00007f70cf594000)
prjemian commented 4 months ago

This definition can be applied when the environment is activated. Here's an explanation.

prjemian commented 4 months ago

And some generalized advice how to set environment variables.

prjemian commented 4 months ago

Might compilation be easier if the conda-forge compiler tools were used?

prjemian commented 4 months ago

https://docs.conda.io/projects/conda-build/en/latest/resources/define-metadata.html

prjemian commented 1 month ago

Now contributed to Hkl source code: https://repo.or.cz/hkl.git

prjemian commented 1 month ago
#27 0.425 libhkl.VERSION='5.0.0.3512'
#27 0.425 1 APS POLAR
#27 0.425 2 E4CH
#27 0.425 3 E4CV
#27 0.425 4 E6C
#27 0.425 5 ESRF ID01 PSIC
#27 0.425 6 K4CV
#27 0.425 7 K6C
#27 0.425 8 PETRA3 P09 EH2
#27 0.425 9 PETRA3 P23 4C
#27 0.425 10    PETRA3 P23 6C
#27 0.425 11    SOLEIL MARS
#27 0.425 12    SOLEIL NANOSCOPIUM ROBOT
#27 0.425 13    SOLEIL SIRIUS KAPPA
#27 0.425 14    SOLEIL SIRIUS TURRET
#27 0.425 15    SOLEIL SIXS MED1+2
#27 0.425 16    SOLEIL SIXS MED2+2
#27 0.425 17    SOLEIL SIXS MED2+3
#27 0.425 18    SOLEIL SIXS MED2+3 v2
#27 0.425 19    TwoC
#27 0.425 20    ZAXIS