Skip to content

Conversation

@finagolfin
Copy link
Member

Cherrypick of #64103

Explanation: The 5.8 release has an incorrect relative runpath added to the compiler on linux, the second one:

> readelf -d swift-5.8-RELEASE-ubuntu20.04/usr/bin/swift-frontend | ag runpath
 0x000000000000001d (RUNPATH)            Library runpath: [$ORIGIN/../lib/swift/linux:$ORIGIN/../../lib/swift/linux]

This pull fixes that, removing a mild security risk when running the compiler.

Scope: Only affects the compiler runpath on linux

Issue: None

Risk: low, as it only removes an unused runpath for the linux compiler

Testing: Passed all CI on trunk

Reviewer: @edymtt

@finagolfin finagolfin requested a review from a team as a code owner May 25, 2023 09:32
@edymtt
Copy link
Contributor

edymtt commented May 25, 2023

@swift-ci please test

@edymtt
Copy link
Contributor

edymtt commented May 25, 2023

@swift-ci please build toolchain

@edymtt edymtt added 🍒 release cherry pick Flag: Release branch cherry picks swift 5.8 labels May 25, 2023
@finagolfin
Copy link
Member Author

Mac CI failure is unrelated:

Users/ec2-user/jenkins/workspace/swift-PR-macos/branch-release/5.8/build/buildbot_incremental/toolchain-macosx-x86_64/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc -output-file-map Sources/PackageDescription/CMakeFiles/PackageDescription.dir/Debug/output-file-map.json -incremental -j 12 -emit-library -o pm/ManifestAPI/libPackageDescription.dylib -module-name PackageDescription -module-link-name PackageDescription -emit-module -emit-module-path pm/ManifestAPI/PackageDescription.swiftmodule -emit-dependencies -DPackageDescription_EXPORTS -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk -module-cache-path "/Users/ec2-user/jenkins/workspace/swift-PR-macos/branch-release/5.8/build/buildbot_incremental/swiftpm-macosx-x86_64/x86_64-apple-macosx/bootstrap/module-cache" -g -swift-version 5 -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -package-description-version 999.0 -enable-library-evolution -emit-module-interface-path /Users/ec2-user/jenkins/workspace/swift-PR-macos/branch-release/5.8/build/buildbot_incremental/swiftpm-macosx-x86_64/x86_64-apple-macosx/bootstrap/pm/ManifestAPI/PackageDescription.swiftinterface  /Users/ec2-user/jenkins/workspace/swift-PR-macos/branch-release/5.8/swiftpm/Sources/PackageDescription/BuildSettings.swift /Users/ec2-user/jenkins/workspace/swift-PR-macos/branch-release/5.8/swiftpm/Sources/PackageDescription/Context.swift /Users/ec2-user/jenkins/workspace/swift-PR-macos/branch-release/5.8/swiftpm/Sources/PackageDescription/ContextModel.swift /Users/ec2-user/jenkins/workspace/swift-PR-macos/branch-release/5.8/swiftpm/Sources/PackageDescription/LanguageStandardSettings.swift /Users/ec2-user/jenkins/workspace/swift-PR-macos/branch-release/5.8/swiftpm/Sources/PackageDescription/PackageDescription.swift /Users/ec2-user/jenkins/workspace/swift-PR-macos/branch-release/5.8/swiftpm/Sources/PackageDescription/PackageDescriptionSerialization.swift /Users/ec2-user/jenkins/workspace/swift-PR-macos/branch-release/5.8/swiftpm/Sources/PackageDescription/PackageDependency.swift /Users/ec2-user/jenkins/workspace/swift-PR-macos/branch-release/5.8/swiftpm/Sources/PackageDescription/PackageRequirement.swift /Users/ec2-user/jenkins/workspace/swift-PR-macos/branch-release/5.8/swiftpm/Sources/PackageDescription/Product.swift /Users/ec2-user/jenkins/workspace/swift-PR-macos/branch-release/5.8/swiftpm/Sources/PackageDescription/Resource.swift /Users/ec2-user/jenkins/workspace/swift-PR-macos/branch-release/5.8/swiftpm/Sources/PackageDescription/SupportedPlatforms.swift /Users/ec2-user/jenkins/workspace/swift-PR-macos/branch-release/5.8/swiftpm/Sources/PackageDescription/Target.swift /Users/ec2-user/jenkins/workspace/swift-PR-macos/branch-release/5.8/swiftpm/Sources/PackageDescription/Version.swift /Users/ec2-user/jenkins/workspace/swift-PR-macos/branch-release/5.8/swiftpm/Sources/PackageDescription/Version+StringLiteralConvertible.swift -Xlinker -install_name -Xlinker @rpath/libPackageDescription.dylib -Xlinker -install_name -Xlinker @rpath/libPackageDescription.dylib    && :
<unknown>:0: error: unable to execute command: Terminated: 15
<unknown>:0: error: compile command failed due to signal 15 (use -v to see invocation)

@edymtt
Copy link
Contributor

edymtt commented May 25, 2023

@swift-ci please test macOS

1 similar comment
@edymtt
Copy link
Contributor

edymtt commented May 26, 2023

@swift-ci please test macOS

@edymtt
Copy link
Contributor

edymtt commented May 29, 2023

The generated toolchains for Linux and macOS look good rpath-wise

$ readelf -d usr/bin/swift-frontend | grep -E "File:|runpath"
 0x000000000000001d (RUNPATH)            Library runpath: [$ORIGIN/../lib/swift/linux]
> otool -lv macos/Library/Developer/Toolchains/swift-PR-66122-705.xctoolchain/usr/bin/swift-frontend | grep -A2 RPATH
          cmd LC_RPATH
      cmdsize 32
         path /usr/lib/swift (offset 12)
--
          cmd LC_RPATH
      cmdsize 48
         path @executable_path/../lib/swift/host (offset 12)

@finagolfin
Copy link
Member Author

Ping @tomerd, can we get this in for the next patch release now that 5.8.1 shipped?

@edymtt edymtt merged commit e2255b6 into swiftlang:release/5.8 Jun 14, 2023
@finagolfin finagolfin deleted the release/5.8 branch June 14, 2023 16:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🍒 release cherry pick Flag: Release branch cherry picks

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants