Building GCC cross-compiler on AIX 7.3 2 for target powerpc64-linux
Posted: Thu Oct 17, 2024 9:06 am
Hi all
I'm attempting to build GCC on AIX 7.3.2 as a cross compiler for the first time with the following configure parameters:
--host=powerpc-ibm-aix7.3.2.0 (--build should be the same)
--target=powerpc64-linux (big endian)
--disable-threads
--disable-nls
--prefix=/my/gcc_upgrade/installdir
--enable-languages=c (only C is needed)
I'm running config and make from /my/gcc_upgrade/objdir
The native AIX7.3 compiler I'm using to start off with is gcc-12 which is included in the AIX toolbox for Linux applications. Same with g++ (g++-12). I also installed GNU make from the same toolbox.
Instead of downloading the other prereqs from the toolbox, I executed the script in the gcc-14.2.0 source tree contrib/download_prerequisites to download the gmp/mpfr/mpc source code into the gcc-14.2.0 source tree. I also placed the source code for various binutils 2.43.1 tools in the same source tree.
I'm building outside of the source directory as instructed.
I've read that binutils may not work correctly on AIX and may need to use the native tools (as, ld, etc.), so maybe I need to remove these binutils... But I'm also confused - don't I need to build binutils for the host/target combo (aix/powerpc64-linux) at some point? Since the built-in AIX tools are not cross-tools? It's not clear to me if this is giving me an issue or not. The build seems to progress up to a certain point until I run into this issue:
Despite the config of --disable-threads, I'm getting this linker issue that breaks out of the make:
ld: 0711-317 ERROR: Undefined symbol: .pthread_mutex_lock
ld: 0711-317 ERROR: Undefined symbol: .pthread_mutex_unlock
I'm confused as to why these symbols are necessary if I configured the build with --disable-threads ...? Not sure how I can get around this. Do I need to add a -lpthread or -pthread flag somewhere? Where would it be (in a makefile? That thing is huge...). Clearly I'm still inexperienced with builds of this magnitude and complexity.
I'm using --disable-threads because that's what my old cross-compiler used (20 years ago), plus I will not be using threads in any compiled program.
Another side-question: I assume the make is using ld that was built from the binutils source, but is there a way to confirm this? Again, not sure if this is related to the linker issue I'm experiencing that breaks the make.
Thanks in advance and let me know if I can provide more info.
Here is a larger snippet of the make fail:
Here is a the result of the line that broke the make which I don't understand, but with the -bnoquiet flag added
I'm attempting to build GCC on AIX 7.3.2 as a cross compiler for the first time with the following configure parameters:
--host=powerpc-ibm-aix7.3.2.0 (--build should be the same)
--target=powerpc64-linux (big endian)
--disable-threads
--disable-nls
--prefix=/my/gcc_upgrade/installdir
--enable-languages=c (only C is needed)
I'm running config and make from /my/gcc_upgrade/objdir
The native AIX7.3 compiler I'm using to start off with is gcc-12 which is included in the AIX toolbox for Linux applications. Same with g++ (g++-12). I also installed GNU make from the same toolbox.
Instead of downloading the other prereqs from the toolbox, I executed the script in the gcc-14.2.0 source tree contrib/download_prerequisites to download the gmp/mpfr/mpc source code into the gcc-14.2.0 source tree. I also placed the source code for various binutils 2.43.1 tools in the same source tree.
I'm building outside of the source directory as instructed.
I've read that binutils may not work correctly on AIX and may need to use the native tools (as, ld, etc.), so maybe I need to remove these binutils... But I'm also confused - don't I need to build binutils for the host/target combo (aix/powerpc64-linux) at some point? Since the built-in AIX tools are not cross-tools? It's not clear to me if this is giving me an issue or not. The build seems to progress up to a certain point until I run into this issue:
Despite the config of --disable-threads, I'm getting this linker issue that breaks out of the make:
ld: 0711-317 ERROR: Undefined symbol: .pthread_mutex_lock
ld: 0711-317 ERROR: Undefined symbol: .pthread_mutex_unlock
I'm confused as to why these symbols are necessary if I configured the build with --disable-threads ...? Not sure how I can get around this. Do I need to add a -lpthread or -pthread flag somewhere? Where would it be (in a makefile? That thing is huge...). Clearly I'm still inexperienced with builds of this magnitude and complexity.
I'm using --disable-threads because that's what my old cross-compiler used (20 years ago), plus I will not be using threads in any compiled program.
Another side-question: I assume the make is using ld that was built from the binutils source, but is there a way to confirm this? Again, not sure if this is related to the linker issue I'm experiencing that breaks the make.
Thanks in advance and let me know if I can provide more info.
Here is a larger snippet of the make fail:
Code: Select all
make[6]: Leaving directory '/my/gcc_upgrade/objdir/gettext/gnulib-lib'
make[5]: Leaving directory '/my/gcc_upgrade/objdir/gettext/gnulib-lib'
make[4]: Leaving directory '/my/gcc_upgrade/objdir/gettext/gnulib-lib'
Making all in src
make[4]: Entering directory '/my/gcc_upgrade/objdir/gettext/src'
gcc -DLOCALEDIR=\"/my/gcc_upgrade/installdir/share/locale\" -DHAVE_CONFIG_H -I. -I/my/gcc_upgrade/gcc-14.2.0/gettext/gettext-runtime/src -I.. -I. -I/my/gcc_upgrade/gcc-14.2.0/gettext/gettext-runtime/src -I.. -I../intl -I/my/gcc_upgrade/gcc-14.2.0/gettext/gettext-runtime/src/../intl -I../gnulib-lib -I/my/gcc_upgrade/gcc-14.2.0/gettext/gettext-runtime/src/../gnulib-lib -DINSTALLDIR=\"/my/gcc_upgrade/installdir/bin\" -g -O2 -c -o gettext-gettext.o `test -f 'gettext.c' || echo '/my/gcc_upgrade/gcc-14.2.0/gettext/gettext-runtime/src/'`gettext.c
/bin/sh ../libtool --tag=CC --mode=link gcc -DINSTALLDIR=\"/my/gcc_upgrade/installdir/bin\" -g -O2 -static-libstdc++ -static-libgcc -Wl,-bbigtoc -o gettext gettext-gettext.o ../gnulib-lib/libgrt.a -liconv
libtool: link: gcc -DINSTALLDIR=\"/my/gcc_upgrade/installdir/bin\" -g -O2 -static-libstdc++ -static-libgcc -Wl,-bbigtoc -o gettext gettext-gettext.o ../gnulib-lib/libgrt.a -liconv
ld: 0711-317 ERROR: Undefined symbol: .pthread_mutex_lock
ld: 0711-317 ERROR: Undefined symbol: .pthread_mutex_unlock
ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information.
collect2: error: ld returned 8 exit status
make[4]: *** [Makefile:1648: gettext] Error 1
make[4]: Leaving directory '/my/gcc_upgrade/objdir/gettext/src'
make[3]: *** [Makefile:1644: all-recursive] Error 1
make[3]: Leaving directory '/my/gcc_upgrade/objdir/gettext'
make[2]: *** [Makefile:1549: all] Error 2
make[2]: Leaving directory '/my/gcc_upgrade/objdir/gettext'
make[1]: *** [Makefile:9485: all-gettext] Error 2
make[1]: Leaving directory '/my/gcc_upgrade/objdir'
make: *** [Makefile:1059: all] Error 2
Here is a the result of the line that broke the make which I don't understand, but with the -bnoquiet flag added
Code: Select all
bash-5.2# /bin/sh ../libtool --tag=CC --mode=link gcc -DINSTALLDIR=\"/my/
gcc_upgrade/installdir/bin\" -g -O2 -static-libstdc++ -static-libgcc -Wl,-
bbigtoc,-bnoquiet -o gettext gettext-gettext.o ../gnulib-lib/libgrt.a -liconv
libtool: link: gcc -DINSTALLDIR=\"/my/gcc_upgrade/installdir/bin\" -g -O2 -static-libstdc++ -static-libgcc -Wl,-bbigtoc -Wl,-bnoquiet -o gettext gettext-gettext.o ../gnulib-lib/libgrt.a -liconv
(ld): halt 4
(ld): setopt r/o->w
(ld): setopt bigtoc
(ld): setfflag 4
(ld): savename gettext
(ld): filelist 10 1
(ld): i /lib/crt0.o
(ld): i /opt/freeware/lib/gcc/powerpc-ibm-aix7.3.0.0/12/crtcxa.o
(ld): i /opt/freeware/lib/gcc/powerpc-ibm-aix7.3.0.0/12/crtdbase.o
(ld): i gettext-gettext.o
(ld): i ../gnulib-lib/libgrt.a
(ld): lib /opt/freeware/lib/gcc/powerpc-ibm-aix7.3.0.0/12/../../../libiconv.a
(ld): i /opt/freeware/lib/gcc/powerpc-ibm-aix7.3.0.0/12/libgcc.a
(ld): i /opt/freeware/lib/gcc/powerpc-ibm-aix7.3.0.0/12/libgcc_eh.a
(ld): lib /usr/lib/libg.a
(ld): lib /usr/lib/libc.a
LIBRARY: Shared object libiconv.a[libiconv.so.2]: 14 symbols imported.
LIBRARY: Shared object libc.a[shr.o]: 3355 symbols imported.
LIBRARY: Shared object libc.a[meth.o]: 2 symbols imported.
LIBRARY: Shared object libc.a[posix_aio.o]: 20 symbols imported.
LIBRARY: Shared object libc.a[aio.o]: 18 symbols imported.
LIBRARY: Shared object libc.a[pse.o]: 8 symbols imported.
LIBRARY: Shared object libc.a[dl.o]: 4 symbols imported.
LIBRARY: Shared object libc.a[pty.o]: 1 symbols imported.
LIBRARY: Shared object libc.a[cthread.o]: 25 symbols imported.
LIBRARY: Shared object libc.a[uchar.o]: 4 symbols imported.
FILELIST: Number of previously inserted files processed: 10
(ld): resolve
RESOLVE: 405 of 13867 symbols were kept.
(ld): addgl /usr/lib/glinkl.o
ADDGL: Glink code added for 37 symbols.
(ld): er full
ld: 0711-318 ERROR: Undefined symbols were found.
The following symbols are in error:
Symbol Inpndx TY CL Source-File(Object-File) OR Import-File{Shared-object}
RLD: Address Section Rld-type Referencing Symbol
----------------------------------------------------------------------------------------------
.pthread_mutex_lock [4] ER PR /my/gcc_upgrade/gcc-14.2.0/gettext/gettext-runtime/gnulib-lib/setlocale_null.c(../gnulib-lib/libgrt.a[libgrt_a-setlocale_null.o])
00000038 .text R_RBR [34] <.setlocale_null_with_lock>
.pthread_mutex_unlock [12] ER PR /my/gcc_upgrade/gcc-14.2.0/gettext/gettext-runtime/gnulib-lib/setlocale_null.c(../gnulib-lib/libgrt.a[libgrt_a-setlocale_null.o])
00000098 .text R_RBR [34] <.setlocale_null_with_lock>
ER: The return code is 8.
collect2: error: ld returned 8 exit status