Error in libdispatch during incremental build

Trying to build swift-4.1-branch on Ubuntu 16.04 on Linux on Z. I created a build-preset based on one buildbot used. I could build everything first time around but the 2nd time the build hit this error in libdispatch:

[13/23] Performing build step for 'libdispatch'
ninja: no work to do.
[14/23] Performing install step for 'libdispatch'
FAILED: tools/SourceKit/libdispatch-prefix/src/libdispatch-stamp/libdispatch-install 
cd /localbox/vivkong/swift41/build/buildbot_incremental/libdispatch-linux-s390x && /usr/bin/cmake --build . --target install && /usr/bin/cmake -E touch /localbox/vivkong/swift41/build/buildbot_incremental/swift-linux-s390x/tools/SourceKit/libdispatch-prefix/src/libdispatch-stamp/libdispatch-install
[0/1] Install the project...
-- Install configuration: "Release"
CMake Error at cmake_install.cmake:36 (file):
  file cannot create directory: /usr/lib/swift/Block.  Maybe need
  administrative privileges.


FAILED: CMakeFiles/install.util 

My build-preset:

[preset: buildbot_incremental_linux,no_test]
mixin-preset=buildbot_incremental_linux

test=0
validation-test=0
long-test=0
test-optimized=0
skip-build-swiftpm
skip-test-swiftpm

which expands to:

swift/utils/build-script --assertions --release --test --validation-test --lit-args=-v --build-subdir=buildbot_incremental --llbuild --swiftpm --xctest --foundation --libdispatch --test=0 --validation-test=0 --long-test=0 --test-optimized=0 --skip-build-swiftpm --skip-test-swiftpm -- --build-ninja --reconfigure

Here's the output the first time libdispatch is built. It looks like the 2nd incremental build is trying to install libdispatch to the wrong location?

...
[835/844] Performing install step for 'libdispatch'
[0/1] Install the project...
-- Install configuration: ""
-- Installing: /localbox/vivkong/swift41/build/buildbot_incremental/swift-linux-s390x/tools/SourceKit/libdispatch-prefix/lib/swift/Block/Block.h
-- Installing: /localbox/vivkong/swift41/build/buildbot_incremental/swift-linux-s390x/tools/SourceKit/libdispatch-prefix/lib/swift/dispatch/base.h
-- Installing: /localbox/vivkong/swift41/build/buildbot_incremental/swift-linux-s390x/tools/SourceKit/libdispatch-prefix/lib/swift/dispatch/block.h
-- Installing: /localbox/vivkong/swift41/build/buildbot_incremental/swift-linux-s390x/tools/SourceKit/libdispatch-prefix/lib/swift/dispatch/data.h
-- Installing: /localbox/vivkong/swift41/build/buildbot_incremental/swift-linux-s390x/tools/SourceKit/libdispatch-prefix/lib/swift/dispatch/dispatch.h
-- Installing: /localbox/vivkong/swift41/build/buildbot_incremental/swift-linux-s390x/tools/SourceKit/libdispatch-prefix/lib/swift/dispatch/group.h
-- Installing: /localbox/vivkong/swift41/build/buildbot_incremental/swift-linux-s390x/tools/SourceKit/libdispatch-prefix/lib/swift/dispatch/introspection.h
-- Installing: /localbox/vivkong/swift41/build/buildbot_incremental/swift-linux-s390x/tools/SourceKit/libdispatch-prefix/lib/swift/dispatch/io.h
-- Installing: /localbox/vivkong/swift41/build/buildbot_incremental/swift-linux-s390x/tools/SourceKit/libdispatch-prefix/lib/swift/dispatch/object.h
-- Installing: /localbox/vivkong/swift41/build/buildbot_incremental/swift-linux-s390x/tools/SourceKit/libdispatch-prefix/lib/swift/dispatch/once.h
-- Installing: /localbox/vivkong/swift41/build/buildbot_incremental/swift-linux-s390x/tools/SourceKit/libdispatch-prefix/lib/swift/dispatch/queue.h
-- Installing: /localbox/vivkong/swift41/build/buildbot_incremental/swift-linux-s390x/tools/SourceKit/libdispatch-prefix/lib/swift/dispatch/semaphore.h
-- Installing: /localbox/vivkong/swift41/build/buildbot_incremental/swift-linux-s390x/tools/SourceKit/libdispatch-prefix/lib/swift/dispatch/source.h
-- Installing: /localbox/vivkong/swift41/build/buildbot_incremental/swift-linux-s390x/tools/SourceKit/libdispatch-prefix/lib/swift/dispatch/time.h
-- Installing: /localbox/vivkong/swift41/build/buildbot_incremental/swift-linux-s390x/tools/SourceKit/libdispatch-prefix/lib/swift/dispatch/module.modulemap
-- Installing: /localbox/vivkong/swift41/build/buildbot_incremental/swift-linux-s390x/tools/SourceKit/libdispatch-prefix/lib/swift/os/object.h
-- Installing: /localbox/vivkong/swift41/build/buildbot_incremental/swift-linux-s390x/tools/SourceKit/libdispatch-prefix/lib/swift/os/generic_unix_base.h
-- Installing: /localbox/vivkong/swift41/build/buildbot_incremental/swift-linux-s390x/tools/SourceKit/libdispatch-prefix/lib/swift/linux/libdispatch.so
-- Installing: /localbox/vivkong/swift41/build/buildbot_incremental/swift-linux-s390x/tools/SourceKit/libdispatch-prefix/lib/swift/linux/s390x/Dispatch.swiftmodule
-- Installing: /localbox/vivkong/swift41/build/buildbot_incremental/swift-linux-s390x/tools/SourceKit/libdispatch-prefix/lib/swift/linux/s390x/Dispatch.swiftdoc

I'm not familiar with CMake. And I would really like to avoid building from scratch every time. Any idea what could be wrong?

Thanks.

1 Like

@compnerd may have some ideas here.

What is the value being passed into the CMAKE_INSTALL_PREFIX for the installation? The script is a bit opaque, so if you could trace that down and get that, perhaps we can figure out what is happening here.

I modified /libdispatch-linux-s390x/cmake_install.cmake to print CMAKE_INSTALL_PREFIX and it is empty. So it eventually became /usr. This is for the subsequent run. I'll try to see if I can find what the value is when I run the build for the first time.

Thanks.

I tried building on a different machine and I don't see this error anymore...so probably it's the set up on this 1 particular machine. Sorry for the noise. For now I've turned off building SourceKit to get around it.