summaryrefslogtreecommitdiff
path: root/sal
diff options
context:
space:
mode:
authorTor Lillqvist <tml@collabora.com>2020-08-09 10:51:22 +0100
committerTor Lillqvist <tml@collabora.com>2020-11-15 10:42:34 +0100
commit3a36922aa824e3800da08f21bd1acab0cda56d60 (patch)
treec2a8cb913454d348421d24ae91df580fd1500832 /sal
parentce8291f5c9cf3742766d5d32e146dbbea7b5c3bc (diff)
Make the C++/UNO bridge work to some extent on macOS on arm64
Use the same code as for Linux on aarch64, with minor additional hacks. But that will not actually work in all cases, as there are slight differences in the ABI. See https://developer.apple.com/library/archive/documentation/Xcode/Conceptual/iPhoneOSABIReference/Articles/ARM64FunctionCallingConventions.html Thus we can drop the use of the lo_mobile_throwException() hack that was very temporarily used. The run-time code generation requires use of a new API on macOS to work: See the use of pthread_jit_write_protect_np() in bridges/source/cpp_uno/shared/vtablefactory.cxx. For some reason, with the Xcode 12 betas, when compiling for arm64-apple-macos, the symbols for the type_infos for the UNO exception types (_ZTIN3com3sun4star3uno16RuntimeExceptionE etc) end up as "weak private external" in the object file, as displayed by "nm -f darwin". We try to look them up with dlsym(), but that then fails. So use a gross hack: Introduce separate real variables that point to these typeinfos, and look up and dereference them instead. If this hack ends up needing to be permanent, instead of having a manually edited set of such pointer variables, we should teach codemaker to generate corresponding functions, and look up and invoke them to get the std::type_info pointer. When compiling for x86_64-apple-macos, the type_info symbols end up as "weak external" which is fine. With this, LibreOffice starts and seems to work to some extent, and many unit tests succeed. Change-Id: I05f46a122a51ade1ac7dccd57cb90e594547740e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100408 Tested-by: Jenkins Reviewed-by: Tor Lillqvist <tml@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105880 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Diffstat (limited to 'sal')
-rw-r--r--sal/osl/unx/salinit.cxx8
1 files changed, 6 insertions, 2 deletions
diff --git a/sal/osl/unx/salinit.cxx b/sal/osl/unx/salinit.cxx
index 9424089dbba0..c3ac48c575d1 100644
--- a/sal/osl/unx/salinit.cxx
+++ b/sal/osl/unx/salinit.cxx
@@ -1,3 +1,4 @@
+#include <sal/log.hxx>
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
@@ -22,6 +23,7 @@
#include <sal/config.h>
#if defined MACOSX
+#include <algorithm>
#include <cassert>
#include <limits>
#include <unistd.h>
@@ -71,8 +73,10 @@ void sal_detail_initialize(int argc, char ** argv) {
// Some random value, but hopefully sysconf never returns -1 anyway:
openMax = 1024;
}
- assert(openMax >= 0 && openMax <= std::numeric_limits< int >::max());
- for (int fd = 3; fd < int(openMax); ++fd) {
+ // When LibreOffice restarts itself on macOS 11 beta on arm64, for
+ // some reason sysconf(_SC_OPEN_MAX) returns 0x7FFFFFFFFFFFFFFF,
+ // so use a sanity limit here.
+ for (int fd = 3; fd < std::min(100000l, openMax); ++fd) {
struct stat s;
if (fstat(fd, &s) != -1 && S_ISREG(s.st_mode))
close(fd);