How to force clang to use some library by default?

后端 未结 1 1506
故里飘歌
故里飘歌 2021-01-03 21:53

I build clang by clang against libc++, libc++abi, compiler-rt in the following steps:

  • To download (and update)

相关标签:
1条回答
  • 2021-01-03 22:03

    There are a couple of workarounds have been suggested. I ended up with the following workaround:

    mkdir build
    cd build
    # backup:
    cp -vaf /usr/local/lib/libc++.{a,so.1.0} /usr/local/lib/libc++abi.{a,so.1.0} /usr/local/lib/libunwind.{a,so.1.0} .
    clang -shared -fPIC -pthread -o fuse.so -Wl,--whole-archive libc++.a libc++abi.a libunwind.a -Wl,--no-whole-archive -ldl -lm
    ar x libc++.a
    ar x libc++abi.a
    ar x libunwind.a
    ar rc fuse.a *.o
    sudo chown root:root fuse.*
    sudo cp -vaf fuse.so /usr/local/lib/
    sudo ln -svf /usr/local/lib/libc++.so.1 /usr/local/lib/fuse.so
    sudo cp -vaf fuse.a /usr/local/lib/
    sudo mv -vf /usr/local/lib/libc++.a /usr/local/lib/libc++.a.bak
    sudo ln -svf /usr/local/lib/libc++.a /usr/local/lib/fuse.a
    

    It merges all the libraries used (libc++, libc++abi and libunwind) into the one single *.a or *.so file. Then libc++.a and libc++.so are replaced with (links to) resulting assemblied files, saving a previous versions for possible backup.

    It works perfectly for me.

    But this is not the answer. Maybe someday clang will not have such a problem right from the box.

    0 讨论(0)
提交回复
热议问题