Skip to content

ci: Migrate CI scripts to CMake#142

Merged
hebasto merged 0 commit into
cmake-stagingfrom
240405-cmake-DG
May 20, 2024
Merged

ci: Migrate CI scripts to CMake#142
hebasto merged 0 commit into
cmake-stagingfrom
240405-cmake-DG

Conversation

@hebasto
Copy link
Copy Markdown
Owner

@hebasto hebasto commented Apr 5, 2024

For the same changes in the master branch with CI logs, please see bitcoin#29790.

Still no Android-related changes.

@hebasto
Copy link
Copy Markdown
Owner Author

hebasto commented Apr 5, 2024

@maflcko Want to look into this PR?

@hebasto hebasto added the enhancement New feature or request label Apr 5, 2024
Comment thread ci/test/00_setup_env_win64.sh Outdated
Comment thread ci/test/00_setup_env_native_valgrind.sh Outdated
Comment thread ci/test/00_setup_env_native_previous_releases.sh Outdated
Comment thread ci/test/00_setup_env_native_tidy.sh
Copy link
Copy Markdown

@fanquake fanquake left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had a quick look over.

@hebasto
Copy link
Copy Markdown
Owner Author

hebasto commented Apr 6, 2024

#142 (comment) has been addressed.

See Cirrus CI logs in bitcoin#29790 -- https://cirrus-ci.com/build/4887272447803392.

@hebasto
Copy link
Copy Markdown
Owner Author

hebasto commented Apr 6, 2024

Rebased.

Comment thread ci/test/wrap-wine.sh Outdated
Comment thread ci/test/03_test_script.sh
ccache --zero-stats
PRINT_CCACHE_STATISTICS="ccache --version | head -n 1 && ccache --show-stats"

mkdir -p "${BASE_BUILD_DIR}"
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Would be nice to keep the HOST or CONTAINER_NAME in the build dir, just as a redundancy for some more context?

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Done.

An excerpt from https://cirrus-ci.com/task/5556699505885184:

-- Build files have been written to: /ci_container_base/ci/scratch/build-i686-pc-linux-gnu

@hebasto
Copy link
Copy Markdown
Owner Author

hebasto commented May 17, 2024

Rebased.

The last commit is bitcoin@c06b2bb cherry-picked from the bitcoin#29790. So reviewers can inspect CI logs there.

It follows the following approach:

... we agreed on using APPEND_*FLAGS variables as the last resort only, without advertising them to users and attempting to use native CMake's variables as wide as possible...


@maflcko Do you mind having another look at this PR please?

@maflcko
Copy link
Copy Markdown

maflcko commented May 17, 2024

lgtm, I guess.

Considering that APPEND_ is a hidden option for power users only, and the CI uses it in a few places as power user, that seems fine.

@hebasto hebasto force-pushed the 240405-cmake-DG branch from af260a6 to 2b66814 Compare May 17, 2024 20:10
Comment thread ci/test/00_setup_env_native_previous_releases.sh Outdated
@hebasto
Copy link
Copy Markdown
Owner Author

hebasto commented May 17, 2024

@fanquake requested offline to:

... take the compiler flags out of the CC and CXX defines.

Done. This PR and bitcoin#29790 have been updated simultaneously.

@hebasto hebasto force-pushed the 240405-cmake-DG branch from 2b66814 to 8e2fb0e Compare May 18, 2024 07:41
@hebasto
Copy link
Copy Markdown
Owner Author

hebasto commented May 18, 2024

Addressed @theuni's #142 (comment).

This PR and bitcoin#29790 have been updated simultaneously.


export CONTAINER_NAME=ci_native_asan
export PACKAGES="systemtap-sdt-dev clang-18 llvm-18 libclang-rt-18-dev python3-zmq qtbase5-dev qttools5-dev-tools libevent-dev libboost-dev libdb5.3++-dev libminiupnpc-dev libnatpmp-dev libzmq3-dev libqrencode-dev libsqlite3-dev ${BPFCC_PACKAGE}"
export PACKAGES="systemtap-sdt-dev clang-18 llvm-18 libclang-rt-18-dev python3-zmq qtbase5-dev qttools5-dev qttools5-dev-tools libevent-dev libboost-dev libdb5.3++-dev libminiupnpc-dev libnatpmp-dev libzmq3-dev libqrencode-dev libsqlite3-dev ${BPFCC_PACKAGE}"
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this redundant?

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It follows the build docs:

sudo apt-get install qtbase5-dev qttools5-dev qttools5-dev-tools

Otherwise, CMakes fails to find Qt5LinguistTools.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, please resolve.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess the change could also be submitted upstream standalone, maybe along with similar changes that are unrelated to cmake? But either way seems fine.

