LLNL / GOTCHA

GOTCHA is a library for wrapping function calls in shared libraries
https://gotcha.readthedocs.io/en/latest/
Other
71 stars 21 forks source link

Fix SYMVER to be built using attributes for GCC 13.2 #139

Closed hariharan-devarajan closed 11 months ago

hariharan-devarajan commented 11 months ago

Fixes #136

hariharan-devarajan commented 11 months ago

@bkmgit I tried compiling with gcc 13.2 on ubuntu with #139. It seems to be building and running. Can you confirm if this PR solves your issue?

bertwesarg commented 11 months ago

"gcc 1.13.2"?

bkmgit commented 11 months ago

Tried on Fedora 39 with

sudo -y dnf install check-devel cmake git gcc-c++ python3-sphinx
git clone https://github.com/LLNL/GOTCHA
cd GOTCHA
git checkout build/fix_symver_gcc13
sed -i 's/-O0 //g' test/hammer/CMakeLists.txt
export CFLAGS='-O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Werror=implicit-function-declaration -Werror=implicit-int -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1  -mbranch-protection=standard -fasynchronous-unwind-tables -fstack-clash-protection -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer '
export CXXFLAGS='-O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1  -mbranch-protection=standard -fasynchronous-unwind-tables -fstack-clash-protection -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer '
mkdir build
cd build
cmake -DGOTCHA_ENABLE_TESTS=ON -DDEPENDENCIES_PREINSTALLED=TRUE ..
make

This fails with

[ 93%] Linking C shared library libretX.so
/usr/bin/ld: libretX.so: version node not found for symbol retX @ @GOTCHA_2
/usr/bin/ld: failed to set dynamic section sizes: bad value
collect2: error: ld returned 1 exit status
make[2]: *** [test/symver/CMakeFiles/retX.dir/build.make:113: test/symver/libretX.so] Error 1
make[1]: *** [CMakeFiles/Makefile2:1510: test/symver/CMakeFiles/retX.dir/all] Error 2
make: *** [Makefile:146: all] Error 2

If it would help, can make a pull request to add a GitHub actions build on Fedora using a container. Build flags are those used when packaging the library. Without those flags for a hardened build, the build completes and tests pass.

hariharan-devarajan commented 11 months ago

"gcc 1.13.2"?

Yes I installed that with spack and was able to compile with the above fixes.

@bkmgit I will try it on a container with fedora. Which image of fedora are u using? Is it on Dockerhub? If u have a docker script as a reproducer it will help me a lot.

bertwesarg commented 11 months ago

My point is, that "GCC 1.13.2" is probably a typo. If anything, that version was released in the 1980s.

hariharan-devarajan commented 11 months ago

My point is, that "GCC 1.13.2" is probably a typo. If anything, that version was released in the 1980s.

Ah yes. I meant 13.2. Fixed the PR name too.

bkmgit commented 11 months ago

Created a pull request that uses GitHub Actions: https://github.com/LLNL/GOTCHA/pull/141

The O0 optimization flag in https://github.com/LLNL/GOTCHA/blob/develop/test/hammer/CMakeLists.txt#L17 causes a build failure. Not sure why. Have removed it using sed, but maybe it can be fixed?

It does not have the other hardened build compiler flags which cause the build failure, can add these afterwards.

Finally, Fedora offers a CI service packit - can add this as well as a follow on.

hariharan-devarajan commented 11 months ago

@mplegendre Do you know if the -O0 flag was added to that test?

mplegendre commented 11 months ago

I don't know.

github-actions[bot] commented 11 months ago

Pull Request Test Coverage Report for Build 7233125937


Totals Coverage Status
Change from base Build 7028813137: 0.0%
Covered Lines: 1001
Relevant Lines: 1001

💛 - Coveralls