Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ci_build.sh auto-detection of paths and flags for trickier distros #2781

Merged
merged 25 commits into from
Jan 25, 2025

Conversation

jimklimov
Copy link
Member

@jimklimov jimklimov commented Jan 23, 2025

Previously there was a lot of smart guesswork applied to PKG_CONFIG_PATH on illumos/Solaris, and various tuning around HOMEBREW_PREFIX with MacOS, done in BUILD_TYPE=default* test cases, but not in developer-oriented build with an empty BUILD_TYPE or in-place builds for end users.

This PR moves into methods and revises that guesswork logic, allowing its re-use in both major use-cases.

As a practical benefit, builds on OmniOS where most of the non-core software is in "Extra" package repository installed under /opt/ooce, dependencies such as libusb-1 are much easier to find and actually use. Similar approach might apply to pkgsrc or similar popular alternative ecosystems.

UPDATE: Notes below are off-loaded into issue #2782 to address separately.

Note this does not at the moment solve run-time detection of dependencies outside of LD_LIBRARY_PATH:

...
configure:41265: checking whether we can build, link and/or run a program with libgd                                                                                                 
configure:41360: /usr/lib/ccache/gcc -o conftest -g -O2 -Wno-reserved-identifier -fdiagnostics-color=always -Wno-unknown-warning-option -std=gnu99 -D_REENTRANT -I/opt/ooce/include -
I/opt/ooce/include/libpng16 -I/opt/ooce/include -I/opt/ooce/include/freetype2 -I/opt/ooce/include -I/opt/ooce/include/webp -Werror -Werror=implicit-function-declaration     conftest
.c -lsocket -lnsl  -L/opt/ooce/lib/amd64 -lgd >&5                                                                                                                                    
configure:41360: $? = 0                                                                                                                                                              
configure:41360: ./conftest                                                                                                                                                          
ld.so.1: conftest: fatal: libgd.so.3: open failed: No such file or directory  

:; find /opt -name libgd.so.3
/opt/ooce/lib/amd64/libgd.so.3
/opt/ooce/lib/libgd.so.3

or

:; ./drivers/usbhid-ups -h
ld.so.1: usbhid-ups: fatal: libusb-1.0.so.0: open failed: No such file or directory
Killed

For the latter, notably, the driver got built right as a program, not as a libtool wrapper script. This may be a deficiency of OmniOS libtools build, as it impacts installed programs as well:

:; make DESTDIR=/tmp/nut-inst install

abuild@nutci-oo:~/nut$ /tmp/nut-inst/usr/local/ups/bin/usbhid-ups -h
ld.so.1: usbhid-ups: fatal: libusb-1.0.so.0: open failed: No such file or directory
Killed

abuild@nutci-oo:~/nut$ /tmp/nut-inst/usr/local/ups/bin/nut -h
nut-scanner           nutconf               nutdrv_atcl_usb       nutdrv_qx             nutdrv_siemens-sitop  

abuild@nutci-oo:~/nut$ /tmp/nut-inst/usr/local/ups/bin/nutconf -h
ld.so.1: nutconf: fatal: libnutscan.so.2: open failed: No such file or directory
Killed

abuild@nutci-oo:~/nut$ /tmp/nut-inst/usr/local/ups/bin/nut-scanner -h
ld.so.1: nut-scanner: fatal: libnutscan.so.2: open failed: No such file or directory
Killed

abuild@nutci-oo:~/nut$ /tmp/nut-inst/usr/local/ups/bin/upsc -h
ld.so.1: upsc: fatal: libupsclient.so.6: open failed: No such file or directory
Killed

The NUT library client programs do work in the build area, where they do have libtool wrappers:

abuild@nutci-oo:~/nut$ ls -la ./tools/nutconf/{.libs/,}nutconf 
-rwxr-xr-x   1 abuild   abuild   3335552 Jan 23 11:14 ./tools/nutconf/.libs/nutconf
-rwxr-xr-x   1 abuild   abuild      6294 Jan 23 11:14 ./tools/nutconf/nutconf

abuild@nutci-oo:~/nut$ ls -la ./clients/{.libs/,}upsc
-rwxr-xr-x   1 abuild   abuild    962544 Jan 23 11:13 ./clients/.libs/upsc
-rwxr-xr-x   1 abuild   abuild      6229 Jan 23 11:13 ./clients/upsc

abuild@nutci-oo:~/nut$ ls -la ./tools/nut-scanner/{.libs/,}nut-scanner
-rwxr-xr-x   1 abuild   abuild    188352 Jan 23 11:13 ./tools/nut-scanner/.libs/nut-scanner
-rwxr-xr-x   1 abuild   abuild      6310 Jan 23 11:13 ./tools/nut-scanner/nut-scanner

Probably hacking around with LD_LIBRARY_PATH (frowned upon) or crle (or crle -c) can help, but the correct way would be for the binaries to be linked the right way.

Similar issue happens with the installation in OpenIndiana, although its third-party dependencies like libusb are in common paths so work:

abuild@nutci-oi:~/nut$ /tmp/nut-inst/usr/local/ups/bin/nut-scanner -h
ld.so.1: nut-scanner: fatal: libnutscan.so.2: open failed: No such file or directory
Killed

abuild@nutci-oi:~/nut$ /tmp/nut-inst/usr/local/ups/bin/upsc -h
ld.so.1: upsc: fatal: libupsclient.so.6: open failed: No such file or directory
Killed

