Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cross compile build for riscv64 fails on Ubuntu 22.04 #50645

Closed
maks opened this issue Dec 7, 2022 · 1 comment
Closed

cross compile build for riscv64 fails on Ubuntu 22.04 #50645

maks opened this issue Dec 7, 2022 · 1 comment
Labels
area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends.

Comments

@maks
Copy link

maks commented Dec 7, 2022

Following the instructions on the wiki I tried building for RISC-V on my x86 (AMD) laptop and this is the error I get is for cross-compiling the SDK for risc-v is:

./tools/build.py --no-goma --no-clang -m release -a riscv64 create_sdk
Done. Made 381 targets from 89 files in 178ms
buildtools/ninja/ninja -C out/ReleaseXRISCV64 create_sdk
ninja: Entering directory `out/ReleaseXRISCV64'
[1851/5076] CXX obj/runtime/vm/libdart_vm_precompiler_product.image_snapshot.o
FAILED: obj/runtime/vm/libdart_vm_precompiler_product.image_snapshot.o 
riscv64-linux-gnu-g++ -MMD -MF obj/runtime/vm/libdart_vm_precompiler_product.image_snapshot.o.d -D_FORTIFY_SOURCE=2 -DNDEBUG -DTARGET_ARCH_RISCV64 -DDART_USE_TCMALLOC -DDART_TARGET_OS_LINUX -DDART_PRECOMPILER -DPRODUCT -DU_USING_ICU_NAMESPACE=0 -DU_ENABLE_DYLOAD=0 -DUSE_CHROMIUM_ICU=1 -DU_ENABLE_TRACING=1 -DU_ENABLE_RESOURCE_TRACING=0 -DU_STATIC_IMPLEMENTATION -DICU_UTIL_DATA_IMPL=ICU_UTIL_DATA_FILE -I../../runtime -I../.. -Igen -I../../runtime/include -I../../third_party/tcmalloc/gperftools/src -I../../third_party/icu/source/common -I../../third_party/icu/source/i18n -fPIC -Wall -Wextra -Werror -Wendif-labels -Wno-missing-field-initializers -Wno-unused-parameter -Wno-ignored-qualifiers -fdebug-prefix-map=/home/maks/builds/dart-sdk/sdk=../.. -no-canonical-prefixes -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -O3 -fno-ident -fdata-sections -ffunction-sections -g3 -ggdb3 -Werror -Wall -Wextra -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 -O3 -fvisibility=hidden -fvisibility-inlines-hidden -fno-omit-frame-pointer -std=c++17 -fno-rtti -c ../../runtime/vm/image_snapshot.cc -o obj/runtime/vm/libdart_vm_precompiler_product.image_snapshot.o
../../runtime/vm/image_snapshot.cc: In member function ‘virtual void dart::AssemblyImageWriter::ExitSection(dart::ImageWriter::ProgramSection, bool, intptr_t)’:
../../runtime/vm/image_snapshot.cc:1416:27: error: ‘%s’ directive argument is null [-Werror=format-overflow=]
 1416 |   assembly_stream_->Printf(".size %s, %zu\n", SectionSymbol(name, vm), size);
      |   ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../runtime/vm/image_snapshot.cc:1417:27: error: ‘%s’ directive argument is null [-Werror=format-overflow=]
 1417 |   assembly_stream_->Printf(".type %s, %%object\n", SectionSymbol(name, vm));
      |   ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
At global scope:
cc1plus: note: unrecognized command-line option ‘-Wno-unused-private-field’ may have been intended to silence earlier diagnostics
cc1plus: all warnings being treated as errors
[1868/5076] CXX obj/runtime/vm/libdart_vm_precompiled_runtime_product.object.o
ninja: build stopped: subcommand failed.
BUILD FAILED

This seems to be newer versions of gcc being more fussy about potential null arguments used in printf.

I followed the instructions to install the risc-v cross-compiler with apt so I have:

/usr/bin/riscv64-linux-gnu-g++ --version
riscv64-linux-gnu-g++ (Ubuntu 11.3.0-1ubuntu1~22.04) 11.3.0

Attempting the same command to compile the native version of the SDK (x64) gives the same error.
Doing so with I assume clang instead of gcc works:

/tools/build.py --no-goma -m release -a x64 create_sdk
Done. Made 348 targets from 90 files in 127ms
buildtools/ninja/ninja -C out/ReleaseX64 create_sdk
ninja: Entering directory `out/ReleaseX64'
[3629/3629] STAMP obj/create_sdk.stamp
The build took 673.270 seconds

