From 2d86729d7dc8be16d2080428298154cbe2925f4b Mon Sep 17 00:00:00 2001 From: Ryan Beasley Date: Tue, 20 Oct 2020 11:40:09 -0700 Subject: [PATCH] linux-sandbox: don't assume -lrt, -D__STDC_FORMAT_MACROS Resolves #12327. --- src/main/tools/BUILD | 11 +++++++++-- src/main/tools/logging.h | 4 ++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/main/tools/BUILD b/src/main/tools/BUILD index 9f64e096a88349..4737ed08a83791 100644 --- a/src/main/tools/BUILD +++ b/src/main/tools/BUILD @@ -41,7 +41,8 @@ cc_binary( }), linkopts = select({ "//src/conditions:windows": [], - "//conditions:default": ["-lm"], + "//src/conditions:darwin": ["-lm"], + "//conditions:default": ["-lm", "-lrt"], }), deps = select({ "//src/conditions:windows": [], @@ -86,7 +87,13 @@ cc_binary( "linux-sandbox-pid1.h", ], }), - linkopts = ["-lm"], + linkopts = select({ + "//src/conditions:darwin": [], + "//src/conditions:freebsd": [], + "//src/conditions:openbsd": [], + "//src/conditions:windows": [], + "//conditions:default": ["-lm", "-lrt"], + }), deps = select({ "//src/conditions:darwin": [], "//src/conditions:freebsd": [], diff --git a/src/main/tools/logging.h b/src/main/tools/logging.h index c3abe35e231758..14b46c92561b10 100644 --- a/src/main/tools/logging.h +++ b/src/main/tools/logging.h @@ -15,6 +15,10 @@ #ifndef SRC_MAIN_TOOLS_LOGGING_H_ #define SRC_MAIN_TOOLS_LOGGING_H_ +// See https://stackoverflow.com/a/8132440 . +#ifndef __STDC_FORMAT_MACROS +#define __STDC_FORMAT_MACROS +#endif #include #include #include