Skip to content

Commit 403b2bf

Browse files
Merge pull request #32362 from adrian-prantl/63991514
Fix the hardcoded Swift AST section / segment name for Mach-O
2 parents 2a377bc + f20d567 commit 403b2bf

File tree

4 files changed

+21
-3
lines changed

4 files changed

+21
-3
lines changed

include/swift/Basic/Dwarf.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ namespace swift {
2323
/// The DWARF version emitted by the Swift compiler.
2424
const unsigned DWARFVersion = 4;
2525

26-
static const char MachOASTSegmentName[] = "__SWIFT";
27-
static const char MachOASTSectionName[] = "__ast";
26+
static const char MachOASTSegmentName[] = "__DWARF";
27+
static const char MachOASTSectionName[] = "__swift_ast";
2828
static const char ELFASTSectionName[] = ".swift_ast";
2929
static const char COFFASTSectionName[] = "swiftast";
3030
static const char WasmASTSectionName[] = ".swift_ast";

lib/IRGen/IRGen.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1364,6 +1364,10 @@ swift::createSwiftModuleObjectFile(SILModule &SILMod, StringRef Buffer,
13641364
assert(!Ctx.hadError());
13651365

13661366
IRGenOptions Opts;
1367+
// This tool doesn't pass the necessary runtime library path to
1368+
// TypeConverter, because this feature isn't needed.
1369+
Opts.DisableLegacyTypeInfo = true;
1370+
13671371
Opts.OutputKind = IRGenOutputKind::ObjectFile;
13681372
IRGenerator irgen(Opts, SILMod);
13691373

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// REQUIRES: executable_test
2+
// REQUIRES: swift_tools_extra
3+
4+
// Test that a module-wrapped Swift AST section can be parsed.
5+
6+
// RUN: %empty-directory(%t)
7+
8+
// RUN: echo "public let a0 = 0" >%t/a0.swift
9+
// RUN: %target-build-swift %t/a0.swift -emit-module -emit-module-path %t/a0.swiftmodule
10+
// RUN: %target-swift-modulewrap %t/a0.swiftmodule -o %t/a0-mod.o
11+
12+
// RUN: %lldb-moduleimport-test -verbose %t/a0-mod.o | %FileCheck %s
13+
// CHECK: Importing a0... ok!
14+

test/DebugInfo/ASTSection_linker.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
// RUN: %swift-ide-test -test-CompilerInvocation-from-module -source-filename=%t/ASTSection.swiftmodule
77

88
// Test the inline section mechanism.
9-
// RUN: %target-ld %t/ASTSection.o -sectcreate __SWIFT __ast %t/ASTSection.swiftmodule -o %t/ASTSection.dylib -dylib -lSystem -lobjc
9+
// RUN: %target-ld %t/ASTSection.o -sectcreate __DWARF __swift_ast %t/ASTSection.swiftmodule -o %t/ASTSection.dylib -dylib -lSystem -lobjc
1010
// RUN: %lldb-moduleimport-test -verbose %t/ASTSection.dylib | %FileCheck %s
1111

1212
// Test the symbol table entry.

0 commit comments

Comments
 (0)