But if I attempt to use clang to build for riscv64 I get:

./tools/build.py --no-goma -m release -a riscv64 create_sdk
Done. Made 381 targets from 90 files in 177ms
buildtools/ninja/ninja -C out/ReleaseXRISCV64 create_sdk
ninja: Entering directory `out/ReleaseXRISCV64'
[3/5076] CXX obj/runtime/bin/elf_loader.virtual_memory_fuchsia.o
FAILED: obj/runtime/bin/elf_loader.virtual_memory_fuchsia.o 
../../buildtools/linux-x64/clang/bin/clang++ -MMD -MF obj/runtime/bin/elf_loader.virtual_memory_fuchsia.o.d -DTOOLCHAIN_VERSION=r2G18YIAK34NbwRXt2sm5ZlMA0QhhvPDqM5Ccy24kRQC -DNDEBUG -DTARGET_ARCH_RISCV64 -DDART_USE_TCMALLOC -DPRODUCT -DDART_TARGET_OS_FUCHSIA -I../../runtime -I../.. -Igen -I../../runtime/include -I../../third_party/tcmalloc/gperftools/src -fPIC --target=riscv64-linux-gnu -fcolor-diagnostics -Wall -Wextra -Werror -Wendif-labels -Wno-missing-field-initializers -Wno-unused-parameter -Wno-tautological-constant-compare -Wno-unused-but-set-variable -Wno-deprecated-non-prototype -fdebug-prefix-map=/home/maks/builds/dart-sdk/sdk=../.. -no-canonical-prefixes -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -Wheader-hygiene -Wstring-conversion -O3 -fno-ident -fdata-sections -ffunction-sections -g3 -ggdb3 -Werror -Wall -Wextra -Wno-unused-parameter -Wno-unused-private-field -Wnon-virtual-dtor -Wvla -Woverloaded-virtual -Wno-comments -g3 -ggdb3 -fno-rtti -fno-exceptions -Wimplicit-fallthrough -fno-strict-vtable-pointers -O3 -fvisibility=hidden -fvisibility-inlines-hidden -fno-omit-frame-pointer -std=c++17 -fno-rtti -c ../../runtime/bin/virtual_memory_fuchsia.cc -o obj/runtime/bin/elf_loader.virtual_memory_fuchsia.o
In file included from ../../runtime/bin/virtual_memory_fuchsia.cc:5:
In file included from ../../runtime/platform/globals.h:80:
In file included from ../../buildtools/linux-x64/clang/bin/../include/c++/v1/float.h:73:
../../buildtools/linux-x64/clang/bin/../include/c++/v1/__config:13:10: fatal error: '__config_site' file not found
#include <__config_site>
         ^~~~~~~~~~~~~~~
1 error generated.

So is there a specific version of gcc I should be using for cross compiling for riscv64 ?

@kevmoo
Copy link
Member

kevmoo commented Dec 7, 2022

CC @rmacnak-google

@kevmoo kevmoo added the area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. label Dec 7, 2022
copybara-service bot pushed a commit that referenced this issue Dec 15, 2022
TEST=local builds
Bug: #50645
Change-Id: If6cd26620feff06abd449be0f7d1dd1e620b8411
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/275841
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends.
Projects
None yet
Development

No branches or pull requests

3 participants