This is an archive of the discontinued LLVM Phabricator instance.

[libc] Build two different static archives libc.a and libm.a under full build.
ClosedPublic

Authored by sivachandra on Jan 31 2023, 11:32 AM.

Details

Summary

We currently put everything in one single archive libc.a which breaks in
certain situations where the compiler drivers expect libm.a also. With
this change, we separate out libc.a and libm.a functions as is done
conventionally and put them in two different static archives.

One will now have to build two targets, libc and libm which produce
libc.a and libm.a respectively. Under default build, one still builds only
one target named libc which produces libllvmlibc.a.

Diff Detail

Event Timeline

sivachandra created this revision.Jan 31 2023, 11:32 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptJan 31 2023, 11:32 AM
sivachandra requested review of this revision.Jan 31 2023, 11:32 AM
jhuber6 added inline comments.Jan 31 2023, 11:33 AM
libc/lib/CMakeLists.txt
6

Does this omit libm if there are no entrypoints for it enabled? Right now I haven't begun working on any libm related stuff.

Skip adding an archive target if the archive's entrypoint list is not present.

sivachandra added inline comments.Jan 31 2023, 12:00 PM
libc/lib/CMakeLists.txt
6

That's a good point. I have updated now to skip adding an archive target if the correspond entrypoint list is missing.

jhuber6 added inline comments.Jan 31 2023, 12:42 PM
libc/lib/CMakeLists.txt
1–38

Is this necessary? Won't CMake just create an empty one if it doesn't exist?

sivachandra added inline comments.Jan 31 2023, 1:01 PM
libc/lib/CMakeLists.txt
1–38

Yes, in most contexts that is correct. But, I just do it as a practice because we cannot really control var-name leakage from the parent. As in, if the parent uses the same names for its local logic, they will come here already initialized to some value. As a policy though, we name vars having global semantics in UPPER_SNAKE_CASE.

This revision is now accepted and ready to land.Jan 31 2023, 1:16 PM