一些开源软件的configure程序不会为用户提供编译器相关的细粒度控制,就像我用gcc-3.4.3这种老掉牙来编译alsa-sound库,给了一段莫名其妙的错误:
../src/.libs/libasound.a(pcm_dmix.o): In function `snd_pcm_dmix_sync_ptr': pcm_dmix.c:(.text+0x2550): warning: Warning: snd_pcm_hwsync() is deprecated, consider to use snd_pcm_avail() ../src/.libs/libasound.a(error.o): In function `snd_lib_error_set_local': error.c:(.text+0xb4): undefined reference to `__aeabi_read_tp' error.c:(.text+0xc4): undefined reference to `__aeabi_read_tp' ../src/.libs/libasound.a(error.o): In function `snd_lib_error_default': error.c:(.text+0x110): undefined reference to `__aeabi_read_tp' error.c:(.text+0x124): undefined reference to `__aeabi_read_tp' collect2: ld returned 1 exit status
snd_local_error_handler_t snd_lib_error_set_local(snd_local_error_handler_t func) { snd_local_error_handler_t old = local_error; local_error = func; return old; }
只好回去仔细查看函数中的那三行代码,终于找到了蛛丝马迹,对于local_error有如下定义:
#ifndef DOC_HIDDEN #ifdef HAVE___THREAD #define TLS_PFX __thread #else #define TLS_PFX /* NOP */ #endif #endif
(简单的去掉__thread是能通过编译,但还是要手动实现相关数据的tls才能保证程序的行为不变)