• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 2023 Huawei Device Co., Ltd.
2# Licensed under the Apache License, Version 2.0 (the "License");
3# you may not use this file except in compliance with the License.
4# You may obtain a copy of the License at
5#
6#     http://www.apache.org/licenses/LICENSE-2.0
7#
8# Unless required by applicable law or agreed to in writing, software
9# distributed under the License is distributed on an "AS IS" BASIS,
10# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11# See the License for the specific language governing permissions and
12# limitations under the License.
13
14import("//arkcompiler/ets_runtime/js_runtime_config.gni")
15
16config("mapleallcompilecfg") {
17  cflags = []
18  cflags_cc = [ "-frtti" ]
19  cflags_c = []
20
21  if (is_fastverify) {
22    cflags_cc += [
23      "-O3",
24      "-ggdb3",
25      "-fno-omit-frame-pointer",
26      "-D_GLIBCXX_ASSERTIONS",
27    ]
28    cflags_c += [
29      "-O3",
30      "-ggdb3",
31      "-fno-omit-frame-pointer",
32      "-D_GLIBCXX_ASSERTIONS",
33    ]
34  } else if (is_debug) {
35    cflags_cc += [
36      "-O0",
37      "-g3",
38      "-ftrapv",
39      "-fstack-check",
40      "-DDEBUG",
41    ]
42    cflags_c += [
43      "-O0",
44      "-g3",
45      "-ftrapv",
46      "-fstack-check",
47      "-DDEBUG",
48    ]
49  } else {
50    cflags_cc += [
51      "-O2",
52      "-fno-strict-aliasing",
53      "-D_FORTIFY_SOURCE=2",
54    ]
55    cflags_c += [
56      "-O2",
57      "-fno-strict-aliasing",
58      "-D_FORTIFY_SOURCE=2",
59    ]
60  }
61
62  cflags_c += [
63    "-Wall",
64    "-fstack-protector-strong",
65    "-fvisibility=hidden",
66    "-pipe",
67    "-Werror",
68    "-Wdate-time",
69    "-Wfloat-equal",
70    "-Wno-c99-designator",
71  ]
72
73  cflags_cc += [
74    "-Wall",
75    "-fstack-protector-strong",
76    "-fvisibility=hidden",
77    "-pipe",
78    "-Wno-c99-designator",
79    "-Wno-range-loop-construct",
80    "-Werror",
81    "-Wdate-time",
82    "-Wfloat-equal",
83    "-DDYNAMICLANG",
84    "-DRC_NO_MMAP",
85    "-DMIR_FEATURE_FULL=1",
86    "-std=c++17",
87    "-fno-common",
88  ]
89
90  if (current_os != "mingw") {
91    cflags_c += [
92      "-fPIC",
93      "-fPIE",
94    ]
95    cflags_cc += [ "-fPIC" ]
96  } else {
97    cflags_c += [ "-fno-stack-protector" ]
98    cflags_cc += [ "-fno-stack-protector" ]
99  }
100
101  if (TARGET == "aarch64" || TARGET == "x86_64") {
102    cflags_cc += [ "-DTARGX86_64" ]
103    cflags_cc += [ "-DTARGAARCH64" ]
104  }
105
106  # Setting up IS_RELEASE_VERSION if compiling as release version
107  if (build_variant == "user") {
108    cflags_c += [ "-DIS_RELEASE_VERSION" ]
109    cflags_cc += [ "-DIS_RELEASE_VERSION" ]
110  }
111
112  if (TARGET == "riscv64") {
113    cflags_cc += [ "-DTARGRISCV64" ]
114  }
115
116  if (TARGET == "ark") {
117    cflags_cc += [ "-DTARGARK" ]
118  }
119
120  if (HOST_ARCH == 64) {
121    ldflags = []
122    ldflags += [
123      "-rdynamic",
124      "-lpthread",
125      "-Wl,-z,relro",
126      "-Wl,-z,now",
127      "-Wl,-z,noexecstack",
128      "-pie",
129    ]
130  }
131
132  if (enable_litecg_emit) {
133    defines = [ "ARK_LITECG_DEBUG" ]
134  }
135}
136