Skip to content
This repository has been archived by the owner on Jan 14, 2024. It is now read-only.

bitops.h:209:9: error: 'asm goto' constructs are not supported yet #2

Open
omac777 opened this issue Aug 19, 2019 · 5 comments
Open

Comments

@omac777
Copy link

omac777 commented Aug 19, 2019

I tried to build the hello_world example and it failed.

I followed the instructions:

export PATH=/home/loongson/.cargo/bin:$PATH;
rustup component add --toolchain=nightly rust-src
rustup component add rustfmt-preview
cargo install cargo-edit
cargo install cargo-xbuild

uname -a
Linux righteous 5.2.0-2-amd64 #1 SMP Debian 5.2.7-1 (2019-08-07) x86_64 GNU/Linux

sudo apt-get install llvm clang
Reading package lists... Done
Building dependency tree       
Reading state information... Done
clang is already the newest version (1:7.0-47.1).
llvm is already the newest version (1:7.0-47.1).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

sudo apt-get install linux-headers-`uname -r`
Reading package lists... Done
Building dependency tree       
Reading state information... Done
linux-headers-5.2.0-2-amd64 is already the newest version (5.2.7-1).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

loongson@righteous:~/redoxstuff/linux-kernel-module-rust/hello_world$ cargo -V
cargo 1.38.0-nightly (e853aa976 2019-08-09)

git clone https://github.com/lizhuohua/linux-kernel-module-rust.git
cd linux-kernel-module-rust/
cd hello_world
RUST_TARGET_PATH=$(pwd)/.. cargo xbuild --target x86_64-linux-kernel-module
loongson@righteous:~/redoxstuff/linux-kernel-module-rust/hello_world$ RUST_TARGET_PATH=$(pwd)/.. cargo xbuild --target x86_64-linux-kernel-module
    Updating crates.io index
  Downloaded compiler_builtins v0.1.19
   Compiling core v0.0.0 (/home/loongson/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libcore)
   Compiling compiler_builtins v0.1.19
   Compiling rustc-std-workspace-core v1.0.0 (/home/loongson/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/tools/rustc-std-workspace-core)
   Compiling alloc v0.0.0 (/tmp/xargo.fIuOm42grKJg)
    Finished release [optimized] target(s) in 22.59s
    Updating crates.io index
  Downloaded bindgen v0.43.2
  Downloaded env_logger v0.6.2
  Downloaded cexpr v0.3.5
  Downloaded peeking_take_while v0.1.2
  Downloaded which v1.0.5
  Downloaded nom v4.2.3
  Downloaded clang-sys v0.26.4
  Downloaded proc-macro2 v0.3.5
  Downloaded libloading v0.5.2
   Compiling memchr v2.2.1
   Compiling version_check v0.1.5
   Compiling libc v0.2.62
   Compiling cc v1.0.40
   Compiling bitflags v1.1.0
   Compiling log v0.4.8
   Compiling glob v0.2.11
   Compiling lazy_static v1.3.0
   Compiling quick-error v1.2.2
   Compiling cfg-if v0.1.9
   Compiling regex-syntax v0.6.11
   Compiling unicode-xid v0.1.0
   Compiling unicode-width v0.1.5
   Compiling termcolor v1.0.5
   Compiling strsim v0.8.0
   Compiling ansi_term v0.11.0
   Compiling bindgen v0.43.2
   Compiling vec_map v0.8.1
   Compiling peeking_take_while v0.1.2
   Compiling shlex v0.1.1
   Compiling thread_local v0.3.6
   Compiling humantime v1.2.0
   Compiling proc-macro2 v0.3.5
   Compiling textwrap v0.11.0
   Compiling nom v4.2.3
   Compiling clang-sys v0.26.4
   Compiling quote v0.5.2
   Compiling aho-corasick v0.7.6
   Compiling atty v0.2.13
   Compiling which v1.0.5
   Compiling clap v2.33.0
   Compiling libloading v0.5.2
   Compiling cexpr v0.3.5
   Compiling regex v1.2.1
   Compiling env_logger v0.6.2
   Compiling linux-kernel-module v0.1.0 (/home/loongson/redoxstuff/linux-kernel-module-rust)
error: failed to run custom build command for `linux-kernel-module v0.1.0 (/home/loongson/redoxstuff/linux-kernel-module-rust)`

Caused by:
  process didn't exit successfully: `/home/loongson/redoxstuff/linux-kernel-module-rust/hello_world/target/debug/build/linux-kernel-module-7c510a191cf3f5d3/build-script-build` (exit code: 101)
--- stdout
Target=x86_64-linux-kernel-module
get output:-nostdinc -isystem /usr/lib/llvm-7/lib/clang/7.0.1/include -I/usr/src/linux-headers-5.2.0-2-common/arch/x86/include -I/usr/src/linux-headers-5.2.0-2-amd64/./arch/x86/include/generated -I/usr/src/linux-headers-5.2.0-2-common/include -I/usr/src/linux-headers-5.2.0-2-amd64/./include -I/usr/src/linux-headers-5.2.0-2-common/arch/x86/include/uapi -I/usr/src/linux-headers-5.2.0-2-amd64/./arch/x86/include/generated/uapi -I/usr/src/linux-headers-5.2.0-2-common/include/uapi -I/usr/src/linux-headers-5.2.0-2-amd64/./include/generated/uapi -include /usr/src/linux-headers-5.2.0-2-common/include/linux/kconfig.h -DMODULE

cargo:rerun-if-changed=src/bindgen_helper.h

--- stderr
/usr/src/linux-headers-5.2.0-2-common/arch/x86/include/asm/bitops.h:128:2: warning: implicit declaration of function 'barrier' is invalid in C99 [-Wimplicit-function-declaration]
/usr/src/linux-headers-5.2.0-2-common/arch/x86/include/asm/bitops.h:209:9: error: 'asm goto' constructs are not supported yet
/usr/src/linux-headers-5.2.0-2-common/arch/x86/include/asm/bitops.h:255:9: error: 'asm goto' constructs are not supported yet
/usr/src/linux-headers-5.2.0-2-common/arch/x86/include/asm/bitops.h:308:9: error: 'asm goto' constructs are not supported yet
/usr/src/linux-headers-5.2.0-2-common/include/linux/bitops.h:47:10: warning: implicit declaration of function 'fls' is invalid in C99 [-Wimplicit-function-declaration]
/usr/src/linux-headers-5.2.0-2-common/include/linux/bitops.h:53:26: warning: implicit declaration of function 'hweight32' is invalid in C99 [-Wimplicit-function-declaration]
/usr/src/linux-headers-5.2.0-2-common/include/linux/bitops.h:53:41: warning: implicit declaration of function 'hweight64' is invalid in C99 [-Wimplicit-function-declaration]
/usr/src/linux-headers-5.2.0-2-common/include/linux/bitops.h:163:10: warning: implicit declaration of function 'fls' is invalid in C99 [-Wimplicit-function-declaration]
/usr/src/linux-headers-5.2.0-2-common/include/linux/bitops.h:164:9: warning: implicit declaration of function 'fls64' is invalid in C99 [-Wimplicit-function-declaration]
/usr/src/linux-headers-5.2.0-2-common/include/linux/bitops.h:171:10: warning: implicit declaration of function 'fls' is invalid in C99 [-Wimplicit-function-declaration]
/usr/src/linux-headers-5.2.0-2-common/include/linux/log2.h:24:9: warning: implicit declaration of function 'fls' is invalid in C99 [-Wimplicit-function-declaration]
/usr/src/linux-headers-5.2.0-2-common/include/linux/log2.h:32:9: warning: implicit declaration of function 'fls64' is invalid in C99 [-Wimplicit-function-declaration]
/usr/src/linux-headers-5.2.0-2-common/include/linux/log2.h:197:15: error: unknown type name '__attribute_const__'
/usr/src/linux-headers-5.2.0-2-common/include/linux/log2.h:198:1: error: expected identifier or '('
/usr/src/linux-headers-5.2.0-2-common/include/linux/init.h:142:13: error: expected parameter declarator
/usr/src/linux-headers-5.2.0-2-common/include/linux/init.h:142:13: error: expected ')'
/usr/src/linux-headers-5.2.0-2-common/include/linux/init.h:142:13: note: to match this '('
/usr/src/linux-headers-5.2.0-2-common/include/linux/init.h:142:24: error: expected function body after function declarator
/usr/src/linux-headers-5.2.0-2-common/include/linux/init.h:149:5: error: expected parameter declarator
/usr/src/linux-headers-5.2.0-2-common/include/linux/init.h:149:5: error: expected ')'
/usr/src/linux-headers-5.2.0-2-common/include/linux/init.h:149:5: note: to match this '('
/usr/src/linux-headers-5.2.0-2-common/include/linux/init.h:149:5: error: expected function body after function declarator
/usr/src/linux-headers-5.2.0-2-common/include/linux/printk.h:142:28: error: expected parameter declarator
/usr/src/linux-headers-5.2.0-2-common/include/linux/printk.h:142:28: error: expected ')'
/usr/src/linux-headers-5.2.0-2-common/include/linux/printk.h:142:27: note: to match this '('
/usr/src/linux-headers-5.2.0-2-common/include/linux/printk.h:142:19: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
/usr/src/linux-headers-5.2.0-2-common/include/linux/printk.h:142:33: error: expected ';' after top level declarator
/usr/src/linux-headers-5.2.0-2-common/include/linux/printk.h:162:21: error: expected parameter declarator
/usr/src/linux-headers-5.2.0-2-common/include/linux/printk.h:162:21: error: expected ')'
/usr/src/linux-headers-5.2.0-2-common/include/linux/printk.h:162:20: note: to match this '('
/usr/src/linux-headers-5.2.0-2-common/include/linux/printk.h:162:12: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
/usr/src/linux-headers-5.2.0-2-common/include/linux/printk.h:162:26: error: expected ';' after top level declarator
/usr/src/linux-headers-5.2.0-2-common/include/linux/printk.h:167:21: error: expected parameter declarator
/usr/src/linux-headers-5.2.0-2-common/include/linux/printk.h:167:21: error: expected ')'
/usr/src/linux-headers-5.2.0-2-common/include/linux/printk.h:167:20: note: to match this '('
/usr/src/linux-headers-5.2.0-2-common/include/linux/printk.h:167:12: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
fatal error: too many errors emitted, stopping now [-ferror-limit=]
/usr/src/linux-headers-5.2.0-2-common/arch/x86/include/asm/bitops.h:128:2: warning: implicit declaration of function 'barrier' is invalid in C99 [-Wimplicit-function-declaration], err: false
/usr/src/linux-headers-5.2.0-2-common/arch/x86/include/asm/bitops.h:209:9: error: 'asm goto' constructs are not supported yet, err: true
/usr/src/linux-headers-5.2.0-2-common/arch/x86/include/asm/bitops.h:255:9: error: 'asm goto' constructs are not supported yet, err: true
/usr/src/linux-headers-5.2.0-2-common/arch/x86/include/asm/bitops.h:308:9: error: 'asm goto' constructs are not supported yet, err: true
/usr/src/linux-headers-5.2.0-2-common/include/linux/bitops.h:47:10: warning: implicit declaration of function 'fls' is invalid in C99 [-Wimplicit-function-declaration], err: false
/usr/src/linux-headers-5.2.0-2-common/include/linux/bitops.h:53:26: warning: implicit declaration of function 'hweight32' is invalid in C99 [-Wimplicit-function-declaration], err: false
/usr/src/linux-headers-5.2.0-2-common/include/linux/bitops.h:53:41: warning: implicit declaration of function 'hweight64' is invalid in C99 [-Wimplicit-function-declaration], err: false
/usr/src/linux-headers-5.2.0-2-common/include/linux/bitops.h:163:10: warning: implicit declaration of function 'fls' is invalid in C99 [-Wimplicit-function-declaration], err: false
/usr/src/linux-headers-5.2.0-2-common/include/linux/bitops.h:164:9: warning: implicit declaration of function 'fls64' is invalid in C99 [-Wimplicit-function-declaration], err: false
/usr/src/linux-headers-5.2.0-2-common/include/linux/bitops.h:171:10: warning: implicit declaration of function 'fls' is invalid in C99 [-Wimplicit-function-declaration], err: false
/usr/src/linux-headers-5.2.0-2-common/include/linux/log2.h:24:9: warning: implicit declaration of function 'fls' is invalid in C99 [-Wimplicit-function-declaration], err: false
/usr/src/linux-headers-5.2.0-2-common/include/linux/log2.h:32:9: warning: implicit declaration of function 'fls64' is invalid in C99 [-Wimplicit-function-declaration], err: false
/usr/src/linux-headers-5.2.0-2-common/include/linux/log2.h:197:15: error: unknown type name '__attribute_const__', err: true
/usr/src/linux-headers-5.2.0-2-common/include/linux/log2.h:198:1: error: expected identifier or '(', err: true
/usr/src/linux-headers-5.2.0-2-common/include/linux/init.h:142:13: error: expected parameter declarator, err: true
/usr/src/linux-headers-5.2.0-2-common/include/linux/init.h:142:13: error: expected ')', err: true
/usr/src/linux-headers-5.2.0-2-common/include/linux/init.h:142:24: error: expected function body after function declarator, err: true
/usr/src/linux-headers-5.2.0-2-common/include/linux/init.h:149:5: error: expected parameter declarator, err: true
/usr/src/linux-headers-5.2.0-2-common/include/linux/init.h:149:5: error: expected ')', err: true
/usr/src/linux-headers-5.2.0-2-common/include/linux/init.h:149:5: error: expected function body after function declarator, err: true
/usr/src/linux-headers-5.2.0-2-common/include/linux/printk.h:142:28: error: expected parameter declarator, err: true
/usr/src/linux-headers-5.2.0-2-common/include/linux/printk.h:142:28: error: expected ')', err: true
/usr/src/linux-headers-5.2.0-2-common/include/linux/printk.h:142:19: warning: type specifier missing, defaults to 'int' [-Wimplicit-int], err: false
/usr/src/linux-headers-5.2.0-2-common/include/linux/printk.h:142:33: error: expected ';' after top level declarator, err: true
/usr/src/linux-headers-5.2.0-2-common/include/linux/printk.h:162:21: error: expected parameter declarator, err: true
/usr/src/linux-headers-5.2.0-2-common/include/linux/printk.h:162:21: error: expected ')', err: true
/usr/src/linux-headers-5.2.0-2-common/include/linux/printk.h:162:12: warning: type specifier missing, defaults to 'int' [-Wimplicit-int], err: false
/usr/src/linux-headers-5.2.0-2-common/include/linux/printk.h:162:26: error: expected ';' after top level declarator, err: true
/usr/src/linux-headers-5.2.0-2-common/include/linux/printk.h:167:21: error: expected parameter declarator, err: true
/usr/src/linux-headers-5.2.0-2-common/include/linux/printk.h:167:21: error: expected ')', err: true
/usr/src/linux-headers-5.2.0-2-common/include/linux/printk.h:167:12: warning: type specifier missing, defaults to 'int' [-Wimplicit-int], err: false
fatal error: too many errors emitted, stopping now [-ferror-limit=], err: true
thread 'main' panicked at 'Unable to generate bindings: ()', src/libcore/result.rs:1084:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
@omac777
Copy link
Author

omac777 commented Aug 19, 2019

I just noticed that I needed a more recent version of clang. clang-10. I installed that, but still fails with the same build error

wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key|sudo apt-key add -

added the following to /etc/apt/sources.list

deb http://apt.llvm.org/unstable/ llvm-toolchain main
deb-src http://apt.llvm.org/unstable/ llvm-toolchain main
sudo apt-get update
apt-get install clang-10 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  libclang-common-10-dev libclang-cpp1-10 libclang1-10 libllvm10 libobjc-9-dev libomp-10-dev libomp5-10 libpfm4 llvm-10 llvm-10-dev llvm-10-runtime
Suggested packages:
  clang-10-doc libomp-10-doc llvm-10-doc
The following packages will be REMOVED:
  libomp-7-dev libomp5-7
The following NEW packages will be installed:
  clang-10 libclang-common-10-dev libclang-cpp1-10 libclang1-10 libllvm10 libobjc-9-dev libomp-10-dev libomp5-10 libpfm4 llvm-10 llvm-10-dev llvm-10-runtime
0 upgraded, 12 newly installed, 2 to remove and 132 not upgraded.
Need to get 65.5 MB of archives.
After this operation, 402 MB of additional disk space will be used.
Do you want to continue? [Y/n] 
Get:1 http://http.us.debian.org/debian unstable/main amd64 libobjc-9-dev amd64 9.2.1-1 [219 kB]
Get:2 http://http.us.debian.org/debian unstable/main amd64 libpfm4 amd64 4.10.1+git14-g815ff28-1 [268 kB]
Get:3 http://apt.llvm.org/unstable llvm-toolchain/main amd64 libllvm10 amd64 1:10~svn369091-1~exp1+0~20190816093740.2674~1.gbpd39d13 [15.1 MB]
Get:4 http://apt.llvm.org/unstable llvm-toolchain/main amd64 libclang-cpp1-10 amd64 1:10~svn369091-1~exp1+0~20190816093740.2674~1.gbpd39d13 [8,564 kB]
Get:5 http://apt.llvm.org/unstable llvm-toolchain/main amd64 libclang-common-10-dev amd64 1:10~svn369091-1~exp1+0~20190816093740.2674~1.gbpd39d13 [3,079 kB]
Get:6 http://apt.llvm.org/unstable llvm-toolchain/main amd64 libclang1-10 amd64 1:10~svn369091-1~exp1+0~20190816093740.2674~1.gbpd39d13 [6,808 kB]
Get:7 http://apt.llvm.org/unstable llvm-toolchain/main amd64 clang-10 amd64 1:10~svn369091-1~exp1+0~20190816093740.2674~1.gbpd39d13 [1,155 kB]
Get:8 http://apt.llvm.org/unstable llvm-toolchain/main amd64 libomp5-10 amd64 1:10~svn369091-1~exp1+0~20190816093740.2674~1.gbpd39d13 [334 kB]
Get:9 http://apt.llvm.org/unstable llvm-toolchain/main amd64 libomp-10-dev amd64 1:10~svn369091-1~exp1+0~20190816093740.2674~1.gbpd39d13 [65.9 kB]
Get:10 http://apt.llvm.org/unstable llvm-toolchain/main amd64 llvm-10-runtime amd64 1:10~svn369091-1~exp1+0~20190816093740.2674~1.gbpd39d13 [210 kB]
Get:11 http://apt.llvm.org/unstable llvm-toolchain/main amd64 llvm-10 amd64 1:10~svn369091-1~exp1+0~20190816093740.2674~1.gbpd39d13 [4,963 kB]
Get:12 http://apt.llvm.org/unstable llvm-toolchain/main amd64 llvm-10-dev amd64 1:10~svn369091-1~exp1+0~20190816093740.2674~1.gbpd39d13 [24.7 MB]
Fetched 65.5 MB in 6s (11.3 MB/s)       
(Reading database ... 508328 files and directories currently installed.)
Removing libomp-7-dev (1:7.0.1-9) ...
Removing libomp5-7:amd64 (1:7.0.1-9) ...
Selecting previously unselected package libllvm10:amd64.
(Reading database ... 508309 files and directories currently installed.)
Preparing to unpack .../00-libllvm10_1%3a10~svn369091-1~exp1+0~20190816093740.2674~1.gbpd39d13_amd64.deb ...
Unpacking libllvm10:amd64 (1:10~svn369091-1~exp1+0~20190816093740.2674~1.gbpd39d13) ...
Selecting previously unselected package libclang-cpp1-10.
Preparing to unpack .../01-libclang-cpp1-10_1%3a10~svn369091-1~exp1+0~20190816093740.2674~1.gbpd39d13_amd64.deb ...
Unpacking libclang-cpp1-10 (1:10~svn369091-1~exp1+0~20190816093740.2674~1.gbpd39d13) ...
Selecting previously unselected package libobjc-9-dev:amd64.
Preparing to unpack .../02-libobjc-9-dev_9.2.1-1_amd64.deb ...
Unpacking libobjc-9-dev:amd64 (9.2.1-1) ...
Selecting previously unselected package libclang-common-10-dev.
Preparing to unpack .../03-libclang-common-10-dev_1%3a10~svn369091-1~exp1+0~20190816093740.2674~1.gbpd39d13_amd64.deb ...
Unpacking libclang-common-10-dev (1:10~svn369091-1~exp1+0~20190816093740.2674~1.gbpd39d13) ...
Selecting previously unselected package libclang1-10.
Preparing to unpack .../04-libclang1-10_1%3a10~svn369091-1~exp1+0~20190816093740.2674~1.gbpd39d13_amd64.deb ...
Unpacking libclang1-10 (1:10~svn369091-1~exp1+0~20190816093740.2674~1.gbpd39d13) ...
Selecting previously unselected package clang-10.
Preparing to unpack .../05-clang-10_1%3a10~svn369091-1~exp1+0~20190816093740.2674~1.gbpd39d13_amd64.deb ...
Unpacking clang-10 (1:10~svn369091-1~exp1+0~20190816093740.2674~1.gbpd39d13) ...
Selecting previously unselected package libomp5-10:amd64.
Preparing to unpack .../06-libomp5-10_1%3a10~svn369091-1~exp1+0~20190816093740.2674~1.gbpd39d13_amd64.deb ...
Unpacking libomp5-10:amd64 (1:10~svn369091-1~exp1+0~20190816093740.2674~1.gbpd39d13) ...
Selecting previously unselected package libomp-10-dev.
Preparing to unpack .../07-libomp-10-dev_1%3a10~svn369091-1~exp1+0~20190816093740.2674~1.gbpd39d13_amd64.deb ...
Unpacking libomp-10-dev (1:10~svn369091-1~exp1+0~20190816093740.2674~1.gbpd39d13) ...
Selecting previously unselected package libpfm4:amd64.
Preparing to unpack .../08-libpfm4_4.10.1+git14-g815ff28-1_amd64.deb ...
Unpacking libpfm4:amd64 (4.10.1+git14-g815ff28-1) ...
Selecting previously unselected package llvm-10-runtime.
Preparing to unpack .../09-llvm-10-runtime_1%3a10~svn369091-1~exp1+0~20190816093740.2674~1.gbpd39d13_amd64.deb ...
Unpacking llvm-10-runtime (1:10~svn369091-1~exp1+0~20190816093740.2674~1.gbpd39d13) ...
Selecting previously unselected package llvm-10.
Preparing to unpack .../10-llvm-10_1%3a10~svn369091-1~exp1+0~20190816093740.2674~1.gbpd39d13_amd64.deb ...
Unpacking llvm-10 (1:10~svn369091-1~exp1+0~20190816093740.2674~1.gbpd39d13) ...
Selecting previously unselected package llvm-10-dev.
Preparing to unpack .../11-llvm-10-dev_1%3a10~svn369091-1~exp1+0~20190816093740.2674~1.gbpd39d13_amd64.deb ...
Unpacking llvm-10-dev (1:10~svn369091-1~exp1+0~20190816093740.2674~1.gbpd39d13) ...
Setting up libllvm10:amd64 (1:10~svn369091-1~exp1+0~20190816093740.2674~1.gbpd39d13) ...
Setting up libpfm4:amd64 (4.10.1+git14-g815ff28-1) ...
Setting up libclang-cpp1-10 (1:10~svn369091-1~exp1+0~20190816093740.2674~1.gbpd39d13) ...
Setting up libclang1-10 (1:10~svn369091-1~exp1+0~20190816093740.2674~1.gbpd39d13) ...
Setting up libobjc-9-dev:amd64 (9.2.1-1) ...
Setting up libomp5-10:amd64 (1:10~svn369091-1~exp1+0~20190816093740.2674~1.gbpd39d13) ...
Setting up libomp-10-dev (1:10~svn369091-1~exp1+0~20190816093740.2674~1.gbpd39d13) ...
Setting up libclang-common-10-dev (1:10~svn369091-1~exp1+0~20190816093740.2674~1.gbpd39d13) ...
Setting up llvm-10-runtime (1:10~svn369091-1~exp1+0~20190816093740.2674~1.gbpd39d13) ...
Setting up clang-10 (1:10~svn369091-1~exp1+0~20190816093740.2674~1.gbpd39d13) ...
Setting up llvm-10 (1:10~svn369091-1~exp1+0~20190816093740.2674~1.gbpd39d13) ...
Setting up llvm-10-dev (1:10~svn369091-1~exp1+0~20190816093740.2674~1.gbpd39d13) ...
Processing triggers for man-db (2.8.6.1-1) ...
Processing triggers for libc-bin (2.28-10) ...
loongson@righteous:~/redoxstuff$ sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/lib/llvm-7/bin/clang++ 100
update-alternatives: using /usr/lib/llvm-7/bin/clang++ to provide /usr/bin/clang++ (clang++) in auto mode
loongson@righteous:~/redoxstuff$ sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/lib/llvm-10/bin/clang++ 1000
update-alternatives: using /usr/lib/llvm-10/bin/clang++ to provide /usr/bin/clang++ (clang++) in auto mode
loongson@righteous:~/redoxstuff$ sudo update-alternatives --install /usr/bin/clang clang /usr/lib/llvm-7/bin/clang 100
update-alternatives: using /usr/lib/llvm-7/bin/clang to provide /usr/bin/clang (clang) in auto mode
loongson@righteous:~/redoxstuff$ sudo update-alternatives --install /usr/bin/clang clang /usr/lib/llvm-10/bin/clang 1000
update-alternatives: using /usr/lib/llvm-10/bin/clang to provide /usr/bin/clang (clang) in auto mode
loongson@righteous:~/redoxstuff$ sudo update-alternatives --config clang
There are 2 choices for the alternative clang (providing /usr/bin/clang).

  Selection    Path                        Priority   Status
