[libdispatch-dev] linux + libdispatch + clang + blocks

David Leimbach leimy2k at gmail.com
Mon Jun 7 19:16:25 PDT 2010


 Oh well time to use a different libc?  I hear FreeBSD has a nice one!  :-)

On Monday, June 7, 2010, Mark Heily <mark at heily.com> wrote:
> I have been able to compile libdispatch on Linux with a blocks-enabled clang and ran into some issues. The biggest problem is <unistd.h> in the GNU libc declares a function which takes an argument named "__block" which causes an error when compiling with Clang. This has been reported as a bug to GNU and rejected by drepper@ as a WONTFIX bug.
>
> I'll submit some patches soon to address these issues, but see below for a list of what I encountered and the "fix" used to get it to work.
>
> Regards,
>
>  - Mark
>
>
>
> Build environment:
>
>   clang version 1.1 (branches/release_27)
>   Target: x86_64-pc-linux-gnu
>
> Build Commands:
>
>   cd ~/src/libdispatch
>   sh ./autogen.sh && CC=clang CFLAGS=-fPIC ./configure && make clean && make
>
> Problems:
>
> [1] __block used within unistd.h declaration
>
> In file included from ./internal.h:35:
> In file included from ../dispatch/dispatch.h:36:
> /usr/include/unistd.h:1128:35: error: __block attribute not allowed, only allowed on local
>       variables
> extern void encrypt (char *__block, int __edflag) __THROW __nonnull ((1));
>                                   ^
>
>         fix: edit unistd.h and remove the __block identifier
>
>         see: http://sources.redhat.com/bugzilla/show_bug.cgi?id=11157
>
>
> [2] two private_extern variables cause compile failures.
>
> /usr/bin/ld: .libs/libdispatch_la-queue_kevent.o: relocation R_X86_64_PC32 against symbol `_dispatch_safe_fork' can not be used when making a shared object; recompile with -fPIC
> /usr/bin/ld: final link failed: Bad value
>
>         fix: remove __private_extern__ from variable declarations
>
>
> [3] clang wants arc4random defined
>
>         fix: add u_int32_t arc4random(); to source
>
> [4] clang doesn't like __unused
>
> dispatch_after.c:32:21: error: expected ')'
> void done(void *arg __unused) {
>                     ^
> dispatch_after.c:32:10: note: to match this '('
> void done(void *arg __unused) {
>          ^
>
>         fix: delete this attribute
>
> [5] fabs() undefined symbol
>
> dispatch_drift.o: In function `__main_block_invoke_':
> dispatch_drift.c:(.text+0x529): undefined reference to `fabs'
>
>         fix: add -lm to testing/Makefile.am
>
>
> [6] fgetln() not declared
>
> summarize.c:69:8: warning: implicit declaration of function 'fgetln' is invalid in C99
>       [-Wimplicit-function-declaration]
>                 ln = fgetln(stdin, &len);
>
>         fix: add declaration: char *fgetln(FILE *fp, size_t *lenp);
>
> [7] Dispatch Source Read test failed
>
> ==================================================
> [TEST] Dispatch Source Read
> [PID] 8515
> ==================================================
>
>         Actual: 0x603200
>         Expected: 0x603200
> [PASS] dispatch_get_main_queue
>         Actual: 0x12dd010
>         Expected: 0x12dd010
> [PASS] DISPATCH_SOURCE_TYPE_READ
> bytes available: 1
> bytes read: 512000
> ^^^^^ hung here, process 8515 was defunct and I killed it manually
> /bin/bash: line 5:  8515 Terminated              ${dir}$tst
> FAIL: dispatch_read
>
>         fix: none as of yet
>
> _______________________________________________
> libdispatch-dev mailing list
> libdispatch-dev at lists.macosforge.org
> http://lists.macosforge.org/mailman/listinfo.cgi/libdispatch-dev
>


More information about the libdispatch-dev mailing list