swift-lispkit icon indicating copy to clipboard operation
swift-lispkit copied to clipboard

Build fails: error: redefinition of module

Open bentxt opened this issue 2 years ago • 3 comments

'swift-lispkit': error: invalidManifestFormat("/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/clang/include/module.modulemap:10:8: error: redefinition of module '_Builtin_intrinsics'\nmodule _Builtin_intrinsics [system] [extern_c] {\n ^\n/usr/local/Cellar/llvm/13.0.1_1/lib/clang/13.0.1/include/module.modulemap:10:8: note: previously defined here\nmodule _Builtin_intrinsics [system] [extern_c] {\n ^\n/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/clang/include/module.modulemap:156:8: error: redefinition of module '_Builtin_stddef_max_align_t'\nmodule _Builtin_stddef_max_align_t [system] [extern_c] {\n ^\n/usr/local/Cellar/llvm/13.0.1_1/lib/clang/13.0.1/include/module.modulemap:156:8: note: previously defined here\nmodule _Builtin_stddef_max_align_t [system] [extern_c] {\n ^\n/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/clang/include/module.modulemap:160:8: error: redefinition of module 'opencl_c'\nmodule opencl_c {\n ^\n/usr/local/Cellar/llvm/13.0.1_1/lib/clang/13.0.1/include/module.modulemap:160:8: note: previously defined here\nmodule opencl_c {\n ^\n/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/clang/include/module.modulemap:10:8: error: redefinition of module '_Builtin_intrinsics'\nmodule _Builtin_intrinsics [system] [extern_c] {\n ^\n/usr/local/Cellar/llvm/13.0.1_1/lib/clang/13.0.1/include/module.modulemap:10:8: note: previously defined here\nmodule _Builtin_intrinsics [system] [extern_c] {\n ^\n/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/clang/include/module.modulemap:156:8: error: redefinition of module '_Builtin_stddef_max_align_t'\nmodule _Builtin_stddef_max_align_t [system] [extern_c] {\n ^\n/usr/local/Cellar/llvm/13.0.1_1/lib/clang/13.0.1/include/module.modulemap:156:8: note: previously defined here\nmodule _Builtin_stddef_max_align_t [system] [extern_c] {\n ^\n/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/clang/include/module.modulemap:160:8: error: redefinition of module 'opencl_c'\nmodule opencl_c {\n ^\n/usr/local/Cellar/llvm/13.0.1_1/lib/clang/13.0.1/include/module.modulemap:160:8: note: previously defined here\nmodule opencl_c {\n ^\n:5:9: note: in file included from :5:\n#import "copyfile.h"\n ^\n/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk/usr/include/copyfile.h:41:9: error: unknown type name 'uint32_t'\ntypedef uint32_t copyfile_flags_t;\n ^\n:5:9: note: in file included from :5:\n#import "copyfile.h"\n ^\n/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk/usr/include/copyfile.h:62:44: error: unknown type name 'uint32_t'\nint copyfile_state_get(copyfile_state_t s, uint32_t flag, void * dst);\n ^\n:5:9: note: in file included from :5:\n#import "copyfile.h"\n ^\n/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk/usr/include/copyfile.h:63:44: error: unknown type name 'uint32_t'\nint copyfile_state_set(copyfile_state_t s, uint32_t flag, const void * src);\n ^\n:14:9: note: in file included from :14:\n#import "inttypes.h"\n ^\n/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk/usr/include/inttypes.h:235:8: error: unknown type name 'intmax_t'\nextern intmax_t\n ^\n:14:9: note: in file included from :14:\n#import "inttypes.h"\n ^\n/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk/usr/include/inttypes.h:236:9: error: unknown type name 'intmax_t'\nimaxabs(intmax_t j);\n ^\n:14:9: note: in file included from :14:\n#import "inttypes.h"\n ^\n/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk/usr/include/inttypes.h:240:2: error: unknown type name 'intmax_t'\n intmax_t quot;\n ^\n:14:9: note: in file included from :14:\n#import "inttypes.h"\n ^\n/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk/usr/include/inttypes.h:241:2: error: unknown type name 'intmax_t'\n intmax_t rem;\n ^\n:14:9: note: in file included from :14:\n#import "inttypes.h"\n ^\n/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk/usr/include/inttypes.h:246:9: error: unknown type name 'intmax_t'\nimaxdiv(intmax_t __numer, intmax_t __denom);\n ^\n:14:9: note: in file included from :14:\n#import "inttypes.h"\n ^\n/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk/usr/include/inttypes.h:246:27: error: unknown type name 'intmax_t'\nimaxdiv(intmax_t __numer, intmax_t __denom);\n ^\n:14:9: note: in file included from :14:\n#import "inttypes.h"\n ^\n/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk/usr/include/inttypes.h:250:8: error: unknown type name 'intmax_t'\nextern intmax_t\n ^\n:14:9: note: in file included from :14:\n#import "inttypes.h"\n ^\n/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk/usr/include/inttypes.h:256:8: error: unknown type name 'uintmax_t'\nextern uintmax_t\n ^\n:14:9: note: in file included from :14:\n#import "inttypes.h"\n ^\n/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk/usr/include/inttypes.h:263:8: error: unknown type name 'intmax_t'\nextern intmax_t\n ^\n:14:9: note: in file included from :14:\n#import "inttypes.h"\n ^\n/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk/usr/include/inttypes.h:269:8: error: unknown type name 'uintmax_t'\nextern uintmax_t\n ^\n:23:9: note: in file included from :23:\n#import "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/clang/include/stdatomic.h"\n ^\n/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/clang/include/stdatomic.h:93:17: error: unknown type name 'uint_least16_t'\ntypedef _Atomic(uint_least16_t) atomic_char16_t;\n ^\n:23:9: note: in file included from :23:\n#import "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/clang/include/stdatomic.h"\n ^\n/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/clang/include/stdatomic.h:94:17: error: unknown type name 'uint_least32_t'\ntypedef _Atomic(uint_least32_t) atomic_char32_t;\n ^\n:23:9: note: in file included from :23:\n#import "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/clang/include/stdatomic.h"\n ^\n/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/clang/include/stdatomic.h:96:17: error: unknown type name 'int_least8_t'\ntypedef _Atomic(int_least8_t) atomic_int_least8_t;\n ^\n:0: error: too many errors emitted, stopping now\n:0: error: could not build Objective-C module 'Darwin'\n/Volumes/scand500gb01/usrdirs_bkb_drive_scand500gb01/localstore_bkb_drive_scand500gb01/dev_homefolders/local/lispkit/swift-lispkit.git/Package.swift:39:8: error: failed to build module 'PackageDescription' for importation due to the errors above; the textual interface may be broken by project issues or a compiler bug\nimport PackageDescription\n ^", diagnosticFile: nil)