------------------------------------------------------------
* 0            /usr/lib/llvm-10/bin/clang   1000      auto mode
  1            /usr/lib/llvm-10/bin/clang   1000      manual mode
  2            /usr/lib/llvm-7/bin/clang    100       manual mode

Press <enter> to keep the current choice[*], or type selection number: 0
loongson@righteous:~/redoxstuff$ sudo update-alternatives --config clang++
There are 2 choices for the alternative clang++ (providing /usr/bin/clang++).

  Selection    Path                          Priority   Status
------------------------------------------------------------
* 0            /usr/lib/llvm-10/bin/clang++   1000      auto mode
  1            /usr/lib/llvm-10/bin/clang++   1000      manual mode
  2            /usr/lib/llvm-7/bin/clang++    100       manual mode

Press <enter> to keep the current choice[*], or type selection number: 0

Even after all that, it still errors out:

export PATH=/home/loongson/.cargo/bin:$PATH;
git clone https://github.com/lizhuohua/linux-kernel-module-rust.git
cd linux-kernel-module-rust/
cd hello_world/
RUST_TARGET_PATH=$(pwd)/.. cargo xbuild --target x86_64-linux-kernel-module
    Updating crates.io index
   Compiling compiler_builtins v0.1.19
   Compiling core v0.0.0 (/home/loongson/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libcore)
   Compiling rustc-std-workspace-core v1.0.0 (/home/loongson/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/tools/rustc-std-workspace-core)
   Compiling alloc v0.0.0 (/tmp/xargo.jijQ6mr2M8eM)
    Finished release [optimized] target(s) in 22.59s
    Updating crates.io index
   Compiling memchr v2.2.1
   Compiling libc v0.2.62
   Compiling version_check v0.1.5
   Compiling cc v1.0.40
   Compiling glob v0.2.11
   Compiling log v0.4.8
   Compiling lazy_static v1.3.0
   Compiling bitflags v1.1.0
   Compiling unicode-xid v0.1.0
   Compiling regex-syntax v0.6.11
   Compiling unicode-width v0.1.5
   Compiling quick-error v1.2.2
   Compiling cfg-if v0.1.9
   Compiling ansi_term v0.11.0
   Compiling vec_map v0.8.1
   Compiling strsim v0.8.0
   Compiling bindgen v0.43.2
   Compiling termcolor v1.0.5
   Compiling peeking_take_while v0.1.2
   Compiling shlex v0.1.1
   Compiling thread_local v0.3.6
   Compiling proc-macro2 v0.3.5
   Compiling textwrap v0.11.0
   Compiling humantime v1.2.0
   Compiling nom v4.2.3
   Compiling clang-sys v0.26.4
   Compiling quote v0.5.2
   Compiling aho-corasick v0.7.6
   Compiling libloading v0.5.2
   Compiling atty v0.2.13
   Compiling which v1.0.5
   Compiling clap v2.33.0
   Compiling cexpr v0.3.5
   Compiling regex v1.2.1
   Compiling env_logger v0.6.2
   Compiling linux-kernel-module v0.1.0 (/home/loongson/redoxstuff/linux-kernel-module-rust)
error: failed to run custom build command for `linux-kernel-module v0.1.0 (/home/loongson/redoxstuff/linux-kernel-module-rust)`

Caused by:
  process didn't exit successfully: `/home/loongson/redoxstuff/linux-kernel-module-rust/hello_world/target/debug/build/linux-kernel-module-7c510a191cf3f5d3/build-script-build` (exit code: 101)
--- stdout
Target=x86_64-linux-kernel-module
get output:-nostdinc -isystem /usr/lib/llvm-10/lib/clang/10.0.0/include -I/usr/src/linux-headers-5.2.0-2-common/arch/x86/include -I/usr/src/linux-headers-5.2.0-2-amd64/./arch/x86/include/generated -I/usr/src/linux-headers-5.2.0-2-common/include -I/usr/src/linux-headers-5.2.0-2-amd64/./include -I/usr/src/linux-headers-5.2.0-2-common/arch/x86/include/uapi -I/usr/src/linux-headers-5.2.0-2-amd64/./arch/x86/include/generated/uapi -I/usr/src/linux-headers-5.2.0-2-common/include/uapi -I/usr/src/linux-headers-5.2.0-2-amd64/./include/generated/uapi -include /usr/src/linux-headers-5.2.0-2-common/include/linux/kconfig.h -DMODULE

cargo:rerun-if-changed=src/bindgen_helper.h

--- stderr
/usr/src/linux-headers-5.2.0-2-common/arch/x86/include/asm/bitops.h:128:2: warning: implicit declaration of function 'barrier' is invalid in C99 [-Wimplicit-function-declaration]
/usr/src/linux-headers-5.2.0-2-common/arch/x86/include/asm/bitops.h:209:9: error: 'asm goto' constructs are not supported yet
/usr/src/linux-headers-5.2.0-2-common/arch/x86/include/asm/bitops.h:255:9: error: 'asm goto' constructs are not supported yet
/usr/src/linux-headers-5.2.0-2-common/arch/x86/include/asm/bitops.h:308:9: error: 'asm goto' constructs are not supported yet
/usr/src/linux-headers-5.2.0-2-common/include/linux/bitops.h:47:10: warning: implicit declaration of function 'fls' is invalid in C99 [-Wimplicit-function-declaration]
/usr/src/linux-headers-5.2.0-2-common/include/linux/bitops.h:53:26: warning: implicit declaration of function 'hweight32' is invalid in C99 [-Wimplicit-function-declaration]
/usr/src/linux-headers-5.2.0-2-common/include/linux/bitops.h:53:41: warning: implicit declaration of function 'hweight64' is invalid in C99 [-Wimplicit-function-declaration]
/usr/src/linux-headers-5.2.0-2-common/include/linux/bitops.h:163:10: warning: implicit declaration of function 'fls' is invalid in C99 [-Wimplicit-function-declaration]
/usr/src/linux-headers-5.2.0-2-common/include/linux/bitops.h:164:9: warning: implicit declaration of function 'fls64' is invalid in C99 [-Wimplicit-function-declaration]
/usr/src/linux-headers-5.2.0-2-common/include/linux/bitops.h:171:10: warning: implicit declaration of function 'fls' is invalid in C99 [-Wimplicit-function-declaration]
/usr/src/linux-headers-5.2.0-2-common/include/linux/log2.h:24:9: warning: implicit declaration of function 'fls' is invalid in C99 [-Wimplicit-function-declaration]
/usr/src/linux-headers-5.2.0-2-common/include/linux/log2.h:32:9: warning: implicit declaration of function 'fls64' is invalid in C99 [-Wimplicit-function-declaration]
/usr/src/linux-headers-5.2.0-2-common/include/linux/log2.h:197:15: error: unknown type name '__attribute_const__'
/usr/src/linux-headers-5.2.0-2-common/include/linux/log2.h:198:1: error: expected identifier or '('
/usr/src/linux-headers-5.2.0-2-common/include/linux/init.h:142:13: error: expected parameter declarator
/usr/src/linux-headers-5.2.0-2-common/include/linux/init.h:142:13: error: expected ')'
/usr/src/linux-headers-5.2.0-2-common/include/linux/init.h:142:13: note: to match this '('
/usr/src/linux-headers-5.2.0-2-common/include/linux/init.h:142:24: error: expected function body after function declarator
/usr/src/linux-headers-5.2.0-2-common/include/linux/init.h:149:5: error: expected parameter declarator
/usr/src/linux-headers-5.2.0-2-common/include/linux/init.h:149:5: error: expected ')'
/usr/src/linux-headers-5.2.0-2-common/include/linux/init.h:149:5: note: to match this '('
/usr/src/linux-headers-5.2.0-2-common/include/linux/init.h:149:5: error: expected function body after function declarator
/usr/src/linux-headers-5.2.0-2-common/include/linux/printk.h:142:28: error: expected parameter declarator
/usr/src/linux-headers-5.2.0-2-common/include/linux/printk.h:142:28: error: expected ')'
/usr/src/linux-headers-5.2.0-2-common/include/linux/printk.h:142:27: note: to match this '('
/usr/src/linux-headers-5.2.0-2-common/include/linux/printk.h:142:19: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
/usr/src/linux-headers-5.2.0-2-common/include/linux/printk.h:142:33: error: expected ';' after top level declarator
/usr/src/linux-headers-5.2.0-2-common/include/linux/printk.h:162:21: error: expected parameter declarator
/usr/src/linux-headers-5.2.0-2-common/include/linux/printk.h:162:21: error: expected ')'
/usr/src/linux-headers-5.2.0-2-common/include/linux/printk.h:162:20: note: to match this '('
/usr/src/linux-headers-5.2.0-2-common/include/linux/printk.h:162:12: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
/usr/src/linux-headers-5.2.0-2-common/include/linux/printk.h:162:26: error: expected ';' after top level declarator
/usr/src/linux-headers-5.2.0-2-common/include/linux/printk.h:167:21: error: expected parameter declarator
/usr/src/linux-headers-5.2.0-2-common/include/linux/printk.h:167:21: error: expected ')'
/usr/src/linux-headers-5.2.0-2-common/include/linux/printk.h:167:20: note: to match this '('
/usr/src/linux-headers-5.2.0-2-common/include/linux/printk.h:167:12: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
fatal error: too many errors emitted, stopping now [-ferror-limit=]
/usr/src/linux-headers-5.2.0-2-common/arch/x86/include/asm/bitops.h:128:2: warning: implicit declaration of function 'barrier' is invalid in C99 [-Wimplicit-function-declaration], err: false
/usr/src/linux-headers-5.2.0-2-common/arch/x86/include/asm/bitops.h:209:9: error: 'asm goto' constructs are not supported yet, err: true
/usr/src/linux-headers-5.2.0-2-common/arch/x86/include/asm/bitops.h:255:9: error: 'asm goto' constructs are not supported yet, err: true
/usr/src/linux-headers-5.2.0-2-common/arch/x86/include/asm/bitops.h:308:9: error: 'asm goto' constructs are not supported yet, err: true
/usr/src/linux-headers-5.2.0-2-common/include/linux/bitops.h:47:10: warning: implicit declaration of function 'fls' is invalid in C99 [-Wimplicit-function-declaration], err: false
/usr/src/linux-headers-5.2.0-2-common/include/linux/bitops.h:53:26: warning: implicit declaration of function 'hweight32' is invalid in C99 [-Wimplicit-function-declaration], err: false
/usr/src/linux-headers-5.2.0-2-common/include/linux/bitops.h:53:41: warning: implicit declaration of function 'hweight64' is invalid in C99 [-Wimplicit-function-declaration], err: false
/usr/src/linux-headers-5.2.0-2-common/include/linux/bitops.h:163:10: warning: implicit declaration of function 'fls' is invalid in C99 [-Wimplicit-function-declaration], err: false
/usr/src/linux-headers-5.2.0-2-common/include/linux/bitops.h:164:9: warning: implicit declaration of function 'fls64' is invalid in C99 [-Wimplicit-function-declaration], err: false
/usr/src/linux-headers-5.2.0-2-common/include/linux/bitops.h:171:10: warning: implicit declaration of function 'fls' is invalid in C99 [-Wimplicit-function-declaration], err: false
/usr/src/linux-headers-5.2.0-2-common/include/linux/log2.h:24:9: warning: implicit declaration of function 'fls' is invalid in C99 [-Wimplicit-function-declaration], err: false
/usr/src/linux-headers-5.2.0-2-common/include/linux/log2.h:32:9: warning: implicit declaration of function 'fls64' is invalid in C99 [-Wimplicit-function-declaration], err: false
/usr/src/linux-headers-5.2.0-2-common/include/linux/log2.h:197:15: error: unknown type name '__attribute_const__', err: true
/usr/src/linux-headers-5.2.0-2-common/include/linux/log2.h:198:1: error: expected identifier or '(', err: true
/usr/src/linux-headers-5.2.0-2-common/include/linux/init.h:142:13: error: expected parameter declarator, err: true
/usr/src/linux-headers-5.2.0-2-common/include/linux/init.h:142:13: error: expected ')', err: true
/usr/src/linux-headers-5.2.0-2-common/include/linux/init.h:142:24: error: expected function body after function declarator, err: true
/usr/src/linux-headers-5.2.0-2-common/include/linux/init.h:149:5: error: expected parameter declarator, err: true
/usr/src/linux-headers-5.2.0-2-common/include/linux/init.h:149:5: error: expected ')', err: true
/usr/src/linux-headers-5.2.0-2-common/include/linux/init.h:149:5: error: expected function body after function declarator, err: true
/usr/src/linux-headers-5.2.0-2-common/include/linux/printk.h:142:28: error: expected parameter declarator, err: true
/usr/src/linux-headers-5.2.0-2-common/include/linux/printk.h:142:28: error: expected ')', err: true
/usr/src/linux-headers-5.2.0-2-common/include/linux/printk.h:142:19: warning: type specifier missing, defaults to 'int' [-Wimplicit-int], err: false
/usr/src/linux-headers-5.2.0-2-common/include/linux/printk.h:142:33: error: expected ';' after top level declarator, err: true
/usr/src/linux-headers-5.2.0-2-common/include/linux/printk.h:162:21: error: expected parameter declarator, err: true
/usr/src/linux-headers-5.2.0-2-common/include/linux/printk.h:162:21: error: expected ')', err: true
/usr/src/linux-headers-5.2.0-2-common/include/linux/printk.h:162:12: warning: type specifier missing, defaults to 'int' [-Wimplicit-int], err: false
/usr/src/linux-headers-5.2.0-2-common/include/linux/printk.h:162:26: error: expected ';' after top level declarator, err: true
/usr/src/linux-headers-5.2.0-2-common/include/linux/printk.h:167:21: error: expected parameter declarator, err: true
/usr/src/linux-headers-5.2.0-2-common/include/linux/printk.h:167:21: error: expected ')', err: true
/usr/src/linux-headers-5.2.0-2-common/include/linux/printk.h:167:12: warning: type specifier missing, defaults to 'int' [-Wimplicit-int], err: false
fatal error: too many errors emitted, stopping now [-ferror-limit=], err: true
thread 'main' panicked at 'Unable to generate bindings: ()', src/libcore/result.rs:1084:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.

@geofft
Copy link

geofft commented Aug 19, 2019

Hm, this looks like the same as #1. Can you see if running export CLANG=clang-10 makes it pick up the right version of clang?

@omac777
Copy link
Author

omac777 commented Aug 20, 2019 via email

@omac777
Copy link
Author

omac777 commented Aug 20, 2019

I would like to add I tried this on fedora rawhide. Same error.

$ uname -a
Linux io02fedora30 5.2.8-200.fc30.x86_64 #1 SMP Sat Aug 10 13:21:39 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

cargo --version --verbose --verbose
cargo 1.38.0-nightly (e853aa976 2019-08-09)
release: 1.38.0
commit-hash: e853aa976543168fbb6bfcc983c35c3facca9840
commit-date: 2019-08-09

$ clang --version
clang version 8.0.0 (Fedora 8.0.0-1.fc30)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
   Compiling linux-kernel-module v0.1.0 (/home/davidm/Downloads/linux-kernel-module-rust)
     Running `CARGO_PKG_HOMEPAGE= CARGO_PKG_REPOSITORY= CARGO_PKG_AUTHORS='Li Zhuohua <[email protected]>' CARGO_MANIFEST_DIR=/home/davidm/Downloads/linux-kernel-module-rust CARGO_PKG_DESCRIPTION= CARGO_PKG_NAME=linux-kernel-module CARGO_PKG_VERSION_PATCH=0 CARGO_PKG_VERSION_PRE= CARGO=/home/davidm/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/cargo CARGO_PKG_VERSION_MINOR=1 LD_LIBRARY_PATH='/home/davidm/Downloads/linux-kernel-module-rust/hello_world/target/debug/deps:/home/davidm/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib:/home/davidm/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib' CARGO_PKG_VERSION_MAJOR=0 CARGO_PKG_VERSION=0.1.0 rustc --edition=2018 --crate-name build_script_build /home/davidm/Downloads/linux-kernel-module-rust/build.rs --color never --crate-type bin --emit=dep-info,link -C debuginfo=2 -C metadata=171394e104421971 -C extra-filename=-171394e104421971 --out-dir /home/davidm/Downloads/linux-kernel-module-rust/hello_world/target/debug/build/linux-kernel-module-171394e104421971 -C incremental=/home/davidm/Downloads/linux-kernel-module-rust/hello_world/target/debug/incremental -L dependency=/home/davidm/Downloads/linux-kernel-module-rust/hello_world/target/debug/deps --extern bindgen=/home/davidm/Downloads/linux-kernel-module-rust/hello_world/target/debug/deps/libbindgen-f87b89b3d396acec.rlib --extern cc=/home/davidm/Downloads/linux-kernel-module-rust/hello_world/target/debug/deps/libcc-860d70e513a341b8.rlib --extern shlex=/home/davidm/Downloads/linux-kernel-module-rust/hello_world/target/debug/deps/libshlex-97ef5087ea3fa79b.rlib -L native=/home/davidm/Downloads/linux-kernel-module-rust/hello_world/target/debug/build/libloading-9a882d70621138c7/out`
     Running `/home/davidm/Downloads/linux-kernel-module-rust/hello_world/target/debug/build/linux-kernel-module-171394e104421971/build-script-build`
[linux-kernel-module 0.1.0] Target=x86_64-linux-kernel-module
[linux-kernel-module 0.1.0] get output:-nostdinc -isystem /usr/lib64/clang/8.0.0/include -I/usr/src/kernels/5.2.8-200.fc30.x86_64/./arch/x86/include -I/usr/src/kernels/5.2.8-200.fc30.x86_64/./arch/x86/include/generated -I/usr/src/kernels/5.2.8-200.fc30.x86_64/./include -I/usr/src/kernels/5.2.8-200.fc30.x86_64/./arch/x86/include/uapi -I/usr/src/kernels/5.2.8-200.fc30.x86_64/./arch/x86/include/generated/uapi -I/usr/src/kernels/5.2.8-200.fc30.x86_64/./include/uapi -I/usr/src/kernels/5.2.8-200.fc30.x86_64/./include/generated/uapi -include /usr/src/kernels/5.2.8-200.fc30.x86_64/include/linux/kconfig.h -DMODULE
[linux-kernel-module 0.1.0] 
[linux-kernel-module 0.1.0] cargo:rerun-if-changed=src/bindgen_helper.h
[linux-kernel-module 0.1.0] /usr/src/kernels/5.2.8-200.fc30.x86_64/./arch/x86/include/asm/bitops.h:128:2: warning: implicit declaration of function 'barrier' is invalid in C99 [-Wimplicit-function-declaration]
[linux-kernel-module 0.1.0] /usr/src/kernels/5.2.8-200.fc30.x86_64/./arch/x86/include/asm/bitops.h:209:9: error: 'asm goto' constructs are not supported yet

@geofft
Copy link

geofft commented Aug 27, 2020

Hi @omac777 - on newer kernels (5.0 or newer), you need LLVM 9 or later for support for "asm goto".

By the way, the build code in this project as well as the hello-world module comes from our project at https://github.com/fishinabarrel/linux-kernel-module-rust , which is actively developed. You may have better luck trying the version there, we have since added compatibility with more kernel versions (as well as a bit more functionality).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants