一些開源軟體的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;}
看似沒有那些asm之類的代碼。google一通,看到有個拽人搞了個__aeabi_read_tp空函數解決了 *_*
只好回去仔細查看函數中的那三行代碼,終於找到了蛛絲馬跡,對於local_error有如下定義:
#ifndef DOC_HIDDEN#ifdef HAVE___THREAD#define TLS_PFX__thread#else#define TLS_PFX/* NOP */#endif#endif
看來是使用的編譯器不支援執行緒區域儲存關鍵字,而軟體包帶來的configure竟然也沒有這個控制選項。只好手動修改configure產生的config.h檔案。
(簡單的去掉__thread是能通過編譯,但還是要手動實現相關資料的tls才能保證程式的行為不變)