
Fix an issue about module linking with LTO. When compiling with PIE, the small data limitation needs to be consistent with that in PIC, otherwise there will be linking errors due to conflicting values. bar.c ``` int bar() { return 1; } ``` foo.c ``` int foo() { return 1; } ``` ``` clang --target=riscv64-unknown-linux-gnu -flto -c foo.c -o foo.o -fPIE clang --target=riscv64-unknown-linux-gnu -flto -c bar.c -o bar.o -fPIC clang --target=riscv64-unknown-linux-gnu -flto foo.o bar.o -flto -nostdlib -v -fuse-ld=lld ``` ``` ld.lld: error: linking module flags 'SmallDataLimit': IDs have conflicting values in 'bar.o' and 'ld-temp.o' clang-15: error: linker command failed with exit code 1 (use -v to see invocation) ``` Use Min instead of Error for conflicting SmallDataLimit. Authored by: @joshua-arch1 Signed-off-by: xiaojing.zhang <xiaojing.zhang@xcalibyte.com> Signed-off-by: jianxin.lai <jianxin.lai@xcalibyte.com> Reviewed By: MaskRay Differential Revision: https://reviews.llvm.org/D131230
16 lines
516 B
LLVM
16 lines
516 B
LLVM
; RUN: llc -mtriple=riscv32 < %s | FileCheck -check-prefix=RV32 %s
|
|
; RUN: llc -mtriple=riscv64 < %s | FileCheck -check-prefix=RV64 %s
|
|
|
|
@v = dso_local global i32 0, align 4
|
|
@r = dso_local global i64 7, align 8
|
|
|
|
; SmallDataLimit set to 4, so we expect @v will be put in sbss,
|
|
; but @r won't be put in sdata.
|
|
!llvm.module.flags = !{!0}
|
|
!0 = !{i32 8, !"SmallDataLimit", i32 4}
|
|
|
|
; RV32: .section .sbss
|
|
; RV32-NOT: .section .sdata
|
|
; RV64: .section .sbss
|
|
; RV64-NOT: .section .sdata
|