Skip to content

Commit 9181a10

Browse files
committed
[Tizen] Add syscall compat header for custom Linux toolchains
Inject a small compat header into the custom cross-toolchain command line so Linux targets built with Tizen sysroots still see __NR_getrandom even when the sysroot headers do not export it. This keeps third_party/dart untouched and fixes builds across common Tizen architectures: - x86: 355 - x64: 318 - arm: 384 - arm64: 278
1 parent 51446ac commit 9181a10

2 files changed

Lines changed: 38 additions & 3 deletions

File tree

engine/src/build/toolchain/custom/BUILD.gn

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ toolchain("custom") {
2020

2121
target_triple_flags = "--target=${custom_target_triple}"
2222
sysroot_flags = "--sysroot ${custom_sysroot}"
23+
syscall_compat_header =
24+
rebase_path("//build/toolchain/custom/tizen_syscall_compat.h", root_build_dir)
25+
syscall_compat_flags = "-include ${syscall_compat_header}"
2326

2427
custom_lib_flags = "-L${custom_toolchain}/lib"
2528

@@ -29,7 +32,7 @@ toolchain("custom") {
2932

3033
tool("cc") {
3134
depfile = "{{output}}.d"
32-
command = "$cc -MD -MF $depfile $target_triple_flags $sysroot_flags {{defines}} {{include_dirs}} {{cflags}} {{cflags_c}} -c {{source}} -o {{output}}"
35+
command = "$cc -MD -MF $depfile $target_triple_flags $sysroot_flags $syscall_compat_flags {{defines}} {{include_dirs}} {{cflags}} {{cflags_c}} -c {{source}} -o {{output}}"
3336
depsformat = "gcc"
3437
description = "CC {{output}}"
3538
outputs =
@@ -38,7 +41,7 @@ toolchain("custom") {
3841

3942
tool("cxx") {
4043
depfile = "{{output}}.d"
41-
command = "$cxx -MD -MF $depfile $target_triple_flags $sysroot_flags {{defines}} {{include_dirs}} {{cflags}} {{cflags_cc}} -c {{source}} -o {{output}}"
44+
command = "$cxx -MD -MF $depfile $target_triple_flags $sysroot_flags $syscall_compat_flags {{defines}} {{include_dirs}} {{cflags}} {{cflags_cc}} -c {{source}} -o {{output}}"
4245
depsformat = "gcc"
4346
description = "CXX {{output}}"
4447
outputs =
@@ -47,7 +50,7 @@ toolchain("custom") {
4750

4851
tool("asm") {
4952
depfile = "{{output}}.d"
50-
command = "$cc -MD -MF $depfile $target_triple_flags $sysroot_flags {{defines}} {{include_dirs}} {{asmflags}} {{cflags}} {{cflags_c}} -c {{source}} -o {{output}}"
53+
command = "$cc -MD -MF $depfile $target_triple_flags $sysroot_flags $syscall_compat_flags {{defines}} {{include_dirs}} {{asmflags}} {{cflags}} {{cflags_c}} -c {{source}} -o {{output}}"
5154
depsformat = "gcc"
5255
description = "ASM {{output}}"
5356
outputs =
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// Copyright 2026 The Flutter Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
#ifndef BUILD_TOOLCHAIN_CUSTOM_TIZEN_SYSCALL_COMPAT_H_
6+
#define BUILD_TOOLCHAIN_CUSTOM_TIZEN_SYSCALL_COMPAT_H_
7+
8+
// Some Tizen cross-compilation sysroots do not expose __NR_getrandom even
9+
// though the target Linux ABI supports the syscall. Dart's crypto_linux.cc
10+
// references the syscall number directly, so provide the missing arch-specific
11+
// values for custom Linux toolchains without modifying third_party sources.
12+
#if defined(__linux__)
13+
14+
#if defined(__i386__) && !defined(__NR_getrandom)
15+
#define __NR_getrandom 355
16+
#endif
17+
18+
#if defined(__x86_64__) && !defined(__NR_getrandom)
19+
#define __NR_getrandom 318
20+
#endif
21+
22+
#if defined(__arm__) && !defined(__NR_getrandom)
23+
#define __NR_getrandom 384
24+
#endif
25+
26+
#if defined(__aarch64__) && !defined(__NR_getrandom)
27+
#define __NR_getrandom 278
28+
#endif
29+
30+
#endif // defined(__linux__)
31+
32+
#endif // BUILD_TOOLCHAIN_CUSTOM_TIZEN_SYSCALL_COMPAT_H_

0 commit comments

Comments
 (0)