8000 [backport 3.3] cmake: fix LTO build on Fedora by TarantoolBot · Pull Request #11521 · tarantool/tarantool · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[backport 3.3] cmake: fix LTO build on Fedora #11521

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

Merged
merged 1 commit into from
May 26, 2025

Conversation

TarantoolBot
Copy link
Collaborator
@TarantoolBot TarantoolBot commented May 21, 2025

(This PR is a backport of #11509 to release/3.3 to a future 3.3.3 release.)


This patch is a follow-up to the commit
25af976 ("build: support cmake 4.0"). Since version 3.4, CMake doesn't add flags to export symbols from executables without the ENABLE_EXPORTS target property, see CMP0065 1 for details. Without this property, some unit C tests produce build warnings with LTO optimization enabled (for example, on Fedora 39):

NO_WRAP

[ 72%] Linking CXX executable luaT_tuple_new.test
In function ‘rmean_collect’,
    inlined from ‘txn_complete_success’ at src/box/txn.c:836:2,
    inlined from ‘txn_limbo_complete’ at src/box/txn_limbo.c:205:3:
src/lib/core/rmean.c:65:9: error: ‘__atomic_add_fetch_8’ writing 8 bytes into a region of size 0 overflows the destination [-Werror=stringop-overflow=]
   65 |         __atomic_add_fetch(&rmean->stats[name].value[0], value, __ATOMIC_RELAXED);
      |         ^
In function ‘txn_limbo_complete’:
lto1: note: destination object is likely at address zero

NO_WRAP

The CMP0065 is removed from CMake version 4.0 2. Thus, this patch fixes the behaviour by setting the property ENABLE_EXPORTS for unit tests directly.

NO_DOC=build
NO_TEST=build
NO_CHANGELOG=build


Originally observed on 2.11, see this CI run. But may be reproduced on the master branch with the following Dockerfile:

FROM fedora:39
RUN dnf upgrade --refresh -y
RUN dnf install -y git
RUN dnf install -y vim
RUN dnf install -y bash
RUN dnf install -y make
RUN dnf install -y cmake
RUN dnf install -y gcc
RUN dnf install -y g++
RUN dnf install -y libicu-devel
RUN dnf install -y openssl-devel
RUN dnf install -y readline-devel
RUN dnf install -y zlib-devel
RUN dnf install -y autoconf automake
RUN dnf install -y libtool

CMD ["bash"]

In the Docker: clone the Tarantool repo and build with the following command:

cmake . -DCMAKE_BUILD_TYPE=RelWithDebInfo -DENABLE_LTO=ON -DENABLE_WERROR=ON -DENABLE_DIST=ON && make -j3

This patch is a follow-up to the commit
25af976 ("build: support cmake 4.0").
Since version 3.4, CMake doesn't add flags to export symbols from
executables without the ENABLE_EXPORTS target property, see CMP0065 [1]
for details.  Without this property, some unit C tests produce build
warnings with LTO optimization enabled (for example, on Fedora 39):

NO_WRAP
```
[ 72%] Linking CXX executable luaT_tuple_new.test
In function ‘rmean_collect’,
    inlined from ‘txn_complete_success’ at src/box/txn.c:836:2,
    inlined from ‘txn_limbo_complete’ at src/box/txn_limbo.c:205:3:
src/lib/core/rmean.c:65:9: error: ‘__atomic_add_fetch_8’ writing 8 bytes into a region of size 0 overflows the destination [-Werror=stringop-overflow=]
   65 |         __atomic_add_fetch(&rmean->stats[name].value[0], value, __ATOMIC_RELAXED);
      |         ^
In function ‘txn_limbo_complete’:
lto1: note: destination object is likely at address zero
```
NO_WRAP

The real reason should be investigated in the scope of #11517. The
compilation warning may be suppressed, but it may also mask the actual
problems in the future tests. The CMP0065 is removed from CMake version
4.0 [2]. Thus, this patch fixes the behaviour by setting the property
`ENABLE_EXPORTS` for unit tests directly.

[1]: https://cmake.org/cmake/help/latest/policy/CMP0065.html
[2]: https://cmake.org/cmake/help/latest/manual/cmake-policies.7.html#policies-introduced-by-cmake-3-4-removed-by-cmake-4-0

NO_DOC=build
NO_TEST=build
NO_CHANGELOG=build

(cherry picked from commit 2bde926)
@TarantoolBot TarantoolBot added build full-ci Enables all tests for a pull request test labels May 21, 2025
@TarantoolBot TarantoolBot changed the title [Backport release/3.3] cmake: fix LTO build on Fedora [backport 3.3] cmake: fix LTO build on Fedora May 21, 2025
@coveralls
Copy link

Coverage Status

coverage: 87.514% (+0.009%) from 87.505%
when pulling 463729a on backport/release/3.3/11509
into 00ad84a
on release/3.3
.

8000
@Buristan Buristan requested a review from ligurio May 21, 2025 08:02
@Buristan Buristan merged commit 7ecea5d into release/3.3 May 26, 2025
45 of 63 checks passed
@Buristan Buristan deleted the backport/release/3.3/11509 branch May 26, 2025 12:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build full-ci Enables all tests for a pull request test
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
0