czimaginginstitute / MotionCor3

Anisotropic correction of beam induced sample motion for cryo-electron microscopy and tomography
BSD 3-Clause "New" or "Revised" License
41 stars 2 forks source link

Compiling issues #11

Open mbelouso opened 8 months ago

mbelouso commented 8 months ago

Hey guys,

I have the following issue. When compiling with:

make exe -f makefile11

I get the following error after it compiles lots of other things:

/usr/bin/ld: /home/mbelouso/MotionCor3/Lib/libmrcfile.a(CLoadExtHeader.o): relocation R_X86_64_32 against symbol '__gxx_personality_v0@@CXXABI_1.3' can not be used when making a PIE object; recompile with -fPIE /usr/bin/ld: failed to set dynamic section sizes: bad value collect2: error: ld returned 1 exit status make: *** [makefile11:160: exe] Error 1

gcc and g++ version is 11.4, CUDA 11.8, linux mint 21

Any thoughts?

elainehoml commented 7 months ago

I had the same issue but adding -Xcompiler -no-pie to makefile11 in the exe block worked for me (copied from Issue #4)

See https://github.com/czimaginginstitute/MotionCor3/issues/4#issuecomment-1784848759 for the full code snippet

mbelouso commented 7 months ago

@elainehoml Thanks for the heads up. I added these lines to the makefile11, but still run into the same issue. Same error output as in my initial post.

stiobhan commented 4 months ago

Adding these flags in makefile11 seems to work. A different workaround that worked for me as well was to use GCC 10 instead of GCC 11.

mbelouso commented 4 months ago

Yeah. I eventually got it to compile with a different version of GCC (8.0) and adding these flags. Thanks.

On Wed, 14 Feb 2024, 10:13 pm Stefan Fleischmann, @.***> wrote:

Adding these flags in makefile11 seems to work. A different workaround that worked for me as well was to use GCC 10 instead of GCC 11.

— Reply to this email directly, view it on GitHub https://github.com/czimaginginstitute/MotionCor3/issues/11#issuecomment-1943556513, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGEXN7BZNKGSSKSSIRTZSHTYTSL4VAVCNFSM6AAAAAA7KC2IFCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNBTGU2TMNJRGM . You are receiving this because you authored the thread.Message ID: @.***>

jpellman commented 1 month ago

Just to provide more context here, at some point several popular Linux distributions decided to compile their packaged versions of gcc with the -enable-default-pie option (see here). The version of gcc used isn't as relevant so much as whether or not gcc was compiled with PIE as default. The list of compile options for the particular gcc binary you're using can be found by typing gcc -v (or g++ -v in the case of g++).

A PIE (position independent executable) is a binary compiled with a security measure that is meant to prevent some common buffer overflow attacks; I'm not certain, but I imagine it has become the default due to several high-profile buffer overflow exploits in somewhat recent years (e.g., Heartbleed).

I'm uncertain why PIE binaries can't be produced with NVCC, but some frightfully old CUDA docs provide a clue:

The host linker on Mac OS 10.7 generates position-independent executables by default. As CUDA does not support position-independent executable currently, the linker must generate position-dependent executable by passing in the -no_pie option. If nvcc is being used to link the application, this option will be passed to the linker by default. To override the default behavior, the -Xlinker -pie option can be passed to nvcc.

My educated guess is that modern versions of CUDA still do not support PIE binaries, although I can find no documentation out there to confirm or deny this hypothesis.