• 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_debug) {
22    cflags_cc += [
23      "-O0",
24      "-g3",
25      "-ftrapv",
26      "-fstack-check",
27      "-DDEBUG",
28    ]
29    cflags_c += [
30      "-O0",
31      "-g3",
32      "-ftrapv",
33      "-fstack-check",
34      "-DDEBUG",
35    ]
36  } else {
37    cflags_cc += [
38      "-O2",
39      "-fno-strict-aliasing",
40      "-D_FORTIFY_SOURCE=2",
41    ]
42    cflags_c += [
43      "-O2",
44      "-fno-strict-aliasing",
45      "-D_FORTIFY_SOURCE=2",
46    ]
47  }
48
49  cflags_c += [
50    "-Wall",
51    "-fstack-protector-strong",
52    "-fvisibility=hidden",
53    "-pipe",
54    "-Werror",
55    "-Wdate-time",
56    "-Wfloat-equal",
57    "-Wno-c99-designator",
58  ]
59
60  cflags_cc += [
61    "-Wall",
62    "-fstack-protector-strong",
63    "-fvisibility=hidden",
64    "-pipe",
65    "-Wno-c99-designator",
66    "-Wno-range-loop-construct",
67    "-Werror",
68    "-Wdate-time",
69    "-Wfloat-equal",
70    "-DDYNAMICLANG",
71    "-DRC_NO_MMAP",
72    "-DMIR_FEATURE_FULL=1",
73    "-DMIR_JAVA=1",
74    "-std=c++17",
75    "-fno-common",
76  ]
77
78  if (current_os != "mingw") {
79    cflags_c += [
80      "-fPIC",
81      "-fPIE",
82    ]
83    cflags_cc += [ "-fPIC" ]
84  } else {
85    cflags_c += [ "-fno-stack-protector" ]
86    cflags_cc += [ "-fno-stack-protector" ]
87  }
88
89  if (TARGET == "aarch64") {
90    cflags_cc += [ "-DTARGAARCH64" ]
91  }
92
93  if (TARGET == "x86_64") {
94    cflags_cc += [ "-DTARGX86_64" ]
95  }
96
97  if (TARGET == "riscv64") {
98    cflags_cc += [ "-DTARGRISCV64" ]
99  }
100
101  if (TARGET == "ark") {
102    cflags_cc += [ "-DTARGARK" ]
103  }
104
105  if (HOST_ARCH == 64) {
106    ldflags = []
107    ldflags += [
108      "-rdynamic",
109      "-lpthread",
110      "-Wl,-z,relro",
111      "-Wl,-z,now",
112      "-Wl,-z,noexecstack",
113      "-pie",
114    ]
115  }
116}
117