MacPorts: "Error: clang-4.0 has been replaced by clang-8.0; please install that instead" but I have clang-8.0 already installed

MacPorts: "Error: clang-4.0 has been replaced by clang-8.0; please install that instead" but I have clang-8.0 already installed

我在尝试使用 MacPorts 安装多个端口时遇到了同样的错误,例如gtk2:

~ sudo port install gtk2
Password:
--->  Computing dependencies for gtk2
The following dependencies will be installed: 
 clang-4.0
 clang-5.0
 graphite2
 harfbuzz
 ld64
 ld64-latest
 libmacho-headers
 libomp
 llvm-5.0
 pango
 perl5
 xar
 xorg-libXcomposite
 xorg-libXcursor
 xorg-libXdamage
 xorg-libXinerama
 xorg-libXrandr
 xorg-util-macros
Continue? [Y/n]: 
--->  Configuring clang-4.0
Error: clang-4.0 has been replaced by clang-8.0; please install that instead.
Error: Failed to configure clang-4.0: obsolete port
Error: See /opt/local/var/macports/logs/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_lang_llvm-4.0/clang-4.0/main.log for details.
Error: Follow https://guide.macports.org/#project.tickets to report a bug.
Error: Processing of port gtk2 failed

这里的安装建议安装clang-4.0等,我只能回答"Continue"。 但是,它随后无法声称完全相同的端口是 "obsolete"。建议改为安装 8.0。

但是,我已经通过 MacPorts 安装了它:

~ clang -v
clang version 8.0.0 (tags/RELEASE_800/final)
Target: x86_64-apple-darwin12.6.0
Thread model: posix
InstalledDir: /opt/local/bin
➜  ~ which clang
/opt/local/bin/clang

这里有什么问题,为什么 MacPorts 坚持安装过时的端口依赖项?


更新1。一些故障排除尝试...

➜  ~ port installed|grep llvm 
  cctools @921_2+llvm37 (active)
  llvm-3.7 @3.7.1_4 (active)
  llvm_select @2_0 (active)
➜  ~ 

更新 2.

~ sudo port uninstall lldb-4.0
Warning: no such port: lldb-4.0, skipping uninstall
➜  ~ sudo port uninstall clang-4.0
➜ ~ sudo port uninstall clang_select
--->  Deactivating clang_select @2_0
--->  Cleaning clang_select
--->  Uninstalling clang_select @2_0
--->  Cleaning clang_select
➜  ~ 

但是,clang-8.0 已安装并运行:

~ clang -v
clang version 8.0.0 (tags/RELEASE_800/final)
Target: x86_64-apple-darwin12.6.0
Thread model: posix
InstalledDir: /opt/local/bin
➜  ~ clang
clang-8: error: no input files
➜  ~ 

那为什么 MacPorts 找不到它?

➜  ~ sudo port install gtk2       
--->  Computing dependencies for gtk2
The following dependencies will be installed: 
 clang-4.0
 ...

我可以将它配置为在 /opt/local/bin 中找到而不是尝试安装旧的 clang-4.0 吗?


更新3。 我的配置目录:

➜  ~ ls /opt/local/etc/macports
archive_sites.conf         macports.conf.default      sources.conf               variants.conf.default
archive_sites.conf.default pubkeys.conf               sources.conf.default
macports.conf              pubkeys.conf.default       variants.conf
➜  ~ 
➜  ~ less /opt/local/etc/macports/macports.conf

# MacPorts system-wide configuration file.
# Commented-out values are defaults unless otherwise noted.

# Directory under which MacPorts should install ports. This must be
# where MacPorts itself is installed.
prefix                  /opt/local

# User to run operations as when MacPorts drops privileges.
#macportsuser           macports

# Directory for MacPorts working data.
portdbpath              /opt/local/var/macports

# Colon-delimited list of directories to search for external tools
# (make(1), pkg-config(1), etc.). While installing ports, MacPorts uses
# this list for PATH. Changing this setting is intended for advanced
# users only and is unsupported.
#binpath                /opt/local/bin:/opt/local/sbin:/bin:/sbin:/usr/bin:/usr/sbin

# Directory containing Xcode Tools. By default, MacPorts determines this
# using xcode-select(1).
#developer_dir          /Applications/Xcode.app/Contents/Developer

# Location of PackageMaker. Defaults to
# "${developer_dir}/Applications/Utilities/PackageMaker.app" with Xcode
# 4.2 and earlier and "/Applications/PackageMaker.app" with 4.3 and later.
#packagemaker_path      /Applications/PackageMaker.app

# Directory for application bundles installed by ports.
applications_dir        /Applications/MacPorts

# Directory for frameworks installed by ports.
frameworks_dir          /opt/local/Library/Frameworks

