forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Set target-abi module flag for RISC-V targets
Fixes cross-language LTO on RISC-V targets (Fixes rust-lang#121924)
- Loading branch information
Showing
10 changed files
with
119 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
//@ revisions:riscv64gc riscv32gc riscv32imac | ||
|
||
//@[riscv64gc] compile-flags: --target=riscv64gc-unknown-linux-gnu | ||
//@[riscv64gc] needs-llvm-components: riscv | ||
// riscv64gc: !{i32 {{1}}, !"target-abi", !"lp64d"} | ||
|
||
//@[riscv32gc] compile-flags: --target=riscv32gc-unknown-linux-musl | ||
//@[riscv32gc] needs-llvm-components: riscv | ||
// riscv32gc: !{i32 {{1}}, !"target-abi", !"ilp32d"} | ||
|
||
//@[riscv32imac] compile-flags: --target=riscv32imac-unknown-none-elf | ||
//@[riscv32imac] needs-llvm-components: riscv | ||
// riscv32imac-NOT: !{i32 {{1}}, !"target-abi", !""} | ||
|
||
#![feature(no_core, lang_items)] | ||
#![crate_type = "lib"] | ||
#![no_core] | ||
|
||
#[lang = "sized"] | ||
trait Sized {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# needs-matching-clang | ||
|
||
# This test makes sure that cross-language LTO works on riscv targets | ||
|
||
include ../tools.mk | ||
|
||
all: riscv64gc-unknown-linux-gnu riscv32imac-unknown-none-elf riscv32gc-unknown-linux-gnu | ||
|
||
define check-target = | ||
@echo "Testing target $(1)" | ||
$(RUSTC) --target $(1) -Clinker-plugin-lto=on -Cpanic=abort --crate-type=rlib -o $(TMPDIR)/libriscv-xlto.a ./riscv-xlto.rs | ||
$(CLANG) -target $(2) -march=$(3) -mabi=$(4) -flto=thin -fuse-ld=lld -L $(TMPDIR) -lriscv-xlto $(5) -nostdlib -o $(TMPDIR)/riscv-xlto ./clib.c | ||
file $(TMPDIR)/riscv-xlto | $(CGREP) "$(6)" | ||
endef | ||
|
||
|
||
riscv64gc-unknown-linux-gnu: | ||
@$(call check-target,$@,riscv64-linux-gnu,rv64gc,lp64d,-shared,double-float ABI) | ||
|
||
riscv32imac-unknown-none-elf: | ||
@$(call check-target,$@,riscv32-unknown-elf,rv32imac,ilp32,-DEXECUTABLE,soft-float ABI) | ||
|
||
riscv32gc-unknown-linux-gnu: | ||
@$(call check-target,$@,riscv32-linux-gnu,rv32gc,ilp32d,-shared,double-float ABI) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
extern void hello(); | ||
|
||
void test() { | ||
hello(); | ||
} | ||
|
||
#ifdef EXECUTABLE | ||
void _start() { | ||
test(); | ||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#![allow(internal_features)] | ||
#![feature(no_core, lang_items)] | ||
#![no_core] | ||
|
||
#[lang = "sized"] | ||
trait Sized {} | ||
|
||
#[no_mangle] | ||
pub fn hello() {} |