Skip to content

[Clang][KASAN][RISCV]How to Correctly Build Clang Containing KASAN for RISCV #148331

Open
@dong-miao

Description

@dong-miao

Description

I am a beginner in clang.I want to debug the running process of LLVM KASAN for riscv64, but I used the following build configuration and ended up with an error. I want to know if there is a problem with my configuration.

And I specified to compile RISCV, why does the system still compile x86 files.

cmake -G Ninja \
    -DLLVM_ENABLE_PROJECTS="clang;compiler-rt" \
    -DCMAKE_BUILD_TYPE=Debug \
    -DCMAKE_C_COMPILER=/home/summer/riscv-llvm/build/bin/clang \
    -DCMAKE_CXX_COMPILER=/home/summer/riscv-llvm/build/bin/clang++ \
    -DLLVM_TARGETS_TO_BUILD="RISCV" \
    -DCOMPILER_RT_DEFAULT_TARGET_TRIPLE="riscv64-unknown-linux-gnu" \
    -DCMAKE_C_FLAGS=" -target riscv64-unknown-linux-gnu -B /opt/riscv/lib/gcc/riscv64-unknown-linux-gnu/14.2.0  -O0 -g"  \
    -DCMAKE_CXX_FLAGS=" -target riscv64-unknown-linux-gnu  -B /opt/riscv/lib/gcc/riscv64-unknown-linux-gnu/14.2.0  -O0 -g"  \
    -DCOMPILER_RT_BUILD_SANITIZERS=ON \
    -DCMAKE_CROSSCOMPILING=ON \
    -DCOMPILER_RT_BUILD_KASAN=ON \
    -DCMAKE_INSTALL_PREFIX=/home/summer/riscv-llvm/install \
    ../llvm

The error is:

FAILED: projects/compiler-rt/lib/asan/CMakeFiles/RTAsan_static.riscv64.dir/asan_rtl_x86_64.S.o
/home/summer/riscv-llvm/build/bin/clang -D_DEBUG -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/home/summer/riscv-llvm/build-rt/projects/compiler-rt/lib/asan -I/home/summer/riscv-llvm/compiler-rt/lib/asan -I/home/summer/riscv-llvm/build-rt/include -I/home/summer/riscv-llvm/llvm/include -I/home/summer/riscv-llvm/compiler-rt/lib/asan/.. -fPIC -g -fPIC -fno-builtin -fno-exceptions -fomit-frame-pointer -funwind-tables -fno-stack-protector -fno-sanitize=safe-stack -fvisibility=hidden -fno-lto -Wthread-safety -Wthread-safety-reference -Wthread-safety-beta -O3 -gline-tables-only -Wno-gnu -Wno-variadic-macros -Wno-c99-extensions -nostdinc++ -fno-rtti -Wno-format -MD -MT projects/compiler-rt/lib/asan/CMakeFiles/RTAsan_static.riscv64.dir/asan_rtl_x86_64.S.o -MF projects/compiler-rt/lib/asan/CMakeFiles/RTAsan_static.riscv64.dir/asan_rtl_x86_64.S.o.d -o projects/compiler-rt/lib/asan/CMakeFiles/RTAsan_static.riscv64.dir/asan_rtl_x86_64.S.o -c /home/summer/riscv-llvm/compiler-rt/lib/asan/asan_rtl_x86_64.S
In file included from /home/summer/riscv-llvm/compiler-rt/lib/asan/asan_rtl_x86_64.S:1:
In file included from /home/summer/riscv-llvm/compiler-rt/lib/asan/asan_mapping.h:16:
/home/summer/riscv-llvm/compiler-rt/lib/asan/../sanitizer_common/sanitizer_platform.h:18:4: error: "This operating system is not supported"
#  error "This operating system is not supported"
   ^
1 error generated.
[1856/3589] Building RISCVGenDAGISel.inc...
ninja: build stopped: subcommand failed.

Thank you all for your help!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions