Skip to content

Switch to LLVM/clang 16 (16.0.3)#49678

Merged
rschu1ze merged 33 commits intoClickHouse:masterfrom
azat:build/llvm-16
May 12, 2023
Merged

Switch to LLVM/clang 16 (16.0.3)#49678
rschu1ze merged 33 commits intoClickHouse:masterfrom
azat:build/llvm-16

Conversation

@azat
Copy link
Copy Markdown
Member

@azat azat commented May 8, 2023

Changelog category (leave one):

  • Build/Testing/Packaging Improvement

Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):

Switch to LLVM/clang 16

Based on: #47709 (cc @alexey-milovidov )
Reverts: #43195
Fixes: #41500 (many thanks to @itrofimow for the patch!)
Closes: #46383 (cc @Felixoid )
Partially reverts: #42457/#40873 (workaround for emitting .debug_aranges), since patch had been merged to upstream) and included into LLVM 16
Blocks: #47783

Required fixes:

alexey-milovidov and others added 6 commits March 18, 2023 23:45
Since initial issue got resolved [1].

  [1]: google/sanitizers#1540

Signed-off-by: Azat Khuzhin <[email protected]>
…d-for-llvm-bug"

With clang 16 this workaround should not be required anymore.

This reverts commit 992729f, reversing
changes made to d885b3c.
@robot-ch-test-poll robot-ch-test-poll added the pr-build Pull request with build/testing/packaging improvement label May 8, 2023
@robot-ch-test-poll
Copy link
Copy Markdown
Contributor

robot-ch-test-poll commented May 8, 2023

This is an automated comment for commit e5c4eb3 with description of existing statuses. It's updated for the latest CI running
The full report is available here
The overall status of the commit is 🔴 failure

Check nameDescriptionStatus
AST fuzzerRuns randomly generated queries to catch program errors. The build type is optionally given in parenthesis. If it fails, ask a maintainer for help🟢 success
CI runningA meta-check that indicates the running CI. Normally, it's in success or pending state. The failed status indicates some problems with the PR🟢 success
ClickHouse build checkBuilds ClickHouse in various configurations for use in further steps. You have to fix the builds that fail. Build logs often has enough information to fix the error, but you might have to reproduce the failure locally. The cmake options can be found in the build log, grepping for cmake. Use these options and follow the general build process🟢 success
Compatibility checkChecks that clickhouse binary runs on distributions with old libc versions. If it fails, ask a maintainer for help🟢 success
Docker image for serversThe check to build and optionally push the mentioned image to docker hub🟢 success
Docs CheckBuilds and tests the documentation🟢 success
Fast testNormally this is the first check that is ran for a PR. It builds ClickHouse and runs most of stateless functional tests, omitting some. If it fails, further checks are not started until it is fixed. Look at the report to see which tests fail, then reproduce the failure locally as described here🟢 success
Flaky testsChecks if new added or modified tests are flaky by running them repeatedly, in parallel, with more randomization. Functional tests are run 100 times with address sanitizer, and additional randomization of thread scheduling. Integrational tests are run up to 10 times. If at least once a new test has failed, or was too long, this check will be red. We don't allow flaky tests, read the doc🟢 success
Install packagesChecks that the built packages are installable in a clear environment🟢 success
Integration testsThe integration tests report. In parenthesis the package type is given, and in square brackets are the optional part/total tests🔴 failure
Mergeable CheckChecks if all other necessary checks are successful🟢 success
Performance ComparisonMeasure changes in query performance. The performance test report is described in detail here. In square brackets are the optional part/total tests🟢 success
Push to DockerhubThe check for building and pushing the CI related docker images to docker hub🟢 success
SQLancerFuzzing tests that detect logical bugs with SQLancer tool🟢 success
SqllogicRun clickhouse on the sqllogic test set against sqlite and checks that all statements are passed🟢 success
Stateful testsRuns stateful functional tests for ClickHouse binaries built in various configurations -- release, debug, with sanitizers, etc🟢 success
Stateless testsRuns stateless functional tests for ClickHouse binaries built in various configurations -- release, debug, with sanitizers, etc🔴 failure
Stress testRuns stateless functional tests concurrently from several clients to detect concurrency-related errors🟢 success
Style CheckRuns a set of checks to keep the code style clean. If some of tests failed, see the related log from the report🟢 success
Unit testsRuns the unit tests for different release types🟢 success
Upgrade checkRuns stress tests on server version from last release and then tries to upgrade it to the version from the PR. It checks if the new server can successfully startup without any errors, crashes or sanitizer asserts🟢 success

