Skip to content

libyang header installation incompatible with multiarch installation #1739

@eqvinox

Description

@eqvinox

libyang's install includes an autogenerated config.h header, which unfortunately differs between 32-bit and 64-bit:

--- ./work/libyang-2.0.97_build-abi_x86_32.x86/src/config.h     2021-11-21 20:18:56.187900206 +0100
+++ ./work/libyang-2.0.97_build-abi_x86_64.amd64/src/config.h   2021-11-21 20:18:58.627783486 +0100
@@ -21,8 +21,8 @@
 /** plugins */
 #define LYPLG_SUFFIX ".so"
 #define LYPLG_SUFFIX_LEN (sizeof LYPLG_SUFFIX - 1)
-#define LYPLG_TYPE_DIR "/usr/lib/libyang/extensions"
-#define LYPLG_EXT_DIR "/usr/lib/libyang/types"
+#define LYPLG_TYPE_DIR "/usr/lib64/libyang/extensions"
+#define LYPLG_EXT_DIR "/usr/lib64/libyang/types"
 
 /** atomic compiler operations, to be able to use uint32_t */
 #define LY_ATOMIC_INC_BARRIER(var) __sync_fetch_and_add(&(var), 1)

This makes a multi-arch install problematic since that best way to do that is for the headers to not be different.

(Also I think the 2 defines are swapped?)

The best approach here would be to remove these variables and put them into the libyang.pc file instead. pkg-config files can include additional custom variables that can be queried, e.g.:

# cat libyang.pc
prefix=/usr
includedir=${prefix}/include
libdir=${prefix}/lib64
typesdir=${libdir}/libyang/types
extensionsdir=${libdir}/libyang/extensions

Name: libyang
Description: libyang is YANG data modelling language parser and toolkit written (and providing API) in C.
Version: 2.0.97
Requires.private: libpcre2-8
Libs: -L${libdir} -lyang
Libs.private: -lpcre2-8
Cflags: -I${includedir}
# PKG_CONFIG_PATH="`pwd`" pkg-config --variable=extensionsdir libyang
/usr/lib64/libyang/extensions

This solves the problem since 2 libyang.pc files will be installed, one for 32-bit and one for 64-bit.

P.S.: the #if (@CMAKE_C_COMPILER_ID@ == GNU) || (@CMAKE_C_COMPILER_ID@ == Clang) check is wrong too, there is no guarantee that the compiler used to build libyang is the same later used by some application using libyang. The check should be #ifdef __GNUC__ instead (clang defines that too.) And the @LYD_VALUE_SIZE@ replacement might cause issues later too.

Metadata

Metadata

Assignees

No one assigned

    Labels

    is:bugBug description.status:completedFrom the developer perspective, the issue was solved (bug fixed, question answered,...)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions