Skip to content

FreeBSD: Link C++ runtimes when Cxx interop is enabled #82355

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

etcwilde
Copy link
Member

This patch gets all of the C++ interop tests passing on FreeBSD. There were two bugs.

First, the Swift tests use the old Swift driver, which only used the experimental C++ interop flag to determine whether or not to use clang++ or clang. Changing the legacy driver to align more closely with the behavior of the Swift driver:

      var cxxCompatEnabled = parsedOptions.hasArgument(.enableExperimentalCxxInterop)
      if let cxxInteropMode = parsedOptions.getLastArgument(.cxxInteroperabilityMode) {
        if cxxInteropMode.asSingle != "off" {
          cxxCompatEnabled = true
        }
      }
      // ...
      let clangTool: Tool = cxxCompatEnabled ? .clangxx : .clang
      // ...

Second, there were several tests that didn't pass the flag to the driver, but to the frontend, so that didn't fix all of the tests. The tests passing it to the frontend are relying on the autolink mechanism to automatically pull in a C++ runtime and an overlay. A separate patch adds FreeBSD to the list of OS's to automatically link the C++ runtime when C++ interop is enabled.

Third, this isn't fixing bugs, but just enabling a handful of tests that are passing but were marked unsupported.

etcwilde added 3 commits June 17, 2025 10:42
This aligns the old driver with the behavior of the new driver.
When building with C++ interop enabled, it's important that we link a
C++ runtime, which is handled by the clang++ driver.
The new driver uses clang++ when linking with C++ enabled, either
through the c++ interoperability mode flag or the experimental C++
interop flag. The old driver only enabled it with the experimental C++
interop flag. This results in the C++ interop tests failing on FreeBSD
and a behavioral difference between what we are testing and what we are
shipping.
This hooks up the autolink mechanism to link the C++ runtime when C++
interop is enabled on FreeBSD.
Some of these tests were marked as unsupported since they were only
checking for macOS and Linux. They seem to be passing on FreeBSD as
well, so enabling them here.
@etcwilde
Copy link
Member Author

@swift-ci please test

@etcwilde etcwilde moved this to In Progress in Swift on FreeBSD Jun 18, 2025
@etcwilde etcwilde added the c++ interop Feature: Interoperability with C++ label Jun 18, 2025
Copy link
Contributor

@Xazax-hun Xazax-hun left a comment

Choose a reason for hiding this comment

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

LG, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ interop Feature: Interoperability with C++ FreeBSD Platform: FreeBSD
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

3 participants