|
|
|
# Copyright (c) 2016, Google Inc.
|
|
|
|
#
|
|
|
|
# Permission to use, copy, modify, and/or distribute this software for any
|
|
|
|
# purpose with or without fee is hereby granted, provided that the above
|
|
|
|
# copyright notice and this permission notice appear in all copies.
|
|
|
|
#
|
|
|
|
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
|
|
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
|
|
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
|
|
|
# SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
|
|
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
|
|
|
|
# OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
|
|
|
# CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
|
|
|
|
|
|
|
|
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library")
|
|
|
|
load(
|
|
|
|
":BUILD.generated.bzl",
|
|
|
|
"crypto_headers",
|
|
|
|
"crypto_internal_headers",
|
|
|
|
"crypto_sources",
|
Simplify the external Bazel build.
Now that all assembly files are conditionalized, we no longer need to
detect platforms at the build level. This is convenient because
detecting platforms in Bazel is a bit of a mess.
In particular, this reduces how much we depend on @platforms being
correct. gRPC's build appears to still be using some legacy modes which
seem cause it to, on cross-compiles, report the host's platforms rather
than the target. See https://github.com/grpc/grpc/pull/31938
gRPC should eventually fix this, but it is apparently challenging due
to complexities in migrating from Bazel's legacy system the new
"platforms" mechanism. Instead, try to sidestep this problem by not
relying on the build to do this.
Now, we primarily rely on os:windows being accurate, and cross-compiling
to/from Windows is uncommon. We do also need os:linux to be accurate
when Linux is the target OS, but if Linux is the host and gRPC mislabels
the target as os:linux, this is fine as long as the target is not
FreeBSD, Apple, or another platform that cares about _XOPEN_SOURCE. (In
particular, Android is ambivalent.)
I've also renamed a few things based on what they were actually
selecting. posix_copts was really copts for toolchains with GCC-style
flags. Unfortunately, it's not clear how to condition on the compiler,
rather than the platform in Bazel, so we'll do the wrong thing on
non-MSVC Windows toolchains, but that was true before.
Bug: 542
Change-Id: I7330d8961145ae5714d4cad01259044230d96bcd
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/56465
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2 years ago
|
|
|
"crypto_sources_asm",
|
|
|
|
"fips_fragments",
|
|
|
|
"ssl_headers",
|
|
|
|
"ssl_internal_headers",
|
|
|
|
"ssl_sources",
|
|
|
|
"tool_headers",
|
|
|
|
"tool_sources",
|
|
|
|
)
|
|
|
|
|
|
|
|
licenses(["notice"])
|
|
|
|
|
|
|
|
exports_files(["LICENSE"])
|
|
|
|
|
Simplify the external Bazel build.
Now that all assembly files are conditionalized, we no longer need to
detect platforms at the build level. This is convenient because
detecting platforms in Bazel is a bit of a mess.
In particular, this reduces how much we depend on @platforms being
correct. gRPC's build appears to still be using some legacy modes which
seem cause it to, on cross-compiles, report the host's platforms rather
than the target. See https://github.com/grpc/grpc/pull/31938
gRPC should eventually fix this, but it is apparently challenging due
to complexities in migrating from Bazel's legacy system the new
"platforms" mechanism. Instead, try to sidestep this problem by not
relying on the build to do this.
Now, we primarily rely on os:windows being accurate, and cross-compiling
to/from Windows is uncommon. We do also need os:linux to be accurate
when Linux is the target OS, but if Linux is the host and gRPC mislabels
the target as os:linux, this is fine as long as the target is not
FreeBSD, Apple, or another platform that cares about _XOPEN_SOURCE. (In
particular, Android is ambivalent.)
I've also renamed a few things based on what they were actually
selecting. posix_copts was really copts for toolchains with GCC-style
flags. Unfortunately, it's not clear how to condition on the compiler,
rather than the platform in Bazel, so we'll do the wrong thing on
non-MSVC Windows toolchains, but that was true before.
Bug: 542
Change-Id: I7330d8961145ae5714d4cad01259044230d96bcd
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/56465
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2 years ago
|
|
|
# By default, the C files will expect assembly files, if any, to be linked in
|
|
|
|
# with the build. This default can be flipped with -DOPENSSL_NO_ASM. If building
|
|
|
|
# in a configuration where we have no assembly optimizations, -DOPENSSL_NO_ASM
|
|
|
|
# has no effect, and either value is fine.
|
|
|
|
#
|
|
|
|
# Like C files, assembly files are wrapped in #ifdef (or NASM equivalent), so it
|
|
|
|
# is safe to include a file for the wrong platform in the build. It will just
|
|
|
|
# output an empty object file. However, we need some platform selectors to
|
|
|
|
# distinguish between gas or NASM syntax.
|
|
|
|
#
|
|
|
|
# For all non-Windows platforms, we use gas assembly syntax and can assume any
|
|
|
|
# GCC-compatible toolchain includes a gas-compatible assembler.
|
|
|
|
#
|
|
|
|
# For Windows, we use NASM on x86 and x86_64 and gas, specifically
|
|
|
|
# clang-assembler, on aarch64. We have not yet added NASM support to this build,
|
|
|
|
# and would need to detect MSVC vs clang-cl for aarch64 so, for now, we just
|
|
|
|
# disable assembly on Windows across the board.
|
|
|
|
#
|
|
|
|
# These two selects for asm_sources and asm_copts must be kept in sync. If we
|
|
|
|
# specify assembly, we don't want OPENSSL_NO_ASM. If we don't specify assembly,
|
|
|
|
# we want OPENSSL_NO_ASM, in case the C files expect them in some format (e.g.
|
|
|
|
# NASM) this build file doesn't yet support.
|
|
|
|
#
|
|
|
|
# TODO(https://crbug.com/boringssl/531): Enable assembly for Windows.
|
|
|
|
asm_sources = select({
|
|
|
|
"@platforms//os:windows": [],
|
|
|
|
"//conditions:default": crypto_sources_asm,
|
|
|
|
})
|
|
|
|
asm_copts = select({
|
|
|
|
"@platforms//os:windows": ["-DOPENSSL_NO_ASM"],
|
|
|
|
"//conditions:default": [],
|
|
|
|
})
|
|
|
|
|
Simplify the external Bazel build.
Now that all assembly files are conditionalized, we no longer need to
detect platforms at the build level. This is convenient because
detecting platforms in Bazel is a bit of a mess.
In particular, this reduces how much we depend on @platforms being
correct. gRPC's build appears to still be using some legacy modes which
seem cause it to, on cross-compiles, report the host's platforms rather
than the target. See https://github.com/grpc/grpc/pull/31938
gRPC should eventually fix this, but it is apparently challenging due
to complexities in migrating from Bazel's legacy system the new
"platforms" mechanism. Instead, try to sidestep this problem by not
relying on the build to do this.
Now, we primarily rely on os:windows being accurate, and cross-compiling
to/from Windows is uncommon. We do also need os:linux to be accurate
when Linux is the target OS, but if Linux is the host and gRPC mislabels
the target as os:linux, this is fine as long as the target is not
FreeBSD, Apple, or another platform that cares about _XOPEN_SOURCE. (In
particular, Android is ambivalent.)
I've also renamed a few things based on what they were actually
selecting. posix_copts was really copts for toolchains with GCC-style
flags. Unfortunately, it's not clear how to condition on the compiler,
rather than the platform in Bazel, so we'll do the wrong thing on
non-MSVC Windows toolchains, but that was true before.
Bug: 542
Change-Id: I7330d8961145ae5714d4cad01259044230d96bcd
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/56465
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2 years ago
|
|
|
# Configure C, C++, and common flags for GCC-compatible toolchains.
|
|
|
|
#
|
|
|
|
# TODO(davidben): Can we remove some of these? In Bazel, are warnings the
|
|
|
|
# toolchain or project's responsibility? -Wa,--noexecstack should be unnecessary
|
|
|
|
# now, though https://crbug.com/boringssl/292 tracks testing this in CI.
|
|
|
|
# -fno-common did not become default until
|
|
|
|
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85678.
|
|
|
|
gcc_copts = [
|
|
|
|
# Assembler option --noexecstack adds .note.GNU-stack to each object to
|
|
|
|
# ensure that binaries can be built with non-executable stack.
|
|
|
|
"-Wa,--noexecstack",
|
|
|
|
|
|
|
|
# This list of warnings should match those in the top-level CMakeLists.txt.
|
|
|
|
"-Wall",
|
|
|
|
"-Werror",
|
|
|
|
"-Wformat=2",
|
|
|
|
"-Wsign-compare",
|
|
|
|
"-Wmissing-field-initializers",
|
|
|
|
"-Wwrite-strings",
|
|
|
|
"-Wshadow",
|
|
|
|
"-fno-common",
|
|
|
|
]
|
Simplify the external Bazel build.
Now that all assembly files are conditionalized, we no longer need to
detect platforms at the build level. This is convenient because
detecting platforms in Bazel is a bit of a mess.
In particular, this reduces how much we depend on @platforms being
correct. gRPC's build appears to still be using some legacy modes which
seem cause it to, on cross-compiles, report the host's platforms rather
than the target. See https://github.com/grpc/grpc/pull/31938
gRPC should eventually fix this, but it is apparently challenging due
to complexities in migrating from Bazel's legacy system the new
"platforms" mechanism. Instead, try to sidestep this problem by not
relying on the build to do this.
Now, we primarily rely on os:windows being accurate, and cross-compiling
to/from Windows is uncommon. We do also need os:linux to be accurate
when Linux is the target OS, but if Linux is the host and gRPC mislabels
the target as os:linux, this is fine as long as the target is not
FreeBSD, Apple, or another platform that cares about _XOPEN_SOURCE. (In
particular, Android is ambivalent.)
I've also renamed a few things based on what they were actually
selecting. posix_copts was really copts for toolchains with GCC-style
flags. Unfortunately, it's not clear how to condition on the compiler,
rather than the platform in Bazel, so we'll do the wrong thing on
non-MSVC Windows toolchains, but that was true before.
Bug: 542
Change-Id: I7330d8961145ae5714d4cad01259044230d96bcd
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/56465
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2 years ago
|
|
|
gcc_copts_c11 = [
|
|
|
|
"-std=c11",
|
|
|
|
"-Wmissing-prototypes",
|
|
|
|
"-Wold-style-definition",
|
|
|
|
"-Wstrict-prototypes",
|
|
|
|
]
|
Simplify the external Bazel build.
Now that all assembly files are conditionalized, we no longer need to
detect platforms at the build level. This is convenient because
detecting platforms in Bazel is a bit of a mess.
In particular, this reduces how much we depend on @platforms being
correct. gRPC's build appears to still be using some legacy modes which
seem cause it to, on cross-compiles, report the host's platforms rather
than the target. See https://github.com/grpc/grpc/pull/31938
gRPC should eventually fix this, but it is apparently challenging due
to complexities in migrating from Bazel's legacy system the new
"platforms" mechanism. Instead, try to sidestep this problem by not
relying on the build to do this.
Now, we primarily rely on os:windows being accurate, and cross-compiling
to/from Windows is uncommon. We do also need os:linux to be accurate
when Linux is the target OS, but if Linux is the host and gRPC mislabels
the target as os:linux, this is fine as long as the target is not
FreeBSD, Apple, or another platform that cares about _XOPEN_SOURCE. (In
particular, Android is ambivalent.)
I've also renamed a few things based on what they were actually
selecting. posix_copts was really copts for toolchains with GCC-style
flags. Unfortunately, it's not clear how to condition on the compiler,
rather than the platform in Bazel, so we'll do the wrong thing on
non-MSVC Windows toolchains, but that was true before.
Bug: 542
Change-Id: I7330d8961145ae5714d4cad01259044230d96bcd
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/56465
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2 years ago
|
|
|
gcc_copts_cxx = [
|
|
|
|
"-std=c++14",
|
|
|
|
"-Wmissing-declarations",
|
|
|
|
]
|
|
|
|
|
|
|
|
boringssl_copts = [
|
|
|
|
"-DBORINGSSL_IMPLEMENTATION",
|
|
|
|
] + select({
|
Simplify the external Bazel build.
Now that all assembly files are conditionalized, we no longer need to
detect platforms at the build level. This is convenient because
detecting platforms in Bazel is a bit of a mess.
In particular, this reduces how much we depend on @platforms being
correct. gRPC's build appears to still be using some legacy modes which
seem cause it to, on cross-compiles, report the host's platforms rather
than the target. See https://github.com/grpc/grpc/pull/31938
gRPC should eventually fix this, but it is apparently challenging due
to complexities in migrating from Bazel's legacy system the new
"platforms" mechanism. Instead, try to sidestep this problem by not
relying on the build to do this.
Now, we primarily rely on os:windows being accurate, and cross-compiling
to/from Windows is uncommon. We do also need os:linux to be accurate
when Linux is the target OS, but if Linux is the host and gRPC mislabels
the target as os:linux, this is fine as long as the target is not
FreeBSD, Apple, or another platform that cares about _XOPEN_SOURCE. (In
particular, Android is ambivalent.)
I've also renamed a few things based on what they were actually
selecting. posix_copts was really copts for toolchains with GCC-style
flags. Unfortunately, it's not clear how to condition on the compiler,
rather than the platform in Bazel, so we'll do the wrong thing on
non-MSVC Windows toolchains, but that was true before.
Bug: 542
Change-Id: I7330d8961145ae5714d4cad01259044230d96bcd
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/56465
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2 years ago
|
|
|
# We assume that non-Windows builds use a GCC-compatible toolchain and that
|
|
|
|
# Windows builds do not.
|
|
|
|
#
|
|
|
|
# TODO(davidben): Should these be querying something in @bazel_tools?
|
|
|
|
# Unfortunately, @bazel_tools is undocumented. See
|
|
|
|
# https://github.com/bazelbuild/bazel/issues/14914
|
|
|
|
"@platforms//os:windows": [],
|
|
|
|
"//conditions:default": gcc_copts,
|
|
|
|
}) + select({
|
|
|
|
# This is needed on glibc systems to get rwlock in pthreads, but it should
|
|
|
|
# not be set on Apple platforms or FreeBSD, where it instead disables APIs
|
|
|
|
# we use.
|
|
|
|
# See compat(5), sys/cdefs.h, and https://crbug.com/boringssl/471
|
|
|
|
"@platforms//os:linux": ["-D_XOPEN_SOURCE=700"],
|
|
|
|
# Without WIN32_LEAN_AND_MEAN, <windows.h> pulls in wincrypt.h, which
|
|
|
|
# conflicts with our <openssl/x509.h>.
|
|
|
|
"@platforms//os:windows": ["-DWIN32_LEAN_AND_MEAN"],
|
|
|
|
"//conditions:default": [],
|
Simplify the external Bazel build.
Now that all assembly files are conditionalized, we no longer need to
detect platforms at the build level. This is convenient because
detecting platforms in Bazel is a bit of a mess.
In particular, this reduces how much we depend on @platforms being
correct. gRPC's build appears to still be using some legacy modes which
seem cause it to, on cross-compiles, report the host's platforms rather
than the target. See https://github.com/grpc/grpc/pull/31938
gRPC should eventually fix this, but it is apparently challenging due
to complexities in migrating from Bazel's legacy system the new
"platforms" mechanism. Instead, try to sidestep this problem by not
relying on the build to do this.
Now, we primarily rely on os:windows being accurate, and cross-compiling
to/from Windows is uncommon. We do also need os:linux to be accurate
when Linux is the target OS, but if Linux is the host and gRPC mislabels
the target as os:linux, this is fine as long as the target is not
FreeBSD, Apple, or another platform that cares about _XOPEN_SOURCE. (In
particular, Android is ambivalent.)
I've also renamed a few things based on what they were actually
selecting. posix_copts was really copts for toolchains with GCC-style
flags. Unfortunately, it's not clear how to condition on the compiler,
rather than the platform in Bazel, so we'll do the wrong thing on
non-MSVC Windows toolchains, but that was true before.
Bug: 542
Change-Id: I7330d8961145ae5714d4cad01259044230d96bcd
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/56465
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2 years ago
|
|
|
}) + asm_copts
|
|
|
|
|
|
|
|
boringssl_copts_c11 = boringssl_copts + select({
|
|
|
|
"@platforms//os:windows": ["/std:c11"],
|
Simplify the external Bazel build.
Now that all assembly files are conditionalized, we no longer need to
detect platforms at the build level. This is convenient because
detecting platforms in Bazel is a bit of a mess.
In particular, this reduces how much we depend on @platforms being
correct. gRPC's build appears to still be using some legacy modes which
seem cause it to, on cross-compiles, report the host's platforms rather
than the target. See https://github.com/grpc/grpc/pull/31938
gRPC should eventually fix this, but it is apparently challenging due
to complexities in migrating from Bazel's legacy system the new
"platforms" mechanism. Instead, try to sidestep this problem by not
relying on the build to do this.
Now, we primarily rely on os:windows being accurate, and cross-compiling
to/from Windows is uncommon. We do also need os:linux to be accurate
when Linux is the target OS, but if Linux is the host and gRPC mislabels
the target as os:linux, this is fine as long as the target is not
FreeBSD, Apple, or another platform that cares about _XOPEN_SOURCE. (In
particular, Android is ambivalent.)
I've also renamed a few things based on what they were actually
selecting. posix_copts was really copts for toolchains with GCC-style
flags. Unfortunately, it's not clear how to condition on the compiler,
rather than the platform in Bazel, so we'll do the wrong thing on
non-MSVC Windows toolchains, but that was true before.
Bug: 542
Change-Id: I7330d8961145ae5714d4cad01259044230d96bcd
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/56465
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2 years ago
|
|
|
"//conditions:default": gcc_copts_c11,
|
|
|
|
})
|
|
|
|
|
|
|
|
boringssl_copts_cxx = boringssl_copts + select({
|
|
|
|
"@platforms//os:windows": [],
|
|
|
|
"//conditions:default": gcc_copts_cxx,
|
|
|
|
})
|
|
|
|
|
|
|
|
cc_library(
|
|
|
|
name = "crypto",
|
Simplify the external Bazel build.
Now that all assembly files are conditionalized, we no longer need to
detect platforms at the build level. This is convenient because
detecting platforms in Bazel is a bit of a mess.
In particular, this reduces how much we depend on @platforms being
correct. gRPC's build appears to still be using some legacy modes which
seem cause it to, on cross-compiles, report the host's platforms rather
than the target. See https://github.com/grpc/grpc/pull/31938
gRPC should eventually fix this, but it is apparently challenging due
to complexities in migrating from Bazel's legacy system the new
"platforms" mechanism. Instead, try to sidestep this problem by not
relying on the build to do this.
Now, we primarily rely on os:windows being accurate, and cross-compiling
to/from Windows is uncommon. We do also need os:linux to be accurate
when Linux is the target OS, but if Linux is the host and gRPC mislabels
the target as os:linux, this is fine as long as the target is not
FreeBSD, Apple, or another platform that cares about _XOPEN_SOURCE. (In
particular, Android is ambivalent.)
I've also renamed a few things based on what they were actually
selecting. posix_copts was really copts for toolchains with GCC-style
flags. Unfortunately, it's not clear how to condition on the compiler,
rather than the platform in Bazel, so we'll do the wrong thing on
non-MSVC Windows toolchains, but that was true before.
Bug: 542
Change-Id: I7330d8961145ae5714d4cad01259044230d96bcd
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/56465
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2 years ago
|
|
|
srcs = crypto_sources + crypto_internal_headers + asm_sources,
|
|
|
|
hdrs = crypto_headers + fips_fragments,
|
|
|
|
copts = boringssl_copts_c11,
|
|
|
|
includes = ["src/include"],
|
|
|
|
linkopts = select({
|
|
|
|
"@platforms//os:windows": ["-defaultlib:advapi32.lib"],
|
Use -pthread instead of -lpthread in Bazel.
This seems to work more reliably across platforms. Actually, both seem
to work on Apple platforms, so we probably didn't need the conditions,
while Android seems to only accept -pthread, based on [1].
This also matches Abseil [2], Envoy [3], and a random example in Bazel
documentation [4].
Though, as a counter-example, POSIX seems to prefer -lpthread, not
-pthread, per [5].
[1] https://github.com/grpc/grpc/pull/31938#issuecomment-1370024585
[2] https://github.com/abseil/abseil-cpp/blob/625a18016d6208c6c0419697cb6caa3f23ce31bc/absl/base/BUILD.bazel#L185
[3] https://github.com/envoyproxy/envoy/blob/main/bazel/envoy_binary.bzl#L72
[4] https://bazel.build/tutorials/cpp-use-cases#include-external-libraries
[5] https://github.com/gflags/gflags/issues/176#issuecomment-252243506
Change-Id: I15005bcf4e4b7ebe91a835b8262c5c6434715c3b
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/55927
Auto-Submit: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2 years ago
|
|
|
"//conditions:default": ["-pthread"],
|
|
|
|
}),
|
|
|
|
visibility = ["//visibility:public"],
|
|
|
|
)
|
|
|
|
|
|
|
|
cc_library(
|
|
|
|
name = "ssl",
|
|
|
|
srcs = ssl_sources + ssl_internal_headers,
|
|
|
|
hdrs = ssl_headers,
|
|
|
|
copts = boringssl_copts_cxx,
|
|
|
|
includes = ["src/include"],
|
|
|
|
visibility = ["//visibility:public"],
|
|
|
|
deps = [
|
|
|
|
":crypto",
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
|
|
|
cc_binary(
|
|
|
|
name = "bssl",
|
|
|
|
srcs = tool_sources + tool_headers,
|
|
|
|
copts = boringssl_copts_cxx,
|
|
|
|
visibility = ["//visibility:public"],
|
|
|
|
deps = [":ssl"],
|
|
|
|
)
|