export GOAL="install"
# _FORTIFY_SOURCE is not compatible with MSAN.
export BITCOIN_CONFIG="--enable-fuzz --with-sanitizers=fuzzer,memory CPPFLAGS='-DBOOST_MULTI_INDEX_ENABLE_SAFE_MODE -U_FORTIFY_SOURCE'"
export BITCOIN_CONFIG="-DFUZZ=ON -DSANITIZERS=fuzzer,memory -DAPPEND_CPPFLAGS='-DBOOST_MULTI_INDEX_ENABLE_SAFE_MODE -U_FORTIFY_SOURCE'"
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we using the APPEND_*FLAGS here just because setting -DCMAKE_CXX_FLAGS would clobber the CXXFLAGS?

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No.

-DAPPEND_CPPFLAGS='-U_FORTIFY_SOURCE' is required to override -D_FORTIFY_SOURCE=3 from

bitcoin/CMakeLists.txt

Lines 505 to 507 in 0578462

target_compile_options(hardening_interface INTERFACE
$<$<NOT:$<CONFIG:Debug>>:-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3>
)

Copy link
Copy Markdown
Owner Author

@hebasto hebasto May 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW, there was bitcoin#30140 in the main repository.

Copy link
Copy Markdown

@fanquake fanquake May 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess the answer here is that given how hardening has been implemented in the CMake branch, it's impossible to override any of the flags using the proper CMake vars?

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess the answer here is that given how hardening has been implemented in the CMake branch, it's impossible to override any of the flags using the proper CMake vars?

That's correct.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That seems like a problem in it's own right, but I guess can be followed up with separately.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this the exact use case we added the APPEND flags for, though?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll probably just need to document which flags happen to only work with those flags in some way, because at the moment, it's buried in CMake implementation detail.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On second glance, -DBOOST_MULTI_INDEX_ENABLE_SAFE_MODE is going into DCMAKE_CXX_FLAGS in most other places. If nothing else, we should be consistent with where we stick vars to avoid confusion.

Copy link
Copy Markdown
Owner Author

@hebasto hebasto May 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On second glance, -DBOOST_MULTI_INDEX_ENABLE_SAFE_MODE is going into DCMAKE_CXX_FLAGS in most other places. If nothing else, we should be consistent with where we stick vars to avoid confusion.

Done.

Comment thread ci/test/00_setup_env_native_previous_releases.sh
Comment thread cmake/leveldb.cmake
)

set_target_properties(leveldb PROPERTIES
EXPORT_COMPILE_COMMANDS OFF
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to set this for some of our targets?

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By default, when EXPORT_COMPILE_COMMANDS is ON, CMake generates a compile_commands.json, which is used in the "tidy" CI task. On the master branch, compile_commands.json is generated by the bear tool.

We do not want to analyze code from subtrees, so disabling EXPORT_COMPILE_COMMANDS in there.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How would a user work around this if they want to analyze code from subtrees?

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't it supposed to be done in upstream repositories?

@sedited
Copy link
Copy Markdown

sedited commented May 20, 2024

Changes seem sane to me, but given this changes much of the CI I might be missing something.

@hebasto
Copy link
Copy Markdown
Owner Author

hebasto commented May 20, 2024

I'm going to merge this PR shortly.

export BITCOIN_CONFIG="--enable-debug CC='clang -m32' CXX='clang++ -m32' \
CPPFLAGS='-DBOOST_MULTI_INDEX_ENABLE_SAFE_MODE' CXXFLAGS='-Wno-error=documentation'"
export BITCOIN_CONFIG="-DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER='clang;-m32' -DCMAKE_CXX_COMPILER='clang++;-m32' \
-DCMAKE_CXX_FLAGS='-DBOOST_MULTI_INDEX_ENABLE_SAFE_MODE -Wno-error=documentation'"
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these not going into APPEND flags because we don't add -Wdocumentation ourselves? Meaning that the primary use-case for APPEND_CXXFLAGS is specifically when we:

  • Add a flag in our own buildsystem
  • Want that flag turned off by the user at build-time

?

If so, it would be nice to document exactly that.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait, we do add -Wdocumentation though. So why doesn't this have to be in APPEND_CXXFLAGS?

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have to use APPEND_CXXFLAGS for -Wno-documentation.

-Wno-error=documentation works with CMAKE_CXX_FLAGS just fine.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, ok. I would've thought that order matters there. But that makes sense.

@theuni
Copy link
Copy Markdown

theuni commented May 20, 2024

Agree with what @TheCharlatan said. I left a few nits, but this is a pretty huge change and I don't feel that I can review the whole thing and compare it to master with much confidence. I'm ok merging it (after addressing comments) and dealing with any fallout in a follow-up.

@hebasto hebasto force-pushed the 240405-cmake-DG branch from 8e2fb0e to 44713c2 Compare May 20, 2024 17:48
@hebasto
Copy link
Copy Markdown
Owner Author

hebasto commented May 20, 2024

@theuni's #142 (comment) has been addressed.

@hebasto
Copy link
Copy Markdown
Owner Author

hebasto commented May 20, 2024

I'm ok merging it (after addressing comments) and dealing with any fallout in a follow-up.

bitcoin#29790 will continue to run the CI for the cmake-staging branch. So we'll be able to observe any overlooked problem.

@hebasto hebasto merged this pull request into cmake-staging May 20, 2024
@hebasto hebasto mentioned this pull request May 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants