Skip to content

Building Swift fails on linux with module redefinition errors #62429

Closed
@keith

Description

@keith

When building the Swift compiler on Linux with:

LDFLAGS="-Xlinker -z -Xlinker nostart-stop-gc" CC=/usr/bin/clang CXX=/usr/bin/clang++ ./swift/utils/build-script --release-debuginfo --sccache --llvm-max-parallel-lto-link-jobs 1 --llvm-cmake-options='-DLLVM_ENABLE_LLD=' --extra-cmake-options="-DSWIFT_USE_LINKER= -DLLVM_USE_LINKER=/home/ksmiley/.bin/ld.lld" --reconfigure --bootstrapping off

While also having swiftc 5.7.1 in my $PATH, I end up getting these build failures:

/opt/swift/swift-5.7.1/usr/lib/swift/dispatch/module.modulemap:8:8: error: redefinition of module 'DispatchIntrospection'
module DispatchIntrospection [system] [extern_c] {
       ^
/home/ksmiley/dev/oss-swift/swift-corelibs-libdispatch/dispatch/module.modulemap:8:8: note: previously defined here
module DispatchIntrospection [system] [extern_c] {
       ^
/opt/swift/swift-5.7.1/usr/lib/swift/dispatch/module.modulemap:13:8: error: redefinition of module 'CDispatch'
module CDispatch [system] [extern_c] {
       ^
/home/ksmiley/dev/oss-swift/swift-corelibs-libdispatch/dispatch/module.modulemap:13:8: note: previously defined here
module CDispatch [system] [extern_c] {
       ^
ninja: build stopped: subcommand failed.

Dispatch seems to be the first module that fails, but there are many errors with the same issue. Eventually I also see:

/home/ksmiley/dev/oss-swift/build/Ninja-RelWithDebInfoAssert/swift-linux-x86_64/lib/swift/host/SwiftDiagnostics.swiftmodule/x86_64-unknown-linux-gnu.private.swiftinterface:5:8: error: failed to build module 'SwiftSyntax' for importation due to the errors above; the textual interface may be broken by project issues or a compiler bug
import SwiftSyntax
       ^
/home/ksmiley/dev/oss-swift/build/Ninja-RelWithDebInfoAssert/swift-linux-x86_64/lib/swift/host/SwiftParser.swiftmodule/x86_64-unknown-linux-gnu.private.swiftinterface:5:8: error: failed to build module 'SwiftDiagnostics' for importation due to the errors above; the textual interface may be broken by project issues or a compiler bug
import SwiftDiagnostics
       ^
/opt/swift/swift-5.7.1/usr/lib/swift/dispatch/module.modulemap:1:8: error: redefinition of module 'Dispatch'
module Dispatch {
       ^
/home/ksmiley/dev/oss-swift/swift-corelibs-libdispatch/dispatch/module.modulemap:1:8: note: previously defined here
module Dispatch {
       ^

But I believe the message is correct that the issue is the other duplicate modules.

My impression was that building with an existing Swift compiler installation was expected (or maybe even required), but I am attempting to build without these in my $PATH assuming that if it still works that way it won't be able to find these modulemaps, so maybe I'll side step this.

Steps to reproduce

  • Checkout 5b9aef9 and friends
  • Build with the command above

Environment

  • Swift 5.7.1 release
  • Ubuntu 20.04

Metadata

Metadata

Assignees

No one assigned

    Labels

    LinuxPlatform: LinuxbugA deviation from expected or documented behavior. Also: expected but undesirable behavior.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions