Skip to content

Commit 2313549

Browse files
committed
devel/corrade: fix build on aarch64, missing FreeBSD code
- add CPU detection code for armv7, aarch64 (armv7 is still broken for other reasons) - add missing FreeBSD support code for executableLocation() - hook up test suite See also: mosra/corrade#171 Approved by: yuri (maintainer) Differential Revision: https://reviews.freebsd.org/D40202
1 parent fc8585d commit 2313549

File tree

4 files changed

+109
-1
lines changed

4 files changed

+109
-1
lines changed

devel/corrade/Makefile

+4-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ WWW= https://magnum.graphics/corrade/
1111
LICENSE= MIT
1212
LICENSE_FILE= ${WRKSRC}/COPYING
1313

14-
USES= cmake compiler:c++14-lang
14+
USES= cmake:testing compiler:c++14-lang
1515
USE_LDCONFIG= yes
1616

1717
USE_GITHUB= yes
@@ -20,4 +20,7 @@ GH_TUPLE= mosra:toolchains:65568a9:toolchains/toolchains
2020

2121
CMAKE_ARGS= -DLIB_SUFFIX:STRING=""
2222

23+
OPTIONS_DEFINE= TEST
24+
TEST_CMAKE_BOOL= CORRADE_BUILD_TESTS
25+
2326
.include <bsd.port.mk>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
--- src/Corrade/Cpu.cpp.orig 2023-05-22 11:59:16 UTC
2+
+++ src/Corrade/Cpu.cpp
3+
@@ -34,7 +34,7 @@
4+
/** @todo these are indented to work around acme.py extracting them to the top,
5+
fix properly */
6+
/* getauxval() for ARM on Linux and Android with API level 18+ */
7+
-#if defined(CORRADE_TARGET_ARM) && defined(__linux__) && !(defined(CORRADE_TARGET_ANDROID) && __ANDROID_API__ < 18)
8+
+#if defined(CORRADE_TARGET_ARM) && (defined(__linux__) && !(defined(CORRADE_TARGET_ANDROID) && __ANDROID_API__ < 18) || defined(__FreeBSD__))
9+
#include <sys/auxv.h>
10+
/* sysctlbyname() for ARM on macOS / iOS */
11+
#elif defined(CORRADE_TARGET_ARM) && defined(CORRADE_TARGET_APPLE)
12+
@@ -80,7 +80,7 @@ int appleSysctlByName(const char* name) {
13+
}
14+
#endif
15+
16+
-#if defined(CORRADE_TARGET_ARM) && ((defined(__linux__) && !(defined(CORRADE_TARGET_ANDROID) && __ANDROID_API__ < 18)) || defined(CORRADE_TARGET_APPLE))
17+
+#if defined(CORRADE_TARGET_ARM) && ((defined(__linux__) && !(defined(CORRADE_TARGET_ANDROID) && __ANDROID_API__ < 18)) || defined(CORRADE_TARGET_APPLE) || defined(__FreeBSD__))
18+
Features runtimeFeatures() {
19+
/* Use getauxval() on ARM on Linux and Android */
20+
#if defined(CORRADE_TARGET_ARM) && defined(__linux__) && !(defined(CORRADE_TARGET_ANDROID) && __ANDROID_API__ < 18)
21+
@@ -130,6 +130,13 @@ Features runtimeFeatures() {
22+
/* No other (deinlined) implementation at the moment. The function should
23+
not be even defined here in that case -- it's inlined in the header
24+
instead, including the x86 implementation. */
25+
+ #elif defined(CORRADE_TARGET_ARM) && defined(__FreeBSD__)
26+
+ /* use elf_aux_info() on ARM on FreeBSD */
27+
+ unsigned long hwcap = 0;
28+
+
29+
+ elf_aux_info(AT_HWCAP, &hwcap, sizeof hwcap);
30+
+
31+
+ return Implementation::runtimeFeatures(hwcap);
32+
#else
33+
#error
34+
#endif
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
--- src/Corrade/Cpu.h.orig 2023-05-22 12:04:59 UTC
2+
+++ src/Corrade/Cpu.h
3+
@@ -1357,7 +1357,7 @@ equivalent:
4+
*/
5+
template<class T> constexpr T tag() { return T{Implementation::Init}; }
6+
7+
-#if defined(CORRADE_TARGET_ARM) && defined(__linux__) && !(defined(CORRADE_TARGET_ANDROID) && __ANDROID_API__ < 18)
8+
+#if defined(CORRADE_TARGET_ARM) && (defined(__linux__) && !(defined(CORRADE_TARGET_ANDROID) && __ANDROID_API__ < 18) || defined(__FreeBSD__))
9+
namespace Implementation {
10+
/* Needed for a friend declaration, implementation is at the very end of
11+
the header */
12+
@@ -1496,7 +1496,7 @@ class Features {
13+
#endif
14+
Features runtimeFeatures();
15+
#endif
16+
- #if defined(CORRADE_TARGET_ARM) && defined(__linux__) && !(defined(CORRADE_TARGET_ANDROID) && __ANDROID_API__ < 18)
17+
+ #if defined(CORRADE_TARGET_ARM) && (defined(__linux__) && !(defined(CORRADE_TARGET_ANDROID) && __ANDROID_API__ < 18) || defined(__FreeBSD__))
18+
friend Features Implementation::runtimeFeatures(unsigned long);
19+
#endif
20+
21+
@@ -1775,7 +1775,7 @@ value is equal to @ref Scalar, which in turn is equiva
22+
default-constructed) @ref Features.
23+
@see @ref DefaultBase, @ref DefaultExtra, @ref Default
24+
*/
25+
-#if (defined(CORRADE_TARGET_X86) && (defined(CORRADE_TARGET_MSVC) || defined(CORRADE_TARGET_GCC))) || (defined(CORRADE_TARGET_ARM) && ((defined(__linux__) && !(defined(CORRADE_TARGET_ANDROID) && __ANDROID_API__ < 18)) || defined(CORRADE_TARGET_APPLE))) || defined(DOXYGEN_GENERATING_OUTPUT)
26+
+#if (defined(CORRADE_TARGET_X86) && (defined(CORRADE_TARGET_MSVC) || defined(CORRADE_TARGET_GCC))) || (defined(CORRADE_TARGET_ARM) && ((defined(__linux__) && !(defined(CORRADE_TARGET_ANDROID) && __ANDROID_API__ < 18)) || defined(CORRADE_TARGET_APPLE) || defined(__FreeBSD__))) || defined(DOXYGEN_GENERATING_OUTPUT)
27+
#ifdef CORRADE_TARGET_ARM
28+
CORRADE_UTILITY_EXPORT /* Inlined on x86 at the very end of the header */
29+
#endif
30+
@@ -3214,7 +3214,7 @@ inline Features runtimeFeatures() {
31+
/** @todo If AT_HWCAP2 or other bits are needed, it's passed to ifunc resolvers
32+
only since glibc 2.30 (and Android API 30+, which is the same as before):
33+
https://github.com/bminor/glibc/commit/2b8a3c86e7606cf1b0a997dad8af2d45ae8989c3 */
34+
-#if defined(CORRADE_TARGET_ARM) && defined(__linux__) && !(defined(CORRADE_TARGET_ANDROID) && __ANDROID_API__ < 18)
35+
+#if defined(CORRADE_TARGET_ARM) && (defined(__linux__) && !(defined(CORRADE_TARGET_ANDROID) && __ANDROID_API__ < 18) || defined(__FreeBSD__))
36+
namespace Implementation {
37+
inline Features runtimeFeatures(const unsigned long caps) {
38+
unsigned int out = 0;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
--- src/Corrade/Utility/Path.cpp.orig 2023-01-12 11:52:02 UTC
2+
+++ src/Corrade/Utility/Path.cpp
3+
@@ -89,6 +89,11 @@
4+
#include <io.h>
5+
#endif
6+
7+
+#ifdef __FreeBSD__
8+
+#include <sys/types.h>
9+
+#include <sys/sysctl.h>
10+
+#endif
11+
+
12+
#include "Corrade/configure.h"
13+
#include "Corrade/Containers/Array.h"
14+
#include "Corrade/Containers/GrowableArray.h"
15+
@@ -540,6 +545,18 @@ Containers::Optional<Containers::String> executableLoc
16+
/* hardcoded for Emscripten */
17+
#elif defined(CORRADE_TARGET_EMSCRIPTEN)
18+
return Containers::String{"/app.js"_s};
19+
+
20+
+ #elif defined(__FreeBSD__)
21+
+ Containers::Array<char> path;
22+
+ size_t size;
23+
+ const int mib[4] = { CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1 };
24+
+
25+
+ sysctl(mib, 4, nullptr, &size, NULL, 0);
26+
+ arrayResize(path, NoInit, size + 1);
27+
+ sysctl(mib, 4, path, &size, NULL, 0);
28+
+ path[size] = '\0';
29+
+ const auto deleter = path.deleter();
30+
+ return Containers::String{path.release(), size, deleter};
31+
32+
/* Not implemented */
33+
#else

0 commit comments

Comments
 (0)