- 所有 tcc 文件/内容/宏改名为 pcc (tcc.c->pcc.c, tccelf.c->pccelf.c, libtcc.c->libpcc.c 等) - 支持架构: i386, x86_64, ARM, ARM64, RISC-V, C67 - 支持格式: PE, ELF, Mach-O, COFF - 完整预处理、代码生成、链接器、调试信息 - 构建成功: pcc.exe (x86_64 Windows) - 功能测试通过: 递归/结构体/浮点/switch/循环 - 自编译测试通过: pcc 可以编译自身
49 行
862 B
C
49 行
862 B
C
#include <stdio.h>
|
|
|
|
#if (defined _WIN32 || defined __APPLE__) && (!defined __TINYC__ || defined __leading_underscore)
|
|
# define _ "_"
|
|
#else
|
|
# define _
|
|
#endif
|
|
|
|
#ifdef __clang__
|
|
/* clang needs some help tp not throw functions away even at -O0 */
|
|
#define __USED __attribute__((__used__))
|
|
#else
|
|
#define __USED
|
|
#endif
|
|
|
|
int x3(void)
|
|
{
|
|
printf(" x3");
|
|
return 3;
|
|
}
|
|
|
|
/* That callx4 is defined globally (as if ".globl callx4")
|
|
is a PCC extension. GCC doesn't behave like this. */
|
|
void callx4(void);
|
|
#if __i386__
|
|
__asm__(_"callx4: call "_"x4; ret;"
|
|
#else
|
|
/* Keep stack aligned */
|
|
__asm__(_"callx4: sub $8,%rsp; call "_"x4; add $8,%rsp; ret;"
|
|
#endif
|
|
#ifndef __TINYC__
|
|
" .global "_"callx4"
|
|
#endif
|
|
);
|
|
|
|
extern void x5(void);
|
|
|
|
void callx5_again(void);
|
|
void callx5_again(void)
|
|
{
|
|
x5();
|
|
asm("call "_"x6");
|
|
}
|
|
|
|
static void __USED x6()
|
|
{
|
|
printf(" x6-2");
|
|
}
|