cloudfoundry / python-buildpack

Cloud Foundry buildpack for the Python Language
http://docs.cloudfoundry.org/buildpacks/
Apache License 2.0
119 stars 278 forks source link

Compilation issues on Ubuntu 22.04 cells #733

Open amhuber opened 1 year ago

amhuber commented 1 year ago

What version of Cloud Foundry and CF CLI are you using? (i.e. What is the output of running cf curl /v2/info && cf version? API 2.195.0 / CLI v8.6.1

What version of the buildpack you are using? Any

If you were attempting to accomplish a task, what was it you were attempting to do? Trying to stage apps that use the xmlsec package which requires binary compilation. Using the following config along with the APT buildpack to install the necessary components:

apt.yml

---
packages:
- libxml2-dev
- libxmlsec1-dev
- libxmlsec1-openssl

requirements.txt

xmlsec

This being done on cells using the jammy stemcell but still using cflinuxfs3.

What did you expect to happen? Compilation should succeed and staging should work. We've tried multiple versions of the buildpack and multiple Python versions.

What was the actual behavior? Getting a compilation error:

   /usr/bin/ld: /tmp/contents2936741549/deps/0/apt/usr/lib/x86_64-linux-gnu/libxml2.a(tree.o): relocation R_X86_64_PC32 against symbol `xmlMalloc' can not be used when making a shared object; recompile with -fPIC

Please confirm where necessary:

robdimsdale commented 1 year ago

@amhuber This is a very specific use-case that we haven't covered (specific libraries on Bionic stack on top of Jammy stemcell) so I'm not hugely surprised you're running into issues.

To help us figure this out, have you tried this on either combination of Jammy stemcell/Jammy stack or Bionic stemcell/Bionic stack? I want to narrow down if the issue is with the stack itself or the combination of stack and stemcell. If you are able to build on the cflinuxfs4 stack on top of the cflinuxfs4 stemcell, that would be a useful data point.

amhuber commented 1 year ago

We just deployed cflinuxfs4 today actually since it was just added to cf-deployment so I gave it a try and I'm getting more or less the same error:

/usr/bin/ld: /tmp/contents1881946331/deps/0/apt/usr/lib/x86_64-linux-gnu/libxml2.a(error.o): relocation R_X86_64_PC32 against symbol `stderr@@GLIBC_2.2.5' can not be used when making a shared object; recompile with -fPIC

As far as I can tell the "-fPIC" option is already being used in the compilation options, but one way or another I'm assuming that there is some compilation option that needs to be added to CFLAGS in the buildpack to deal with address space randomization in the Jammy kernel. I'm assuming that any PIP package that needs needs native compilation might have the same issue but I haven't tested any beyond xmlsec.

robdimsdale commented 1 year ago

Thanks for reproducing on Jammy stemcell + cflinuxfs4. That makes it easier to reproduce and also increases the priority of this because I think it can be abstracted to "PIP packages that require native compilation fail to compile on cflinuxfs4 on Jammy stemcell". Which I think is a reasonable problem statement for us to explore and hopefully fix.

Did you see this working on the previous stemcell (xenial?) and cflinuxfs3 ? Again, I'm just trying to narrow down the scope - is this a new problem with Jammy stemcells/stacks, or is this a net-new feature that has never worked before.

amhuber commented 1 year ago

Yes, this was one of the test cases that failed with the Python.h issues (https://github.com/cloudfoundry/python-buildpack/issues/574) so it was definitely working on bionic with cflinuxfs3. Basically compilation now fails on jammy with either cflinuxfs3 or cflinuxfs4.

robdimsdale commented 1 year ago

@amhuber do you have a way to reproduce this without using the apt buildpack? Just trying to reduce the number of moving parts to explore.

amhuber commented 1 year ago

The only issue reported by my customers is with xmlsec and it requires the APT packages or it just fails immediately with an error that they are missing. It's very possible there are other PIP packages that would have the same issue but I don't know of any.

The simplest possible repro steps:

That is currently erroring for me with v1.8.12 of the buildpack.