1e509ee18Sopenharmony_ci# Copyright (c) 2023 Huawei Device Co., Ltd.
2e509ee18Sopenharmony_ci# Licensed under the Apache License, Version 2.0 (the "License");
3e509ee18Sopenharmony_ci# you may not use this file except in compliance with the License.
4e509ee18Sopenharmony_ci# You may obtain a copy of the License at
5e509ee18Sopenharmony_ci#
6e509ee18Sopenharmony_ci# http://www.apache.org/licenses/LICENSE-2.0
7e509ee18Sopenharmony_ci#
8e509ee18Sopenharmony_ci# Unless required by applicable law or agreed to in writing, software
9e509ee18Sopenharmony_ci# distributed under the License is distributed on an "AS IS" BASIS,
10e509ee18Sopenharmony_ci# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11e509ee18Sopenharmony_ci# See the License for the specific language governing permissions and
12e509ee18Sopenharmony_ci# limitations under the License.
13e509ee18Sopenharmony_ci
14e509ee18Sopenharmony_ciimport("$build_root/config/compiler/compiler.gni")
15e509ee18Sopenharmony_ciimport("$build_root/config/ohos/config.gni")
16e509ee18Sopenharmony_ciimport("$build_root/third_party_gn/musl/musl_config.gni")
17e509ee18Sopenharmony_ci
18e509ee18Sopenharmony_ciassert(is_ohos)
19e509ee18Sopenharmony_ci
20e509ee18Sopenharmony_ciconfig("compiler") {
21e509ee18Sopenharmony_ci  cflags = [
22e509ee18Sopenharmony_ci    "-ffunction-sections",
23e509ee18Sopenharmony_ci    "-fno-short-enums",
24e509ee18Sopenharmony_ci  ]
25e509ee18Sopenharmony_ci  defines = [ "HAVE_SYS_UIO_H" ]
26e509ee18Sopenharmony_ci
27e509ee18Sopenharmony_ci  cflags += [ "--target=$abi_target" ]
28e509ee18Sopenharmony_ci  include_dirs = [ "${musl_sysroot}/usr/include/${abi_target}" ]
29e509ee18Sopenharmony_ci
30e509ee18Sopenharmony_ci  ldflags = [ "--target=$abi_target" ]
31e509ee18Sopenharmony_ci  asmflags = cflags
32e509ee18Sopenharmony_ci}
33e509ee18Sopenharmony_ci
34e509ee18Sopenharmony_ciconfig("runtime_config") {
35e509ee18Sopenharmony_ci  cflags_cc = []
36e509ee18Sopenharmony_ci
37e509ee18Sopenharmony_ci  defines = [
38e509ee18Sopenharmony_ci    "__MUSL__",
39e509ee18Sopenharmony_ci    "_LIBCPP_HAS_MUSL_LIBC",
40e509ee18Sopenharmony_ci    "__BUILD_LINUX_WITH_CLANG",
41e509ee18Sopenharmony_ci  ]
42e509ee18Sopenharmony_ci  ldflags = [ "-nostdlib" ]
43e509ee18Sopenharmony_ci
44e509ee18Sopenharmony_ci  libs = [
45e509ee18Sopenharmony_ci    rebase_path(libclang_rt_file),
46e509ee18Sopenharmony_ci    "c",
47e509ee18Sopenharmony_ci    rebase_path(libcxxabi_file),
48e509ee18Sopenharmony_ci  ]
49e509ee18Sopenharmony_ci
50e509ee18Sopenharmony_ci  if ((current_cpu == "arm" && arm_version == 6) || current_cpu == "mipsel") {
51e509ee18Sopenharmony_ci    libs += [ "atomic" ]
52e509ee18Sopenharmony_ci    libs_out_dir = "usr/lib/${musl_target_triple}"
53e509ee18Sopenharmony_ci    output_dir = "${target_out_dir}/${libs_out_dir}"
54e509ee18Sopenharmony_ci    atomic_path = rebase_path("${output_dir}")
55e509ee18Sopenharmony_ci    ldflags += [ "-L${atomic_path}" ]
56e509ee18Sopenharmony_ci  }
57e509ee18Sopenharmony_ci
58e509ee18Sopenharmony_ci  ldflags += [ "-Wl,--warn-shared-textrel" ]
59e509ee18Sopenharmony_ci}
60e509ee18Sopenharmony_ci
61e509ee18Sopenharmony_ciconfig("executable_config") {
62e509ee18Sopenharmony_ci  cflags = [
63e509ee18Sopenharmony_ci    "-fPIE",
64e509ee18Sopenharmony_ci    "-fPIC",
65e509ee18Sopenharmony_ci  ]
66e509ee18Sopenharmony_ci  asmflags = [ "-fPIE" ]
67e509ee18Sopenharmony_ci}
68