Coder Social home page Coder Social logo

Comments (6)

keith avatar keith commented on July 20, 2024 1

It looks like SwiftPM hard codes always passing -fPic on Linux (and not on macOS since it's the default) https://github.com/apple/swift-package-manager/blob/b8d4c97579cfb6eec7a383e26e4dc855b693c61f/Sources/Workspace/Destination.swift#L128

from rules_swift.

allevato avatar allevato commented on July 20, 2024 1

It hasn't affected us internally yet because AFAICT our CROSSTOOL passes -pie by default, and rules_swift's linking merely piggy-backs off the C++ executable linking behavior there.

That being said, Joe Groff says that "PIE is a functional necessity for linking Swift executables correctly", so perhaps we should be passing it unconditionally anyway. I dug around and it's not clear why it's required and why it affects the behavior you saw above, but judging by where the crash occurred in that backtrace, maybe PIC/PIE has some effect on how protocol witnesses are looked up.

One concern I have is, if you have a Swift binary that also links in C++ code, do the archives I get from the cc_library targets have code compiled with -fPIC, since I don't think non-PIC objects will work correctly in a PIE. Presumably if we're already linking PIEs internally then that should be working correctly now, but I want to double-check a few things.

from rules_swift.

keith avatar keith commented on July 20, 2024

I've submitted #99 to fix this if there's no objection

from rules_swift.

keith avatar keith commented on July 20, 2024

The linker flags in my PR shouldn't get propagated to the cc_library right? But actually if PIE is required for Swift, maybe that's desired anyways?

from rules_swift.

allevato avatar allevato commented on July 20, 2024

No, nothing would get propagated down the dependency tree. My concern is the opposite direction—whether anything needs to be done to ensure that .o files from cc_libraries used upstream are compiled with PIC enabled so that they can be linked into a PIE.

from rules_swift.

keith avatar keith commented on July 20, 2024

Ah. At least that that point I think it would fail to link? Or at least warn?

from rules_swift.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.