How to compile for macOS M1 (Apple Silicon)? #33

Closed
opened 2021-09-23 23:37:00 +00:00 by unserialize · 2 comments
unserialize commented 2021-09-23 23:37:00 +00:00 (Migrated from github.com)

I have no idea, how to compile this :(
I tried make, but with no luck.
I tried meson, just

meson builddir && cd builddir
meson compile

With no luck either:

../include/libucontext/bits.h:8:9: error: unknown type name 'greg_t'
typedef greg_t libucontext_greg_t;
        ^
../include/libucontext/bits.h:9:9: error: unknown type name 'ucontext_t'
typedef ucontext_t libucontext_ucontext_t;
        ^
../arch/aarch64/makecontext.c:24:16: error: offsetof requires struct, union, or class type, 'libucontext_ucontext_t' (aka 'int') invalid
_Static_assert(offsetof(libucontext_ucontext_t, uc_mcontext.regs[0]) == R0_OFFSET, "R0_OFFSET is invalid");
               ^        ~~~~~~~~~~~~~~~~~~~~~~
/Library/Developer/CommandLineTools/usr/lib/clang/13.0.0/include/stddef.h:104:24: note: expanded from macro 'offsetof'
#define offsetof(t, d) __builtin_offsetof(t, d)
                       ^                  ~
../arch/aarch64/makecontext.c:25:16: error: offsetof requires struct, union, or class type, 'libucontext_ucontext_t' (aka 'int') invalid
_Static_assert(offsetof(libucontext_ucontext_t, uc_mcontext.sp) == SP_OFFSET, "SP_OFFSET is invalid");
               ^        ~~~~~~~~~~~~~~~~~~~~~~
/Library/Developer/CommandLineTools/usr/lib/clang/13.0.0/include/stddef.h:104:24: note: expanded from macro 'offsetof'
#define offsetof(t, d) __builtin_offsetof(t, d)
                       ^                  ~

encoupled with an error "The deprecated ucontext routines require _XOPEN_SOURCE to be defined"

All in all, how can it be compiled and installed into the system?
I want to use it instead of makecontext and others while porting source code of my project to M1

I have no idea, how to compile this :( I tried `make`, but with no luck. I tried `meson`, just ``` meson builddir && cd builddir meson compile ``` With no luck either: ``` ../include/libucontext/bits.h:8:9: error: unknown type name 'greg_t' typedef greg_t libucontext_greg_t; ^ ../include/libucontext/bits.h:9:9: error: unknown type name 'ucontext_t' typedef ucontext_t libucontext_ucontext_t; ^ ../arch/aarch64/makecontext.c:24:16: error: offsetof requires struct, union, or class type, 'libucontext_ucontext_t' (aka 'int') invalid _Static_assert(offsetof(libucontext_ucontext_t, uc_mcontext.regs[0]) == R0_OFFSET, "R0_OFFSET is invalid"); ^ ~~~~~~~~~~~~~~~~~~~~~~ /Library/Developer/CommandLineTools/usr/lib/clang/13.0.0/include/stddef.h:104:24: note: expanded from macro 'offsetof' #define offsetof(t, d) __builtin_offsetof(t, d) ^ ~ ../arch/aarch64/makecontext.c:25:16: error: offsetof requires struct, union, or class type, 'libucontext_ucontext_t' (aka 'int') invalid _Static_assert(offsetof(libucontext_ucontext_t, uc_mcontext.sp) == SP_OFFSET, "SP_OFFSET is invalid"); ^ ~~~~~~~~~~~~~~~~~~~~~~ /Library/Developer/CommandLineTools/usr/lib/clang/13.0.0/include/stddef.h:104:24: note: expanded from macro 'offsetof' #define offsetof(t, d) __builtin_offsetof(t, d) ^ ~ ``` encoupled with an error "The deprecated ucontext routines require _XOPEN_SOURCE to be defined" All in all, how can it be compiled and installed into the system? I want to use it instead of `makecontext` and others while porting source code of my project to M1
Torrekie commented 2021-11-13 10:09:55 +00:00 (Migrated from github.com)

try compile like that:
For object files:
cd arch/aarch64 && cc *.c *.S -I. -I../common -Iinclude -I../../include -fPIC -DPIC -O2 -ggdb3 -D_BSD_SOURCE -std=gnu99 -c
Archive objects to static library (libucontext.a):
ar rcs libucontext.a *.o
Compile objects to dynamic library (libucontext.dylib):
cc -dynamiclib -o libucontext.1.dylib -compatibility_version 1 -current_version 1 *.o

try compile like that: For object files: `cd arch/aarch64 && cc *.c *.S -I. -I../common -Iinclude -I../../include -fPIC -DPIC -O2 -ggdb3 -D_BSD_SOURCE -std=gnu99 -c` Archive objects to static library (libucontext.a): `ar rcs libucontext.a *.o` Compile objects to dynamic library (libucontext.dylib): `cc -dynamiclib -o libucontext.1.dylib -compatibility_version 1 -current_version 1 *.o`

The non-Meson build system should now work. I'll cut a new release shortly.

The non-Meson build system should now work. I'll cut a new release shortly.
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: ariadne/libucontext#33
There is no content yet.