# Location of the MacPorts sources list.
sources_conf            /opt/local/etc/macports/sources.conf

# Location of the MacPorts global variants definition file. Optional.
variants_conf           /opt/local/etc/macports/variants.conf

# When MacPorts should build ports from source.
# - ifneeded: Download binary archives if available; build from source
#   otherwise.
# - always: Always build from source; never try fetching archives.
# - never: Never build from source; try fetching archives and abort if
#   unavailable.
#buildfromsource        ifneeded

# Type of archive to use for port images. Supported types are cpgz,
# cpio, tar, tbz, tbz2, tgz, tlz, txz, xar, zip.
#portarchivetype        tbz2

# Apply transparent filesystem compression to files on activation.
# Requires bsdtar with support for --hfsCompression in binpath, which can be
# provided by installing the libarchive port. This will work with HFS+ or APFS
# volumes only and will be ignored on other filesystems.
#hfscompression         yes

# CPU architecture to target. Supported values are "ppc", "ppc64",
# "i386", and "x86_64". Defaults to:
# - OS X 10.5 and earlier: "ppc" on PowerPC, otherwise "i386".
# - OS X 10.6 and later: "x86_64" on Intel 64, otherwise "i386".
#build_arch             i386

# Space-delimited list of CPU architectures to target when building
# universal. Defaults to "i386 ppc" on Mac OS X 10.5 and earlier,
# "x86_64 i386" on Mac OS X 10.6 through macOS 10.13, and "x86_64" on
# macOS 10.14 and later (the 10.14 SDK is not universal).
#universal_archs        x86_64 i386

# Use ccache, a compiler cache for C, C++, Objective-C, and
# Objective-C++. (See http://ccache.samba.org.) The "ccache" executable
# must exist in one of the directories in binpath.
#configureccache        no

# Directory for ccache's cached compiler output.
#ccache_dir             /opt/local/var/macports/build/.ccache

# Maximum size of files stored in ccache's cache. Append "G", "M", or
# "K" for gigabytes, megabytes, or kilobytes.

# Use distcc, a distributed compiler for C, C++, Objective-C, and
# Objective-C++. (See http://distcc.org.) The "distcc" executable must
# exist in one of the directories in binpath.
#configuredistcc        no

# Use pipes rather than temporary files for communication between the
# various stages of C, C++, Objective-C, and Objective-C++ compilation.
#configurepipe          yes

# Lowered scheduling priority to use for commands run during configure,
# build, and destroot. Accepted values are 0 (normal priority) through
# 20 (lowest priority).
#buildnicevalue         0

# Number of simultaneous make(1) jobs to use when building ports. If set
# to 0, the number of jobs will be the lesser of:
# - number of automatically-detected CPU cores
# - gigabytes of physical memory + 1
#buildmakejobs          0

# umask value to use when a port installs its files.
#destroot_umask         022

# Automatically execute "clean" after "install" of ports.
#portautoclean          yes

# Keep logs after successful installations.
#keeplogs               no

# The rsync server for fetching MacPorts base during selfupdate. This
# setting is NOT used when downloading ports trees; ports trees are
# configured using the file referenced by sources_conf. See
# https://trac.macports.org/wiki/Mirrors#MacPortsSource for a list of
# available servers.
#rsync_server           rsync.macports.org

# Location of MacPorts base sources on rsync_server. If this references
# a .tar file, a signed .rmd160 file must exist in the same directory
# and will be used to verify its integrity. See
# https://trac.macports.org/wiki/Mirrors#MacPortsSource to find the
# correct rsync_dir for a particular rsync_server.
#rsync_dir              macports/release/tarballs/base.tar

# Options to pass to rsync when fetching MacPorts base and the ports tree.
#rsync_options          -rtzvl --delete-after

# Type of generated StartupItems.
# - launchd: Create StartupItems for use with launchd.
# - default: Create StartupItems for launchd on OS X and none on
#   other platforms.
# - none: Disable creation of StartupItems.
# This setting only applies when building ports from source.
#startupitem_type       default

# Create system-level symlinks to generated StartupItems. If set to
# "no", symlinks will not be created; otherwise, symlinks will be placed
# in /Library/LaunchDaemons or /Library/LaunchAgents as appropriate.
# This setting only applies when building ports from source.
#startupitem_install    yes

# Whether to allow ports to automatically load their StartupItems.
# If set to "no", StartupItems will never be loaded unless the user
# explicitly requests it. If set to "yes" (the default), some ports may
# automatically load their StartupItems when they are activated.
#startupitem_autostart  yes

