haschatan wrote:Ok. I do not understand why nobody want to compile Minetest on Mac OS. What a shame.
Assertion failed: (sem_init_retval == 0), function JSemaphore, file /Users/me/minetest/minetest/src/jthread/pthread/jsemaphore.cpp, line 28.
OmniStudent wrote:Managed to compile on xcode 5.1 by setting architechture on all targets to x86_64, which I guess means I got a 64bit minecraft :)
OmniStudent wrote:But at startup the program crashed due toYour phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
- Code: Select all
Assertion failed: (sem_init_retval == 0), function JSemaphore, file /Users/me/minetest/minetest/src/jthread/pthread/jsemaphore.cpp, line 28.
it was sem_init() in jsemaphore.cpp. Apparently this is not properly implemented on osx and returns -1
Morn76 wrote:
How did you set the architecture in Xcode, OmniStudent?
Morn76 wrote:Found this:
"Unnamed semaphores are not supported, you need to use named semaphores.
To use named semaphores instead of unnamed semaphores, use sem_open instead of sem_init, and use sem_close and sem_unlink instead of sem_destroy."
http://stackoverflow.com/questions/1413 ... it-on-os-x
]Morn76 wrote:P.S. Apparently OX X does not implement sem_getvalue ( http://stackoverflow.com/questions/1665 ... mac-os-x-c ), so it's no wonder this workaround fails.
OmniStudent wrote:]Morn76 wrote:P.S. Apparently OX X does not implement sem_getvalue ( http://stackoverflow.com/questions/1665 ... mac-os-x-c ), so it's no wonder this workaround fails.
That's a pity, I thought that was the way to go :(
OmniStudent wrote:Managed to build the "package" target too by putting an old "mac" folder inside the "misc" folder in minetest.
git checkout 122875c30cc2
patch -p1 < mt.patch
cmake -G Xcode .
(change architecture in XCode to 64 bit and build)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 153e1c1..f171926 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -168,7 +168,6 @@ install(FILES "minetest.conf.example" DESTINATION "${EXAMPLE_CONF_DIR}")
if(UNIX)
install(FILES "doc/minetest.6" "doc/minetestserver.6" DESTINATION "${MANDIR}/man6")
- install(FILES "misc/minetest.desktop" DESTINATION "${XDG_APPS_DIR}")
install(FILES "misc/minetest-icon.svg" DESTINATION "${ICONDIR}/hicolor/scalable/apps")
endif()
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 90f5867..a0917ca 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -160,7 +160,7 @@ else()
endif(APPLE)
endif(BUILD_CLIENT)
find_package(ZLIB REQUIRED)
- set(PLATFORM_LIBS -lpthread -lrt ${CMAKE_DL_LIBS})
+ set(PLATFORM_LIBS -lpthread "-framework CoreFoundation" ${CMAKE_DL_LIBS})
#set(CLIENT_PLATFORM_LIBS -lXxf86vm)
# This way Xxf86vm is found on OpenBSD too
find_library(XXF86VM_LIBRARY Xxf86vm)
@@ -170,7 +170,6 @@ endif()
find_package(Sqlite3 REQUIRED)
find_package(Json REQUIRED)
-find_package(OpenGLES2)
if(USE_FREETYPE)
find_package(Freetype REQUIRED)
diff --git a/src/porting.h b/src/porting.h
index ea7f31b..e08eea8 100644
--- a/src/porting.h
+++ b/src/porting.h
@@ -188,7 +188,10 @@
#else // Posix
#include <sys/time.h>
#include <time.h>
-
+#ifdef __MACH__
+#include <mach/clock.h>
+#include <mach/mach.h>
+#endif
inline u32 getTimeS()
{
struct timeval tv;
@@ -213,7 +216,18 @@
inline u32 getTimeNs()
{
struct timespec ts;
+#ifdef __MACH__ // OS X does not have clock_gettime, use clock_get_time
+ clock_serv_t cclock;
+ mach_timespec_t mts;
+ host_get_clock_service(mach_host_self(), CALENDAR_CLOCK, &cclock);
+ clock_get_time(cclock, &mts);
+ mach_port_deallocate(mach_task_self(), cclock);
+ ts.tv_sec = mts.tv_sec;
+ ts.tv_nsec = mts.tv_nsec;
+
+#else
clock_gettime(CLOCK_REALTIME, &ts);
+#endif
return ts.tv_sec * 1000000000 + ts.tv_nsec;
}
Morn76 wrote:Where did you get that mac folder from? When I run minetest from bin/Debug, all my keyboard input goes to a terminal instead of the MT window for some reason, so I'm very interested in bundle creation.
Morn76 wrote:I could not get 97723226 to work (semaphore error mesages again), so I've built 122875c30cc2 (with the patch below).
Morn76 wrote:StackOverflow also links to this monster: http://www.aao.gov.au/local/www/ks/uplo ... imedwait.c , but I don't even know how I would integrate this thing into the existing code. More fiddling with cmake would probably be needed.
OmniStudent wrote:That's strange, 97723226 is supposed to be before semaphores where added. Are you sure you got the correct commit? Can't find 122875c30cc2 on github but that's just because one can't search for sha numbers there.
OmniStudent wrote:Morn76 wrote:StackOverflow also links to this monster: http://www.aao.gov.au/local/www/ks/uplo ... imedwait.c , but I don't even know how I would integrate this thing into the existing code. More fiddling with cmake would probably be needed.
That looks promising though, I will have a look at it.
Morn76 wrote:It needs "sem_timedwait.h" apparently though, and I can't find that anywhere online.
Morn76 wrote:Basically it should be enough to include mach/semaphore.h instead of semaphore.h and then call semaphore_timedwait() because the Mach kernel on OS X actually has this function. Like it's done here: https://github.com/constcast/vermont/tr ... /osdep/osx Unfortunately I have not been able to do this with the MT code successfully though, I always get lots of compilation errors when I change the include file to mach.
#else // Posix
#include <sys/time.h>
#include <time.h>
#include <mach/mach_time.h>
#include <mach/mach.h>
#include <mach/mach_init.h>
#include <mach/thread_policy.h>
#define CLOCK_REALTIME 0
#define CLOCK_MONOTONIC 0
inline u32 getTimeS()
Morn76 wrote:
If Sapier could rewrite his MT code so sem_getvalue() and sem_timedwait() were no longer needed, we could use the Apple macros to transform the remaining sem_*() calls and everything should be solved. I don't know if this is possible though.
The devs have really painted themselves into the proverbial corner with all this jsemaphore stuff in MT. IMO Sapier's commit should have been rejected in November as non-portable, but unfortunately nobody seems to have checked portability at the time. So now we are a bit stuck.
#if defined(WIN32)
#include <windows.h>
#include <assert.h>
#define MAX_SEMAPHORE_COUNT 1024
#else
#include <mach/semaphore.h>
#include <pthread.h>
//#include <semaphore.h>
#include <mach/mach.h>
#include <mach/task.h>
#undef sem_t
#define sem_t semaphore_t
#undef sem_init
#define sem_init(s,p,c) semaphore_create(mach_task_self(),s,SYNC_POLICY_FIFO,c)
#undef sem_wait
#define sem_wait(s) semaphore_wait(*s)
#undef sem_post
#define sem_post(s) semaphore_signal(*s)
#undef sem_destroy
#define sem_destroy(s) semaphore_destroy(mach_task_self(),*s)
#undef sem_timedwait
#define sem_timedwait(s,t) semaphore_timedwait(*s,t)
#endif
#define sem_init(s, p, v) fuse_sem_init(s, p, v)
#define sem_destroy(s) fuse_sem_destroy(s)
#define sem_getvalue(s, v) fuse_sem_getvalue(s, v)
#define sem_post(s) fuse_sem_post(s)
#define sem_timedwait(s, t) fuse_sem_timedwait(s, t)
#define sem_trywait(s) fuse_sem_trywait(s)
#define sem_wait(s) fuse_sem_wait(s)
Users browsing this forum: No registered users and 81 guests