From af6b24b54253a6500397ac4176d481e728d7ec61 Mon Sep 17 00:00:00 2001 From: Kuba Mracek Date: Tue, 10 Dec 2024 15:56:37 -0800 Subject: [PATCH 1/2] [embedded] Don't emit metadata references from C++ interop --- lib/IRGen/IRGenSIL.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/IRGen/IRGenSIL.cpp b/lib/IRGen/IRGenSIL.cpp index 5d48d165b2a33..aad546c6cf053 100644 --- a/lib/IRGen/IRGenSIL.cpp +++ b/lib/IRGen/IRGenSIL.cpp @@ -2564,7 +2564,7 @@ void IRGenModule::emitSILFunction(SILFunction *f) { return; // Type metadata for foreign references is not yet supported on Windows. Bug #76168. - if (Context.LangOpts.EnableCXXInterop && + if (Context.LangOpts.EnableCXXInterop && !Context.LangOpts.hasFeature(Feature::Embedded) && f->getLinkage() == SILLinkage::Public && !Context.LangOpts.Target.isOSWindows()) noteUseOfMetadataByCXXInterop(IRGen, f, TypeExpansionContext(*f)); From 77c6494cdb1dd3cafc9663c86856a5fc5b9f7228 Mon Sep 17 00:00:00 2001 From: Kuba Mracek Date: Thu, 12 Dec 2024 15:08:58 -0800 Subject: [PATCH 2/2] [embedded] Add test/embedded/cxx-no-metadata.swift testcase --- test/embedded/cxx-no-metadata.swift | 30 +++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 test/embedded/cxx-no-metadata.swift diff --git a/test/embedded/cxx-no-metadata.swift b/test/embedded/cxx-no-metadata.swift new file mode 100644 index 0000000000000..9fe31b91487d3 --- /dev/null +++ b/test/embedded/cxx-no-metadata.swift @@ -0,0 +1,30 @@ +// RUN: %empty-directory(%t) +// RUN: %{python} %utils/split_file.py -o %t %s + +// RUN: %target-swift-frontend -I %t %t/Main.swift -enable-experimental-feature Embedded -cxx-interoperability-mode=default -c -o %t/a.o -Rmodule-loading + +// REQUIRES: swift_in_compiler +// REQUIRES: OS=macosx || OS=linux-gnu +// REQUIRES: swift_feature_Embedded + +// BEGIN header.h + +// C++ +struct CxxStruct { + int field; +}; + +// BEGIN module.modulemap + +module MyModule { + header "header.h" +} + +// BEGIN Main.swift + +import MyModule + +public func foo(ptr: UnsafeMutablePointer?) { +} + +foo(ptr: nil)