Bug 289673 - devel/wasi-libcxx19 lld_linker_error
Summary: devel/wasi-libcxx19 lld_linker_error
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: amd64 Any
: --- Affects Only Me
Assignee: Charlie Li
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-09-17 20:01 UTC by Mateusz Wiącek
Modified: 2025-10-10 18:12 UTC (History)
1 user (show)

See Also:
vishwin: maintainer-feedback+


Attachments
Build logs from poudriere (354.17 KB, text/plain)
2025-09-17 20:01 UTC, Mateusz Wiącek
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Mateusz Wiącek 2025-09-17 20:01:44 UTC
Created attachment 263892 [details]
Build logs from poudriere

Poudriere reports wasi-libcxx19-19.1.7 build as failed.

clang++: error: unsupported option '-march=' for target 'wasm32-wasi'
clang++: error: unsupported option '-march=' for target 'wasm32-wasi'

My make.conf

CPUTYPE ?= znver3

WITH_CCACHE_BUILD = YES

DEFAULT_VERSIONS += linux=rl9
#DEFAULT_VERSIONS += gcc=15
#DEFAULT_VERSIONS += java=21

LICENSES_ACCEPTED += Proprietary

No other changes
Comment 1 Charlie Li freebsd_committer freebsd_triage 2025-09-17 21:18:01 UTC
The error message is correct; you cannot use CPUTYPE or -march since this is technically a cross-compile to a non-x86 architecture, namely WebAssembly System Interface. Until I figure out something that ignores any CPUTYPE set for this and devel/wasi-compiler-rt, you will need to temporarily unset CPUTYPE at least for these two ports.
Comment 2 Mateusz Wiącek 2025-09-18 14:08:19 UTC
Thank you for your reply. Now I'm curious why on 14-STABLE I haven't encountered this error
Comment 3 Charlie Li freebsd_committer freebsd_triage 2025-09-25 19:36:44 UTC
(In reply to Mateusz Wiącek from comment #2)
There was a change in the base system that extended _CPUFLAGS into CXXFLAGS, which did not happen before.
Comment 4 commit-hook freebsd_committer freebsd_triage 2025-10-10 18:10:59 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 5 commit-hook freebsd_committer freebsd_triage 2025-10-10 18:11:03 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(+)