Skip to content

Fix the hardcoded Swift AST section / segment name for Mach-O #32362

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

Merged
merged 1 commit into from
Jun 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions include/swift/Basic/Dwarf.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ namespace swift {
/// The DWARF version emitted by the Swift compiler.
const unsigned DWARFVersion = 4;

static const char MachOASTSegmentName[] = "__SWIFT";
static const char MachOASTSectionName[] = "__ast";
static const char MachOASTSegmentName[] = "__DWARF";
static const char MachOASTSectionName[] = "__swift_ast";
static const char ELFASTSectionName[] = ".swift_ast";
static const char COFFASTSectionName[] = "swiftast";
static const char WasmASTSectionName[] = ".swift_ast";
Expand Down
4 changes: 4 additions & 0 deletions lib/IRGen/IRGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1364,6 +1364,10 @@ swift::createSwiftModuleObjectFile(SILModule &SILMod, StringRef Buffer,
assert(!Ctx.hadError());

IRGenOptions Opts;
// This tool doesn't pass the necessary runtime library path to
// TypeConverter, because this feature isn't needed.
Opts.DisableLegacyTypeInfo = true;

Opts.OutputKind = IRGenOutputKind::ObjectFile;
IRGenerator irgen(Opts, SILMod);

Expand Down
14 changes: 14 additions & 0 deletions test/DebugInfo/ASTSection-single.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// REQUIRES: executable_test
// REQUIRES: swift_tools_extra

// Test that a module-wrapped Swift AST section can be parsed.

// RUN: %empty-directory(%t)

// RUN: echo "public let a0 = 0" >%t/a0.swift
// RUN: %target-build-swift %t/a0.swift -emit-module -emit-module-path %t/a0.swiftmodule
// RUN: %target-swift-modulewrap %t/a0.swiftmodule -o %t/a0-mod.o

// RUN: %lldb-moduleimport-test -verbose %t/a0-mod.o | %FileCheck %s
// CHECK: Importing a0... ok!

2 changes: 1 addition & 1 deletion test/DebugInfo/ASTSection_linker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// RUN: %swift-ide-test -test-CompilerInvocation-from-module -source-filename=%t/ASTSection.swiftmodule

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

// Test the symbol table entry.
Expand Down