Additional Update Guidelines for libc
As a reminder, these are guidelines. The version you update to might make some of these steps obsolete, so make sure you understand what they do and why they're necessary.
Steps
1. Replace the current source with the updated source
Follow step 1 in "General Steps", with some extra exceptions. In addition to keeping the CMakeLists.txt
, also keep:
empty.c
- This is needed as a dummy source file for libraries that are only built for certain configurations.weak_reference.h
- This is needed to provide a no-op macro that sometimes gets overridden or undefined in certain filesdarling-scripts
- This directory contains some scripts you'll need later on to generate some essential fileslocale/locale
- Contains locale information.
2. Create an initial update commit
Follow step 2 in "General Steps".
3. Update the CMakeLists.txt
Follow step 3 in "General Steps".
4. Review the Git history for the project
Follow step 4 in "General Steps".
The next step explains some of the modifications in place when this document was last updated.
5. Make source modifications if necessary
Follow step 5 in "General Steps".
As of Libc-1353.60.8, the following files need Darling-specific modifications:
-
gen/FreeBSD/opendir.c
- Modified to not define_filldir
when building thelegacy
variant of the libraryOtherwise, it causes duplicate symbol errors for the i386 build of libc because the
noinode64
variant already defines it exactly the same way and both thenoinode64
andlegacy
variants are included in the i386 build. -
gen/FreeBSD/telldir.c
- Modified to not define_fixtelldir
when building thelegacy
variant of the librarySame reason as the modification in
gen/FreeBSD/opendir.c
. -
string/FreeBSD/strerror.c
- Modified to not define__errstr
andstrerror_r
when building thelegacy
variant of the libraryWithout this modification, both the
legacy
andregular
variants define the exact same functions (same name and functionality), causing duplicate symbol errors for the i386 build.
Remember that, as explained in steps 4 and 5 of "General Steps", some of these modifications may not be necessary for the version you're updating to, and some additional modifications may be necessary.
6. Generate some additional files
libc requires some additional files that are normally generated by the Xcode build for Apple's code. However, since we're not using Xcode, we need to generate these files separately.
The scripts you need to run are:
darling-scripts/generate-derived.sh
- Generates the feature headers inderived
for various platformsdarling-scripts/replace-libc-comments.sh
- Finds headers with private libc-only code, copies them to a private header directory, and removes the private code from the originals (a.k.a. the public headers)
7. Build and test it
Follow step 6 in "General Steps".
8. Commit your final changes
Follow step 7 in "General Steps".