Solaris上的Mono 5构建问题

问题描述 投票:0回答:2

我试图在Solaris 10上构建Mono并遇到错误“Posix系统缺乏对递归互斥体的支持”的问题。我正在尝试使用gcc 3.4.3构建它,并且我已经安装了gmake,gar,granlib和gstrip来替换他们的Solaris替代品。我找到了一个可能的解决方案,但我无法找到引用此行的博客“1)patch /usr/lib/pkgconfig/gthread-2.0.pc来替换位于https://lists.dot.net/pipermail/mono-list/2007-January/034101.html的-mt选项(请参阅Jonel的博客)。博客不再有效。有没有人有任何想法他们所指的补丁可能是什么?提前致谢。

mono solaris
2个回答
1
投票

Solaris 10确实支持递归互斥锁。

对于the Solaris 10 pthread_mutexattr_settype man page

PTHREAD_MUTEX_RECURSIVE

尝试重新锁定此互斥锁而不先解锁它的线程将成功锁定互斥锁。使用PTHREAD_MUTEX_NORMAL类型的互斥锁时可能发生的重新锁定死锁不会出现在这种类型的互斥锁中。此互斥锁的多个锁需要相同数量的解锁才能释放互斥锁,然后另一个线程才能获取互斥锁。尝试解锁另一个线程已锁定的互斥锁的线程将返回错误。尝试解锁未锁定互斥锁的线程将返回错误。只有进程共享属性为PTHREAD_PROCESS_PRIVATE的互斥锁才支持这种类型的互斥锁。

同样根据手册页,所需的编译/链接选项以及正确的#include语句:

cc –mt [ flag... ] file... –lpthread [ library... ]
#include <pthread.h> 

请注意添加-lpthread。我怀疑你所指的博客说要用-mt取代-mt -lpthread


0
投票

(关于这个问题的更多研究,由Unix问题How to install .net Mono on Solaris 11 (source code compile)?提出,产生了this answer,我在这里重复。)

你设置_XOPEN_SOURCE的确切值无关紧要。 Mono错误地定义了_XOPEN_SOURCE_EXTENDED宏:

case "${host}" in
        *solaris* )
                AC_MSG_CHECKING(for Solaris XPG4 support)
                if test -f /usr/lib/libxnet.so; then
                        CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=600"
                        CPPFLAGS="$CPPFLAGS -D__EXTENSIONS__"
                        CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE_EXTENDED=1" <-- WRONG
                        LIBS="$LIBS -lxnet"

_XOPEN_SOURCE_EXTENDED宏在the POSIX 6the POSIX 7 standard中都不存在。

甚至Linux也同意不应该在这里定义_XOPEN_SOURCE_EXTENDED。每the Linux feature_test_macros man page

_XOPEN_SOURCE_EXTENDED

如果定义了此宏,并且定义了_XOPEN_SOURCE,则公开与XPG4v2(SUSv1)UNIX扩展(UNIX 95)对应的定义。将_XOPEN_SOURCE定义为500或更大的值也会产生与定义_XOPEN_SOURCE_EXTENDED相同的效果。应避免在新源代码中使用_XOPEN_SOURCE_EXTENDED

由于将_XOPEN_SOURCE定义为500或更大的值与定义_XOPEN_SOURCE_EXTENDED具有相同的效果,后者(过时的)特征测试宏通常不在手册页的概要中描述。

请注意准确的措辞:

如果定义了此宏(_XOPEN_SOURCE_EXTENDED),并且定义了_XOPEN_SOURCE,则公开与XPG4v2(SUSv1)UNIX扩展(UNIX 95)对应的定义。 ...

_XOPEN_SOURCE定义为任何值,同时在XPG4v2中定义_XOPEN_SOURCE_EXTENDED结果,这不是获取递归互斥锁所必需的XPG6。

你可能会遇到this check in the Solaris 11 /usr/include/sys/feature_tests.h

/*
 * It is invalid to compile an XPG3, XPG4, XPG4v2, or XPG5 application
 * using c99.  The same is true for POSIX.1-1990, POSIX.2-1992, POSIX.1b,
 * and POSIX.1c applications. Likewise, it is invalid to compile an XPG6
 * or a POSIX.1-2001 application with anything other than a c99 or later
 * compiler.  Therefore, we force an error in both cases.
 */
#if defined(_STDC_C99) && (defined(__XOPEN_OR_POSIX) && !defined(_XPG6))
#error "Compiler or options invalid for pre-UNIX 03 X/Open applications \
 and pre-2001 POSIX applications"
