File tree Expand file tree Collapse file tree 9 files changed +180
-5
lines changed Expand file tree Collapse file tree 9 files changed +180
-5
lines changed Original file line number Diff line number Diff line change @@ -511,6 +511,7 @@ KBUILD_CFLAGS := -Wall -Wundef -Werror=strict-prototypes -Wno-trigraphs \
511
511
-Werror=return-type -Wno-format-security \
512
512
-std=gnu89
513
513
KBUILD_CPPFLAGS := -D__KERNEL__
514
+ KBUILD_RUSTC_TARGET := $(srctree ) /arch/$(SRCARCH ) /rust/target.json
514
515
KBUILD_RUSTCFLAGS := --emit=dep-info,obj,metadata --edition=2018 \
515
516
-Cpanic=abort -Cembed-bitcode=n -Clto=n -Crpath=n \
516
517
-Cforce-unwind-tables=n -Ccodegen-units=1 \
@@ -542,7 +543,7 @@ export KBUILD_HOSTCXXFLAGS KBUILD_HOSTLDFLAGS KBUILD_HOSTLDLIBS LDFLAGS_MODULE
542
543
543
544
export KBUILD_CPPFLAGS NOSTDINC_FLAGS LINUXINCLUDE OBJCOPYFLAGS KBUILD_LDFLAGS
544
545
export KBUILD_CFLAGS CFLAGS_KERNEL CFLAGS_MODULE
545
- export KBUILD_RUSTCFLAGS RUSTCFLAGS_KERNEL RUSTCFLAGS_MODULE
546
+ export KBUILD_RUSTC_TARGET KBUILD_RUSTCFLAGS RUSTCFLAGS_KERNEL RUSTCFLAGS_MODULE
546
547
export KBUILD_AFLAGS AFLAGS_KERNEL AFLAGS_MODULE
547
548
export KBUILD_AFLAGS_MODULE KBUILD_CFLAGS_MODULE KBUILD_RUSTCFLAGS_MODULE KBUILD_LDFLAGS_MODULE
548
549
export KBUILD_AFLAGS_KERNEL KBUILD_CFLAGS_KERNEL KBUILD_RUSTCFLAGS_KERNEL
Original file line number Diff line number Diff line change @@ -45,6 +45,7 @@ riscv-march-$(CONFIG_FPU) := $(riscv-march-y)fd
45
45
riscv-march-$(CONFIG_RISCV_ISA_C) := $(riscv-march-y ) c
46
46
KBUILD_CFLAGS += -march=$(subst fd,,$(riscv-march-y ) )
47
47
KBUILD_AFLAGS += -march=$(riscv-march-y )
48
+ KBUILD_RUSTC_TARGET := $(srctree ) /arch/riscv/rust/$(subst fd,,$(riscv-march-y ) ) .json
48
49
49
50
KBUILD_CFLAGS += -mno-save-restore
50
51
KBUILD_CFLAGS += -DCONFIG_PAGE_OFFSET=$(CONFIG_PAGE_OFFSET )
Original file line number Diff line number Diff line change
1
+ {
2
+ "arch" : " riscv32" ,
3
+ "code-model" : " medium" ,
4
+ "cpu" : " generic-rv32" ,
5
+ "data-layout" : " e-m:e-p:32:32-i64:64-n32-S128" ,
6
+ "disable-redzone" : true ,
7
+ "eliminate-frame-pointer" : false ,
8
+ "emit-debug-gdb-scripts" : false ,
9
+ "env" : " gnu" ,
10
+ "features" : " +m,+a" ,
11
+ "function-sections" : false ,
12
+ "is-builtin" : true ,
13
+ "linker-flavor" : " gcc" ,
14
+ "linker-is-gnu" : true ,
15
+ "llvm-target" : " riscv32" ,
16
+ "max-atomic-width" : 32 ,
17
+ "needs-plt" : true ,
18
+ "os" : " none" ,
19
+ "panic-strategy" : " abort" ,
20
+ "position-independent-executables" : true ,
21
+ "pre-link-args" : {
22
+ "gcc" : [
23
+ " -Wl,--as-needed" ,
24
+ " -Wl,-z,noexecstack" ,
25
+ " -m32"
26
+ ]
27
+ },
28
+ "relocation-model" : " static" ,
29
+ "relro-level" : " full" ,
30
+ "stack-probes" : {
31
+ "kind" : " inline-or-call" ,
32
+ "min-llvm-version-for-inline" : [
33
+ 11 ,
34
+ 0 ,
35
+ 1
36
+ ]
37
+ },
38
+ "target-c-int-width" : " 32" ,
39
+ "target-endian" : " little" ,
40
+ "target-pointer-width" : " 32" ,
41
+ "vendor" : " "
42
+ }
Original file line number Diff line number Diff line change
1
+ {
2
+ "arch" : " riscv32" ,
3
+ "code-model" : " medium" ,
4
+ "cpu" : " generic-rv32" ,
5
+ "data-layout" : " e-m:e-p:32:32-i64:64-n32-S128" ,
6
+ "disable-redzone" : true ,
7
+ "eliminate-frame-pointer" : false ,
8
+ "emit-debug-gdb-scripts" : false ,
9
+ "env" : " gnu" ,
10
+ "features" : " +m,+a,+c" ,
11
+ "function-sections" : false ,
12
+ "is-builtin" : true ,
13
+ "linker-flavor" : " gcc" ,
14
+ "linker-is-gnu" : true ,
15
+ "llvm-target" : " riscv32" ,
16
+ "max-atomic-width" : 32 ,
17
+ "needs-plt" : true ,
18
+ "os" : " none" ,
19
+ "panic-strategy" : " abort" ,
20
+ "position-independent-executables" : true ,
21
+ "pre-link-args" : {
22
+ "gcc" : [
23
+ " -Wl,--as-needed" ,
24
+ " -Wl,-z,noexecstack" ,
25
+ " -m32"
26
+ ]
27
+ },
28
+ "relocation-model" : " static" ,
29
+ "relro-level" : " full" ,
30
+ "stack-probes" : {
31
+ "kind" : " inline-or-call" ,
32
+ "min-llvm-version-for-inline" : [
33
+ 11 ,
34
+ 0 ,
35
+ 1
36
+ ]
37
+ },
38
+ "target-c-int-width" : " 32" ,
39
+ "target-endian" : " little" ,
40
+ "target-pointer-width" : " 32" ,
41
+ "vendor" : " "
42
+ }
Original file line number Diff line number Diff line change
1
+ {
2
+ "arch" : " riscv64" ,
3
+ "code-model" : " medium" ,
4
+ "cpu" : " generic-rv64" ,
5
+ "data-layout" : " e-m:e-p:64:64-i64:64-i128:128-n64-S128" ,
6
+ "disable-redzone" : true ,
7
+ "eliminate-frame-pointer" : false ,
8
+ "emit-debug-gdb-scripts" : false ,
9
+ "env" : " gnu" ,
10
+ "features" : " +m,+a" ,
11
+ "function-sections" : false ,
12
+ "is-builtin" : true ,
13
+ "linker-flavor" : " gcc" ,
14
+ "linker-is-gnu" : true ,
15
+ "llvm-target" : " riscv64" ,
16
+ "max-atomic-width" : 64 ,
17
+ "needs-plt" : true ,
18
+ "os" : " none" ,
19
+ "panic-strategy" : " abort" ,
20
+ "position-independent-executables" : true ,
21
+ "pre-link-args" : {
22
+ "gcc" : [
23
+ " -Wl,--as-needed" ,
24
+ " -Wl,-z,noexecstack" ,
25
+ " -m64"
26
+ ]
27
+ },
28
+ "relocation-model" : " static" ,
29
+ "relro-level" : " full" ,
30
+ "stack-probes" : {
31
+ "kind" : " inline-or-call" ,
32
+ "min-llvm-version-for-inline" : [
33
+ 11 ,
34
+ 0 ,
35
+ 1
36
+ ]
37
+ },
38
+ "target-c-int-width" : " 32" ,
39
+ "target-endian" : " little" ,
40
+ "target-pointer-width" : " 64" ,
41
+ "vendor" : " "
42
+ }
Original file line number Diff line number Diff line change
1
+ {
2
+ "arch" : " riscv64" ,
3
+ "code-model" : " medium" ,
4
+ "cpu" : " generic-rv64" ,
5
+ "data-layout" : " e-m:e-p:64:64-i64:64-i128:128-n64-S128" ,
6
+ "disable-redzone" : true ,
7
+ "eliminate-frame-pointer" : false ,
8
+ "emit-debug-gdb-scripts" : false ,
9
+ "env" : " gnu" ,
10
+ "features" : " +m,+a,+c" ,
11
+ "function-sections" : false ,
12
+ "is-builtin" : true ,
13
+ "linker-flavor" : " gcc" ,
14
+ "linker-is-gnu" : true ,
15
+ "llvm-target" : " riscv64" ,
16
+ "max-atomic-width" : 64 ,
17
+ "needs-plt" : true ,
18
+ "os" : " none" ,
19
+ "panic-strategy" : " abort" ,
20
+ "position-independent-executables" : true ,
21
+ "pre-link-args" : {
22
+ "gcc" : [
23
+ " -Wl,--as-needed" ,
24
+ " -Wl,-z,noexecstack" ,
25
+ " -m64"
26
+ ]
27
+ },
28
+ "relocation-model" : " static" ,
29
+ "relro-level" : " full" ,
30
+ "stack-probes" : {
31
+ "kind" : " inline-or-call" ,
32
+ "min-llvm-version-for-inline" : [
33
+ 11 ,
34
+ 0 ,
35
+ 1
36
+ ]
37
+ },
38
+ "target-c-int-width" : " 32" ,
39
+ "target-endian" : " little" ,
40
+ "target-pointer-width" : " 64" ,
41
+ "vendor" : " "
42
+ }
Original file line number Diff line number Diff line change @@ -58,7 +58,7 @@ config LLD_VERSION
58
58
default 0
59
59
60
60
config HAS_RUST
61
- depends on ARM64 || CPU_32v6 || CPU_32v6K || (PPC64 && CPU_LITTLE_ENDIAN) || X86_64
61
+ depends on ARM64 || CPU_32v6 || CPU_32v6K || (PPC64 && CPU_LITTLE_ENDIAN) || X86_64 || RISCV
62
62
def_bool $(success,$(RUSTC) --version)
63
63
64
64
config RUSTC_VERSION
Original file line number Diff line number Diff line change 9
9
10
10
#![ allow( non_camel_case_types) ]
11
11
12
- #[ cfg( any( target_arch = "arm" , target_arch = "x86" ) ) ]
12
+ #[ cfg( any(
13
+ target_arch = "arm" ,
14
+ target_arch = "x86" ,
15
+ target_arch = "riscv32" ,
16
+ ) ) ]
13
17
mod c {
14
18
/// C `void` type.
15
19
pub type c_void = core:: ffi:: c_void ;
@@ -63,7 +67,8 @@ mod c {
63
67
#[ cfg( any(
64
68
target_arch = "aarch64" ,
65
69
target_arch = "x86_64" ,
66
- target_arch = "powerpc64"
70
+ target_arch = "powerpc64" ,
71
+ target_arch = "riscv64" ,
67
72
) ) ]
68
73
mod c {
69
74
/// C `void` type.
Original file line number Diff line number Diff line change @@ -291,7 +291,7 @@ $(obj)/%.lst: $(src)/%.c FORCE
291
291
# Compile Rust sources (.rs)
292
292
# ---------------------------------------------------------------------------
293
293
294
- rustc_cross_flags := --target=$(srctree)/arch/$(SRCARCH)/rust/target.json
294
+ rustc_cross_flags := --target=$(KBUILD_RUSTC_TARGET)
295
295
296
296
quiet_cmd_rustc_o_rs = $(RUSTC_OR_CLIPPY_QUIET) $(quiet_modtag) $@
297
297
cmd_rustc_o_rs = \
You can’t perform that action at this time.
0 commit comments