Skip to content

Commit f8606e5

Browse files
rbeasleycopybara-github
authored andcommitted
linux-sandbox: don't assume -lrt, -D__STDC_FORMAT_MACROS
Resolves bazelbuild#12327. Closes bazelbuild#12662. PiperOrigin-RevId: 346374211
1 parent ace6652 commit f8606e5

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

src/main/tools/BUILD

+15-2
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,11 @@ cc_binary(
4141
}),
4242
linkopts = select({
4343
"//src/conditions:windows": [],
44-
"//conditions:default": ["-lm"],
44+
"//src/conditions:darwin": ["-lm"],
45+
"//conditions:default": [
46+
"-lm",
47+
"-lrt",
48+
],
4549
}),
4650
deps = select({
4751
"//src/conditions:windows": [],
@@ -86,7 +90,16 @@ cc_binary(
8690
"linux-sandbox-pid1.h",
8791
],
8892
}),
89-
linkopts = ["-lm"],
93+
linkopts = select({
94+
"//src/conditions:darwin": [],
95+
"//src/conditions:freebsd": [],
96+
"//src/conditions:openbsd": [],
97+
"//src/conditions:windows": [],
98+
"//conditions:default": [
99+
"-lm",
100+
"-lrt",
101+
],
102+
}),
90103
deps = select({
91104
"//src/conditions:darwin": [],
92105
"//src/conditions:freebsd": [],

src/main/tools/logging.h

+4
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515
#ifndef SRC_MAIN_TOOLS_LOGGING_H_
1616
#define SRC_MAIN_TOOLS_LOGGING_H_
1717

18+
// See https://stackoverflow.com/a/8132440 .
19+
#ifndef __STDC_FORMAT_MACROS
20+
#define __STDC_FORMAT_MACROS
21+
#endif
1822
#include <inttypes.h>
1923
#include <stdint.h>
2024
#include <stdio.h>

0 commit comments

Comments
 (0)