summaryrefslogtreecommitdiff
path: root/var/spack/repos/builtin/packages/apple-libunwind/package.py
blob: b77301359a94ea732f970fa7b209fe23e254d1bd (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
##############################################################################
# Copyright (c) 2013-2018, Lawrence Livermore National Security, LLC.
# Produced at the Lawrence Livermore National Laboratory.
#
# This file is part of Spack.
# Created by Todd Gamblin, tgamblin@llnl.gov, All rights reserved.
# LLNL-CODE-647188
#
# For details, see https://github.com/spack/spack
# Please also see the NOTICE and LICENSE files for our notice and the LGPL.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License (as
# published by the Free Software Foundation) version 2.1, February 1999.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the IMPLIED WARRANTY OF
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms and
# conditions of the GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
##############################################################################
from spack import *


class AppleLibunwind(Package):
    """Placeholder package for Apple's analogue to non-GNU libunwind"""

    homepage = "https://opensource.apple.com/source/libunwind/libunwind-35.3/"

    provides('unwind')

    # The 'conflicts' directive only accepts valid spack specs;
    # platforms cannot be negated -- 'platform!=darwin' is not a valid
    # spec -- so expressing a conflict for any platform that isn't
    # Darwin must be expressed by listing a conflict with every
    # platform that isn't Darwin/macOS
    conflicts('platform=linux')
    conflicts('platform=bgq')
    conflicts('platform=cray')

    # Override the fetcher method to throw a useful error message;
    # avoids GitHub issue (#7061) in which the opengl placeholder
    # package threw a generic, uninformative error during the `fetch`
    # step,
    @property
    def fetcher(self):
        msg = """This package is intended to be a placeholder for Apple's
        system-provided, non-GNU-compatible libunwind library.

        Add to your packages.yaml:

        packages:
          apple-libunwind:
            paths:
              apple-libunwind@35.3: /usr
            buildable: False

        """
        raise InstallError(msg)

    def install(self, spec, prefix):
        pass

    @property
    def libs(self):
        """Export the Apple libunwind library. The Apple libunwind library
        cannot be linked to directly using an absolute path; doing so
        will cause the linker to throw an error 'cannot link directly
        with /usr/lib/system/libunwind.dylib' and the linker will
        suggest linking with System.framework instead. Linking to this
        framework is equivalent to linking with libSystem.dylib, which
        can be confirmed on a macOS system by executing at a terminal
        the command `ls -l
        /System/Library/Frameworks/System.Framework` -- the file
        "System" is a symlink to `/usr/lib/libSystem.B.dylib`, and
        `/usr/lib/libSystem.dylib` also symlinks to this file.

        Running `otool -L /usr/lib/libSystem.dylib` confirms that
        it will link dynamically to `/usr/lib/system/libunwind.dylib`.

        """
        libs = find_libraries('libSystem',
                              self.prefix.lib,
                              shared=True, recursive=False)
        if libs:
            return libs
        return None

    @property
    def headers(self):
        """ Export the Apple libunwind header
        """
        hdrs = HeaderList(find(self.prefix.include, 'libunwind.h',
                               recursive=False))
        return hdrs or None