amazonlinux / amazon-linux-2023

Amazon Linux 2023
https://aws.amazon.com/linux/amazon-linux-2023/
Other
500 stars 37 forks source link

[Bug] - python3 cflags #705

Closed mloubout closed 2 months ago

mloubout commented 2 months ago

Describe the bug

It looks like the python3 cflags are a bit too restrictive in the docker image public.ecr.aws/amazonlinux/amazonlinux:2023

To Reproduce

Steps to reproduce the behavior:

docker run --rm -it public.ecr.aws/amazonlinux/amazonlinux:2023 /bin/bash

then, in the docker image

bash-5.2# yum install python3-devel
bash-5.2# python3-config --cflags
-I/usr/include/python3.9 -I/usr/include/python3.9  -Wno-unused-result -Wsign-compare  -O2 -ftree-vectorize  -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS  -fstack-protector-strong   -m64 -march=x86-64-v2 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -D_GNU_SOURCE -fPIC -fwrapv  -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG  -O2 -ftree-vectorize  -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS  -fstack-protector-strong   -m64 -march=x86-64-v2 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -D_GNU_SOURCE -fPIC -fwrapv

Some of these flags are very problematic, as for example nvc (nvidia compiler) does not support x86-64-v2 making the amazon linux image unusable as a base for nvc based workflows (e.g installing mpi4py with nvc for cross GPU mpi in python) Expected behavior

Additional context

It is also worth mentioning that public.ecr.aws/amazonlinux/amazonlinux:2 has issues as well that are more problematic as the cflags contains c++ exculive flags that breaks some C compilers

bash-4.2# python3-config --cflags
-I/usr/include/python3.7m -I/usr/include/python3.7m  -Wno-unused-result -Wsign-compare -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches    -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv   -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches    -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv

where you can see for example -fexceptions which is a c++-only cflag

stewartsmith commented 2 months ago

An x86-64-v2 baseline is not unique to Amazon Linux, and third party software will need to adapt in order to remain compatible with modern major Linux distributions.

mloubout commented 2 months ago

This is not what this is about. The CFLAGS of the python3 configuration are too restrictive.

For reference:

https://docs.python.org/3/using/configure.html#envvar-CFLAGS_NODIST

Which explicitly uses -Werror as something that should not be in the config cflags. Having every flag duplicate is also not a good sign.

third party software will need to adapt in order to remain compatible with modern major Linux distributions.

Considering every version of the NVIDIA HPC SDK of the past two years (I stopped trying at 22.9) fails to install mpi4py because of those config flags on amazon Linux because x86-64-v2 restricts to a version too old for nvc, I really doubt they will revert their entire HPC SDK for amazon Linux and keep using something else.