@azat azat mentioned this pull request May 8, 2023
@azat azat changed the title Switch to LLVM/clang 16 Switch to LLVM/clang 16 (16.0.3) May 8, 2023
azat added 3 commits May 9, 2023 10:25
Otherwise you will get the following error:

    CMake Error at /usr/lib/llvm-16/lib/cmake/clang/ClangTargets.cmake:792 (message):
      The imported target "clangBasic" references the file

         "/usr/lib/llvm-16/lib/libclangBasic.a"

      but this file does not exist.  Possible reasons include:

      * The file was deleted, renamed, or moved to another location.

      * An install or uninstall procedure did not complete successfully.

      * The installation package was faulty and contained

         "/usr/lib/llvm-16/lib/cmake/clang/ClangTargets.cmake"

      but not all the files it references.

    Call Stack (most recent call first):
      /usr/lib/llvm-16/lib/cmake/clang/ClangConfig.cmake:20 (include)
      generator/CMakeLists.txt:7 (Find_Package)

Signed-off-by: Azat Khuzhin <[email protected]>
By default woboq uses $version.$minor.$patch, while clang simply uses
$version:

    CMake Error at generator/CMakeLists.txt:77 (message):
      Could not find any clang builtins headers in
      /usr/lib/llvm-16/lib/clang/16.0.4/include

    # ls -d /usr/lib/llvm-16/lib/clang/16/include
    /usr/lib/llvm-16/lib/clang/16/include

Signed-off-by: Azat Khuzhin <[email protected]>
@azat azat force-pushed the build/llvm-16 branch from 23569c9 to bf17c81 Compare May 9, 2023 08:33
@azat azat changed the title Switch to LLVM/clang 16 (16.0.3) Switch to LLVM/clang 16 (16.0.4) May 9, 2023
@azat azat changed the title Switch to LLVM/clang 16 (16.0.4) Switch to LLVM/clang 16 (16.0.3) May 9, 2023
azat added 2 commits May 9, 2023 12:20
From the release notes [1]:

    To match GCC, __ppc64__ is no longer defined on PowerPC64 targets. Use __powerpc64__ instead.

  [1]: https://releases.llvm.org/16.0.0/tools/clang/docs/ReleaseNotes.html

Signed-off-by: Azat Khuzhin <[email protected]>
"The -fexperimental-new-pass-manager and -fno-legacy-pass-manager flags
have been removed. These flags have been silently ignored since Clang
15."

Signed-off-by: Azat Khuzhin <[email protected]>
@rschu1ze rschu1ze self-assigned this May 9, 2023
rschu1ze

This comment was marked as outdated.

rschu1ze

This comment was marked as outdated.

azat added 3 commits May 9, 2023 20:28
@azat

This comment was marked as outdated.

azat added 5 commits May 9, 2023 20:40
Conflicts:
	docker/test/codebrowser/Dockerfile
It is too noisy during upgrade:

$ grep error: build_log.log | awk '{print $NF}' | sort | uniq -c
      1 [bugprone-standalone-empty,-warnings-as-errors]
      1 [misc-misplaced-const,-warnings-as-errors]
   2147 [misc-use-anonymous-namespace,-warnings-as-errors]
      6 [modernize-loop-convert,-warnings-as-errors]
      9 [readability-redundant-string-cstr,-warnings-as-errors]

Signed-off-by: Azat Khuzhin <[email protected]>
@robot-ch-test-poll2 robot-ch-test-poll2 added the submodule changed At least one submodule changed in this PR. label May 10, 2023
@azat azat marked this pull request as draft May 10, 2023 15:47
@azat azat force-pushed the build/llvm-16 branch from 9666bb1 to dde5357 Compare May 10, 2023 17:35
@azat

This comment was marked as outdated.

@rschu1ze

This comment was marked as outdated.

@azat

This comment was marked as outdated.

@rschu1ze

This comment was marked as outdated.

azat added 2 commits May 11, 2023 16:30
NgramDistanceImpl::unrollLowering() relies on the fact that PODArray has
padding and it is OK to access more items.

