Skip to content
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

Generate Clang module maps during the build #6983

Merged
merged 1 commit into from Oct 31, 2023
Merged

Conversation

neonichu
Copy link
Member

@neonichu neonichu commented Oct 9, 2023

This moves generation of module maps for Clang targets into the build process.

@neonichu neonichu self-assigned this Oct 9, 2023
@neonichu
Copy link
Member Author

neonichu commented Oct 9, 2023

@swift-ci please smoke test

@neonichu
Copy link
Member Author

neonichu commented Oct 9, 2023

@swift-ci please test

@neonichu
Copy link
Member Author

/home/build-user/swiftpm/Sources/LLBuildManifest/BuildManifest.swift:15:8: error: no such module 'PackageLoading'
import PackageLoading
       ^

CMake build needs adjusting.

@neonichu
Copy link
Member Author

@swift-ci please test

@neonichu
Copy link
Member Author

@swift-ci please test windows

1 similar comment
@neonichu
Copy link
Member Author

@swift-ci please test windows

@neonichu
Copy link
Member Author

[92/610] Compiling llvmSupport StringRef.cpp
fatal error: module map file '/home/build-user/build/buildbot_incremental/swiftpm-linux-x86_64/x86_64-unknown-linux-gnu/release/llbuildNinja.build/module.modulemap' not found
fatal error: module map file '/home/build-user/build/buildbot_incremental/swiftpm-linux-x86_64/x86_64-unknown-linux-gnu/release/llbuildNinja.build/module.modulemap' not found

This looks relevant

@neonichu
Copy link
Member Author

Ah I think I understand the problem: we previously relied on module maps to always be present to allow compilation of dependent targets, but now we actually need to add a dependency on the module map generation in the dependent targets as well.

This is somewhat more involved since the dependent targets do not (and should not) know whether their dependencies have generated module maps, so we need a way to depend on the generation without depending on a concrete file. I believe Xcode's build system has a "modules ready" gate task for that purpose, but we don't have any such concept so far in SwiftPM's build system.

@neonichu
Copy link
Member Author

@swift-ci please test package compatibility

@neonichu
Copy link
Member Author

[/Users/ec2-user/jenkins/workspace-private/swift-package-manager-source-compat-suite-PR-macos/swift/utils/build-script] ERROR: can't find CMake (please install CMake)
Traceback (most recent call last):
  File "/Users/ec2-user/jenkins/workspace/swift-package-manager-source-compat-suite-PR-macos/./swift-source-compat-suite/run", line 331, in <module>
    sys.exit(main())
  File "/Users/ec2-user/jenkins/workspace/swift-package-manager-source-compat-suite-PR-macos/./swift-source-compat-suite/run", line 38, in main
    build_swift_toolchain(workspace, args)
  File "/Users/ec2-user/jenkins/workspace/swift-package-manager-source-compat-suite-PR-macos/./swift-source-compat-suite/run", line 299, in build_swift_toolchain
    common.check_execute(build_command, timeout=9999999)
  File "/Users/ec2-user/jenkins/workspace/swift-package-manager-source-compat-suite-PR-macos/swift-source-compat-suite/common.py", line 524, in check_execute
    raise ExecuteCommandFailure(command, returncode)
common.ExecuteCommandFailure: ExecuteCommandFailure(command="/Users/ec2-user/jenkins/workspace-private/swift-package-manager-source-compat-suite-PR-macos/swift/utils/build-script --preset=source_compat_suite_macos_RA --cmake-c-launcher=/usr/local/bin/sccache --cmake-cxx-launcher=/usr/local/bin/sccache install_destdir=/Users/ec2-user/jenkins/workspace-private/swift-package-manager-source-compat-suite-PR-macos/build/compat_macos/install install_prefix=/toolchain/usr install_symroot=/Users/ec2-user/jenkins/workspace-private/swift-package-manager-source-compat-suite-PR-macos/build/compat_macos/symroot installable_package=/Users/ec2-user/jenkins/workspace-private/swift-package-manager-source-compat-suite-PR-macos/build/compat_macos/root.tar.gz symbols_package=/Users/ec2-user/jenkins/workspace-private/swift-package-manager-source-compat-suite-PR-macos/build/compat_macos/root-symbols.tar.gz", returncode=1)

