Bug 32503

Summary: liblapacke.a is not relocatable
Product: Mageia Reporter: michel zou <xantares09>
Component: RPM PackagesAssignee: All Packagers <pkg-bugs>
Status: NEW --- QA Contact:
Severity: normal    
Priority: Normal CC: joequant, lewyssmith
Version: 9   
Target Milestone: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Source RPM: lapack-3.11.0-1.mga9.src.rpm CVE:
Status comment:

Description michel zou 2023-11-10 15:50:31 CET
it would seem that lapacke static lib is not compiled with fPIC:


[100%] Linking CXX shared library libhmat.so
[   32s] /usr/bin/cmake -E cmake_link_script CMakeFiles/hmat.dir/link.txt --verbose=1
[   32s] /usr/bin/c++ -fPIC -I/usr/include/lapacke -DNDEBUG -Wl,--as-needed -Wl,--no-undefined -Wl,-z,relro -Wl,-O1 -Wl,--build-id=sha1 -Wl,--enable-new-dtags -shared -Wl,-soname,libhmat.so.3 -o libhmat.so.1.8.1 CMakeFiles/hmat.dir/src/admissibility.cpp.o CMakeFiles/hmat.dir/src/assembly.cpp.o CMakeFiles/hmat.dir/src/c_default_interface.cpp.o CMakeFiles/hmat.dir/src/cluster_assembly_function.cpp.o CMakeFiles/hmat.dir/src/cluster_tree.cpp.o CMakeFiles/hmat.dir/src/clustering.cpp.o CMakeFiles/hmat.dir/src/common/context.cpp.o CMakeFiles/hmat.dir/src/common/memory_instrumentation.cpp.o CMakeFiles/hmat.dir/src/compression.cpp.o CMakeFiles/hmat.dir/src/coordinates.cpp.o CMakeFiles/hmat.dir/src/data_types.cpp.o CMakeFiles/hmat.dir/src/default_engine.cpp.o CMakeFiles/hmat.dir/src/disable_threading.cpp.o CMakeFiles/hmat.dir/src/fromdouble.cpp.o CMakeFiles/hmat.dir/src/full_matrix.cpp.o CMakeFiles/hmat.dir/src/h_matrix.cpp.o CMakeFiles/hmat.dir/src/hmat_cpp_interface.cpp.o CMakeFiles/hmat.dir/src/hodlr.cpp.o CMakeFiles/hmat.dir/src/json.cpp.o CMakeFiles/hmat.dir/src/lapack_operations.cpp.o CMakeFiles/hmat.dir/src/random_pivot_manager.cpp.o CMakeFiles/hmat.dir/src/rk_matrix.cpp.o CMakeFiles/hmat.dir/src/scalar_array.cpp.o CMakeFiles/hmat.dir/src/serialization.cpp.o CMakeFiles/hmat.dir/src/uncompressed_values.cpp.o  -lm -lrt /usr/lib/gcc/x86_64-mageia-linux/12/libgomp.so /usr/lib64/libpthread.a /usr/lib64/liblapacke.a /usr/lib64/libblas.a /usr/lib64/liblapack.a /usr/lib64/libcblas.so /usr/lib64/libblas.so /usr/lib64/libtmglib.a /usr/lib64/liblapack.a /usr/lib64/libblas.a 
[   32s] /usr/bin/ld: /usr/lib64/liblapacke.a(lapacke_sgeqrf.c.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
[   32s] /usr/bin/ld: failed to set dynamic section sizes: bad value
[   32s] collect2: error: ld returned 1 exit status
Comment 1 michel zou 2023-11-10 15:52:15 CET
from the log:

[213/312] installing lib64lapack3-3.11.0-1.mga9
...
[264/312] installing lib64lapack-devel-3.11.0-1.mga9
...
[268/312] installing lib64lapack-static-devel-3.11.0-1.mga9

here is the full build log:
https://build.opensuse.org/public/build/science:openturns/Mageia_9/x86_64/hmat-oss/_log
sturmvogel 2023-11-10 18:26:31 CET

Source RPM: https://distrib-coffee.ipsl.jussieu.fr/pub/linux/Mageia/distrib/9/SRPMS/core/release/lapack-3.11.0-1.mga9.src.rpm => lapack-3.11.0-1.mga9.src.rpm
URL: https://distrib-coffee.ipsl.jussieu.fr/pub/linux/Mageia/distrib/9/x86_64/media/core/release/lib64lapack-static-devel-3.11.0-1.mga9.x86_64.rpm => (none)

Comment 2 Lewis Smith 2023-11-16 22:22:45 CET
Michel, sorry to have left you; and thank you for the report.
How did you encounter this?
Please say what problem results from your diagnosis.

Your complaint comes I suppose from the end of comment 0:
[   32s] /usr/bin/ld: /usr/lib64/liblapacke.a(lapacke_sgeqrf.c.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
[   32s] /usr/bin/ld: failed to set dynamic section sizes: bad value
[   32s] collect2: error: ld returned 1 exit status

From the Suse build log:
[   33s] /usr/bin/c++ -fPIC -I/usr/include/lapacke ...

It is a complicated subject, and I got the impression that compiling with PIC (Position Independant Code) is normal, even though in some situations not strictly necessary.
It could be an isolated case where the compile flag -fPIC is missing, but begs the question of whether there are others.

No one packager deals with this, so assigning it globally. CC'ing Joseph who last committed it.

Assignee: bugsquad => pkg-bugs
CC: (none) => joequant, lewyssmith

Comment 3 michel zou 2023-11-17 08:35:33 CET
Hello, the -fPIC flag is present in the log I'm showing because I'm try to build a shared lib that links to lapacke static lib.

Now if -fPIC its not used when linking lapack itself (in mageai's lib64lapack-static-devel package) then we get the error "relocation R_X86_64_32 ... can not be used when making a shared object"