Skip to content

Commit 33a89a6

Browse files
modulewrap: Disable ObjC interop by default on non-Darwin platforms
0a5653d started to call `IGM.finalize()`, which leads the Clang instance to emit ObjC metadata sections when the ObjC interop is enabled. Emitting ObjC metadata sections is not well supported on non-Darwin platforms and causes crashes for WebAssembly and COFF object formats[^1]. modulewrap tool did not configure the ObjC interop option, so it always enabled the ObjC interop. This patch aligns the default ObjC interop value with other tools by disabling it on non-Darwin platforms. [^1]: https://github.com/apple/llvm-project/blob/stable/20230725/clang/lib/CodeGen/CGObjCMac.cpp#L5068-L5074
1 parent 5c01e7f commit 33a89a6

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

lib/DriverTool/modulewrap_main.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ class ModuleWrapInvocation {
4848
llvm::Triple TargetTriple;
4949
std::vector<std::string> InputFilenames;
5050
bool UseSharedResourceFolder = true;
51+
bool EnableObjCInterop = true;
5152

5253
public:
5354
bool hasSingleInput() const { return InputFilenames.size() == 1; }
@@ -65,6 +66,7 @@ class ModuleWrapInvocation {
6566
llvm::Triple &getTargetTriple() { return TargetTriple; }
6667

6768
bool useSharedResourceFolder() { return UseSharedResourceFolder; }
69+
bool enableObjCInterop() { return EnableObjCInterop; }
6870

6971
int parseArgs(llvm::ArrayRef<const char *> Args, DiagnosticEngine &Diags) {
7072
using namespace options;
@@ -124,6 +126,9 @@ class ModuleWrapInvocation {
124126
UseSharedResourceFolder = false;
125127
}
126128

129+
EnableObjCInterop = ParsedArgs.hasFlag(OPT_enable_objc_interop,
130+
OPT_disable_objc_interop, TargetTriple.isOSDarwin());
131+
127132
return 0;
128133
}
129134
};
@@ -184,6 +189,7 @@ int modulewrap_main(ArrayRef<const char *> Args, const char *Argv0,
184189
symbolgraphgen::SymbolGraphOptions SymbolGraphOpts;
185190
CASOptions CASOpts;
186191
LangOpts.Target = Invocation.getTargetTriple();
192+
LangOpts.EnableObjCInterop = Invocation.enableObjCInterop();
187193
ASTContext &ASTCtx = *ASTContext::get(
188194
LangOpts, TypeCheckOpts, SILOpts, SearchPathOpts, ClangImporterOpts,
189195
SymbolGraphOpts, CASOpts, SrcMgr, Instance.getDiags(),

0 commit comments

Comments
 (0)