Skip to content

Commit f83100d

Browse files
authored
Merge pull request #13 from sailfishos/1.52.1
[rust] Initial packaging of rust 1.52.1. JB#54225 JOLLA-139
2 parents ecfc96f + 5a164a7 commit f83100d

10 files changed

+128
-160
lines changed

0001-Use-a-non-existent-test-path-instead-of-clobbering-d.patch

Lines changed: 0 additions & 60 deletions
This file was deleted.

0003-Disable-statx-for-all-builds.-JB-50106.patch

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
From f131514903bb02f5f9f1d312aea19e954ab1ffee Mon Sep 17 00:00:00 2001
2-
From: =?UTF-8?q?Tomi=20Lepp=C3=A4nen?= <tomi.leppanen@jolla.com>
3-
Date: Fri, 26 Jun 2020 11:58:19 +0300
4-
Subject: [PATCH 3/4] Disable statx for all builds. JB#50106
1+
From 0ea195274d580ada6af1f9687647564d9a06ecd5 Mon Sep 17 00:00:00 2001
2+
From: Niels Breet <niels.breet@jolla.com>
3+
Date: Tue, 11 May 2021 13:03:55 +0300
4+
Subject: [PATCH] Disable statx for all builds. JB#50106
55
MIME-Version: 1.0
66
Content-Type: text/plain; charset=UTF-8
77
Content-Transfer-Encoding: 8bit
@@ -15,13 +15,13 @@ that gracefully without issues thanks to rust's type system.
1515
Signed-off-by: Tomi Leppänen <tomi.leppanen@jolla.com
1616
Signed-off-by: Matti Kosola <matti.kosola@jolla.com>
1717
---
18-
src/libstd/sys/unix/fs.rs | 15 ++-------------
18+
library/std/src/sys/unix/fs.rs | 15 ++-------------
1919
1 file changed, 2 insertions(+), 13 deletions(-)
2020

21-
diff --git a/src/libstd/sys/unix/fs.rs b/src/libstd/sys/unix/fs.rs
22-
index a233aa47dff..45fb192fc8c 100644
23-
--- a/src/libstd/sys/unix/fs.rs
24-
+++ b/src/libstd/sys/unix/fs.rs
21+
diff --git a/library/std/src/sys/unix/fs.rs b/library/std/src/sys/unix/fs.rs
22+
index d1b0ad9..f5ddc9b 100644
23+
--- a/library/std/src/sys/unix/fs.rs
24+
+++ b/library/std/src/sys/unix/fs.rs
2525
@@ -58,20 +58,9 @@ pub struct File(FileDesc);
2626
// https://github.com/rust-lang/rust/pull/67774
2727
macro_rules! cfg_has_statx {
@@ -46,5 +46,5 @@ index a233aa47dff..45fb192fc8c 100644
4646

4747
cfg_has_statx! {{
4848
--
49-
2.20.1
49+
1.9.1
5050

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
From ee426fcbb8e03d1a7834c73225a65697b3dd4a1a Mon Sep 17 00:00:00 2001
2-
From: David Greaves <david.greaves@jolla.com>
3-
Date: Mon, 5 Oct 2020 10:14:39 +0100
4-
Subject: [PATCH 4/4] Scratchbox2 needs to be able to tell rustc the default
1+
From ac226bbc018e11311394126fe580763c5bc77a2c Mon Sep 17 00:00:00 2001
2+
From: Niels Breet <niels.breet@jolla.com>
3+
Date: Tue, 11 May 2021 13:10:49 +0300
4+
Subject: [PATCH] Scratchbox2 needs to be able to tell rustc the default
55
target.
66

77
Currently this defaults to the target rust was built with. Rather than
@@ -10,29 +10,29 @@ allows the same rustc binary to be used for all builds.
1010

1111
Signed-off-by: David Greaves <david.greaves@jolla.com>
1212
---
13-
src/librustc_session/config.rs | 9 ++++++++-
13+
compiler/rustc_session/src/config.rs | 9 ++++++++-
1414
1 file changed, 8 insertions(+), 1 deletion(-)
1515

16-
diff --git a/src/librustc_session/config.rs b/src/librustc_session/config.rs
17-
index 2513cfa73e5..529d836dc82 100644
18-
--- a/src/librustc_session/config.rs
19-
+++ b/src/librustc_session/config.rs
20-
@@ -1363,7 +1363,14 @@ fn parse_target_triple(matches: &getopts::Matches, error_format: ErrorOutputType
16+
diff --git a/compiler/rustc_session/src/config.rs b/compiler/rustc_session/src/config.rs
17+
index 85448b7..ec51c50 100644
18+
--- a/compiler/rustc_session/src/config.rs
19+
+++ b/compiler/rustc_session/src/config.rs
20+
@@ -1537,7 +1537,14 @@ fn parse_target_triple(matches: &getopts::Matches, error_format: ErrorOutputType
2121
})
2222
}
2323
Some(target) => TargetTriple::TargetTriple(target),
2424
- _ => TargetTriple::from_triple(host_triple()),
25-
+ // In SFOS we use SB2 and need to tell rust what the
25+
+ // In SFOS we use SB2 and need to tell rust what the
2626
+ // 'default' target is. If the SB2_RUST_TARGET_TRIPLE
2727
+ // environment variable is set then it is used. Otherwise
2828
+ // the fallback is the host_triple as usual
2929
+ _ => match std::env::var("SB2_RUST_TARGET_TRIPLE") {
3030
+ Ok(tgt) => TargetTriple::TargetTriple(tgt),
3131
+ Err(_) => TargetTriple::from_triple(host_triple()),
32-
+ }
32+
+ }
3333
}
3434
}
3535

3636
--
37-
2.20.1
37+
1.9.1
3838

0006-Provide-ENV-controls-to-bypass-some-sb2-calls-betwee.patch

Lines changed: 64 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -34,21 +34,25 @@ needed to support the SHIM functionality
3434

3535
Signed-off-by: David Greaves <david.greaves@jolla.com>
3636
---
37-
src/libstd/sys/unix/process/process_common.rs | 40 ++++-
38-
src/libstd/sys/unix/process/process_unix.rs | 138 ++++++++++++++++--
37+
library/std/src/sys/unix/process/process_common.rs | 40 ++++-
38+
library/std/src/sys/unix/process/process_unix.rs | 138 ++++++++++++++++--
3939
2 files changed, 160 insertions(+), 18 deletions(-)
4040

41-
diff --git a/src/libstd/sys/unix/process/process_common.rs b/src/libstd/sys/unix/process/process_common.rs
41+
diff --git a/library/std/src/sys/unix/process/process_common.rs b/library/std/src/sys/unix/process/process_common.rs
4242
index 859da691ad2..ee5e776efac 100644
43-
--- a/src/libstd/sys/unix/process/process_common.rs
44-
+++ b/src/libstd/sys/unix/process/process_common.rs
45-
@@ -71,10 +71,16 @@ pub struct Command {
46-
// located. Whenever we add a key we update it in place if it's already
47-
// present, and whenever we remove a key we update the locations of all
48-
// other keys.
43+
--- a/library/std/src/sys/unix/process/process_common.rs
44+
+++ b/library/std/src/sys/unix/process/process_common.rs
45+
@@ -60,7 +60,7 @@
46+
////////////////////////////////////////////////////////////////////////////////
47+
48+
pub struct Command {
4949
- program: CString,
5050
+ pub(crate) program: CString,
5151
args: Vec<CString>,
52+
/// Exactly what will be passed to `execvp`.
53+
///
54+
@@ -69,6 +69,13 @@
55+
/// `args` to properly update this as well.
5256
argv: Argv,
5357
env: CommandEnv,
5458
+ pub(crate) execvp: Option<ExecvpFn>,
@@ -57,24 +61,26 @@ index 859da691ad2..ee5e776efac 100644
5761
+ pub(crate) chdir: Option<ChdirFn>,
5862
+ pub(crate) setuid: Option<SetuidFn>,
5963
+ pub(crate) setgid: Option<SetgidFn>,
60-
64+
+ pub(crate) setgroups: Option<SetgroupsFn>,
65+
6166
cwd: Option<CString>,
6267
uid: Option<uid_t>,
63-
@@ -86,6 +92,13 @@ pub struct Command {
68+
@@ -81,6 +88,14 @@
6469
stderr: Option<Stdio>,
6570
}
66-
71+
6772
+pub(crate) type ExecvpFn = fn(*const c_char, *const *const c_char)->c_int;
6873
+pub(crate) type Dup2Fn = fn(c_int, c_int)->c_int;
6974
+pub(crate) type CloseFn = fn(c_int)->c_int;
7075
+pub(crate) type ChdirFn = fn(*const c_char)->c_int;
7176
+pub(crate) type SetuidFn = fn(uid_t)->c_int;
7277
+pub(crate) type SetgidFn = fn(gid_t)->c_int;
73-
+
74-
// Create a new type for argv, so that we can make it `Send`
78+
+pub(crate) type SetgroupsFn = fn(libc::size_t, *const gid_t)->c_int;
79+
+
80+
// Create a new type for argv, so that we can make it `Send` and `Sync`
7581
struct Argv(Vec<*const c_char>);
76-
77-
@@ -130,15 +143,22 @@ impl Command {
82+
83+
@@ -130,15 +143,23 @@ impl Command {
7884
pub fn new(program: &OsStr) -> Command {
7985
let mut saw_nul = false;
8086
let program = os2c(program, &mut saw_nul);
@@ -93,6 +99,7 @@ index 859da691ad2..ee5e776efac 100644
9399
+ chdir: None,
94100
+ setuid: None,
95101
+ setgid: None,
102+
+ setgroups: None,
96103
cwd: None,
97104
uid: None,
98105
gid: None,
@@ -118,14 +125,14 @@ index 859da691ad2..ee5e776efac 100644
118125
pub fn set_arg_0(&mut self, arg: &OsStr) {
119126
// Set a new arg0
120127
let arg = os2c(arg, &mut self.saw_nul);
121-
diff --git a/src/libstd/sys/unix/process/process_unix.rs b/src/libstd/sys/unix/process/process_unix.rs
128+
diff --git a/library/std/src/sys/unix/process/process_unix.rs b/library/std/src/sys/unix/process/process_unix.rs
122129
index f389c60615f..d5763b8aa1a 100644
123-
--- a/src/libstd/sys/unix/process/process_unix.rs
124-
+++ b/src/libstd/sys/unix/process/process_unix.rs
125-
@@ -5,7 +5,10 @@ use crate::sys;
126-
use crate::sys::cvt;
127-
use crate::sys::process::process_common::*;
130+
--- a/library/std/src/sys/unix/process/process_unix.rs
131+
+++ b/library/std/src/sys/unix/process/process_unix.rs
132+
@@ -5,7 +5,10 @@ #[cfg(target_os = "vxworks")]
133+
use libc::RTP_ID as pid_t;
128134

135+
#[cfg(not(target_os = "vxworks"))]
129136
-use libc::{c_int, gid_t, pid_t, uid_t};
130137
+use libc::{c_int, gid_t, pid_t, uid_t, dlsym, c_char};
131138
+use crate::intrinsics::transmute;
@@ -134,7 +141,7 @@ index f389c60615f..d5763b8aa1a 100644
134141

135142
////////////////////////////////////////////////////////////////////////////////
136143
// Command
137-
@@ -33,6 +36,70 @@ impl Command {
144+
@@ -35,6 +41,74 @@ impl Command {
138145

139146
let (input, output) = sys::pipe::anon_pipe()?;
140147

@@ -196,6 +203,10 @@ index f389c60615f..d5763b8aa1a 100644
196203
+ "setgid\0".as_ptr() as *const c_char) as *const ();
197204
+ self.setgid = Some(
198205
+ transmute::<*const (), SetgidFn>(real_setgid_p) );
206+
+ let real_setgroups_p = dlsym(libc_h,
207+
+ "setgroups\0".as_ptr() as *const c_char) as *const ();
208+
+ self.setgroups = Some(
209+
+ transmute::<*const (), SetgroupsFn>(real_setgroups_p) );
199210
+ },
200211
+ None => {}
201212
+ };
@@ -205,21 +216,16 @@ index f389c60615f..d5763b8aa1a 100644
205216
// Whatever happens after the fork is almost for sure going to touch or
206217
// look at the environment in one way or another (PATH in `execvp` or
207218
// accessing the `environ` pointer ourselves). Make sure no other thread
208-
@@ -45,11 +112,11 @@ impl Command {
209-
let _env_lock = sys::os::env_lock();
210-
cvt(libc::fork())?
211-
};
212-
-
213-
+
214-
let pid = unsafe {
219+
@@ -54,7 +125,7 @@
215220
match result {
216221
0 => {
222+
mem::forget(env_lock);
217223
- drop(input);
218224
+ self.unwrap_drop(input);
219225
let Err(err) = self.do_exec(theirs, envp.as_ref());
220226
let errno = err.raw_os_error().unwrap_or(libc::EINVAL) as u32;
221-
let bytes = [
222-
@@ -135,7 +202,37 @@ impl Command {
227+
let errno = errno.to_be_bytes();
228+
@@ -135,7 +202,43 @@ impl Command {
223229
Err(e) => e,
224230
}
225231
}
@@ -254,11 +260,17 @@ index f389c60615f..d5763b8aa1a 100644
254260
+ Some(real_setgid) => { (real_setgid)(gid) },
255261
+ None => { unsafe { libc::setgid(gid) } }
256262
+ }
263+
+ }
264+
+ fn unwrap_setgroups(&self, ngroups: libc::size_t, gid: *const gid_t) -> c_int {
265+
+ match self.setgroups {
266+
+ Some(real_setgroups) => { (real_setgroups)(ngroups, gid) },
267+
+ None => { unsafe { libc::setgroups(ngroups, gid) } }
268+
+ }
257269
+ }
258270
// And at this point we've reached a special time in the life of the
259271
// child. The child must now be considered hamstrung and unable to
260272
// do anything other than syscalls really. Consider the following
261-
@@ -174,19 +271,19 @@ impl Command {
273+
@@ -174,24 +277,24 @@ impl Command {
262274
use crate::sys::{self, cvt_r};
263275

264276
if let Some(fd) = stdio.stdin.fd() {
@@ -276,16 +288,25 @@ index f389c60615f..d5763b8aa1a 100644
276288

277289
#[cfg(not(target_os = "l4re"))]
278290
{
291+
if let Some(_g) = self.get_groups() {
292+
//FIXME: Redox kernel does not support setgroups yet
293+
#[cfg(not(target_os = "redox"))]
294+
- cvt(libc::setgroups(_g.len().try_into().unwrap(), _g.as_ptr()))?;
295+
+ cvt(self.unwrap_setgroups(_g.len().try_into().unwrap(), _g.as_ptr()))?;
296+
}
279297
if let Some(u) = self.get_gid() {
280298
- cvt(libc::setgid(u as gid_t))?;
281299
+ cvt(self.unwrap_setgid(u as gid_t))?;
282300
}
283301
if let Some(u) = self.get_uid() {
284302
// When dropping privileges from root, the `setgroups` call
285-
@@ -199,11 +296,11 @@ impl Command {
303+
@@ -199,13 +296,13 @@ impl Command {
286304
//FIXME: Redox kernel does not support setgroups yet
287305
#[cfg(not(target_os = "redox"))]
288-
let _ = libc::setgroups(0, ptr::null());
306+
if libc::getuid() == 0 && self.get_groups().is_none() {
307+
- cvt(libc::setgroups(0, ptr::null()))?;
308+
+ cvt(self.unwrap_setgroups(0, ptr::null()))?;
309+
}
289310
- cvt(libc::setuid(u as uid_t))?;
290311
+ cvt(self.unwrap_setuid(u as uid_t))?;
291312
}
@@ -301,15 +322,15 @@ index f389c60615f..d5763b8aa1a 100644
301322
*sys::os::environ() = envp.as_ptr();
302323
}
303324
-
304-
- libc::execvp(self.get_program().as_ptr(), self.get_argv().as_ptr());
325+
- libc::execvp(self.get_program_cstr().as_ptr(), self.get_argv().as_ptr());
305326
- Err(io::Error::last_os_error())
306327
+ match self.execvp {
307328
+ Some(real_execvp) => {
308-
+ (real_execvp)(self.get_program().as_ptr(),
329+
+ (real_execvp)(self.get_program_cstr().as_ptr(),
309330
+ self.get_argv().as_ptr())
310331
+ },
311332
+ None => {
312-
+ libc::execvp(self.get_program().as_ptr(),
333+
+ libc::execvp(self.get_program_cstr().as_ptr(),
313334
+ self.get_argv().as_ptr())
314335
+ }
315336
+ };
@@ -325,23 +346,20 @@ index f389c60615f..d5763b8aa1a 100644
325346
Ok(None)
326347
}
327348

328-
@@ -283,10 +389,16 @@ impl Command {
349+
@@ -283,11 +389,14 @@ impl Command {
329350
use crate::mem::MaybeUninit;
330-
use crate::sys;
351+
use crate::sys::{self, cvt_nz};
331352

332-
+ let skip_spawnvp :bool = match getenv(&OsString::from("SB2_RUST_NO_SPAWNVP"))? {
333-
+ Some(_var) => true,
334-
+ None => false
335-
+ };
353+
+ let skip_spawnvp: bool = getenv(&OsString::from("SB2_RUST_NO_SPAWNVP"))?.is_some();
336354
+
337355
if self.get_gid().is_some()
338356
|| self.get_uid().is_some()
339-
|| self.env_saw_path()
357+
|| (self.env_saw_path() && !self.program_is_path())
340358
|| !self.get_closures().is_empty()
359+
|| self.get_groups().is_some()
341360
+ || skip_spawnvp
342361
{
343362
return Ok(None);
344363
}
345364
--
346365
2.20.1
347-

rust-1.44.0-i686-unknown-linux-gnu.tar.gz

Lines changed: 0 additions & 3 deletions
This file was deleted.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
version https://git-lfs.github.com/spec/v1
2+
oid sha256:c91f0431c8137a4e98e097ab47b49846820531aafb6e9c249b71b770771832e9
3+
size 353110704

0 commit comments

Comments
 (0)