I am trying to build lxml from source (trying the latest 5.2.2 release and the latest master commit with hash bce5b10) using the STATIC_DEPS option in an attempt to test compatibility of my libraries on the latest pre-release code of Python 3.13.
The system is Ubuntu 22.04 in both cases. After it failed with Python 3.13.0-beta.3 through GitHub Actions, I verified this locally as well using Python Python 3.10.12 in this case. Both show the same behaviour.
To install the package, I would use `STATIC_DEPS=true python -m pip install lxml` for the latest release and `STATIC_DEPS=true python -m build --verbose .` for the latest development code.
This is the output generated on Python 3.10:
```
[...]
copying /tmp/build-via-sdist-ydv3hdvg/lxml-5.2.2/build/tmp/libxml2/include/libxml2/libxml/__init__.py -> build/lib.linux-x86_64-cpython-310/lxml/includes/libxml
running build_ext
building 'lxml.etree' extension
creating build/temp.linux-x86_64-cpython-310
creating build/temp.linux-x86_64-cpython-310/src
creating build/temp.linux-x86_64-cpython-310/src/lxml
x86_64-linux-gnu-gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -fPIC -DLIBXML_STATIC -DLIBXSLT_STATIC -DLIBEXSLT_STATIC -DCYTHON_CLINE_IN_TRACEBACK=0 -Ibuild/tmp/libxml2/include -Ibuild/tmp/libxml2/include/libxml2 -Ibuild/tmp/libxml2/include/libxslt -Ibuild/tmp/libxml2/include/libexslt -Isrc -Isrc/lxml/includes -I/tmp/build-env-l25x1o5d/include -I/usr/include/python3.10 -c src/lxml/etree.c -o build/temp.linux-x86_64-cpython-310/src/lxml/etree.o -w
x86_64-linux-gnu-gcc -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -g -fwrapv -O2 build/temp.linux-x86_64-cpython-310/src/lxml/etree.o /tmp/build-via-sdist-ydv3hdvg/lxml-5.2.2/build/tmp/libxml2/lib/libxml2.a /tmp/build-via-sdist-ydv3hdvg/lxml-5.2.2/build/tmp/libxml2/lib/libexslt.a /tmp/build-via-sdist-ydv3hdvg/lxml-5.2.2/build/tmp/libxml2/lib/libxslt.a /tmp/build-via-sdist-ydv3hdvg/lxml-5.2.2/build/tmp/libxml2/lib/libiconv.a /tmp/build-via-sdist-ydv3hdvg/lxml-5.2.2/build/tmp/libxml2/lib/libz.a -Lbuild/tmp/libxml2/lib -L/usr/lib/x86_64-linux-gnu -lrt -lm -o build/lib.linux-x86_64-cpython-310/lxml/etree.cpython-310-x86_64-linux-gnu.so
/usr/bin/ld: /tmp/build-via-sdist-ydv3hdvg/lxml-5.2.2/build/tmp/libxml2/lib/libxslt.a(transform.o): warning: relocation against `xslDebugStatus' in read-only section `.text'
/usr/bin/ld: /tmp/build-via-sdist-ydv3hdvg/lxml-5.2.2/build/tmp/libxml2/lib/libxml2.a(libxml2_la-relaxng.o): relocation R_X86_64_PC32 against symbol `xmlFree' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: bad value
collect2: error: ld returned 1 exit status
error: command '/usr/bin/x86_64-linux-gnu-gcc' failed with exit code 1
ERROR Backend subprocess exited when trying to invoke build_wheel
```
The error message is:
"relocation R_X86_64_PC32 against symbol `xmlFree' can not be used when making a shared object; recompile with -fPIC"
So, you need to make sure that your C compiler CFLAGS contain "-fPIC".
Regardless, the next release will have binary wheels for Py3.13, so this should no longer be an issue then.