Skip to content

Do not prefix relative SDK paths twice #76620

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

Merged
merged 1 commit into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion lib/Serialization/ModuleFileSharedCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1798,7 +1798,7 @@ bool ModuleFileSharedCore::hasSourceInfo() const {
std::string ModuleFileSharedCore::resolveModuleDefiningFilePath(const StringRef SDKPath) const {
if (!ModuleInterfacePath.empty()) {
std::string interfacePath = ModuleInterfacePath.str();
if (llvm::sys::path::is_relative(interfacePath)) {
if (llvm::sys::path::is_relative(interfacePath) && !ModuleInterfacePath.starts_with(SDKPath)) {
SmallString<128> absoluteInterfacePath(SDKPath);
llvm::sys::path::append(absoluteInterfacePath, interfacePath);
return absoluteInterfacePath.str().str();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// swift-interface-format-version: 1.0
// swift-module-flags: -target arm64-apple-macosx15.0 -module-name OtherModule -O

import Swift

public struct OtherStruct {
var x : Int
public init()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// swift-interface-format-version: 1.0
// swift-module-flags: -disable-objc-attr-requires-foundation-module -target arm64-apple-macosx15.0 -enable-objc-interop -enable-library-evolution -module-link-name swiftCore -parse-stdlib -swift-version 5 -O -library-level api -enforce-exclusivity=unchecked -enable-experimental-concise-pound-file -target-min-inlining-version min -module-name Swift

public struct Int {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// swift-interface-format-version: 1.0
// swift-module-flags: -disable-objc-attr-requires-foundation-module -target arm64-apple-macosx15.0 -enable-objc-interop -enable-library-evolution -module-link-name swiftSwiftOnoneSupport -parse-stdlib -swift-version 5 -O -library-level api -enforce-exclusivity=unchecked -target-min-inlining-version min -module-name SwiftOnoneSupport

import Swift

public let x: Swift.Int
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// swift-interface-format-version: 1.0
// swift-module-flags: -disable-objc-attr-requires-foundation-module -target arm64-apple-macosx15.0 -enable-objc-interop -enable-library-evolution -module-link-name swift_Concurrency -parse-stdlib -swift-version 5 -O -library-level api -enforce-exclusivity=unchecked -target-min-inlining-version min -module-name _Concurrency

import Swift

@frozen public enum Task {}

public let x: Swift.Int
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// swift-interface-format-version: 1.0
// swift-module-flags: -target arm64-apple-macosx15.0 -enable-objc-interop -enable-library-evolution -module-link-name swift_StringProcessing -swift-version 5 -O -library-level api -enforce-exclusivity=unchecked -target-min-inlining-version min -module-name _StringProcessing

import Swift

public let x: Swift.Int
15 changes: 15 additions & 0 deletions test/ModuleInterface/relative-sdk-path.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// RUN: %empty-directory(%t.relative_sdk_path)
// RUN: %empty-directory(%t.mcp)

// RUN: cp -R %S/Inputs/stdlib_rebuild %t.relative_sdk_path/
// RUN: cd %t.relative_sdk_path

// RUN: %target-swift-frontend(mock-sdk: -sdk stdlib_rebuild -module-cache-path %t.mcp) -target arm64-apple-macosx15.0 -resource-dir /dev/null -o %t.relative_sdk_path -emit-object %s

// REQUIRES: OS=macosx

import OtherModule

func fn(_: Int) {
let _ = OtherStruct()
}