NVIDIA / cuda-quantum

C++ and Python support for the CUDA Quantum programming model for heterogeneous quantum-classical workflows
https://nvidia.github.io/cuda-quantum/
Other
501 stars 182 forks source link

source build error in build_cudaq.sh #2272

Open kannanlu opened 1 week ago

kannanlu commented 1 week ago

Required prerequisites

Describe the bug

Hi, I try to build from source with openssl and zlib installed following the methods in "install_prerequisites.sh", then I try to install with "build_cudaq.sh" and I encountered errors in the ninja log as follows:

[268/615] Linking CXX shared library lib/libcudaq-common.so FAILED: lib/libcudaq-common.so : && /usr/bin/g++ -fPIC -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -Wimplicit-fallthrough -Wno-class-memaccess -Wno-redundant-move -Wno-pessimizing-move -Wno-noexcept-type -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment -Wno-misleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -O3 -DNDEBUG -Wl,-z,defs -Wl,-z,nodelete -shared -Wl,-soname,libcudaq-common.so -o lib/libcudaq-common.so runtime/common/CMakeFiles/cudaq-common.dir/Environment.cpp.o runtime/common/CMakeFiles/cudaq-common.dir/Executor.cpp.o runtime/common/CMakeFiles/cudaq-common.dir/Future.cpp.o runtime/common/CMakeFiles/cudaq-common.dir/Logger.cpp.o runtime/common/CMakeFiles/cudaq-common.dir/MeasureCounts.cpp.o runtime/common/CMakeFiles/cudaq-common.dir/NoiseModel.cpp.o runtime/common/CMakeFiles/cudaq-common.dir/Resources.cpp.o runtime/common/CMakeFiles/cudaq-common.dir/ServerHelper.cpp.o runtime/common/CMakeFiles/cudaq-common.dir/Trace.cpp.o runtime/common/CMakeFiles/cudaq-common.dir/RestClient.cpp.o -Wl,-rpath,"\$ORIGIN:\$ORIGIN/lib:\$ORIGIN/lib/plugins:\$ORIGIN/../lib:\$ORIGIN/../lib/plugins" lib/libcudaq-spin.so tpls/spdlog/libspdlog.a tpls/cpr/cpr/libcpr.a -Wl,--start-group /usr/local/zlib/lib/libz.a tpls/fmt/libfmt.a /usr/local/curl/lib/libcurl.a /usr/local/openssl/lib64/libssl.a /usr/local/openssl/lib64/libcrypto.a -ldl && : /bin/ld: missing --end-group; added as last command line option /bin/ld: /usr/local/zlib/lib/libz.a(deflate.o): warning: relocation against z_errmsg' in read-only section.text' /bin/ld: /usr/local/zlib/lib/libz.a(zutil.o): relocation R_X86_64_PC32 against symbol `z_errmsg' can not be used when making a shared object; recompile with -fPIC /bin/ld: final link failed: bad value collect2: error: ld returned 1 exit status

anyone knows what might actually causing this issue? Thanks.

Best, Kannan

Steps to reproduce the bug

simply follow the source build instructions: run "build_llvm.sh", then run "install_prerequisites.sh", then run "build_cudaq.sh"

Expected behavior

simply build successfully without error

Is this a regression? If it is, put the last known working version (or commit) here.

Not a regression

Environment

Suggestions

No response

1tnguyen commented 1 week ago

I'm not sure about the root cause but the error message indicates that libz.a might not be compiled with -fPIC. The compile script for libz in install_prerequisites.sh certainly set that flag. Could you please rerun the install_prerequisites.sh and gather the log related to libz? You may need to delete the existing installation (/usr/local/zlib) for it to re-install libz.