Skip to content

Commit

Permalink
(PA-5645) Disable AIX runtime linking for curl on AIX
Browse files Browse the repository at this point in the history
For reasons not entirely clear, if we provision an AIX host, install yum,
install build dependencies and then build curl within the same ssh session, then
the resulting curl executable will fail to run:

    # /opt/puppetlabs/puppet/bin/curl
    exec(): 0509-036 Cannot load program /opt/puppetlabs/puppet/bin/curl because of the following errors:
        0509-150   Dependent module libcurl.a(libcurl.so.4) could not be loaded.
        0509-022 Cannot load module libcurl.a(libcurl.so.4).
        0509-026 System error: A file or directory in the path name does not exist.

This occurs even though our libdir is first in the linker search path:

    # dumpbin -Hv /opt/puppetlabs/puppet/bin/curl
    ...
                      ***Import File Strings***
         INDEX  PATH                          BASE                MEMBER
         0      /opt/puppetlabs/puppet/lib:/opt/puppetlabs/puppet/lib:/opt/freeware/lib/gcc/powerpc-ibm-aix7.2.0.0/10:/opt/freeware/lib/gcc/powerpc-ibm-aix7.2.0.0/10/../../..:/opt/freeware/lib:/usr/lib:/lib

However, if you install yum and dependendencies in one ssh connection and then
try to build curl in a second, it works.

I think this has something to do with the way AIX caches shared libraries in
memory. For example, `yum install` loads `libcurl.a` and it's still in memory
when we build curl:

    # genkld | grep curl
    d15c9100    8a424 /opt/freeware/lib/libcurl.a[libcurl.so.4]

It's possible to clear shared libraries whose reference counts are 0, using
slibclean, but there's no guarantee that the library is unloaded.

Disabling runtime linking (removing -brtl from LDFLAGS) seems to reliably work.
  • Loading branch information
joshcooper committed Jul 12, 2023
1 parent a46d6e1 commit 7a461ec
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion configs/components/curl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
pkg.build_requires "openssl-#{settings[:openssl_version]}"
pkg.build_requires "puppet-ca-bundle"

ldflags = settings[:ldflags]
if platform.is_cross_compiled_linux?
pkg.build_requires "runtime-#{settings[:runtime_project]}"
pkg.environment "PATH", "/opt/pl-build-tools/bin:$(PATH):#{settings[:bindir]}"
Expand All @@ -22,7 +23,10 @@
pkg.environment "PATH", "$(shell cygpath -u #{settings[:gcc_bindir]}):$(PATH)"
pkg.environment "CYGWIN", settings[:cygwin]
elsif platform.is_aix? && platform.name != 'aix-7.1-ppc'
pkg.environment "PKG_CONFIG_PATH", "/opt/puppetlabs/puppet/lib/pkgconfig"
pkg.environment 'PATH', "/opt/freeware/bin:$(PATH):#{settings[:bindir]}"
# exclude -Wl,-brtl
ldflags = "-L#{settings[:libdir]}"
else
pkg.environment "PATH", "/opt/pl-build-tools/bin:$(PATH):#{settings[:bindir]}"
end
Expand All @@ -43,7 +47,7 @@

pkg.configure do
["CPPFLAGS='#{settings[:cppflags]}' \
LDFLAGS='#{settings[:ldflags]}' \
LDFLAGS='#{ldflags}' \
./configure --prefix=#{settings[:prefix]} \
#{configure_options.join(" ")} \
--enable-threaded-resolver \
Expand Down

0 comments on commit 7a461ec

Please sign in to comment.