Error when building Python 3.11.4 on Amazon Linux 2

HI there!

I’m trying to build Python 3.11.4 on an Amazon Linux 2 based docker image. It’s been failing non-deterministically with the following error:

[AWS CodeBuild Plugin] INFO   - __main__             - + sudo make -j 2 EXTRA_CFLAGS= 'LDFLAGS=-Wl,-rpath='\''$$ORIGIN/../lib'\''' install
[AWS CodeBuild Plugin] INFO   - __main__             - gcc -pthread  -Wl,-rpath='$ORIGIN/../lib' -fno-semantic-interposition -flto -fuse-linker-plugin -ffat-lto-objects -flto-partition=none -g  -Xlinker -export-dynamic -o python Programs/python.o -L. -lpython3.11 -lpthread -ldl  -lutil                        -lm
[AWS CodeBuild Plugin] INFO   - __main__             - Rebuilding with profile guided optimizations:
[AWS CodeBuild Plugin] INFO   - __main__             - rm -f profile-clean-stamp
[AWS CodeBuild Plugin] INFO   - __main__             - make build_all CFLAGS_NODIST=" -fprofile-use -fprofile-correction" LDFLAGS_NODIST=""
[AWS CodeBuild Plugin] INFO   - __main__             - make[1]: Entering directory `/usr/src/python'
[AWS CodeBuild Plugin] INFO   - __main__             - LD_LIBRARY_PATH=/usr/src/python ./python -E -S -m sysconfig --generate-posix-vars ;\
[AWS CodeBuild Plugin] if test $? -ne 0 ; then \
[AWS CodeBuild Plugin] 	echo "generate-posix-vars failed" ; \
[AWS CodeBuild Plugin] 	rm -f ./pybuilddir.txt ; \
[AWS CodeBuild Plugin] 	exit 1 ; \
[AWS CodeBuild Plugin] INFO   - __main__             - fi
[AWS CodeBuild Plugin] INFO   - __main__             - /bin/sh: ./python: Permission denied
[AWS CodeBuild Plugin] INFO   - __main__             - generate-posix-vars failed
[AWS CodeBuild Plugin] INFO   - __main__             - make[1]:
[AWS CodeBuild Plugin] INFO   - __main__             - *** [pybuilddir.txt] Error 1
[AWS CodeBuild Plugin] INFO   - __main__             - make[1]: Leaving directory `/usr/src/python'
[AWS CodeBuild Plugin] INFO   - __main__             - make:
[AWS CodeBuild Plugin] INFO   - __main__             - *** [profile-opt] Error 2
[AWS CodeBuild Plugin] INFO   - __main__             - make:
[AWS CodeBuild Plugin] INFO   - __main__             - *** Waiting for unfinished jobs....
[AWS CodeBuild Plugin] INFO   - __main__             - 2

Has anyone run into something like this before? I’m not quite sure where to go next to try and debug this. I’m using gcc 7.3.1.

Many thanks!

That “permission denied” error when trying to run ./python is
indicative of missing execute permission on the file. Perhaps the
build is occurring somewhere like /tmp and the filesystem there is
mounted with the noexec flag for security reasons?