From dc1c2f0db6c8b61ff16a82f2b9bbfda7d85e3e7c Mon Sep 17 00:00:00 2001 From: David Benjamin Date: Thu, 24 Aug 2023 14:23:25 -0400 Subject: [PATCH] Also suppress OPENSSL_LINUX for nanolibc Where the Trusty and Android baremetal cases are unambiguously mistakes in their respective builds, nanolibc is a bit more interesting. nanolibc sometimes build for a non-Linux target (which should not define __linux__), but also sometimes build for Linux. Although technically running in Linux userspace, this lacks all the libc APIs we'd normally expect on Linux, so we treat it as a non-Linux target. Change-Id: Id36f6bbc6e790d96e31193532717630a86f124b8 Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/62685 Commit-Queue: David Benjamin Commit-Queue: Adam Langley Reviewed-by: Adam Langley Auto-Submit: David Benjamin --- include/openssl/target.h | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/include/openssl/target.h b/include/openssl/target.h index 53d7f15b6..12736416f 100644 --- a/include/openssl/target.h +++ b/include/openssl/target.h @@ -70,13 +70,18 @@ #define OPENSSL_WINDOWS #endif -// Trusty and Android baremetal aren't't Linux but currently define __linux__. -// As a workaround, we exclude them here. +// Trusty and Android baremetal aren't Linux but currently define __linux__. +// As a workaround, we exclude them here. We also exclude nanolibc. nanolibc +// sometimes build for a non-Linux target (which should not define __linux__), +// but also sometimes build for Linux. Although technically running in Linux +// userspace, this lacks all the libc APIs we'd normally expect on Linux, so we +// treat it as a non-Linux target. // // TODO(b/169780122): Remove this workaround once Trusty no longer defines it. // TODO(b/291101350): Remove this workaround once Android baremetal no longer // defines it. -#if defined(__linux__) && !defined(__TRUSTY__) && !defined(ANDROID_BAREMETAL) +#if defined(__linux__) && !defined(__TRUSTY__) && \ + !defined(ANDROID_BAREMETAL) && !defined(OPENSSL_NANOLIBC) #define OPENSSL_LINUX #endif