blob: a3b98a60270637f5c21696e1767c238a659ed70c [file] [log] [blame]
# Copyright 2021 The Cobalt Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
if (target_cpu == "x64") {
musl_arch = "x86_64"
} else if (target_cpu == "x86") {
musl_arch = "i386"
} else if (target_cpu == "arm") {
musl_arch = "arm"
} else if (target_cpu == "arm64") {
musl_arch = "aarch64"
} else if (target_cpu == "mips") {
musl_arch = "mips"
}
config("external_settings") {
include_dirs = [
"musl/include",
"arch/$musl_arch",
"arch/generic",
]
}
group("c") {
public_configs = [ ":external_settings" ]
deps = [ ":c_internal" ]
}
static_library("c_internal") {
# External targets must depend on the group so that they get the
# "external_settings" config applied.
visibility = [ ":c" ]
include_dirs = [
"src/starboard/internal",
"src/errno",
"src/multibyte",
"src/time",
"src/internal",
"arch/$musl_arch",
]
cflags = [
"-nobuiltininc",
"-isystem" + rebase_path("include", root_build_dir),
"-isystem" + rebase_path("arch/$musl_arch", root_build_dir),
"-isystem" + rebase_path("arch/generic", root_build_dir),
"-w",
]
# Enables temporary situation where main cobalt is built with glibc headers
# but then linked with some musl components. Expected to go away when main
# cobalt is also build with stand-alone libc++.
defines = [ "COBALT_MUSL_W_GLIBC_HEADERS" ]
sources = [
"src/ctype/__ctype_b_loc.c",
# Excluded because locale_impl needs mutexs
# "src/ctype/__ctype_get_mb_cur_max.c",
"src/ctype/__ctype_tolower_loc.c",
"src/ctype/__ctype_toupper_loc.c",
"src/ctype/isalnum.c",
"src/ctype/isalpha.c",
"src/ctype/isascii.c",
"src/ctype/isblank.c",
"src/ctype/iscntrl.c",
"src/ctype/isdigit.c",
"src/ctype/isgraph.c",
"src/ctype/islower.c",
"src/ctype/isprint.c",
"src/ctype/ispunct.c",
"src/ctype/isspace.c",
"src/ctype/isupper.c",
"src/ctype/iswalnum.c",
"src/ctype/iswalpha.c",
"src/ctype/iswblank.c",
"src/ctype/iswcntrl.c",
"src/ctype/iswctype.c",
"src/ctype/iswdigit.c",
"src/ctype/iswgraph.c",
"src/ctype/iswlower.c",
"src/ctype/iswprint.c",
"src/ctype/iswpunct.c",
"src/ctype/iswspace.c",
"src/ctype/iswupper.c",
"src/ctype/iswxdigit.c",
"src/ctype/isxdigit.c",
"src/ctype/tolower.c",
"src/ctype/toupper.c",
"src/ctype/towctrans.c",
"src/ctype/wcswidth.c",
"src/ctype/wctrans.c",
"src/ctype/wcwidth.c",
"src/errno/strerror.c",
"src/exit/assert.c",
"src/exit/atexit.c",
"src/exit/exit.c",
"src/fenv/__flt_rounds.c",
"src/fenv/fegetexceptflag.c",
"src/fenv/feholdexcept.c",
"src/fenv/fesetexceptflag.c",
"src/fenv/fesetround.c",
"src/fenv/feupdateenv.c",
"src/internal/floatscan.c",
"src/internal/intscan.c",
"src/internal/shgetc.c",
"src/locale/strcoll.c",
"src/locale/strxfrm.c",
"src/locale/wcscoll.c",
"src/locale/wcsxfrm.c",
"src/math/__cos.c",
"src/math/__cosdf.c",
"src/math/__cosl.c",
"src/math/__expo2.c",
"src/math/__expo2f.c",
"src/math/__fpclassify.c",
"src/math/__fpclassifyf.c",
"src/math/__fpclassifyl.c",
"src/math/__invtrigl.c",
"src/math/__polevll.c",
"src/math/__rem_pio2.c",
"src/math/__rem_pio2_large.c",
"src/math/__rem_pio2f.c",
"src/math/__rem_pio2l.c",
"src/math/__signbit.c",
"src/math/__signbitf.c",
"src/math/__signbitl.c",
"src/math/__sin.c",
"src/math/__sindf.c",
"src/math/__sinl.c",
"src/math/__tan.c",
"src/math/__tandf.c",
"src/math/__tanl.c",
"src/math/acos.c",
"src/math/acosf.c",
"src/math/acosh.c",
"src/math/acoshf.c",
"src/math/acoshl.c",
"src/math/acosl.c",
"src/math/asin.c",
"src/math/asinf.c",
"src/math/asinh.c",
"src/math/asinhf.c",
"src/math/asinhl.c",
"src/math/asinl.c",
"src/math/atan.c",
"src/math/atan2.c",
"src/math/atan2f.c",
"src/math/atan2l.c",
"src/math/atanf.c",
"src/math/atanh.c",
"src/math/atanhf.c",
"src/math/atanhl.c",
"src/math/atanl.c",
"src/math/cbrt.c",
"src/math/cbrtf.c",
"src/math/cbrtl.c",
"src/math/ceil.c",
"src/math/ceilf.c",
"src/math/ceill.c",
"src/math/copysign.c",
"src/math/copysignf.c",
"src/math/copysignl.c",
"src/math/cos.c",
"src/math/cosf.c",
"src/math/cosh.c",
"src/math/coshf.c",
"src/math/coshl.c",
"src/math/cosl.c",
"src/math/erf.c",
"src/math/erff.c",
"src/math/erfl.c",
"src/math/exp.c",
"src/math/exp10.c",
"src/math/exp10f.c",
"src/math/exp10l.c",
"src/math/exp2.c",
"src/math/exp2f.c",
"src/math/exp2l.c",
"src/math/expf.c",
"src/math/expl.c",
"src/math/expm1.c",
"src/math/expm1f.c",
"src/math/expm1l.c",
"src/math/fabs.c",
"src/math/fabsf.c",
"src/math/fabsl.c",
"src/math/fdim.c",
"src/math/fdimf.c",
"src/math/fdiml.c",
"src/math/finite.c",
"src/math/finitef.c",
"src/math/floor.c",
"src/math/floorf.c",
"src/math/floorl.c",
"src/math/fma.c",
"src/math/fmaf.c",
"src/math/fmal.c",
"src/math/fmax.c",
"src/math/fmaxf.c",
"src/math/fmaxl.c",
"src/math/fmin.c",
"src/math/fminf.c",
"src/math/fminl.c",
"src/math/fmod.c",
"src/math/fmodf.c",
"src/math/fmodl.c",
"src/math/frexp.c",
"src/math/frexpf.c",
"src/math/frexpl.c",
"src/math/hypot.c",
"src/math/hypotf.c",
"src/math/hypotl.c",
"src/math/ilogb.c",
"src/math/ilogbf.c",
"src/math/ilogbl.c",
"src/math/j0.c",
"src/math/j0f.c",
"src/math/j1.c",
"src/math/j1f.c",
"src/math/jn.c",
"src/math/jnf.c",
"src/math/ldexp.c",
"src/math/ldexpf.c",
"src/math/ldexpl.c",
"src/math/lgamma.c",
"src/math/lgamma_r.c",
"src/math/lgammaf.c",
"src/math/lgammaf_r.c",
"src/math/lgammal.c",
"src/math/llrint.c",
"src/math/llrintf.c",
"src/math/llrintl.c",
"src/math/llround.c",
"src/math/llroundf.c",
"src/math/llroundl.c",
"src/math/log.c",
"src/math/log10.c",
"src/math/log10f.c",
"src/math/log10l.c",
"src/math/log1p.c",
"src/math/log1pf.c",
"src/math/log1pl.c",
"src/math/log2.c",
"src/math/log2f.c",
"src/math/log2l.c",
"src/math/logb.c",
"src/math/logbf.c",
"src/math/logbl.c",
"src/math/logf.c",
"src/math/logl.c",
"src/math/lrint.c",
"src/math/lrintf.c",
"src/math/lrintl.c",
"src/math/lround.c",
"src/math/lroundf.c",
"src/math/lroundl.c",
"src/math/modf.c",
"src/math/modff.c",
"src/math/modfl.c",
"src/math/nan.c",
"src/math/nanf.c",
"src/math/nanl.c",
"src/math/nearbyint.c",
"src/math/nearbyintf.c",
"src/math/nearbyintl.c",
"src/math/nextafter.c",
"src/math/nextafterf.c",
"src/math/nextafterl.c",
"src/math/nexttoward.c",
"src/math/nexttowardf.c",
"src/math/nexttowardl.c",
"src/math/pow.c",
"src/math/powf.c",
"src/math/powl.c",
"src/math/remainder.c",
"src/math/remainderf.c",
"src/math/remainderl.c",
"src/math/remquo.c",
"src/math/remquof.c",
"src/math/remquol.c",
"src/math/rint.c",
"src/math/rintf.c",
"src/math/rintl.c",
"src/math/round.c",
"src/math/roundf.c",
"src/math/roundl.c",
"src/math/scalb.c",
"src/math/scalbf.c",
"src/math/scalbln.c",
"src/math/scalblnf.c",
"src/math/scalblnl.c",
"src/math/scalbn.c",
"src/math/scalbnf.c",
"src/math/scalbnl.c",
"src/math/signgam.c",
"src/math/significand.c",
"src/math/significandf.c",
"src/math/sin.c",
"src/math/sincos.c",
"src/math/sincosf.c",
"src/math/sincosl.c",
"src/math/sinf.c",
"src/math/sinh.c",
"src/math/sinhf.c",
"src/math/sinhl.c",
"src/math/sinl.c",
"src/math/sqrt.c",
"src/math/sqrtf.c",
"src/math/sqrtl.c",
"src/math/tan.c",
"src/math/tanf.c",
"src/math/tanh.c",
"src/math/tanhf.c",
"src/math/tanhl.c",
"src/math/tanl.c",
"src/math/tgamma.c",
"src/math/tgammaf.c",
"src/math/tgammal.c",
"src/math/trunc.c",
"src/math/truncf.c",
"src/math/truncl.c",
"src/multibyte/btowc.c",
"src/multibyte/internal.c",
"src/multibyte/mbrlen.c",
"src/multibyte/mbrtowc.c",
"src/multibyte/mbsnrtowcs.c",
"src/multibyte/mbsrtowcs.c",
"src/multibyte/mbtowc.c",
"src/multibyte/wcrtomb.c",
"src/multibyte/wcsnrtombs.c",
"src/multibyte/wcsrtombs.c",
"src/multibyte/wcstombs.c",
"src/multibyte/wctob.c",
"src/prng/rand.c",
# Starboardized implementations
"src/starboard/ctype/__ctype_get_mb_cur_max.c",
"src/starboard/errno/__errno_location.c",
"src/starboard/exit/abort.c",
"src/starboard/hwcap/sethwcap.c",
"src/starboard/locale/freelocale.c",
"src/starboard/locale/langinfo.c",
"src/starboard/locale/localeconv.c",
"src/starboard/locale/newlocale.c",
"src/starboard/locale/setlocale.c",
"src/starboard/locale/uselocale.c",
"src/starboard/malloc/malloc.c",
"src/starboard/malloc/memalign.c",
"src/starboard/malloc/posix_memalign.c",
"src/starboard/stdio/fflush.c",
"src/starboard/stdio/fputc.c",
"src/starboard/stdio/stderr.c",
"src/starboard/stdio/stdout.c",
"src/starboard/stdio/vfprintf.c",
"src/starboard/stdio/vsnprintf.c",
"src/starboard/stdio/vsscanf.c",
"src/starboard/stdio/vswprintf.c",
"src/starboard/stdlib/strtod_l.c",
"src/starboard/time/__tz.c",
"src/starboard/time/clock_gettime.c",
"src/stdio/__toread.c",
"src/stdio/__uflow.c",
"src/stdio/fprintf.c",
"src/stdio/fwrite.c",
"src/stdio/printf.c",
"src/stdio/snprintf.c",
"src/stdio/sscanf.c",
"src/stdio/swprintf.c",
"src/stdio/vasprintf.c",
"src/stdio/vprintf.c",
"src/stdio/vsprintf.c",
"src/stdlib/abs.c",
"src/stdlib/atof.c",
"src/stdlib/atoi.c",
"src/stdlib/atol.c",
"src/stdlib/bsearch.c",
"src/stdlib/div.c",
"src/stdlib/labs.c",
"src/stdlib/llabs.c",
"src/stdlib/qsort.c",
"src/stdlib/strtod.c",
"src/stdlib/strtol.c",
"src/stdlib/wcstod.c",
"src/stdlib/wcstol.c",
"src/string/bcmp.c",
"src/string/bcopy.c",
"src/string/bzero.c",
"src/string/explicit_bzero.c",
"src/string/index.c",
"src/string/memccpy.c",
"src/string/memchr.c",
"src/string/memcmp.c",
"src/string/memcpy.c",
"src/string/memmem.c",
"src/string/memmove.c",
"src/string/mempcpy.c",
"src/string/memrchr.c",
"src/string/memset.c",
"src/string/rindex.c",
"src/string/stpcpy.c",
"src/string/stpncpy.c",
"src/string/strcat.c",
"src/string/strchr.c",
"src/string/strchrnul.c",
"src/string/strcmp.c",
"src/string/strcpy.c",
"src/string/strcspn.c",
"src/string/strerror_r.c",
"src/string/strlcat.c",
"src/string/strlcpy.c",
"src/string/strlen.c",
"src/string/strncat.c",
"src/string/strncmp.c",
"src/string/strncpy.c",
"src/string/strnlen.c",
"src/string/strpbrk.c",
"src/string/strrchr.c",
"src/string/strsep.c",
"src/string/strspn.c",
"src/string/strstr.c",
"src/string/strtok.c",
"src/string/strtok_r.c",
"src/string/strverscmp.c",
"src/string/swab.c",
"src/string/wcpcpy.c",
"src/string/wcpncpy.c",
"src/string/wcscat.c",
"src/string/wcschr.c",
"src/string/wcscmp.c",
"src/string/wcscpy.c",
"src/string/wcscspn.c",
"src/string/wcslen.c",
"src/string/wcsncat.c",
"src/string/wcsncmp.c",
"src/string/wcsncpy.c",
"src/string/wcsnlen.c",
"src/string/wcspbrk.c",
"src/string/wcsrchr.c",
"src/string/wcsspn.c",
"src/string/wcsstr.c",
"src/string/wcstok.c",
"src/string/wcswcs.c",
"src/string/wmemchr.c",
"src/string/wmemcmp.c",
"src/string/wmemcpy.c",
"src/string/wmemmove.c",
"src/string/wmemset.c",
"src/time/__month_to_secs.c",
"src/time/__tm_to_secs.c",
"src/time/__year_to_secs.c",
"src/time/strftime.c",
]
if (musl_arch == "i386" || musl_arch == "x86_64" || musl_arch == "aarch64") {
sources += [
"src/fenv/$musl_arch/fenv.s",
"src/setjmp/$musl_arch/longjmp.s",
"src/setjmp/$musl_arch/setjmp.s",
]
}
if (musl_arch == "arm") {
sources += [
"src/fenv/$musl_arch/fenv-hf.S",
"src/fenv/$musl_arch/fenv.c",
"src/setjmp/$musl_arch/longjmp.s",
"src/setjmp/$musl_arch/setjmp.s",
]
}
if (musl_arch == "mips") {
sources += [
"src/fenv/$musl_arch/fenv-sf.c",
"src/fenv/$musl_arch/fenv.S",
"src/setjmp/$musl_arch/longjmp.S",
"src/setjmp/$musl_arch/setjmp.S",
]
}
if (musl_arch == "i386" || musl_arch == "x86_64") {
sources += [
"src/string/$musl_arch/memcpy.s",
"src/string/$musl_arch/memmove.s",
"src/string/$musl_arch/memset.s",
]
sources -= [
"src/string/memcpy.c",
"src/string/memmove.c",
"src/string/memset.c",
]
}
deps = [
"//starboard:starboard_headers_only",
"//starboard/common:common_headers_only",
]
}
target(gtest_target_type, "musl_unittests") {
testonly = true
sources = [ "test/type_size_test.cc" ]
deps = [
":c",
"//starboard:starboard_headers_only",
]
}