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

build fails on AIX 7.1 due to thread-local storage #1287

Open
infrastation opened this issue Mar 3, 2024 · 4 comments
Open

build fails on AIX 7.1 due to thread-local storage #1287

infrastation opened this issue Mar 3, 2024 · 4 comments

Comments

@infrastation
Copy link
Member

Commit b10eefd seems to be the breaking change.

Using Autoconf and XL C 12.1:

$ make -s CFLAGS=-qhalt=w
"./pcap.c", line 3428.16: 1506-731 (S) The '__thread' keyword is not supported on the target platform.  The keyword is ignored.
"./pcap.c", line 3694.16: 1506-731 (S) The '__thread' keyword is not supported on the target platform.  The keyword is ignored.
"./etherent.c", line 92.16: 1506-731 (S) The '__thread' keyword is not supported on the target platform.  The keyword is ignored.
make: 1254-004 The error code from the last command is 1.

Using Autoconf and GCC 8.3.0:

$ make -s CFLAGS=-Werror
config.status: creating libpcap.pc.tmp
config.status: creating pcap-config.tmp
ld: 0711-317 ERROR: Undefined symbol: __get_tpointer
ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information.
collect2: error: ld returned 8 exit status
make: 1254-004 The error code from the last command is 1.

(The only description of __get_tpointer I managed to find is this and it seems to be 32-bit specific, which looks wrong.)

@infrastation
Copy link
Member Author

infrastation commented Mar 13, 2024

Adding -lpthreads seems to fix the GCC part of the problem.

@infrastation
Copy link
Member Author

Running XL C with -qtls replaces "The '__thread' keyword is not supported" with a linked error about __tls_get_mod(), which in turn resolves with -lpthreads. Let me prepare a bug fix...

@guyharris
Copy link
Member

There'a already stuff for both autotools and CMake to check for libpthreads and to check whether it's necessary; the latter should be expanded to see whether using thread-local data requires libpthreads.

@infrastation
Copy link
Member Author

This is what I was just going to commit:

--- a/aclocal.m4
+++ b/aclocal.m4
@@ -101,6 +101,23 @@ AC_DEFUN(AC_LBL_C_INIT,
 
            case "$host_os" in
 
+           aix*)
+                   case "$CC" in
+                   *xlc*)
+                       # XL C supports the "__thread" storage class specifier
+                       # and the associated "-qtls" command-line option since
+                       # at least version 12.1.0, the newer "-ftls-model"
+                       # option became available in version 16.1.0.  By
+                       # default TLS is enabled on Linux and disabled on AIX.
+                       #
+                       # However, XL C 17 is actually LLVM, which will require
+                       # a more sophisticated workaround if and when it is
+                       # available on AIX.
+                       $1="$$1 -qtls"
+                       ;;
+                   esac
+                   ;;
+
            darwin*)
                    #
                    # This is assumed either to be GCC or clang, both
diff --git a/configure.ac b/configure.ac
index cb93687e..5498ba45 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2079,6 +2079,9 @@ aix*)
                LIBS="-lodm -lcfg"
                ;;
        esac
+       # Thread-local storage on AIX requires libpthreads no matter if using
+       # GCC or XL C.
+       LIBS="$LIBS -lpthreads"
        ;;
 
 darwin*)

If you see a better solution, let me know and I will work on a different problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants