This is an archive of the discontinued LLVM Phabricator instance.

[libcxx] Remove installation rules on Darwin when it would overwrite the system installation.
ClosedPublic

Authored by EricWF on Aug 20 2015, 1:22 PM.

Details

Summary

On Mac OS X overwriting /usr/lib/libc++.dylib can cause your computer to fail to boot. This patch tries to make it harder to do that accidentally.

If CMAKE_SYSTEM_NAME is Darwin and CMAKE_INSTALL_PREFIX is /usr don't generate installation rules unless the user explicitly provides LIBCXX_OVERRIDE_DARWIN_INSTALL=ON. Note that CMAKE_INSTALL_PREFIX is always absolute so we don't need to worry about things like /usr/../usr.

Diff Detail

Event Timeline

EricWF updated this revision to Diff 32727.Aug 20 2015, 1:22 PM
EricWF retitled this revision from to [libcxx] Remove installation rules on Darwin when it would overwrite the system installation..
EricWF updated this object.
EricWF added reviewers: mclow.lists, beanz, jroelofs.
EricWF added a subscriber: cfe-commits.
jroelofs edited edge metadata.Aug 20 2015, 1:35 PM

I like it!

jroelofs accepted this revision.Aug 25 2015, 12:02 PM
jroelofs edited edge metadata.
jroelofs added inline comments.
CMakeLists.txt
105

I would check for "/usr/" too.

This revision is now accepted and ready to land.Aug 25 2015, 12:02 PM
EricWF added inline comments.Aug 25 2015, 12:06 PM
CMakeLists.txt
105

CMake canonicalizes CMAKE_INSTALL_PREFIX which includes removing the trailing slash. I tested this before submitting the patch.

Ah, I only tested it by editing the CMakeCache.txt manually... ship it!

EricWF closed this revision.Aug 26 2015, 1:19 PM