diff --git a/utils/bazel/.bazelrc b/utils/bazel/.bazelrc --- a/utils/bazel/.bazelrc +++ b/utils/bazel/.bazelrc @@ -35,15 +35,15 @@ build:generic_clang --cxxopt=-std=c++14 --host_cxxopt=-std=c++14 # Use `-Wall` and `-Werror` for Clang. -build:generic_clang --copt=-Wall --copt=-Werror --host_copt=-Wall --host_copt=-Werror +build:generic_clang --cxxopt=-Wall --cxxopt=-Werror # The Clang available on MacOS has a warning that isn't clean on MLIR code. The # warning doesn't show up with more recent Clangs, so just disable for now. -build:generic_clang --cxxopt=-Wno-range-loop-analysis --host_cxxopt=-Wno-range-loop-analysis +build:generic_clang --cxxopt=-Wno-range-loop-analysis # Build errors are not a helpful way to enforce deprecation in-repo and it is # not the point of the Bazel build to catch usage of deprecated APIs. -build:generic_clang --copt=-Wno-deprecated --host_copt=-Wno-deprecated +build:generic_clang --cxxopt=-Wno-deprecated ############################################################################### # Options for "generic_gcc" builds: these options should generally apply to @@ -61,7 +61,7 @@ # Build errors are not a helpful way to enforce deprecation in-repo and it is # not the point of the Bazel build to catch usage of deprecated APIs. -build:generic_gcc --copt=-Wno-deprecated --host_copt=-Wno-deprecated +build:generic_gcc --cxxopt=-Wno-deprecated # Disable GCC warnings that are noisy and/or false positives on LLVM code. # These need to be global as some code triggering these is in header files. @@ -72,7 +72,7 @@ build:generic_gcc --copt=-Wno-misleading-indentation --host_copt=-Wno-misleading-indentation # Use `-Werror` for GCC to make sure warnings don't slip past. -build:generic_gcc --copt=-Werror --host_copt=-Werror +build:generic_gcc --cxxopt=-Werror ############################################################################### # Generic Windows flags common to both MSVC and Clang. diff --git a/utils/bazel/WORKSPACE b/utils/bazel/WORKSPACE --- a/utils/bazel/WORKSPACE +++ b/utils/bazel/WORKSPACE @@ -4,6 +4,7 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe") +load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository") SKYLIB_VERSION = "1.0.3" @@ -71,16 +72,43 @@ name = "vulkan_sdk", ) -http_archive( +git_repository( name = "bazel_toolchains", - sha256 = "1adf5db506a7e3c465a26988514cfc3971af6d5b3c2218925cd6e71ee443fc3f", - strip_prefix = "bazel-toolchains-4.0.0", + tag = "4.0.0", + remote = "https://github.com/bazelbuild/bazel-toolchains.git" +) + +git_repository( + name = "rules_foreign_cc", + tag = "0.7.1", + remote = "https://github.com/bazelbuild/rules_foreign_cc.git" +) + +load("@rules_foreign_cc//foreign_cc:repositories.bzl", "rules_foreign_cc_dependencies") + +rules_foreign_cc_dependencies() + +maybe( + http_archive, + name = "gmp", + build_file = "@llvm-raw//utils/bazel/third_party_build:gmp.BUILD", + sha256 = "fd4829912cddd12f84181c3451cc752be224643e87fac497b69edddadc49b4f2", + strip_prefix = "gmp-6.2.1", urls = [ - "https://mirror.bazel.build/github.com/bazelbuild/bazel-toolchains/releases/download/4.0.0/bazel-toolchains-4.0.0.tar.gz", - "https://github.com/bazelbuild/bazel-toolchains/releases/download/4.0.0/bazel-toolchains-4.0.0.tar.gz", + "https://gmplib.org/download/gmp/gmp-6.2.1.tar.xz", + "https://ftp.gnu.org/gnu/gmp/gmp-6.2.1.tar.xz", ], ) +maybe( + http_archive, + name = "mpfr", + build_file = "@llvm-raw//utils/bazel/third_party_build:mpfr.BUILD", + sha256 = "3127fe813218f3a1f0adf4e8899de23df33b4cf4b4b3831a5314f78e65ffa2d6", + strip_prefix = "mpfr-4.1.0", + urls = ["https://www.mpfr.org/mpfr-current/mpfr-4.1.0.tar.gz"], +) + load("@bazel_toolchains//rules:rbe_repo.bzl", "rbe_autoconfig") rbe_autoconfig(name = "rbe_default") diff --git a/utils/bazel/llvm-project-overlay/libc/test/libc_test_rules.bzl b/utils/bazel/llvm-project-overlay/libc/test/libc_test_rules.bzl new file mode 100644 --- /dev/null +++ b/utils/bazel/llvm-project-overlay/libc/test/libc_test_rules.bzl @@ -0,0 +1,32 @@ +"""LLVM libc starlark rules for tests.""" + +load("@llvm-project//libc:libc_build_rules.bzl", "INTERNAL_SUFFIX") + +def libc_test(name, srcs, libc_function_deps, additional_deps = None, **kw): + """Add target for a libc test. + + Args: + name: Test target name + srcs: List of sources for the test. + libc_function_deps: List of libc_function targets used by this test. + additional_deps: List of additional targets used by this test. + **kw: Attributes relevant for a cc_test. For example, name, srcs, deps. + """ + if "deps" in kw: + fail("A libc_test target should list 'libc_function_deps' and " + + "'additional_deps' instead of 'deps'.") + deps = [ + "@llvm-project//libc:libc_root", + "@llvm-project//libc/utils/UnitTest:LibcUnitTest", + ] + for d in libc_function_deps: + deps.append(d + INTERNAL_SUFFIX) + if additional_deps: + deps.extend(additional_deps) + native.cc_test( + name = name, + srcs = srcs, + deps = deps, + features = ["-link_llvmlibc"], # Do not link libllvmlibc.a + **kw + ) diff --git a/utils/bazel/llvm-project-overlay/libc/test/src/fenv/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/test/src/fenv/BUILD.bazel new file mode 100644 --- /dev/null +++ b/utils/bazel/llvm-project-overlay/libc/test/src/fenv/BUILD.bazel @@ -0,0 +1,102 @@ +# Tests for LLVM libc math.h functions. + +load("@llvm-project//libc:test/libc_test_rules.bzl", "libc_test") + +licenses(["notice"]) + +libc_test( + name = "exception_status_test", + srcs = ["exception_status_test.cpp"], + additional_deps = ["@llvm-project//libc:__support_fputil"], + libc_function_deps = [ + "@llvm-project//libc:feclearexcept", + "@llvm-project//libc:feraiseexcept", + "@llvm-project//libc:fetestexcept", + ], +) + +libc_test( + name = "rounding_mode_test", + srcs = ["rounding_mode_test.cpp"], + libc_function_deps = [ + "@llvm-project//libc:fegetround", + "@llvm-project//libc:fesetround", + ], +) + +libc_test( + name = "enabled_exceptions_test", + srcs = ["enabled_exceptions_test.cpp"], + additional_deps = [ + "@llvm-project//libc/utils/UnitTest:fp_test_helpers", + "@llvm-project//libc:__support_common", + "@llvm-project//libc:__support_fputil", + ], + libc_function_deps = [ + "@llvm-project//libc:feclearexcept", + "@llvm-project//libc:feraiseexcept", + "@llvm-project//libc:fetestexcept", + ], + tags = ["nosan"], +) + +libc_test( + name = "feholdexcept_test", + srcs = ["feholdexcept_test.cpp"], + additional_deps = [ + "@llvm-project//libc/utils/UnitTest:fp_test_helpers", + "@llvm-project//libc:__support_common", + "@llvm-project//libc:__support_fputil", + ], + libc_function_deps = ["@llvm-project//libc:feholdexcept"], + tags = ["nosan"], +) + +libc_test( + name = "exception_flags_test", + srcs = ["exception_flags_test.cpp"], + additional_deps = [ + "@llvm-project//libc:__support_fputil", + ], + libc_function_deps = [ + "@llvm-project//libc:fegetexceptflag", + "@llvm-project//libc:fesetexceptflag", + ], +) + +libc_test( + name = "feclearexcept_test", + srcs = ["feclearexcept_test.cpp"], + additional_deps = ["@llvm-project//libc:__support_fputil"], + libc_function_deps = ["@llvm-project//libc:feclearexcept"], +) + +libc_test( + name = "feenableexcept_test", + srcs = ["feenableexcept_test.cpp"], + additional_deps = ["@llvm-project//libc:__support_common"], + libc_function_deps = [ + "@llvm-project//libc:fedisableexcept", + "@llvm-project//libc:feenableexcept", + "@llvm-project//libc:fegetexcept", + ], +) + +libc_test( + name = "feupdateenv_test", + srcs = ["feupdateenv_test.cpp"], + additional_deps = ["@llvm-project//libc:__support_fputil"], + libc_function_deps = ["@llvm-project//libc:feupdateenv"], +) + +libc_test( + name = "getenv_and_setenv_test", + srcs = ["getenv_and_setenv_test.cpp"], + additional_deps = ["@llvm-project//libc:__support_fputil"], + libc_function_deps = [ + "@llvm-project//libc:fegetenv", + "@llvm-project//libc:fegetround", + "@llvm-project//libc:fesetenv", + "@llvm-project//libc:fesetround", + ], +) diff --git a/utils/bazel/llvm-project-overlay/libc/test/src/math/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/test/src/math/BUILD.bazel new file mode 100644 --- /dev/null +++ b/utils/bazel/llvm-project-overlay/libc/test/src/math/BUILD.bazel @@ -0,0 +1,457 @@ +# Tests for LLVM libc math.h functions. + +load("@llvm-project//libc/test/src/math:libc_math_test_rules.bzl", "math_test") + +licenses(["notice"]) + +math_test( + name = "fabs", + hdrs = ["FAbsTest.h"], +) + +math_test( + name = "fabsf", + hdrs = ["FAbsTest.h"], +) + +math_test( + name = "fabsl", + hdrs = ["FAbsTest.h"], +) + +math_test( + name = "ceil", + hdrs = ["CeilTest.h"], +) + +math_test( + name = "ceilf", + hdrs = ["CeilTest.h"], +) + +math_test( + name = "ceill", + hdrs = ["CeilTest.h"], +) + +math_test( + name = "floor", + hdrs = ["FloorTest.h"], +) + +math_test( + name = "floorf", + hdrs = ["FloorTest.h"], +) + +math_test( + name = "floorl", + hdrs = ["FloorTest.h"], +) + +math_test( + name = "trunc", + hdrs = ["TruncTest.h"], +) + +math_test( + name = "truncf", + hdrs = ["TruncTest.h"], +) + +math_test( + name = "truncl", + hdrs = ["TruncTest.h"], +) + +math_test( + name = "round", + hdrs = ["RoundTest.h"], +) + +math_test( + name = "roundf", + hdrs = ["RoundTest.h"], +) + +math_test( + name = "roundl", + hdrs = ["RoundTest.h"], +) + +math_test( + name = "frexp", + hdrs = ["FrexpTest.h"], +) + +math_test( + name = "frexpf", + hdrs = ["FrexpTest.h"], +) + +math_test( + name = "frexpl", + hdrs = ["FrexpTest.h"], +) + +math_test( + name = "hypot", + hdrs = ["HypotTest.h"], +) + +math_test( + name = "hypotf", + hdrs = [ + "HypotTest.h", + "hypotf_hard_to_round.h", + ], +) + +math_test( + name = "logb", + hdrs = ["LogbTest.h"], +) + +math_test( + name = "logbf", + hdrs = ["LogbTest.h"], +) + +math_test( + name = "logbl", + hdrs = ["LogbTest.h"], +) + +math_test( + name = "modf", + hdrs = ["ModfTest.h"], +) + +math_test( + name = "modff", + hdrs = ["ModfTest.h"], +) + +math_test( + name = "modfl", + hdrs = ["ModfTest.h"], +) + +cc_library( + name = "remquo_test_template", + hdrs = ["RemQuoTest.h"], + deps = [ + "@llvm-project//libc:__support_fputil", + "@llvm-project//libc/utils/MPFRWrapper:mpfr_wrapper", + "@llvm-project//libc/utils/UnitTest:LibcUnitTest", + "@llvm-project//libc/utils/UnitTest:fp_test_helpers", + ], +) + +math_test( + name = "remquo", + additional_deps = [":remquo_test_template"], +) + +math_test( + name = "remquof", + additional_deps = [":remquo_test_template"], +) + +math_test( + name = "remquol", + additional_deps = [":remquo_test_template"], +) + +math_test( + name = "fmin", + hdrs = ["FMinTest.h"], +) + +math_test( + name = "fminf", + hdrs = ["FMinTest.h"], +) + +math_test( + name = "fminl", + hdrs = ["FMinTest.h"], +) + +math_test( + name = "fmax", + hdrs = ["FMaxTest.h"], +) + +math_test( + name = "fmaxf", + hdrs = ["FMaxTest.h"], +) + +math_test( + name = "fmaxl", + hdrs = ["FMaxTest.h"], +) + +math_test( + name = "sqrt", + hdrs = ["SqrtTest.h"], + additional_deps = ["@llvm-project//libc:__support_standalone_cpp"], +) + +math_test( + name = "sqrtf", + hdrs = ["SqrtTest.h"], + additional_deps = ["@llvm-project//libc:__support_standalone_cpp"], +) + +# TODO(sivachandra): sqrtl test currently fails on Aarch64 because of +# insufficient precision in MPFR leading to https://hal.archives-ouvertes.fr/hal-01091186/document +# We will comment it out for now and wait for it to get fixed upstream. +# math_test(name = "sqrtl") + +math_test( + name = "copysign", + hdrs = ["CopySignTest.h"], +) + +math_test( + name = "copysignf", + hdrs = ["CopySignTest.h"], +) + +math_test( + name = "copysignl", + hdrs = ["CopySignTest.h"], +) + +cc_library( + name = "ilogb_test_template", + hdrs = ["ILogbTest.h"], + deps = [ + "@llvm-project//libc:__support_fputil", + "@llvm-project//libc/utils/UnitTest:LibcUnitTest", + ], +) + +math_test( + name = "ilogb", + additional_deps = [":ilogb_test_template"], +) + +math_test( + name = "ilogbf", + additional_deps = [":ilogb_test_template"], +) + +math_test( + name = "ilogbl", + additional_deps = [":ilogb_test_template"], +) + +cc_library( + name = "fdim_test_template", + hdrs = ["FDimTest.h"], + deps = [ + "@llvm-project//libc:__support_fputil", + "@llvm-project//libc/utils/UnitTest:LibcUnitTest", + "@llvm-project//libc/utils/UnitTest:fp_test_helpers", + ], +) + +math_test( + name = "fdim", + additional_deps = [":fdim_test_template"], +) + +math_test( + name = "fdimf", + additional_deps = [":fdim_test_template"], +) + +math_test( + name = "fdiml", + additional_deps = [":fdim_test_template"], +) + +cc_library( + name = "ldexp_test_template", + hdrs = ["LdExpTest.h"], + deps = [ + "@llvm-project//libc:__support_fputil", + "@llvm-project//libc/utils/UnitTest:LibcUnitTest", + "@llvm-project//libc/utils/UnitTest:fp_test_helpers", + ], +) + +math_test( + name = "ldexp", + additional_deps = [":ldexp_test_template"], +) + +math_test( + name = "ldexpf", + additional_deps = [":ldexp_test_template"], +) + +math_test( + name = "ldexpl", + additional_deps = [":ldexp_test_template"], +) + +cc_library( + name = "rint_test_template", + hdrs = ["RIntTest.h"], + deps = [ + "@llvm-project//libc:__support_fputil", + "@llvm-project//libc/utils/MPFRWrapper:mpfr_wrapper", + "@llvm-project//libc/utils/UnitTest:LibcUnitTest", + "@llvm-project//libc/utils/UnitTest:fp_test_helpers", + ], +) + +math_test( + name = "rint", + additional_deps = [":rint_test_template"], +) + +math_test( + name = "rintf", + additional_deps = [":rint_test_template"], +) + +math_test( + name = "rintl", + additional_deps = [":rint_test_template"], +) + +cc_library( + name = "round_to_integer_test_template", + hdrs = ["RoundToIntegerTest.h"], + deps = [ + "@llvm-project//libc:__support_fputil", + "@llvm-project//libc/utils/MPFRWrapper:mpfr_wrapper", + "@llvm-project//libc/utils/UnitTest:LibcUnitTest", + "@llvm-project//libc/utils/UnitTest:fp_test_helpers", + ], +) + +math_test( + name = "lrint", + additional_deps = [":round_to_integer_test_template"], +) + +math_test( + name = "lrintf", + additional_deps = [":round_to_integer_test_template"], +) + +math_test( + name = "lrintl", + additional_deps = [":round_to_integer_test_template"], +) + +math_test( + name = "llrint", + additional_deps = [":round_to_integer_test_template"], +) + +math_test( + name = "llrintf", + additional_deps = [":round_to_integer_test_template"], +) + +math_test( + name = "llrintl", + additional_deps = [":round_to_integer_test_template"], +) + +math_test( + name = "lround", + additional_deps = [":round_to_integer_test_template"], +) + +math_test( + name = "lroundf", + additional_deps = [":round_to_integer_test_template"], +) + +math_test( + name = "lroundl", + additional_deps = [":round_to_integer_test_template"], +) + +math_test( + name = "llround", + additional_deps = [":round_to_integer_test_template"], +) + +math_test( + name = "llroundf", + additional_deps = [":round_to_integer_test_template"], +) + +math_test( + name = "llroundl", + additional_deps = [":round_to_integer_test_template"], +) + +cc_library( + name = "nextafter_test_template", + hdrs = ["NextAfterTest.h"], + deps = [ + "@llvm-project//libc:__support_fputil", + "@llvm-project//libc:__support_standalone_cpp", + "@llvm-project//libc/utils/UnitTest:LibcUnitTest", + "@llvm-project//libc/utils/UnitTest:fp_test_helpers", + ], +) + +math_test( + name = "nextafter", + additional_deps = [":nextafter_test_template"], +) + +math_test( + name = "nextafterf", + additional_deps = [":nextafter_test_template"], +) + +math_test( + name = "nextafterl", + additional_deps = [":nextafter_test_template"], +) + +cc_library( + name = "sdcomp26094", + hdrs = ["sdcomp26094.h"], + deps = [ + "@llvm-project//libc:__support_fputil", + "@llvm-project//libc:__support_standalone_cpp", + "@llvm-project//libc:libc_root", + ], +) + +math_test( + name = "cosf", + additional_deps = [ + ":sdcomp26094", + "@llvm-project//libc:__support_standalone_cpp", + ], +) + +math_test( + name = "sincosf", + additional_deps = [ + ":sdcomp26094", + "@llvm-project//libc:__support_standalone_cpp", + ], +) + +math_test( + name = "sinf", + additional_deps = [ + ":sdcomp26094", + "@llvm-project//libc:__support_standalone_cpp", + ], +) diff --git a/utils/bazel/llvm-project-overlay/libc/test/src/math/libc_math_test_rules.bzl b/utils/bazel/llvm-project-overlay/libc/test/src/math/libc_math_test_rules.bzl new file mode 100644 --- /dev/null +++ b/utils/bazel/llvm-project-overlay/libc/test/src/math/libc_math_test_rules.bzl @@ -0,0 +1,30 @@ +load("@llvm-project//libc:test/libc_test_rules.bzl", "libc_test") + +def math_test(name, additional_deps = None, need_mpfr = True, hdrs = None): + """Add a target for the unittest of a math function. + + Args: + name: The name of the function being tested. + additional_deps: List of additional depenencies required by the test. + need_mpfr: True if the test uses mpfr_wrappper, False otherwise. + hdrs: List of headers to add. + """ + test_name = name + "_test" + srcs = [test_name + ".cpp"] + (hdrs or []) + additional_deps = additional_deps or [] + libc_function_deps = ["@llvm-project//libc:" + name] + additional_deps += [ + "@llvm-project//libc:__support_fputil", + "@llvm-project//libc/utils/UnitTest:fp_test_helpers", + ] + if need_mpfr: + additional_deps.append( + "@llvm-project//libc/utils/MPFRWrapper:mpfr_wrapper", + ) + libc_test( + name = test_name, + srcs = srcs, + libc_function_deps = libc_function_deps, + additional_deps = additional_deps, + size = "enormous", # Some tests are emulated and take very long. + ) diff --git a/utils/bazel/llvm-project-overlay/libc/test/src/stdlib/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/test/src/stdlib/BUILD.bazel new file mode 100644 --- /dev/null +++ b/utils/bazel/llvm-project-overlay/libc/test/src/stdlib/BUILD.bazel @@ -0,0 +1,59 @@ +# Tests for LLVM libc stdlib.h functions. + +load("@llvm-project//libc:test/libc_test_rules.bzl", "libc_test") + +licenses(["notice"]) + +libc_test( + name = "atoi_test", + srcs = ["atoi_test.cpp"], + libc_function_deps = ["@llvm-project//libc:atoi"], +) + +libc_test( + name = "atol_test", + srcs = ["atol_test.cpp"], + libc_function_deps = ["@llvm-project//libc:atol"], +) + +libc_test( + name = "atoll_test", + srcs = ["atoll_test.cpp"], + libc_function_deps = ["@llvm-project//libc:atoll"], +) + +libc_test( + name = "bsearch_test", + srcs = ["bsearch_test.cpp"], + libc_function_deps = ["@llvm-project//libc:bsearch"], +) + +libc_test( + name = "qsort_test", + srcs = ["qsort_test.cpp"], + libc_function_deps = ["@llvm-project//libc:qsort"], +) + +libc_test( + name = "strtol_test", + srcs = ["strtol_test.cpp"], + libc_function_deps = ["@llvm-project//libc:strtol"], +) + +libc_test( + name = "strtoll_test", + srcs = ["strtoll_test.cpp"], + libc_function_deps = ["@llvm-project//libc:strtoll"], +) + +libc_test( + name = "strtoul_test", + srcs = ["strtoul_test.cpp"], + libc_function_deps = ["@llvm-project//libc:strtoul"], +) + +libc_test( + name = "strtoull_test", + srcs = ["strtoull_test.cpp"], + libc_function_deps = ["@llvm-project//libc:strtoull"], +) diff --git a/utils/bazel/llvm-project-overlay/libc/test/src/string/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/test/src/string/BUILD.bazel new file mode 100644 --- /dev/null +++ b/utils/bazel/llvm-project-overlay/libc/test/src/string/BUILD.bazel @@ -0,0 +1,123 @@ +# Tests for LLVM libc string.h functions. + +load("@llvm-project//libc:test/libc_test_rules.bzl", "libc_test") + +licenses(["notice"]) + +libc_test( + name = "strlen_test", + srcs = ["strlen_test.cpp"], + libc_function_deps = ["@llvm-project//libc:strlen"], +) + +libc_test( + name = "strcpy_test", + srcs = ["strcpy_test.cpp"], + libc_function_deps = ["@llvm-project//libc:strcpy_sanitized"], +) + +libc_test( + name = "strcmp_test", + srcs = ["strcmp_test.cpp"], + libc_function_deps = ["@llvm-project//libc:strcmp"], +) + +libc_test( + name = "memchr_test", + srcs = ["memchr_test.cpp"], + libc_function_deps = ["@llvm-project//libc:memchr"], +) + +libc_test( + name = "strchr_test", + srcs = ["strchr_test.cpp"], + libc_function_deps = ["@llvm-project//libc:strchr"], +) + +libc_test( + name = "strstr_test", + srcs = ["strstr_test.cpp"], + libc_function_deps = ["@llvm-project//libc:strstr"], +) + +libc_test( + name = "strnlen_test", + srcs = ["strnlen_test.cpp"], + libc_function_deps = ["@llvm-project//libc:strnlen"], +) + +libc_test( + name = "memrchr_test", + srcs = ["memrchr_test.cpp"], + libc_function_deps = ["@llvm-project//libc:memrchr"], +) + +libc_test( + name = "strrchr_test", + srcs = ["strrchr_test.cpp"], + libc_function_deps = ["@llvm-project//libc:strrchr"], +) + +libc_test( + name = "strcspn_test", + srcs = ["strcspn_test.cpp"], + libc_function_deps = ["@llvm-project//libc:strcspn"], +) + +libc_test( + name = "strspn_test", + srcs = ["strspn_test.cpp"], + libc_function_deps = ["@llvm-project//libc:strspn"], +) + +libc_test( + name = "strtok_test", + srcs = ["strtok_test.cpp"], + libc_function_deps = ["@llvm-project//libc:strtok"], +) + +libc_test( + name = "memcpy_test", + srcs = ["memcpy_test.cpp"], + additional_deps = ["@llvm-project//libc:__support_standalone_cpp"], + libc_function_deps = ["@llvm-project//libc:memcpy"], +) + +libc_test( + name = "memset_test", + srcs = ["memset_test.cpp"], + additional_deps = ["@llvm-project//libc:__support_standalone_cpp"], + libc_function_deps = ["@llvm-project//libc:memset"], +) + +libc_test( + name = "memmove_test", + srcs = ["memmove_test.cpp"], + additional_deps = [ + "@llvm-project//libc:__support_standalone_cpp", + "@llvm-project//libc/utils/UnitTest:memory_matcher", + ], + libc_function_deps = [ + "@llvm-project//libc:memcmp", + "@llvm-project//libc:memmove", + ], +) + +libc_test( + name = "memcmp_test", + srcs = ["memcmp_test.cpp"], + libc_function_deps = ["@llvm-project//libc:memcmp"], +) + +libc_test( + name = "bcmp_test", + srcs = ["bcmp_test.cpp"], + libc_function_deps = ["@llvm-project//libc:bcmp"], +) + +libc_test( + name = "bzero_test", + srcs = ["bzero_test.cpp"], + additional_deps = ["@llvm-project//libc:__support_standalone_cpp"], + libc_function_deps = ["@llvm-project//libc:bzero"], +) diff --git a/utils/bazel/llvm-project-overlay/libc/utils/MPFRWrapper/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/utils/MPFRWrapper/BUILD.bazel new file mode 100644 --- /dev/null +++ b/utils/bazel/llvm-project-overlay/libc/utils/MPFRWrapper/BUILD.bazel @@ -0,0 +1,19 @@ +# A wrapper library over MPFR for use with LLVM libc math unittests. + +licenses(["notice"]) + +cc_library( + name = "mpfr_wrapper", + srcs = ["MPFRUtils.cpp"], + hdrs = ["MPFRUtils.h"], + visibility = ["//visibility:public"], + deps = [ + "@llvm-project//libc:__support_common", + "@llvm-project//libc:__support_fputil", + "@llvm-project//libc:__support_standalone_cpp", + "@llvm-project//libc:libc_root", + "@llvm-project//libc/utils/UnitTest:LibcUnitTest", + "@llvm-project//libc/utils/UnitTest:fp_test_helpers", + "@mpfr//:mpfr", + ], +) diff --git a/utils/bazel/llvm-project-overlay/libc/utils/UnitTest/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/utils/UnitTest/BUILD.bazel new file mode 100644 --- /dev/null +++ b/utils/bazel/llvm-project-overlay/libc/utils/UnitTest/BUILD.bazel @@ -0,0 +1,54 @@ +# LLVM libc unittest library. + +licenses(["notice"]) + +cc_library( + name = "LibcUnitTest", + srcs = [ + "LibcTest.cpp", + "LibcTestMain.cpp", + ], + hdrs = [ + "LibcTest.h", + "PlatformDefs.h", + "Test.h", + ], + visibility = ["//visibility:public"], + deps = [ + "//llvm:Support", + "@llvm-project//libc:__support_fputil", + "@llvm-project//libc:__support_standalone_cpp", + "@llvm-project//libc:libc_root", + "@llvm-project//libc/utils/testutils:libc_test_utils", + ], +) + +cc_library( + name = "fp_test_helpers", + srcs = [ + "FPExceptMatcher.cpp", + "FPMatcher.cpp", + ], + hdrs = [ + "FPExceptMatcher.h", + "FPMatcher.h", + ], + visibility = ["//visibility:public"], + deps = [ + ":LibcUnitTest", + "@llvm-project//libc:__support_fputil", + "@llvm-project//libc:__support_standalone_cpp", + "@llvm-project//libc:libc_root", + ], +) + +cc_library( + name = "memory_matcher", + srcs = ["MemoryMatcher.cpp"], + hdrs = ["MemoryMatcher.h"], + visibility = ["//visibility:public"], + deps = [ + ":LibcUnitTest", + "@llvm-project//libc:__support_standalone_cpp", + ], +) diff --git a/utils/bazel/llvm-project-overlay/libc/utils/testutils/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/utils/testutils/BUILD.bazel new file mode 100644 --- /dev/null +++ b/utils/bazel/llvm-project-overlay/libc/utils/testutils/BUILD.bazel @@ -0,0 +1,20 @@ +licenses(["notice"]) + +cc_library( + name = "libc_test_utils", + srcs = [ + "ExecuteFunctionUnix.cpp", + "FDReaderUnix.cpp", + "StreamWrapper.cpp", + ], + hdrs = [ + "ExecuteFunction.h", + "FDReader.h", + "StreamWrapper.h", + ], + visibility = ["//visibility:public"], + deps = [ + "//llvm:Support", + "@llvm-project//libc:libc_root", + ], +) diff --git a/utils/bazel/third_party_build/gmp.BUILD b/utils/bazel/third_party_build/gmp.BUILD new file mode 100644 --- /dev/null +++ b/utils/bazel/third_party_build/gmp.BUILD @@ -0,0 +1,14 @@ +load("@rules_foreign_cc//foreign_cc:defs.bzl", "configure_make") + +filegroup( + name = "sources", + srcs = glob(["**"]), +) + +configure_make( + name = "gmp", + copts = ["-Wno-error"], # ./configure crashes with `-Werror` + lib_name = "libgmp", + lib_source = ":sources", + visibility = ["//visibility:public"], +) diff --git a/utils/bazel/third_party_build/mpfr.BUILD b/utils/bazel/third_party_build/mpfr.BUILD new file mode 100644 --- /dev/null +++ b/utils/bazel/third_party_build/mpfr.BUILD @@ -0,0 +1,15 @@ +load("@rules_foreign_cc//foreign_cc:defs.bzl", "configure_make") + +filegroup( + name = "sources", + srcs = glob(["**"]), +) + +configure_make( + name = "mpfr", + copts = ["-Wno-error"], # ./configure crashes with `-Werror` + lib_name = "libmpfr", + lib_source = ":sources", + visibility = ["//visibility:public"], + deps = ["@gmp"], +)