Building executable on top of swift-nio on Ubuntu 18.04

I'm trying to build on top of Swift NIO on Ubuntu 18.04 and I'm having some build issues - I assumes are of the "I need to specify something in my build command / Package definition" or "I need to change how Swift's installed" variety.

I've actually got this simplified to just building the swift-nio project without any of my code on top of it:

So, inside the swift-nio project, swift build yields the following redefinition of module errors:

Compile CNIOSHA1 c_nio_sha1.c
/usr/lib/llvm-6.0/lib/clang/6.0.0/include/module.modulemap:24:8: error: redefinition of module '_Builtin_intrinsics'
module _Builtin_intrinsics [system] [extern_c] {
       ^
/home/vagrant/swift-4.2.1-RELEASE-ubuntu18.04/usr/lib/swift/clang/include/module.modulemap:24:8: note: previously defined here
module _Builtin_intrinsics [system] [extern_c] {
       ^
/usr/lib/llvm-6.0/lib/clang/6.0.0/include/module.modulemap:160:8: error: redefinition of module '_Builtin_stddef_max_align_t'
module _Builtin_stddef_max_align_t [system] [extern_c] {
       ^
/home/vagrant/swift-4.2.1-RELEASE-ubuntu18.04/usr/lib/swift/clang/include/module.modulemap:160:8: note: previously defined here
module _Builtin_stddef_max_align_t [system] [extern_c] {
       ^
/usr/lib/llvm-6.0/lib/clang/6.0.0/include/module.modulemap:164:8: error: redefinition of module 'opencl_c'
module opencl_c {
       ^
/home/vagrant/swift-4.2.1-RELEASE-ubuntu18.04/usr/lib/swift/clang/include/module.modulemap:164:8: note: previously defined here
module opencl_c {

I get why the module's are redefined - I see the definition in both the /usr/lib/llvm-6.0/lib/clang and /home/vagrant/swift-4.2.1-RELEASE-ubuntu18.04/usr/lib/swift/clang. Since LLVM 6 is part of the standard Ubuntu 18.04 install (at least, as far as I understand it), I haven't figured out how to avoid the issue.

So, any help or tips would be greatly appreciated.

Thanks!

Eric

Thanks for reporting this! I just tried to reproduce this and unfortunately failed. I just did a

docker run -it --rm ubuntu:18.04

and in there I downloaded Swift 4.2.1-RELEASE and swift-nio. I ran

apt-get update && apt-get install -y git curl libatomic1 libicu60 libxml2 libz-dev pkg-config clang
curl https://swift.org/builds/swift-4.2.1-release/ubuntu1804/swift-4.2.1-RELEASE/swift-4.2.1-RELEASE-ubuntu18.04.tar.gz | tar -xz
git clone https://github.com/apple/swift-nio && cd swift-nio && git checkout nio-1.12
../swift-4.2.1-RELEASE-ubuntu18.04/usr/bin/swift build

and it built everything just fine. I do also have this _Builtin_intrinsics module defined in both places and that seems to be okay:

root@bfd03e4e98df:~/swift-nio# grep Builtin_intrinsics ~/swift-4.2.1-RELEASE-ubuntu18.04/usr/lib/swift/clang/include/module.modulemap 
module _Builtin_intrinsics [system] [extern_c] {
root@bfd03e4e98df:~/swift-nio# grep Builtin_intrinsics /usr/lib/llvm-6.0/lib/clang/6.0.0/include/module.modulemap
module _Builtin_intrinsics [system] [extern_c] {

OS is:

root@bfd03e4e98df:~/swift-nio# lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 18.04.1 LTS
Release:	18.04
Codename:	bionic

Would you mind sending the output of

clang -v

maybe? For me that's

root@f4c2ff6fed87:~/swift-nio# clang -v
clang version 6.0.0-1ubuntu2 (tags/RELEASE_600/final)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/7
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/7.3.0
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7.3.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8
Selected GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/7.3.0
Candidate multilib: .;@m64
Selected multilib: .;@m64

@johannesweiss Thanks for the response. My Clang and OS versions look the same as yours

**vagrant@homestead** : **~/sandbox/swift-nio** $ clang -v
clang version 6.0.0-1ubuntu2 (tags/RELEASE_600/final)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/7
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/7.3.0
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7.3.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8
Selected GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/7.3.0
Candidate multilib: .;@m64
Selected multilib: .;@m64

**vagrant@homestead** : **~/sandbox/swift-nio** $ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 18.04.1 LTS
Release: 18.04
Codename: bionic

hmm, would you mind posting the output of

swift build -v

? It might be quite a bit but maybe we can see the difference there. For me, the beginning (which covers the C files where you hit the error I think are:

root@d21a7d7032be:/swift-nio# ../swift-4.2.1-RELEASE-ubuntu18.04/usr/bin/swift build -v
lsb_release -r
which clang
/swift-4.2.1-RELEASE-ubuntu18.04/usr/bin/swiftc --driver-mode=swift -L /swift-4.2.1-RELEASE-ubuntu18.04/usr/lib/swift/pm/4 -lPackageDescription -suppress-warnings -swift-version 4 -I /swift-4.2.1-RELEASE-ubuntu18.04/usr/lib/swift/pm/4 -sdk / /swift-nio/Package.swift -fileno 5
/swift-4.2.1-RELEASE-ubuntu18.04/usr/bin/swiftc --driver-mode=swift -L /swift-4.2.1-RELEASE-ubuntu18.04/usr/lib/swift/pm/4 -lPackageDescription -suppress-warnings -swift-version 4 -I /swift-4.2.1-RELEASE-ubuntu18.04/usr/lib/swift/pm/4 -sdk / /swift-nio/.build/checkouts/swift-nio-zlib-support.git--7750919553872813342/Package.swift -fileno 5
pkg-config --variable pc_path pkg-config
/swift-4.2.1-RELEASE-ubuntu18.04/usr/bin/swift-build-tool -f /swift-nio/.build/debug.yaml main -v
/usr/bin/clang -target x86_64-unknown-linux --sysroot / -fPIC -g -O0 -DSWIFT_PACKAGE=1 -DDEBUG=1 -fblocks -fmodules -fmodule-name=CNIOZlib -I /swift-nio/Sources/CNIOZlib/include -fmodule-map-file=/swift-nio/.build/checkouts/swift-nio-zlib-support.git--7750919553872813342/module.modulemap -fmodules-cache-path=/swift-nio/.build/x86_64-unknown-linux/debug/ModuleCache -MD -MT dependencies -MF /swift-nio/.build/x86_64-unknown-linux/debug/CNIOZlib.build/empty.c.d -c /swift-nio/Sources/CNIOZlib/empty.c -o /swift-nio/.build/x86_64-unknown-linux/debug/CNIOZlib.build/empty.c.o
/usr/bin/clang -target x86_64-unknown-linux --sysroot / -fPIC -g -O0 -DSWIFT_PACKAGE=1 -DDEBUG=1 -fblocks -fmodules -fmodule-name=CNIOSHA1 -I /swift-nio/Sources/CNIOSHA1/include -fmodule-map-file=/swift-nio/.build/checkouts/swift-nio-zlib-support.git--7750919553872813342/module.modulemap -fmodules-cache-path=/swift-nio/.build/x86_64-unknown-linux/debug/ModuleCache -MD -MT dependencies -MF /swift-nio/.build/x86_64-unknown-linux/debug/CNIOSHA1.build/c_nio_sha1.c.d -c /swift-nio/Sources/CNIOSHA1/c_nio_sha1.c -o /swift-nio/.build/x86_64-unknown-linux/debug/CNIOSHA1.build/c_nio_sha1.c.o
/usr/bin/clang -target x86_64-unknown-linux --sysroot / -fPIC -g -O0 -DSWIFT_PACKAGE=1 -DDEBUG=1 -fblocks -fmodules -fmodule-name=CNIOLinux -I /swift-nio/Sources/CNIOLinux/include -fmodule-map-file=/swift-nio/.build/checkouts/swift-nio-zlib-support.git--7750919553872813342/module.modulemap -fmodules-cache-path=/swift-nio/.build/x86_64-unknown-linux/debug/ModuleCache -MD -MT dependencies -MF /swift-nio/.build/x86_64-unknown-linux/debug/CNIOLinux.build/shim.c.d -c /swift-nio/Sources/CNIOLinux/shim.c -o /swift-nio/.build/x86_64-unknown-linux/debug/CNIOLinux.build/shim.c.o
/usr/bin/clang -target x86_64-unknown-linux --sysroot / -fPIC -g -O0 -DSWIFT_PACKAGE=1 -DDEBUG=1 -fblocks -fmodules -fmodule-name=CNIOLinux -I /swift-nio/Sources/CNIOLinux/include -fmodule-map-file=/swift-nio/.build/checkouts/swift-nio-zlib-support.git--7750919553872813342/module.modulemap -fmodules-cache-path=/swift-nio/.build/x86_64-unknown-linux/debug/ModuleCache -MD -MT dependencies -MF /swift-nio/.build/x86_64-unknown-linux/debug/CNIOLinux.build/ifaddrs-android.c.d -c /swift-nio/Sources/CNIOLinux/ifaddrs-android.c -o /swift-nio/.build/x86_64-unknown-linux/debug/CNIOLinux.build/ifaddrs-android.c.o
/swift-4.2.1-RELEASE-ubuntu18.04/usr/bin/swiftc -module-name NIOPriorityQueue -incremental -emit-dependencies -emit-module -emit-module-path /swift-nio/.build/x86_64-unknown-linux/debug/NIOPriorityQueue.swiftmodule -output-file-map /swift-nio/.build/x86_64-unknown-linux/debug/NIOPriorityQueue.build/output-file-map.json -parse-as-library -c /swift-nio/Sources/NIOPriorityQueue/Heap.swift /swift-nio/Sources/NIOPriorityQueue/PriorityQueue.swift -I /swift-nio/.build/x86_64-unknown-linux/debug -swift-version 4 -enable-batch-mode -target x86_64-unknown-linux -sdk / -Onone -g -enable-testing -j4 -DSWIFT_PACKAGE -DDEBUG -Xcc -fmodule-map-file=/swift-nio/.build/checkouts/swift-nio-zlib-support.git--7750919553872813342/module.modulemap -module-cache-path /swift-nio/.build/x86_64-unknown-linux/debug/ModuleCache -Xfrontend -color-diagnostics
/usr/bin/clang -target x86_64-unknown-linux --sysroot / -fPIC -g -O0 -DSWIFT_PACKAGE=1 -DDEBUG=1 -fblocks -fmodules -fmodule-name=CNIODarwin -I /swift-nio/Sources/CNIODarwin/include -fmodule-map-file=/swift-nio/.build/checkouts/swift-nio-zlib-support.git--7750919553872813342/module.modulemap -fmodules-cache-path=/swift-nio/.build/x86_64-unknown-linux/debug/ModuleCache -MD -MT dependencies -MF /swift-nio/.build/x86_64-unknown-linux/debug/CNIODarwin.build/shim.c.d -c /swift-nio/Sources/CNIODarwin/shim.c -o /swift-nio/.build/x86_64-unknown-linux/debug/CNIODarwin.build/shim.c.o
/usr/bin/clang -target x86_64-unknown-linux --sysroot / -fPIC -g -O0 -DSWIFT_PACKAGE=1 -DDEBUG=1 -fblocks -fmodules -fmodule-name=CNIOHTTPParser -I /swift-nio/Sources/CNIOHTTPParser/include -fmodule-map-file=/swift-nio/.build/checkouts/swift-nio-zlib-support.git--7750919553872813342/module.modulemap -fmodules-cache-path=/swift-nio/.build/x86_64-unknown-linux/debug/ModuleCache -MD -MT dependencies -MF /swift-nio/.build/x86_64-unknown-linux/debug/CNIOHTTPParser.build/c_nio_http_parser.c.d -c /swift-nio/Sources/CNIOHTTPParser/c_nio_http_parser.c -o /swift-nio/.build/x86_64-unknown-linux/debug/CNIOHTTPParser.build/c_nio_http_parser.c.o
/usr/bin/clang -target x86_64-unknown-linux --sysroot / -fPIC -g -O0 -DSWIFT_PACKAGE=1 -DDEBUG=1 -fblocks -fmodules -fmodule-name=CNIOAtomics -I /swift-nio/Sources/CNIOAtomics/include -fmodule-map-file=/swift-nio/.build/checkouts/swift-nio-zlib-support.git--7750919553872813342/module.modulemap -fmodules-cache-path=/swift-nio/.build/x86_64-unknown-linux/debug/ModuleCache -MD -MT dependencies -MF /swift-nio/.build/x86_64-unknown-linux/debug/CNIOAtomics.build/src/c-atomics.c.d -c /swift-nio/Sources/CNIOAtomics/src/c-atomics.c -o /swift-nio/.build/x86_64-unknown-linux/debug/CNIOAtomics.build/src/c-atomics.c.o
/swift-4.2.1-RELEASE-ubuntu18.04/usr/bin/swiftc -module-name NIOConcurrencyHelpers -incremental -emit-dependencies -emit-module -emit-module-path /swift-nio/.build/x86_64-unknown-linux/debug/NIOConcurrencyHelpers.swiftmodule -output-file-map /swift-nio/.build/x86_64-unknown-linux/debug/NIOConcurrencyHelpers.build/output-file-map.json -parse-as-library -c /swift-nio/Sources/NIOConcurrencyHelpers/atomics.swift /swift-nio/Sources/NIOConcurrencyHelpers/lock.swift -I /swift-nio/.build/x86_64-unknown-linux/debug -swift-version 4 -enable-batch-mode -target x86_64-unknown-linux -sdk / -Onone -g -enable-testing -j4 -DSWIFT_PACKAGE -DDEBUG -Xcc -fmodule-map-file=/swift-nio/.build/x86_64-unknown-linux/debug/CNIOAtomics.build/module.modulemap -I /swift-nio/Sources/CNIOAtomics/include -Xcc -fmodule-map-file=/swift-nio/.build/checkouts/swift-nio-zlib-support.git--7750919553872813342/module.modulemap -module-cache-path /swift-nio/.build/x86_64-unknown-linux/debug/ModuleCache -Xfrontend -color-diagnostics

Here's my output. I blew away the .build folder beforehand, so I've got the git commands in here, too.

vagrant@homestead:~/sandbox/swift-nio$ swift build -v
lsb_release -r
which clang
/home/vagrant/swift-4.2.1-RELEASE-ubuntu18.04/usr/bin/swiftc --driver-mode=swift -L /home/vagrant/swift-4.2.1-RELEASE-ubuntu18.04/usr/lib/swift/pm/4 -lPackageDescription -suppress-warnings -swift-version 4 -I /home/vagrant/swift-4.2.1-RELEASE-ubuntu18.04/usr/lib/swift/pm/4 -sdk / /home/vagrant/sandbox/swift-nio/Package.swift -fileno 5
/home/vagrant/swift-4.2.1-RELEASE-ubuntu18.04/usr/bin/swiftc --driver-mode=swift -L /home/vagrant/swift-4.2.1-RELEASE-ubuntu18.04/usr/lib/swift/pm/4 -lPackageDescription -suppress-warnings -swift-version 4 -I /home/vagrant/swift-4.2.1-RELEASE-ubuntu18.04/usr/lib/swift/pm/4 -sdk / /tmp/TemporaryFile.bcpQDT.swift -fileno 6
Fetching https://github.com/apple/swift-nio-zlib-support.git
git clone --mirror https://github.com/apple/swift-nio-zlib-support.git /home/vagrant/sandbox/swift-nio/.build/repositories/swift-nio-zlib-support.git--4602089437811353477
git -C /home/vagrant/sandbox/swift-nio/.build/repositories/swift-nio-zlib-support.git--4602089437811353477 rev-parse --is-bare-repository
git -C /home/vagrant/sandbox/swift-nio/.build/repositories/swift-nio-zlib-support.git--4602089437811353477 tag -l
git -C /home/vagrant/sandbox/swift-nio/.build/repositories/swift-nio-zlib-support.git--4602089437811353477 rev-parse --verify '1.0.0^{commit}'
git -C /home/vagrant/sandbox/swift-nio/.build/repositories/swift-nio-zlib-support.git--4602089437811353477 rev-parse --verify '37760e9a52030bb9011972c5213c3350fa9d41fd^{tree}'
git -C /home/vagrant/sandbox/swift-nio/.build/repositories/swift-nio-zlib-support.git--4602089437811353477 ls-tree 6e803ab3ba20a17ab4009c31621f964e7ed5a362
git -C /home/vagrant/sandbox/swift-nio/.build/repositories/swift-nio-zlib-support.git--4602089437811353477 cat-file -p 3feb7894f502fd1ed5c4b3279b8e45fa74a72db7
git -C /home/vagrant/sandbox/swift-nio/.build/repositories/swift-nio-zlib-support.git--4602089437811353477 rev-parse --verify '1.0.0^{commit}'
git -C /home/vagrant/sandbox/swift-nio/.build/repositories/swift-nio-zlib-support.git--4602089437811353477 rev-parse --verify '37760e9a52030bb9011972c5213c3350fa9d41fd^{tree}'
git -C /home/vagrant/sandbox/swift-nio/.build/repositories/swift-nio-zlib-support.git--4602089437811353477 ls-tree 6e803ab3ba20a17ab4009c31621f964e7ed5a362
git -C /home/vagrant/sandbox/swift-nio/.build/repositories/swift-nio-zlib-support.git--4602089437811353477 cat-file -p 3feb7894f502fd1ed5c4b3279b8e45fa74a72db7
git -C /home/vagrant/sandbox/swift-nio/.build/repositories/swift-nio-zlib-support.git--4602089437811353477 cat-file -p 3feb7894f502fd1ed5c4b3279b8e45fa74a72db7
/home/vagrant/swift-4.2.1-RELEASE-ubuntu18.04/usr/bin/swiftc --driver-mode=swift -L /home/vagrant/swift-4.2.1-RELEASE-ubuntu18.04/usr/lib/swift/pm/4 -lPackageDescription -suppress-warnings -swift-version 4 -I /home/vagrant/swift-4.2.1-RELEASE-ubuntu18.04/usr/lib/swift/pm/4 -sdk / /tmp/TemporaryFile.nGoxuk.swift -fileno 6
Completed resolution in 0.37s
git -C /home/vagrant/sandbox/swift-nio/.build/repositories/swift-nio-zlib-support.git--4602089437811353477 rev-parse --is-bare-repository
git -C /home/vagrant/sandbox/swift-nio/.build/repositories/swift-nio-zlib-support.git--4602089437811353477 rev-parse --is-bare-repository
git -C /home/vagrant/sandbox/swift-nio/.build/repositories/swift-nio-zlib-support.git--4602089437811353477 tag -l
git -C /home/vagrant/sandbox/swift-nio/.build/repositories/swift-nio-zlib-support.git--4602089437811353477 rev-parse --verify '1.0.0^{commit}'
git -C /home/vagrant/sandbox/swift-nio/.build/repositories/swift-nio-zlib-support.git--4602089437811353477 rev-parse --is-bare-repository
Cloning https://github.com/apple/swift-nio-zlib-support.git
git clone --shared /home/vagrant/sandbox/swift-nio/.build/repositories/swift-nio-zlib-support.git--4602089437811353477 /home/vagrant/sandbox/swift-nio/.build/checkouts/swift-nio-zlib-support.git--4602089437811353477
git -C /home/vagrant/sandbox/swift-nio/.build/checkouts/swift-nio-zlib-support.git--4602089437811353477 rev-parse --is-bare-repository
Resolving https://github.com/apple/swift-nio-zlib-support.git at 1.0.0
git -C /home/vagrant/sandbox/swift-nio/.build/checkouts/swift-nio-zlib-support.git--4602089437811353477 checkout -f 37760e9a52030bb9011972c5213c3350fa9d41fd
git -C /home/vagrant/sandbox/swift-nio/.build/checkouts/swift-nio-zlib-support.git--4602089437811353477 submodule update --init --recursive
git -C /home/vagrant/sandbox/swift-nio/.build/checkouts/swift-nio-zlib-support.git--4602089437811353477 clean -ffdx
/home/vagrant/swift-4.2.1-RELEASE-ubuntu18.04/usr/bin/swiftc --driver-mode=swift -L /home/vagrant/swift-4.2.1-RELEASE-ubuntu18.04/usr/lib/swift/pm/4 -lPackageDescription -suppress-warnings -swift-version 4 -I /home/vagrant/swift-4.2.1-RELEASE-ubuntu18.04/usr/lib/swift/pm/4 -sdk / /home/vagrant/sandbox/swift-nio/.build/checkouts/swift-nio-zlib-support.git--4602089437811353477/Package.swift -fileno 5
pkg-config --variable pc_path pkg-config
/home/vagrant/swift-4.2.1-RELEASE-ubuntu18.04/usr/bin/swift-build-tool -f /home/vagrant/sandbox/swift-nio/.build/debug.yaml main -v
/usr/bin/clang -target x86_64-unknown-linux --sysroot / -fPIC -g -O0 -DSWIFT_PACKAGE=1 -DDEBUG=1 -fblocks -fmodules -fmodule-name=CNIOZlib -I /home/vagrant/sandbox/swift-nio/Sources/CNIOZlib/include -fmodule-map-file=/home/vagrant/sandbox/swift-nio/.build/checkouts/swift-nio-zlib-support.git--4602089437811353477/module.modulemap -fmodules-cache-path=/home/vagrant/sandbox/swift-nio/.build/x86_64-unknown-linux/debug/ModuleCache -MD -MT dependencies -MF /home/vagrant/sandbox/swift-nio/.build/x86_64-unknown-linux/debug/CNIOZlib.build/empty.c.d -c /home/vagrant/sandbox/swift-nio/Sources/CNIOZlib/empty.c -o /home/vagrant/sandbox/swift-nio/.build/x86_64-unknown-linux/debug/CNIOZlib.build/empty.c.o
/home/vagrant/swift-4.2.1-RELEASE-ubuntu18.04/usr/bin/swiftc -module-name NIOPriorityQueue -incremental -emit-dependencies -emit-module -emit-module-path /home/vagrant/sandbox/swift-nio/.build/x86_64-unknown-linux/debug/NIOPriorityQueue.swiftmodule -output-file-map /home/vagrant/sandbox/swift-nio/.build/x86_64-unknown-linux/debug/NIOPriorityQueue.build/output-file-map.json -parse-as-library -c /home/vagrant/sandbox/swift-nio/Sources/NIOPriorityQueue/Heap.swift /home/vagrant/sandbox/swift-nio/Sources/NIOPriorityQueue/PriorityQueue.swift -I /home/vagrant/sandbox/swift-nio/.build/x86_64-unknown-linux/debug -swift-version 4 -enable-batch-mode -target x86_64-unknown-linux -sdk / -Onone -g -enable-testing -j1 -DSWIFT_PACKAGE -DDEBUG -Xcc -fmodule-map-file=/home/vagrant/sandbox/swift-nio/.build/checkouts/swift-nio-zlib-support.git--4602089437811353477/module.modulemap -module-cache-path /home/vagrant/sandbox/swift-nio/.build/x86_64-unknown-linux/debug/ModuleCache -Xfrontend -color-diagnostics
/usr/bin/clang -target x86_64-unknown-linux --sysroot / -fPIC -g -O0 -DSWIFT_PACKAGE=1 -DDEBUG=1 -fblocks -fmodules -fmodule-name=CNIOSHA1 -I /home/vagrant/sandbox/swift-nio/Sources/CNIOSHA1/include -fmodule-map-file=/home/vagrant/sandbox/swift-nio/.build/checkouts/swift-nio-zlib-support.git--4602089437811353477/module.modulemap -fmodules-cache-path=/home/vagrant/sandbox/swift-nio/.build/x86_64-unknown-linux/debug/ModuleCache -MD -MT dependencies -MF /home/vagrant/sandbox/swift-nio/.build/x86_64-unknown-linux/debug/CNIOSHA1.build/c_nio_sha1.c.d -c /home/vagrant/sandbox/swift-nio/Sources/CNIOSHA1/c_nio_sha1.c -o /home/vagrant/sandbox/swift-nio/.build/x86_64-unknown-linux/debug/CNIOSHA1.build/c_nio_sha1.c.o
/usr/lib/llvm-6.0/lib/clang/6.0.0/include/module.modulemap:24:8: error: redefinition of module '_Builtin_intrinsics'
module _Builtin_intrinsics [system] [extern_c] {
       ^
/home/vagrant/swift-4.2.1-RELEASE-ubuntu18.04/usr/lib/swift/clang/include/module.modulemap:24:8: note: previously defined here
module _Builtin_intrinsics [system] [extern_c] {
       ^
/usr/lib/llvm-6.0/lib/clang/6.0.0/include/module.modulemap:160:8: error: redefinition of module '_Builtin_stddef_max_align_t'
module _Builtin_stddef_max_align_t [system] [extern_c] {
       ^
/home/vagrant/swift-4.2.1-RELEASE-ubuntu18.04/usr/lib/swift/clang/include/module.modulemap:160:8: note: previously defined here
module _Builtin_stddef_max_align_t [system] [extern_c] {
       ^
/usr/lib/llvm-6.0/lib/clang/6.0.0/include/module.modulemap:164:8: error: redefinition of module 'opencl_c'
module opencl_c {
       ^
/home/vagrant/swift-4.2.1-RELEASE-ubuntu18.04/usr/lib/swift/clang/include/module.modulemap:164:8: note: previously defined here
module opencl_c {
       ^
3 errors generated.
error: terminated(1): /home/vagrant/swift-4.2.1-RELEASE-ubuntu18.04/usr/bin/swift-build-tool -f /home/vagrant/sandbox/swift-nio/.build/debug.yaml main -v output:

Other than the shifted order of some of the build commands, nothings jumping at at me, particularly in the arguments to clang command for CNIOSHA1.

Unsurprisingly, everything build fine when I tried on the Docker image.

Yes, that totally looks the same to me too. I'm glad you can repro with the Docker image but I still would like to understand why the vagrant is failing...

@Aciid / @jrose / @ddunbar / @NeoNacho any ideas here?

Hm. Both Swift and Clang have copies of the Clang headers on the platform, and they may not be in sync. That part seems fine. What I don't get is why Clang is searching in Swift's resource directory, or why Swift is searching in the system Clang's resource directory. (I can't tell which one the error message is coming from.) Neither one seems to have any extra funny include paths.

FWIW, I've seen similar-looking (resolved) issues on bugs.swift.com referencing the REPL (ie, https://bugs.swift.org/browse/SR-7065). I'm enough of a "fish out of water" on Linux that I'm not sure if that's relevant or how it applies here.

…and, found it.

Our vagrantfile for building the VM was exporting C_INCLUDE_PATH and CPLUS_INCLUDE_PATH. with swift-4.2.1-RELEASE-ubuntu18.04/usr/lib/swift/clang/include/ included in the path.

I'm reaching out to my colleague who manages our Vagrant config to see how those got in there - if they came from something quasi-official (not necessarily Apple/Swift official), something old that we should've removed, or somewhere else.

@johannesweiss and @jrose, thank you jumping in. I know rubber ducking's not the funnest thing in the world, but maybe this'll save somebody else from spending their time on this.

2 Likes

Nice one, glad you found it!

So I remember setting C_INCLUDE_PATH and CPLUS_INCLUDE_PATH to those places was a hack that made import Foundation and import Glibc work in the REPL in the Swift 4.0 days and maybe even still in 4.1.
But I believe that’s now fixed and setting those will probably just cause issues.

Terms of Service

Privacy Policy

Cookie Policy