bentxt avatar Jun 18 '22 16:06 bentxt

Thanks for the bug report. Unfortunately, I am unable to reproduce it. Can you let me know what Xcode version you use, how you built LispKit, for what platform (iOS/macOS), etc.

BTW, I noticed that there's a reference to Atomics. swift-atomics is a framework (from Apple) that is needed since earlier this year. I needs to be added explicitly to all projects that make use of the LispKit framework.

objecthub avatar Jun 18 '22 18:06 objecthub

Here is some hopefully useful information about my specific environment

First the reproducible steps:

 git clone https://github.com/objecthub/swift-lispkit
cd swift-lispkit/
make

Specs: XCode Version:

 /usr/bin/xcodebuild -version
Xcode 13.4
Build version 13F17a

Swift Version:

xcrun swift -version
swift-driver version: 1.45.2 Apple Swift version 5.6.1 (swiftlang-5.6.0.323.66 clang-1316.0.20.12)
Target: x86_64-apple-macosx12.0

Version of Clang compiler

clang --version
Homebrew clang version 13.0.1
Target: x86_64-apple-darwin21.5.0
Thread model: posix
InstalledDir: /usr/local/opt/llvm/bin

bentxt avatar Jun 25 '22 14:06 bentxt

I followed your instructions closely and could not reproduce the issue (see the transcript below). Both on an Intel and an M1-based MacBook Pro I could compile LispKit without problems. One difference I noticed is that you seem to use a clang installation that does not come from Xcode (as it was installed via Homebrew). My guess is that this is what causes the problem.

[Development/Scratch] git clone https://github.com/objecthub/swift-lispkit
Cloning into 'swift-lispkit'...
remote: Enumerating objects: 8377, done.
remote: Counting objects: 100% (1756/1756), done.
remote: Compressing objects: 100% (740/740), done.
remote: Total 8377 (delta 1119), reused 1609 (delta 975), pack-reused 6621
Receiving objects: 100% (8377/8377), 12.59 MiB | 1.17 MiB/s, done.
Resolving deltas: 100% (5772/5772), done.
[Development/Scratch] cd swift-lispkit/
[Scratch/swift-lispkit] make
swift build -Xswiftc "-D" -Xswiftc "SPM"
warning: Usage of /Users/zenger/Library/org.swift.swiftpm/collections.json has been deprecated. Please delete it and use the new /Users/zenger/Library/org.swift.swiftpm/configuration/collections.json instead.
Fetching https://github.com/objecthub/swift-commandlinekit.git from cache
Fetching https://github.com/objecthub/swift-markdownkit.git from cache
Fetching https://github.com/weichsel/ZIPFoundation.git
[4283/4283] Fetching objects
Fetched https://github.com/weichsel/ZIPFoundation.git (8.34s)
Fetched https://github.com/objecthub/swift-commandlinekit.git (8.34s)
Fetching https://github.com/objecthub/swift-sqliteexpress.git from cache
Fetching https://github.com/objecthub/swift-numberkit.git from cache
Fetched https://github.com/objecthub/swift-markdownkit.git (8.37s)
Fetching https://github.com/apple/swift-atomics.git from cache
Fetched https://github.com/objecthub/swift-sqliteexpress.git (0.54s)
Fetched https://github.com/objecthub/swift-numberkit.git (0.55s)
Fetched https://github.com/apple/swift-atomics.git (0.54s)
Computing version for https://github.com/apple/swift-atomics.git
Computed https://github.com/apple/swift-atomics.git at 1.0.2 (0.32s)
Computing version for https://github.com/weichsel/ZIPFoundation.git
Computed https://github.com/weichsel/ZIPFoundation.git at 0.9.14 (0.50s)
Computing version for https://github.com/objecthub/swift-sqliteexpress.git
Computed https://github.com/objecthub/swift-sqliteexpress.git at 1.0.3 (0.51s)
Computing version for https://github.com/objecthub/swift-commandlinekit.git
Computed https://github.com/objecthub/swift-commandlinekit.git at 0.3.4 (0.52s)
Computing version for https://github.com/objecthub/swift-markdownkit.git
Computed https://github.com/objecthub/swift-markdownkit.git at 1.1.5 (0.53s)
Computing version for https://github.com/objecthub/swift-numberkit.git
Computed https://github.com/objecthub/swift-numberkit.git at 2.4.1 (0.52s)
Creating working copy for https://github.com/apple/swift-atomics.git
Working copy of https://github.com/apple/swift-atomics.git resolved at 1.0.2
Creating working copy for https://github.com/objecthub/swift-markdownkit.git
Working copy of https://github.com/objecthub/swift-markdownkit.git resolved at 1.1.5
Creating working copy for https://github.com/objecthub/swift-numberkit.git
Working copy of https://github.com/objecthub/swift-numberkit.git resolved at 2.4.1
Creating working copy for https://github.com/objecthub/swift-commandlinekit.git
Working copy of https://github.com/objecthub/swift-commandlinekit.git resolved at 0.3.4
Creating working copy for https://github.com/objecthub/swift-sqliteexpress.git
Working copy of https://github.com/objecthub/swift-sqliteexpress.git resolved at 1.0.3
Creating working copy for https://github.com/weichsel/ZIPFoundation.git
Working copy of https://github.com/weichsel/ZIPFoundation.git resolved at 0.9.14
Building for debugging...
[220/220] Linking LispKitRepl
Build complete! (28.68s)
.build/debug/LispKitRepl -r Sources/LispKit/Resources -d LispKit
LispKit Shell 2.2.6
Copyright © 2016–2022 Matthias Zenger. All rights reserved.
> (exit)
[Scratch/swift-lispkit] /usr/bin/xcodebuild -version
Xcode 13.4.1
Build version 13F100
[Scratch/swift-lispkit] xcrun swift -version
swift-driver version: 1.45.2 Apple Swift version 5.6.1 (swiftlang-5.6.0.323.66 clang-1316.0.20.12)
Target: arm64-apple-macosx12.0
[Scratch/swift-lispkit] clang --version
Apple clang version 13.1.6 (clang-1316.0.21.2.5)
Target: arm64-apple-darwin21.5.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

objecthub avatar Jul 06 '22 03:07 objecthub

Hi, A few weeks and few system environment changes later I'm no longer able to reproduce the error.

One difference I noticed is that you seem to use a clang installation that does not come from Xcode (as it was installed via Homebrew). My guess is that this is what causes the problem.

On the one hand I agree that this could , since this a common root of such problems on the other hand in this case I'm still using the homebrew clang, and it successfully builds the project...

So for now I'm closing this.

bentxt avatar Aug 31 '22 21:08 bentxt