This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Redesign pthread in LIB_SPEC for systems without libpthread
- From: Maxim Kuvyrkov <maxim at kugelworks dot com>
- To: Pavel Chupin <pavel dot v dot chupin at gmail dot com>
- Cc: Alexander Ivchenko <aivchenk at gmail dot com>, GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Sat, 17 Aug 2013 17:55:14 +1200
- Subject: Re: [PATCH] Redesign pthread in LIB_SPEC for systems without libpthread
- References: <CANwJu1-9g7bEwRowQGRywFk3tSDW-s+CRq_qDEDOJFtMg4Xp8g at mail dot gmail dot com> <CACysShhNtEO2me2jbBpvUaq=D6rUeW9x4Lg+fOy8jV1V+DD0Pw at mail dot gmail dot com> <CANwJu1_RgaXergMwgwS-0ME5MOoZrVZQ55+xHkPnAwe=uBoEjQ at mail dot gmail dot com> <CANwJu1-O8FFBVkhUMLwZSDVyFp91cYzOGQJXEoCjriT2B2pEgQ at mail dot gmail dot com> <CACysShhE_Cbd5rXOS4SEtENZ=DYDSAbe9qn0+259rMyShuAv4A at mail dot gmail dot com> <FE12AADD-5609-44FD-8BF9-1B83E1624BCF at kugelworks dot com> <CANwJu18gNtCns_On9D8hCVc-kH+FxOh9RrJgJcnB4qxxHq1SGQ at mail dot gmail dot com>
On 17/08/2013, at 3:07 AM, Pavel Chupin wrote:
...
>
> It's late to change subj I think to avoid producing new thread but I
> got your point.
> Problem is that all 3 Android compilers (arm, x86, mips) are failed to
> build on trunk due to libgomp and libatomic configure errors like (arm
> example):
>
> configure:14403:
> /tmp/ndk-pvchupin/build/host-gcc/i686-linux-gnu/build-gcc-4.9-arm-linux-androideabi/./gcc/xgcc
> -B/tmp/ndk-pvchupin/build/host-gcc/i686-linux-gnu/build-gcc-4.9-arm-linux-androideabi/./gcc/
> -B/tmp/ndk-pvchupin/build/host-gcc/i686-linux-gnu/temp-arm-linux-androideabi-4.9/arm-linux-androideabi/bin/
> -B/tmp/ndk-pvchupin/build/host-gcc/i686-linux-gnu/temp-arm-linux-androideabi-4.9/arm-linux-androideabi/lib/
> -isystem /tmp/ndk-pvchupin/build/host-gcc/i686-linux-gnu/temp-arm-linux-androideabi-4.9/arm-linux-androideabi/include
> -isystem /tmp/ndk-pvchupin/build/host-gcc/i686-linux-gnu/temp-arm-linux-androideabi-4.9/arm-linux-androideabi/sys-include
> -o conftest -g -Os -fno-sync-libcalls -pthread conftest.c >&5
> /tmp/ndk-pvchupin/build/host-gcc/i686-linux-gnu/temp-binutils-2.23-arm-linux-androideabi/bin/arm-linux-androideabi-ld:
> error: cannot find -lpthread
>
> There is no libpthread library in Bionic, pthreads is integrated into libc.
> My fix removes -lpthread from GNU_USER_TARGET_LIB_SPEC definition
> which is included in both bionic and linux but keeping it in linux
> LIB_SPEC.
Thanks for the description. I thought a bit more about the problem, and it might be possible to solve it more concisely:
1. In config/gnu-user.h you define GNU_USER_TARGET_NO_PTHREADS_LIB_SPEC to the main part of GNU_USER_TARGET_LIB_SPEC. GNU_USER_TARGET_LIB_SPEC now becomes '"%{pthread:-lpthread} " GNU_USER_TARGET_NO_PTHREADS_LIB_SPEC'.
2. In occurrences of LINUX_OR_ANDROID_LD you continue to use GNU_USER_TARGET_LIB_SPEC for the first argument and 'GNU_USER_TARGET_NO_PTHREADS_LIB_SPEC " " ANDROID_LIB_SPEC' for the second argument.
This way you are operating with named macros instead of verbatim "%{pthread:-lpthread}", and, hopefully, this will be more clear to an outside observer.
>
> Please see modified patch attached.
> I've built all 3 Android compilers, x86_64 and i686 and ran simple
> test with -pthread.
Thanks for good test coverage. I assume you have also tested a non-android Linux target?
The patch is OK if adjusted to the comments above (or good arguments provided why your current patch is more straigh-forward).
Thank you,
--
Maxim Kuvyrkov
www.kugelworks.com