From a07b84598f8f10e356eb4de38a2c61f94bedcf85 Mon Sep 17 00:00:00 2001 From: Dan Albert Date: Thu, 11 Jan 2018 13:00:46 -0800 Subject: [PATCH] Disable availability macros in libc++ on Darwin. libc++'s headers are annotated with availability macros that indicate which version of Mac OS was the first to ship with a libc++ feature available in its *system's* libc++.dylib. We do not use the system's library, but rather ship our own. As such, these availability attributes are meaningless for us but cause build breaks when we try to use code that would not be available in the system's dylib. Test: removed the darwin check and checked showcommands on linux Bug: None Change-Id: I3d328d7363eba83f1cb857c8abfd6cd0173a3058 --- cc/stl.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/cc/stl.go b/cc/stl.go index c65f1c2f5..c5757cd06 100644 --- a/cc/stl.go +++ b/cc/stl.go @@ -144,6 +144,19 @@ func (stl *stl) flags(ctx ModuleContext, flags Flags) Flags { switch stl.Properties.SelectedStl { case "libc++", "libc++_static": flags.CFlags = append(flags.CFlags, "-D_USING_LIBCXX") + + if ctx.Darwin() { + // libc++'s headers are annotated with availability macros that + // indicate which version of Mac OS was the first to ship with a + // libc++ feature available in its *system's* libc++.dylib. We do + // not use the system's library, but rather ship our own. As such, + // these availability attributes are meaningless for us but cause + // build breaks when we try to use code that would not be available + // in the system's dylib. + flags.CppFlags = append(flags.CppFlags, + "-D_LIBCPP_DISABLE_AVAILABILITY") + } + if !ctx.toolchain().Bionic() { flags.CppFlags = append(flags.CppFlags, "-nostdinc++") flags.LdFlags = append(flags.LdFlags, "-nodefaultlibs")