Skip to content

Commit

Permalink
libcxx: bootstrap with +emulated_tls on 10.6
Browse files Browse the repository at this point in the history
  • Loading branch information
catap authored and kencu committed Aug 3, 2022
1 parent fcccae1 commit 2a6125b
Showing 1 changed file with 13 additions and 65 deletions.
78 changes: 13 additions & 65 deletions lang/libcxx/Portfile
@@ -1,13 +1,12 @@
# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4

PortSystem 1.0
PortGroup compiler_blacklist_versions 1.0
PortGroup active_variants 1.1

name libcxx
epoch 1
version 5.0.1
revision 4
revision 5
categories lang
platforms darwin
license MIT NCSA
Expand Down Expand Up @@ -71,7 +70,7 @@ platform darwin {
# The Tiger SDK has an u after the version number,
set sdk_name MacOSX10.4u.sdk
} else {
set sdk_name MacOSX[join [lrange [split ${macosx_version} .] 0 1] .].sdk
set sdk_name MacOSX${macos_version_major}.sdk
}
lappend dirs ${developer_dir}/SDKs/${sdk_name}
}
Expand All @@ -94,58 +93,17 @@ if {${os.major} < 11 || [variant_isset replacemnt_libcxx]} {
configure.universal_archs i386 x86_64
}

# Use clang-11-bootstrap as bootstrap compiler
depends_build-append port:clang-11-bootstrap
depends_skip_archcheck-append \
port:clang-11-bootstrap
configure.cc ${prefix}/libexec/clang-11-bootstrap/bin/clang
configure.cxx ${prefix}/libexec/clang-11-bootstrap/bin/clang++

This comment has been minimized.

Copy link
@jmroot

jmroot Aug 8, 2022

Member

You've deleted all the compiler selection logic below, so now the dependencies are incorrect:

% port deps libcxx 
Full Name: libcxx @5.0.1_5+emulated_tls+universal
Extract Dependencies: xz-bootstrap
Build Dependencies:   clang-11-bootstrap, clang-11
Library Dependencies: libcxx

This comment has been minimized.

Copy link
@catap

catap Aug 8, 2022

Author Contributor

@jmroot yeah, I've forgot to add configure.compiler.add_deps no

This comment has been minimized.

Copy link
@jmroot

jmroot Aug 8, 2022

Member

That would take care of the clang-11 dependency, but not the libcxx self-dependency.

This comment has been minimized.

Copy link
@catap

catap Aug 8, 2022

Author Contributor

@jmroot yep, but clang-11 depends on libcxx via cmake for example.


if {${os.major} < 11} {
variant emulated_tls description {build libcxxabi and libcxx with support for emulated thread_local storage} {}

# only selected clang versions support emulated_tls, and the emulated_tls variant
# needs to be enabled to build libcxx with emulated_tls support
set emutls_clangs [list]
foreach clang_c ${compiler.fallback} {
if {[string match macports-clang-* $clang_c]} {
# Extract version number from macports clang compiler name
set clang_v [lindex [split $clang_c -] 2]
if {${clang_v} >= 5.0 && [file exists ${prefix}/bin/clang-mp-${clang_v}]
&& [active_variants clang-${clang_v} emulated_tls]} {
ui_debug "Adding ${clang_c} to list of compilers supporting emulated_tls"
lappend emutls_clangs ${clang_c}
}
}
}
if {[llength $emutls_clangs] > 0} {
default_variants-append +emulated_tls
} else {
if {![info exists registry_open]} {
registry::open [file join ${registry.path} registry registry.db]
set registry_open yes
}
foreach ent [registry::entry search name $name version $version revision $revision] {
if {[string match *+emulated_tls* [$ent variants]]} {
# this version of the port is already installed with +emulated_tls, so keep defaulting to it
default_variants-append +emulated_tls
break
}
}
}
if {[variant_isset emulated_tls]} {
compiler.whitelist-prepend [lindex $emutls_clangs end]
}

}

compiler.blacklist *gcc* {clang < 500}

# clang 3.5 and newer are conditionally blacklisted to prevent dependency cycles
foreach clang_c ${compiler.fallback} {
if {[string match macports-clang-* $clang_c]} {
# Extract version number from macports clang compiler name
set clang_v [lindex [split $clang_c -] 2]
if { ${clang_v} >= 3.5 } {
if {![file exists ${prefix}/bin/clang-mp-${clang_v}]} {
ui_debug "Adding ${clang_c} to compiler blacklist"
compiler.blacklist-append ${clang_c}
}
}
}
default_variants-append +emulated_tls
}

post-extract {
Expand All @@ -158,6 +116,9 @@ if {${os.major} < 11 || [variant_isset replacemnt_libcxx]} {
# cmake doesn't include this for darwin builds, so nuke it here as well
# however, this file is essential for emulated-tls to function
delete ${libcxxabi_worksrcpath}/src/cxa_thread_atexit.cpp
} else {
require_active_variants \
port:clang-11-bootstrap emulated_tls
}

file mkdir ${workpath}/build
Expand Down Expand Up @@ -247,19 +208,6 @@ if {${os.major} < 11 || [variant_isset replacemnt_libcxx]} {
system -W ${destroot}${roots_path}/${root_name} "tar czf ../${root_name}.tgz ."
delete ${destroot}${roots_path}/${root_name}
}

if {![variant_isset emulated_tls] && ${os.major} < 11} {
notes "
The libcxx you have installed is functional but does not have thread_local support.\
To rebuild libcxx with full thread_local support, please install clang-9.0 or any\
macports-clang >= clang-5.0 and then rebuild libcxx like this:
sudo port -v -n upgrade --force --enforce-variants libcxx +emulated_tls
and you will have a fully-functional libcxx installation.
"
}

} else {
supported_archs noarch
distfiles
Expand Down

0 comments on commit 2a6125b

Please sign in to comment.