Skip to content

[build][Linux] Create preset to run LLVM's TSan libdispatch tests #24330

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 17, 2019

Conversation

yln
Copy link
Contributor

@yln yln commented Apr 27, 2019

Build a separate compiler-rt instance for running the tests. It is built
and tested against an installed toolchain instead of the llvm-build-dir.

Install everything we need to run tests (CMake modules, FileCheck, etc.)
into the toolchain directory.

Add synthetic target 'all' for llvm-install-components. Also we must set
LLVM_INSTALL_UTILS=ON, so the utilities required by tests (e.g.,
FileCheck) are included in the install target.

rdar://49396529

@shahmishal
Copy link
Member

When you ready to start test use please test with preset

For more info:
https://github.com/apple/swift/blob/master/docs/ContinuousIntegration.md#specific-preset-testing

@beccadax beccadax removed their request for review April 29, 2019 18:27
@beccadax
Copy link
Contributor

(I've taken myself off the review list because this is outside my area of expertise, but I'll keep following this PR because I want to see how this works.)

@yln
Copy link
Contributor Author

yln commented Apr 30, 2019

preset=buildbot_incremental_linux,tsan-libdispatch-test
@swift-ci Please test with preset Linux Platform

Copy link
Member

@compnerd compnerd left a comment

Choose a reason for hiding this comment

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

Seems good to me.

@yln
Copy link
Contributor Author

yln commented May 1, 2019

When invoking the cmake configure step from my python script, I configure the clang to use like so:
-DCMAKE_C_COMPILER=/home/buildnode/jenkins/workspace/swift-PR-Linux-preset/branch-master/buildbot_incremental_tsan_libdispatch_test/tsanlibdispatch-linux-x86_64/../llvm-linux-x86_64/bin/clang

The path is constructed via:

llvm_build_dir = os.path.join(self.build_dir, '../llvm-' + host_target)
cc_path = os.path.join(llvm_build_dir, 'bin/clang')

When I build my preset locally, this folder contains the just-built clang.

@shahmishal @gottesmm Any ideas why/what things could be different when compared to my local Ubuntu VM?

Relevant build output:

cmake -GNinja \
-B/home/buildnode/jenkins/workspace/swift-PR-Linux-preset/branch-master/buildbot_incremental_tsan_libdispatch_test/tsanlibdispatch-linux-x86_64 \
-DCMAKE_PREFIX_PATH=/home/buildnode/jenkins/workspace/swift-PR-Linux-preset/branch-master/buildbot_incremental_tsan_libdispatch_test/tsanlibdispatch-linux-x86_64/../llvm-linux-x86_64 \
-DCMAKE_C_COMPILER=/home/buildnode/jenkins/workspace/swift-PR-Linux-preset/branch-master/buildbot_incremental_tsan_libdispatch_test/tsanlibdispatch-linux-x86_64/../llvm-linux-x86_64/bin/clang \
-DCMAKE_CXX_COMPILER=/home/buildnode/jenkins/workspace/swift-PR-Linux-preset/branch-master/buildbot_incremental_tsan_libdispatch_test/tsanlibdispatch-linux-x86_64/../llvm-linux-x86_64/bin/clang++ \
-DCMAKE_BUILD_TYPE=Release \
-DLLVM_ENABLE_ASSERTIONS=ON \
-DCOMPILER_RT_INCLUDE_TESTS=ON \
-DCOMPILER_RT_INTERCEPT_LIBDISPATCH=ON \
-DCOMPILER_RT_LIBDISPATCH_INSTALL_PATH=/home/buildnode/jenkins/workspace/swift-PR-Linux-preset/branch-master/buildbot_incremental_tsan_libdispatch_test/toolchain-linux-x86_64/usr \
/home/buildnode/jenkins/workspace/swift-PR-Linux-preset/branch-master/tsan-libdispatch-test/../compiler-rt

19:21:12 CMake Error at CMakeLists.txt:10 (project):
19:21:12   The CMAKE_C_COMPILER:
19:21:12 
19:21:12     /home/buildnode/jenkins/workspace/swift-PR-Linux-preset/branch-master/buildbot_incremental_tsan_libdispatch_test/tsanlibdispatch-linux-x86_64/../llvm-linux-x86_64/bin/clang
19:21:12 
19:21:12   is not a full path to an existing compiler tool.

Copy link
Contributor

@gottesmm gottesmm left a comment

Choose a reason for hiding this comment

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

Much better! = ).

Only comment is shouldn't you be using the toolchain as your CMAKE_PREFIX_PATH? You shouldn't have access to the original llvm build directory.

@gottesmm
Copy link
Contributor

gottesmm commented May 1, 2019

@yln #24330 (comment)

Maybe try making the path absolute? os.path.abspath(...)? I vaguely remember hitting that before.

@yln
Copy link
Contributor Author

