ルギア君の戯言

雑多な記事。

Linuxに

もどってきた。

それにしてもかなり重くなったなぁ。

f:id:lugia:20140110225029p:plain

えーと、うちの子は NVIDIAGeForce 7100 なので、NVIDIAプロプライエタリなドライバを使う場合、304.xx 以下じゃないといけないわけです。

結構長い間 304.88 のままだったから、kernel 3.12.x になった時にカーネルモジュールがビルドできなくなって、もうサポートされなくなるなと思って OpenIndiana を使っていたんだけど、

そんなことはなかったぜ…みたいな。

…と言っても、現時点でもベータ版の方を見に行かないとないけど。

ちなみに、うちの環境では nouveau-1.0.9 のドライバで 3D を表示させると見るに耐えない映像になる (か、クラッシュする) のでプロプライエタリなドライバを使っているのはそういう理由であります。 (ちなみに 3D と言っても Minecraft ではなくて…)

TeX のパッケージングの続きでもやりますかな。

LLVM on OpenIndiana

ことの始まりは、Qt のビルドから。 一応、gcc-4.8.2 ではビルドできたし、qtconfig などはちゃんと動いている。OpenGL でプログラムを作成する用事があった (実際には Qt ではなく Windows Forms なのだが…) ので、その Qt で練習していた分には問題なかった。しかし、desingerqtdemo は動かなかった。

$ /opt/kde/bin/designer
Segmentation Fault (core dumped)

何が原因かよく分からないので、clang でもビルドしてみることにした (Qt では clang でのビルドは unsupported 扱いになっているが…)。

その辺はあくまで発見した経緯で、問題になったのは次のソースを C++ としてコンパイルした場合。

#include <stdlib.h>
#include <math.h>

int main() {
    return 0;
}

もちろん(?)、g++ では問題なく通る。これを clang++ でコンパイルすると、…

/usr/include/floatingpoint.h:204:15: error: declaration conflicts with target of
      using declaration already in scope
extern double atof __P((const char *));
              ^
/usr/include/iso/stdlib_iso.h:124:15: note: target of using declaration
extern double atof(const char *);
              ^
/usr/include/stdlib.h:52:12: note: using declaration
using std::atof;
           ^

(atof のほか strtod に対しても出る)

ちなみに、stdlib.hcstdlibmath.hcmath としても変わらず (libstdc++libc++ ともに)。

また、stdlib.hmath.h の include 順を変えた場合は通る。

何が問題って、何で math.h (の中の floatingpoint.h) で atof (や strtod) を宣言しているのかっていう点と、cstdlib でもないのに、std::atofstd 名前空間の中に閉じ込めて using で global からも呼び出せるようにしているのかという点。

ちなみに、string.hsys/socket.h でも起こる。

どちらも __EXTENSIONS__ の定義が無ければ回避できるが、かなりの量の宣言が消えるので、たとえコンパイルが通ったとしても、それはそれで問題がある。

/opt/llvm/3.4/include/c++/v1/cstdio:148:9: error: no member named 'vfscanf' in
      the global namespace; did you mean 'fscanf'?
using ::vfscanf;
      ~~^

(※ vfscanfC++11 では宣言されているはずであるが、OpenIndiana では対応していない。)

だから、floatingpoint.h とか普通使わない拡張機能のヘッダを math.h を読む前にあらかじめ読んで、別の名前空間に入れてしまえば一応解決できる(?)。

#include <stdlib.h>

namespace _fp {
  extern "C" {
#include <floatingpoint.h>
  }
}
#include <math.h>

sys/socket.h の方はこんな感じ。

#include <string.h>

namespace _sys_un {
  extern "C" {
#include <sys/un.h>
  }
}
using _sys_un::sa_family_t;
#include <sys/socket.h>

ちなみに Qt では mutex という名前の変数 (QMutex 型) を使っているが、sys/mutex.h で構造体の名前として使われているため、それの回避も。

namespace _sys_mut {
  extern "C" {
#include <sys/mutex.h>
  }
}
using _sys_mut::kmutex_t;

あれ、でもそれって本来問題ない様な…

LLVM

LLVM (clang) がなんかホットみたいだから、 OpenIndiana で clang をビルドしてやろうと思って、ビルドしてて何か不思議なエラーが大量にでるなと思ったら、変な定数が define されてた。

*1

#include <cstdlib>

int main(void) {
  return ES;
}
$ g++ -o a a.cpp -Wl,-R/opt/gcc/4.8.2/lib
$ ./a
$ echo $?
2
#include <cstdlib>
#define ES ES