#elif !defined(_STDC_C99) && \
 (defined(__XOPEN_OR_POSIX) && defined(_XPG6))
#error "Compiler or options invalid; UNIX 03 and POSIX.1-2001 applications \
 require the use of c99"
#endif

_XPG6定义earlier in the file, in this block

/*
 * Use of _XOPEN_SOURCE
 *
 * The following X/Open specifications are supported:
 *
 * X/Open Portability Guide, Issue 3 (XPG3)
 * X/Open CAE Specification, Issue 4 (XPG4)
 * X/Open CAE Specification, Issue 4, Version 2 (XPG4v2)
 * X/Open CAE Specification, Issue 5 (XPG5)
 * Open Group Technical Standard, Issue 6 (XPG6), also referred to as
 *    IEEE Std. 1003.1-2001 and ISO/IEC 9945:2002.
 *
 * XPG4v2 is also referred to as UNIX 95 (SUS or SUSv1).
 * XPG5 is also referred to as UNIX 98 or the Single Unix Specification,
 *     Version 2 (SUSv2)
 * XPG6 is the result of a merge of the X/Open and POSIX specifications
 *     and as such is also referred to as IEEE Std. 1003.1-2001 in
 *     addition to UNIX 03 and SUSv3.
 *
 * When writing a conforming X/Open application, as per the specification
 * requirements, the appropriate feature test macros must be defined at
 * compile time. These are as follows. For more info, see standards(5).
 *
 * Feature Test Macro                    Specification
 * ------------------------------------------------  -------------
 * _XOPEN_SOURCE                                         XPG3
 * _XOPEN_SOURCE && _XOPEN_VERSION = 4                   XPG4
 * _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED = 1           XPG4v2
 * _XOPEN_SOURCE = 500                                   XPG5
 * _XOPEN_SOURCE = 600  (or POSIX_C_SOURCE=200112L)      XPG6
 *
 * In order to simplify the guards within the headers, the following
 * implementation private test macros have been created. Applications
 * must NOT use these private test macros as unexpected results will
 * occur.
 *
 * Note that in general, the use of these private macros is cumulative.
 * For example, the use of _XPG3 with no other restrictions on the X/Open
 * namespace will make the symbols visible for XPG3 through XPG6
 * compilation environments. The use of _XPG4_2 with no other X/Open
 * namespace restrictions indicates that the symbols were introduced in
 * XPG4v2 and are therefore visible for XPG4v2 through XPG6 compilation
 * environments, but not for XPG3 or XPG4 compilation environments.
 *
 * _XPG3    X/Open Portability Guide, Issue 3 (XPG3)
 * _XPG4    X/Open CAE Specification, Issue 4 (XPG4)
 * _XPG4_2  X/Open CAE Specification, Issue 4, Version 2 (XPG4v2/UNIX 95/SUS)
 * _XPG5    X/Open CAE Specification, Issue 5 (XPG5/UNIX 98/SUSv2)
 * _XPG6    Open Group Technical Standard, Issue 6 (XPG6/UNIX 03/SUSv3)
 */

/* X/Open Portability Guide, Issue 3 */
#if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE - 0 < 500) && \
    (_XOPEN_VERSION - 0 < 4) && !defined(_XOPEN_SOURCE_EXTENDED)
#define _XPG3
/* X/Open CAE Specification, Issue 4 */
#elif   (defined(_XOPEN_SOURCE) && _XOPEN_VERSION - 0 == 4)
#define _XPG4
#define _XPG3
/* X/Open CAE Specification, Issue 4, Version 2 */
#elif (defined(_XOPEN_SOURCE) && _XOPEN_SOURCE_EXTENDED - 0 == 1)
#define _XPG4_2
#define _XPG4
#define _XPG3
/* X/Open CAE Specification, Issue 5 */
#elif   (_XOPEN_SOURCE - 0 == 500)
#define _XPG5
#define _XPG4_2
#define _XPG4
#define _XPG3
#undef  _POSIX_C_SOURCE
#define _POSIX_C_SOURCE         199506L
/* Open Group Technical Standard , Issue 6 */
#elif   (_XOPEN_SOURCE - 0 == 600) || (_POSIX_C_SOURCE - 0 == 200112L)
#define _XPG6
#define _XPG5
#define _XPG4_2
#define _XPG4
#define _XPG3
#undef  _POSIX_C_SOURCE
#define _POSIX_C_SOURCE         200112L
#undef  _XOPEN_SOURCE
#define _XOPEN_SOURCE           600
#endif
© www.soinside.com 2019 - 2024. All rights reserved.