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

CI: configure script's m4/* library checks begin with CFLAGS="" #2673

Closed
jimklimov opened this issue Nov 8, 2024 · 1 comment · Fixed by #2675
Closed

CI: configure script's m4/* library checks begin with CFLAGS="" #2673

jimklimov opened this issue Nov 8, 2024 · 1 comment · Fixed by #2675
Labels
bug CI Entries related to continuous integration infrastructure (historically also recipes like Makefiles) cross-builds impacts-release-2.8.2 Issues reported against NUT release 2.8.2 (maybe vanilla or with minor packaging tweaks) portability We want NUT to build and run everywhere possible
Milestone

Comments

@jimklimov
Copy link
Member

jimklimov commented Nov 8, 2024

The goal of emptying the CFLAGS is to determine (from pkg-config, CLI args or other sources) the actual set of tokens needed by a dependency.

This however leads to NOT using some earlier discovered (or caller-provided) CFLAGS in some of those tests, notably with hints about customized bitness or target architecture. As a result, a build system capable of building for several targets actually checks some of the dependencies for the compiler-default target. Most of the time this is okay if dependencies are all present consistently for all targets, but fails if targets are provisioned with different abilities.

As a practical example, OpenIndiana is capable of 32-bit (i386) and 64-bit (amd64) builds. It provides a libgd which is unfortunately broken for 32-bit version (packaging no longer delivers some shared objects used by libgd.so for the platform, but the library itself, headers and pkg-config metadata are delivered). Tests with gcc-7 compiler (targeting 32-bit by default) fail to find a functional libgd even if we call CFLAGS=-m64 ./configure --with-cgi for an explicit 64-bit build. Some code is tested for 64-bit compile-/link-ability, but m4/nut_check_libgd.m4 is subject to compiler defaults, tests the broken 32-bit library, and bails out.

It also does not help when pkg-config returns linkage info correct for the requested target platform (per --with-pkg-config-path settings), but the compiler tries to build for another:

configure:23778: checking for Mozilla NSS version via pkg-config
configure:23784: result: 3.98 found
configure:23811: checking for Mozilla NSS cflags
configure:23829: result: -I/usr/include/mps
configure:23832: checking for Mozilla NSS ldflags
configure:23850: result: -L/usr/lib/mps/amd64 -R/usr/lib/mps/amd64 -lnss3 -lsmime3 -lssl3 -lnssutil3 -R/usr/lib/mps/amd64 -lplds4 -lplc4 -lnspr4 -lpthread -ldl -lposix4
configure:23856: checking for NSS_Init
configure:23856: /usr/lib/ccache/gcc-7 -o conftest -I/usr/include/mps  -I/export/home/abuild/nut/tmp/include -L/export/home/abuild/nut/tmp/lib  conftest.c -L/usr/lib/mps/amd64 -R/usr/lib/mps/amd64 -lnss3 -lsmime3 -lssl3 -lnssutil3 -R/usr/lib/mps/amd64 -lplds4 -lplc4 -lnspr4 -lpthread -ldl -lposix4 >&5
ld: fatal: file /usr/lib/mps/amd64/libnss3.so: wrong ELF class: ELFCLASS64
ld: fatal: file /usr/lib/mps/amd64/libsmime3.so: wrong ELF class: ELFCLASS64
ld: fatal: file /usr/lib/mps/amd64/libssl3.so: wrong ELF class: ELFCLASS64
ld: fatal: file /usr/lib/mps/amd64/libnssutil3.so: wrong ELF class: ELFCLASS64
ld: fatal: file /usr/lib/mps/amd64/libplds4.so: wrong ELF class: ELFCLASS64
ld: fatal: file /usr/lib/mps/amd64/libplc4.so: wrong ELF class: ELFCLASS64
ld: fatal: file /usr/lib/mps/amd64/libnspr4.so: wrong ELF class: ELFCLASS64
ld: fatal: file processing errors. No output written to conftest
collect2: error: ld returned 1 exit status
configure:23856: $? = 1

This issue is about thinking some way around the problem. For example, we could track COMPONENT_CFLAGS etc. in their dedicated variables right away, maybe kept private until success, and mix with the stored copy of original CFLAGS etc. for practical tests (perhaps also somehow determine which flags are "systemic")?.. An example prospective solution is in m4/nut_check_libnss.m4 in fact, where it honours original -m32/-m64 if present in the flags (and if GCC==yes), attaching them to the copy of $CC used by the test.

Also it would be wise to find a way of checking/ensuring that pkg-config results (or search path?) match the compiler default/requested target architecture, so configure-time discoveries are representative of what the actual build/link would achieve.

This would impact many of the m4 scripts, and possibly code inside the configure.ac script source.

@jimklimov jimklimov added bug CI Entries related to continuous integration infrastructure (historically also recipes like Makefiles) cross-builds portability We want NUT to build and run everywhere possible impacts-release-2.8.2 Issues reported against NUT release 2.8.2 (maybe vanilla or with minor packaging tweaks) labels Nov 8, 2024
@jimklimov jimklimov added this to the 2.8.4 milestone Nov 8, 2024
@jimklimov jimklimov modified the milestones: 2.8.4, 2.8.3 Nov 10, 2024
@jimklimov
Copy link
Member Author

