Skip to content

Conversation

@artemcm
Copy link
Contributor

@artemcm artemcm commented May 14, 2025

Resolves rdar://143793051

@artemcm artemcm force-pushed the MorePieOrLessPie branch from 8a99375 to 9d989a5 Compare May 14, 2025 22:39
@artemcm
Copy link
Contributor Author

artemcm commented May 14, 2025

@swift-ci test

Copy link
Contributor

@nkcsgexi nkcsgexi left a comment

Choose a reason for hiding this comment

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

Thank you!

Copy link
Member

@etcwilde etcwilde 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 the fix is fine. How haven't we hit this before though?
Also, maybe for embedded applications, do we have any support for emitting programs that aren't position independent?

@etcwilde
Copy link
Member

// Executables on Linux get -fpie
if targetTriple.os == .linux && linkerOutputType == .executable {
commandLine.appendFlag("-pie")
commandLine.appendFlag("-fpie")
Copy link
Member

Choose a reason for hiding this comment

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

I'm confused by this change. The spelling is -pie for the linker driver invocation, but -fpie for the compiler invocation (unless you are on certain platforms, where the spelling is -fPIE) under certain circumstances.

-pie is the equivalent of -shared but for executables.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for clearing that up, I had confused the two. @cachemeifyoucan pointed out that the warning we get appears to be due to the Clang driver emitting it for platforms where the toolchain default for executables is PIE.

Copy link
Contributor

Choose a reason for hiding this comment

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

I am actually unsure where the warning coming from before seeing the build log. I suggest it is better if you just pass -Xlinker -pie if you worried about unused argument warning.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

5 participants