Skip to content

Commit 9b55842

Browse files
authored
Merge pull request swiftlang#567 from swiftlang/owenv/frame-pointers
Add settings to control frame pointer omission
2 parents 99ab50b + 380f251 commit 9b55842

File tree

3 files changed

+112
-0
lines changed

3 files changed

+112
-0
lines changed

Sources/SWBUniversalPlatform/Specs/Clang.xcspec

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2934,6 +2934,25 @@
29342934
NO = ();
29352935
};
29362936
},
2937+
{
2938+
Name = "CLANG_OMIT_FRAME_POINTERS";
2939+
Type = Enumeration;
2940+
Values = (
2941+
"compiler-default",
2942+
YES,
2943+
NO,
2944+
);
2945+
CommandLineArgs = {
2946+
YES = (
2947+
"-fomit-frame-pointer",
2948+
);
2949+
NO = (
2950+
"-fno-omit-frame-pointer",
2951+
);
2952+
"<<otherwise>>" = ();
2953+
};
2954+
DefaultValue = "compiler-default";
2955+
},
29372956
// Index-while-building options, not visible in build settings.
29382957
{
29392958
Name = "CLANG_INDEX_STORE_PATH";

Sources/SWBUniversalPlatform/Specs/Swift.xcspec

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -995,6 +995,25 @@
995995
DefaultValue = "$(DEBUG_INFORMATION_VERSION)";
996996
Condition = "$(GCC_GENERATE_DEBUGGING_SYMBOLS) && $(DEBUG_INFORMATION_FORMAT) != \"\"";
997997
},
998+
{
999+
Name = "SWIFT_OMIT_FRAME_POINTERS";
1000+
Type = Enumeration;
1001+
Values = (
1002+
"compiler-default",
1003+
YES,
1004+
NO,
1005+
);
1006+
CommandLineArgs = {
1007+
YES = (
1008+
"-Xcc", "-fomit-frame-pointer",
1009+
);
1010+
NO = (
1011+
"-Xcc", "-fno-omit-frame-pointer",
1012+
);
1013+
"<<otherwise>>" = ();
1014+
};
1015+
DefaultValue = "compiler-default";
1016+
},
9981017
{
9991018
Name = "CLANG_MODULE_CACHE_PATH";
10001019
Type = Path;

Tests/SWBTaskConstructionTests/TaskConstructionTests.swift

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8583,6 +8583,80 @@ fileprivate struct TaskConstructionTests: CoreBasedTests {
85838583
}
85848584
}
85858585

8586+
@Test(.requireSDKs(.host))
8587+
func framePointerControl() async throws {
8588+
try await withTemporaryDirectory { tmpDir in
8589+
let testProject = try await TestProject(
8590+
"aProject",
8591+
sourceRoot: tmpDir,
8592+
groupTree: TestGroup(
8593+
"SomeFiles", path: "Sources",
8594+
children: [
8595+
TestFile("SourceFile.c"),
8596+
TestFile("Source.swift"),
8597+
]),
8598+
buildConfigurations: [
8599+
TestBuildConfiguration("Debug", buildSettings: [
8600+
"SWIFT_EXEC": swiftCompilerPath.str,
8601+
"SWIFT_VERSION": swiftVersion,
8602+
])
8603+
],
8604+
targets: [
8605+
TestStandardTarget(
8606+
"Library",
8607+
type: .dynamicLibrary,
8608+
buildConfigurations: [
8609+
TestBuildConfiguration("Debug")
8610+
],
8611+
buildPhases: [
8612+
TestSourcesBuildPhase([
8613+
"SourceFile.c",
8614+
"Source.swift"
8615+
])
8616+
]
8617+
)]
8618+
)
8619+
8620+
let fs = PseudoFS()
8621+
8622+
let core = try await getCore()
8623+
let tester = try TaskConstructionTester(core, testProject)
8624+
8625+
await tester.checkBuild(BuildParameters(configuration: "Debug", overrides: [:]), runDestination: .host, fs: fs) { results in
8626+
results.checkTask(.matchRuleType("CompileC")) { task in
8627+
task.checkCommandLineDoesNotContain("-fomit-frame-pointer")
8628+
task.checkCommandLineDoesNotContain("-fno-omit-frame-pointer")
8629+
}
8630+
results.checkTask(.matchRuleType("SwiftDriver Compilation")) { task in
8631+
task.checkCommandLineDoesNotContain("-fomit-frame-pointer")
8632+
task.checkCommandLineDoesNotContain("-fno-omit-frame-pointer")
8633+
}
8634+
}
8635+
8636+
await tester.checkBuild(BuildParameters(configuration: "Debug", overrides: ["CLANG_OMIT_FRAME_POINTERS": "YES", "SWIFT_OMIT_FRAME_POINTERS": "YES"]), runDestination: .host, fs: fs) { results in
8637+
results.checkTask(.matchRuleType("CompileC")) { task in
8638+
task.checkCommandLineContains(["-fomit-frame-pointer"])
8639+
task.checkCommandLineDoesNotContain("-fno-omit-frame-pointer")
8640+
}
8641+
results.checkTask(.matchRuleType("SwiftDriver Compilation")) { task in
8642+
task.checkCommandLineContains(["-Xcc", "-fomit-frame-pointer"])
8643+
task.checkCommandLineDoesNotContain("-fno-omit-frame-pointer")
8644+
}
8645+
}
8646+
8647+
await tester.checkBuild(BuildParameters(configuration: "Debug", overrides: ["CLANG_OMIT_FRAME_POINTERS": "NO", "SWIFT_OMIT_FRAME_POINTERS": "NO"]), runDestination: .host, fs: fs) { results in
8648+
results.checkTask(.matchRuleType("CompileC")) { task in
8649+
task.checkCommandLineDoesNotContain("-fomit-frame-pointer")
8650+
task.checkCommandLineContains(["-fno-omit-frame-pointer"])
8651+
}
8652+
results.checkTask(.matchRuleType("SwiftDriver Compilation")) { task in
8653+
task.checkCommandLineDoesNotContain("-fomit-frame-pointer")
8654+
task.checkCommandLineContains(["-Xcc", "-fno-omit-frame-pointer"])
8655+
}
8656+
}
8657+
}
8658+
}
8659+
85868660
@Test(.requireSDKs(.macOS))
85878661
func warningSuppression() async throws {
85888662
try await withTemporaryDirectory { tmpDir in

0 commit comments

Comments
 (0)