-
Notifications
You must be signed in to change notification settings - Fork 865
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix Build for MacOS, FreeBSD, GCC earlier than 4.7, and Clang earlier… #2104
Conversation
I would like to have this patch. I first found I can no longer build libsrt native for our build/test 'Indigo' system (C86_64 GCC4.6.3). From the detailed problem description above (thanks @jlsantiago0 ) I realized I cannot cross-compile for our X-series as well (arm GCC 4.4.1). |
I have one fix that I am testing for the test issue indicated by the CI tester. It should only effect MacOS. You may also need the patch for #2103 as well. |
@jlsantiago0 thanks for your pull request. This pull request make more easier to build libsrt for MacOS. This very handy for debugging and for personal use. I saw that the checks for MacOS failed. I don't know if that's a bad thing, maybe the Haivision team can answer this? Link: https://github.com/Haivision/srt/pull/2104/checks?check_run_id=3437542062. |
@KvanSteijn The latest commit seems to have resolved the MacOS CI test failure, Visual Studio Release builds are breaking, but the Debug builds are fine. I dont understand what is wrong. |
@jlsantiago0 I think it has to do with atomic. I'm seeing a lot of syntax errors that has to do with atomic. Edit: Link to pthreads repo that VS 2013 release CI are using: https://github.com/Cinegy/pthread-win32
|
VS 2013 release CI build uses |
@maxsharabayko It looks like the intent of the code was to use |
…ic implementation.
@maxsharabayko and @KvanSteijn OK. I cleaned it up so that it is obvious that we have explicit definitions for each atomic implementation. |
@maxsharabayko BTW |
@maxsharabayko |
This comment has been minimized.
This comment has been minimized.
@jlsantiago0 Thanks for noting! Created issue #2108. |
Testing Windows POSIX build. Running for 2 hours (more than one TSBPD wrapping period), no issues. ✔️ |
Co-authored-by: Maxim Sharabayko <maxlovic@gmail.com>
Co-authored-by: Maxim Sharabayko <maxlovic@gmail.com>
… than 6.
There are two major problems,
srt::sync::atomic
implementation and usage ofpthread_getname_np()
andpthread_setname_np()
.This fixes the build for
MacOS
for a number of versions. For instanceXCode
<7 usesApple LLVM
based on Clang 5 or earlier andXCode
<5 usesGCC
<4.5. These do not supportGCC
__atomic_*
intrinsics which were introduced inGCC
4.7. This patch usesC++11 std::atomic
to implementsrt::sync::atomic
for MacOS 10.7 and later, and provides an implementation ofsrt::sync::atomic
usingPOSIX
Mutexes
for MacOS <10.7. Also some of the macros used to instrument the synchronous operations annotations are not available inLLVM
<6. With this patch, OpenSRT is now building withXCode-3.2.6 (X86_64, i386, PPC, PPC64) targeting MacOS-10.5.x
on MacOS 10.8,XCode-5.1.1 (X86_64, i386)
on MacOS 10.8,XCode-9.4.2 (X86_64, i386)
on MacOS 10.13,XCode-12.2 (X86_64)
on MacOS-11.1. I have not yet had time to test MacOS-11.x for ARM64 builds.This fixes MacOS builds for MacOS <10.6 as
pthread_getname_np()
andpthread_setname_np()
was introduced in MacOS 10.6 and is not available in MacOS 10.5 and earlier.While resolving the issues for MacOS builds, I was able to us the
POSIX
Mutex
srt::sync::atomic
implementation to fix build issues withGCC
<4.7. This fixes the build for the MakitoX toolchain which is based onGCC-4.4.1
, it also fixes the build for CentOS <7, Ubuntu <14 and for Slackware <14. NOTE It would be possible to support the older__sync_*
intrinsics available in the older versions ofGCC
, but it might not be as simple as it seems as the synchronous memory model was changed in theGCC
4.7 implementation to matchC++11
andC11
standards.Also the rework of the
pthread_getname_np()
andpthread_setname_np()
allows other operating systems that support the API to use it. For instance these functions are available in many of the BSD variants, but may be in a different header file or may have a slightly different name. I also fixed handling of the different function call parameters of the Apple and non-Apple implementations ofpthread_setname_np()
. Apple takes one parameter and the most implementations take 2. This was tested withFreeBSD-11.3
andOpenBSD-6.4
.NOTE That other than the Apple
XCode
toolchains, I assume that otherClang
<6 users will not have support for theGCC
__atomic_* intrinisics
and will need to usePOSIX
Mutex
implementation as well, if or until someone ports itto the older__sync_* intrinsics
. But I havent specified that in this patch.