iovisor / iovisor/bcc

Fails to build with LLVM 8 due to non-const lvalue reference to type 'llvm::APSInt'

Open
#2,513 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C
Stars
22.7k
Forks
4.1k
Avg merge
5d 13h
Merged PRs (30d)
3

Description

```
$ git describe
v0.10.0-94-gd147588e
```

Should it matter, I'm running Linux kernel 4.19.37.

Build command:

```
$ ( rm -rf build ; mkdir build && cd build && export PATH=/usr/bin:/bin CC=clang-8 CXX=clang++-8 && cmake .. -GNinja -DCMAKE_INSTALL_PREFIX=$HOME/opt && env -u LUA_PATH ninja && ninja install )
```

Most files seem to build. Error:

```[69/262] Building CXX object src/cc/frontends/clang/CMakeFiles/clang_frontend.dir/b_frontend_action.cc.o
FAILED: src/cc/frontends/clang/CMakeFiles/clang_frontend.dir/b_frontend_action.cc.o
/usr/bin/clang++-8 -I/usr/lib/llvm-8/include/../tools/clang/include -I../src -Isrc -Isrc/cc -I../src/cc -Isrc/cc/frontends/b -I../src/cc/frontends/b -I../src/cc/frontends/clang -I/usr/lib/llvm-8/include -I../src/cc/libbpf/include -I../src/cc/libbpf/include/uapi -Wall -isystem /usr/lib/llvm-8/include -fno-rtti -fPIC -DBCC_PROG_TAG_DIR='"/var/tmp/bcc"' -Wno-unused-result -DLLVM_MAJOR_VERSION=8 -DKERNEL_MODULES_DIR='"/lib/modules"' -O3 -DNDEBUG -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -std=gnu++11 -MD -MT src/cc/frontends/clang/CMakeFiles/clang_frontend.dir/b_frontend_action.cc.o -MF src/cc/frontends/clang/CMakeFiles/clang_frontend.dir/b_frontend_action.cc.o.d -o src/cc/frontends/clang/CMakeFiles/clang_frontend.dir/b_frontend_action.cc.o -c ../src/cc/frontends/clang/b_frontend_action.cc
../src/cc/frontends/clang/b_frontend_action.cc:1107:40: error: non-const lvalue reference to type 'llvm::APSInt' cannot bind to a value of unrelated type 'Expr::EvalResult'
if (I->getInit(idx)->EvaluateAsInt(res, C)) {
^~~
/usr/lib/llvm-8/include/clang/AST/Expr.h:602:36: note: passing argument to parameter 'Result' here
bool EvaluateAsInt(llvm::APSInt &Result, const ASTContext &Ctx,

```

I could find one similar bug in another project: https://github.com/rpav/c2ffi/issues/59.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with src/cc/frontends/clang/b_frontend_action.cc around line 1107 and reproduce the failure using the provided clang-8 CMake/Ninja command. Check the LLVM 8 Expr::EvaluateAsInt signature shown in the build output and the surrounding expression-evaluation code. Done means the clang frontend builds successfully with LLVM 8 and the installation step completes.

Written by the indexing model from the issue text.

Assessment

Tech stack
cmake, cpp, linux
Domain
build-system, compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.