Skip to content

CMake: Define DARWIN_LIBMALLOC #78963

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

Conversation

etcwilde
Copy link
Member

@etcwilde etcwilde commented Jan 28, 2025

SWIFT_STDLIB_HAS_MALLOC_TYPE is defined in terms of SWIFT_STDLIB_HAS_DARWIN_LIBMALLOC in include/swift/Runtime/Config.h. Apple platforms generally have the Darwin libmalloc, so it should be a safe bet to define it this way. Unfortunately, a lot of things include the Config.h file, transitively or otherwise, so figuring out exactly which libraries should have this defined vs ones that should not is rather tricky, so for now, I've defined it globally.

rdar://143697425

`SWIFT_STDLIB_HAS_MALLOC_TYPE` is defined in terms of
`SWIFT_STDLIB_HAS_DARWIN_LIBMALLOC` in `include/swift/Runtime/Config.h`.
Apple platforms generally have the Darwin libmalloc, so it should be a
safe bet to define it this way. Unfortunately, a lot of things include
the Config.h file, transitively or otherwise, so figuring out exactly
which libraries should have this defined vs ones that should not is
rather tricky, so for now, I've defined it globally.
@etcwilde
Copy link
Member Author

@swift-ci please smoke test

@@ -135,6 +135,7 @@ add_compile_definitions(
$<$<BOOL:${SwiftCore_ENABLE_UNICODE_DATA}>:-DSWIFT_STDLIB_ENABLE_UNICODE_DATA> # Stubs
$<$<BOOL:${SwiftCore_ENABLE_ENVIRONMENT}>:-DSWIFT_STDLIB_HAS_ENVIRON> # Concurrency, runtime, shims, platform overlay
$<$<BOOL:${SwiftCore_ENABLE_BACKDEPLOYMENT_SUPPORT}>:-DSWIFT_STDLIB_SUPPORT_BACK_DEPLOYMENT> # Concurrency, Compatibility override, magic symbols
$<$<BOOL:${SwiftCore_HAS_DARWIN_LIBMALLOC}>:-DSWIFT_STDLIB_HAS_DARWIN_LIBMALLOC> # Anything that includes include/swift/Runtime/Config.h
Copy link
Member

Choose a reason for hiding this comment

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

Can we not make this an interface property for anything that has the include path for Config.h?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not sure how you propose doing that? We aren't tracking the includes of that file in CMake...
If you have a solution, I'm happy to change it though.

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.

Ugh, no, this file is not generated, its static :sigh:

@etcwilde
Copy link
Member Author

@swift-ci please smoke test macOS

@etcwilde etcwilde merged commit e17df88 into swiftlang:main Jan 28, 2025
3 checks passed
@etcwilde etcwilde deleted the ewilde/stdlib-rebuild-extra-malloc-type branch January 29, 2025 23:09
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.

3 participants