1

add DEFAULT_COPTS

This commit is contained in:
Motiejus Jakštys 2021-08-05 15:21:38 +03:00
parent 63fc7aeb7a
commit 7b0c37aacd

View File

@ -18,6 +18,10 @@ DEFAULT_INCLUDE_DIRECTORIES = [
"libcxxabi/include", "libcxxabi/include",
] ]
# -Os, -O2 or -O3 must be set, because some dependencies use C's undefined
# behavior. See https://github.com/ziglang/zig/issues/4830
DEFAULT_COPTS = ["-O3"]
_fcntl_map = """ _fcntl_map = """
GLIBC_2.2.5 { GLIBC_2.2.5 {
fcntl; fcntl;
@ -64,7 +68,7 @@ def _target_darwin(gocpu, zigcpu):
"libc/include/{}-macos-gnu".format(zigcpu), "libc/include/{}-macos-gnu".format(zigcpu),
], ],
linkopts = [], linkopts = [],
copts = [], copts = DEFAULT_COPTS,
bazel_target_cpu = "darwin", bazel_target_cpu = "darwin",
constraint_values = [ constraint_values = [
"@platforms//os:macos", "@platforms//os:macos",
@ -109,7 +113,7 @@ def _target_linux_gnu(gocpu, zigcpu, glibc_version = ""):
compiler_extra_includes = ["glibchack-fcntl.h"] if fcntl_hack else [], compiler_extra_includes = ["glibchack-fcntl.h"] if fcntl_hack else [],
linker_version_scripts = ["glibc-hacks/fcntl.map"] if fcntl_hack else [], linker_version_scripts = ["glibc-hacks/fcntl.map"] if fcntl_hack else [],
linkopts = ["-lc++", "-lc++abi"], linkopts = ["-lc++", "-lc++abi"],
copts = [], copts = DEFAULT_COPTS,
bazel_target_cpu = "k8", bazel_target_cpu = "k8",
constraint_values = [ constraint_values = [
"@platforms//os:linux", "@platforms//os:linux",
@ -129,7 +133,7 @@ def _target_linux_musl(gocpu, zigcpu):
"libc/include/{}-linux-any".format(zigcpu), "libc/include/{}-linux-any".format(zigcpu),
], ],
linkopts = ["-s", "-w"], linkopts = ["-s", "-w"],
copts = ["-D_LIBCPP_HAS_MUSL_LIBC", "-D_LIBCPP_HAS_THREAD_API_PTHREAD"], copts = DEFAULT_COPTS + ["-D_LIBCPP_HAS_MUSL_LIBC", "-D_LIBCPP_HAS_THREAD_API_PTHREAD"],
bazel_target_cpu = "k8", bazel_target_cpu = "k8",
constraint_values = [ constraint_values = [
"@platforms//os:linux", "@platforms//os:linux",