Skip to content
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

Use __attribute__ ((constructor)) instead of INIT_ROUTINE on macOS (Xcode) #4925

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ikesyo
Copy link
Collaborator

@ikesyo ikesyo commented Mar 15, 2024

I'm not sure why but it looks like __CFInitialize is not called on macOS with Xcode.

ref: https://developer.apple.com/library/archive/documentation/MacOSX/Conceptual/BPFrameworks/Tasks/InitializingFrameworks.html

This might be related to #3271 and #4608.

@ikesyo
Copy link
Collaborator Author

ikesyo commented Mar 15, 2024

@swift-ci test

@compnerd
Copy link
Collaborator

@swift-ci please test macOS platform

@ikesyo
Copy link
Collaborator Author

ikesyo commented Mar 24, 2024

Please test with following PRs:
apple/swift-corelibs-xctest#476

@swift-ci please test macOS platform

@grynspan
Copy link
Contributor

Static constructors are considered a performance issue on Darwin and are generally avoided. @parkera would this be an acceptable change? Is it even necessary given that corelibs-foundation isn't typically used on Darwin?

@compnerd
Copy link
Collaborator

It is useful to be able to build and run foundation on macos for testing behavioral issues. I would say that since it didn't normally run in macos, this is likely fine.

@ikesyo
Copy link
Collaborator Author

ikesyo commented Mar 27, 2024

I found another solution, using the classic linker by adding -Wl,-ld_classic to OTHER_LDFLAGS did solve the problem 🤔

Which is better?

@parkera
Copy link
Member

parkera commented Apr 2, 2024

CFInitialize simply has to run, and although we don't encourage the use of static initializers in general, we make an exception for this particular one.

I think I would rather give it the source code annotation than force a compatibility mode in the linker.

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.

None yet

4 participants