Comment #20 on issue 188 by liuj...@google.com: protobuf fails to link after compiling with LDFLAGS="-Wl,--as-needed" because of missing -lpthread
http://code.google.com/p/protobuf/issues/detail?id=188

Thanks Xarthisius and Monty.

Xarthisius, your patch seems to be examining if it works under -nostdlib. I think if the -nostdlib is actually set in the CFLAGS before running the acx_pthread.m4(set when running configure), the existing loops(checks) in acx_pthread.m4 should be able to catch and add -lpthread.

Back to this issue, when we set LDFLAGS='--as-needed', the acx_pthread.m4 can try_link successful without -lpthread, but failed to link libprotobuf.

The test code to link in the current acx_pthread.m4 is:

pthread_t th; pthread_join(th, 0);
pthread_attr_init(0); pthread_cleanup_push(0, 0);
pthread_create(0,0,0,0); pthread_cleanup_pop(0);

So I think these 3 lines' test isn't enough.. A more direct fix is changing this to the way protobuf uses pthread(in common.cc, once.cc). So that if the the ACX_TRY_LINK succeeds, the libprotobuf will link successful(for pthread).

From the log, it seems the pthread_once is the problem "the linker in Drizzle said the pthread_once is not defined". So maybe we can just add pthread_once related stuffs to the exisiting 3 lines test?

BTW, Monty, the patch you mentioned doesn't seem right to me. It just bypasses the "whether -pthread is sufficient with -shared" block. Before the patch, -pthread is sufficient with -shared already, but the patch skipped that block, so it has the chance to try -lpthread, which is also sufficient with -shared, and happened to fix the Drizzle problem.


--
You received this message because you are subscribed to the Google Groups "Protocol 
Buffers" group.
To post to this group, send email to proto...@googlegroups.com.
To unsubscribe from this group, send email to 
protobuf+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/protobuf?hl=en.

Reply via email to