Skip to content

Commit d9b0cbe

Browse files
author
Raphael Kubo da Costa
committed
chromium: Backport patch to stop including <sys/random.h>
This header might not exist on systems with very old glibc packages (e.g. CentOS 7) when building some host binaries that we need to run as part of the build. It turns out the header is not necessary at all, as Chromium uses LSS (Linux Syscall Support) to call the syscall and falls back to reading from /dev/urandom when that fails. Fixes #445. Signed-off-by: Raphael Kubo da Costa <raphael.kubo.da.costa@intel.com>
1 parent f132b68 commit d9b0cbe

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed

recipes-browser/chromium/chromium-gn.inc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ SRC_URI += " \
2222
file://0001-drop-dep-on-ui-ozone-for-building-without-ozone.patch \
2323
file://0001-Fix-local-build.patch \
2424
file://0001-IWYU-ui-CursorFactory-is-required-without-Ozone.patch \
25+
file://0001-RandBytes-Stop-including-sys-random.h-on-Linux.patch \
2526
"
2627

2728
SRC_URI_append_libc-musl = "\
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
Upstream-Status: Backport
2+
3+
Signed-off-by: Raphael Kubo da Costa <raphael.kubo.da.costa@intel.com>
4+
---
5+
From 80fb001240ed0c30f06eabc75a7899bf1067f515 Mon Sep 17 00:00:00 2001
6+
From: Raphael Kubo da Costa <raphael.kubo.da.costa@intel.com>
7+
Date: Wed, 27 Jan 2021 00:09:41 +0000
8+
Subject: [PATCH] RandBytes: Stop including sys/random.h on Linux.
9+
10+
We use the getrandom() syscall via LSS, so the header is not necessary.
11+
Additionally, this file might be built on host toolchains with very old
12+
packages (e.g. CentOS 7 cross-compiling to a more recent target) where the
13+
header might not exist (due to glibc and/or the Linux kernel version being
14+
too old), but where reading from /dev/urandom should still work.
15+
16+
Replicate the #ifdef checks from RandBytes() itself in the includes to make
17+
the file build in more systems.
18+
19+
Bug: 995996
20+
Change-Id: If75d706f51bed2f0239ec15ca82d2f58d1055b05
21+
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2644955
22+
Reviewed-by: Chris Palmer <palmer@chromium.org>
23+
Commit-Queue: Raphael Kubo da Costa <raphael.kubo.da.costa@intel.com>
24+
Cr-Commit-Position: refs/heads/master@{#847397}
25+
---
26+
base/rand_util_posix.cc | 6 ++----
27+
1 file changed, 2 insertions(+), 4 deletions(-)
28+
29+
diff --git a/base/rand_util_posix.cc b/base/rand_util_posix.cc
30+
index f121db7fcbdf..b58c37406214 100644
31+
--- a/base/rand_util_posix.cc
32+
+++ b/base/rand_util_posix.cc
33+
@@ -17,11 +17,9 @@
34+
#include "base/posix/eintr_wrapper.h"
35+
#include "build/build_config.h"
36+
37+
-#if defined(OS_LINUX) || defined(OS_CHROMEOS)
38+
+#if (defined(OS_LINUX) || defined(OS_CHROMEOS)) && !defined(OS_NACL)
39+
#include "third_party/lss/linux_syscall_support.h"
40+
-#endif
41+
-
42+
-#if !defined(OS_IOS) && !defined(OS_NACL)
43+
+#elif defined(OS_MAC)
44+
// TODO(crbug.com/995996): Waiting for this header to appear in the iOS SDK.
45+
// (See below.)
46+
#include <sys/random.h>
47+
--
48+
2.29.2
49+

0 commit comments

Comments
 (0)