Skip to content

pass -fno-omit-frame-pointer in support of new backtracer #7042

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 4 commits into from
Nov 1, 2023

Conversation

tomerd
Copy link
Contributor

@tomerd tomerd commented Oct 27, 2023

motivation: new backtracer relies on frame pointers. make sure we do not omit them. this can be removed once the backtracer uses DWARF instead of frame pointers

changes:

  • introduce new hidden "omitFramePointers" build option to explicit omit frame pointers
  • unless user specifies omitFramePointers/noOmitFramePointers, pass -fno-omit-frame-pointer to the compiler on Linux only
  • add and adjust tests

rdar://117578677

motivation: new backtracer relies on frame pointers. make sure we do not omit them. this can be removed once the backtracer uses DWARF instead of frame pointers

changes:
* intriduce new hidden "omitFramePointers" build option to explicit omit frame pointers
* unless omitFramePointers is set to true (false by default), pass -fno-omit-frame-pointer to the compiler
* adjust tests
@tomerd
Copy link
Contributor Author

tomerd commented Oct 27, 2023

cc @al45tair

@tomerd
Copy link
Contributor Author

tomerd commented Oct 27, 2023

not sure if we want to do this on all platforms, but started with that

Copy link
Contributor

@neonichu neonichu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, only concern would be that we are not doing any checking w.r.t. availability of the option, not sure if that gets us into trouble on any platforms.

@tomerd
Copy link
Contributor Author

tomerd commented Oct 30, 2023

@swift-ci test

Copy link
Contributor

@MaxDesiatov MaxDesiatov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but also curious whether this should only be enabled for specific target platforms?

@neonichu
Copy link
Contributor

@swift-ci test windows

Copy link
Member

@compnerd compnerd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a platform check. -fno-omit-frame-pointer cannot be passed on all targets (e.g. armv7-unknown-windows-msvc IIRC does object).

@tomerd
Copy link
Contributor Author

tomerd commented Oct 31, 2023

@swift-ci test

@tomerd
Copy link
Contributor Author

tomerd commented Oct 31, 2023

this is now Linux specific unless users forces it

@MaxDesiatov MaxDesiatov requested a review from compnerd October 31, 2023 17:35
@MaxDesiatov
Copy link
Contributor

@swift-ci test windows

@tomerd tomerd enabled auto-merge (squash) October 31, 2023 20:28
@tomerd
Copy link
Contributor Author

tomerd commented Oct 31, 2023

@compnerd ptal

Copy link
Member

@compnerd compnerd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that @neonichu's idea to vend this as an enum is a great idea. It would avoid having the logic duplicated in multiple sites.

@tomerd
Copy link
Contributor Author

tomerd commented Oct 31, 2023

since optional bool already represents three states, we dont really need another enum. that said, moving the platform logic to BuildParameters::Debugging initializer is a good idea

@tomerd
Copy link
Contributor Author

tomerd commented Oct 31, 2023

@swift-ci test

@tomerd
Copy link
Contributor Author

tomerd commented Oct 31, 2023

@neonichu @compnerd ptal

@tomerd
Copy link
Contributor Author

tomerd commented Nov 1, 2023

@swift-ci test windows

@tomerd tomerd requested a review from compnerd November 1, 2023 00:18
@@ -3511,18 +3538,68 @@ final class BuildPlanTests: XCTestCase {
XCTAssertMatch(dep, [.anySequence, "-DDEP", .anySequence])

let cbar = try result.target(for: "cbar").clangTarget().basicArguments(isCXX: false)
XCTAssertMatch(cbar, [.anySequence, "-DCCC=2", "-I\(A.appending(components: "Sources", "cbar", "Sources", "headers"))", "-I\(A.appending(components: "Sources", "cbar", "Sources", "cppheaders"))", "-Icfoo", "-L", "cbar", "-Icxxfoo", "-L", "cxxbar", "-g", .end])
XCTAssertMatch(cbar, [.anySequence, "-DCCC=2", "-I\(A.appending(components: "Sources", "cbar", "Sources", "headers"))", "-I\(A.appending(components: "Sources", "cbar", "Sources", "cppheaders"))", "-Icfoo", "-L", "cbar", "-Icxxfoo", "-L", "cxxbar", "-g", "-fno-omit-frame-pointer", .end])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this correct?

Copy link
Contributor Author

@tomerd tomerd Nov 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think so, why not?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for reference this is for .x86_64Linux


let exe = try result.target(for: "exe").swiftTarget().compileArguments()
XCTAssertMatch(exe, [.anySequence, "-DFOO", "-g", "-Xcc", "-g", "-Xcc", "-fno-omit-frame-pointer", .end])
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure I like that we're making these tests even more unmaintainable by copy-pasting two extra times, but I guess it's fine...

@tomerd
Copy link
Contributor Author

tomerd commented Nov 1, 2023

@swift-ci test macOS

@@ -3059,7 +3083,7 @@ final class BuildPlanTests: XCTestCase {
"-fblocks", "-fmodules", "-fmodule-name=lib",
"-I", Pkg.appending(components: "Sources", "lib", "include").pathString,
"-fmodules-cache-path=\(buildPath.appending(components: "ModuleCache"))",
"-g",
"-g"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why remove the trailing ,? It is convenient.

@tomerd tomerd merged commit 4375ebb into swiftlang:main Nov 1, 2023
tomerd added a commit to tomerd/swift-package-manager that referenced this pull request Nov 1, 2023
…7042)

motivation: new backtracer relies on frame pointers. make sure we do not
omit them. this can be removed once the backtracer uses DWARF instead of
frame pointers

changes:
* introduce new hidden "omitFramePointers" build option to explicit omit
frame pointers
* unless user specifies omitFramePointers/noOmitFramePointers, pass
-fno-omit-frame-pointer to the compiler on Linux only
* add and adjust tests

rdar://117578677
tomerd added a commit that referenced this pull request Nov 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants