Bug 289844 - WITHOUT_CPU_CFLAGS doesn't work for CXXFLAGS after base 0fb33e049ac0
Summary: WITHOUT_CPU_CFLAGS doesn't work for CXXFLAGS after base 0fb33e049ac0
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Ports Framework (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Some People
Assignee: Port Management Team
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-09-25 18:45 UTC by Dimitry Andric
Modified: 2025-10-10 18:12 UTC (History)
3 users (show)

See Also:


Attachments
Make WITHOUT_CPU_CFLAGS also apply to CXXFLAGS (360 bytes, patch)
2025-09-25 18:47 UTC, Dimitry Andric
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Dimitry Andric freebsd_committer freebsd_triage 2025-09-25 18:45:17 UTC
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-sections -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'

I will attach a proposed patch, which seems to work for me.
Comment 1 Dimitry Andric freebsd_committer freebsd_triage 2025-09-25 18:47:03 UTC
Created attachment 264092 [details]
Make WITHOUT_CPU_CFLAGS also apply to CXXFLAGS
Comment 2 Dimitry Andric freebsd_committer freebsd_triage 2025-09-29 21:16:54 UTC
Ok to commit this relatively simple fix?
Comment 3 commit-hook freebsd_committer freebsd_triage 2025-10-10 18:11:00 UTC
A commit in branch main references this bug:

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(+)
Comment 4 commit-hook freebsd_committer freebsd_triage 2025-10-10 18:11:01 UTC
A commit in branch 2025Q4 references this bug:

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

commit cda9162a0ffb86dbc36b3cc95c1136dc5c072638
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:10:24 +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

    (cherry picked from commit 9d078a8bc60d0528b74b88f19b61911818d3a415)

 Mk/bsd.port.mk | 1 +
 1 file changed, 1 insertion(+)