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

AIX: no pkgconfig so never finds libssl.a, etc. #375

Closed
aixtools opened this issue May 1, 2022 · 21 comments
Closed

AIX: no pkgconfig so never finds libssl.a, etc. #375

aixtools opened this issue May 1, 2022 · 21 comments
Assignees
Labels
enhancement New feature or request platform issue Issue is specific to an OS or desktop priority-low waiting for reporter There are data requested from the reporter
Milestone

Comments

@aixtools
Copy link
Contributor

aixtools commented May 1, 2022

  • AIX does not have, by default, pkgconfig, so the else block is always going to fire.

  • Even if pkgconfig is installed - it doesn't have any info on OpenSSL, so that will also fail.

  • Having trouble counting and balancing the square brackets [], but something such as this might help:

        AC_CHECK_LIB([ssl], [SSL_library_init], [
            AC_MSG_RESULT([yes])
            have_tls="1"
            with_tls="openssl"
            TLSLIBS="-lssl -lcrypto"
            TLSFLAGS=""
            AC_DEFINE([HAVE_TLS], [1], [Do we support TLS?])
            AC_DEFINE([HAVE_OPENSSL], [1], [Do we have the OpenSSL library?])

        ], [
            AC_MSG_ERROR([--with-tls=openssl was specified but neither the OpenSSL nor LibreSSL library were found.])
    ])
  • Working on a PR, but trying to find the best place to insert AC_CHECK_LIB
@michaelrsweet michaelrsweet self-assigned this May 2, 2022
@michaelrsweet michaelrsweet added enhancement New feature or request priority-low platform issue Issue is specific to an OS or desktop labels May 2, 2022
@michaelrsweet
Copy link
Member

@aixtools Hi, so we don't actually officially support AIX anymore - see the Supported Platforms wiki page (I need to make sure there is a link from the new CUPS home page for this...) CUPS 2.4 actually removed a bunch of AIX-specific things (particularly for AIX 4's older shared library support) because we had nobody that could/would maintain it...

