|
| 1 | +From 72186018e974398dfadc1b0825ac22e45920ddf3 Mon Sep 17 00:00:00 2001 |
| 2 | +From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= <berrange@redhat.com> |
| 3 | +Date: Mon, 24 Jun 2024 17:36:13 +0100 |
| 4 | +Subject: [PATCH] enclave_common: add missing <algorithm> header for GCC 14 |
| 5 | + compat |
| 6 | +MIME-Version: 1.0 |
| 7 | +Content-Type: text/plain; charset=UTF-8 |
| 8 | +Content-Transfer-Encoding: 8bit |
| 9 | + |
| 10 | +When building with GCC 14, various c++ stdlib functions are undefined: |
| 11 | + |
| 12 | +sgx_enclave_common.cpp: In function ‘void* get_enclave_base_address_from_address(void*)’: |
| 13 | +sgx_enclave_common.cpp:164:23: error: ‘upper_bound’ is not a member of ‘std’; did you mean ‘lower_bound’? |
| 14 | + 164 | auto upper = std::upper_bound(s_enclave_base_address.begin(), s_enclave_base_address.end(), (uint64_t)target_address); |
| 15 | + | ^~~~~~~~~~~ |
| 16 | + | lower_bound |
| 17 | +sgx_enclave_common.cpp: In function ‘void* enclave_create_ex(void*, size_t, size_t, uint32_t, const void*, size_t, uint32_t, const void**, uint32_t*)’: |
| 18 | +sgx_enclave_common.cpp:790:14: error: ‘sort’ is not a member of ‘std’; did you mean ‘qsort’? |
| 19 | + 790 | std::sort(s_enclave_base_address.begin(), s_enclave_base_address.end()); |
| 20 | + | ^~~~ |
| 21 | + | qsort |
| 22 | +sgx_enclave_common.cpp: In function ‘bool enclave_delete(void*, uint32_t*)’: |
| 23 | +sgx_enclave_common.cpp:1255:43: error: ‘remove’ is not a member of ‘std’; did you mean ‘move’? |
| 24 | + 1255 | s_enclave_base_address.erase(std::remove(s_enclave_base_address.begin(), s_enclave_base_address.end(), (uint64_t)base_address), |
| 25 | + | ^~~~~~ |
| 26 | + | move |
| 27 | + |
| 28 | +These stdlib functions are provided by bits/stl_algo.h, and prior |
| 29 | +to GCC 14, the <functional> header would pull in stl_algo.h. |
| 30 | + |
| 31 | +With GCC 14, the <functional> header was changed to only pull in |
| 32 | +stl_algobase.h. |
| 33 | + |
| 34 | +We must now use <algorithm> to get these definitions, which should |
| 35 | +work on all versions of GCC. |
| 36 | + |
| 37 | +Signed-off-by: Daniel P. Berrangé <berrange@redhat.com> |
| 38 | +--- |
| 39 | + psw/enclave_common/sgx_enclave_common.cpp | 1 + |
| 40 | + 1 file changed, 1 insertion(+) |
| 41 | + |
| 42 | +diff --git a/psw/enclave_common/sgx_enclave_common.cpp b/psw/enclave_common/sgx_enclave_common.cpp |
| 43 | +index 9867ecc86..46fcf8733 100644 |
| 44 | +--- a/psw/enclave_common/sgx_enclave_common.cpp |
| 45 | ++++ b/psw/enclave_common/sgx_enclave_common.cpp |
| 46 | +@@ -35,6 +35,7 @@ |
| 47 | + #include <dlfcn.h> |
| 48 | + #include <map> |
| 49 | + #include <functional> |
| 50 | ++#include <algorithm> |
| 51 | + #include "sgx_enclave_common.h" |
| 52 | + #include "sgx_urts.h" |
| 53 | + #include "arch.h" |
0 commit comments