-
Notifications
You must be signed in to change notification settings - Fork 587
Description
Module: Perl
Description
Perl cannot compile on AIX with the openxlc (clang) compiler out of the box.
I was able to get around this with a patch and a workaround. This is the patch. It makes it so clang is treated the same as gcc, and removes -DNEED_PTHREAD_INIT
which seems to be incorrectly added, as the definition of pthread_init could not be found when compiling.
--- aix.sh 2025-05-27 14:48:19.499509204 -0500
+++ aix.sh 2025-05-27 15:50:47.991929476 -0500
@@ -94,7 +94,7 @@
ccflags="$ccflags -D_ALL_SOURCE -D_ANSI_C_SOURCE -D_POSIX_SOURCE"
case "$cc" in
- *gcc*|*g++*) ;;
+ *gcc*|*g++*|*clang*) ;;
*) ccflags="$ccflags -qmaxmem=-1 -qnoansialias -qlanglvl=extc99" ;;
esac
nm_opt='-B'
@@ -109,7 +109,7 @@
cccdlflags='none' # All AIX code is position independent
cc_type=xlc # do not export to config.sh
case "$cc" in
- *gcc*|*g++*)
+ *gcc*|*g++*|*clang*)
cc_type=gcc
ccdlflags='-Xlinker'
if [ "X$gccversion" = "X" ]; then
@@ -189,7 +189,7 @@
esac
case "$cc" in
- *gcc*|*g++*) ;;
+ *gcc*|*g++*|*clang*) ;;
cc*|xlc*) # cc should've been set by line 116 or so if empty.
if test ! -x /usr/bin/$cc -a -x /usr/vac/bin/$cc; then
@@ -236,9 +236,8 @@
d_srandom_r='undef'
d_strerror_r='undef'
- ccflags="$ccflags -DNEED_PTHREAD_INIT"
case "$cc" in
- *gcc*|*g++*)
+ *gcc*|*g++*|*clang*)
ccflags="-D_THREAD_SAFE $ccflags"
;;
cc_r)
@@ -429,7 +428,7 @@
ccflags="`echo $ccflags | sed -e 's@-q32@@'`"
ldflags="`echo $ldflags | sed -e 's@-b32@@'`"
case "$cc" in
- *gcc*|*g++*)
+ *gcc*|*g++*|*clang*)
ccflags="`echo $ccflags | sed -e 's@-q64@-maix64@'`"
ccflags_uselargefiles="`echo $ccflags_uselargefiles | sed -e 's@-q64@-maix64@'`"
qacflags="`echo $qacflags | sed -e 's@-q64@-maix64@'`"
@@ -474,10 +473,10 @@
# libraries. AIX allows both .so and .a libraries to
# contain dynamic shared objects.
case "$cc" in
- *gcc*|*g++*) ldflags="$ldflags -Wl,-brtl -Wl,-bdynamic" ;;
+ *gcc*|*g++*|*clang*) ldflags="$ldflags -Wl,-brtl -Wl,-bdynamic" ;;
*) ldflags="$ldflags -brtl -bdynamic" ;;
esac
-elif test -f /lib/libC.a -a X"`$cc -v 2>&1 | grep gcc`" = X; then
+elif test -f /lib/libC.a -a X"`$cc -v 2>&1 | grep -E 'gcc|clang'`" = X; then
# If the C++ libraries, libC and libC_r, are available we will
# prefer them over the vanilla libc, because the libC contain
# loadAndInit() and terminateAndUnload() which work correctly
And the additional workaround is to add -Accflags=-DSWIG
to the ./Configure
invocation so that PERL_TSA_ACTIVE
gets undefined, since leaving that enabled was causing the build to break. I think there needs to be a change to perl.h to check if clang is running under AIX, because it doesn't seem to be able to get all the symbols exported correctly with PERL_TSA_ACTIVE
defined. This is the problematic section:
/* clang Thread Safety Analysis/Annotations/Attributes
* http://clang.llvm.org/docs/ThreadSafetyAnalysis.html
*
* Available since clang 3.6-ish (appeared in 3.4, but shaky still in 3.5).
* Apple XCode hijacks __clang_major__ and __clang_minor__
* (6.1 means really clang 3.6), so needs extra hijinks
* (could probably also test the contents of __apple_build_version__).
*/
#if defined(USE_ITHREADS) && defined(I_PTHREAD) && \
defined(__clang__) && \
!defined(SWIG) && \
((!defined(__apple_build_version__) && \
((__clang_major__ == 3 && __clang_minor__ >= 6) || \
(__clang_major__ >= 4))) || \
(defined(__apple_build_version__) && \
((__clang_major__ == 6 && __clang_minor__ >= 1) || \
(__clang_major__ >= 7))))
# define PERL_TSA__(x) __attribute__((x))
# define PERL_TSA_ACTIVE
#else
# define PERL_TSA__(x) /* No TSA, make TSA attributes no-ops. */
# undef PERL_TSA_ACTIVE
#endif
Steps to Reproduce
export OBJECT_MODE=64
./Configure -Dcc=/opt/IBM/openxlC/17.1.3/bin/ibm-clang_r -Dusemorebits -Dusethreads -Doptimize=-O -des
make
Expected behavior
It should be able to use the aix hints and gcc flags to configure and build.
Perl configuration
N/A