# Extra environment variables to keep. MacPorts sanitizes its
# environment while processing ports, keeping:
# - DISPLAY
# - DYLD_FALLBACK_FRAMEWORK_PATH, DYLD_FALLBACK_LIBRARY_PATH,
#   DYLD_FRAMEWORK_PATH, DYLD_INSERT_LIBRARIES, DYLD_LIBRARY_PATH
# - JAVA_HOME
# - ARCHIVE_SITE_LOCAL, MASTER_SITE_LOCAL, PATCH_SITE_LOCAL
# - PORTSRC
# - ALL_PROXY, FTP_PROXY, http_proxy, HTTPS_PROXY, NO_PROXY, RSYNC_PROXY
# - GROUP, USER
# - COLUMNS, LINES
# Variables listed in extra_env are added to this list. This has no
# default value; setting it is intended for advanced users and is
# unsupported. (Note that sudo(8) sanitizes its environment on OS X 10.5
# and later, so it may have to be configured to pass the desired
# variables to MacPorts.)
#extra_env              KEEP_THIS THIS_TOO

# Override proxy-related environment variables. By default, MacPorts
# takes proxy settings from the environment, from the proxy_* options
# below, and from Network Preferences, in that order. If this is set to
# "yes", MacPorts uses proxy_*, then Network Preferences, then the
# environment. (Note that Network Preferences does not have a setting
# for rsync proxies. Also note that sudo(8) sanitizes its environment on
# OS X 10.5 and later, so it may have to be configured to pass desired
# variables to MacPorts.)
#proxy_override_env     no

# Proxies. These have no default values. The analogous environment
# variables are "http_proxy", "HTTPS_PROXY", "FTP_PROXY", and
# "RSYNC_PROXY".
#proxy_http             proxy1:12345
#proxy_https            proxy2:67890
#proxy_ftp              proxy3:02139
#proxy_rsync            proxy4:11377

# Comma-delimited list of hosts that MacPorts should not access through
# the HTTP, HTTPS, and FTP proxies. This does not apply to rsync, and it
# has no default value.
#proxy_skip             host1, host2, host3

# Space-delimited lists of glob patterns matched against download hosts
# that MacPorts should not use and that MacPorts should prefer, respectively,
# overriding the usual ping time checks. These have no default values.
#host_blacklist         badhost1 badhost2
#preferred_hosts        preferredhost1 preferredhost2 *.de.*.macports.org

# Whether MacPorts should automatically run rev-upgrade after upgrading
# ports.
#revupgrade_autorun     yes

# Whether rev-upgrade should automatically rebuild ports with broken
# linking or merely report the breakage. Supported values are "report"
# and "rebuild".
#revupgrade_mode        rebuild

# Space-delimited list of files and directories to delete after the
# unarchive stage and before creating a pkg. Paths are interpreted
# relative to prefix, and there is no default value. This is useful for
# removing unnecessary files and directories prior to pkg or mpkg
# deployment.
#pkg_post_unarchive_deletions   include share/doc share/man

# Whether the user interface should ask interactive questions
#ui_interactive         yes

# Added to support C++11 following https://trac.macports.org/wiki/LibcxxOnOlderSystems
cxx_stdlib         libc++
buildfromsource    always
(END) 

这是一条过时消息。既然你已经有了替代品,那么卸载clang-4.0、llvm-4.0和lldb-4.0就可以了。

感谢 MacPorts mailing list 用户的提示,我终于解决了这个难题。他建议

port install <port> configure.compiler=macports-clang-8.0

但这对我不起作用,因为我的 clang8/usr/bin 中,而如果我理解正确的话,MacPorts 会寻找自己的软件包而不是从其他地方安装的软件包, 即使在我手动将其符号链接到 /opt/local/bin/clang.

之后

然后我读了this comment

We kept 3.4, 3.7, and 5.0 as stepping stones. I hope I thought that through fully...I think that’s the minimal amount needed.

然后我想到我可以尝试 clang-3.7 作为 "stepping stone",安装它,然后能够使用

安装其他端口
port install <port> configure.compiler=macports-clang-3.7

特别是,我还能够以这种方式安装 clang-5.0

port install clang-5.0 configure.compiler=macports-clang-3.7

现在我在链条中有了更新的垫脚石,问题似乎已经解决,不再有烦人的回退 过时的端口!


更多来源

MacPorts base 2.5.4 still has clang 4.0 in its list of compilers, even though the port has been made obsolete: ​https://github.com/macports/macports-base/blob/v2.5.4/src/port1.0/portconfigure.tcl#L604

它指向代码行604:

lappend compilers macports-clang-5.0 macports-clang-4.0

从那里看来 clang-4.05.0 之一是必需的。这可能是它坚持安装这些端口之一的原因,默认为过时的 4.0.

我认为修复应该包括向此列表添加更多端口,例如clang-3.7 并没有过时(希望没有更改它的计划)。 目前在

中提出

请添加您的声音以将其合并!