int main(void) {
  return ES;
}
$ g++ -o a a.cpp -Wl,-R/opt/gcc/4.8.2/lib
a.cpp:2:0: warning: "ES" redefined [enabled by default]
 #define ES ES
 ^
In file included from /usr/include/sys/ucontext.h:36:0,
                 from /usr/include/sys/signal.h:245,
                 from /usr/include/sys/procset.h:42,
                 from /usr/include/sys/wait.h:43,
                 from /usr/include/stdlib.h:38,
                 from /opt/gcc/4.8.2/include/c++/4.8.2/cstdlib:72,
                 from a.cpp:1:
/usr/include/sys/regset.h:111:0: note: this is the location of the previous definition
 #define ES  2
 ^
(以下略)

あんなところに定義されているのか。付近のソースを読んだところ、__EXTENSIONS__ を undef しておけば大丈夫だろう*2

ちなみに Solaris Studio の C++ コンパイラ CC では cstdlib が stdlib.h を読み込む形になっていないだけでなく、__EXTENSIONS__も定義していない様です。

$ CC -o a a.cpp
"a.cpp", 行 4: エラー: ES は定義されていません.
1 個のエラーが検出されました.


PS: make clang-test で Abort が頻発しているので、再コンパイルだな。

*1:gcc 4.8.2 は自分でビルドしたもの

*2:http://www.silversoft.net/docs/standards.html

Trying to build KDE on OpenIndiana - Part 1

I just want to use KDE!

I searched, but I couldn't get information about this.

This is my memo to remeber what I did. So some details may be omitted.

I'm not good at English.

Environment

  • HARDWARE
    • Intel Core 2 Duo 2.53 GHz (I'm not sure how long takes to compile KDE.)
    • 4GB memory.
    • NVIDIA GeForce 7 (NVIDIA seems that they dropped the support of 304.xx driver for the newest Linux (3.10.xx or later), and the nouveau driver was useless for me*1.)
  • SOFTWARE
    • OpenIndiana 151.1.8 x86 (Build KDE as 64 bit application)
    • Solaris Studio 12.3 (Even GCC of recent version for OpenIndiana is in development. So I used stable compiler. I won't (re)distribute the executables of KDE.)

Build Qt-4.8.5

  1. Download source.
  2. Fix source.

    Line 899 in qt-everywhere-opensource-src-4.8.5/src/gui/dialogs/qfiledialog.cpp, getpwnum_r in OI151 is defined as conformed to POSIX, Qt detects as Solaris OS and _POSIX_C_SOURCE is not defined.

    err = getpwnam_r(userName.toLocal8Bit().constData(), &pw, buf, bufSize, &tmpPw);
    
  3. CC=cc CXX=CC CFLAGS="-xarch=sse3 -m64 -O5" CXXFLAGS="-xarch=sse3 -m64" LDFLAGS="-xarch=sse3 -m64" ./configure --prefix=/opt/kde
    
    • -O5 option seems ignored. Because they use -O2.
  4. gmake and pray for all.
  5. gmake install

Build CMake-2.8.12

  1. Download source.
  2. Fix source.

    CMake configure detects that OI have the function backtrace_symbols, but at the line 1383 in cmake-2.8.12/Source/kwsys/SystemInformation.cxx they use that function without including execinfo.h. Workaround fix is to add #include <execinfo.h> somewhere in global scope before that line.

  3.  CC=cc CXX=CC CFLAGS="-xarch=sse3 -m64 -O5" CXXFLAGS="-xarch=sse3 -m64" LDFLAGS="-xarch=sse3 -m64" ./configure --prefix=/opt/kde
    
  4. gmake and pray for all.
  5. gmake install

*2

*1:3D applications still does not work?

*2:PS: Solaris 11 seems to have KDE.

コバルオンの話

  • 先回りをして行動するのだ!
  • 働かざる者 食うべからず!
  • 立ち止まってはならない!
  • あいさつに はじまって あいさつに おわる!
  • 同じ まちがいを くりかえさない!
  • さらに高みをめざすのだ!
  • かんたんに あきらめてはいけない!
  • かんしゃの心を 大切に!
  • ときには 休むことも ひつようだ!
  • たくわえを たやすな!
  • コツコツ努力を!
  • さぁ! いざ 進むのだ!
  • いつでも準備は できている!
  • 「リーダー」についてゆこうぞ!
  • なにも おそれることは ない!
  • 強い敵は わたしにまかせろ!

当たり前のことではありますが。