The problem with simply looking for libssl is that OpenSSL also needs libcrypto - pkg-config takes care of that detail but adding a legacy autoconf check will require checking for both libraries (with libcrypto first) to ensure that the check will work (a static libssl won't automatically include libcrypto). That's not a huge problem but it makes the autoconf check code a little more complicated.

WRT a PR, we'll consider it. You'll want to put it in the "openssl" check as an else clause after the PKGCONFIG check, e.g.:

AS_IF([test $with_tls = yes -o $with_tls = openssl], [
    AS_IF([test "x$PKGCONFIG" != x], [
        AC_MSG_CHECKING([for openssl package])
        AS_IF([$PKGCONFIG --exists openssl], [
            AC_MSG_RESULT([yes])
            have_tls="1"
            with_tls="openssl"
            TLSLIBS="$($PKGCONFIG --libs openssl)"
            TLSFLAGS="$($PKGCONFIG --cflags openssl)"
            PKGCONFIG_REQUIRES="$PKGCONFIG_REQUIRES openssl"
            AC_DEFINE([HAVE_TLS], [1], [Do we support TLS?])
            AC_DEFINE([HAVE_OPENSSL], [1], [Do we have the OpenSSL library?])
        ], [
            AC_MSG_RESULT([no])
        ])
>   ], [
>     YOUR NEW TESTS GO HERE
    ])

@aixtools
Copy link
Contributor Author

aixtools commented May 3, 2022

Thanks for the pointer. I was having a hard time deciding where it should go.

And thanks for the hint to look for libcrypto first.

What do you actually mean by AIX v4 shared library support? The normal AIX shared library is an archive that can hold both shared and static libraries - in both 32-bit and 64-bit format (ABI).

Not sure how AIX v4 is any different from what is common now (or do you mean v4 is when the current format first appeared).

@aixtools
Copy link
Contributor Author

aixtools commented May 3, 2022

As to supporting AIX - CUPS is a pre-requisite for building OpenJDK. I think I mentioned that in the 'discussion'. Don't know why, but it is why I am going through this now. FYI.

@michaelrsweet
Copy link
Member

@aixtools What I mean is that the CUPS build system used to provide shared library support by creating libcups_s.a archives (which was the only way shared libraries worked for AIX 4.x), but more "standard" shared objects (libcups.so.2) for AIX 5.x. But all of that build support code was dumped in CUPS 2.4.

@aixtools
Copy link
Contributor Author

aixtools commented May 3, 2022

I noticed that.

The current situation is that dlopen looks first for a libfoo.a and then searches for a member (of any name), and if nothing is found searches the same directory libfoo.so.

So, AIX adding support for external libfoo.so support did not become the new standard - it became an addition, and complicates (imho) mixed support (/usr/lib64 is not a default library - afaik on most systems /usr/lib64 does not exist.

The simple way to support AIX is to create the libfoo.so.X and then add that as a member to libfoo.a

@aixtools
Copy link
Contributor Author

aixtools commented May 3, 2022

@michaelrsweet
Copy link
Member

@aixtools Because I've found that archive to be hit-or-miss and most platforms provide pkg-config these days which greatly simplifies things. If I did use something from there I'd be copying it (the whole file) into the repository and including it, as no system has these macros installed as standard. Also, there is always the license problem - at least this macro appears to be using a BSD-style ("all permissive") license, but not all of them are so generous...

@aixtools
Copy link
Contributor Author

aixtools commented May 4, 2022

I understand that you would use the whole thing (fyi, I found it via Python which uses the full text - m4 is not my thing).

Q. Adoptium has something activated so that a PR can be put in 'Draft' status. That is probably best for the PR I opened on this, as they are just examples - to see if I could get it working.

FYI: These are files with modifications (some hand made). (Re-running make DESTDIR=xxx install, for verification) - to give an impression of what I found and/or hacked-in to get it to build.

aixtools@x064:[cups-2.4.1.1]git diff master | grep +++
+++ b/.gitignore
+++ b/backend/snmp.c
+++ b/config-scripts/cups-tls.m4
+++ b/configure
+++ b/configure.ac
+++ b/cups/Makefile
+++ b/cups/http.c
+++ b/tools/Makefile
+++ b/tools/ippeveprinter.c

@aixtools
Copy link
Contributor Author

aixtools commented May 4, 2022

I built autoconf-2.71 - and this is the short list:

+++ b/.gitignore
+++ b/backend/snmp.c
+++ b/config-scripts/cups-tls.m4
+++ b/configure
+++ b/cups/Makefile
+++ b/cups/http.c
+++ b/tools/Makefile
+++ b/tools/ippeveprinter.c
  • .gitignore is only relevant because I am building in-tree, normally I build out of tree and do not need additions to .gitignore

  • The three .c files are minor things, imho, likely caused by differences in how gcc and xlc look at source code.
    I am not saying these changes are the best way to fix it, but for a prototype build - they work.

  • configure is the expected change - after the change to config-scripts/cups-tls.m4. As you mention above, better is to include the complete macro, rather than an extract.

  • cups/Makefile and tools/Makefile - are just a text change so I could experiment (so, disregard).

  • what does not show up - and I did not have a the time to figure out how to make these changes in configure.ac are the changes to Makedefs after ./configure has finished.
    a) the .m4 file still needs to update TLSLIBS (my error)
    b) DSOFLAGS - these are the most basic AIX loader flags (i.e., more complex options are possible).
    c) LDFLAGS: when we get into the tools area - as the default for AIX is to not add missing shared libraries to a new shared library - the library flags need to be provided when the applications are being built. This was the final bit of magic that got everything working.

  • the end result, however, lacks /usr/lib/libcups.a (or /opt/aixtools/lib/libcups.a) - only the shared (.so) files are there. The file libcups.a is created however.

root@x065:[/data/prj/aixtools/cups/cups-2.4.1.1/X32/opt/aixtools/lib]ls -l
total 80
drwxr-xr-x  10 bin      bin            4096 May 04 08:46 cups
lrwxrwxrwx   1 root     system           12 May 04 2022  libcups.so -> libcups.so.2
-rwxr-xr-x   1 bin      bin            4681 May 04 08:46 libcups.so.2
lrwxrwxrwx   1 root     system           17 May 04 2022  libcupsimage.so -> libcupsimage.so.2
-rwxr-xr-x   1 bin      bin            4694 May 04 08:46 libcupsimage.so.2
drwxr-xr-x  14 bin      bin            4096 May 04 08:46 locale
drwxr-xr-x   2 bin      bin            4096 May 04 08:46 pkgconfig

FYI:

root@x065:[/data/prj/aixtools/cups/cups-2.4.1.1]find . -name \*.a
./backend/libbackend.a
./cgi-bin/libcupscgi.a
./cups/libcupsimage.a
./cups/libcups.a
./ppdc/libcupsppdc.a
./scheduler/libcupsmime.a

@michaelrsweet
Copy link
Member

Try this:

[master dd93106] Look for OpenSSL the old way if pkg-config is not available (Issue #375)

@michaelrsweet
Copy link
Member

@aixtools Can you confirm that current Github master works for you?

@aixtools
Copy link
Contributor Author

I'll rebuild next week. My apologies for the delay.

@zdohnal zdohnal added the waiting for reporter There are data requested from the reporter label May 26, 2022
@aixtools
Copy link
Contributor Author

😊 working on it now.

@aixtools
Copy link
Contributor Author

aixtools commented Jul 15, 2022

Starting from git worktree add ../cups-2.4.2 v2.4.2
a) run CC=xlc_r OBJECT_MODE=64 configure --prefix=/opt/aixtools
b) in tools need to manually add: -lssl -lcrypto SO:

