[英]How small can I make a clang executable?
I'm just testing to see how small I can make this C++ code我只是测试看看我能把这个 C++ 代码做多小
#include <iostream>
using namespace std;
int main() {
cout << "hi";
}
using this zsh command:使用这个 zsh 命令:
g++ test.cpp -Os -g -o main
but the smallest I can make it is 52 Kb, so is there any way to make it even smaller?但是我能做到的最小的是 52 Kb,那么有没有办法让它更小呢?
Using your code and compiler flags with g++ 11.2
I get a 35,8kB executable (different result could be explained by using a different compiler version or target system).将您的代码和编译器标志与
g++ 11.2
一起使用,我得到一个35,8kB的可执行文件(可以通过使用不同的编译器版本或目标系统来解释不同的结果)。
-g
flag brings the output file's size down to 16,3kB .-g
标志会使 output 文件的大小降至16,3kB 。#include <stdio.h>
int main(){
fputs("hi", stdout);
return 0; // doesn't change the output, only here for completeness sake
}
Using clang
to compile above code further reduces output executable's size to 15,9kB .使用
clang
编译上述代码进一步将 output 可执行文件的大小减少到15,9kB 。
Adding the -s
flag: 14,5kB添加
-s
标志: 14,5kB
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.