summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Schleifer <js@heap.zone>2019-05-05 21:28:25 +0200
committerJonathan Schleifer <js@heap.zone>2019-05-05 21:28:25 +0200
commitdbf7c3525b35506ed3d249b757c726c13d7f5a47 (patch)
tree1a433c7239a386b5582a04969601a0485a1695c6
parent3223b12d2f0ce0f2525e863db2cb56d405cbe83a (diff)
Create separate Amiga libraries for OS3 & MorphOS
Otherwise, it would be necessary to make unwinding work between 68k and PPC code, and would get even worse with OS4 support. This also includes using separate .sfd files.
-rw-r--r--configure.ac19
-rw-r--r--extra.mk.in1
-rw-r--r--generators/Makefile7
-rw-r--r--src/runtime/Makefile9
-rw-r--r--src/runtime/amiga-library.m2
-rw-r--r--src/runtime/amigaos3.sfd (renamed from src/runtime/ObjFW_RT.sfd)2
-rw-r--r--src/runtime/linklib/Makefile5
-rw-r--r--src/runtime/linklib/linklib.m7
-rw-r--r--src/runtime/morphos.sfd81
-rw-r--r--tests/Makefile7
10 files changed, 117 insertions, 23 deletions
diff --git a/configure.ac b/configure.ac
index ff482d4b..0c02d4cd 100644
--- a/configure.ac
+++ b/configure.ac
@@ -11,7 +11,7 @@ AC_SUBST(BUNDLE_SHORT_VERSION, 0.90)
for i in configure.ac build-aux/m4/*; do
AS_IF([test $i -nt configure], [
- AC_MSG_ERROR([$i is newer than configure! Run autoreconf!])
+ AC_MSG_ERROR([$i is newer than configure! Run ./autogen.sh!])
])
done
@@ -58,7 +58,10 @@ case "$host" in
ac_cv_snprintf_useful_ret="yes"
AS_IF([test x"$enable_amiga_lib" != x"no"], [
+ AC_SUBST(OBJFW_RT_AMIGA_LIB,
+ 'objfw_rt_${OBJFW_RT_LIB_MAJOR}_68k.library')
AC_SUBST(SFDC_TARGET, m68k-amigaos)
+ AC_SUBST(SFD_FILE, amigaos3.sfd)
dnl For 68000, GCC emits calls to helper functions that
dnl do not work properly in a library.
AC_SUBST(AMIGA_LIB_CFLAGS, "-mcpu=68020 -fbaserel")
@@ -82,12 +85,15 @@ case "$host" in
supports_amiga_lib="yes"
AS_IF([test x"$enable_amiga_lib" != x"no"], [
+ t='objfw_rt_${OBJFW_RT_LIB_MAJOR}_abox.library'
+ AC_SUBST(OBJFW_RT_AMIGA_LIB, $t)
AC_SUBST(SFDC_TARGET, ppc-morphos)
- tmp="-mresident32 -fno-builtin"
- AC_SUBST(AMIGA_LIB_CFLAGS, $tmp)
- tmp="-mresident32 -nostartfiles -nodefaultlibs"
- tmp="$tmp -lc"
- AC_SUBST(AMIGA_LIB_LDFLAGS, $tmp)
+ AC_SUBST(SFD_FILE, morphos.sfd)
+ t="-mresident32 -fno-builtin"
+ AC_SUBST(AMIGA_LIB_CFLAGS, $t)
+ t="-mresident32 -nostartfiles -nodefaultlibs"
+ t="$tmp -lc"
+ AC_SUBST(AMIGA_LIB_LDFLAGS, $t)
])
])
@@ -512,7 +518,6 @@ case "$objc_runtime" in
])
AS_IF([test x"$enable_amiga_lib" != x"no"], [
- AC_SUBST(OBJFW_RT_AMIGA_LIB, objfw_rt.library)
AC_SUBST(RUNTIME_LIBS, "-lobjfw_rt.library")
AC_SUBST(LINKLIB, linklib)
tmp="../src/runtime/linklib/libobjfw_rt.library.a"
diff --git a/extra.mk.in b/extra.mk.in
index b45f2183..c1fd9905 100644
--- a/extra.mk.in
+++ b/extra.mk.in
@@ -70,6 +70,7 @@ RUNTIME_FRAMEWORK_LIBS = @RUNTIME_FRAMEWORK_LIBS@
RUNTIME_LIBS = @RUNTIME_LIBS@
RUN_TESTS = @RUN_TESTS@
SFDC_TARGET = @SFDC_TARGET@
+SFD_FILE = @SFD_FILE@
TESTPLUGIN = @TESTPLUGIN@
TESTPLUGIN_LIBS = @TESTPLUGIN_LIBS@
TESTS_LIBS = @TESTS_LIBS@
diff --git a/generators/Makefile b/generators/Makefile
index f8720e3e..1e100706 100644
--- a/generators/Makefile
+++ b/generators/Makefile
@@ -11,7 +11,7 @@ run: all
rm -f libobjfw_rt.so.${OBJFW_RT_LIB_MAJOR}
rm -f libobjfw_rt.so.${OBJFW_RT_LIB_MAJOR_MINOR}
rm -f libobjfw_rt.dll libobjfw_rt.${OBJFW_RT_LIB_MAJOR}.dylib
- rm -f objfw_rt.library
+ rm -f ${OBJFW_RT_AMIGA_LIB}
if test -f ../src/libobjfw.so; then \
${LN_S} ../src/libobjfw.so libobjfw.so.${OBJFW_LIB_MAJOR}; \
${LN_S} ../src/libobjfw.so \
@@ -42,8 +42,9 @@ run: all
${LN_S} ../src/runtime/libobjfw_rt.dylib \
libobjfw_rt.${OBJFW_RT_LIB_MAJOR}.dylib; \
fi
- if test -f ../src/runtime/objfw_rt.library; then \
- ${LN_S} ../src/runtime/objfw_rt.library objfw_rt.library; \
+ if test -f ../src/runtime/${OBJFW_RT_AMIGA_LIB}; then \
+ ${LN_S} ../src/runtime/${OBJFW_RT_AMIGA_LIB} \
+ ${OBJFW_RT_AMIGA_LIB}; \
fi
LD_LIBRARY_PATH=.$${LD_LIBRARY_PATH+:}$$LD_LIBRARY_PATH \
DYLD_FRAMEWORK_PATH=../src:../src/runtime$${DYLD_FRAMEWORK_PATH+:}$$DYLD_FRAMEWORK_PATH \
diff --git a/src/runtime/Makefile b/src/runtime/Makefile
index e46e4e22..d81a59e0 100644
--- a/src/runtime/Makefile
+++ b/src/runtime/Makefile
@@ -45,14 +45,15 @@ ${OBJFW_RT_AMIGA_LIB}: inline.h
amiga-library.m: amiga-library-functable.inc
-amiga-library-functable.inc: ObjFW_RT.sfd
+amiga-library-functable.inc: ${SFD_FILE}
sfdc -q --target=${SFDC_TARGET} --mode=functable -o $@ $<
-inline.h: ObjFW_RT.sfd
+inline.h: ${SFD_FILE}
sfdc -q --target=${SFDC_TARGET} --mode=macros -o $@ $<
-CPPFLAGS += -I. -I.. -I../.. \
- -DOBJFW_RT_LIB_MAJOR=${OBJFW_RT_LIB_MAJOR} \
+CPPFLAGS += -I. -I.. -I../.. \
+ -DOBJFW_RT_AMIGA_LIB=\"${OBJFW_RT_AMIGA_LIB}\" \
+ -DOBJFW_RT_LIB_MAJOR=${OBJFW_RT_LIB_MAJOR} \
-DOBJFW_RT_LIB_MINOR=${OBJFW_RT_LIB_MINOR}
AMIGA_LIB_CFLAGS += -DOBJC_COMPILING_AMIGA_LIBRARY
LD = ${OBJC}
diff --git a/src/runtime/amiga-library.m b/src/runtime/amiga-library.m
index 84e2d6d0..a529c110 100644
--- a/src/runtime/amiga-library.m
+++ b/src/runtime/amiga-library.m
@@ -601,7 +601,7 @@ struct Resident resident = {
.rt_Version = OBJFW_RT_LIB_MAJOR,
.rt_Type = NT_LIBRARY,
.rt_Pri = 0,
- .rt_Name = (char *)"objfw_rt.library",
+ .rt_Name = (char *)OBJFW_RT_AMIGA_LIB,
.rt_IdString = (char *)"ObjFW_RT " VERSION_STRING
" \xA9 2008-2019 Jonathan Schleifer",
.rt_Init = &init_table,
diff --git a/src/runtime/ObjFW_RT.sfd b/src/runtime/amigaos3.sfd
index 95132fda..d6f2ba94 100644
--- a/src/runtime/ObjFW_RT.sfd
+++ b/src/runtime/amigaos3.sfd
@@ -1,6 +1,6 @@
==base _ObjFWRTBase
==basetype struct Library *
-==libname objfw_rt.library
+==libname objfw_rt_0_68k.library
==bias 30
==public
* Functions that are only for the linklib.
diff --git a/src/runtime/linklib/Makefile b/src/runtime/linklib/Makefile
index 0e95d0e0..87ef1114 100644
--- a/src/runtime/linklib/Makefile
+++ b/src/runtime/linklib/Makefile
@@ -5,5 +5,8 @@ SRCS = linklib.m
include ../../../buildsys.mk
-CPPFLAGS += -DOBJC_COMPILING_AMIGA_LINKLIB -I.. -I../.. -I../../..
+CPPFLAGS += -I.. -I../.. -I../../.. \
+ -DOBJC_COMPILING_AMIGA_LINKLIB \
+ -DOBJFW_RT_AMIGA_LIB=\"${OBJFW_RT_AMIGA_LIB}\" \
+ -DOBJFW_RT_LIB_MINOR=${OBJFW_RT_LIB_MINOR}
LD = ${OBJC}
diff --git a/src/runtime/linklib/linklib.m b/src/runtime/linklib/linklib.m
index ccf1d1a4..0b2b2749 100644
--- a/src/runtime/linklib/linklib.m
+++ b/src/runtime/linklib/linklib.m
@@ -96,13 +96,14 @@ ctor(void)
if (initialized)
return;
- if ((ObjFWRTBase = OpenLibrary("objfw_rt.library", 0)) == NULL) {
- fputs("Failed to open objfw_rt.library!\n", stderr);
+ if ((ObjFWRTBase = OpenLibrary(OBJFW_RT_AMIGA_LIB,
+ OBJFW_RT_LIB_MINOR)) == NULL) {
+ fputs("Failed to open " OBJFW_RT_AMIGA_LIB "!\n", stderr);
abort();
}
if (!objc_init_m68k(1, &libc, stdout, stderr)) {
- fputs("Failed to initialize objfw_rt.library!\n", stderr);
+ fputs("Failed to initialize " OBJFW_RT_AMIGA_LIB "!\n", stderr);
abort();
}
diff --git a/src/runtime/morphos.sfd b/src/runtime/morphos.sfd
new file mode 100644
index 00000000..aa594e5b
--- /dev/null
+++ b/src/runtime/morphos.sfd
@@ -0,0 +1,81 @@
+==base _ObjFWRTBase
+==basetype struct Library *
+==libname objfw_rt_0_abox.library
+==bias 30
+==public
+* Functions that are only for the linklib.
+bool objc_init_m68k(unsigned int version, struct objc_libc *libc, FILE *stdout, FILE *stdin)(d0,a0,a1,a2)
+* These have a built-in declaration in the compiler that does not use the
+* registers and thus always need glue.
+void __objc_exec_class_m68k(void *_Nonnull module)(a0)
+IMP _Nonnull objc_msg_lookup_m68k(id _Nullable object, SEL _Nonnull selector)(a0,a1)
+IMP _Nonnull objc_msg_lookup_stret_m68k(id _Nullable object, SEL _Nonnull selector)(a0,a1)
+IMP _Nonnull objc_msg_lookup_super_m68k(struct objc_super *_Nonnull super, SEL _Nonnull selector)(a0,a1)
+IMP _Nonnull objc_msg_lookup_super_stret_m68k(struct objc_super *_Nonnull super, SEL _Nonnull selector)(a0,a1)
+Class _Nullable objc_lookUpClass_m68k(const char *_Nonnull name)(a0)
+Class _Nullable objc_getClass_m68k(const char *_Nonnull name)(a0)
+Class _Nonnull objc_getRequiredClass_m68k(const char *_Nonnull name)(a0)
+Class _Nullable objc_lookup_class_m68k(const char *_Nonnull name)(a0)
+Class _Nonnull objc_get_class_m68k(const char *_Nonnull name)(a0)
+void objc_exception_throw_m68k(id _Nonnull object)(a0)
+int objc_sync_enter_m68k(id _Nullable object)(a0)
+int objc_sync_exit_m68k(id _Nullable object)(a0)
+id objc_getProperty_m68k(id _Nonnull self, SEL _Nonnull _cmd, ptrdiff_t offset, bool atomic)(a0,a1,d0,d1)
+void objc_setProperty_m68k(id _Nonnull self, SEL _Nonnull _cmd, ptrdiff_t offset, id value, bool atomic, signed char copy)(a0,a1,d0,a2,d1,d2)
+void objc_getPropertyStruct_m68k(void *_Nonnull dest, const void *_Nonnull src, ptrdiff_t size, bool atomic, bool strong)(a0,a1,d0,d1,d2)
+void objc_setPropertyStruct_m68k(void *_Nonnull dest, const void *_Nonnull src, ptrdiff_t size, bool atomic, bool strong)(a0,a1,d0,d1,d2)
+void objc_enumerationMutation_m68k(id _Nonnull object)(a0)
+int __gnu_objc_personality_v0_m68k(int version, int actions, uint64_t *_Nonnull exClass, void *_Nonnull ex, void *_Nonnull ctx)(d0,d1,d2,a0,a1)
+int __gnu_objc_personality_sj0_m68k(int version, int actions, uint64_t *_Nonnull exClass, void *_Nonnull ex, void *_Nonnull ctx)(d0,d1,d2,a0,a1)
+id _Nullable objc_retain_m68k(id _Nullable object)(a0)
+id _Nullable objc_retainBlock_m68k(id _Nullable block)(a0)
+id _Nullable objc_retainAutorelease_m68k(id _Nullable object)(a0)
+void objc_release_m68k(id _Nullable object)(a0)
+id _Nullable objc_autorelease_m68k(id _Nullable object)(a0)
+id _Nullable objc_autoreleaseReturnValue_m68k(id _Nullable object)(a0)
+id _Nullable objc_retainAutoreleaseReturnValue_m68k(id _Nullable object)(a0)
+id _Nullable objc_retainAutoreleasedReturnValue_m68k(id _Nullable object)(a0)
+id _Nullable objc_storeStrong_m68k(id _Nullable *_Nonnull object, id _Nullable value)(a0,a1)
+id _Nullable objc_storeWeak_m68k(id _Nullable *_Nonnull object, id _Nullable value)(a0,a1)
+id _Nullable objc_loadWeakRetained_m68k(id _Nullable *_Nonnull object)(a0)
+id _Nullable objc_initWeak_m68k(id _Nullable *_Nonnull object, id _Nullable value)(a0,a1)
+void objc_destroyWeak_m68k(id _Nullable *_Nonnull object)(a0)
+id _Nullable objc_loadWeak_m68k(id _Nullable *_Nonnull object)(a0)
+void objc_copyWeak_m68k(id _Nullable *_Nonnull dest, id _Nullable *_Nonnull src)(a0,a1)
+void objc_moveWeak_m68k(id _Nullable *_Nonnull dest, id _Nullable *_Nonnull src)(a0,a1)
+* These only need glue on MorphOS. As none of them are functions that are used
+* in hot paths, it's easier to also use the glue on AmigaOS 3, which also has
+* the benefit of having all __saveds in a single place.
+SEL _Nonnull sel_registerName_m68k(const char *_Nonnull name)(a0)
+const char *_Nonnull sel_getName_m68k(SEL _Nonnull selector)(a0)
+bool sel_isEqual_m68k(SEL _Nonnull selector1, SEL _Nonnull selector2)(a0,a1)
+Class _Nonnull objc_allocateClassPair_m68k(Class _Nullable superclass, const char *_Nonnull name, size_t extraBytes)(a0,a1,d0)
+void objc_registerClassPair_m68k(Class _Nonnull class_)(a0)
+unsigned int objc_getClassList_m68k(Class _Nonnull *_Nullable buffer, unsigned int count)(a0,d0)
+Class _Nonnull *_Nonnull objc_copyClassList_m68k(unsigned int *_Nullable length)(a0)
+bool class_isMetaClass_m68k(Class _Nullable class_)(a0)
+const char *_Nullable class_getName_m68k(Class _Nullable class_)(a0)
+Class _Nullable class_getSuperclass_m68k(Class _Nullable class_)(a0)
+unsigned long class_getInstanceSize_m68k(Class _Nullable class_)(a0)
+bool class_respondsToSelector_m68k(Class _Nullable class_, SEL _Nonnull selector)(a0,a1)
+bool class_conformsToProtocol_m68k(Class _Nullable class_, Protocol *_Nonnull p)(a0,a1)
+IMP _Nullable class_getMethodImplementation_m68k(Class _Nullable class_, SEL _Nonnull selector)(a0,a1)
+IMP _Nullable class_getMethodImplementation_stret_m68k(Class _Nullable class_, SEL _Nonnull selector)(a0,a1)
+const char *_Nullable class_getMethodTypeEncoding_m68k(Class _Nullable class_, SEL _Nonnull selector)(a0,a1)
+bool class_addMethod_m68k(Class _Nonnull class_, SEL _Nonnull selector, IMP _Nonnull implementation, const char *_Nullable typeEncoding)(a0,a1,a2,a3)
+IMP _Nullable class_replaceMethod_m68k(Class _Nonnull class_, SEL _Nonnull selector, IMP _Nonnull implementation, const char *_Nullable typeEncoding)(a0,a1,a2,a3)
+Class _Nullable object_getClass_m68k(id _Nullable object)(a0)
+Class _Nullable object_setClass_m68k(id _Nullable object, Class _Nonnull class_)(a0,a1)
+const char *_Nullable object_getClassName_m68k(id _Nullable object)(a0)
+const char *_Nonnull protocol_getName_m68k(Protocol *_Nonnull protocol)(a0)
+bool protocol_isEqual_m68k(Protocol *_Nonnull protocol1, Protocol *_Nonnull protocol2)(a0,a1)
+bool protocol_conformsToProtocol_m68k(Protocol *_Nonnull protocol1, Protocol *_Nonnull protocol2)(a0,a1)
+void objc_exit_m68k(void)()
+_Nullable objc_uncaught_exception_handler_t objc_setUncaughtExceptionHandler_m68k(objc_uncaught_exception_handler_t _Nullable handler)(a0)
+void objc_setForwardHandler_m68k(IMP _Nullable forward, IMP _Nullable stretForward)(a0,a1)
+void objc_setEnumerationMutationHandler_m68k(objc_enumeration_mutation_handler_t _Nullable handler)(a0)
+void objc_zero_weak_references_m68k(id _Nonnull value)(a0)
+* SysV functions for MorphOS could be added here for performance. Having them
+* in addition to the m68k functions allows m68k applications to call into the
+* PPC library, while native code can use the SysV functions.
+==end
diff --git a/tests/Makefile b/tests/Makefile
index e97a09c6..ebde561b 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -81,7 +81,7 @@ run:
rm -f libobjfw_rt.so.${OBJFW_RT_LIB_MAJOR}
rm -f libobjfw_rt.so.${OBJFW_RT_LIB_MAJOR_MINOR}
rm -f libobjfw_rt.dll libobjfw_rt.${OBJFW_RT_LIB_MAJOR}.dylib
- rm -f objfw_rt.library
+ rm -f ${OBJFW_RT_AMIGA_LIB}
if test -f ../src/libobjfw.so; then \
${LN_S} ../src/libobjfw.so libobjfw.so.${OBJFW_LIB_MAJOR}; \
${LN_S} ../src/libobjfw.so \
@@ -112,8 +112,9 @@ run:
${LN_S} ../src/runtime/libobjfw_rt.dylib \
libobjfw_rt.${OBJFW_RT_LIB_MAJOR}.dylib; \
fi
- if test -f ../src/runtime/objfw_rt.library; then \
- ${LN_S} ../src/runtime/objfw_rt.library objfw_rt.library; \
+ if test -f ../src/runtime/${OBJFW_RT_AMIGA_LIB}; then \
+ ${LN_S} ../src/runtime/${OBJFW_RT_AMIGA_LIB} \
+ ${OBJFW_RT_AMIGA_LIB}; \
fi
LD_LIBRARY_PATH=.$${LD_LIBRARY_PATH+:}$$LD_LIBRARY_PATH \
DYLD_FRAMEWORK_PATH=../src:../src/runtime$${DYLD_FRAMEWORK_PATH+:}$$DYLD_FRAMEWORK_PATH \