Looks like infra failure?

@neonichu
Copy link
Member Author

@swift-ci please test package compatibility

@neonichu
Copy link
Member Author

Looks like this failed similar to the reverted changes from #6988, but this should be using main?

@neonichu
Copy link
Member Author

@swift-ci please test package compatibility

1 similar comment
@neonichu
Copy link
Member Author

@swift-ci please test package compatibility

@neonichu
Copy link
Member Author

@swift-ci please test package compatibility

@neonichu
Copy link
Member Author

@swift-ci please test

@neonichu
Copy link
Member Author

Ah yes, need to update a few tests because the raw LLBuild manifest has changed.

@neonichu neonichu force-pushed the module-map-generation branch 2 times, most recently from de5a4d3 to 70715ef Compare October 18, 2023 21:53
@neonichu
Copy link
Member Author

@swift-ci please test

@neonichu
Copy link
Member Author

@swift-ci please test windows

@neonichu
Copy link
Member Author

@swift-ci please test package compatibility

@neonichu
Copy link
Member Author

# command stderr:
Error: 'rm' command failed, [WinError 32] The process cannot access the file because it is being used by another process.
error: command failed with exit status: 1

@neonichu
Copy link
Member Author

@swift-ci please test

@neonichu
Copy link
Member Author

@swift-ci please test windows

@neonichu
Copy link
Member Author

@swift-ci please test package compatibility

@neonichu
Copy link
Member Author

Looks like there's still a race here (most likely due to an unexpressed dependency on the generated module map):

[123/621] Compiling llvmSupport APSInt.cpp
fatal error: module map file '/Users/ec2-user/jenkins/workspace/swift-package-manager-PR-macos-smoke-test/branch-main/build/buildbot_incremental/swiftpm-macosx-x86_64/x86_64-apple-macosx/release/llbuildBasic.build/module.modulemap' not found
1 error generated.

@neonichu
Copy link
Member Author

We're missing a dependency from Swift targets to the modulesReady node of Clang targets.

This moves generation of module maps for Clang targets into the build process.
@neonichu
Copy link
Member Author

@swift-ci please test

@neonichu
Copy link
Member Author

@swift-ci please test windows

@neonichu
Copy link
Member Author

@swift-ci please test package compatibility

@neonichu
Copy link
Member Author

Also cc @m-i-r-z-a since this touches the build system.

@neonichu
Copy link
Member Author

@swift-ci please test package compatibility

Copy link
Member

@tomerd tomerd left a comment

Choose a reason for hiding this comment

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

not familiar with the details but the change conceptually makes sense and i assume the logic is the same and just moved into the build graph execution. do we feel test coverage is enough?

@neonichu
Copy link
Member Author

do we feel test coverage is enough?

It's quite difficult for tests to discover issues with this since the more tricky mistakes will just result in a race which the typical small test case will almost always win. Even with compatibility test suite plus toolchain build, the missing dependency in Swift tasks only showed up once in several builds.

So I wouldn't say it's enough, but I also don't have any concrete ideas on what to add.

@neonichu
Copy link
Member Author

One failure that looks very much unrelated, it's a compiler crash:

Apple Swift version 5.11-dev (LLVM b41a79e3732f732, Swift e9b297a0d22d5a3)
Target: x86_64-apple-macosx10.13
/Users/ec2-user/jenkins/workspace-private/swift-package-manager-source-compat-suite-PR-macos/build/compat_macos/install/toolchain/usr/bin/swift-frontend -frontend -c /Users/ec2-user/jenkins/workspace/swift-package-manager-source-compat-suite-PR-macos/swift-source-compat-suite/project_cache/BricBrac/Sources/BricBrac/Brac.swift /Users/ec2-user/jenkins/workspace/swift-package-manager-source-compat-suite-PR-macos/swift-source-compat-suite/project_cache/BricBrac/Sources/BricBrac/Bric.swift /Users/ec2-user/jenkins/workspace/swift-package-manager-source-compat-suite-PR-macos/swift-source-compat-suite/project_cache/BricBrac/Sources/BricBrac/BricBrac.swift /Users/ec2-user/jenkins/workspace/swift-package-manager-source-compat-suite-PR-macos/swift-source-compat-suite/project_cache/BricBrac/Sources/BricBrac/BricEncoder.swift /Users/ec2-user/jenkins/workspace/swift-package-manager-source-compat-suite-PR-macos/swift-source-compat-suite/project_cache/BricBrac/Sources/BricBrac/BricIO+Foundation.swift /Users/ec2-user/jenkins/workspace/swift-package-manager-source-compat-suite-PR-macos/swift-source-compat-suite/project_cache/BricBrac/Sources/BricBrac/BricIO.swift /Users/ec2-user/jenkins/workspace/swift-package-manager-source-compat-suite-PR-macos/swift-source-compat-suite/project_cache/BricBrac/Sources/BricBrac/BricPointer.swift /Users/ec2-user/jenkins/workspace/swift-package-manager-source-compat-suite-PR-macos/swift-source-compat-suite/project_cache/BricBrac/Sources/BricBrac/Defaultables.swift /Users/ec2-user/jenkins/workspace/swift-package-manager-source-compat-suite-PR-macos/swift-source-compat-suite/project_cache/BricBrac/Sources/BricBrac/JSONParser.swift /Users/ec2-user/jenkins/workspace/swift-package-manager-source-compat-suite-PR-macos/swift-source-compat-suite/project_cache/BricBrac/Sources/BricBrac/JSONSchema.swift /Users/ec2-user/jenkins/workspace/swift-package-manager-source-compat-suite-PR-macos/swift-source-compat-suite/project_cache/BricBrac/Sources/BricBrac/Structures.swift -supplementary-output-file-map /var/folders/7n/r31lzfjx6556jgc6vg55_cg80000gn/T/TemporaryDirectory.OvpCuH/supplementaryOutputs-1 -target x86_64-apple-macosx10.13 -enable-objc-interop -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk -I /Users/ec2-user/jenkins/workspace/swift-package-manager-source-compat-suite-PR-macos/swift-source-compat-suite/project_cache/BricBrac/.build/x86_64-apple-macosx/release -I /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib -F /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks -g -module-cache-path /Users/ec2-user/jenkins/workspace/swift-package-manager-source-compat-suite-PR-macos/swift-source-compat-suite/project_cache/BricBrac/.build/x86_64-apple-macosx/release/ModuleCache -swift-version 5 -O -D SWIFT_PACKAGE -new-driver-path /Users/ec2-user/jenkins/workspace-private/swift-package-manager-source-compat-suite-PR-macos/build/compat_macos/install/toolchain/usr/bin/swift-driver -empty-abi-descriptor -resource-dir /Users/ec2-user/jenkins/workspace-private/swift-package-manager-source-compat-suite-PR-macos/build/compat_macos/install/toolchain/usr/lib/swift -Xcc -isysroot -Xcc /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk -Xcc -F -Xcc /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks -Xcc -fPIC -Xcc -g -module-name BricBrac -target-sdk-version 13.1 -target-sdk-name macosx13.1 -external-plugin-path /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk/usr/lib/swift/host/plugins#/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk/usr/bin/swift-plugin-server -external-plugin-path /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk/usr/local/lib/swift/host/plugins#/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk/usr/bin/swift-plugin-server -external-plugin-path /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib/swift/host/plugins#/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/bin/swift-plugin-server -external-plugin-path /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/local/lib/swift/host/plugins#/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/bin/swift-plugin-server -plugin-path /Users/ec2-user/jenkins/workspace-private/swift-package-manager-source-compat-suite-PR-macos/build/compat_macos/install/toolchain/usr/lib/swift/host/plugins -plugin-path /Users/ec2-user/jenkins/workspace-private/swift-package-manager-source-compat-suite-PR-macos/build/compat_macos/install/toolchain/usr/local/lib/swift/host/plugins -enable-default-cmo -parse-as-library -num-threads 12 -o /Users/ec2-user/jenkins/workspace/swift-package-manager-source-compat-suite-PR-macos/swift-source-compat-suite/project_cache/BricBrac/.build/x86_64-apple-macosx/release/BricBrac.build/Brac.swift.o -o /Users/ec2-user/jenkins/workspace/swift-package-manager-source-compat-suite-PR-macos/swift-source-compat-suite/project_cache/BricBrac/.build/x86_64-apple-macosx/release/BricBrac.build/Bric.swift.o -o /Users/ec2-user/jenkins/workspace/swift-package-manager-source-compat-suite-PR-macos/swift-source-compat-suite/project_cache/BricBrac/.build/x86_64-apple-macosx/release/BricBrac.build/BricBrac.swift.o -o /Users/ec2-user/jenkins/workspace/swift-package-manager-source-compat-suite-PR-macos/swift-source-compat-suite/project_cache/BricBrac/.build/x86_64-apple-macosx/release/BricBrac.build/BricEncoder.swift.o -o /Users/ec2-user/jenkins/workspace/swift-package-manager-source-compat-suite-PR-macos/swift-source-compat-suite/project_cache/BricBrac/.build/x86_64-apple-macosx/release/BricBrac.build/BricIO+Foundation.swift.o -o /Users/ec2-user/jenkins/workspace/swift-package-manager-source-compat-suite-PR-macos/swift-source-compat-suite/project_cache/BricBrac/.build/x86_64-apple-macosx/release/BricBrac.build/BricIO.swift.o -o /Users/ec2-user/jenkins/workspace/swift-package-manager-source-compat-suite-PR-macos/swift-source-compat-suite/project_cache/BricBrac/.build/x86_64-apple-macosx/release/BricBrac.build/BricPointer.swift.o -o /Users/ec2-user/jenkins/workspace/swift-package-manager-source-compat-suite-PR-macos/swift-source-compat-suite/project_cache/BricBrac/.build/x86_64-apple-macosx/release/BricBrac.build/Defaultables.swift.o -o /Users/ec2-user/jenkins/workspace/swift-package-manager-source-compat-suite-PR-macos/swift-source-compat-suite/project_cache/BricBrac/.build/x86_64-apple-macosx/release/BricBrac.build/JSONParser.swift.o -o /Users/ec2-user/jenkins/workspace/swift-package-manager-source-compat-suite-PR-macos/swift-source-compat-suite/project_cache/BricBrac/.build/x86_64-apple-macosx/release/BricBrac.build/JSONSchema.swift.o -o /Users/ec2-user/jenkins/workspace/swift-package-manager-source-compat-suite-PR-macos/swift-source-compat-suite/project_cache/BricBrac/.build/x86_64-apple-macosx/release/BricBrac.build/Structures.swift.o
error: compile command failed due to signal 6 (use -v to see invocation)
/Users/ec2-user/jenkins/workspace/swift-package-manager-source-compat-suite-PR-macos/swift-source-compat-suite/project_cache/BricBrac/Sources/BricBrac/BricBrac.swift:69:27: warning: generic parameter 'T' shadows generic parameter from outer scope with the same name; this is an error in Swift 6
    public static func ==<T>(lhs: NotBrac<T>, rhs: NotBrac<T>) -> Bool {
                          ^
/Users/ec2-user/jenkins/workspace/swift-package-manager-source-compat-suite-PR-macos/swift-source-compat-suite/project_cache/BricBrac/Sources/BricBrac/BricBrac.swift:31:23: note: 'T' previously declared here
public struct NotBrac<T> : ExpressibleByNilLiteral {
                      ^
Assertion failed: (index < getNumSILArguments()), function getSILArgumentConvention, file SILArgument.cpp, line 89.
Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the crash backtrace.
Stack dump:

@neonichu neonichu merged commit 6b0d8b7 into main Oct 31, 2023
5 of 6 checks passed
@neonichu neonichu deleted the module-map-generation branch October 31, 2023 01:20
neonichu added a commit that referenced this pull request Oct 31, 2023
shahmishal pushed a commit that referenced this pull request Oct 31, 2023
Reverts #6983

We're seeing errors like

```
fatal error: module map file '/Users/ec2-user/jenkins/workspace/swift-PR-macos-smoke-test/branch-main/build/buildbot_incremental/swiftdriver-macosx-x86_64/x86_64-apple-macosx/release/llbuildBasic.build/module.modulemap' not found
```

on various CI jobs and should revert this to unblock.
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.

None yet

3 participants