Hi all, I would like to configure my build to use custom clang binary.I have the args.gn below:target_os="linux"
target_cpu="riscv64"
is_component_build = trueis_debug=falseis_clang=true
clang_base_path=getenv("HOME") + "/riscv/_install"
clang_use_chrome_plugins=falseHowever, the GN output was showing the wrong arch settings passed into my custom clang binary. May i seek advice on how to configure the arch settings so that it passes -march=rv64gc into the compiler?[73/1863] CXX clang_x64/obj/third_party/perfetto/src/base/base/metatrace.o
FAILED: clang_x64/obj/third_party/perfetto/src/base/base/metatrace.o
../../../../riscv/_install/bin/clang++ -MMD -MF clang_x64/obj/third_party/perfetto/src/base/base/metatrace.o.d -DDCHECK_ALWAYS_ON=1 -DUSE_UDEV -DUSE_AURA=1 -
DUSE_GLIB=1 -DUSE_OZONE=1 -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D_FORTIFY_SOURCE=2 -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_GNU_SOURCE -DCOMPONENT_BUILD -D_LIBCPP_ABI_UNSTABLE -D_LIBCPP_ABI_VERSION=Cr -D_LIBCPP_ENABLE_NODISCARD -D_LIBCPP_DEBUG=0 -DCR_LIBCXX_REVISION=79a2e924d96e2fc1e4b937c42efd08898fa472d7 -DNDEBUG -DNVALGRIND -DDYNAMIC_ANNOTATIONS_ENABLED=0 -DPERFETTO_IMPLEMENTATION -I../.. -Iclang_x64/gen -I../../buildtools/third_party/libc++ -I../../third_party/perfetto -I../../third_party/perfetto/src/profiling/memory/include -I../../third_party/perfetto/include -Iclang_x64/
gen/third_party/perfetto/build_config -Iclang_x64/gen/third_party/perfetto -Wall -Wextra -Wimplicit-fallthrough -Wunreachable-code-aggressive -Wthread-safety -Wno-missing-field-initializers -Wno-unused-parameter -Wloop-analysis -Wno-unneeded-internal-declaration -Wenum-compare-conditional -Wno-psabi -Wno-ignored-pragma-optimize -Wno-unqualified-std-cast-call -Wshadow -fno-delete-null-pointer-checks -fno-ident -fno-strict-aliasing --param=ssp-buffer-size=4 -fstack-protector -funwind-tables -fPIC -pthread -fmerge-all-constants -fcrash-diagnostics-dir=../../tools/clang/crashreports -mllvm -instcombine-lower-dbg-declare=0 -ffp-contract=off -fcomplete-member-pointers -m64 -march=x86-64 -msse3 -Wno-builtin-macro-redefined -D__DATE__= -D__TIME__= -D__TIMESTAMP__= -ffile-compilation-dir=. -no-canonical-prefixes -ftrivial-auto-var-init=pattern -O2 -fdata-sections -ffunction-sections -fno-unique-section-names -fno-omit-frame-pointer -g0 -fvisibility=hidden -Wheader-hygiene -Wstring-conversion -Wtautological-overlap-compare -std=c++17
-Wno-trigraphs -fno-aligned-new -fno-exceptions -fno-rtti -nostdinc++ -isystem../../buildtools/third_party/libc++/trunk/include -isystem../../buildtools/third_party/libc++abi/trunk/include --sysroot=../../build/linux/debian_bullseye_amd64-sysroot -fvisibility-inlines-hidden -c ../../third_party/perfetto/src/base/metatrace.cc -o clang_x64/obj/third_party/perfetto/src/base/base/metatrace.o
clang++: error: invalid arch name 'x86-64', string must begin with rv32{i,e,g} or rv64{i,g}
--
--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev
---
You received this message because you are subscribed to the Google Groups "Chromium-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-dev...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-dev/cb3b4471-1908-4b45-b054-f8724d57e9f3n%40chromium.org.
Thanks for your pointer, but in the same file, I found there is clang_riscv64.I am using a x64 build host, and cross-compiling for riscv64. So I guess the cross-compiling environment got messed up somewhere. Probably the target_cpu and current_cpu settings. Do you know any good source of information about cross-compiling chromium src?
Thanks a lot, I managed to set it but now protoc is giving me some errors. Is it because the protoc I built is not supporting riscv64?
[4/648] ACTION //third_party/perfetto/protos/perfetto/config:descriptor_gen(//build/toolchain/linux:clang_riscv64)
FAILED: gen/third_party/perfetto/protos/perfetto/config/config.descriptor
python3 ../../tools/protoc_wrapper/protoc_wrapper.py protos/perfetto/config/trace_config.proto --protoc ./protoc --proto-in-dir ../../third_party/perfetto/ --descriptor-set-out gen/third_party/perfetto/protos/perfetto/config/config.descriptor --descriptor-set-dependency-file gen/third_party/perfetto/protos/perfetto/config/config.descriptor.d
Traceback (most recent call last):
File "../../tools/protoc_wrapper/protoc_wrapper.py", line 216, in <module>
main(sys.argv[1:])
File "../../tools/protoc_wrapper/protoc_wrapper.py", line 188, in main
ret = subprocess.call(protoc_cmd)
File "/usr/lib/python3.8/subprocess.py", line 340, in call
with Popen(*popenargs, **kwargs) as p:
File "/usr/lib/python3.8/subprocess.py", line 858, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "/usr/lib/python3.8/subprocess.py", line 1704, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
OSError: [Errno 8] Exec format error: '/home/rebecca.chang/chromium/src/out/riscv64/protoc'
You received this message because you are subscribed to a topic in the Google Groups "Chromium-dev" group.
To unsubscribe from this topic, visit
https://groups.google.com/a/chromium.org/d/topic/chromium-dev/S21NrXCIzxQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to
chromium-dev...@chromium.org.
To view this discussion on the web visit
https://groups.google.com/a/chromium.org/d/msgid/chromium-dev/CAPNB-6U2zDh7t03w%3DH-5O%2BnJATSzJf3XrdGctfZA%3DDYGkNx_rg%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-dev/f99edc0dcb5f4beda132fdf94dd57538%40EXMBX172.cuchost.com.
I am building a riscv64 target on x86.
The output from file is
$ file /home/rebecca.chang/chromium/src/out/riscv64/protoc
/home/rebecca.chang/chromium/src/out/riscv64/protoc: ELF 64-bit LSB shared object, UCB RISC-V, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-riscv64-lp64d.so.1, BuildID[sha1]=cdbc7f0a6062801d15746b3ad10cf002fca1ae8f, for GNU/Linux 4.15.0, with debug_info, not stripped
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-dev/CAPNB-6W%2BqvXydCJ3qW8XandX9%3DGweq8qOwXEB8xpMA-8C1cdhA%40mail.gmail.com.
Thanks for all the info. I will need to rebuild my toolchain to support both x64 and riscv target.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-dev/CAMGbLiGk3C_bg0hR_a_M9GCD%3DPC2XtqN9E2D9gM4v54FrAq7-A%40mail.gmail.com.
Hi all,
Some updates where I am able to add RISCV as one of the target in https://source.chromium.org/chromium/chromium/src/+/main:tools/clang/scripts/build.py script.
And I can build a clang toolchain locally using the script. Also, I have removed the clang_base_path from my args.gn since I have a copy of clang build in //third_party/llvm-build/Release+Asserts/bin .
But further compiling gave me some weird issue:
I ran $ autoninja skia. Libc++ is giving some errors unsupported architecture. But I believe libc++ does support riscv64 right?
[64/3397] CXX obj/buildtools/third_party/libc++/libc++/string.o
FAILED: obj/buildtools/third_party/libc++/libc++/string.o
../../third_party/llvm-build/Release+Asserts/bin/clang++ -MMD -MF obj/buildtools/third_party/libc++/libc++/string.o.d -DLIBCXX_BUILDING_LIBCXXABI -DDCHECK_ALWAYS_ON=1 -DUSE_UDEV -DUSE_AURA=1 -DUSE_GLIB=1 -DUSE_OZONE=1 -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_GNU_SOURCE -DCR_CLANG_REVISION=\"llvmorg-15-init-5937-g23b3df56-1\" -DCOMPONENT_BUILD -D_LIBCPP_ABI_UNSTABLE -D_LIBCPP_ABI_VERSION=Cr -D_LIBCPP_ENABLE_NODISCARD -D_LIBCPP_DEBUG=0 -DCR_LIBCXX_REVISION=79a2e924d96e2fc1e4b937c42efd08898fa472d7 -DNDEBUG -DNVALGRIND -DDYNAMIC_ANNOTATIONS_ENABLED=0 -D_LIBCPP_BUILDING_LIBRARY -I../.. -Igen -I../../buildtools/third_party/libc++ -fno-delete-null-pointer-checks -fno-ident -fno-strict-aliasing --param=ssp-buffer-size=4 -fstack-protector -funwind-tables -fPIC -pthread -fmerge-all-constants -fcrash-diagnostics-dir=../../tools/clang/crashreports -mllvm -instcombine-lower-dbg-declare=0 -ffp-contract=off -fcomplete-member-pointers --target=riscv64 -m64 -march=rv64gc -mabi=lp64d -Wno-builtin-macro-redefined -D__DATE__= -D__TIME__= -D__TIMESTAMP__= -ffile-compilation-dir=. -no-canonical-prefixes -ftrivial-auto-var-init=pattern -O2 -fdata-sections -ffunction-sections -fno-unique-section-names -fno-omit-frame-pointer -g0 -Xclang -add-plugin -Xclang find-bad-constructs -Xclang -plugin-arg-find-bad-constructs -Xclang raw-ptr-template-as-trivial-member -Xclang -plugin-arg-find-bad-constructs -Xclang use-classify-type -Xclang -plugin-arg-find-bad-constructs -Xclang check-ipc -Wheader-hygiene -Wstring-conversion -Wtautological-overlap-compare -fstrict-aliasing -fPIC -isystem../../build/linux/debian_sid_riscv64-sysroot/usr/include -Wall -Wno-unused-variable -Wno-c++11-narrowing -Wno-unused-but-set-variable -Wno-misleading-indentation -Wno-missing-field-initializers -Wno-unused-parameter -Wloop-analysis -Wno-unneeded-internal-declaration -Wenum-compare-conditional -Wno-psabi -Wno-ignored-pragma-optimize -Wno-unqualified-std-cast-call -fvisibility=default -std=c++17 -Wno-trigraphs -fno-aligned-new -nostdinc++ -isystem../../buildtools/third_party/libc++/trunk/include -isystem../../buildtools/third_party/libc++abi/trunk/include --sysroot=../../build/linux/debian_sid_riscv64-sysroot -std=c++20 -fexceptions -frtti -c ../../buildtools/third_party/libc++/trunk/src/string.cpp -o obj/buildtools/third_party/libc++/libc++/string.o
In file included from ../../buildtools/third_party/libc++/trunk/src/string.cpp:9:
In file included from ../../buildtools/third_party/libc++/trunk/include/string:516:
../../buildtools/third_party/libc++/trunk/include/__config:1154:6: error: "No thread API"
# error "No thread API"
^
In file included from ../../buildtools/third_party/libc++/trunk/src/string.cpp:9:
In file included from ../../buildtools/third_party/libc++/trunk/include/string:518:
In file included from ../../buildtools/third_party/libc++/trunk/include/string_view:186:
In file included from ../../buildtools/third_party/libc++/trunk/include/__string:14:
In file included from ../../buildtools/third_party/libc++/trunk/include/algorithm:653:
In file included from ../../buildtools/third_party/libc++/trunk/include/memory:690:
In file included from ../../buildtools/third_party/libc++/trunk/include/__memory/shared_ptr.h:30:
In file included from ../../buildtools/third_party/libc++/trunk/include/atomic:579:
../../buildtools/third_party/libc++/trunk/include/__threading_support:144:3: error: Unsupported architecture
# error Unsupported architecture
^
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-dev/c73ee467813f4d5da2470e4f7451b30a%40EXMBX172.cuchost.com.
Hi all,
Some updates where I am able to add RISCV as one of the target in https://source.chromium.org/chromium/chromium/src/+/main:tools/clang/scripts/build.py script.
And I can build a clang toolchain locally using the script. Also, I have removed the clang_base_path from my args.gn since I have a copy of clang build in //third_party/llvm-build/Release+Asserts/bin .
But further compiling gave me some weird issue:
I ran $ autoninja skia. Libc++ is giving some errors unsupported architecture. But I believe libc++ does support riscv64 right?
Hi,
>> You may need to disable use_custom_libcxx in
[Rebecca Chang] Thank you. I have them set in the args.gn now.
use_custom_libcxx=false
use_custom_libcxx_for_host=true
Sorry, as I’m not an expert in the compiler. The settings look promising to me, but right now the linker seems to be finding a file which was in the sysroot. I’m not sure why the linker isn’t able to pick up the file.
An example when it is linking:
$ python3 "../../build/toolchain/gcc_solink_wrapper.py" --readelf="../../third_party/llvm-build/Release+Asserts/bin/llvm-readelf" --nm="../../third_party/llvm-build/Release+Asserts/bin/llvm-nm" --sofile="./libchrome_zlib.so" --tocfile="./libchrome_zlib.so.TOC" --output="./libchrome_zlib.so" -- ../../third_party/llvm-build/Release+Asserts/bin/clang++ -v -shared -Wl,-soname="libchrome_zlib.so" -Wl,--build-id -fPIC -Wl,-z,noexecstack -Wl,-z,relro -m64 -L../../build/linux/debian_sid_riscv64-sysroot/usr/lib64/lp64d -no-canonical-prefixes -Wl,-O2 -Wl,--gc-sections -rdynamic -Wl,-z,defs -Wl,--as-needed --sysroot=../../build/linux/debian_sid_riscv64-sysroot -Wl,-rpath=\$ORIGIN -Wl,-O2 -Wl,--gc-sections -o "./libchrome_zlib.so" @"./libchrome_zlib.so.rsp"
The output:
clang version 15.0.0 (https://github.com/llvm/llvm-project/ 23b3df5675362cd031f674b76239e5de6fd0077a)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: ../../third_party/llvm-build/Release+Asserts/bin
"/usr/bin/ld" --sysroot=../../build/linux/debian_sid_riscv64-sysroot -export-dynamic -z relro --hash-style=gnu --eh-frame-hdr -m elf_x86_64 -shared -export-dynamic -o ./libchrome_zlib.so crti.o crtbeginS.o -L../../build/linux/debian_sid_riscv64-sysroot/usr/lib64/lp64d -L../../build/linux/debian_sid_riscv64-sysroot/lib/../lib64 -L../../build/linux/debian_sid_riscv64-sysroot/usr/lib/../lib64 -L../../build/linux/debian_sid_riscv64-sysroot/lib -L../../build/linux/debian_sid_riscv64-sysroot/usr/lib -soname=libchrome_zlib.so --build-id -z noexecstack -z relro -O2 --gc-sections -z defs --as-needed "-rpath=\$ORIGIN" -O2 --gc-sections --whole-archive obj/third_party/zlib/zlib/adler32.o obj/third_party/zlib/zlib/compress.o obj/third_party/zlib/zlib/cpu_features.o obj/third_party/zlib/zlib/crc32.o obj/third_party/zlib/zlib/deflate.o obj/third_party/zlib/zlib/gzclose.o obj/third_party/zlib/zlib/gzlib.o obj/third_party/zlib/zlib/gzread.o obj/third_party/zlib/zlib/gzwrite.o obj/third_party/zlib/zlib/infback.o obj/third_party/zlib/zlib/inffast.o obj/third_party/zlib/zlib/inftrees.o obj/third_party/zlib/zlib/trees.o obj/third_party/zlib/zlib/uncompr.o obj/third_party/zlib/zlib/zutil.o obj/third_party/zlib/zlib/inflate.o --no-whole-archive -latomic -ldl -lpthread -lrt --whole-archive --no-whole-archive -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc crtendS.o crtn.o
/usr/bin/ld: cannot find crti.o: No such file or directory
/usr/bin/ld: cannot find crtbeginS.o: No such file or directory
/usr/bin/ld: obj/third_party/zlib/zlib/adler32.o: Relocations in generic ELF (EM: 243)
/usr/bin/ld: obj/third_party/zlib/zlib/adler32.o: Relocations in generic ELF (EM: 243)
/usr/bin/ld: obj/third_party/zlib/zlib/adler32.o: Relocations in generic ELF (EM: 243)
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
[Rebecca Chang] The crti.o file is in the sysroot:
$ find . -name "crti.o"
./build/linux/debian_sid_riscv64-sysroot/usr/lib64/lp64d/crti.o
./build/linux/debian_sid_riscv64-sysroot/usr/lib64/lp64/crti.o
./build/linux/debian_sid_riscv64-sysroot/usr/lib32/ilp32/crti.o
./build/linux/debian_sid_riscv64-sysroot/usr/lib32/ilp32d/crti.o
./build/linux/debian_sid_riscv64-sysroot/usr/lib/riscv64-linux-gnu/crti.o
./build/linux/debian_sid_riscv64-sysroot/usr/lib/gcc/riscv64-linux-gnu/10/crti.o
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-dev/CALNjmMrwWcMN-CN%2B0gw9i2KBOoz1oHMdjerRQhqeL2X-4GVUfQ%40mail.gmail.com.