Skip to content

SR-7154: swiftpm tests fail if --debug-foundation option is used. #1544

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

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Utilities/bootstrap
Original file line number Diff line number Diff line change
Expand Up @@ -816,6 +816,9 @@ def main():
parser.add_argument("--swiftc", dest="swiftc_path",
help="path to the swift compiler [%(default)s]",
metavar="PATH")
parser.add_argument("--swift-lib-dir", dest="swift_lib_dir",
help="path to the swift built library directory",
metavar="PATH")
parser.add_argument("--sbt", dest="sbt_path",
help="path to the 'swift-build-tool' tool "
"[%(default)s]",
Expand Down Expand Up @@ -1052,6 +1055,9 @@ def main():

env_cmd = ["env", "SWIFT_EXEC=" + os.path.join(bindir, "swiftc"),
"SWIFTPM_BUILD_DIR=" + build_path]

if args.swift_lib_dir:
env_cmd.append("LD_LIBRARY_PATH=" + args.swift_lib_dir)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we put a symlink in the fake toolchain instead of using LD_LIBRARY_PATH or that doesn't work?

Copy link
Author

Choose a reason for hiding this comment

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

You can do it that way and it was the original way I had it working, however it also requires adding a symlink in Foundation's build directory as well. The other downside is that if in the future more libraries get built by the main swift repo in addition to libswiftCore.so and libswiftSwiftOnone.so then symlinks will also be required there.

However thinking about it, this LD_LIBRARY_PATH could possibly be exported in the swift/utils/build-script-impl script the same way it is setup when running TestFoundation (see https://github.com/spevans/swift/blob/ce45ea3eeaca9a30e257be7fbe5746a67d5b2788/utils/build-script-impl#L2950) and then this change wouldnt be required.

Copy link
Contributor

Choose a reason for hiding this comment

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

We have several tests in SwiftPM that build Swift packages in debug mode. I don't understand why we don't hit the same problem there. @jrose-apple said these libraries can be considered part of stdlib.

Copy link
Author

Choose a reason for hiding this comment

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

I don't think it matters whether the packages that SwiftPM builds are in debug or release mode but whether the libFoundation.so they link to is in release or debug mode. In debug mode it links to libswiftSwiftOnone.so which it can't find in the build directories without this path.
The --debug-foundation flag controls whether the libFoundation.so is built in debug mode.

Copy link
Contributor

Choose a reason for hiding this comment

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

@jrose-apple said these libraries are required if something is being built with -Onone and we have several test packages that are built with -Onone. Presence of libFoundation.so shouldn't matter.

Copy link
Contributor

Choose a reason for hiding this comment

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

Can we have an investigation on this behavior and why and how it affects SwiftPM tests? It is blocking Foundation adoption of @testable import.

Copy link
Contributor

Choose a reason for hiding this comment

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

When you build with -Onone, you gain a dependency on libswiftSwiftOnoneSupport.so/.a (yes, it's silly that there are two "swift"s in there). It shouldn't have anything to do with @testable import.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'll take a closer look tomm...

if args.sysroot:
env_cmd.append("SYSROOT=" + args.sysroot)
cmd = env_cmd + [bootstrapped_product] + build_flags
Expand Down