• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#
2# Copyright (c) 2024 Huawei Device Co., Ltd.
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#     http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14#
15
16import("//build/ohos.gni")
17import("FreeBSD.gni")
18
19config("free_bsd_config") {
20  include_dirs = [ "//third_party/FreeBSD" ]
21}
22
23ohos_static_library("libfreebsd_static") {
24  branch_protector_ret = "pac_ret"
25  output_name = "libfreebsd_static"
26  sources = [ "lib/libc/gen/fts.c" ]
27  if (use_libfuzzer && !is_mac) {
28    cflags = []
29  } else {
30    cflags = [
31      "-fno-emulated-tls",
32      "-fno-lto",
33      "-fno-whole-program-vtables",
34    ]
35
36    cflags += [
37      "-D_GNU_SOURCE",
38      "-DHAVE_REALLOCARRAY",
39      "-w",
40    ]
41  }
42  public_configs = [ ":free_bsd_config" ]
43}
44
45static_library("ld128_static") {
46  sources = [
47    "lib/msun/ld128/e_lgammal_r.c",
48    "lib/msun/ld128/e_powl.c",
49    "lib/msun/ld128/k_cosl.c",
50    "lib/msun/ld128/k_sinl.c",
51    "lib/msun/ld128/s_erfl.c",
52    "lib/msun/ld128/s_expl.c",
53    "lib/msun/ld128/s_logl.c",
54    "lib/msun/src/e_acoshl.c",
55    "lib/msun/src/e_coshl.c",
56    "lib/msun/src/e_lgammal.c",
57    "lib/msun/src/e_sinhl.c",
58    "lib/msun/src/s_asinhl.c",
59    "lib/msun/src/s_tanhl.c",
60  ]
61
62  defines = [ "LD128_ENABLE" ]
63  include_dirs = [
64    "//third_party/FreeBSD/lib/msun/ld128",
65    "//third_party/FreeBSD/lib/msun/src",
66    "//third_party/FreeBSD/lib/libc/include",
67    "//third_party/FreeBSD/sys",
68  ]
69
70  configs -= build_inherited_configs
71  configs += [ "//build/config/components/musl:soft_musl_config" ]
72  cflags = [
73    "-mllvm",
74    "-instcombine-max-iterations=0",
75    "-ffp-contract=fast",
76    "-O3",
77    "-fPIC",
78    "-fstack-protector-strong",
79  ]
80}
81
82freebsd_files = [
83  "contrib/gdtoa/strtod.c",
84  "contrib/gdtoa/gethex.c",
85  "contrib/gdtoa/smisc.c",
86  "contrib/gdtoa/misc.c",
87  "contrib/gdtoa/strtord.c",
88  "contrib/gdtoa/hexnan.c",
89  "contrib/gdtoa/gmisc.c",
90  "contrib/gdtoa/hd_init.c",
91  "contrib/gdtoa/strtodg.c",
92  "contrib/gdtoa/ulp.c",
93  "contrib/gdtoa/strtof.c",
94  "contrib/gdtoa/sum.c",
95  "lib/libc/gdtoa/glue.c",
96  "lib/libc/stdio/parsefloat.c",
97]
98
99static_library("libc_static") {
100  sources = [
101    "contrib/tcp_wrappers/strcasecmp.c",
102    "lib/libc/gen/arc4random.c",
103    "lib/libc/gen/arc4random_uniform.c",
104    "lib/libc/stdlib/qsort.c",
105    "lib/libc/stdlib/strtoimax.c",
106    "lib/libc/stdlib/strtoul.c",
107    "lib/libc/stdlib/strtoumax.c",
108  ]
109  if (!is_llvm_build) {
110    sources += [ "contrib/libexecinfo/unwind.c" ]
111  }
112  if (musl_arch == "arm") {
113    sources += freebsd_files
114  } else if (musl_arch == "aarch64") {
115    sources += [ "lib/msun/src/s_frexpl.c" ]
116    if (!defined(ARM_FEATURE_SVE) && !defined(ARM_FEATURE_MTE)) {
117      sources += freebsd_files
118    }
119  } else {
120    not_needed([ "freebsd_files" ])
121  }
122  cflags = [
123    "-O3",
124    "-fPIC",
125    "-fstack-protector-strong",
126  ]
127
128  if (!(use_libfuzzer || is_mac || is_asan || use_clang_coverage)) {
129    cflags += [ "-flto" ]
130  }
131  if (!defined(include_dirs)) {
132    include_dirs = []
133  }
134  if (musl_arch == "aarch64") {
135    include_dirs += [ "//third_party/FreeBSD/lib/libc/aarch64" ]
136  } else if (musl_arch == "arm") {
137    include_dirs += [ "//third_party/FreeBSD/lib/libc/arm" ]
138  }
139  include_dirs += [ "//third_party/FreeBSD/lib/libc/include" ]
140  include_dirs += [ "//third_party/FreeBSD/contrib/libexecinfo" ]
141  include_dirs += [ "//third_party/FreeBSD/crypto/openssh/openbsd-compat" ]
142
143  configs -= build_inherited_configs
144  configs += [ "//build/config/components/musl:soft_musl_config" ]
145}
146