Skip to content

Buildfixes atop the Ventura merge (in #4633) #4648

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

Closed
wants to merge 5 commits into from

Conversation

3405691582
Copy link
Member

This picks the Ventura merge commit and buildfixes it for OpenBSD.

Draft pr, so that the commits can be picked back on #4633 -- I don't know off the top of my head if you can get Github to chain prs from someone else.

iCharlesHu and others added 5 commits September 19, 2022 11:12
* [runloop] Set up some symbols for generic code.

CFRunLoop has a recurring abstraction for platform-specific code, but it
is a little leaky. Plug these leaks: ensure `MACH_PORT_NULL` in the
generic, non-platform context is rewritten as `CFPORT_NULL`, and ensure
that `kern_return_t` and `KERN_SUCCESS` are defined properly.

* [runloop] Remind porter these stubs are required.

New platforms must define these types and functions; it is incorrect to
not have #else cases here.

* [runloop] Implement runloop abstraction for BSD.

* [runloop] Avoid pthread_main_np on OpenBSD.

During runloop testing, log messages suggest that the runloop thinks the
main thread has exited and certain runloop operations don't actually
proceed. The flag for denoting when the main thread has exited is set in
the thread-specific data destructor `__CFTSDFinalize`.

This function detects whether the thread in question is the main thread
via `pthread_main_np`, and has been observed in debugging this problem
to return 1 on apparently non-main threads on OpenBSD. This obviously
will cause the main thread exited flag to be erroneously set when
non-main threads complete their work and dispose of thread-specific
data.

Instead, use the existing `_CFMainPThread` symbol set in
`__CFInitialize` to determine the main thread. I am not sure whether the
platform `pthread_main_np` is at fault here, but since this workaround
makes the tests pass, let's use it.
CFBasicHashGetSize has an argument, total, to enable whether to
presumably calculate the size its dependent data structures.
CFBasicHashGetSize does not appear outside CFBasicHash.c, and this total
argument is true only when ENABLE_MEMORY_COUNTERS is true or
transitively when ENABLE_DTRACE_PROBES is true. These preprocessor
symbols appear to be to control debugging and other informational
purposes.

malloc introspection, as afforded by malloc_size, malloc_usable_size, or
msize, is nonportable (and thus not guaranteed to be present on all
platforms), not guaranteed to be accurate (though certainly an upper
bound), and is generally recommended for debugging.

For those reasons, only expose the call to malloc_size when either of
ENABLE_MEMORY_COUNTERS or ENABLE_DTRACE_PROBES is true. This avoids an
undefined symbol issue when malloc introspection is unavailable, but
does mean these counters and other information is not available on
platforms when malloc_size is not present.
This function is tagged with __attribute__((unused)) and certainly
appears to be unused. It may be a function intended for use in a
debugger context. As it is a static function, the reference to this
function and malloc_size will not necessarily be present when built,
_but_ this does cause a compiler warning when building on systems where
malloc_size or alternatives are not available.

malloc introspection, as afforded by malloc_size, malloc_usable_size, or
msize, is nonportable (and thus not guaranteed to be present on all
platforms), not guaranteed to be accurate (though certainly an upper
bound), and is generally recommended for debugging.

For those reasons, remove this function.
Other fixes are reapplied by repicking prior commits.

This commit, additionally:

* excludes OpenBSD from having a __printflike macro,

* resolves an error with `pthread_set_name_np`'s return value,

* restores conditionals for `_CFReallocf`,

* properly handles RTLD_NOLOAD.
@parkera
Copy link
Contributor

parkera commented Jul 19, 2024

Closing older PRs with conflicts after our swift-foundation merge (#5001).

@parkera parkera closed this Jul 19, 2024
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