Here is an MSan report:

    ==656==WARNING: MemorySanitizer: use-of-uninitialized-value
        0 0x557fd825485f in DB::NgramDistanceImpl<4ul, char8_t, false, true, false>::vectorConstant(DB::PODArray<char8_t, 4096ul, Allocator<false, false>, 63ul, 64ul> const&, DB::PODArray<unsigned long, 4096ul, Allocator<false, false>, 63ul, 64ul> const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, DB::PODArray<float, 4096ul, Allocator<false, false>, 63ul, 64ul>&) (/usr/bin/clickhouse+0x124d885f) (BuildId: 76773125d8739591c75d4f4d263a2ffe7ca96855)
        1 0x557fd824eb83 in DB::FunctionsStringSimilarity<DB::NgramDistanceImpl<4ul, char8_t, false, true, false>, DB::NameNgramSearchCaseInsensitive>::executeImpl(std::__1::vector<DB::ColumnWithTypeAndName, std::__1::allocator<DB::ColumnWithTypeAndName>> const&, std::__1::shared_ptr<DB::IDataType const> const&, unsigned long) const (/usr/bin/clickhouse+0x124d2b83) (BuildId: 76773125d8739591c75d4f4d263a2ffe7ca96855)
        2 0x557fd50023b7 in DB::FunctionToExecutableFunctionAdaptor::executeImpl() const (/usr/bin/clickhouse+0xf2863b7) (BuildId: 76773125d8739591c75d4f4d263a2ffe7ca96855)

      Uninitialized value was stored to memory at
        0 0x557fd4f8da5a in __msan_memcpy (/usr/bin/clickhouse+0xf211a5a) (BuildId: 76773125d8739591c75d4f4d263a2ffe7ca96855)
        1 0x557fd8253803 in DB::NgramDistanceImpl<4ul, char8_t, false, true, false>::vectorConstant(DB::PODArray<char8_t, 4096ul, Allocator<false, false>, 63ul, 64ul> const&, DB::PODArray<unsigned long, 4096ul, Allocator<false, false>, 63ul, 64ul> const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, DB::PODArray<float, 4096ul, Allocator<false, false>, 63ul, 64ul>&) (/usr/bin/clickhouse+0x124d7803) (BuildId: 76773125d8739591c75d4f4d263a2ffe7ca96855)
        2 0x557fd824eb83 in DB::FunctionsStringSimilarity<DB::NgramDistanceImpl<4ul, char8_t, false, true, false>, DB::NameNgramSearchCaseInsensitive>::executeImpl(std::__1::vector<DB::ColumnWithTypeAndName, std::__1::allocator<DB::ColumnWithTypeAndName>> const&, std::__1::shared_ptr<DB::IDataType const> const&, unsigned long) const (/usr/bin/clickhouse+0x124d2b83) (BuildId: 76773125d8739591c75d4f4d263a2ffe7ca96855)
        3 0x557fd50023b7 in DB::FunctionToExecutableFunctionAdaptor::executeImpl() const (/usr/bin/clickhouse+0xf2863b7) (BuildId: 76773125d8739591c75d4f4d263a2ffe7ca96855)

      Uninitialized value was stored to memory at
        0 0x557fd4f8da5a in __msan_memcpy (/usr/bin/clickhouse+0xf211a5a) (BuildId: 76773125d8739591c75d4f4d263a2ffe7ca96855)
        1 0x5580061699f5 in detail::memcpySmallAllowReadWriteOverflow15Impl(char*, char const*, long) build_docker/./src/Common/memcpySmall.h:42:13
        2 0x5580061699f5 in memcpySmallAllowReadWriteOverflow15(void*, void const*, unsigned long) build_docker/./src/Common/memcpySmall.h:57:5
        3 0x5580061699f5 in DB::ColumnString::replicate(DB::PODArray<unsigned long, 4096ul, Allocator<false, false>, 63ul, 64ul> const&) const build_docker/./src/Columns/ColumnString.cpp:462:13
        4 0x558005d3fae4 in DB::ColumnConst::convertToFullColumn() const build_docker/./src/Columns/ColumnConst.cpp:48:18

Signed-off-by: Azat Khuzhin <[email protected]>
* u/master:
  enable used flags's reinit only when the hash talbe rehash
  Fix build of libfiu on clang-16
  fix flaky test 02504_regexp_dictionary_ua_parser
  fix convertation
  Fix test that expected CH to apply a wrong optimization
  ActionsDAG: remove wrong optimization
@azat
Copy link
Copy Markdown
Member Author

azat commented May 12, 2023

Test failures looks unrelated:

Integration tests (release) [2/4] — fail: 2, passed: 545, flaky: 0

E           Code: 117. DB::Exception: Received from 172.16.1.7:9000. DB::Exception: Data directory for table already containing data parts - probably it was unclean DROP table or manual intervention. You must either clear directory by hand or use ATTACH TABLE instead of CREATE TABLE if you need to use that parts.. Stack trace:

Stateless tests (release, analyzer) — fail: 1, passed: 5246, skipped: 17

