git: 9d078a8bc60d - main - bsd.port.mk: Make WITHOUT_CPU_CFLAGS also work for CXXFLAGS

From: Dimitry Andric <dim_at_FreeBSD.org>
Date: Fri, 10 Oct 2025 18:10:04 UTC
The branch main has been updated by dim:

URL: https://cgit.FreeBSD.org/ports/commit/?id=9d078a8bc60d0528b74b88f19b61911818d3a415

commit 9d078a8bc60d0528b74b88f19b61911818d3a415
Author:     Dimitry Andric <dim@FreeBSD.org>
AuthorDate: 2025-09-28 10:48:24 +0000
Commit:     Dimitry Andric <dim@FreeBSD.org>
CommitDate: 2025-10-10 18:09:38 +0000

    bsd.port.mk: Make WITHOUT_CPU_CFLAGS also work for CXXFLAGS
    
    In base 0fb33e049ac0 the _CPUFLAGS value (initialized from CPUTYPE in
    make.conf) is also being appended to CXXFLAGS, instead of only to
    CFLAGS.
    
    Some ports use WITHOUT_CPU_CFLAGS to avoid having CPUTYPE flags added to
    their command lines, for example devel/wasi-libcxx*.
    
    bsd.port.mk handles it like so:
    
    .    if defined(WITHOUT_CPU_CFLAGS)
    .      if defined(_CPUCFLAGS)
    .        if !empty(_CPUCFLAGS)
    CFLAGS:=        ${CFLAGS:C/${_CPUCFLAGS}//}
    .        endif
    .      endif
    .    endif
    
    However this will no longer work after base 0fb33e049ac0 (which is in
    main and stable/15), leading to build errors similar to:
    
    FAILED: [code=1] libcxxabi/src/CMakeFiles/cxxabi_static_objects.dir/cxa_aux_runtime.cpp.o
    /usr/local/llvm19/bin/clang++ --target=wasm32-wasi --sysroot=/usr/local/share/wasi-sysroot -DLIBCXXABI_SILENT_TERMINATE -DLIBCXX_BUILDING_LIBCXXABI -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LIBCPP_BUILDING_LIBRARY -D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER -D_LIBCXXABI_BUILDING_LIBRARY -D_LIBCXXABI_HAS_NO_THREADS -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/wrkdirs/usr/ports/devel/wasi-libcxx19/work/llvm-project-19.1.7.src/libcxxabi/../libcxx/src -I/wrkdirs/usr/ports/devel/wasi-libcxx19/work/.build/include/c++/v1 -I/wrkdirs/usr/ports/devel/wasi-libcxx19/work/llvm-project-19.1.7.src/libcxxabi/include -O2 -pipe -fno-strict-aliasing -march=haswell -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wstring-conversion -fdiagnostics-color -ffunction-secti
 ons -fdata-sections  -O2 -pipe -fno-strict-aliasing -march=haswell   -DNDEBUG -std=c++23 -D_DEBUG -UNDEBUG -MD -MT libcxxabi/src/CMakeFiles/cxxabi_static_objects.dir/cxa_aux_runtime.cpp.o -MF libcxxabi/src/CMakeFiles/cxxabi_static_objects.dir/cxa_aux_runtime.cpp.o.d -o libcxxabi/src/CMakeFiles/cxxabi_static_objects.dir/cxa_aux_runtime.cpp.o -c /wrkdirs/usr/ports/devel/wasi-libcxx19/work/llvm-project-19.1.7.src/libcxxabi/src/cxa_aux_runtime.cpp
    clang++: error: unsupported option '-march=' for target 'wasm32-wasi'
    
    Fix this by using the same logic for CXXFLAGS as for CFLAGS.
    
    PR:             289844, 289673
    Approved by:    portmgr timeout (2 weeks)
    MFH:            2025Q4
---
 Mk/bsd.port.mk | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Mk/bsd.port.mk b/Mk/bsd.port.mk
index eee8bfb7c45f..6c780d5628ff 100644
--- a/Mk/bsd.port.mk
+++ b/Mk/bsd.port.mk
@@ -1773,6 +1773,7 @@ CFLAGS:=	${CFLAGS:C/ $//}
 .      if defined(_CPUCFLAGS)
 .        if !empty(_CPUCFLAGS)
 CFLAGS:=	${CFLAGS:C/${_CPUCFLAGS}//}
+CXXFLAGS:=	${CXXFLAGS:C/${_CPUCFLAGS}//}
 .        endif
 .      endif
 .    endif