[MacPorts] #71669: macports-libcxx: uses older c++ headers on newer macports-clang compilers
MacPorts
noreply at macports.org
Tue Sep 1 13:10:03 UTC 2026
#71669: macports-libcxx: uses older c++ headers on newer macports-clang compilers
------------------------------+--------------------
Reporter: kencu | Owner: (none)
Type: defect | Status: new
Priority: Normal | Milestone:
Component: ports | Version:
Resolution: | Keywords:
Port: macports-libcxx |
------------------------------+--------------------
Comment (by tomio-arisaka):
On macOS High Sierra (10.13), {{{legacysupport}}} PG and {{{macports-
libcxx}}} are very useful.
But some ports cannot be built with them due to {{{c++20}}} and
{{{c++23}}}.\\
So I tried to add the following keywords to the
{{{legacysupport-1.1.tcl}}} file in order to build {{{poppler}}},
{{{bitcoin}}}, and others.
* {{{legacysupport.use_mp_cxx_header}}}: Use C++ header files included in
macports clang instead of macports libcxx
* {{{legacysupport.use_mp_cxx_libcxx}}}: Use a libcxx runtime included in
macports clang instead of macports libcxx
These keywords work only if macports clang is chosen.
For example, how to use the new keywords:\\
In the {{{poppler}}} portfile, the following keywords work out:
{{{
legacysupport.use_mp_libcxx yes
legacysupport.use_mp_cxx_header yes
}}}
or
{{{
legacysupport.use_mp_cxx_libcxx yes
legacysupport.use_mp_cxx_header yes
}}}
The patch which adds the new keywords is as follows:
{{{
$ diff -u legacysupport-1.1.tcl.orig legacysupport-1.1.tcl
--- legacysupport-1.1.tcl.orig 2026-08-03 18:29:44.000000000 +0900
+++ legacysupport-1.1.tcl 2026-08-18 21:00:00.000000000 +0900
@@ -16,6 +16,10 @@
# create a wrapper so that only MacPorts
libstdc++ is used
#
# legacysupport.use_mp_libcxx: Use an update libcxx runtime from a
recent macports clang build
+#
+# legacysupport.use_mp_cxx_header: Use C++ header files included in
macports clang instead of macports libcxx
+#
+# legacysupport.use_mp_cxx_libcxx: Use a libcxx runtime included in
macports clang instead of macports libcxx
namespace eval legacysupport {
# Newest Darwin version that requires legacy support.
@@ -38,6 +42,12 @@
options legacysupport.use_mp_libcxx
default legacysupport.use_mp_libcxx no
+options legacysupport.use_mp_cxx_header
+default legacysupport.use_mp_cxx_header no
+
+options legacysupport.use_mp_cxx_libcxx
+default legacysupport.use_mp_cxx_libcxx no
+
if {[exists makefile.override]} {
pre-configure {
ui_error "The legacysupport PG must be included *before* the
makefile PG"
@@ -162,11 +172,29 @@
set ls_cache_cppflags "[legacysupport::get_cpp_flags]"
# Flags for using MP libcxx
- if { [option legacysupport.use_mp_libcxx] &&
${configure.cxx_stdlib} eq "libc++" } {
- legacysupport::add_once depends_lib append port:macports-
libcxx
- append ls_cache_incpath " ${prefix}/include/libcxx/v1"
- append ls_cache_ldflags " -L${prefix}/lib/libcxx"
- append ls_cache_cppflags " -nostdinc++
-isystem${prefix}/include/libcxx/v1"
+ if { ([option legacysupport.use_mp_libcxx] || [option
legacysupport.use_mp_cxx_libcxx]) && ${configure.cxx_stdlib} eq "libc++" }
{
+ global configure.compiler
+ set ls_cxx_inc "${prefix}/include/libcxx/v1"
+ # Flags for using C++ header files which are included in MP
clang instead of MP libcxx
+ if { [option legacysupport.use_mp_cxx_header] && [regexp
{^macports-clang-([0-9]+\.*[0-9]*$)} ${configure.compiler} matched
mp_clang_ver] == 1 } {
+ set ls_cxx_inc
"${prefix}/libexec/llvm-${mp_clang_ver}/include/c++/v1"
+ append ls_cache_cppflags "
-D_LIBCPP_DISABLE_AVAILABILITY"
+ }
+ set ls_cxx_lib "${prefix}/lib/libcxx"
+ # Flags for using a libcxx runtime which is included in MP
clang instead of MP libcxx
+ if { [option legacysupport.use_mp_cxx_libcxx] && [regexp
{^macports-clang-([0-9]+\.*[0-9]*$)} ${configure.compiler} matched
mp_clang_ver] == 1 } {
+ set ls_cxx_lib
"${prefix}/libexec/llvm-${mp_clang_ver}/lib/libc++"
+ append ls_cache_ldflags " -Wl,-rpath,${ls_cxx_lib}"
+ if {${mp_clang_ver} > 17} {
+ append ls_cache_ldflags "
-Wl,-rpath,${prefix}/libexec/llvm-${mp_clang_ver}/lib/libunwind"
+ }
+ legacysupport::add_once depends_lib append
port:clang-${mp_clang_ver}
+ } else {
+ legacysupport::add_once depends_lib append port:macports-
libcxx
+ }
+ append ls_cache_incpath " ${ls_cxx_inc}"
+ append ls_cache_ldflags " -L${ls_cxx_lib}"
+ append ls_cache_cppflags " -nostdinc++ -isystem${ls_cxx_inc}"
}
ui_debug "legacysupport: ldflags ${ls_cache_ldflags}"
@@ -215,6 +243,8 @@
option_proc legacysupport.newest_darwin_requires_legacy
legacysupport::legacysupport_proc
option_proc legacysupport.legacysupport.use_mp_libcxx
legacysupport::legacysupport_proc
option_proc legacysupport.legacysupport.use_static
legacysupport::legacysupport_proc
+option_proc legacysupport.legacysupport.use_mp_cxx_header
legacysupport::legacysupport_proc
+option_proc legacysupport.legacysupport.use_mp_cxx_libcxx
legacysupport::legacysupport_proc
# see https://trac.macports.org/ticket/59832
post-destroot {
}}}
I guess {{{legacysupport.use_mp_cxx_libcxx}}} is out of the main purpose
of {{{macports-libcxx}}}.
But it is useful for me in order to build {{{nodejs24}}} and
{{{NGSolve}}}.
I am using these keywords only on macOS High Sierra (10.13).
So I don't know whether they work right on the other macOS or not.
But I hope this patch will be an example for someone who wants to use
later {{{clang++}}} on earlier macOS.
--
Ticket URL: <https://trac.macports.org/ticket/71669#comment:5>
MacPorts <https://www.macports.org/>
Ports system for macOS
More information about the macports-tickets
mailing list