It shows bunch of NOT_FAILED, but apparently it simply does not count it as an error (since in upstream it has the same - https://s3.amazonaws.com/clickhouse-test-reports/0/fc993f4c07ae3d14e5141d810a22322d0f444949/stateless_tests__release__analyzer_.html and check is green)

But, there is one failure of 00992_system_parts_race_condition_zookeeper_long while this test is flaky - play

url = https://github.com/VectorCamp/vectorscan
# FIXME: update once upstream fixes will be merged:
# - https://github.com/VectorCamp/vectorscan/pull/148
# - https://github.com/VectorCamp/vectorscan/pull/149
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.

Just an interesting observation: "cmake/sanitize.cmake" sets -fsanitize-blacklist=${CMAKE_SOURCE_DIR}/tests/msan_suppressions.txt for msan. This file contains line fun:roseRunProgram that suppresses msan warnings in top-level (publicly callable) function "roseRunProgram ()" in rose/program_runtime.c. In other words, it achieves theoretically the same thing as VectorCamp/vectorscan#149.

But the GCC devs agree with your approach, https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61978#c1 😄.

Anyways, once this PR is in, I can try to clean out msan_suppressions.txt, it seems redundant and un-obvious to have an alternative way to suppress msan warnings.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Just an interesting observation: "cmake/sanitize.cmake" sets -fsanitize-blacklist=${CMAKE_SOURCE_DIR}/tests/msan_suppressions.txt for msan. This file contains line fun:roseRunProgram that suppresses msan warnings in top-level (publicly callable) function "roseRunProgram ()" in rose/program_runtime.c. In other words, it achieves theoretically the same thing as VectorCamp/vectorscan#149.

Hm, I totally forgot to look at MSan suppressions, thanks! I want check it again now, need to get full stack trace to compare why it does not work in debug build, and works in release.

There is actually one more fix for this - ClickHouse/boost#12, I tried to fix this in the small_vector, but since clang-16 it was not easy (I wrote about this in the vectorscan PR)

Anyways, once this PR is in, I can try to clean out msan_suppressions.txt, it seems redundant and un-obvious to have an alternative way to suppress msan warnings

Will take a look, but first, I need to check why it didn't work (maybe there is something more...)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Looks like you already did this - #49829, thanks!

But the question why suppressions does not work, it still open.

if constexpr (case_insensitive)
{
#if defined(MEMORY_SANITIZER)
/// Due to PODArray padding accessing more elements should be OK
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.

Speaking of tests/msan_suppressions.txt, it contains another suppression

# We apply std::tolower to uninitialized padding, but don't use the result, so        
# it is OK. Reproduce with "select ngramDistanceCaseInsensitive(materialize(''), '')" 
fun:tolower                                                                           

Looks like msan16 no longer picks these suppressions up.

@rschu1ze rschu1ze marked this pull request as ready for review May 12, 2023 11:47
@rschu1ze rschu1ze merged commit b9c185a into ClickHouse:master May 12, 2023
rschu1ze added a commit to rschu1ze/ClickHouse that referenced this pull request May 12, 2023
@azat azat deleted the build/llvm-16 branch May 12, 2023 12:30
# FIXME: update once upstream fixes will be merged:
# - https://github.com/VectorCamp/vectorscan/pull/148
# - https://github.com/VectorCamp/vectorscan/pull/149
url = https://github.com/azat-ch/vectorscan
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.

Sorry for being a bit late for the party, but there's no need to change the url. It is available all over the forks

VectorCamp/vectorscan@aaca65a

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.

I am on it ...

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@Felixoid I don't mind leaving my fork, but a) I guess it is some kind of unspoken rule to use ClickHouse namespace for forks and b) it makes sense most of the time, since if fork will be removed, then you will not be able to download it (though personally I - not going to remove this forks, but still).

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.

I also don't mind too much. I would say the unspoken rule is "reference upstream if possible (= there are no custom patches), otherwise reference a fork in the ClickHouse organization".

Anyways, after making some silly mess, I now

Your two pushes against vectorscan upstream remain as is (fingers crossed they are merged).

azat added a commit to azat/ClickHouse that referenced this pull request May 18, 2023
woboq codebrowser uses clang tooling, which adds clang system includes
(in Linux::AddClangSystemIncludeArgs()), because none of (-nostdinc,
-nobuiltininc) is set.

And later it will complain with -Wpoison-system-directories for added by
itself includes in InitHeaderSearch::AddUnmappedPath(), because they are
starts from one of the following:
- /usr/include
- /usr/local/include

The interesting thing here is that it got broken only after upgrading to
llvm 16 (in ClickHouse#49678), and the reason for this is that clang 15 build has
system includes that does not trigger the warning -
"/usr/lib/clang/15.0.7/include", while clang 16 has
"/usr/include/clang/16.0.4/include"

So let's simply disable this warning, but only for woboq.

Signed-off-by: Azat Khuzhin <[email protected]>
@rschu1ze rschu1ze mentioned this pull request Aug 25, 2023
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 submodule changed At least one submodule changed in this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

stack-use-after-scope in random places

7 participants