Marking a function as __attribute__((weak))


(Philippe Hausler) #1

Is there a way to mark a function in swift (on Linux) to use the same emission strategy as weak declarations in c?

I was to tinkering with some ideas on fixing some poor behavior in swift-corelibs-foundation and weak would potentially solve this specific case.

For reference this is the syntax I am interested in (since it is a bit obscure) https://en.m.wikipedia.org/wiki/Weak_symbol


(Greg Parker) #2

Weak definitions are expensive. What are you trying to do?

···

On Mar 6, 2017, at 5:48 PM, Philippe Hausler via swift-dev <swift-dev@swift.org> wrote:

Is there a way to mark a function in swift (on Linux) to use the same emission strategy as weak declarations in c?

I was to tinkering with some ideas on fixing some poor behavior in swift-corelibs-foundation and weak would potentially solve this specific case.

For reference this is the syntax I am interested in (since it is a bit obscure) https://en.m.wikipedia.org/wiki/Weak_symbol

--
Greg Parker gparker@apple.com <mailto:gparker@apple.com> Runtime Wrangler


(Philippe Hausler) #3

Is there a way to mark a function in swift (on Linux) to use the same emission strategy as weak declarations in c?

I was to tinkering with some ideas on fixing some poor behavior in swift-corelibs-foundation and weak would potentially solve this specific case.

For reference this is the syntax I am interested in (since it is a bit obscure) https://en.m.wikipedia.org/wiki/Weak_symbol

Weak definitions are expensive. What are you trying to do?

I was trying to prototype some fixes for factory pattern initializers. The other strategy that I was considering was using hoisting of functions to init methods but that didn't seem to work with disparate types. This wasn't really intended to be a real solution but more so a proof of concept.

···

On Mar 6, 2017, at 5:59 PM, Greg Parker <gparker@apple.com> wrote:

On Mar 6, 2017, at 5:48 PM, Philippe Hausler via swift-dev <swift-dev@swift.org> wrote:

--
Greg Parker gparker@apple.com Runtime Wrangler


(Joe Groff) #4

Could you be more specific about how you're trying to apply weak definitions to the problem?

-Joe

···

On Mar 6, 2017, at 7:10 PM, Philippe Hausler via swift-dev <swift-dev@swift.org> wrote:

On Mar 6, 2017, at 5:59 PM, Greg Parker <gparker@apple.com <mailto:gparker@apple.com>> wrote:

On Mar 6, 2017, at 5:48 PM, Philippe Hausler via swift-dev <swift-dev@swift.org <mailto:swift-dev@swift.org>> wrote:

Is there a way to mark a function in swift (on Linux) to use the same emission strategy as weak declarations in c?

I was to tinkering with some ideas on fixing some poor behavior in swift-corelibs-foundation and weak would potentially solve this specific case.

For reference this is the syntax I am interested in (since it is a bit obscure) https://en.m.wikipedia.org/wiki/Weak_symbol

Weak definitions are expensive. What are you trying to do?

I was trying to prototype some fixes for factory pattern initializers. The other strategy that I was considering was using hoisting of functions to init methods but that didn't seem to work with disparate types. This wasn't really intended to be a real solution but more so a proof of concept.