diff options
author | Tor Lillqvist <tml@collabora.com> | 2020-08-09 10:51:22 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2020-11-24 10:09:00 +0100 |
commit | 8ff60753d11be4d0c51fa7b362e0adc73d5fb7e0 (patch) | |
tree | 5a96d8806c0be1d1a68f6bbe2c5a25cbe0c7ce99 /sal | |
parent | 0516e495272c9aeff325d595e7f92e11c7ab8b47 (diff) |
Make the C++/UNO bridge work on macOS on arm64
Use the same code as for Linux on aarch64, with minor additional
hacks. (There are slight differences in the ABI. See
https://developer.apple.com/library/archive/documentation/Xcode/Conceptual/iPhoneOSABIReference/Articles/ARM64FunctionCallingConventions.html
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.
Unlike the arm64 ABI used on Linux, on macOS (and iOS, but we don't
really use the C++/UNO bridge for iOS) we need to pack parameters
smaller than eight bytes according to their natural alignment. Bytes
take one byte, shorts two bytes aligned at a two-byte boundary, etc.
For some reason, 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.
(This is a combination of what was two patches in master.)
Change-Id: I05f46a122a51ade1ac7dccd57cb90e594547740e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106465
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sal')
-rw-r--r-- | sal/osl/unx/salinit.cxx | 8 |
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); |