yln commented May 2, 2019

preset=buildbot_incremental_linux,tsan-libdispatch-test
@swift-ci Please test with preset Linux Platform

@yln
Copy link
Contributor Author

yln commented May 2, 2019

Using absolute paths got me one step further. Thanks for the tip! Next issue:

cmake -GNinja -B/home/buildnode/jenkins/workspace/swift-PR-Linux-preset/branch-master/buildbot_incremental_tsan_libdispatch_test/tsanlibdispatch-linux-x86_64 ...

However:
Build files have been written to: /home/buildnode/jenkins/workspace/swift-PR-Linux-preset/branch-master

Leading to:
cmake --build /home/buildnode/jenkins/workspace/swift-PR-Linux-preset/branch-master/buildbot_incremental_tsan_libdispatch_test/tsanlibdispatch-linux-x86_64 --target tsan
Error: /home/buildnode/jenkins/workspace/swift-PR-Linux-preset/branch-master/buildbot_incremental_tsan_libdispatch_test/tsanlibdispatch-linux-x86_64 is not a directory

Looks like cmake -B/path/to/build/dir has no effect. Is that a recent cmake feature? Which version are we using on our bots? @shahmishal @gottesmm Can you test which version of cmake we use and if it understands the -B option? Like so:

➤ cmake --version
cmake version 3.14.3
➤ cmake --help | grep -e "-B"
  cmake [options] -S <path-to-source> -B <path-to-build>
  -B <path-to-build>           = Explicitly specify a build directory.

@gottesmm
Copy link
Contributor

gottesmm commented May 2, 2019

@yln I would perform the invocation of cmake in that specific directory. We assume I think 3.4.3. We should update at some point soon once compnerd's changes in cmake itself land to enable swift as a language.

@yln
Copy link
Contributor Author

yln commented May 2, 2019

preset=buildbot_incremental_linux,tsan-libdispatch-test
@swift-ci Please test with preset Linux Platform

@yln yln force-pushed the preset-for-llvm-tsan-libdispatch-tests branch from 0f82d0c to 2d77de9 Compare May 3, 2019 00:05
@yln
Copy link
Contributor Author

yln commented May 3, 2019

preset=buildbot_incremental_linux,tsan-libdispatch-test
@swift-ci Please test with preset Linux Platform

@yln yln force-pushed the preset-for-llvm-tsan-libdispatch-tests branch from 2d77de9 to d3170c2 Compare May 10, 2019 18:14
@yln
Copy link
Contributor Author

yln commented May 10, 2019

@swift-ci Please clean test

@yln
Copy link
Contributor Author

yln commented May 10, 2019

preset=buildbot_incremental_linux,tsan-libdispatch-test
@swift-ci Please test with preset Linux Platform

@yln
Copy link
Contributor Author

yln commented May 14, 2019

I think I have finally found the problem for undefined references during the configure step for 'libcxx_tsan_x86_64'.

The 'stable' branch is used for CI, but the following (required) change hasn't made it there yet:
https://reviews.llvm.org/D58013

I could cherry-pick it into stable, however, since the purpose of the libdispatch tests is guarding against upstream changes, they should actually build run against "The Upstream Branches". master-next/upstream-with-swift for Swift and LLVM respectively.

@shahmishal @gottesmm
How can I configure this?

@yln
Copy link
Contributor Author

yln commented May 15, 2019

apple/swift-compiler-rt#39
preset=buildbot_incremental_linux,tsan-libdispatch-test
@swift-ci Please test with preset Linux Platform

@yln
Copy link
Contributor Author

yln commented May 15, 2019

@swift-ci Please test

yln added a commit to apple/swift-compiler-rt that referenced this pull request May 15, 2019
Required change to make "Swift CI preset for LLVM libdispatch tests" [1]
work.

This goes the opposite direction of [2], ensuring that the link step
succeeds for the prodcued dynamic library (*.so). In the future versions
of compiler-rt this will not be necessary since we will create a static
archive instead.

[1] swiftlang/swift#24330
[2] https://reviews.llvm.org/D58013
@yln
Copy link
Contributor Author

yln commented May 15, 2019

apple/swift-compiler-rt#40
preset=buildbot_incremental_linux,tsan-libdispatch-test
@swift-ci Please test with preset Linux Platform

yln added a commit to apple/swift-compiler-rt that referenced this pull request May 15, 2019
Required change to make "Swift CI preset for LLVM libdispatch tests" [1]
work.

This goes the opposite direction of [2], ensuring that the link step
succeeds for the prodcued dynamic library (*.so). In the future versions
of compiler-rt this will not be necessary since we will create a static
archive instead.

[1] swiftlang/swift#24330
[2] https://reviews.llvm.org/D58013
@yln
Copy link
Contributor Author

yln commented May 15, 2019

