diff --git a/Sources/SWBUniversalPlatform/Specs/Clang.xcspec b/Sources/SWBUniversalPlatform/Specs/Clang.xcspec index f7ce248e..484a1d3c 100644 --- a/Sources/SWBUniversalPlatform/Specs/Clang.xcspec +++ b/Sources/SWBUniversalPlatform/Specs/Clang.xcspec @@ -2934,6 +2934,25 @@ NO = (); }; }, + { + Name = "CLANG_OMIT_FRAME_POINTERS"; + Type = Enumeration; + Values = ( + "compiler-default", + YES, + NO, + ); + CommandLineArgs = { + YES = ( + "-fomit-frame-pointer", + ); + NO = ( + "-fno-omit-frame-pointer", + ); + "<>" = (); + }; + DefaultValue = "compiler-default"; + }, // Index-while-building options, not visible in build settings. { Name = "CLANG_INDEX_STORE_PATH"; diff --git a/Sources/SWBUniversalPlatform/Specs/Swift.xcspec b/Sources/SWBUniversalPlatform/Specs/Swift.xcspec index cccdc078..ff751506 100644 --- a/Sources/SWBUniversalPlatform/Specs/Swift.xcspec +++ b/Sources/SWBUniversalPlatform/Specs/Swift.xcspec @@ -995,6 +995,25 @@ DefaultValue = "$(DEBUG_INFORMATION_VERSION)"; Condition = "$(GCC_GENERATE_DEBUGGING_SYMBOLS) && $(DEBUG_INFORMATION_FORMAT) != \"\""; }, + { + Name = "SWIFT_OMIT_FRAME_POINTERS"; + Type = Enumeration; + Values = ( + "compiler-default", + YES, + NO, + ); + CommandLineArgs = { + YES = ( + "-Xcc", "-fomit-frame-pointer", + ); + NO = ( + "-Xcc", "-fno-omit-frame-pointer", + ); + "<>" = (); + }; + DefaultValue = "compiler-default"; + }, { Name = "CLANG_MODULE_CACHE_PATH"; Type = Path; diff --git a/Tests/SWBTaskConstructionTests/TaskConstructionTests.swift b/Tests/SWBTaskConstructionTests/TaskConstructionTests.swift index a3931342..a0edbbe6 100644 --- a/Tests/SWBTaskConstructionTests/TaskConstructionTests.swift +++ b/Tests/SWBTaskConstructionTests/TaskConstructionTests.swift @@ -8583,6 +8583,80 @@ fileprivate struct TaskConstructionTests: CoreBasedTests { } } + @Test(.requireSDKs(.host)) + func framePointerControl() async throws { + try await withTemporaryDirectory { tmpDir in + let testProject = try await TestProject( + "aProject", + sourceRoot: tmpDir, + groupTree: TestGroup( + "SomeFiles", path: "Sources", + children: [ + TestFile("SourceFile.c"), + TestFile("Source.swift"), + ]), + buildConfigurations: [ + TestBuildConfiguration("Debug", buildSettings: [ + "SWIFT_EXEC": swiftCompilerPath.str, + "SWIFT_VERSION": swiftVersion, + ]) + ], + targets: [ + TestStandardTarget( + "Library", + type: .dynamicLibrary, + buildConfigurations: [ + TestBuildConfiguration("Debug") + ], + buildPhases: [ + TestSourcesBuildPhase([ + "SourceFile.c", + "Source.swift" + ]) + ] + )] + ) + + let fs = PseudoFS() + + let core = try await getCore() + let tester = try TaskConstructionTester(core, testProject) + + await tester.checkBuild(BuildParameters(configuration: "Debug", overrides: [:]), runDestination: .host, fs: fs) { results in + results.checkTask(.matchRuleType("CompileC")) { task in + task.checkCommandLineDoesNotContain("-fomit-frame-pointer") + task.checkCommandLineDoesNotContain("-fno-omit-frame-pointer") + } + results.checkTask(.matchRuleType("SwiftDriver Compilation")) { task in + task.checkCommandLineDoesNotContain("-fomit-frame-pointer") + task.checkCommandLineDoesNotContain("-fno-omit-frame-pointer") + } + } + + await tester.checkBuild(BuildParameters(configuration: "Debug", overrides: ["CLANG_OMIT_FRAME_POINTERS": "YES", "SWIFT_OMIT_FRAME_POINTERS": "YES"]), runDestination: .host, fs: fs) { results in + results.checkTask(.matchRuleType("CompileC")) { task in + task.checkCommandLineContains(["-fomit-frame-pointer"]) + task.checkCommandLineDoesNotContain("-fno-omit-frame-pointer") + } + results.checkTask(.matchRuleType("SwiftDriver Compilation")) { task in + task.checkCommandLineContains(["-Xcc", "-fomit-frame-pointer"]) + task.checkCommandLineDoesNotContain("-fno-omit-frame-pointer") + } + } + + await tester.checkBuild(BuildParameters(configuration: "Debug", overrides: ["CLANG_OMIT_FRAME_POINTERS": "NO", "SWIFT_OMIT_FRAME_POINTERS": "NO"]), runDestination: .host, fs: fs) { results in + results.checkTask(.matchRuleType("CompileC")) { task in + task.checkCommandLineDoesNotContain("-fomit-frame-pointer") + task.checkCommandLineContains(["-fno-omit-frame-pointer"]) + } + results.checkTask(.matchRuleType("SwiftDriver Compilation")) { task in + task.checkCommandLineDoesNotContain("-fomit-frame-pointer") + task.checkCommandLineContains(["-Xcc", "-fno-omit-frame-pointer"]) + } + } + } + } + @Test(.requireSDKs(.macOS)) func warningSuppression() async throws { try await withTemporaryDirectory { tmpDir in