Solaris10 で gcc の visibility を使う場合

Luaのコンパイルをしていて出くわしたのでメモ。

一言で言うと、Solaris10でgcc4以降でサポートのvisibilityを使う場合は、gccのビルド時にobjdump(binutilsに含まれる)が必要かもというお話です。
# gcc4.4.2くらいはまだ無くても良いです。また、どこか上位バージョンでも不要になっているかもしれませんが、調べてません。
visibility はこんなもののようです。
 http://gcc.gnu.org/wiki/Visibility
 http://d.hatena.ne.jp/pyopyopyo/20050402/p1



出くわした流れを後はつらつらと。。。。
まず、luaconf.hに __attribute__((visibility("hidden"))) の記述があります。
visibility が有効でない場合、ビルド時に↓の警告が盛大に出ます。
「warning: visibility attribute not supported in this configuration; ignored」

対応方法はこんなもんでしょうか。
1)visibility対応したgccでビルドする
2)luaconf.h のLUAI_FUNCからvisibilityを外す
3)警告なんで無視する

で、1)を採用する場合ですが、visibilityを有効にするかどうかはgcc/configureで行っているようです。
コメントに条件も書いてあります。具体的には gcc_cv_as_hidden/gcc_cv_ld_hidden 両方yesになれば良いです。

# .hidden needs to be supported in both the assembler and the linker,
# because GNU LD versions before 2.12.1 have buggy support for STV_HIDDEN.
# This is irritatingly difficult to feature test for; we have to check the
# date string after the version number. If we've got an in-tree
# ld, we don't know its patchlevel version, so we set the baseline at 2.13
# to be safe.
# The gcc_GAS_CHECK_FEATURE call just sets a cache variable.

で、Solarisの場合の判定方法がgcc-4.4.6ではこうなってました。(一部抜粋)

if $gcc_cv_as -o conftest.o conftest.s > /dev/null 2>&1 \
&& $gcc_cv_objdump -t conftest.o 2>/dev/null | \
grep '\.hidden default' > /dev/null; then
gcc_cv_as_hidden=no
else
gcc_cv_as_hidden=yes
fi

ということで、objdump を使って内容判定している箇所があるため、
無いと gcc_cv_as_hidden=no になってvisibilityが有効にならないという感じでした。
この程度で半日くらいつぶれてしまったあたり、だめだめです。