mrk-its / rust-mos

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
55 stars 7 forks source link

const class llvm::APInt’ has no member named ‘zextOrSelf’ #4

Closed ghost closed 2 years ago

ghost commented 2 years ago

When compiling the code using the directions on the readme page, I get the following error: cargo:warning=llvm-wrapper/RustWrapper.cpp:1541:28: error: ‘const class llvm::APInt’ has no member named ‘sextOrSelf’ cargo:warning= 1541 | AP = C->getValue().sextOrSelf(128); cargo:warning= | ^~~~~~ cargo:warning=llvm-wrapper/RustWrapper.cpp:1543:28: error: ‘const class llvm::APInt’ has no member named ‘zextOrSelf’ cargo:warning= 1543 | AP = C->getValue().zextOrSelf(128);

error occurred: Command "c++" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-m64" "-ffunction-sections" "-fdata-sections" "-fPIC" "-m64" "-I/usr/local/include" "-std=c++14" "-fno-exceptions" "-fno-rtti" "-D_GNU_SOURCE" "-DSTDC_CONSTANT_MACROS" "-DSTDC_FORMAT_MACROS" "-D__STDC_LIMIT_MACROS" "-DLLVM_COMPONENT_ASMPARSER" "-DLLVM_COMPONENT_BITREADER" "-DLLVM_COMPONENT_BITWRITER" "-DLLVM_COMPONENT_COVERAGE" "-DLLVM_COMPONENT_INSTRUMENTATION" "-DLLVM_COMPONENT_IPO" "-DLLVM_COMPONENT_LINKER" "-DLLVM_COMPONENT_LTO" "-DLLVM_COMPONENT_MOS" "-DLLVM_COMPONENT_X86" "-DNDEBUG" "-o" "/workspace/rust-mos/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/build/rustc_llvm-475f372969e8d34a/out/llvm-wrapper/RustWrapper.o" "-c" "llvm-wrapper/RustWrapper.cpp" with args "c++" did not execute successfully (status code exit status: 1).

Looking at the file at https://github.com/rust-lang/rust/blob/master/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp: I find the following code:

extern "C" bool LLVMRustConstInt128Get(LLVMValueRef CV, bool sext, uint64_t high, uint64_t low) { auto C = unwrap(CV); if (C->getBitWidth() > 128) { return false; } APInt AP;

if LLVM_VERSION_GE(15, 0)

if (sext) {
    AP = C->getValue().sext(128);
} else {
    AP = C->getValue().zext(128);
}

else

running: rustc 1.61.0 (fe5b13d68 2022-05-18) clang version 15.0.0 (https://github.com/llvm-mos/llvm-mos.git d1f2bf8b6dba96c40affca6b4035a255b6b822d8) Target: mos-unknown-unknown Thread model: posix

llvm-config gives me the following: llvm-config --version 15.0.0git

Any ideas?

mrk-its commented 2 years ago

Thanks, I'll try to reproduce it

ghost commented 2 years ago

I'm creating a docker file so that downloading and compiler (might) be easier. The contents of the docker file are below: `` FROM ubuntu:latest

RUN apt update

run apt install -y git cmake python3 zlib1g make g++-10 clang binutils build-essential gcc ninja-build curl libssl-dev pkg-config bash

run apt install -y linux-headers-$(uname -r)

run mkdir /workspace run cd /workspace

WORKDIR "/workspace/"

run git clone https://github.com/llvm-mos/llvm-mos.git

run cd /workspace/llvm-mos

WORKDIR "/workspace/llvm-mos"

run cmake -C ./clang/cmake/caches/MOS.cmake -G "Ninja" -S llvm -B build \ -DLLVM_INSTALL_TOOLCHAIN_ONLY=OFF \ -DLLVM_BUILD_LLVM_DYLIB=ON -DLLVM_LINK_LLVM_DYLIB=ON \ -DLLVM_INSTALL_UTILS=ON -DLLVM_BUILD_UTILS=ON -DLLVM_TOOLCHAIN_UTILITIES=FileCheck \ -DLLVM_TOOLCHAIN_TOOLS="llvm-addr2line;llvm-ar;llvm-cxxfilt;llvm-dwarfdump;llvm-mc;llvm-nm;llvm-objcopy;llvm-objdump;llvm-ranlib;llvm-readelf;llvm-readobj;llvm-size;llvm-strings;llvm-strip;llvm-symbolizer;llvm-config;llc" \ -DLIBXML2_LIBRARY=/usr/lib/x86_64-linux-gnu/libxml2.so \ -DLLVM_TARGETS_TO_BUILD="MOS;X86" \ -DLLVM_ENABLE_PROJECTS="clang;lld;lldb"

run cmake --build build -t install

run cd /workspace WORKDIR "/workspace/"

run git clone https://github.com/llvm-mos/llvm-mos-sdk.git

run cd /workspace/llvm-mos-sdk WORKDIR "/workspace/llvm-mos-sdk"

run cmake -G "Ninja" -B build run cmake --build build -t install

run export RUST_TARGET_PATH=/usr/local/rust-mos-targets/

run cd /workspace WORKDIR "/workspace/"

run git clone https://github.com/mrk-its/rust-mos.git

run cd /workspace/rust-mos WORKDIR "/workspace/rust-mos"

run cp config.toml.example config.toml

run python3 ./x.py build -i --stage 0 src/tools/cargo run python3 x.py build -i && ( \ ln -s ../../stage0-tools-bin/cargo build/x86_64-unknown-linux-gnu/stage1/bin/cargo \ rustup toolchain link mos build/x86_64-unknown-linux-gnu/stage1 \ rustup default mos \ mkdir -p $RUST_TARGET_PATH \ python3 create_mos_targets.py $RUST_TARGET_PATH \ ) ``

mrk-its commented 2 years ago

I see llvm-mos merged recently upstream changes, so I need probably rebase rust-mos code on latest head too. Will work on it tomorrow.

mrk-its commented 2 years ago

After merging upstream rust changes it should work (I'm building docker images without problems now). Closing.