Skip to content

Commit d2e4017

Browse files
authored
Add support for arm64 QNX toolchains. (flutter#168699)
The pattern is similar to the recently added WASM (and previously NACL) toolchains. The major change is the engines use of functions that became constexpr in C++26 (such as [sqrt](https://en.cppreference.com/w/cpp/numeric/math/sqrt)) as if they were already constexpr. I have attempted to keep the linkage the same and am investigating how to enable this form of checking with our own toolchain.
1 parent f61ef2d commit d2e4017

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+320
-160
lines changed

engine/src/build/config/BUILDCONFIG.gn

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ if (current_os == "win") {
202202
is_posix = false
203203
is_win = true
204204
is_wasm = false
205+
is_qnx = false
205206
} else if (current_os == "mac") {
206207
is_android = false
207208
is_chromeos = false
@@ -213,6 +214,7 @@ if (current_os == "win") {
213214
is_posix = true
214215
is_win = false
215216
is_wasm = false
217+
is_qnx = false
216218
} else if (current_os == "android") {
217219
is_android = true
218220
is_chromeos = false
@@ -224,6 +226,7 @@ if (current_os == "win") {
224226
is_posix = true
225227
is_win = false
226228
is_wasm = false
229+
is_qnx = false
227230
} else if (current_os == "chromeos") {
228231
is_android = false
229232
is_chromeos = true
@@ -235,6 +238,7 @@ if (current_os == "win") {
235238
is_posix = true
236239
is_win = false
237240
is_wasm = false
241+
is_qnx = false
238242
} else if (current_os == "nacl") {
239243
# current_os == "nacl" will be passed by the nacl toolchain definition.
240244
# It is not set by default or on the command line. We treat is as a
@@ -249,6 +253,7 @@ if (current_os == "win") {
249253
is_posix = true
250254
is_win = false
251255
is_wasm = false
256+
is_qnx = false
252257
} else if (current_os == "ios") {
253258
is_android = false
254259
is_chromeos = false
@@ -260,6 +265,7 @@ if (current_os == "win") {
260265
is_posix = true
261266
is_win = false
262267
is_wasm = false
268+
is_qnx = false
263269
} else if (current_os == "linux") {
264270
is_android = false
265271
is_chromeos = false
@@ -271,6 +277,7 @@ if (current_os == "win") {
271277
is_posix = true
272278
is_win = false
273279
is_wasm = false
280+
is_qnx = false
274281
} else if (current_os == "fuchsia" || target_os == "fuchsia") {
275282
is_android = false
276283
is_chromeos = false
@@ -282,6 +289,7 @@ if (current_os == "win") {
282289
is_posix = true
283290
is_win = false
284291
is_wasm = false
292+
is_qnx = false
285293
} else if (current_os == "wasm") {
286294
is_android = false
287295
is_chromeos = false
@@ -293,6 +301,19 @@ if (current_os == "win") {
293301
is_posix = false
294302
is_win = false
295303
is_wasm = true
304+
is_qnx = false
305+
} else if (current_os == "qnx") {
306+
is_android = false
307+
is_chromeos = false
308+
is_fuchsia = false
309+
is_fuchsia_host = false
310+
is_ios = false
311+
is_linux = false
312+
is_mac = false
313+
is_posix = false
314+
is_win = false
315+
is_wasm = false
316+
is_qnx = true
296317
}
297318

298319
is_apple = is_ios || is_mac
@@ -598,6 +619,9 @@ if (custom_toolchain != "") {
598619
clang_win_version = ""
599620
host_toolchain = "//build/toolchain/wasm"
600621
set_default_toolchain("//build/toolchain/wasm")
622+
} else if (is_qnx) {
623+
host_toolchain = "//build/toolchain/linux:clang_$host_cpu"
624+
set_default_toolchain("//build/toolchain/qnx")
601625
} else {
602626
assert(false, "Toolchain not set because of unknown platform.")
603627
}

engine/src/build/config/compiler/BUILD.gn

Lines changed: 57 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,14 @@ config("compiler") {
7676
configs += [ "//build/config/darwin:compiler" ]
7777
}
7878

79+
if (is_qnx) {
80+
defines += [
81+
"_XOPEN_SOURCE=700",
82+
"_QNX_SOURCE",
83+
"SKNX_NO_SIMD",
84+
]
85+
}
86+
7987
# In general, Windows is totally different, but all the other builds share
8088
# some common GCC configuration. This section sets up Windows and the common
8189
# GCC flags, and then we handle the other non-Windows platforms specifically
@@ -104,7 +112,7 @@ config("compiler") {
104112
# Stack protection.
105113
if (is_mac) {
106114
cflags += [ "-fstack-protector-all" ]
107-
} else if (!is_ios && !is_wasm) {
115+
} else if (!is_ios && !is_wasm && !is_qnx) {
108116
cflags += [
109117
"-fstack-protector",
110118
# 8 is the default, but make this explicit here so that we don't have to
@@ -346,12 +354,17 @@ config("compiler") {
346354

347355
# Linux/Android common flags setup.
348356
# ---------------------------------
349-
if (is_linux || is_android) {
357+
if (is_linux || is_android || is_qnx) {
350358
cflags += [
351359
"-fPIC",
352-
"-pipe", # Use pipes for communicating between sub-processes. Faster.
353360
]
354361

362+
if (!is_qnx) {
363+
cflags += [
364+
"-pipe", # Use pipes for communicating between sub-processes. Faster.
365+
]
366+
}
367+
355368
ldflags += [
356369
"-fPIC",
357370
"-Wl,-z,noexecstack",
@@ -363,6 +376,20 @@ config("compiler") {
363376
}
364377
}
365378

379+
if (is_qnx) {
380+
qnx_arch_flags = []
381+
if (target_cpu == "arm64") {
382+
qnx_arch_flags += [
383+
"-V",
384+
"gcc_ntoaarch64le"
385+
]
386+
} else {
387+
assert(false, "Unknown QNX architecture")
388+
}
389+
cflags += qnx_arch_flags
390+
ldflags += qnx_arch_flags
391+
}
392+
366393
# Linux-specific compiler flags setup.
367394
# ------------------------------------
368395
if (is_linux) {
@@ -619,6 +646,9 @@ config("runtime_library") {
619646

620647
default_warning_flags = []
621648
default_warning_flags_cc = []
649+
if (is_qnx) {
650+
default_warning_flags_cc += [ "-fpermissive" ]
651+
}
622652
if (is_win) {
623653
default_warning_flags += [
624654
# Permanent.
@@ -659,13 +689,18 @@ if (is_win) {
659689
default_warning_flags += [
660690
# Enables.
661691
"-Wendif-labels", # Weird old-style text after an #endif.
662-
"-Werror", # Warnings as errors.
663692

664693
# Disables.
665694
"-Wno-missing-field-initializers", # "struct foo f = {0};"
666695
"-Wno-unused-parameter", # Unused function parameters.
667696
]
668697

698+
if (!is_qnx) {
699+
default_warning_flags += [
700+
"-Werror", # Warnings as errors.
701+
]
702+
}
703+
669704
if (is_wasm) {
670705
default_warning_flags += [
671706
# zlib needs this
@@ -680,27 +715,32 @@ if (is_win) {
680715
default_warning_flags += [
681716
"-Wno-unused-but-set-parameter",
682717
"-Wno-unused-but-set-variable",
683-
"-Wno-implicit-int-float-conversion",
684-
"-Wno-deprecated-copy",
685718

686719
# Needed for compiling Skia with clang-12
687720
"-Wno-psabi",
688721
]
689722

690-
if (!is_android) {
723+
if (is_clang) {
724+
default_warning_flags += [
725+
"-Wno-implicit-int-float-conversion",
726+
"-Wno-deprecated-copy",
727+
]
728+
}
729+
730+
if (!is_android && is_clang) {
691731
default_warning_flags += [
692732
# Needed for nlohmann/json.
693733
"-Wno-deprecated-literal-operator",
694734
]
695735
}
696736

697-
if (!is_wasm) {
737+
if (!is_wasm && is_clang) {
698738
default_warning_flags += [
699739
# Unqualified std::move is pretty common.
700740
"-Wno-unqualified-std-cast-call",
701741
]
702742
}
703-
if (!is_fuchsia) {
743+
if (!is_fuchsia && is_clang) {
704744
default_warning_flags += [
705745
"-Wno-non-c-typedef-for-linkage",
706746
"-Wno-range-loop-construct",
@@ -728,10 +768,14 @@ config("chromium_code") {
728768
if (is_win || is_wasm) {
729769
cflags = []
730770
} else {
731-
cflags = [
732-
"-Wall",
733-
"-Wextra",
734-
]
771+
cflags = []
772+
773+
if (!is_qnx) {
774+
cflags = [
775+
"-Wall",
776+
"-Wextra",
777+
]
778+
}
735779

736780
# In Chromium code, we define __STDC_foo_MACROS in order to get the
737781
# C99 macros on Mac and Linux.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Copyright (c) 2013 The Chromium 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+
import("//build/toolchain/gcc_toolchain.gni")
6+
7+
gcc_toolchain("qnx") {
8+
asm = "qcc"
9+
cc = "qcc"
10+
cxx = "q++"
11+
12+
readelf = "readelf"
13+
nm = "ntoaarch64-nm"
14+
ar = "ntoaarch64-ar"
15+
ld = "q++"
16+
strip = "ntoaarch64-strip"
17+
18+
toolchain_cpu = "arm64"
19+
toolchain_os = "linux"
20+
is_clang = false
21+
}
22+

engine/src/flutter/BUILD.gn

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,15 @@ group("flutter") {
7474
testonly = true
7575

7676
# Compile the engine.
77-
public_deps = [
78-
":unittests",
79-
"//flutter/shell/platform/embedder:flutter_engine",
80-
"//flutter/sky",
81-
]
77+
public_deps = []
78+
79+
if (!is_qnx) {
80+
public_deps = [
81+
":unittests",
82+
"//flutter/shell/platform/embedder:flutter_engine",
83+
"//flutter/sky",
84+
]
85+
}
8286

8387
# Ensure the example for a sample embedder compiles.
8488
if (build_embedder_examples) {
@@ -93,7 +97,7 @@ group("flutter") {
9397
}
9498

9599
# If enabled, compile the SDK / snapshot.
96-
if (!is_fuchsia) {
100+
if (!is_fuchsia && !is_qnx) {
97101
public_deps += [ "//flutter/lib/snapshot:generate_snapshot_bins" ]
98102

99103
if (build_engine_artifacts) {
@@ -154,7 +158,7 @@ group("flutter") {
154158
}
155159

156160
# Build the standalone Impeller library.
157-
if (is_mac || is_linux || is_win || is_android) {
161+
if (is_mac || is_linux || is_win || is_android || is_qnx) {
158162
public_deps += [ "//flutter/impeller/toolkit/interop:sdk" ]
159163
}
160164

engine/src/flutter/ci/licenses_golden/licenses_flutter

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51089,6 +51089,7 @@ ORIGIN: ../../../flutter/fml/platform/posix/native_library_posix.cc + ../../../f
5108951089
ORIGIN: ../../../flutter/fml/platform/posix/paths_posix.cc + ../../../flutter/LICENSE
5109051090
ORIGIN: ../../../flutter/fml/platform/posix/posix_wrappers_posix.cc + ../../../flutter/LICENSE
5109151091
ORIGIN: ../../../flutter/fml/platform/posix/process_posix.cc + ../../../flutter/LICENSE
51092+
ORIGIN: ../../../flutter/fml/platform/qnx/paths_qnx.cc + ../../../flutter/LICENSE
5109251093
ORIGIN: ../../../flutter/fml/platform/win/command_line_win.cc + ../../../flutter/LICENSE
5109351094
ORIGIN: ../../../flutter/fml/platform/win/errors_win.cc + ../../../flutter/LICENSE
5109451095
ORIGIN: ../../../flutter/fml/platform/win/errors_win.h + ../../../flutter/LICENSE
@@ -54109,6 +54110,7 @@ FILE: ../../../flutter/fml/platform/posix/native_library_posix.cc
5410954110
FILE: ../../../flutter/fml/platform/posix/paths_posix.cc
5411054111
FILE: ../../../flutter/fml/platform/posix/posix_wrappers_posix.cc
5411154112
FILE: ../../../flutter/fml/platform/posix/process_posix.cc
54113+
FILE: ../../../flutter/fml/platform/qnx/paths_qnx.cc
5411254114
FILE: ../../../flutter/fml/platform/win/command_line_win.cc
5411354115
FILE: ../../../flutter/fml/platform/win/errors_win.cc
5411454116
FILE: ../../../flutter/fml/platform/win/errors_win.h

engine/src/flutter/display_list/BUILD.gn

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -280,36 +280,38 @@ if (enable_unittests) {
280280
}
281281
}
282282

283-
source_set("display_list_benchmarks_source") {
284-
testonly = true
283+
if (enable_unittests) {
284+
source_set("display_list_benchmarks_source") {
285+
testonly = true
285286

286-
sources = [
287-
"benchmarking/dl_benchmarks.cc",
288-
"benchmarking/dl_benchmarks.h",
289-
]
287+
sources = [
288+
"benchmarking/dl_benchmarks.cc",
289+
"benchmarking/dl_benchmarks.h",
290+
]
290291

291-
deps = [
292-
":display_list",
293-
":display_list_fixtures",
294-
"$dart_src/runtime:libdart_jit", # for tracing
295-
"//flutter/benchmarking",
296-
"//flutter/common/graphics",
297-
"//flutter/display_list/testing:display_list_surface_provider",
298-
"//flutter/display_list/testing:display_list_testing",
299-
"//flutter/fml",
300-
"//flutter/skia",
301-
"//flutter/testing:skia",
302-
"//flutter/testing:testing_lib",
303-
]
304-
}
292+
deps = [
293+
":display_list",
294+
":display_list_fixtures",
295+
"$dart_src/runtime:libdart_jit", # for tracing
296+
"//flutter/benchmarking",
297+
"//flutter/common/graphics",
298+
"//flutter/display_list/testing:display_list_surface_provider",
299+
"//flutter/display_list/testing:display_list_testing",
300+
"//flutter/fml",
301+
"//flutter/skia",
302+
"//flutter/testing:skia",
303+
"//flutter/testing:testing_lib",
304+
]
305+
}
305306

306-
executable("display_list_benchmarks") {
307-
testonly = true
307+
executable("display_list_benchmarks") {
308+
testonly = true
308309

309-
deps = [ ":display_list_benchmarks_source" ]
310+
deps = [ ":display_list_benchmarks_source" ]
311+
}
310312
}
311313

312-
if (is_ios) {
314+
if (is_ios && enable_unittests) {
313315
shared_library("ios_display_list_benchmarks") {
314316
testonly = true
315317
visibility = [ ":*" ]

engine/src/flutter/display_list/benchmarking/dl_complexity_helper.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include "flutter/display_list/benchmarking/dl_complexity.h"
99
#include "flutter/display_list/dl_blend_mode.h"
1010
#include "flutter/display_list/dl_op_receiver.h"
11+
#include "flutter/display_list/geometry/dl_path.h"
1112
#include "flutter/display_list/utils/dl_receiver_utils.h"
1213

1314
namespace flutter {

0 commit comments

Comments
 (0)