Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

libcrypto.a located inside /hbb_shlib/lib64 is not compiled with -fPIC #66

Open
PMarinov1994 opened this issue Oct 22, 2024 · 0 comments

Comments

@PMarinov1994
Copy link

PMarinov1994 commented Oct 22, 2024

I am building a Python binary with the _ssl module. Python creates shared libraries which wrap functions of other libraries. With the _ssl module, the python script is building _ssl.cpython-313-x86_64-linux-gnu.so. When this shared library is created, it needs to be linked with libcrypto.a static library.

I use the environment from /hbb_shlib. The static libraries there should be compiled with -fPIC, but libcrypto.a is not.

I looked what is the cause and here is what I found:
image/variants/shlib.sh does not provide -fPIC for EXTRA_SHLIB_CFLAGS which in turn is used for SHLIB_CFLAGS.

When building the openSSL library inside image/build.sh:175 install_openssl(), the LIB_CFLAGS variable is set to SHLIB_CFLAGS (this variable does not contain -fPIC flag), which results in the libcrypto.a static library to not be usable in shared libraries.

Possible solutions:

  1. Add -fPIC to image/variants/shlib.sh
activate_holy_build_box /hbb_shlib \
	"" \
	"-static-libstdc++" \
	"-fPIC" \
	"-fPIC" \  # <---- CHANGE
	"-static-libstdc++"
  1. Change the build function of install_openssl (line 195 @ image/build.sh)
export LIB_CFLAGS="$SHLIB_CFLAGS" # <---- OLD LINE
export LIB_CFLAGS="$STATICLIB_CFLAGS" # <---- NEW LINE

Here is the build script that will trigger the error.

source /hbb_shlib/activate
curl -L -O https://www.python.org/ftp/python/3.13.0/Python-3.13.0.tar.xz

tar -xf Python-3.13.0.tar.xz
cd Python-3.13.0

sed -i 's|-lssl -lcrypto|-lssl -lcrypto -lz -ldl|' configure
./configure --prefix=$PWD/_install --with-openssl=/hbb_shlib

make -j4

Let me know what you think :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant