| # Copyright 2019 The Fuchsia Authors. All rights reserved. |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| |
| import("//build/zircon/migrated_targets.gni") |
| import("//zircon/system/ulib/c/libc.gni") |
| |
| group("string") { |
| deps = [ |
| ":strerror_r", |
| ":strsignal", |
| ":strverscmp", |
| ":wcs", |
| ":wmem", |
| ] |
| if (!use_llvm_libc_string_functions) { |
| deps += [ |
| ":bsd", |
| ":extmem", |
| ":extstr", |
| ":stdmem", |
| ":stdstr", |
| ] |
| } |
| } |
| |
| # These are the functions the compiler produces implicit calls to. |
| source_set("compiler") { |
| visibility = [ ":*" ] |
| |
| deps = [ "//zircon/third_party/ulib/musl:musl_internal" ] |
| if (current_cpu == "arm64") { |
| # These use '#include "third_party/lib/cortex-strings/src/aarch64/..."'. |
| include_dirs = [ "//zircon/" ] |
| sources = [ |
| "aarch64/memcpy.S", |
| "aarch64/memset.S", |
| ] |
| } else if (current_cpu == "x64") { |
| sources = [ |
| "x86_64/memcpy.S", |
| "x86_64/memset.S", |
| ] |
| } else { |
| sources = [ |
| "memcpy.c", |
| "memset.c", |
| ] |
| } |
| |
| if (zircon_toolchain != false) { |
| # When compiling for libc, the C functions should be exported, so don't |
| # compile with default hidden visibility. The functions aren't annotated |
| # for export so that they can be compiled in non-libc contexts where their |
| # definitions need to have hidden visibility for hermetic linking. |
| configs -= [ "//build/config:symbol_visibility_hidden" ] |
| } else { |
| # When not compiling for libc, the C functions get the default hidden |
| # visibility like all other code. But the assembly sources need -DHIDDEN |
| # to tell them to use hidden visibility. |
| defines = [ "HIDDEN=1" ] |
| } |
| } |
| |
| source_set("stdmem") { |
| visibility = [ ":*" ] |
| |
| deps = [ |
| ":compiler", |
| "//zircon/third_party/ulib/musl:musl_internal", |
| ] |
| sources = [ "memrchr.c" ] |
| if (current_cpu == "arm64") { |
| # These use '#include "third_party/lib/cortex-strings/src/aarch64/..."'. |
| include_dirs = [ "//zircon/" ] |
| sources += [ |
| "aarch64/memchr.S", |
| "aarch64/memcmp.S", |
| "aarch64/memmove.S", |
| ] |
| } else { |
| sources += [ |
| "memchr.c", |
| "memcmp.c", |
| ] |
| if (current_cpu == "x64") { |
| sources += [ "x86_64/memmove.S" ] |
| } else { |
| sources += [ "memmove.c" ] |
| } |
| } |
| |
| if (zircon_toolchain != false) { |
| configs -= [ "//build/config:symbol_visibility_hidden" ] |
| } else { |
| defines = [ "HIDDEN=1" ] |
| } |
| } |
| |
| source_set("extmem") { |
| visibility = [ ":*" ] |
| |
| deps = [ "//zircon/third_party/ulib/musl:musl_internal" ] |
| sources = [ |
| "memccpy.c", |
| "memmem.c", |
| ] |
| if (current_cpu == "x64" && toolchain_variant.tags + [ "asan" ] - |
| [ "asan" ] == toolchain_variant.tags) { |
| # Only use the assembly version if x86-64 and not sanitized. |
| sources += [ "x86_64/mempcpy.S" ] |
| } else { |
| sources += [ "mempcpy.c" ] |
| } |
| |
| if (zircon_toolchain != false) { |
| configs -= [ "//build/config:symbol_visibility_hidden" ] |
| } else { |
| defines = [ "HIDDEN=1" ] |
| } |
| |
| # TODO(https://fxbug.dev/42136089): delete the below and fix compiler warnings |
| configs += [ "//build/config:Wno-conversion" ] |
| } |
| |
| source_set("minimal_str") { |
| visibility = [ ":*" ] |
| |
| deps = [ "//zircon/third_party/ulib/musl:musl_internal" ] |
| if (current_cpu == "arm64") { |
| # These use '#include "third_party/lib/cortex-strings/src/aarch64/..."'. |
| include_dirs = [ "//zircon/" ] |
| sources = [ |
| "aarch64/strlen.S", |
| "aarch64/strncmp.S", |
| ] |
| } else { |
| sources = [ |
| "strlen.c", |
| "strncmp.c", |
| ] |
| } |
| |
| if (zircon_toolchain != false) { |
| configs -= [ "//build/config:symbol_visibility_hidden" ] |
| } else { |
| defines = [ "HIDDEN=1" ] |
| } |
| } |
| |
| source_set("stdstr") { |
| visibility = [ ":*" ] |
| |
| deps = [ |
| ":minimal_str", |
| "//zircon/third_party/ulib/musl:musl_internal", |
| ] |
| sources = [ |
| "strcat.c", |
| "strcspn.c", |
| "strdup.c", |
| "strncat.c", |
| "strncpy.c", |
| "strpbrk.c", |
| "strrchr.c", |
| "strspn.c", |
| "strstr.c", |
| "strtok.c", |
| "strtok_r.c", |
| ] |
| if (current_cpu == "arm64") { |
| # These use '#include "third_party/lib/cortex-strings/src/aarch64/..."'. |
| include_dirs = [ "//zircon/" ] |
| sources += [ |
| "aarch64/strchr.S", |
| "aarch64/strcmp.S", |
| "aarch64/strcpy.S", |
| ] |
| } else { |
| sources += [ |
| "strchr.c", |
| "strcmp.c", |
| "strcpy.c", |
| ] |
| } |
| |
| if (zircon_toolchain != false) { |
| configs -= [ "//build/config:symbol_visibility_hidden" ] |
| } else { |
| defines = [ "HIDDEN=1" ] |
| } |
| |
| # TODO(https://fxbug.dev/42136089): delete the below and fix compiler warnings |
| configs += [ "//build/config:Wno-conversion" ] |
| } |
| |
| source_set("strerror_r") { |
| visibility = [ |
| ":*", |
| "//zircon/system/ulib/c/*", |
| ] |
| |
| deps = [ "//zircon/third_party/ulib/musl:musl_internal" ] |
| sources = [ "strerror_r.c" ] |
| if (zircon_toolchain != false) { |
| configs -= [ "//build/config:symbol_visibility_hidden" ] |
| } |
| } |
| |
| source_set("strsignal") { |
| visibility = [ |
| ":*", |
| "//zircon/system/ulib/c/*", |
| ] |
| |
| deps = [ "//zircon/third_party/ulib/musl:musl_internal" ] |
| sources = [ "strsignal.c" ] |
| if (zircon_toolchain != false) { |
| configs -= [ "//build/config:symbol_visibility_hidden" ] |
| } |
| } |
| |
| source_set("strverscmp") { |
| visibility = [ |
| ":*", |
| "//zircon/system/ulib/c/*", |
| ] |
| |
| deps = [ "//zircon/third_party/ulib/musl:musl_internal" ] |
| sources = [ "strverscmp.c" ] |
| if (zircon_toolchain != false) { |
| configs -= [ "//build/config:symbol_visibility_hidden" ] |
| } |
| } |
| |
| source_set("extstr") { |
| visibility = [ ":*" ] |
| |
| deps = [ |
| ":strverscmp", |
| "//zircon/third_party/ulib/musl:musl_internal", |
| ] |
| sources = [ |
| "stpcpy.c", |
| "stpncpy.c", |
| "strcasecmp.c", |
| "strcasestr.c", |
| "strlcat.c", |
| "strlcpy.c", |
| "strncasecmp.c", |
| "strndup.c", |
| "strsep.c", |
| ] |
| if (current_cpu == "arm64") { |
| # These use '#include "third_party/lib/cortex-strings/src/aarch64/..."'. |
| include_dirs = [ "//zircon/" ] |
| sources += [ |
| "//zircon/third_party/lib/cortex-strings/src/aarch64/strnlen.S", |
| "aarch64/strchrnul.S", |
| ] |
| } else { |
| sources += [ |
| "strchrnul.c", |
| "strnlen.c", |
| ] |
| } |
| |
| if (zircon_toolchain != false) { |
| configs -= [ "//build/config:symbol_visibility_hidden" ] |
| } else { |
| defines = [ "HIDDEN=1" ] |
| } |
| } |
| |
| source_set("bsd") { |
| visibility = [ ":*" ] |
| |
| deps = [ "//zircon/third_party/ulib/musl:musl_internal" ] |
| sources = [ |
| "bcmp.c", |
| "bcopy.c", |
| "bzero.c", |
| "index.c", |
| "rindex.c", |
| "swab.c", |
| ] |
| |
| if (zircon_toolchain != false) { |
| configs -= [ "//build/config:symbol_visibility_hidden" ] |
| } else { |
| defines = [ "HIDDEN=1" ] |
| } |
| } |
| |
| source_set("wcs") { |
| visibility = [ ":*" ] |
| |
| deps = [ "//zircon/third_party/ulib/musl:musl_internal" ] |
| sources = [ |
| "wcpcpy.c", |
| "wcpncpy.c", |
| "wcscasecmp.c", |
| "wcscat.c", |
| "wcschr.c", |
| "wcscmp.c", |
| "wcscpy.c", |
| "wcscspn.c", |
| "wcsdup.c", |
| "wcslen.c", |
| "wcsncasecmp.c", |
| "wcsncat.c", |
| "wcsncmp.c", |
| "wcsncpy.c", |
| "wcsnlen.c", |
| "wcspbrk.c", |
| "wcsrchr.c", |
| "wcsspn.c", |
| "wcsstr.c", |
| "wcstok.c", |
| "wcswcs.c", |
| ] |
| |
| if (zircon_toolchain != false) { |
| configs -= [ "//build/config:symbol_visibility_hidden" ] |
| } else { |
| defines = [ "HIDDEN=1" ] |
| } |
| } |
| |
| source_set("wmem") { |
| visibility = [ ":*" ] |
| |
| deps = [ "//zircon/third_party/ulib/musl:musl_internal" ] |
| sources = [ |
| "wmemchr.c", |
| "wmemcmp.c", |
| "wmemcpy.c", |
| "wmemmove.c", |
| "wmemset.c", |
| ] |
| |
| if (zircon_toolchain != false) { |
| configs -= [ "//build/config:symbol_visibility_hidden" ] |
| } else { |
| defines = [ "HIDDEN=1" ] |
| } |
| } |