abuild@nutci-oi:~/nut$ /tmp/nut-inst/usr/local/ups/bin/usbhid-ups -h
Network UPS Tools 2.8.2.1968.12-1980-ge896ab87f (development iteration after 2.8.2) - Generic HID driver 0.60
USB communication driver (libusb 1.0) 0.50
...

Such paths are well built into the programs on other platforms, even non-default paths, e.g.

  • MacOS:
:; otool -L drivers/usbhid-ups
drivers/usbhid-ups:
	/usr/local/opt/libusb/lib/libusb-1.0.0.dylib (compatibility version 5.0.0, current version 5.0.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1319.0.0)
  • Linux:
:; ldd drivers/usbhid-ups
        linux-vdso.so.1 (0x00007ffc1c014000)
        libsystemd.so.0 => /lib/x86_64-linux-gnu/libsystemd.so.0 (0x00007fc8b1388000)
        libusb-1.0.so.0 => /lib/x86_64-linux-gnu/libusb-1.0.so.0 (0x00007fc8b136a000)
        libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fc8b1283000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fc8b105a000)
        liblzma.so.5 => /lib/x86_64-linux-gnu/liblzma.so.5 (0x00007fc8b102f000)
        libzstd.so.1 => /lib/x86_64-linux-gnu/libzstd.so.1 (0x00007fc8b0f5e000)
        liblz4.so.1 => /lib/x86_64-linux-gnu/liblz4.so.1 (0x00007fc8b0f3e000)
        libcap.so.2 => /lib/x86_64-linux-gnu/libcap.so.2 (0x00007fc8b0f33000)
        libgcrypt.so.20 => /lib/x86_64-linux-gnu/libgcrypt.so.20 (0x00007fc8b0df5000)
        /lib64/ld-linux-x86-64.so.2 (0x00007fc8b14d8000)
        libudev.so.1 => /lib/x86_64-linux-gnu/libudev.so.1 (0x00007fc8b0dcb000)
        libgpg-error.so.0 => /lib/x86_64-linux-gnu/libgpg-error.so.0 (0x00007fc8b0da3000)

jimklimov and others added 12 commits January 23, 2025 11:26
Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
…tion (least priority)

Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
…sent

Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
…usable methods

* ensure_CI_CCACHE_SYMLINKDIR_envvar()
* optional_prepare_ccache()
* optional_prepare_compiler_family() and helpers is_gnucc(), is_clang(),
  filter_version(), ver_gnucc(), ver_clang()
* optional_ensure_ccache()
* detect_platform_CANBUILD_LIBGD_CGI()
* detect_platform_PKG_CONFIG_PATH_and_FLAGS()

Signed-off-by: Jim Klimov <jim@jimklimov.com>
When BUILD_TYPE=="" or "inplace", make use of newly separated methods
like optional_ensure_ccache(), optional_prepare_compiler_family(),
detect_platform_PKG_CONFIG_PATH_and_FLAGS()

Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
… many logic paths on Solaris/illumos

Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
…h normalize_path()

Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
…h normalize_path() even more

Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
…k and before build

Signed-off-by: Jim Klimov <jimklimov@gmail.com>
…platform_PKG_CONFIG_PATH_and_FLAGS() in BUILD_TYPE=""/inplace cases

Signed-off-by: Jim Klimov <jimklimov@gmail.com>
@jimklimov jimklimov added CI Entries related to continuous integration infrastructure (historically also recipes like Makefiles) macOS Solaris/illumos Solaris and illumos systems (OpenIndiana, OmniOS, SmartOS, TribbliX...) portability We want NUT to build and run everywhere possible labels Jan 23, 2025
@jimklimov jimklimov added this to the 2.8.3 milestone Jan 23, 2025
Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
@AppVeyorBot
Copy link

…native builds with ccache

Nothing wrong in theory, but in practice either autotools or ccache build on that platform handles the expanded flags as if they were a path to non-existing location of a source file :\

Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
@AppVeyorBot
Copy link

…ent LTS 151046

Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
@AppVeyorBot
Copy link

…ng troubles with OOCE (Extra repo) [networkupstools#2782]

Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
…CONFIGURE_FLAGS

Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
@jimklimov jimklimov force-pushed the fix-ci-build-autodetect branch from 3c2c940 to 21b61f3 Compare January 24, 2025 13:42
@AppVeyorBot
Copy link

…ling sub-"make distcheck" [networkupstools#2541, fixes networkupstools#2542 fallout]

Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
jimklimov and others added 3 commits January 24, 2025 20:18
…RSION_DEFAULT3 and thus NUT_SOURCE_GITREV_IS_RELEASE in configure.ac (for distcheck or tarball builds) [networkupstools#1949]

Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
…values used by configure of the main build (e.g. passed some time ago from ci_build.sh or user), add CPPFLAGS and LDFLAGS to the mix

Signed-off-by: Jim Klimov <jimklimov@gmail.com>
Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
@jimklimov jimklimov force-pushed the fix-ci-build-autodetect branch from dec587a to 6a14151 Compare January 24, 2025 19:19
…e, and not only with C++ builds

Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
@jimklimov jimklimov force-pushed the fix-ci-build-autodetect branch from 043aafb to 5012f42 Compare January 25, 2025 11:21
@jimklimov jimklimov merged commit 66ed615 into networkupstools:master Jan 25, 2025
27 of 31 checks passed
@jimklimov jimklimov deleted the fix-ci-build-autodetect branch January 25, 2025 17:41
@jimklimov jimklimov mentioned this pull request Jan 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI Entries related to continuous integration infrastructure (historically also recipes like Makefiles) macOS portability We want NUT to build and run everywhere possible Solaris/illumos Solaris and illumos systems (OpenIndiana, OmniOS, SmartOS, TribbliX...)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants