Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 8 pull requests #127653

Merged
merged 22 commits into from
Jul 12, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
22 commits
Select commit Hold shift click to select a range
a1ad634
Add fn allocator method to rc/sync::Weak. Relax Rc<T>/Arc<T>::allocat…
zachs18 May 10, 2024
5c46aca
document the cvt methods
the8472 Jun 22, 2024
6687a3f
use pidfd_spawn for faster process creation when pidfds are requested
the8472 Jun 22, 2024
0ce3619
document safety properties of the internal Process::new constructor
the8472 Jun 24, 2024
3e4e31b
more fine-grained feature-detection for pidfd spawning
the8472 Jun 24, 2024
ec0c755
Check that we get somewhat sane PIDs when spawning with pidfds
the8472 Jun 24, 2024
53d3e62
Stabilize const_cstr_from_ptr (CStr::from_ptr, CStr::count_bytes)
dtolnay Jul 6, 2024
0134bd2
remove unnecessary `git` usages
onur-ozkan Jul 10, 2024
f56b207
solve -> solve/mod
lcnr Jul 11, 2024
55256c5
Update dist-riscv64-linux to binutils 2.40
nikic Jul 10, 2024
ec05c4e
Add the feature gate and target-features
sayantn Jun 23, 2024
7f1518b
Add instability attribute on private const_strlen function
dtolnay Jul 12, 2024
3f4b9dd
Lower timeout of CI jobs to 4 hours
Kobzol Jul 12, 2024
15f770b
enable fuzzing of `SearchGraph`
lcnr Jul 11, 2024
65ea92d
Rollup merge of #124980 - zachs18:rc-allocator, r=Amanieu
matthiaskrgr Jul 12, 2024
18152d7
Rollup merge of #126639 - sayantn:amx, r=Amanieu
matthiaskrgr Jul 12, 2024
f9b3e8b
Rollup merge of #126827 - the8472:pidfd-spawn, r=workingjubilee
matthiaskrgr Jul 12, 2024
8ceb4e4
Rollup merge of #127433 - dtolnay:conststrlen, r=workingjubilee
matthiaskrgr Jul 12, 2024
b4f002d
Rollup merge of #127552 - onur-ozkan:unnecessary-git-usage, r=Kobzol
matthiaskrgr Jul 12, 2024
f5fa6fb
Rollup merge of #127613 - nikic:riscv-update, r=cuviper
matthiaskrgr Jul 12, 2024
526da23
Rollup merge of #127627 - lcnr:rustc_search_graph, r=compiler-errors
matthiaskrgr Jul 12, 2024
f11c2c8
Rollup merge of #127648 - Kobzol:ci-lower-timeout, r=pietroalbini
matthiaskrgr Jul 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/ci/docker/host-x86_64/dist-riscv64-linux/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 11,7 @@ RUN sh /scripts/rustbuild-setup.sh
WORKDIR /tmp

COPY scripts/crosstool-ng-build.sh /scripts/
COPY host-x86_64/dist-riscv64-linux/patches/ /tmp/patches/
COPY host-x86_64/dist-riscv64-linux/riscv64-unknown-linux-gnu.defconfig /tmp/crosstool.defconfig
RUN /scripts/crosstool-ng-build.sh

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 1,37 @@
From 4013baf99c38f7bca06a51f8301e8fb195ccfa33 Mon Sep 17 00:00:00 2001
From: Jim Wilson <[email protected]>
Date: Tue, 2 Jun 2020 11:19:39 -0700
Subject: [PATCH] RISC-V: Make __divdi3 handle div by zero same as hardware.

The ISA manual specifies that divide by zero always returns -1 as the result.
We were failing to do that when the dividend was negative.

Original patch from Virginie Moser.

libgcc/
* config/riscv/div.S (__divdi3): For negative arguments, change bgez
to bgtz.
---
libgcc/config/riscv/div.S | 8 ---
1 file changed, 5 insertions( ), 3 deletions(-)

diff --git a/libgcc/config/riscv/div.S b/libgcc/config/riscv/div.S
index 151f8e273ac77..17234324c1e41 100644
--- a/libgcc/config/riscv/div.S
b/libgcc/config/riscv/div.S
@@ -107,10 107,12 @@ FUNC_END (__umoddi3)
/* Handle negative arguments to __divdi3. */
.L10:
neg a0, a0
- bgez a1, .L12 /* Compute __udivdi3(-a0, a1), then negate the result. */
/* Zero is handled as a negative so that the result will not be inverted. */
bgtz a1, .L12 /* Compute __udivdi3(-a0, a1), then negate the result. */
neg a1, a1
- j __udivdi3 /* Compute __udivdi3(-a0, -a1). */
-.L11: /* Compute __udivdi3(a0, -a1), then negate the result. */
j __udivdi3 /* Compute __udivdi3(-a0, -a1). */
.L11: /* Compute __udivdi3(a0, -a1), then negate the result. */
neg a1, a1
.L12:
move t0, ra
Original file line number Diff line number Diff line change
@@ -0,0 1,117 @@
From 45116f342057b7facecd3d05c2091ce3a77eda59 Mon Sep 17 00:00:00 2001
From: Nelson Chu <[email protected]>
Date: Mon, 29 Nov 2021 04:48:20 -0800
Subject: [PATCH] RISC-V: jal cannot refer to a default visibility symbol for
shared object.

This is the original binutils bugzilla report,
https://sourceware.org/bugzilla/show_bug.cgi?id=28509

And this is the first version of the proposed binutils patch,
https://sourceware.org/pipermail/binutils/2021-November/118398.html

After applying the binutils patch, I get the the unexpected error when
building libgcc,

/scratch/nelsonc/riscv-gnu-toolchain/riscv-gcc/libgcc/config/riscv/div.S:42:
/scratch/nelsonc/build-upstream/rv64gc-linux/build-install/riscv64-unknown-linux-gnu/bin/ld: relocation R_RISCV_JAL against `__udivdi3' which may bind externally can not be used when making a shared object; recompile with -fPIC

Therefore, this patch add an extra hidden alias symbol for __udivdi3, and
then use HIDDEN_JUMPTARGET to target a non-preemptible symbol instead.
The solution is similar to glibc as follows,
https://sourceware.org/git/?p=glibc.git;a=commit;h=68389203832ab39dd0dbaabbc4059e7fff51c29b

libgcc/ChangeLog:

* config/riscv/div.S: Add the hidden alias symbol for __udivdi3, and
then use HIDDEN_JUMPTARGET to target it since it is non-preemptible.
* config/riscv/riscv-asm.h: Added new macros HIDDEN_JUMPTARGET and
HIDDEN_DEF.
---
libgcc/config/riscv/div.S | 15 -------
libgcc/config/riscv/riscv-asm.h | 6
2 files changed, 14 insertions( ), 7 deletions(-)

diff --git a/libgcc/config/riscv/div.S b/libgcc/config/riscv/div.S
index c9bd7879c1e36..723c3b82e48c6 100644
--- a/libgcc/config/riscv/div.S
b/libgcc/config/riscv/div.S
@@ -40,7 40,7 @@ FUNC_BEGIN (__udivsi3)
sll a0, a0, 32
sll a1, a1, 32
move t0, ra
- jal __udivdi3
jal HIDDEN_JUMPTARGET(__udivdi3)
sext.w a0, a0
jr t0
FUNC_END (__udivsi3)
@@ -52,7 52,7 @@ FUNC_BEGIN (__umodsi3)
srl a0, a0, 32
srl a1, a1, 32
move t0, ra
- jal __udivdi3
jal HIDDEN_JUMPTARGET(__udivdi3)
sext.w a0, a1
jr t0
FUNC_END (__umodsi3)
@@ -95,11 95,12 @@ FUNC_BEGIN (__udivdi3)
.L5:
ret
FUNC_END (__udivdi3)
HIDDEN_DEF (__udivdi3)

FUNC_BEGIN (__umoddi3)
/* Call __udivdi3(a0, a1), then return the remainder, which is in a1. */
move t0, ra
- jal __udivdi3
jal HIDDEN_JUMPTARGET(__udivdi3)
move a0, a1
jr t0
FUNC_END (__umoddi3)
@@ -111,12 112,12 @@ FUNC_END (__umoddi3)
bgtz a1, .L12 /* Compute __udivdi3(-a0, a1), then negate the result. */

neg a1, a1
- j __udivdi3 /* Compute __udivdi3(-a0, -a1). */
j HIDDEN_JUMPTARGET(__udivdi3) /* Compute __udivdi3(-a0, -a1). */
.L11: /* Compute __udivdi3(a0, -a1), then negate the result. */
neg a1, a1
.L12:
move t0, ra
- jal __udivdi3
jal HIDDEN_JUMPTARGET(__udivdi3)
neg a0, a0
jr t0
FUNC_END (__divdi3)
@@ -126,7 127,7 @@ FUNC_BEGIN (__moddi3)
bltz a1, .L31
bltz a0, .L32
.L30:
- jal __udivdi3 /* The dividend is not negative. */
jal HIDDEN_JUMPTARGET(__udivdi3) /* The dividend is not negative. */
move a0, a1
jr t0
.L31:
@@ -134,7 135,7 @@ FUNC_BEGIN (__moddi3)
bgez a0, .L30
.L32:
neg a0, a0
- jal __udivdi3 /* The dividend is hella negative. */
jal HIDDEN_JUMPTARGET(__udivdi3) /* The dividend is hella negative. */
neg a0, a1
jr t0
FUNC_END (__moddi3)
diff --git a/libgcc/config/riscv/riscv-asm.h b/libgcc/config/riscv/riscv-asm.h
index 8550707a4a26a..96dd85b0df2e5 100644
--- a/libgcc/config/riscv/riscv-asm.h
b/libgcc/config/riscv/riscv-asm.h
@@ -33,3 33,9 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
#define FUNC_ALIAS(X,Y) \
.globl X; \
X = Y
#define CONCAT1(a, b) CONCAT2(a, b)
#define CONCAT2(a, b) a ## b
#define HIDDEN_JUMPTARGET(X) CONCAT1(__hidden_, X)
#define HIDDEN_DEF(X) FUNC_ALIAS(HIDDEN_JUMPTARGET(X), X); \
.hidden HIDDEN_JUMPTARGET(X)
Original file line number Diff line number Diff line change
@@ -0,0 1,58 @@
From 68389203832ab39dd0dbaabbc4059e7fff51c29b Mon Sep 17 00:00:00 2001
From: Fangrui Song <[email protected]>
Date: Thu, 28 Oct 2021 11:39:49 -0700
Subject: [PATCH] riscv: Fix incorrect jal with HIDDEN_JUMPTARGET

A non-local STV_DEFAULT defined symbol is by default preemptible in a
shared object. j/jal cannot target a preemptible symbol. On other
architectures, such a jump instruction either causes PLT [BZ #18822], or
if short-ranged, sometimes rejected by the linker (but not by GNU ld's
riscv port [ld PR/28509]).

Use HIDDEN_JUMPTARGET to target a non-preemptible symbol instead.

With this patch, ld.so and libc.so can be linked with LLD if source
files are compiled/assembled with -mno-relax/-Wa,-mno-relax.

Acked-by: Palmer Dabbelt <[email protected]>
Reviewed-by: Adhemerval Zanella <[email protected]>
---
sysdeps/riscv/setjmp.S | 2 -
sysdeps/unix/sysv/linux/riscv/setcontext.S | 5 --
2 files changed, 4 insertions( ), 3 deletions(-)

diff --git a/sysdeps/riscv/setjmp.S b/sysdeps/riscv/setjmp.S
index 0b92016b311..bec7ff80f49 100644
--- a/sysdeps/riscv/setjmp.S
b/sysdeps/riscv/setjmp.S
@@ -21,7 21,7 @@

ENTRY (_setjmp)
li a1, 0
- j __sigsetjmp
j HIDDEN_JUMPTARGET (__sigsetjmp)
END (_setjmp)
ENTRY (setjmp)
li a1, 1
diff --git a/sysdeps/unix/sysv/linux/riscv/setcontext.S b/sysdeps/unix/sysv/linux/riscv/setcontext.S
index 9510518750a..e44a68aad47 100644
--- a/sysdeps/unix/sysv/linux/riscv/setcontext.S
b/sysdeps/unix/sysv/linux/riscv/setcontext.S
@@ -95,6 95,7 @@ LEAF (__setcontext)
99: j __syscall_error

END (__setcontext)
libc_hidden_def (__setcontext)
weak_alias (__setcontext, setcontext)

LEAF (__start_context)
@@ -108,7 109,7 @@ LEAF (__start_context)
/* Invoke subsequent context if present, else exit(0). */
mv a0, s2
beqz s2, 1f
- jal __setcontext
-1: j exit
jal HIDDEN_JUMPTARGET (__setcontext)
1: j HIDDEN_JUMPTARGET (exit)

END (__start_context)
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 3,16 @@ CT_EXPERIMENTAL=y
CT_PREFIX_DIR="/x-tools/${CT_TARGET}"
CT_USE_MIRROR=y
CT_MIRROR_BASE_URL="https://ci-mirrors.rust-lang.org/rustc"
CT_PATCH_BUNDLED_LOCAL=y
CT_LOCAL_PATCH_DIR="/tmp/patches"
CT_ARCH_RISCV=y
# CT_DEMULTILIB is not set
CT_ARCH_USE_MMU=y
CT_ARCH_64=y
CT_ARCH_ARCH="rv64gc"
CT_KERNEL_LINUX=y
CT_LINUX_V_4_20=y
CT_BINUTILS_V_2_36=y
CT_BINUTILS_V_2_40=y
CT_GLIBC_V_2_29=y
CT_GCC_V_8=y
CT_CC_LANG_CXX=y