Skip to content
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

ci: Migrate CI scripts to CMake #142

Merged
merged 2 commits into from
May 20, 2024
Merged

ci: Migrate CI scripts to CMake #142

merged 2 commits into from
May 20, 2024

Conversation

hebasto
Copy link
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
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
Copy link

@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
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
Owner Author

hebasto commented Apr 6, 2024

Rebased.

ci/test/wrap-wine.sh Outdated Show resolved Hide resolved
fi

ccache --zero-stats
PRINT_CCACHE_STATISTICS="ccache --version | head -n 1 && ccache --show-stats"

mkdir -p "${BASE_BUILD_DIR}"
Copy link

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
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
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

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
Copy link
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
Copy link
Owner Author

hebasto commented May 18, 2024

Addressed @theuni's #142 (comment).

This PR and bitcoin#29790 have been updated simultaneously.

@@ -17,10 +17,11 @@ else
fi

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}"

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
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.

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

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.

@@ -18,7 +18,7 @@ export PACKAGES="ninja-build"
export DEP_OPTS="DEBUG=1 NO_BDB=1 NO_QT=1 CC=clang CXX=clang++ CFLAGS='${MSAN_FLAGS}' CXXFLAGS='${MSAN_AND_LIBCXX_FLAGS}'"
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'"

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
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
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

@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
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.

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

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?

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

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
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.

@@ -99,3 +99,7 @@ target_link_libraries(leveldb PRIVATE
nowarn_leveldb_interface
crc32c
)

set_target_properties(leveldb PROPERTIES
EXPORT_COMPILE_COMMANDS OFF

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
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.

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
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?

@TheCharlatan
Copy link

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

@hebasto
Copy link
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

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

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
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

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

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
Copy link
Owner Author

hebasto commented May 20, 2024

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

@hebasto
Copy link
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 commit 1d76056 into cmake-staging May 20, 2024
34 checks passed
@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