1

I am building a code with meson using GCC 7.5.0 and CUDA 11.4 and getting the error:

/usr/bin/ld: unrecognized option '-pthread'

in the building step. ld version is 2.34. Here is the output:

[5/6] Linking target SU2_CFD/src/SU2_CFD
FAILED: SU2_CFD/src/SU2_CFD 
nvcc  -o SU2_CFD/src/SU2_CFD SU2_CFD/src/SU2_CFD.p/SU2_CFD.cpp.o -Xlinker=-O1 SU2_CFD/src/libSU2core.a externals/metis/libmetis.a externals/parmetis/libparmetis.a Common/src/libSU2Common.a -Xlinker=-pthread -Xlinker=-rpath -Xlinker=/usr/apps/openmpi/lib -Xlinker=--enable-new-dtags -L/usr/apps/openmpi/lib -lmpi -Xlinker=-pthread -Xlinker=-rpath -Xlinker=/usr/apps/openmpi/lib -Xlinker=--enable-new-dtags -L/usr/apps/openmpi/lib -lmpi -Xlinker=/usr/local/cuda-11.4/targets/x86_64-linux/lib/libcusparse.so -Xlinker=-pthread -Xlinker=-rpath -Xlinker=/usr/apps/openmpi/lib -Xlinker=--enable-new-dtags -L/usr/apps/openmpi/lib -lmpi -Xlinker=-pthread -Xlinker=-rpath -Xlinker=/usr/apps/openmpi/lib -Xlinker=--enable-new-dtags -L/usr/apps/openmpi/lib -lmpi -Xlinker=-pthread -Xlinker=-rpath -Xlinker=/usr/apps/openmpi/lib -Xlinker=--enable-new-dtags -L/usr/apps/openmpi/lib -lmpi -Xlinker=-pthread -Xlinker=-rpath -Xlinker=/usr/apps/openmpi/lib -Xlinker=--enable-new-dtags -L/usr/apps/openmpi/lib -lmpi -Xlinker=-pthread -Xlinker=-rpath -Xlinker=/usr/apps/openmpi/lib -Xlinker=--enable-new-dtags -L/usr/apps/openmpi/lib -lmpi -Xlinker=-pthread -Xlinker=-rpath -Xlinker=/usr/apps/openmpi/lib -Xlinker=--enable-new-dtags -L/usr/apps/openmpi/lib -lmpi '-Xlinker=-rpath,$ORIGIN/:$ORIGIN/../../externals/metis:$ORIGIN/../../externals/parmetis:$ORIGIN/../../Common/src' -Xlinker=-rpath-link,/home/nahmad16/SU2/build/SU2_CFD/src -Xlinker=-rpath-link,/home/nahmad16/SU2/build/externals/metis -Xlinker=-rpath-link,/home/nahmad16/SU2/build/externals/parmetis -Xlinker=-rpath-link,/home/nahmad16/SU2/build/Common/src -lstdc++
/usr/bin/ld: unrecognized option '-pthread'
/usr/bin/ld: use the --help option for usage information
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.

Thanks for your help

Robert Crovella
  • 143,785
  • 11
  • 213
  • 257
nahmad
  • 41
  • 2
  • `-Xlinker` is a switch passed to `nvcc` to indicate that the subsequent switch(es) should be passed *directly* to the linker, which is `ld` in this case. `-pthread` is a switch you would pass to `gcc` or `g++` to specify that you want support for pthreads. It's not meaningful/relevant when passed directly to the linker (`ld`). If you want to specify something similar to the linker the switch should be `-lpthread` not `-pthread`. So I have no idea what you are building, but a possibly correct version of the switch for `nvcc` is `-Xlinker=-lpthread` not `-Xlinker=-pthread` – Robert Crovella Dec 19 '21 at 19:59
  • Thanks for the comment, Robert. Actually, the nvcc build command line is built automatically by meson and (probably) ninja. I am not building it myself. – nahmad Dec 19 '21 at 20:03
  • 2
    I'm not familiar with meson, but most build systems I am familiar with take a list of instructions from some kind of input (otherwise how would it know what to build). It might be that there are some input files that tell meson what to do, that are incorrectly defined. You've not indicated what code you are building, nor given any of the inputs that meson uses, so I'm not sure how anyone could tell you what is wrong, or if there is an issue with meson itself. Good luck! – Robert Crovella Dec 19 '21 at 20:14
  • 1
    Meson dev here... The two most obvious things to me are either 1. someone is passing -pthread as an explicit argument which we will just blindly pass along to whatever compiler/linker combination, or the way we translate the `threads` dependency to nvcc is wrong. Out of curiosity, which version of meson is this? – dcbaker Dec 21 '21 at 07:52
  • Hi Baker. Thanks a lot for your reply. Meson version is 0.54.999. I can send more information if you need. Please let me know what additional info is required. – nahmad Dec 21 '21 at 19:16
  • 1
    That's a git snapshot between 0.54 and 0.55, out of curiosity, could you try 0.60.2 (the current latest release) or 0.59.3 and see if the same issue persists? Cuda support in meson has been evolving, and is often entwined with our support for cmake dependencies, which are also evolving pretty rapidly. – dcbaker Dec 21 '21 at 22:03
  • Baker. Using meson build 0.60.2 did the trick. Thank you. Not sure how to mark your comment as an answer although I want to – nahmad Dec 25 '21 at 03:42

0 Answers0