Skip to content

Cross-compilation error when using -march=rv64gcv #60164

@moluopro

Description

@moluopro

When cross-compiling the riscv64 platform, an error was encountered because the compilation parameter “-march=rv64gcv“ was specified. This parameter is necessary as I am doing related optimizations.

Why is it that when compiling with riscv64-linux-gnu-g++ there are still parts of the code that use the x86 compiler?

How can I specify compilation parameters for both compilers separately? Please let me know the specifics of the configuration file I want to modify. Thanks!

System version: Ubuntu24 LTS
Dart version: latest code in main branch

moluo@ubuntu:~/work/dart-sdk/sdk$ ./tools/build.py --no-clang --mode release --arch riscv64 create_sdk
Done. Made 665 targets from 129 files in 170ms
buildtools/ninja/ninja -C out/ReleaseXRISCV64 create_sdk
ninja: Entering directory `out/ReleaseXRISCV64'
[1188/4082] CXX obj/third_party/icu/source/i18n/icui18n.formattedvalue.o
../../third_party/icu/source/i18n/formattedvalue.cpp: In function ‘const char16_t* icu_74::ufmtval_getString_74(const UFormattedValue*, int32_t*, UErrorCode*)’:
../../third_party/icu/source/i18n/formattedvalue.cpp:215:1: warning: function may return address of local variable [-Wreturn-local-addr]
  215 | }
      | ^
../../third_party/icu/source/i18n/formattedvalue.cpp:205:19: note: declared here
  205 |     UnicodeString readOnlyAlias = impl->fFormattedValue->toTempString(*ec);
      |                   ^~~~~~~~~~~~~
[1194/4082] CXX obj/third_party/icu/source/i18n/icui18n.decNumber.o
../../third_party/icu/source/i18n/decNumber.cpp: In function ‘decNumber* uprv_decNumberLog10_74(decNumber*, const decNumber*, decContext*)’:
../../third_party/icu/source/i18n/decNumber.cpp:1528:14: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
 1528 |     w->lsu[1]=1; w->lsu[0]=0;           /* ..  */
      |     ~~~~~~~~~^~
In file included from ../../third_party/icu/source/i18n/decNumber.cpp:184:
../../third_party/icu/source/i18n/decNumber.h:89:19: note: at offset 1 into destination object ‘decNumber::lsu’ of size 1
   89 |     decNumberUnit lsu[DECNUMUNITS];
      |                   ^~~
../../third_party/icu/source/i18n/decNumber.cpp:1528:14: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
 1528 |     w->lsu[1]=1; w->lsu[0]=0;           /* ..  */
      |     ~~~~~~~~~^~
../../third_party/icu/source/i18n/decNumber.h:89:19: note: at offset 1 into destination object ‘decNumber::lsu’ of size 1
   89 |     decNumberUnit lsu[DECNUMUNITS];
      |                   ^~~
../../third_party/icu/source/i18n/decNumber.cpp: In function ‘decNumber* uprv_decNumberSquareRoot_74(decNumber*, const decNumber*, decContext*)’:
../../third_party/icu/source/i18n/decNumber.cpp:2974:31: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
 2974 |         t->lsu[0]=9; t->lsu[1]=5; t->lsu[2]=2;
      |                      ~~~~~~~~~^~
../../third_party/icu/source/i18n/decNumber.h:89:19: note: at offset 1 into destination object ‘decNumber::lsu’ of size 1
   89 |     decNumberUnit lsu[DECNUMUNITS];
      |                   ^~~
../../third_party/icu/source/i18n/decNumber.cpp:2974:44: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
 2974 |         t->lsu[0]=9; t->lsu[1]=5; t->lsu[2]=2;
      |                                   ~~~~~~~~~^~
../../third_party/icu/source/i18n/decNumber.h:89:19: note: at offset 2 into destination object ‘decNumber::lsu’ of size 1
   89 |     decNumberUnit lsu[DECNUMUNITS];
      |                   ^~~
[2534/4082] CXX x64/obj/runtime/bin/gen_snapshot_dart_io.console_win.o
FAILED: x64/obj/runtime/bin/gen_snapshot_dart_io.console_win.o 
x86_64-linux-gnu-g++ -MMD -MF x64/obj/runtime/bin/gen_snapshot_dart_io.console_win.o.d -DDART_IO_SECURE_SOCKET_DISABLED -D_FORTIFY_SOURCE=2 -DNDEBUG -DSUPPORT_PERFETTO -DDART_PRECOMPILER -DTARGET_ARCH_RISCV64 -DDART_TARGET_OS_LINUX -I../../runtime -I../../third_party -I../.. -Ix64/gen -I../../runtime/include -I../../third_party/zlib -m64 -march=x86-64 -msse2 -fPIE -Wall -Wextra -Werror -Wendif-labels -Wno-missing-field-initializers -Wno-unused-parameter -Wno-ignored-qualifiers -fdebug-prefix-map=/home/moluo/work/dart-sdk/sdk/= -no-canonical-prefixes -fvisibility=hidden -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -march=rv64gcv -O2 -fno-ident -fdata-sections -ffunction-sections -g3 -ggdb3 -Wno-unused-parameter -Wno-unused-private-field -Wnon-virtual-dtor -Wvla -Woverloaded-virtual -Wno-comments -g3 -ggdb3 -fno-rtti -fno-exceptions -Wno-cast-function-type -Wno-dangling-reference -O2 -fvisibility-inlines-hidden -fno-omit-frame-pointer -std=c++20 -std=c++20 -fno-rtti -c ../../runtime/bin/console_win.cc -o x64/obj/runtime/bin/gen_snapshot_dart_io.console_win.o
cc1plus: error: bad value ‘rv64gcv’ for ‘-march=’ switch
cc1plus: note: valid arguments to ‘-march=’ switch are: nocona core2 nehalem corei7 westmere sandybridge corei7-avx ivybridge core-avx-i haswell core-avx2 broadwell skylake skylake-avx512 cannonlake icelake-client rocketlake icelake-server cascadelake tigerlake cooperlake sapphirerapids emeraldrapids alderlake raptorlake meteorlake graniterapids graniterapids-d bonnell atom silvermont slm goldmont goldmont-plus tremont gracemont sierraforest grandridge knl knm x86-64 x86-64-v2 x86-64-v3 x86-64-v4 eden-x2 nano nano-1000 nano-2000 nano-3000 nano-x2 eden-x4 nano-x4 lujiazui k8 k8-sse3 opteron opteron-sse3 athlon64 athlon64-sse3 athlon-fx amdfam10 barcelona bdver1 bdver2 bdver3 bdver4 znver1 znver2 znver3 znver4 btver1 btver2 native
cc1plus: note: unrecognized command-line option ‘-Wno-unused-private-field’ may have been intended to silence earlier diagnostics
[2535/4082] CXX x64/obj/runtime/bin/gen_snapshot_dart_io.console_posix.o
FAILED: x64/obj/runtime/bin/gen_snapshot_dart_io.console_posix.o 
x86_64-linux-gnu-g++ -MMD -MF x64/obj/runtime/bin/gen_snapshot_dart_io.console_posix.o.d -DDART_IO_SECURE_SOCKET_DISABLED -D_FORTIFY_SOURCE=2 -DNDEBUG -DSUPPORT_PERFETTO -DDART_PRECOMPILER -DTARGET_ARCH_RISCV64 -DDART_TARGET_OS_LINUX -I../../runtime -I../../third_party -I../.. -Ix64/gen -I../../runtime/include -I../../third_party/zlib -m64 -march=x86-64 -msse2 -fPIE -Wall -Wextra -Werror -Wendif-labels -Wno-missing-field-initializers -Wno-unused-parameter -Wno-ignored-qualifiers -fdebug-prefix-map=/home/moluo/work/dart-sdk/sdk/= -no-canonical-prefixes -fvisibility=hidden -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -march=rv64gcv -O2 -fno-ident -fdata-sections -ffunction-sections -g3 -ggdb3 -Wno-unused-parameter -Wno-unused-private-field -Wnon-virtual-dtor -Wvla -Woverloaded-virtual -Wno-comments -g3 -ggdb3 -fno-rtti -fno-exceptions -Wno-cast-function-type -Wno-dangling-reference -O2 -fvisibility-inlines-hidden -fno-omit-frame-pointer -std=c++20 -std=c++20 -fno-rtti -c ../../runtime/bin/console_posix.cc -o x64/obj/runtime/bin/gen_snapshot_dart_io.console_posix.o
cc1plus: error: bad value ‘rv64gcv’ for ‘-march=’ switch
cc1plus: note: valid arguments to ‘-march=’ switch are: nocona core2 nehalem corei7 westmere sandybridge corei7-avx ivybridge core-avx-i haswell core-avx2 broadwell skylake skylake-avx512 cannonlake icelake-client rocketlake icelake-server cascadelake tigerlake cooperlake sapphirerapids emeraldrapids alderlake raptorlake meteorlake graniterapids graniterapids-d bonnell atom silvermont slm goldmont goldmont-plus tremont gracemont sierraforest grandridge knl knm x86-64 x86-64-v2 x86-64-v3 x86-64-v4 eden-x2 nano nano-1000 nano-2000 nano-3000 nano-x2 eden-x4 nano-x4 lujiazui k8 k8-sse3 opteron opteron-sse3 athlon64 athlon64-sse3 athlon-fx amdfam10 barcelona bdver1 bdver2 bdver3 bdver4 znver1 znver2 znver3 znver4 btver1 btver2 native
cc1plus: note: unrecognized command-line option ‘-Wno-unused-private-field’ may have been intended to silence earlier diagnostics
[2551/4082] ACTION //utils/dart2wasm:compile_dart2wasm_platform(//build/toolchain/linux:riscv64)
ninja: build stopped: subcommand failed.
BUILD FAILED

The reason for the error is here:

FAILED: x64/obj/runtime/bin/gen_snapshot_dart_io.console_win.o
x86_64-linux-gnu-g++ -MMD -MF x64/obj/runtime/bin/gen_snapshot_dart_io.console_win.o.d

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-buildUse area-build for SDK build issues.type-enhancementA request for a change that isn't a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions