• 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("$build_root/config/compiler/compiler.gni")
15import("$build_root/config/ohos/config.gni")
16import("$build_root/third_party_gn/musl/musl_config.gni")
17
18assert(is_ohos)
19
20config("compiler") {
21  cflags = [
22    "-ffunction-sections",
23    "-fno-short-enums",
24  ]
25  defines = [ "HAVE_SYS_UIO_H" ]
26
27  cflags += [ "--target=$abi_target" ]
28  include_dirs = [ "${musl_sysroot}/usr/include/${abi_target}" ]
29
30  ldflags = [ "--target=$abi_target" ]
31  asmflags = cflags
32}
33
34config("runtime_config") {
35  cflags_cc = []
36
37  defines = [
38    "__MUSL__",
39    "_LIBCPP_HAS_MUSL_LIBC",
40    "__BUILD_LINUX_WITH_CLANG",
41  ]
42  ldflags = [ "-nostdlib" ]
43
44  libs = [
45    rebase_path(libclang_rt_file),
46    "c",
47    rebase_path(libcxxabi_file),
48  ]
49
50  if ((current_cpu == "arm" && arm_version == 6) || current_cpu == "mipsel") {
51    libs += [ "atomic" ]
52    libs_out_dir = "usr/lib/${musl_target_triple}"
53    output_dir = "${target_out_dir}/${libs_out_dir}"
54    atomic_path = rebase_path("${output_dir}")
55    ldflags += [ "-L${atomic_path}" ]
56  }
57
58  ldflags += [ "-Wl,--warn-shared-textrel" ]
59}
60
61config("executable_config") {
62  cflags = [
63    "-fPIE",
64    "-fPIC",
65  ]
66  asmflags = [ "-fPIE" ]
67}
68