如何编辑和重新构建 GCC libstdc++ C++ 标准库源代码?

2021-12-30 00:00:00 gcc parallel-processing c++ stl libstdc++

我正在进行一些研究,想编辑 libstdc++ 库中的一些源代码以进行实验.我特别有兴趣尝试并行排序算法.有没有地方可以找到文档来轻松编辑和构建源代码?

I am working on some research and would like to edit some of the source code in the libstdc++ library for experimentation. I am, specifically, interested in experimenting with the parallel sorting algorithms. Is there a place I can find documentation to easily edit and build the source code?

我尝试构建各种版本的 libstdc++ 库,但没有成功.似乎大多数新版本都需要构建整个 gcc 包,这是一个漫长得多的过程,尤其是当我要在 libstdc++ 中编辑和试验一些文件时.

I have tried, unsuccessfully, to build various versions of the libstdc++ library. It seems like most new versions require building the entire gcc package, which is a much more lengthy process, especially if I am going to be editing and experimenting with a few files in libstdc++.

我也找不到包含并行排序算法的源文件.我似乎只能找到定义函数的头文件,而不是源代码本身.任何建议或文档链接将不胜感激.

I have also been unable to find the source files that contain the parallel sorting algorithms. I can only seem to find the header files that define the functions, and not the source code itself. Any advice or links to documentation would be greatly appreciated.

推荐答案

是的,您必须构建整个 GCC,但是一旦完成,您只需要重新构建 libstdc++ 部分.

Yes, you have to build the whole of GCC, but once you've done that you only need to rebuild the libstdc++ part.

在http://gcc.gnu.org/wiki/InstallingGCC

libstdc++ 源代码位于 libstdc++-v3 目录中.并行算法在 libstdc++-v3/include/parallel 中,它们是模板,因此所有代码都在标题中.少量非头代码在libstdc++-v3/src/c++98/parallel-settings.cc

The libstdc++ sources are in the libstdc++-v3 directory. The parallel algorithms are in libstdc++-v3/include/parallel, they are templates so all the code is in headers. The small amount of non-header code is in libstdc++-v3/src/c++98/parallel-settings.cc

在正常配置和构建整个 GCC 后,您可以通过在 $TARGET/libstdc++-v3 目录(其中 $TARGET 类似于 x86_64-pc-linux-gnu).

After configuring and building the whole of GCC as normal, you can rebuild libstdc++ by running make in the $TARGET/libstdc++-v3 directory (where $TARGET is something like x86_64-pc-linux-gnu).

默认情况下,makefile 没有正确的依赖关系,导致对象在标头更改后重建,因此您可能需要执行 make clean 然后再次执行 make 以获得您的更改将被接受.

By default the makefiles don't have proper dependencies that cause objects to be rebuilt after headers change, so you might need to do make clean then make again to get your changes to be picked up.

相关文章