回答我的问题:我们到底使出了一个匿名的命名空间和代码合并。
I.e.所有的cpp/c代码都使用一个庞大而相对复杂/丑陋的python脚本合并到大C文件中。 CPP文件中的所有函数都包装在一个匿名名称空间中,只将名称空间外的导出函数保留下来。
之后,在磁带库上做了一条-S -x清除了大部分垃圾。
I.e.
/************** AMALGAMATED CPP FILE **************/
/************** STD HEADERS **************/
#include "OurLibraryHeader.h"
#include <cmath>
#include <string>
// more standard includes here and includes that aren't possible to do in the anonymous namespace
/************** AMALGAM **************/
namespace {
#include "OneofOurheaders1.h"
#include "OneofOurheaders2.h"
#include "SomeExternalLib.h"
/************************* OneofOurImplementations.cpp *************************/
// included literally
/************************* OneofOurImplementations2.cpp *************************/
// included literally
// etc
}
int OneOfOurLibraryFunctions()
{
}
// etc
这是相当肮脏,但它完成工作。 我敢肯定有更好的方法与一些LLVM弄虚作假做到这一点...
这将是有趣的尝试......我想这涉及到更步骤得到的东西建立。下面描述的我的方法是通过完成构建并在之后剥离来实现的。 – 2013-02-18 16:01:21
额外的步骤是明确列出您的C API导出。 ld将除去exported_symbols_list中的符号之外的所有内容。可以说比将所有内容整合到一个文件中更可怕。 “ar”步骤只有在你想给某人一个“.a”而不是“.o” – mtoy 2013-03-29 17:19:52