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

NVCC compilation flags/options ordering #898

Closed
jjennychen opened this issue Jul 29, 2024 · 0 comments · Fixed by #899
Closed

NVCC compilation flags/options ordering #898

jjennychen opened this issue Jul 29, 2024 · 0 comments · Fixed by #899

Comments

@jjennychen
Copy link
Collaborator

chipStar's nvcc seems to be re-ordering the compilation flags/options, leading to compilation error as the library that a file depends on is placed on its left, while it should be put on the right for linking to be successful. Here is the specific error:

nvcc  -std=c++14 -Xcompiler -Wall -arch=sm_60 -Ddfloat=float -Ddlong=int  -O3 main.o meshBasis.o BlasLapack/libBlasLapack.a -o main BlasLapack/libBlasLapack.a -lgfortran
warning: cucc is a work-in-progress. It is incomplete and may behave incorrectly.
Please, report issues at https://github.com/CHIP-SPV/chipStar/issues.
warning: Ignored option '-arch'
/usr/bin/ld: meshBasis.o: in function `matrixEig(int, float*, float*, float*, float*)':
meshBasis.cpp:(.text+0x800): undefined reference to `dgeev_'
/usr/bin/ld: meshBasis.o: in function `matrixRightSolve(int, int, float*, int, int, float*, float*)':
meshBasis.cpp:(.text+0x3b5c): undefined reference to `dgesv_'
/usr/bin/ld: meshBasis.o: in function `matrixInverse(int, float*)':
meshBasis.cpp:(.text+0x3d04): undefined reference to `dgetrf_'
/usr/bin/ld: meshBasis.cpp:(.text+0x3d21): undefined reference to `dgetri_'
clang++: error: linker command failed with exit code 1 (use -v to see invocation)

failed to execute:/home/tsaini.chen/install/llvm/17.0/bin/clang++ -include /home/tsaini.chen/install/chipStar/chipStar_06272024/include/hip/spirv_fixups.h -I//home/tsaini.chen/install/chipStar/chipStar_06272024/include -isystem /home/tsaini.chen/install/chipStar/chipStar_06272024/include/cuspv -include /home/tsaini.chen/install/chipStar/chipStar_06272024/include/cuspv/cuda_runtime.h -D__NVCC__ -D__CHIP_CUDA_COMPATIBILITY__ -std=c++14 -Wall -Ddfloat=float -Ddlong=int -O3 BlasLapack/libBlasLapack.a BlasLapack/libBlasLapack.a -lgfortran main.o meshBasis.o -o main -L/home/tsaini.chen/install/chipStar/chipStar_06272024/lib -lCHIP -no-hip-rt -Wl,-rpath,/home/tsaini.chen/install/chipStar/chipStar_06272024/lib
make: *** [Makefile:47: main] Error 1

The command nvcc -std=c++14 -Xcompiler -Wall -arch=sm_60 -Ddfloat=float -Ddlong=int -O3 main.o meshBasis.o BlasLapack/libBlasLapack.a -o main BlasLapack/libBlasLapack.a -lgfortran was run with BlasLapack/libBlasLapack.a library on the right of meshBasis.o object file, but in the actual underlying command (the one following "failed to execute:"), the library is placed before the object file, leading to undefined reference errors. The linking was successful when we manually put the library after/on the right of the object file.

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

Successfully merging a pull request may close this issue.

1 participant