Prevent conflicts between libuuid and Apple Cocoa Framework on Mac (#12166)

* Remove libuuid dependency for python on Darwin

Python 2.7 includes Carbon, which requires a proprietary typedef defined in
the system `/usr/include/uuid/uuid.h`:
```
In file included from /rnsdhpc/code/spack/var/spack/stage/python-2.7.16-chgwvgls4ezgujsknn27vlmkhwbzpqik/Python-2.7.16/Python/mactoolboxglue.c:27:
In file included from /rnsdhpc/code/spack/var/spack/stage/python-2.7.16-chgwvgls4ezgujsknn27vlmkhwbzpqik/Python-2.7.16/Include/pymactoolbox.h:10:
In file included from /System/Library/Frameworks/Carbon.framework/Headers/Carbon.h:20:
In file included from /System/Library/Frameworks/CoreServices.framework/Headers/CoreServices.h:23:
In file included from /System/Library/Frameworks/CoreServices.framework/Frameworks/AE.framework/Headers/AE.h:20:
In file included from /System/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework/Headers/CarbonCore.h:208:
In file included from /System/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework/Headers/HFSVolumes.h:25:
/usr/include/hfs/hfs_format.h:794:2: error: unknown type name 'uuid_string_t'; did you mean 'io_string_t'?
```

Similarly, even with Python 3, having Spack's libuuid in the toolchain
causes matplotlib to fail to build downstream because its `osx` backend
links against Carbon:
```
building 'matplotlib.backends._macosx' extension
/rnsdhpc/code/spack/lib/spack/env/clang/clang -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/usr/local/include -I/usr/X11/include -I/opt/X11/include -I. -I/rnsdhpc/code/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.2-bipx24oyxqxowqc75o5vfih7dljiaohz/include/python3.7m -c src/_macosx.m -o build/temp.macosx-10.14.5-x86_64-3.7/src/_macosx.o
In file included from src/_macosx.m:1:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Cocoa.framework/Headers/Cocoa.h:12:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:87:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSURLError.h:15:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/CoreServices.framework/Headers/CoreServices.h:24:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/CoreServices.framework/Frameworks/AE.framework/Headers/AE.h:20:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework/Headers/CarbonCore.h:208:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework/Headers/HFSVolumes.h:25:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/hfs/hfs_format.h:794:2: error: unknown type name 'uuid_string_t'; did you mean 'io_string_t'?
        uuid_string_t   ext_jnl_uuid;
        ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/device/device_types.h:89:33: note: 'io_string_t' declared here
typedef char                    io_string_t[512];
```

MacOS version 10.14.5
Xcode 10.2.1
Apple LLVM version 10.0.1 (clang-1001.0.46.4)

* Mark libuuid as conflicting with Darwin due to framework

If Spack's libuuid is included by any other package that tests for or
requires the Cocoa or Carbon frameworks, the build will *fail* becuse it
appears that Apple's libraries require a special version of libuuid and
uuid.h.

```
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Cocoa.framework/Headers/Cocoa.h:12:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:87:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSURLError.h:15:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/CoreServices.framework/Headers/CoreServices.h:24:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/CoreServices.framework/Frameworks/AE.framework/Headers/AE.h:20:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework/Headers/CarbonCore.h:208:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework/Headers/HFSVolumes.h:25:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/hfs/hfs_format.h:794:2: error: unknown type name 'uuid_string_t'; did you mean 'io_string_t'?
        uuid_string_t   ext_jnl_uuid;
        ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/device/device_types.h:89:33: note: 'io_string_t' declared here
typedef char                    io_string_t[512];
```

* Revert "Mark libuuid as conflicting with Darwin due to framework"

This reverts commit 9a68b75202005fc265abe2033e4ad36312a9a34d.

* Document libuuid exception in python package
This commit is contained in:
Seth R. Johnson 2019-07-28 15:58:09 -04:00 committed by Adam J. Stewart
parent 9afd5113bc
commit 95985e0798

View file

@ -125,7 +125,13 @@ class Python(AutotoolsPackage):
depends_on('tk', when='+tkinter')
depends_on('tcl', when='+tkinter')
depends_on('tix', when='+tix')
depends_on('libuuid', when='+uuid')
if sys.platform != 'darwin':
# On macOS systems, Spack's libuuid conflicts with the system-installed
# version and breaks anything linked against Cocoa/Carbon. Since the
# system-provided version is sufficient to build Python's UUID support,
# the easy solution is to only depend on Spack's libuuid when *not* on
# a Mac.
depends_on('libuuid', when='+uuid')
patch('tkinter.patch', when='@:2.8,3.3: platform=darwin')