With this: (i.e., using the patched version):P

aixtools@x064:[cups-2.4.2]diff -u Makedefs Makedefs.patched
--- Makedefs    2022-07-15 12:33:56.000000000 +0000
+++ Makedefs.patched    2022-07-15 12:31:05.000000000 +0000
@@ -155,7 +155,7 @@
                        $(TLSFLAGS) -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_THREAD_SAFE -D_REENTRANT \
                        $(ONDEMANDFLAGS) $(OPTIONS)
  ALL_DSOFLAGS  =       -L../cups   $(DSOFLAGS) $(OPTIM)
- ALL_LDFLAGS   =       -L../cups   $(LDFLAGS)  \
+ ALL_LDFLAGS   =       -L../cups   $(LDFLAGS)  $(TLSLIBS) \
                         $(OPTIM)
  ARCHFLAGS     =
  ARFLAGS               =       crvs
  • make completes as expected.

  • FYI: This is using AIX 5.3 TL7 - so it should work on any AIX (and xlc (and I expect gcc) after 2007.

  • for packaging purposes I run: /opt/bin/make install DESTDIR=/var/aixtools/aixtools/cups/2.4.2.0. I wish it would make AIX .a files, with the .so inside them. I can do that manually. FYI: this is what I get in /opt/aixtools/lib:

total 40
drwxr-xr-x  10 bin      bin             256 Jul 15 12:44 cups
lrwxrwxrwx   1 root     system           12 Jul 15 12:44 libcups.so -> libcups.so.2
-rwxr-xr-x   1 bin      bin            4681 Jul 15 12:44 libcups.so.2
lrwxrwxrwx   1 root     system           17 Jul 15 12:44 libcupsimage.so -> libcupsimage.so.2
-rwxr-xr-x   1 bin      bin            4694 Jul 15 12:44 libcupsimage.so.2
drwxr-xr-x  14 bin      bin            4096 Jul 15 12:43 locale
drwxr-xr-x   2 bin      bin             256 Jul 15 12:44 pkgconfig
  • If you wish to know more detail (e.g., ls -lR), just ask.
  • MANY thanks for your quick assistence (and my apologies for tardiness).

@michaelrsweet
Copy link
Member

@aixtools OK, so ALL_LDFLAGS most definitely should not contain TLSLIBS. LINKCUPS and LINKCUPSSTATIC are where this needs to happen.

I suspect the issue is that AIX shared libraries work more like dynamically loaded static libraries, so we need to change the definition of LINKCUPS on AIX...

@michaelrsweet
Copy link
Member

Try this:

[master cac6d48] Fix link libraries on AIX (Issue #375)

@michaelrsweet michaelrsweet added this to the v2.4.3 milestone Jul 17, 2022
@aixtools
Copy link
Contributor Author

aixtools commented Aug 1, 2022

NOTE: while reading below - note the OSS management system is NOT intended as a build system. The problems there only demonstrate the kinds of issues that can occur on a contaminated AIX system, i.e., lots of none-AIX packages installed while packaging/building OSS packages. That said, I am not asking you to fix the new issues, but hope it helps that you are aware of them - and in particular, even if pkgconfig is installed - this does not mean it works as expected (GNU pkgconfig does not have any knowledge of AIX OpenSSL).

  • First test on my OSS management system (not what I normally use to build, AIX 7.1):
configure: error: --with-tls=yes was specified but no compatible TLS libraries could be found.

Installed:
openssl.base:openssl.base:1.1.1.1200 (so that would be 1.1.1l (letter l) iirc.
  • The OpenSSL version installed is the same one I used two weeks ago (just checked).
  • The configure script runs fine on the normal build system (AIX 5.3)
  • The make on AIX 5.3 fails at:
Compiling snmp.c...
Linking libcups.so.2...
Linking libcupsimage.so.2...
xlc_r: 1501-228 (W) input file IBS not found
make[1]: *** [Makefile:425: libcupsimage.so.2] Error 252
make: *** [Makefile:43: all] Error 1
root@x065:[/data/prj/aixtools/cups/cups-2.4.3]

Note: at the specific commit you requested:

commit cac6d48addd4be360ef558fbd0cdc3ccfe72505d (HEAD)
Author: Michael R Sweet <[email protected]>
Date:   Sun Jul 17 18:52:35 2022 -0400

    Fix link libraries on AIX (Issue #375)

Update:

diff --git a/cups/Makefile b/cups/Makefile
index 4110b98d0..e796e08f5 100644
--- a/cups/Makefile
+++ b/cups/Makefile
@@ -422,6 +422,7 @@ libcups2.def: $(LIBOBJS) $(IMAGEOBJS) Makefile

 libcupsimage.so.2:     $(IMAGEOBJS) libcups.so.2
        echo Linking $@...
+       echo $(DSO) $(ARCHFLAGS) $(ALL_DSOFLAGS) -o $@ $(IMAGEOBJS) $(LINKCUPS)
        $(DSO) $(ARCHFLAGS) $(ALL_DSOFLAGS) -o $@ $(IMAGEOBJS) $(LINKCUPS)
        $(RM) `basename $@ .2`
        $(LN) $@ `basename $@ .2`

root@x065:[/data/prj/aixtools/cups/cups-2.4.3/cups]make
Linking libcupsimage.so.2...
xlc_r -L../cups -Wl,-G -o libcupsimage.so.2 -o libcupsimage.so.2 raster-interstub.o raster-stubs.o -L../cups -lcups IBS
xlc_r: 1501-228 (W) input file IBS not found
make: *** [Makefile:426: libcupsimage.so.2] Error 252
  • Update 2:
  • Found the key difference. My OSS management system has several OSS tools installed (e.g., the GNU autotools and an old version of pkgconfig (0.25)). I am guessing that the existence of pkgconfig is confusing the system - it now expects gnutls to also be available - but it is not.
  • There is ALSO an early version of gcc installed (4.7.4) and the configure process continues looking (and finding) gcc related stuff.
  • diff -u output of the configure runs - hope it helps:
aixtools@x064:[cups-2.4.3]diff -u ../*configure
--- ../aix5.3.configure 2022-08-01 08:03:07.000000000 +0000
+++ ../aix7.1.configure 2022-08-01 08:05:30.000000000 +0000
@@ -1,7 +1,7 @@
- Script command is started on Mon Aug  1 08:02:27 UTC 2022.
- root@x065:[/data/prj/aixtools/cups/cups-2.4.3]CC=xlc_r OBJECT_MODE=64 ./configure --prefix=/opt/aixtools
- checking build system type... powerpc-ibm-aix5.3.7.0
- checking host system type... powerpc-ibm-aix5.3.7.0
+ Script command is started on Mon Aug  1 08:03:50 UTC 2022.
aixtools@x064:[cups-2.4.3]3]CC=xlc_r OBJECT_MODE=64 ./configure --prefix=/opt/aixtools
+ checking build system type... powerpc-ibm-aix7.1.4.0
+ checking host system type... powerpc-ibm-aix7.1.4.0
  checking for codesign... no
  checking for true... /usr/bin/true
  checking for gawk... no
@@ -18,21 +18,10 @@
  checking for xlc_r option to enable C11 features... unsupported
  checking for xlc_r option to enable C99 features... none needed
  checking how to run the C preprocessor... xlc_r -E
- checking for g++... no
- checking for c++... no
- checking for gpp... no
- checking for aCC... no
- checking for CC... no
- checking for cxx... no
- checking for cc++... no
- checking for cl.exe... no
- checking for FCC... no
- checking for KCC... no
- checking for RCC... no
- checking for xlC_r... xlC_r
+ checking for g++... g++
  checking whether the compiler supports GNU C++... no
- checking whether xlC_r accepts -g... yes
- checking for xlC_r option to enable C++11 features... none needed
+ checking whether g++ accepts -g... no
+ checking for g++ option to enable C++11 features... none needed
  checking for ranlib... ranlib
  checking for ar... /usr/bin/ar
  checking for chmod... /usr/bin/chmod
@@ -46,7 +35,7 @@
  checking for rmdir... /usr/bin/rmdir
  checking for sed... /usr/bin/sed
  checking for xdg-open... no
- checking for pkg-config... no
+ checking for pkg-config... /opt/bin/pkg-config
  checking for library containing abs... none required
  checking for library containing crypt... none required
  checking for library containing fmod... -lm
@@ -69,8 +58,8 @@
  checking for sys/param.h... yes
  checking for sys/ucred.h... no
  checking for iconv.h... yes
- checking for library containing iconv_open... -liconv
- checking for library containing libiconv_open... no
+ checking for library containing iconv_open... no
+ checking for library containing libiconv_open... -liconv
  checking for sys/mount.h... no
  checking for sys/statfs.h... yes
  checking for sys/statvfs.h... yes
@@ -97,10 +86,12 @@
  checking for tm_gmtoff member in tm structure... no
  checking for st_gen member in stat structure... yes
  checking for removefile... no
+ checking for libusb-1.0... no
  checking for zlib.h... yes
  checking for gzgets in -lz... yes
  checking for inflateCopy in -lz... yes
  checking for library containing acl_init... no
+ checking for DBUS... no
  Building CUPS with default compiler optimizations.
  Contact the OpenPrinting CUPS developers on Github with the uname and compiler
  options needed for your platform, or set the CFLAGS and LDFLAGS environment
@@ -125,60 +116,10 @@
  checking for kqueue... no
  checking for pthread.h... yes
  checking for pthread_create using -lpthreads... yes
- checking for SSL_new in -lssl... yes
- checking for openssl/ssl.h... yes
- configure:     Using TLSLIBS="-lssl -lcrypto"
- configure:     Using TLSFLAGS=""
- checking for dlopen in -ldl... yes
- checking for pam_start in -lpam... yes
- checking for pam_set_item in -lpam... yes
- checking for pam_setcred in -lpam... yes
- checking for security/pam_appl.h... yes
- checking for special C compiler options needed for large files... no
- checking for _FILE_OFFSET_BITS value needed for large files... no
- checking for long long int... yes
- checking for strtoll... yes
- checking for dns_sd.h... no
- checking for default print user... lp
- checking for default print group... lp
- checking for default system groups... "sys system"
- configure: creating ./config.status
- config.status: creating Makedefs
- config.status: creating conf/cups-files.conf
- config.status: creating conf/cupsd.conf
- config.status: creating conf/mime.convs
- config.status: creating conf/pam.std
- config.status: creating conf/snmp.conf
- config.status: creating cups.pc
- config.status: creating cups-config
- config.status: creating desktop/cups.desktop
- config.status: creating doc/index.html
- config.status: creating scheduler/cups-lpd.xinetd
- config.status: creating scheduler/cups.sh
- config.status: creating scheduler/cups.xml
- config.status: creating scheduler/org.cups.cups-lpd.plist
- config.status: creating scheduler/cups-lpdAT.service
- config.status: creating scheduler/cups.path
- config.status: creating scheduler/cups.service
- config.status: creating scheduler/cups.socket
- config.status: creating templates/header.tmpl
- config.status: creating packaging/cups.list
- config.status: creating doc/da/index.html
- config.status: creating templates/da/header.tmpl
- config.status: creating doc/de/index.html
- config.status: creating templates/de/header.tmpl
- config.status: creating doc/es/index.html
- config.status: creating templates/es/header.tmpl
- config.status: creating doc/fr/index.html
- config.status: creating templates/fr/header.tmpl
- config.status: creating doc/ja/index.html
- config.status: creating templates/ja/header.tmpl
- config.status: creating doc/pt_BR/index.html
- config.status: creating templates/pt_BR/header.tmpl
- config.status: creating doc/ru/index.html
- config.status: creating templates/ru/header.tmpl
- config.status: creating config.h
- config.status: config.h is unchanged
- root@x065:[/data/prj/aixtools/cups/cups-2.4.3]
+ checking for openssl package... no
+ checking for libgnutls-config... no
+ checking for gnutls package... no
+ configure: error: --with-tls=yes was specified but no compatible TLS libraries could be found.
+ aixtools@x064:[cups-2.4.3]

- Script command is complete on Mon Aug  1 08:03:06 UTC 2022.
+ Script command is complete on Mon Aug  1 08:05:29 UTC 2022.

@michaelrsweet
Copy link
Member

@aixtools Are you able to provide the config.log or Makedefs files as well?

@aixtools
Copy link
Contributor Author

aixtools commented Aug 3, 2022

  • START:
aixtools@x064:[cups-master]git worktree add ../cups-2.4.3 cac6d48addd4be360ef558fbd0cdc3ccfe72505d
Preparing worktree (detached HEAD cac6d48ad)
Updating files: 100% (1312/1312), done.
HEAD is now at cac6d48ad Fix link libraries on AIX (Issue #375)
aixtools@x064:[cups-master]cd ../*3
aixtools@x064:[cups-2.4.3]
  • With pkg-config, but no support of OpenSSL:
aixtools@x064:[cups-2.4.3]/opt/bin/pkg-config --list-all
libpcre      libpcre - PCRE - Perl compatible regular expressions C library with 8 bit character support
libpcrecpp   libpcrecpp - PCRECPP - C++ wrapper for PCRE
expat        expat - expat XML parser
libpcreposix libpcreposix - PCREPosix - Posix compatible interface to libpcre
python3      Python - Python library
python-3.6m  Python - Python library
libcurl      libcurl - Library to transfer files with ftp, http, etc.
python-3.6   Python - Python library
sqlite3      SQLite - SQL database engine
liblzma      liblzma - General purpose data compression library

Note: The packages above are ones I have built. No such information exists for any IBM (AIX) software (package.pc files).

aixtools@x064:[cups-2.4.3]CC=xlc_r OBJECT_MODE=64 ./configure --prefix=/opt/aixtools
  • Results: on this system (x064) - no Makedefs created. config.log attached as config.x064.log

config.x064.log

  • Repeat configure on system without pkg-config
root@x065:[/data/prj/aixtools/cups/cups-2.4.3]CC=xlc_r OBJECT_MODE=64 ./configure --prefix=/opt/aixtools
  • Attaching as Makedefs.x065.txt and config.x065.log

config.x065.log
Makedefs.x065.txt

@michaelrsweet
Copy link
Member

michaelrsweet commented Sep 22, 2022

@aixtools Sorry this took so long, try the latest from master:

[master 634c8cc] Potentially fix the last AIX configure bug (Issue #375)

@michaelrsweet michaelrsweet modified the milestones: v2.4.3, v2.4.4 Jun 2, 2023
@zdohnal zdohnal modified the milestones: v2.4.4, v2.4.x Jun 14, 2023
@zdohnal
Copy link
Member

zdohnal commented Sep 13, 2023

No response for a year, closing.

@zdohnal zdohnal closed this as completed Sep 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request platform issue Issue is specific to an OS or desktop priority-low waiting for reporter There are data requested from the reporter
Projects
None yet
Development

No branches or pull requests

3 participants