As posted into PR #2675, I went with temporary variables to collect flags for the current dependency in each m4/nut_check_lib*.m4 file, combining them into a CFLAGS, LIBS etc. value used by the standard autoconf checks.

Note that AC_SEARCH_LIBS changes LIBS on its own, so we pick up the changes to remember in depLIBS afterwards, in the few files where it happens.

jimklimov added a commit to jimklimov/nut that referenced this issue Nov 10, 2024
jimklimov added a commit to jimklimov/nut that referenced this issue Nov 10, 2024
…h build-common CFLAGS etc. for target-platform-relevant checks [networkupstools#2673]

Signed-off-by: Jim Klimov <jimklimov@gmail.com>
jimklimov added a commit to jimklimov/nut that referenced this issue Nov 10, 2024
…em with build-common CFLAGS etc. for target-platform-relevant checks [networkupstools#2673]

Signed-off-by: Jim Klimov <jimklimov@gmail.com>
jimklimov added a commit to jimklimov/nut that referenced this issue Nov 10, 2024
…ith build-common CFLAGS etc. for target-platform-relevant checks [networkupstools#2673]

Signed-off-by: Jim Klimov <jimklimov@gmail.com>
jimklimov added a commit to jimklimov/nut that referenced this issue Nov 10, 2024
…th build-common CFLAGS etc. for target-platform-relevant checks [networkupstools#2673]

Signed-off-by: Jim Klimov <jimklimov@gmail.com>
jimklimov added a commit to jimklimov/nut that referenced this issue Nov 10, 2024
…m with build-common CFLAGS etc. for target-platform-relevant checks [networkupstools#2673]

Signed-off-by: Jim Klimov <jimklimov@gmail.com>
jimklimov added a commit to jimklimov/nut that referenced this issue Nov 10, 2024
…em with build-common CFLAGS etc. for target-platform-relevant checks [networkupstools#2673]

Signed-off-by: Jim Klimov <jimklimov@gmail.com>
jimklimov added a commit to jimklimov/nut that referenced this issue Nov 10, 2024
…with build-common CFLAGS etc. for target-platform-relevant checks [networkupstools#2673]

Signed-off-by: Jim Klimov <jimklimov@gmail.com>
jimklimov added a commit to jimklimov/nut that referenced this issue Nov 10, 2024
…m with build-common CFLAGS etc. for target-platform-relevant checks [networkupstools#2673]

Signed-off-by: Jim Klimov <jimklimov@gmail.com>
jimklimov added a commit to jimklimov/nut that referenced this issue Nov 10, 2024
…th build-common CFLAGS etc. for target-platform-relevant checks [networkupstools#2673]

Signed-off-by: Jim Klimov <jimklimov@gmail.com>
jimklimov added a commit to jimklimov/nut that referenced this issue Nov 10, 2024
…ith build-common CFLAGS etc. for target-platform-relevant checks [networkupstools#2673]

Signed-off-by: Jim Klimov <jimklimov@gmail.com>
jimklimov added a commit to jimklimov/nut that referenced this issue Nov 10, 2024
…with build-common CFLAGS etc. for target-platform-relevant checks [networkupstools#2673]

Signed-off-by: Jim Klimov <jimklimov@gmail.com>
jimklimov added a commit to jimklimov/nut that referenced this issue Nov 10, 2024
…with build-common CFLAGS etc. for target-platform-relevant checks [networkupstools#2673]

Signed-off-by: Jim Klimov <jimklimov@gmail.com>
jimklimov added a commit to jimklimov/nut that referenced this issue Nov 10, 2024
… with build-common CFLAGS etc. for target-platform-relevant checks [networkupstools#2673]

Signed-off-by: Jim Klimov <jimklimov@gmail.com>
jimklimov added a commit to jimklimov/nut that referenced this issue Nov 10, 2024
…ith build-common CFLAGS etc. for target-platform-relevant checks [networkupstools#2673]

Signed-off-by: Jim Klimov <jimklimov@gmail.com>
jimklimov added a commit to jimklimov/nut that referenced this issue Nov 11, 2024
…m with build-common CFLAGS etc. for target-platform-relevant checks [networkupstools#2673]

Signed-off-by: Jim Klimov <jimklimov@gmail.com>
jimklimov added a commit to jimklimov/nut that referenced this issue Nov 11, 2024
jimklimov added a commit to jimklimov/nut that referenced this issue Nov 11, 2024
…at situation with GCC [networkupstools#2673]

Signed-off-by: Jim Klimov <jimklimov@gmail.com>
jimklimov added a commit to jimklimov/nut that referenced this issue Nov 12, 2024
…nutils (for ldd) [networkupstools#2673]

Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
jimklimov added a commit to jimklimov/nut that referenced this issue Jan 9, 2025
…ts/targets where it is needed [networkupstools#2673]

Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug CI Entries related to continuous integration infrastructure (historically also recipes like Makefiles) cross-builds impacts-release-2.8.2 Issues reported against NUT release 2.8.2 (maybe vanilla or with minor packaging tweaks) portability We want NUT to build and run everywhere possible
Projects
None yet
1 participant