apple/swift-compiler-rt#40
preset=buildbot_incremental_linux,tsan-libdispatch-test
@swift-ci Please test with preset Linux Platform

yln added a commit to apple/swift-compiler-rt that referenced this pull request May 15, 2019
Required change to make "Swift CI preset for LLVM libdispatch tests" [1]
work.

This goes the opposite direction of [2, 3], ensuring that the link step
succeeds for the prodcued dynamic library (*.so). In the future versions
of compiler-rt this will not be necessary since we will create a static
archive instead.

[1] swiftlang/swift#24330
[2] https://reviews.llvm.org/D58013
[3] https://reviews.llvm.org/rG0a9cb239a6c91a709a98c96bbf60b6c006d5a07b
@yln
Copy link
Contributor Author

yln commented May 15, 2019

apple/swift-compiler-rt#40
preset=buildbot_incremental_linux,tsan-libdispatch-test
@swift-ci Please test with preset Linux Platform

yln added a commit to apple/swift-compiler-rt that referenced this pull request May 15, 2019
Required change to make "Swift CI preset for LLVM libdispatch tests" [1]
work.

This goes the opposite direction of [2, 3], ensuring that the link step
succeeds for the produced dynamic library (*.so). In the future versions
of compiler-rt this will not be necessary since we will create a static
archive instead.

[1] swiftlang/swift#24330
[2] https://reviews.llvm.org/D58013
[3] https://reviews.llvm.org/rG0a9cb239a6c91a709a98c96bbf60b6c006d5a07b

rdar://problem/50828689
@yln
Copy link
Contributor Author

yln commented May 15, 2019

apple/swift-compiler-rt#40
preset=buildbot_incremental_linux,tsan-libdispatch-test
@swift-ci Please test with preset Linux Platform

yln added a commit to apple/swift-compiler-rt that referenced this pull request May 15, 2019
Required change to make "Swift CI preset for LLVM libdispatch tests" [1]
work.

This goes the opposite direction of [2, 3], ensuring that the link step
succeeds for the produced dynamic library (*.so). In the future versions
of compiler-rt this will not be necessary since we will create a static
archive instead.

[1] swiftlang/swift#24330
[2] https://reviews.llvm.org/D58013
[3] https://reviews.llvm.org/rG0a9cb239a6c91a709a98c96bbf60b6c006d5a07b

rdar://problem/50828689
@yln
Copy link
Contributor Author

yln commented May 15, 2019

apple/swift-compiler-rt#40
preset=buildbot_incremental_linux,tsan-libdispatch-test
@swift-ci Please test with preset Linux Platform

@yln
Copy link
Contributor Author

yln commented May 16, 2019

It seems to work now. I just clicked merge on the PR for the required changes in swift-compiler-rt [swift-5.1-branch]. I will wait until those have propagated to [stable], and run the preset one more time to verify it works.

@gottesmm @jrose-apple
Does one of you want to sign off on the changes in this PR? Thanks!

@gottesmm
Copy link
Contributor

@swift-ci python lint

@gottesmm
Copy link
Contributor

Lets make sure this passes the python linter. If we pass, I am good with this.

@gottesmm
Copy link
Contributor

@yln can you fix the python lint issues?

Build a separate compiler-rt instance for running the tests. It is built
and tested against an installed toolchain instead of the llvm-build-dir.

Install everything we need to run tests (CMake modules, FileCheck, etc.)
into the toolchain directory.

Add synthetic target 'all' for llvm-install-components. Also we must set
LLVM_INSTALL_UTILS=ON, so the utilities required by tests (e.g.,
FileCheck) are included in the install target.
@yln yln force-pushed the preset-for-llvm-tsan-libdispatch-tests branch from d3170c2 to 9631700 Compare May 16, 2019 20:18
@yln
Copy link
Contributor Author

yln commented May 16, 2019

@swift-ci python lint

@yln
Copy link
Contributor Author

yln commented May 16, 2019

@swift-ci Please test

Copy link
Contributor

@gottesmm gottesmm left a comment

Choose a reason for hiding this comment

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

LGTM

@yln
Copy link
Contributor Author

yln commented May 17, 2019

preset=buildbot_incremental_linux,tsan-libdispatch-test
@swift-ci Please test with preset Linux Platform

@yln yln merged commit 4dcb49d into master May 17, 2019
@yln yln deleted the preset-for-llvm-tsan-libdispatch-tests branch May 17, 2019 17:32
@gottesmm
Copy link
Contributor

@yln congrats!

yln added a commit that referenced this pull request Aug 12, 2019
PR #25085 [1] enabled building and installing the static variant of the
libdispatch library in build-script-impl. This broke the
`tsan-libdispatch-test` preset [2].

Let's make sure we pass along the options specified in
`libdispatch-cmake-options` when building the static variant.

[1] #25085
[2] #24330

rdar://problem/49177823
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants