Skip to content

Commit 3eedf4e

Browse files
authored
examples: more minor fixes (#1503)
1. disable apr_util from finding postgres on the host system. 2. bump gn to a new version that honors the request to disable git 3. bump gperftools to a new version so it builds with a modern toolchain (it was using functions that were removed in c++11). Unfortunately, it now targets c++17, whereas bazel 7's cc toolchain forces c++14 by default, so override that with copts and also work around the new gtest problems. Also, reenable the malloc test since that appears to work now. (whew) 4. Fix pcre on windows, and disable some host deps there too (it was finding zlib and bzip2 from the host; point zlib at the example one, and disable bzip2).
1 parent ac25ea8 commit 3eedf4e

7 files changed

Lines changed: 40 additions & 15 deletions

File tree

docs/WORKSPACE.bzlmod

Whitespace-only changes.

examples/third_party/apr_util/BUILD.apr_util.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ configure_make(
1414
configure_options = [
1515
"--with-apr=$$EXT_BUILD_DEPS/apr",
1616
"--with-expat=$$EXT_BUILD_DEPS/expat",
17+
"--without-pgsql",
1718
],
1819
env = select({
1920
"@platforms//os:macos": {"AR": ""},

examples/third_party/gn/gn_repositories.bzl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ def gn_repositories():
88
new_git_repository,
99
name = "gn",
1010
build_file = Label("//gn:BUILD.gn.bazel"),
11-
commit = "dfcbc6fed0a8352696f92d67ccad54048ad182b3",
11+
commit = "281ba2c91861b10fec7407c4b6172ec3d4661243",
1212
patch_args = [],
1313
patch_tool = "bash",
1414
patches = [Label("//gn:patch.gen_ninja.sh")],
1515
remote = "https://gn.googlesource.com/gn",
16-
shallow_since = "1612864120 +0000",
16+
shallow_since = "1639743738 +0000",
1717
)

examples/third_party/gperftools/BUILD.bazel

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
11
load("@bazel_skylib//rules:build_test.bzl", "build_test")
22
# load("@rules_cc//cc:defs.bzl", "cc_test")
33

4+
load("@rules_cc//cc:defs.bzl", "cc_test")
5+
46
exports_files(
57
[
68
"BUILD.gperftools.bazel",
79
],
810
visibility = ["//visibility:public"],
911
)
1012

11-
# TODO(rules_foreign_cc#227) This currently gives an error:
12-
# "ERROR: <...>/use_malloc/BUILD:17:14: in malloc attribute of cc_test rule //:test:
13-
# configure_make rule '@gperftools//:gperftools_build' is misplaced here (expected cc_library)"
14-
# cc_test(
15-
# name = "malloc_test",
16-
# srcs = ["malloc_test.cpp"],
17-
# malloc = "@gperftools//:gperftools_build",
18-
# )
13+
cc_test(
14+
name = "malloc_test",
15+
srcs = ["malloc_test.cc"],
16+
malloc = "@gperftools//:gperftools_build",
17+
)
1918

2019
build_test(
2120
name = "build_test",

examples/third_party/gperftools/BUILD.gperftools.bazel

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ configure_make(
1515
"--enable-frame-pointers",
1616
"--disable-libunwind",
1717
],
18+
copts = [
19+
# This package requires c++17, and bazel 7.x's default BAZEL_CXXOPTS is
20+
# set to -std=c++14, so override.
21+
"-std=c++17",
22+
],
1823
env = select({
1924
"@platforms//os:macos": {"AR": ""},
2025
"//conditions:default": {},
@@ -26,5 +31,14 @@ configure_make(
2631
"@platforms//os:windows": ["@platforms//:incompatible"],
2732
"//conditions:default": [],
2833
}),
34+
targets = [
35+
# Something is wrong about the project's gtest wiring, resulting in
36+
# unittests failing to build due to being unable to find gtest.h. They
37+
# don't provide any official method to bypass building the tests, so
38+
# work around it by calling the make targets we require directly.
39+
"install-libLTLIBRARIES",
40+
"install-perftoolsincludeHEADERS",
41+
"install-nodist_perftoolsincludeHEADERS",
42+
],
2943
visibility = ["//visibility:public"],
3044
)

examples/third_party/gperftools/gperftools_repositories.bzl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ def gperftools_repositories():
88
http_archive,
99
name = "gperftools",
1010
build_file = Label("//gperftools:BUILD.gperftools.bazel"),
11-
sha256 = "1ee8c8699a0eff6b6a203e59b43330536b22bbcbe6448f54c7091e5efb0763c9",
12-
strip_prefix = "gperftools-2.7",
13-
urls = ["https://github.com/gperftools/gperftools/releases/download/gperftools-2.7/gperftools-2.7.tar.gz"],
11+
sha256 = "f12624af5c5987f2cc830ee534f754c3c5961eec08004c26a8b80de015cf056f",
12+
strip_prefix = "gperftools-2.16",
13+
urls = ["https://github.com/gperftools/gperftools/releases/download/gperftools-2.16/gperftools-2.16.tar.gz"],
1414
)

examples/third_party/pcre/BUILD.pcre.bazel

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,18 @@ filegroup(
1515
cmake(
1616
name = "pcre",
1717
cache_entries = {
18-
"CMAKE_C_FLAGS": "$${CMAKE_C_FLAGS:-} -fPIC",
19-
},
18+
"CMAKE_DISABLE_FIND_PACKAGE_BZip2": "TRUE",
19+
"PCRE2_SUPPORT_LIBZ": "ON",
20+
} | select({
21+
"@platforms//os:windows": {
22+
# PCRE2 adds a "d" postfix for MSVC debug builds by default; keep the
23+
# archive name stable so Bazel can locate the declared output.
24+
"CMAKE_DEBUG_POSTFIX": "",
25+
},
26+
"//conditions:default": {
27+
"CMAKE_C_FLAGS": "$${CMAKE_C_FLAGS:-} -fPIC",
28+
},
29+
}),
2030
lib_source = ":all_srcs",
2131
out_static_libs = select({
2232
"@platforms//os:windows": ["pcre2-8.lib"],
@@ -26,6 +36,7 @@ cmake(
2636
"@platforms//os:windows": ["@rules_foreign_cc_examples_third_party//:broken"],
2737
"//conditions:default": [],
2838
}),
39+
deps = ["@examples_zlib//:zlib"],
2940
)
3041

3142
filegroup(

0 commit comments

Comments
 (0)