Skip to content

Some build improvement#33695

Merged
alexey-milovidov merged 1 commit intoClickHouse:masterfrom
amosbird:buildimprove
Jan 19, 2022
Merged

Some build improvement#33695
alexey-milovidov merged 1 commit intoClickHouse:masterfrom
amosbird:buildimprove

Conversation

@amosbird
Copy link
Copy Markdown
Collaborator

@amosbird amosbird commented Jan 17, 2022

Changelog category (leave one):

  • Build/Testing/Packaging Improvement

Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
Some improvement over current build system.

Detailed description / Documentation draft:

  1. Optimize header files.
  2. Make sure that thirdparty includes are SYSTEM.
  3. Avoid polluting CMAKE_*_FLAGS as it will interfere with try_compile related stuff, like check_type_size, check_functions...
  4. Some cosmetic refinement.

@robot-clickhouse robot-clickhouse added the pr-build Pull request with build/testing/packaging improvement label Jan 17, 2022
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

It takes me more than one hour to find the SHELL: functionality. The cmake language is almost esoteric as the Brainfuck language...

@alexey-milovidov
Copy link
Copy Markdown
Member

FYI I also want to remove all CMake checks like try_compile from the libraries, because they make cross-compiling more difficult.

set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${INCLUDE_DEBUG_HELPERS}")
# CMake generator expression will do insane quoting when it encounters special character like quotes, spaces, etc.
# Prefixing "SHELL:" will force it to use the original text.
set (INCLUDE_DEBUG_HELPERS "SHELL:-I\"${ClickHouse_SOURCE_DIR}/base\" -I\"${MAGIC_ENUM_INCLUDE_DIR}\" -include \"${ClickHouse_SOURCE_DIR}/src/Core/iostream_debug_helpers.h\"")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It's interesting how many people are using debug helpers. I don't use them.
Most likely some people do... but it is quite obscure and difficult to find (although the implementation is very smart).

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

It's quite handy. I see the debug helpers get turned on by default when build type is DEBUG, which indicates some people do)

uint64_t doubleToUInt64(double d)
{
if (d >= std::numeric_limits<uint64_t>::max())
if (d >= double(std::numeric_limits<uint64_t>::max()))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What motivated to make this change?
If we can enable some new warning or clang-tidy check, let's do that.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

The clang-tidy rule is cppcoreguidelines-narrowing-conversions. It might be too strict for us now.

Copy link
Copy Markdown
Member

@alexey-milovidov alexey-milovidov left a comment

Choose a reason for hiding this comment

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

What tools did you use to find missing or unused headers?

@alexey-milovidov alexey-milovidov self-assigned this Jan 19, 2022
@alexey-milovidov alexey-milovidov merged commit d222cb9 into ClickHouse:master Jan 19, 2022
@alexey-milovidov
Copy link
Copy Markdown
Member

Also relevant: #12447 and #9226

@bharatnc
Copy link
Copy Markdown
Contributor

Looks like this broke the build on head: https://github.com/ClickHouse/ClickHouse/runs/4861238785?check_suite_focus=true#step:6:10321

Seeing similar issues while trying to build on dev too.

@amosbird
Copy link
Copy Markdown
Collaborator Author

FYI I also want to remove all CMake checks like try_compile from the libraries, because they make cross-compiling more difficult.

It would be perfect to remove those stuff, as the try_compile check mechanism is impossible to work properly in pseudo cross compilation. https://discourse.cmake.org/t/try-compile-generated-temporary-targets-dont-honor-link-libraries/4767

@amosbird
Copy link
Copy Markdown
Collaborator Author

What tools did you use to find missing or unused headers?

It's discovered by manually optimize some header files to .cc and use forward decl, which will expose issues of missing headers, such as #33765

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-build Pull request with build/testing/packaging improvement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants